prostgles-server 2.0.145 → 2.0.148
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AuthHandler.d.ts +15 -13
- package/dist/AuthHandler.d.ts.map +1 -1
- package/dist/AuthHandler.js +43 -44
- package/dist/AuthHandler.js.map +1 -1
- package/dist/DBEventsManager.d.ts +6 -5
- package/dist/DBEventsManager.d.ts.map +1 -1
- package/dist/DBEventsManager.js +8 -2
- package/dist/DBEventsManager.js.map +1 -1
- package/dist/DboBuilder.d.ts +54 -50
- package/dist/DboBuilder.d.ts.map +1 -1
- package/dist/DboBuilder.js +275 -206
- package/dist/DboBuilder.js.map +1 -1
- package/dist/FileManager.d.ts +5 -5
- package/dist/FileManager.d.ts.map +1 -1
- package/dist/FileManager.js +59 -31
- package/dist/FileManager.js.map +1 -1
- package/dist/Filtering.d.ts.map +1 -1
- package/dist/Filtering.js +17 -14
- package/dist/Filtering.js.map +1 -1
- package/dist/PostgresNotifListenManager.d.ts +3 -3
- package/dist/PostgresNotifListenManager.d.ts.map +1 -1
- package/dist/PostgresNotifListenManager.js +7 -5
- package/dist/PostgresNotifListenManager.js.map +1 -1
- package/dist/Prostgles.d.ts +6 -9
- package/dist/Prostgles.d.ts.map +1 -1
- package/dist/Prostgles.js +125 -86
- package/dist/Prostgles.js.map +1 -1
- package/dist/PubSubManager.d.ts +8 -8
- package/dist/PubSubManager.d.ts.map +1 -1
- package/dist/PubSubManager.js +58 -52
- package/dist/PubSubManager.js.map +1 -1
- package/dist/QueryBuilder.d.ts +21 -8
- package/dist/QueryBuilder.d.ts.map +1 -1
- package/dist/QueryBuilder.js +179 -107
- package/dist/QueryBuilder.js.map +1 -1
- package/dist/SyncReplication.js +38 -35
- package/dist/SyncReplication.js.map +1 -1
- package/dist/TableConfig.d.ts +0 -1
- package/dist/TableConfig.d.ts.map +1 -1
- package/dist/TableConfig.js +36 -28
- package/dist/TableConfig.js.map +1 -1
- package/dist/shortestPath.d.ts.map +1 -1
- package/dist/shortestPath.js +2 -1
- package/dist/shortestPath.js.map +1 -1
- package/dist/utils.d.ts +2 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +7 -0
- package/dist/utils.js.map +1 -1
- package/lib/AuthHandler.ts +50 -40
- package/lib/DBEventsManager.ts +14 -7
- package/lib/DboBuilder.ts +265 -199
- package/lib/FileManager.ts +30 -21
- package/lib/Filtering.ts +19 -16
- package/lib/PostgresNotifListenManager.ts +11 -10
- package/lib/Prostgles.ts +89 -73
- package/lib/PubSubManager.ts +13 -11
- package/lib/QueryBuilder.ts +128 -55
- package/lib/SyncReplication.ts +10 -10
- package/lib/TableConfig.ts +23 -15
- package/lib/shortestPath.ts +6 -4
- package/lib/utils.ts +7 -1
- package/package.json +8 -9
- package/tests/client/PID.txt +1 -1
- package/tests/client/index.js +10 -7
- package/tests/client/index.ts +12 -8
- package/tests/client/package-lock.json +14 -14
- package/tests/client/package.json +2 -2
- package/tests/client/tsconfig.json +2 -2
- package/tests/client_only_queries.js +127 -104
- package/tests/client_only_queries.ts +43 -17
- package/tests/isomorphic_queries.js +43 -6
- package/tests/isomorphic_queries.ts +41 -6
- package/tests/server/package-lock.json +29 -31
- package/tests/server/package.json +2 -2
- package/tests/server/tsconfig.json +2 -2
- package/tsconfig.json +3 -2
package/dist/Prostgles.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Prostgles.d.ts","sourceRoot":"","sources":["../lib/Prostgles.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Prostgles.d.ts","sourceRoot":"","sources":["../lib/Prostgles.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,SAAS,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,GAAG,QAAQ,iCAAiC,CAAC,CAAC;AACvD,OAAO,WAAW,EAAE,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAIjF,OAAO,WAA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E,WAAW,EAAE,EAAE,QAAQ,EAAE,UAAU,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC;IAoJnG,oBAAoB,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC;CA8E9D;AAeD,wBAAsB,WAAW,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAE1D"}
|
package/dist/Prostgles.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Licensed under the MIT License. See LICENSE in the project root for license information.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.isSuperUser = exports.PublishParser = exports.
|
|
7
|
+
exports.isSuperUser = exports.PublishParser = exports.Prostgles = exports.JOIN_TYPES = void 0;
|
|
8
8
|
const promise = require("bluebird");
|
|
9
9
|
const pgPromise = require("pg-promise");
|
|
10
10
|
const FileManager_1 = require("./FileManager");
|
|
@@ -18,36 +18,40 @@ const DboBuilder_1 = require("./DboBuilder");
|
|
|
18
18
|
const PubSubManager_1 = require("./PubSubManager");
|
|
19
19
|
const prostgles_types_1 = require("prostgles-types");
|
|
20
20
|
const DBEventsManager_1 = require("./DBEventsManager");
|
|
21
|
-
|
|
21
|
+
const TABLE_METHODS = ["update", "find", "findOne", "insert", "delete", "upsert"];
|
|
22
22
|
function getDbConnection(dbConnection, options, debugQueries = false, onNotice) {
|
|
23
|
-
let pgp = pgPromise(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
23
|
+
let pgp = pgPromise({
|
|
24
|
+
promiseLib: promise,
|
|
25
|
+
...(debugQueries ? {
|
|
26
|
+
query: function (e) {
|
|
27
|
+
console.log({ psql: e.query, params: e.params });
|
|
28
|
+
},
|
|
29
|
+
} : {}),
|
|
30
|
+
...((onNotice || debugQueries) ? {
|
|
31
|
+
connect: function (client, dc, isFresh) {
|
|
32
|
+
if (isFresh && !client.listeners('notice').length) {
|
|
33
|
+
client.on('notice', function (msg) {
|
|
34
|
+
if (onNotice) {
|
|
35
|
+
onNotice(msg, (0, utils_1.get)(msg, "message"));
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
console.log("notice: %j", (0, utils_1.get)(msg, "message"));
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
if (isFresh && !client.listeners('error').length) {
|
|
43
|
+
client.on('error', function (msg) {
|
|
44
|
+
if (onNotice) {
|
|
45
|
+
onNotice(msg, (0, utils_1.get)(msg, "message"));
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
console.log("error: %j", (0, utils_1.get)(msg, "message"));
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
} : {})
|
|
54
|
+
});
|
|
51
55
|
pgp.pg.defaults.max = 70;
|
|
52
56
|
// /* Casts count/sum/max to bigint. Needs rework to remove casting "+count" and other issues; */
|
|
53
57
|
// pgp.pg.types.setTypeParser(20, BigInt);
|
|
@@ -69,7 +73,6 @@ const DEFAULT_KEYWORDS = {
|
|
|
69
73
|
const fs = require("fs");
|
|
70
74
|
class Prostgles {
|
|
71
75
|
constructor(params) {
|
|
72
|
-
var _a, _b, _c;
|
|
73
76
|
this.opts = {
|
|
74
77
|
DEBUG_MODE: false,
|
|
75
78
|
dbConnection: {
|
|
@@ -97,8 +100,7 @@ class Prostgles {
|
|
|
97
100
|
this.isSuperUser = false;
|
|
98
101
|
this.connectedSockets = [];
|
|
99
102
|
this.pushSocketSchema = async (socket) => {
|
|
100
|
-
|
|
101
|
-
let auth = await ((_a = this.authHandler) === null || _a === void 0 ? void 0 : _a.makeSocketAuth(socket)) || {};
|
|
103
|
+
let auth = await this.authHandler?.makeSocketAuth(socket) || {};
|
|
102
104
|
// let needType = this.publishRawSQL && typeof this.publishRawSQL === "function";
|
|
103
105
|
// let DATA_TYPES = !needType? [] : await this.db.any("SELECT oid, typname FROM pg_type");
|
|
104
106
|
// let USER_TABLES = !needType? [] : await this.db.any("SELECT relid, relname FROM pg_catalog.pg_statio_user_tables");
|
|
@@ -107,7 +109,7 @@ class Prostgles {
|
|
|
107
109
|
let rawSQL = false;
|
|
108
110
|
const { dbo, db, pgp, publishParser } = this;
|
|
109
111
|
try {
|
|
110
|
-
schema = await publishParser
|
|
112
|
+
schema = await publishParser?.getSchemaFromPublish(socket);
|
|
111
113
|
}
|
|
112
114
|
catch (e) {
|
|
113
115
|
publishValidationError = "Server Error: PUBLISH VALIDATION ERROR";
|
|
@@ -118,17 +120,17 @@ class Prostgles {
|
|
|
118
120
|
/* RUN Raw sql from client IF PUBLISHED
|
|
119
121
|
*/
|
|
120
122
|
let fullSchema = [];
|
|
121
|
-
let allTablesViews = this.dboBuilder.tablesOrViews;
|
|
123
|
+
let allTablesViews = this.dboBuilder.tablesOrViews ?? [];
|
|
122
124
|
if (this.opts.publishRawSQL && typeof this.opts.publishRawSQL === "function") {
|
|
123
125
|
const canRunSQL = async () => {
|
|
124
|
-
const publishParams = await this.publishParser
|
|
125
|
-
let res = await this.opts.publishRawSQL(publishParams);
|
|
126
|
+
const publishParams = await this.publishParser?.getPublishParams({ socket });
|
|
127
|
+
let res = await this.opts.publishRawSQL?.(publishParams);
|
|
126
128
|
return Boolean(res && typeof res === "boolean" || res === "*");
|
|
127
129
|
};
|
|
128
130
|
if (await canRunSQL()) {
|
|
129
131
|
socket.removeAllListeners(prostgles_types_1.CHANNELS.SQL);
|
|
130
132
|
socket.on(prostgles_types_1.CHANNELS.SQL, async ({ query, params, options }, cb = (...callback) => { }) => {
|
|
131
|
-
if (!this.dbo
|
|
133
|
+
if (!this.dbo?.sql)
|
|
132
134
|
throw "Internal error: sql handler missing";
|
|
133
135
|
this.dbo.sql(query, params, options, { socket }).then(res => {
|
|
134
136
|
cb(null, res);
|
|
@@ -157,9 +159,17 @@ class Prostgles {
|
|
|
157
159
|
}
|
|
158
160
|
});
|
|
159
161
|
}
|
|
160
|
-
const methods = await publishParser
|
|
161
|
-
socket.emit(prostgles_types_1.CHANNELS.SCHEMA,
|
|
162
|
-
|
|
162
|
+
const methods = await publishParser?.getMethods(socket);
|
|
163
|
+
socket.emit(prostgles_types_1.CHANNELS.SCHEMA, {
|
|
164
|
+
schema,
|
|
165
|
+
methods: (0, DboBuilder_1.getKeys)(methods),
|
|
166
|
+
...(fullSchema ? { fullSchema } : {}),
|
|
167
|
+
rawSQL,
|
|
168
|
+
joinTables: joinTables2,
|
|
169
|
+
auth,
|
|
170
|
+
version,
|
|
171
|
+
err: publishValidationError
|
|
172
|
+
});
|
|
163
173
|
};
|
|
164
174
|
if (!params)
|
|
165
175
|
throw "ProstglesInitOptions missing";
|
|
@@ -179,11 +189,14 @@ class Prostgles {
|
|
|
179
189
|
}
|
|
180
190
|
Object.assign(this.opts, params);
|
|
181
191
|
/* set defaults */
|
|
182
|
-
if (
|
|
183
|
-
this.opts.fileTable.tableName =
|
|
192
|
+
if (this.opts?.fileTable) {
|
|
193
|
+
this.opts.fileTable.tableName = this.opts?.fileTable?.tableName || "media";
|
|
184
194
|
}
|
|
185
195
|
this.opts.schema = this.opts.schema || "public";
|
|
186
|
-
this.keywords =
|
|
196
|
+
this.keywords = {
|
|
197
|
+
...DEFAULT_KEYWORDS,
|
|
198
|
+
...params.keywords,
|
|
199
|
+
};
|
|
187
200
|
}
|
|
188
201
|
get dboBuilder() {
|
|
189
202
|
if (!this._dboBuilder)
|
|
@@ -194,8 +207,7 @@ class Prostgles {
|
|
|
194
207
|
this._dboBuilder = d;
|
|
195
208
|
}
|
|
196
209
|
isMedia(tableName) {
|
|
197
|
-
|
|
198
|
-
return ((_b = (_a = this.opts) === null || _a === void 0 ? void 0 : _a.fileTable) === null || _b === void 0 ? void 0 : _b.tableName) === tableName;
|
|
210
|
+
return this.opts?.fileTable?.tableName === tableName;
|
|
199
211
|
}
|
|
200
212
|
async onSchemaChange(event) {
|
|
201
213
|
const { watchSchema, onReady, tsGeneratedTypesDir } = this.opts;
|
|
@@ -296,7 +308,8 @@ class Prostgles {
|
|
|
296
308
|
this.isSuperUser = await isSuperUser(db);
|
|
297
309
|
}
|
|
298
310
|
this.checkDb();
|
|
299
|
-
const
|
|
311
|
+
const db = this.db;
|
|
312
|
+
const pgp = this.pgp;
|
|
300
313
|
/* 2. Execute any SQL file if provided */
|
|
301
314
|
if (this.opts.sqlFilePath) {
|
|
302
315
|
await this.runSQLFile(this.opts.sqlFilePath);
|
|
@@ -367,7 +380,6 @@ class Prostgles {
|
|
|
367
380
|
pgp,
|
|
368
381
|
io: this.opts.io,
|
|
369
382
|
destroy: async () => {
|
|
370
|
-
var _a;
|
|
371
383
|
console.log("destroying prgl instance");
|
|
372
384
|
this.destroyed = true;
|
|
373
385
|
if (this.opts.io) {
|
|
@@ -379,7 +391,7 @@ class Prostgles {
|
|
|
379
391
|
console.log("this.io.close");
|
|
380
392
|
}
|
|
381
393
|
}
|
|
382
|
-
|
|
394
|
+
this.dboBuilder?.destroy();
|
|
383
395
|
this.dbo = undefined;
|
|
384
396
|
this.db = undefined;
|
|
385
397
|
await db.$pool.end();
|
|
@@ -390,12 +402,13 @@ class Prostgles {
|
|
|
390
402
|
}
|
|
391
403
|
catch (e) {
|
|
392
404
|
console.trace(e);
|
|
405
|
+
// @ts-ignore
|
|
393
406
|
throw "init issues: " + e.toString();
|
|
394
407
|
}
|
|
395
408
|
}
|
|
396
409
|
async runSQLFile(filePath) {
|
|
397
410
|
const fileContent = await this.getFileText(filePath); //.then(console.log);
|
|
398
|
-
return this.db
|
|
411
|
+
return this.db?.multi(fileContent).then((data) => {
|
|
399
412
|
console.log("Prostgles: SQL file executed successfuly \n -> " + filePath);
|
|
400
413
|
return data;
|
|
401
414
|
}).catch((err) => {
|
|
@@ -447,13 +460,14 @@ class Prostgles {
|
|
|
447
460
|
socket.removeAllListeners(prostgles_types_1.CHANNELS.DEFAULT);
|
|
448
461
|
socket.on(prostgles_types_1.CHANNELS.DEFAULT, async ({ tableName, command, param1, param2, param3 }, cb = (...callback) => { }) => {
|
|
449
462
|
try { /* Channel name will only include client-sent params so we ignore table_rules enforced params */
|
|
450
|
-
if (!socket) {
|
|
451
|
-
console.error("socket missing??!!");
|
|
452
|
-
throw "socket missing??!!";
|
|
463
|
+
if (!socket || !this.authHandler || !this.publishParser || !this.dbo) {
|
|
464
|
+
console.error("socket or authhandler missing??!!");
|
|
465
|
+
throw "socket or authhandler missing??!!";
|
|
453
466
|
}
|
|
454
467
|
const clientInfo = await this.authHandler.getClientInfo({ socket });
|
|
455
468
|
let valid_table_command_rules = await this.publishParser.getValidatedRequestRule({ tableName, command, localParams: { socket } }, clientInfo);
|
|
456
469
|
if (valid_table_command_rules) {
|
|
470
|
+
//@ts-ignore
|
|
457
471
|
let res = await this.dbo[tableName][command](param1, param2, param3, valid_table_command_rules, { socket, has_rules: true });
|
|
458
472
|
cb(null, res);
|
|
459
473
|
}
|
|
@@ -469,8 +483,8 @@ class Prostgles {
|
|
|
469
483
|
}
|
|
470
484
|
});
|
|
471
485
|
socket.on("disconnect", () => {
|
|
472
|
-
this.dbEventsManager
|
|
473
|
-
this.dbEventsManager
|
|
486
|
+
this.dbEventsManager?.removeNotice(socket);
|
|
487
|
+
this.dbEventsManager?.removeNotify(undefined, socket);
|
|
474
488
|
this.connectedSockets = this.connectedSockets.filter(s => s.id !== socket.id);
|
|
475
489
|
// subscriptions = subscriptions.filter(sub => sub.socket.id !== socket.id);
|
|
476
490
|
if (this.opts.onSocketDisconnect) {
|
|
@@ -481,7 +495,7 @@ class Prostgles {
|
|
|
481
495
|
socket.removeAllListeners(prostgles_types_1.CHANNELS.METHOD);
|
|
482
496
|
socket.on(prostgles_types_1.CHANNELS.METHOD, async ({ method, params }, cb = (...callback) => { }) => {
|
|
483
497
|
try {
|
|
484
|
-
const methods = await this.publishParser
|
|
498
|
+
const methods = await this.publishParser?.getMethods(socket);
|
|
485
499
|
if (!methods || !methods[method]) {
|
|
486
500
|
cb("Disallowed/missing method " + JSON.stringify(method));
|
|
487
501
|
}
|
|
@@ -512,7 +526,7 @@ exports.Prostgles = Prostgles;
|
|
|
512
526
|
function makeSocketError(cb, err) {
|
|
513
527
|
const err_msg = (err instanceof Error) ?
|
|
514
528
|
err.toString() :
|
|
515
|
-
DboBuilder_1.isPlainObject(err) ?
|
|
529
|
+
(0, DboBuilder_1.isPlainObject)(err) ?
|
|
516
530
|
JSON.stringify(err, null, 2) :
|
|
517
531
|
err.toString(), e = { err_msg, err };
|
|
518
532
|
cb(e);
|
|
@@ -594,14 +608,13 @@ const RULE_TO_METHODS = [
|
|
|
594
608
|
];
|
|
595
609
|
// const ALL_PUBLISH_METHODS = ["update", "upsert", "delete", "insert", "find", "findOne", "subscribe", "unsubscribe", "sync", "unsync", "remove"];
|
|
596
610
|
// const ALL_PUBLISH_METHODS = RULE_TO_METHODS.map(r => r.methods).flat();
|
|
597
|
-
function flat(arr)
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
}
|
|
604
|
-
exports.flat = flat;
|
|
611
|
+
// export function flat(arr){
|
|
612
|
+
// // let res = arr.reduce((acc, val) => [ ...acc, ...val ], []);
|
|
613
|
+
// let res = arr.reduce(function (farr, toFlatten) {
|
|
614
|
+
// return farr.concat(Array.isArray(toFlatten) ? flat(toFlatten) : toFlatten);
|
|
615
|
+
// }, []);
|
|
616
|
+
// return res;
|
|
617
|
+
// }
|
|
605
618
|
class PublishParser {
|
|
606
619
|
constructor(publish, publishMethods, publishRawSQL, dbo, db, prostgles) {
|
|
607
620
|
this.publish = publish;
|
|
@@ -614,15 +627,21 @@ class PublishParser {
|
|
|
614
627
|
throw "INTERNAL ERROR: dbo and/or publish missing";
|
|
615
628
|
}
|
|
616
629
|
async getPublishParams(localParams, clientInfo) {
|
|
617
|
-
return
|
|
630
|
+
return {
|
|
631
|
+
...(clientInfo || await this.prostgles.authHandler?.getClientInfo(localParams)),
|
|
632
|
+
dbo: this.dbo,
|
|
633
|
+
db: this.db,
|
|
634
|
+
socket: localParams.socket
|
|
635
|
+
};
|
|
618
636
|
}
|
|
619
637
|
async getMethods(socket) {
|
|
620
638
|
let methods = {};
|
|
621
639
|
const publishParams = await this.getPublishParams({ socket });
|
|
622
640
|
const _methods = await applyParamsIfFunc(this.publishMethods, publishParams);
|
|
623
641
|
if (_methods && Object.keys(_methods).length) {
|
|
624
|
-
|
|
642
|
+
(0, DboBuilder_1.getKeys)(_methods).map(key => {
|
|
625
643
|
if (_methods[key] && (typeof _methods[key] === "function" || typeof _methods[key].then === "function")) {
|
|
644
|
+
//@ts-ignore
|
|
626
645
|
methods[key] = _methods[key];
|
|
627
646
|
}
|
|
628
647
|
else {
|
|
@@ -642,7 +661,7 @@ class PublishParser {
|
|
|
642
661
|
let _publish = await applyParamsIfFunc(this.publish, publishParams);
|
|
643
662
|
if (_publish === "*") {
|
|
644
663
|
let publish = {};
|
|
645
|
-
this.prostgles.dboBuilder.tablesOrViews
|
|
664
|
+
this.prostgles.dboBuilder.tablesOrViews?.map(tov => {
|
|
646
665
|
publish[tov.name] = "*";
|
|
647
666
|
});
|
|
648
667
|
return publish;
|
|
@@ -654,7 +673,6 @@ class PublishParser {
|
|
|
654
673
|
return await this.getValidatedRequestRule({ tableName, command, localParams }, clientInfo);
|
|
655
674
|
}
|
|
656
675
|
async getValidatedRequestRule({ tableName, command, localParams }, clientInfo) {
|
|
657
|
-
var _a, _b, _c, _d;
|
|
658
676
|
if (!this.dbo)
|
|
659
677
|
throw "INTERNAL ERROR: dbo is missing";
|
|
660
678
|
if (!command || !tableName)
|
|
@@ -665,13 +683,16 @@ class PublishParser {
|
|
|
665
683
|
}
|
|
666
684
|
/* Must be local request -> allow everything */
|
|
667
685
|
if (!localParams || (!localParams.socket && !localParams.httpReq)) {
|
|
668
|
-
return RULE_TO_METHODS.reduce((a, v) => (
|
|
686
|
+
return RULE_TO_METHODS.reduce((a, v) => ({
|
|
687
|
+
...a,
|
|
688
|
+
[v.rule]: v.no_limits
|
|
689
|
+
}), {});
|
|
669
690
|
}
|
|
670
691
|
/* Must be from socket. Must have a publish */
|
|
671
692
|
if (!this.publish)
|
|
672
693
|
throw "publish is missing";
|
|
673
694
|
/* Get any publish errors for socket */
|
|
674
|
-
const schm =
|
|
695
|
+
const schm = localParams?.socket?.prostgles?.schema?.[tableName]?.[command];
|
|
675
696
|
if (schm && schm.err)
|
|
676
697
|
throw schm.err;
|
|
677
698
|
let table_rule = await this.getTableRules({ tableName, localParams }, clientInfo);
|
|
@@ -705,7 +726,8 @@ class PublishParser {
|
|
|
705
726
|
MY_RULES.map(r => {
|
|
706
727
|
/** Check PG User privileges */
|
|
707
728
|
if (tHandler.tableOrViewInfo.privileges[r.sqlRule]) {
|
|
708
|
-
|
|
729
|
+
// @ts-ignore
|
|
730
|
+
table_rules[r.rule] = { ...r.no_limits };
|
|
709
731
|
}
|
|
710
732
|
});
|
|
711
733
|
// if(tableName === "various") console.warn(1042, table_rules)
|
|
@@ -713,16 +735,22 @@ class PublishParser {
|
|
|
713
735
|
/* Add missing implied rules */
|
|
714
736
|
MY_RULES.map(r => {
|
|
715
737
|
if (["getInfo", "getColumns"].includes(r.rule) && ![null, false, 0].includes(table_rules[r.rule])) {
|
|
738
|
+
// @ts-ignore
|
|
716
739
|
table_rules[r.rule] = r.no_limits;
|
|
717
740
|
return;
|
|
718
741
|
}
|
|
719
742
|
/* Add nested properties for fully allowed rules */
|
|
743
|
+
// @ts-ignore
|
|
720
744
|
if ([true, "*"].includes(table_rules[r.rule]) && r.no_limits) {
|
|
745
|
+
// @ts-ignore
|
|
721
746
|
table_rules[r.rule] = Object.assign({}, r.no_limits);
|
|
722
747
|
}
|
|
748
|
+
// @ts-ignore
|
|
723
749
|
if (table_rules[r.rule]) {
|
|
724
750
|
/* Add implied methods if not falsy */
|
|
725
|
-
|
|
751
|
+
// @ts-ignore
|
|
752
|
+
r.methods.forEach(method => {
|
|
753
|
+
// @ts-ignore
|
|
726
754
|
if (table_rules[method] === undefined) {
|
|
727
755
|
const publishedTable = table_rules;
|
|
728
756
|
if (method === "updateBatch" && !publishedTable.update) {
|
|
@@ -731,6 +759,7 @@ class PublishParser {
|
|
|
731
759
|
// return;
|
|
732
760
|
}
|
|
733
761
|
else {
|
|
762
|
+
// @ts-ignore
|
|
734
763
|
table_rules[method] = {};
|
|
735
764
|
}
|
|
736
765
|
}
|
|
@@ -742,46 +771,56 @@ class PublishParser {
|
|
|
742
771
|
Add defaults
|
|
743
772
|
Check for invalid params
|
|
744
773
|
*/
|
|
745
|
-
if (
|
|
746
|
-
const ruleKeys =
|
|
774
|
+
if (table_rules && (0, DboBuilder_1.getKeys)(table_rules).length && table_rules !== "*") {
|
|
775
|
+
const ruleKeys = (0, DboBuilder_1.getKeys)(table_rules);
|
|
776
|
+
// @ts-ignore
|
|
747
777
|
ruleKeys.filter(m => table_rules[m])
|
|
748
778
|
.find(method => {
|
|
749
779
|
let rm = MY_RULES.find(r => r.rule === method || r.methods.includes(method));
|
|
750
780
|
if (!rm) {
|
|
751
|
-
throw `Invalid rule in publish.${tableName} -> ${method} \nExpecting any of: ${
|
|
781
|
+
throw `Invalid rule in publish.${tableName} -> ${method} \nExpecting any of: ${MY_RULES.flatMap(r => [r.rule, ...r.methods]).join(", ")}`;
|
|
752
782
|
}
|
|
753
783
|
/** Check user privileges */
|
|
754
784
|
if (!tHandler.tableOrViewInfo.privileges[rm.sqlRule]) {
|
|
785
|
+
// @ts-ignore
|
|
755
786
|
delete table_rules[method];
|
|
756
787
|
return;
|
|
757
788
|
}
|
|
758
789
|
/* Check RULES for invalid params */
|
|
759
790
|
/* Methods do not have params -> They use them from rules */
|
|
760
791
|
if (method === rm.rule) {
|
|
761
|
-
|
|
762
|
-
let
|
|
792
|
+
// @ts-ignore
|
|
793
|
+
let method_params = (0, DboBuilder_1.getKeys)(table_rules[method]);
|
|
794
|
+
let iparam = method_params.find(p => !rm?.allowed_params.includes(p));
|
|
763
795
|
if (iparam) {
|
|
764
796
|
throw `Invalid setting in publish.${tableName}.${method} -> ${iparam}. \n Expecting any of: ${rm.allowed_params.join(", ")}`;
|
|
765
797
|
}
|
|
766
798
|
}
|
|
767
799
|
/* Add default params (if missing) */
|
|
800
|
+
// @ts-ignore
|
|
768
801
|
if (method === "sync") {
|
|
802
|
+
// @ts-ignore
|
|
769
803
|
if ([true, "*"].includes(table_rules[method])) {
|
|
770
804
|
throw "Invalid sync rule. Expecting { id_fields: string[], synced_field: string } ";
|
|
771
805
|
}
|
|
772
|
-
if (typeof utils_1.get(table_rules, [method, "throttle"]) !== "number") {
|
|
806
|
+
if (typeof (0, utils_1.get)(table_rules, [method, "throttle"]) !== "number") {
|
|
807
|
+
// @ts-ignore
|
|
773
808
|
table_rules[method].throttle = 100;
|
|
774
809
|
}
|
|
775
|
-
if (typeof utils_1.get(table_rules, [method, "batch_size"]) !== "number") {
|
|
810
|
+
if (typeof (0, utils_1.get)(table_rules, [method, "batch_size"]) !== "number") {
|
|
811
|
+
// @ts-ignore
|
|
776
812
|
table_rules[method].batch_size = PubSubManager_1.DEFAULT_SYNC_BATCH_SIZE;
|
|
777
813
|
}
|
|
778
814
|
}
|
|
779
815
|
/* Enable subscribe if not explicitly disabled */
|
|
816
|
+
// @ts-ignore
|
|
780
817
|
if (method === "select" && !ruleKeys.includes("subscribe")) {
|
|
781
818
|
const sr = MY_RULES.find(r => r.rule === "subscribe");
|
|
782
819
|
if (sr) {
|
|
783
|
-
|
|
784
|
-
table_rules.
|
|
820
|
+
// @ts-ignore
|
|
821
|
+
table_rules[sr.rule] = { ...sr.no_limits };
|
|
822
|
+
// @ts-ignore
|
|
823
|
+
table_rules.subscribeOne = { ...sr.no_limits };
|
|
785
824
|
}
|
|
786
825
|
}
|
|
787
826
|
});
|
|
@@ -798,7 +837,7 @@ class PublishParser {
|
|
|
798
837
|
let schema = {};
|
|
799
838
|
try {
|
|
800
839
|
/* Publish tables and views based on socket */
|
|
801
|
-
const clientInfo = await this.prostgles.authHandler
|
|
840
|
+
const clientInfo = await this.prostgles.authHandler?.getClientInfo({ socket });
|
|
802
841
|
let _publish = await this.getPublish(socket, clientInfo);
|
|
803
842
|
if (_publish && Object.keys(_publish).length) {
|
|
804
843
|
let txKey = "tx";
|
|
@@ -811,7 +850,7 @@ class PublishParser {
|
|
|
811
850
|
.map(async (tableName) => {
|
|
812
851
|
if (!this.dbo[tableName]) {
|
|
813
852
|
throw `Table ${tableName} does not exist
|
|
814
|
-
Expecting one of: ${this.prostgles.dboBuilder.tablesOrViews
|
|
853
|
+
Expecting one of: ${this.prostgles.dboBuilder.tablesOrViews?.map(tov => tov.name).join(", ")}
|
|
815
854
|
DBO tables: ${Object.keys(this.dbo).filter(k => this.dbo[k].find).join(", ")}
|
|
816
855
|
`;
|
|
817
856
|
}
|
|
@@ -821,7 +860,7 @@ class PublishParser {
|
|
|
821
860
|
schema[tableName] = {};
|
|
822
861
|
let methods = [];
|
|
823
862
|
if (typeof table_rules === "object") {
|
|
824
|
-
methods =
|
|
863
|
+
methods = (0, DboBuilder_1.getKeys)(table_rules);
|
|
825
864
|
}
|
|
826
865
|
await Promise.all(methods.filter(m => m !== "select").map(async (method) => {
|
|
827
866
|
if (method === "sync" && table_rules[method]) {
|
|
@@ -831,7 +870,7 @@ class PublishParser {
|
|
|
831
870
|
else if (table_rules[method]) {
|
|
832
871
|
schema[tableName][method] = {};
|
|
833
872
|
/* Test for issues with the publish rules */
|
|
834
|
-
if (
|
|
873
|
+
if (TABLE_METHODS.includes(method)) {
|
|
835
874
|
let err = null;
|
|
836
875
|
try {
|
|
837
876
|
let valid_table_command_rules = await this.getValidatedRequestRule({ tableName, command: method, localParams: { socket } }, clientInfo);
|