mp-holistic
Version:
si prefigge l'umile compito di aiutare nella creazione di : - un server API REST mediante express - un semplice ORM per Postgres Questo tramite decoratori o classi particolari.
71 lines • 3.3 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Policy = exports.ListaPolicy = void 0;
const classe_postgres_1 = require("./classe.postgres");
class ListaPolicy extends Array {
constructor(item, nomeTabella) {
super();
if (item) {
for (let index = 0; index < item.length; index++) {
const element = item[index];
element.tabellaDestinazione = nomeTabella;
this.push(new Policy(element));
}
}
if (nomeTabella)
this.nomeTabella = nomeTabella;
else
this.nomeTabella = '';
}
CostruiscePolicySicurezza(/* client: Client */ elencoQuery) {
let ritorno = '';
for (let index = 0; index < this.length; index++) {
const element = this[index];
const tmp = element.CostruiscePolicySicurezza(elencoQuery, this.nomeTabella);
ritorno = ritorno + '' + tmp;
}
return ritorno;
}
}
exports.ListaPolicy = ListaPolicy;
class Policy {
constructor(item) {
this.nomePolicy = item.nomePolicy;
this.tabellaDestinazione = item.tabellaDestinazione;
this.ruoli = item.ruoli;
this.azieneScatenente = item.azieneScatenente;
this.using = item.using;
this.check = item.check;
this.typeFunctionCheck = item.typeFunctionCheck;
this.typeFunctionUsing = item.typeFunctionUsing;
this.nomeFunzioneCheck = item.nomeFunzioneCheck;
this.nomeFunzioneUsing = item.nomeFunzioneUsing;
}
CostruiscePolicySicurezza(/* client: Client */ elencoQuery, nomeTabella) {
var _a, _b, _c, _d;
let ritorno = '';
const ruolitesto = (0, classe_postgres_1.CostruisciRuoli)(this.ruoli);
const nomeFunzioneCK = (0, classe_postgres_1.CostruisciFunzione)(this.check, (_a = this.nomeFunzioneCheck) !== null && _a !== void 0 ? _a : '', this.nomePolicy, (_b = this.typeFunctionCheck) !== null && _b !== void 0 ? _b : 'psql', 'CK', elencoQuery);
const nomeFunzioneUS = (0, classe_postgres_1.CostruisciFunzione)(this.using, (_c = this.nomeFunzioneUsing) !== null && _c !== void 0 ? _c : '', this.nomePolicy, (_d = this.typeFunctionUsing) !== null && _d !== void 0 ? _d : 'psql', 'US', elencoQuery);
try {
//COMMENT ON FUNCTION "FN_${this.nomeFunzione}"() IS 'Hei tanto roba questa è scritta usando plv8!!';
const queri1 = `
CREATE POLICY "PO_MP_${this.nomePolicy}"
ON "${nomeTabella}"
FOR ${this.azieneScatenente}
TO ${ruolitesto}
${this.using && nomeFunzioneUS != "" ? 'USING "' + nomeFunzioneUS + '"()' : ''}
${this.check && nomeFunzioneCK != "" ? 'WITH CHECK ("' + nomeFunzioneCK + '"())' : ''}
;
`;
ritorno = ritorno + '\n' + queri1 + '\n';
elencoQuery.push(queri1);
}
catch (error) {
console.log('\n*****\n' + error + '\n********\n\n');
}
return ritorno;
}
}
exports.Policy = Policy;
//# sourceMappingURL=policy.js.map