prostgles-server 3.0.90 → 3.0.92
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/DBSchemaBuilder.js +1 -2
- package/dist/DBSchemaBuilder.js.map +1 -1
- package/dist/JSONBValidation/validate_jsonb_schema_sql.d.ts.map +1 -1
- package/dist/JSONBValidation/validate_jsonb_schema_sql.js +70 -14
- package/dist/JSONBValidation/validate_jsonb_schema_sql.js.map +1 -1
- package/dist/JSONBValidation/validation.d.ts +52 -12
- package/dist/JSONBValidation/validation.d.ts.map +1 -1
- package/dist/JSONBValidation/validation.js +64 -55
- package/dist/JSONBValidation/validation.js.map +1 -1
- package/dist/PubSubManager/PubSubManager.d.ts.map +1 -1
- package/dist/PubSubManager/PubSubManager.js +13 -11
- package/dist/PubSubManager/PubSubManager.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/lib/DBSchemaBuilder.js +1 -2
- package/lib/DBSchemaBuilder.ts +2 -2
- package/lib/JSONBValidation/validate_jsonb_schema_sql.d.ts.map +1 -1
- package/lib/JSONBValidation/validate_jsonb_schema_sql.js +70 -14
- package/lib/JSONBValidation/validate_jsonb_schema_sql.ts +70 -14
- package/lib/JSONBValidation/validation.d.ts +52 -12
- package/lib/JSONBValidation/validation.d.ts.map +1 -1
- package/lib/JSONBValidation/validation.js +64 -55
- package/lib/JSONBValidation/validation.ts +120 -66
- package/lib/PubSubManager/PubSubManager.d.ts.map +1 -1
- package/lib/PubSubManager/PubSubManager.js +13 -11
- package/lib/PubSubManager/PubSubManager.ts +14 -13
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.ts +1 -1
- package/package.json +1 -1
- package/tests/client/PID.txt +1 -1
- package/tests/client_only_queries.js +1 -1
- package/tests/client_only_queries.ts +1 -1
- package/tests/server/DBoGenerated.d.ts +5 -4
- package/tests/server/index.js +7 -4
- package/tests/server/index.ts +7 -4
- package/tests/server/package-lock.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PubSubManager.d.ts","sourceRoot":"","sources":["PubSubManager.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAE3E,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,eAAe,EAAE,UAAU,EAAE,YAAY,EAAc,MAAM,eAAe,CAAC;AAClH,OAAO,EAAE,EAAE,EAAe,MAAM,cAAc,CAAC;AAO/C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAU,GAAG,EAAW,SAAS,
|
|
1
|
+
{"version":3,"file":"PubSubManager.d.ts","sourceRoot":"","sources":["PubSubManager.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAE3E,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,eAAe,EAAE,UAAU,EAAE,YAAY,EAAc,MAAM,eAAe,CAAC;AAClH,OAAO,EAAE,EAAE,EAAe,MAAM,cAAc,CAAC;AAO/C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAU,GAAG,EAAW,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE7F,OAAO,EAAE,iBAAiB,EAAY,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAQ7C,eAAO,MAAM,OAAO,MAAO,GAAG,WAA6B,CAAC;AAC5D,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAE1C,eAAO,MAAM,GAAG,YAAa,GAAG,EAAE,SAIjC,CAAA;AAED,MAAM,MAAM,aAAa,GAAG,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,KAAK,IAAI,CAAA;AAE1D,MAAM,MAAM,UAAU,GAAG;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,UAA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AG,SAAS,EAAE,MAAM,EAAE,SAAS,GAAG,QAAQ;IAIxG;;;OAGG;IACG,OAAO,CAAC,UAAU,EAAE,aAAa;IAoHjC,MAAM,CAAC,kBAAkB,EAAE,IAAI,CAAC,qBAAqB,EAAE,cAAc,GAAG,iBAAiB,CAAC;IAuIhG,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,GAAG;IAepF,kBAAkB,QAAO;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,EAAE,CAmBnE;IAED,oBAAoB,CAAC,MAAM,CAAC,EAAE,YAAY,EAAE,YAAY,CAAC,EAAE,MAAM;IAwDjE,mBAAmB,eAAsB,MAAM,sBAgB9C;IAQD,iBAAiB,wBAQhB;IAGD,aAAa,EAAE,GAAG,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAa;IAChD,UAAU,CAAC,MAAM,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;KAAE,EAAE,WAAW,CAAC,EAAE,uBAAuB;CA6D3G;AAKD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA"}
|
|
@@ -37,7 +37,7 @@ const pgPromise = __importStar(require("pg-promise"));
|
|
|
37
37
|
const prostgles_types_1 = require("prostgles-types");
|
|
38
38
|
const SyncReplication_1 = require("../SyncReplication");
|
|
39
39
|
const util_1 = require("prostgles-types/dist/util");
|
|
40
|
-
|
|
40
|
+
const pgp = pgPromise({
|
|
41
41
|
promiseLib: Bluebird
|
|
42
42
|
});
|
|
43
43
|
const asValue = (v) => pgp.as.format("$1", [v]);
|
|
@@ -332,8 +332,8 @@ class PubSubManager {
|
|
|
332
332
|
return;
|
|
333
333
|
}
|
|
334
334
|
/* Throttle the subscriptions */
|
|
335
|
-
for (
|
|
336
|
-
|
|
335
|
+
for (let i = 0; i < subs.length; i++) {
|
|
336
|
+
const sub = subs[i];
|
|
337
337
|
if (this.dbo[sub.table_name] &&
|
|
338
338
|
sub.is_ready &&
|
|
339
339
|
(sub.socket_id && this.sockets[sub.socket_id]) || sub.func) {
|
|
@@ -425,7 +425,7 @@ class PubSubManager {
|
|
|
425
425
|
*/
|
|
426
426
|
async addSync(syncParams) {
|
|
427
427
|
const { socket = null, table_info = null, table_rules, synced_field = null, allow_delete = false, id_fields = [], filter = {}, params, condition = "", throttle = 0 } = syncParams || {};
|
|
428
|
-
|
|
428
|
+
const conditionParsed = parseCondition(condition);
|
|
429
429
|
if (!socket || !table_info)
|
|
430
430
|
throw "socket or table_info missing";
|
|
431
431
|
const { name: table_name } = table_info, channel_name = `${this.socketChannelPreffix}.${table_name}.${JSON.stringify(filter)}.sync`;
|
|
@@ -433,7 +433,7 @@ class PubSubManager {
|
|
|
433
433
|
throw "synced_field missing from table_rules";
|
|
434
434
|
this.upsertSocket(socket, channel_name);
|
|
435
435
|
const upsertSync = () => {
|
|
436
|
-
|
|
436
|
+
const newSync = {
|
|
437
437
|
channel_name,
|
|
438
438
|
table_name,
|
|
439
439
|
filter,
|
|
@@ -509,7 +509,7 @@ class PubSubManager {
|
|
|
509
509
|
return newSync;
|
|
510
510
|
};
|
|
511
511
|
// const { min_id, max_id, count, max_synced } = params;
|
|
512
|
-
|
|
512
|
+
const _sync = upsertSync();
|
|
513
513
|
await this.addTrigger({ table_name, condition: conditionParsed });
|
|
514
514
|
return channel_name;
|
|
515
515
|
}
|
|
@@ -625,7 +625,7 @@ class PubSubManager {
|
|
|
625
625
|
}
|
|
626
626
|
}
|
|
627
627
|
removeLocalSub(table_name, condition, func) {
|
|
628
|
-
|
|
628
|
+
const cond = parseCondition(condition);
|
|
629
629
|
if ((0, utils_1.get)(this.subs, [table_name, cond, "subs"])) {
|
|
630
630
|
this.subs[table_name][cond].subs.map((sub, i) => {
|
|
631
631
|
if (sub.func && sub.func === func) {
|
|
@@ -638,7 +638,7 @@ class PubSubManager {
|
|
|
638
638
|
}
|
|
639
639
|
}
|
|
640
640
|
getActiveListeners = () => {
|
|
641
|
-
|
|
641
|
+
const result = [];
|
|
642
642
|
const upsert = (t, c) => {
|
|
643
643
|
if (!result.find(r => r.table_name === t && r.condition === c)) {
|
|
644
644
|
result.push({ table_name: t, condition: c });
|
|
@@ -692,6 +692,7 @@ class PubSubManager {
|
|
|
692
692
|
});
|
|
693
693
|
}
|
|
694
694
|
if (!socket) {
|
|
695
|
+
// Do nothing
|
|
695
696
|
}
|
|
696
697
|
else if (!channel_name) {
|
|
697
698
|
delete this.sockets[socket.id];
|
|
@@ -712,7 +713,7 @@ class PubSubManager {
|
|
|
712
713
|
AND table_name = 'hypertable' \
|
|
713
714
|
);", { schema });
|
|
714
715
|
if (res.exists) {
|
|
715
|
-
|
|
716
|
+
const isHyperTable = await this.db.any("SELECT * FROM " + (0, prostgles_types_1.asName)(schema) + ".hypertable WHERE table_name = ${table_name};", { table_name, schema });
|
|
716
717
|
if (isHyperTable && isHyperTable.length) {
|
|
717
718
|
throw "Triggers do not work on timescaledb hypertables due to bug:\nhttps://github.com/timescale/timescaledb/issues/1084";
|
|
718
719
|
}
|
|
@@ -737,7 +738,8 @@ class PubSubManager {
|
|
|
737
738
|
addTriggerPool = undefined;
|
|
738
739
|
async addTrigger(params, viewOptions) {
|
|
739
740
|
try {
|
|
740
|
-
|
|
741
|
+
const { table_name } = { ...params };
|
|
742
|
+
let { condition } = { ...params };
|
|
741
743
|
if (!table_name)
|
|
742
744
|
throw "MISSING table_name";
|
|
743
745
|
if (!this.appID)
|
|
@@ -783,7 +785,7 @@ class PubSubManager {
|
|
|
783
785
|
}
|
|
784
786
|
}
|
|
785
787
|
exports.PubSubManager = PubSubManager;
|
|
786
|
-
const parseCondition = (condition) =>
|
|
788
|
+
const parseCondition = (condition) => condition && condition.trim().length ? condition : "TRUE";
|
|
787
789
|
var prostgles_types_2 = require("prostgles-types");
|
|
788
790
|
Object.defineProperty(exports, "pickKeys", { enumerable: true, get: function () { return prostgles_types_2.pickKeys; } });
|
|
789
791
|
Object.defineProperty(exports, "omitKeys", { enumerable: true, get: function () { return prostgles_types_2.omitKeys; } });
|
|
@@ -13,7 +13,7 @@ import * as Bluebird from "bluebird";
|
|
|
13
13
|
import * as pgPromise from 'pg-promise';
|
|
14
14
|
import pg from 'pg-promise/typescript/pg-subset';
|
|
15
15
|
|
|
16
|
-
import { SelectParams, FieldFilter, asName, WAL, isEmpty, AnyObject
|
|
16
|
+
import { SelectParams, FieldFilter, asName, WAL, isEmpty, AnyObject } from "prostgles-types";
|
|
17
17
|
|
|
18
18
|
import { ClientExpressData, syncData } from "../SyncReplication";
|
|
19
19
|
import { TableRule } from "../PublishParser";
|
|
@@ -21,7 +21,7 @@ import { find } from "prostgles-types/dist/util";
|
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
type PGP = pgPromise.IMain<{}, pg.IClient>;
|
|
24
|
-
|
|
24
|
+
const pgp: PGP = pgPromise({
|
|
25
25
|
promiseLib: Bluebird
|
|
26
26
|
});
|
|
27
27
|
export const asValue = (v: any) => pgp.as.format("$1", [v]);
|
|
@@ -453,8 +453,8 @@ export class PubSubManager {
|
|
|
453
453
|
}
|
|
454
454
|
|
|
455
455
|
/* Throttle the subscriptions */
|
|
456
|
-
for (
|
|
457
|
-
|
|
456
|
+
for (let i = 0; i < subs.length; i++) {
|
|
457
|
+
const sub = subs[i];
|
|
458
458
|
if (
|
|
459
459
|
this.dbo[sub.table_name] &&
|
|
460
460
|
sub.is_ready &&
|
|
@@ -563,7 +563,7 @@ export class PubSubManager {
|
|
|
563
563
|
params, condition = "", throttle = 0
|
|
564
564
|
} = syncParams || {};
|
|
565
565
|
|
|
566
|
-
|
|
566
|
+
const conditionParsed = parseCondition(condition);
|
|
567
567
|
if (!socket || !table_info) throw "socket or table_info missing";
|
|
568
568
|
|
|
569
569
|
|
|
@@ -575,7 +575,7 @@ export class PubSubManager {
|
|
|
575
575
|
this.upsertSocket(socket, channel_name);
|
|
576
576
|
|
|
577
577
|
const upsertSync = () => {
|
|
578
|
-
|
|
578
|
+
const newSync = {
|
|
579
579
|
channel_name,
|
|
580
580
|
table_name,
|
|
581
581
|
filter,
|
|
@@ -662,7 +662,7 @@ export class PubSubManager {
|
|
|
662
662
|
|
|
663
663
|
// const { min_id, max_id, count, max_synced } = params;
|
|
664
664
|
|
|
665
|
-
|
|
665
|
+
const _sync = upsertSync();
|
|
666
666
|
|
|
667
667
|
await this.addTrigger({ table_name, condition: conditionParsed });
|
|
668
668
|
|
|
@@ -808,7 +808,7 @@ export class PubSubManager {
|
|
|
808
808
|
}
|
|
809
809
|
|
|
810
810
|
removeLocalSub(table_name: string, condition: string, func: (items: object[]) => any) {
|
|
811
|
-
|
|
811
|
+
const cond = parseCondition(condition);
|
|
812
812
|
if (get(this.subs, [table_name, cond, "subs"])) {
|
|
813
813
|
this.subs[table_name][cond].subs.map((sub, i) => {
|
|
814
814
|
if (
|
|
@@ -823,7 +823,7 @@ export class PubSubManager {
|
|
|
823
823
|
}
|
|
824
824
|
|
|
825
825
|
getActiveListeners = (): { table_name: string; condition: string }[] => {
|
|
826
|
-
|
|
826
|
+
const result: { table_name: string; condition: string }[] = [];
|
|
827
827
|
const upsert = (t: string, c: string) => {
|
|
828
828
|
if (!result.find(r => r.table_name === t && r.condition === c)) {
|
|
829
829
|
result.push({ table_name: t, condition: c });
|
|
@@ -886,7 +886,7 @@ export class PubSubManager {
|
|
|
886
886
|
}
|
|
887
887
|
|
|
888
888
|
if (!socket) {
|
|
889
|
-
|
|
889
|
+
// Do nothing
|
|
890
890
|
} else if (!channel_name) {
|
|
891
891
|
delete this.sockets[socket.id];
|
|
892
892
|
} else {
|
|
@@ -909,7 +909,7 @@ export class PubSubManager {
|
|
|
909
909
|
AND table_name = 'hypertable' \
|
|
910
910
|
);", { schema });
|
|
911
911
|
if (res.exists) {
|
|
912
|
-
|
|
912
|
+
const isHyperTable = await this.db.any("SELECT * FROM " + asName(schema) + ".hypertable WHERE table_name = ${table_name};", { table_name, schema });
|
|
913
913
|
if (isHyperTable && isHyperTable.length) {
|
|
914
914
|
throw "Triggers do not work on timescaledb hypertables due to bug:\nhttps://github.com/timescale/timescaledb/issues/1084"
|
|
915
915
|
}
|
|
@@ -939,7 +939,8 @@ export class PubSubManager {
|
|
|
939
939
|
async addTrigger(params: { table_name: string; condition: string; }, viewOptions?: ViewSubscriptionOptions) {
|
|
940
940
|
try {
|
|
941
941
|
|
|
942
|
-
|
|
942
|
+
const { table_name } = { ...params }
|
|
943
|
+
let { condition } = { ...params }
|
|
943
944
|
if (!table_name) throw "MISSING table_name";
|
|
944
945
|
if (!this.appID) throw "MISSING appID";
|
|
945
946
|
|
|
@@ -999,6 +1000,6 @@ export class PubSubManager {
|
|
|
999
1000
|
}
|
|
1000
1001
|
|
|
1001
1002
|
|
|
1002
|
-
const parseCondition = (condition: string): string =>
|
|
1003
|
+
const parseCondition = (condition: string): string => condition && condition.trim().length ? condition : "TRUE"
|
|
1003
1004
|
|
|
1004
1005
|
export { pickKeys, omitKeys } from "prostgles-types"
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SessionUser } from "./AuthHandler";
|
|
2
|
-
import { ProstglesInitOptions
|
|
3
|
-
declare function prostgles<S = void, SUser extends SessionUser = SessionUser>(params: ProstglesInitOptions<S, SUser>): Promise<InitResult>;
|
|
2
|
+
import { ProstglesInitOptions } from "./Prostgles";
|
|
3
|
+
declare function prostgles<S = void, SUser extends SessionUser = SessionUser>(params: ProstglesInitOptions<S, SUser>): Promise<import("./Prostgles").InitResult>;
|
|
4
4
|
export = prostgles;
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAa,oBAAoB,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAa,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAE9D,iBAAS,SAAS,CAAC,CAAC,GAAG,IAAI,EAAE,KAAK,SAAS,WAAW,GAAG,WAAW,EAAE,MAAM,EAAE,oBAAoB,CAAC,CAAC,EAAE,KAAK,CAAC,6CAI3G;AACD,SAAS,SAAS,CAAC"}
|
package/lib/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SessionUser } from "./AuthHandler";
|
|
2
|
-
import { Prostgles, ProstglesInitOptions
|
|
2
|
+
import { Prostgles, ProstglesInitOptions } from "./Prostgles";
|
|
3
3
|
|
|
4
4
|
function prostgles<S = void, SUser extends SessionUser = SessionUser>(params: ProstglesInitOptions<S, SUser>){
|
|
5
5
|
|
package/package.json
CHANGED
package/tests/client/PID.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
446772
|
|
@@ -376,9 +376,9 @@ export type DBSchemaGenerated = {
|
|
|
376
376
|
arr2: number[];
|
|
377
377
|
arrStr?: null | string[];
|
|
378
378
|
o?:
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
379
|
+
| null
|
|
380
|
+
| { o1: number; }
|
|
381
|
+
| { o2: boolean; };
|
|
382
382
|
};
|
|
383
383
|
jsonOneOf?:
|
|
384
384
|
| null
|
|
@@ -390,7 +390,8 @@ export type DBSchemaGenerated = {
|
|
|
390
390
|
| { err: string; }
|
|
391
391
|
| { loading: { loaded: number; total: number; }; }
|
|
392
392
|
table_config?: null | {
|
|
393
|
-
referencedTables?: { name: string; minFiles: number; }[];
|
|
393
|
+
referencedTables?: { name: string; minFiles: number; }[];
|
|
394
|
+
recType?: null | Record<'a' | 'b', { bools: boolean[]; }>;
|
|
394
395
|
};
|
|
395
396
|
};
|
|
396
397
|
};
|
package/tests/server/index.js
CHANGED
|
@@ -108,7 +108,7 @@ function dd() {
|
|
|
108
108
|
arr1: { enum: [1, 2, 3] },
|
|
109
109
|
arr2: { type: "integer[]" },
|
|
110
110
|
arrStr: { type: "string[]", optional: true, nullable: true },
|
|
111
|
-
o: { optional: true, nullable: true,
|
|
111
|
+
o: { optional: true, nullable: true, oneOfType: [
|
|
112
112
|
{ o1: "integer" },
|
|
113
113
|
{ o2: "boolean" }
|
|
114
114
|
] },
|
|
@@ -118,7 +118,7 @@ function dd() {
|
|
|
118
118
|
status: {
|
|
119
119
|
nullable: true,
|
|
120
120
|
jsonbSchema: {
|
|
121
|
-
|
|
121
|
+
oneOfType: [
|
|
122
122
|
{ ok: { type: "string" } },
|
|
123
123
|
{ err: { type: "string" } },
|
|
124
124
|
{
|
|
@@ -134,7 +134,7 @@ function dd() {
|
|
|
134
134
|
jsonOneOf: {
|
|
135
135
|
nullable: true,
|
|
136
136
|
jsonbSchema: {
|
|
137
|
-
|
|
137
|
+
oneOfType: [
|
|
138
138
|
{ command: { enum: ["a"] } },
|
|
139
139
|
{
|
|
140
140
|
command: { enum: ["b"] },
|
|
@@ -144,7 +144,10 @@ function dd() {
|
|
|
144
144
|
}
|
|
145
145
|
},
|
|
146
146
|
table_config: { nullable: true, jsonbSchemaType: {
|
|
147
|
-
referencedTables: { optional: true,
|
|
147
|
+
referencedTables: { optional: true, arrayOfType: { name: "string", minFiles: "number" } },
|
|
148
|
+
recType: {
|
|
149
|
+
nullable: true, optional: true, record: { keysEnum: ["a", "b"], values: { type: { bools: "boolean[]" } } }
|
|
150
|
+
}
|
|
148
151
|
}
|
|
149
152
|
}
|
|
150
153
|
}
|
package/tests/server/index.ts
CHANGED
|
@@ -129,7 +129,7 @@ function dd(){
|
|
|
129
129
|
arr1: { enum: [1, 2, 3] },
|
|
130
130
|
arr2: { type: "integer[]" },
|
|
131
131
|
arrStr: { type: "string[]", optional: true, nullable: true },
|
|
132
|
-
o: { optional: true, nullable: true,
|
|
132
|
+
o: { optional: true, nullable: true, oneOfType: [
|
|
133
133
|
{ o1: "integer" },
|
|
134
134
|
{ o2: "boolean" }
|
|
135
135
|
] },
|
|
@@ -139,7 +139,7 @@ function dd(){
|
|
|
139
139
|
status: {
|
|
140
140
|
nullable: true,
|
|
141
141
|
jsonbSchema: {
|
|
142
|
-
|
|
142
|
+
oneOfType: [
|
|
143
143
|
{ ok: { type: "string" } },
|
|
144
144
|
{ err: { type: "string" } },
|
|
145
145
|
{
|
|
@@ -155,7 +155,7 @@ function dd(){
|
|
|
155
155
|
jsonOneOf: {
|
|
156
156
|
nullable: true,
|
|
157
157
|
jsonbSchema: {
|
|
158
|
-
|
|
158
|
+
oneOfType: [
|
|
159
159
|
{ command: { enum: ["a"] } },
|
|
160
160
|
{
|
|
161
161
|
command: { enum: ["b"] },
|
|
@@ -165,7 +165,10 @@ function dd(){
|
|
|
165
165
|
}
|
|
166
166
|
},
|
|
167
167
|
table_config: { nullable: true, jsonbSchemaType: {
|
|
168
|
-
referencedTables: { optional: true,
|
|
168
|
+
referencedTables: { optional: true, arrayOfType: { name: "string", minFiles: "number" } },
|
|
169
|
+
recType: {
|
|
170
|
+
nullable: true, optional: true, record: { keysEnum: ["a", "b"], values: { type: { bools: "boolean[]" } } }
|
|
171
|
+
}
|
|
169
172
|
}
|
|
170
173
|
}
|
|
171
174
|
}
|