prostgles-types 4.0.114 → 4.0.116
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/.vscode/settings.json +10 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/files.d.ts +5 -5
- package/dist/files.d.ts.map +1 -1
- package/dist/files.js +13 -1
- package/dist/files.js.map +1 -1
- package/dist/filters.d.ts +22 -19
- package/dist/filters.d.ts.map +1 -1
- package/dist/filters.js +89 -45
- package/dist/filters.js.map +1 -1
- package/dist/index.d.ts +37 -29
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +90 -65
- package/dist/index.js.map +1 -1
- package/dist/insertUpdateUtils.d.ts.map +1 -1
- package/dist/insertUpdateUtils.js.map +1 -1
- package/dist/jsonb.d.ts +9 -9
- package/dist/jsonb.d.ts.map +1 -1
- package/dist/jsonb.js +44 -37
- package/dist/jsonb.js.map +1 -1
- package/dist/md5.d.ts.map +1 -1
- package/dist/md5.js +19 -18
- package/dist/md5.js.map +1 -1
- package/dist/replication.d.ts.map +1 -1
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +70 -64
- package/dist/util.js.map +1 -1
- package/lib/auth.ts +11 -13
- package/lib/files.ts +87 -75
- package/lib/filters.ts +228 -193
- package/lib/index.ts +605 -467
- package/lib/insertUpdateUtils.ts +10 -10
- package/lib/jsonb.ts +242 -205
- package/lib/md5.ts +31 -28
- package/lib/replication.ts +39 -33
- package/lib/util.ts +217 -175
- package/package.json +2 -1
package/.vscode/settings.json
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
-
"typescript.tsdk": "node_modules/typescript/lib"
|
|
2
|
+
"typescript.tsdk": "node_modules/typescript/lib",
|
|
3
|
+
"editor.formatOnSave": true,
|
|
4
|
+
"prettier.experimentalTernaries": true,
|
|
5
|
+
"[javascript]": {
|
|
6
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
7
|
+
},
|
|
8
|
+
"[typescript]": {
|
|
9
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
10
|
+
},
|
|
11
|
+
"prettier.printWidth": 100
|
|
3
12
|
}
|
package/dist/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../lib/auth.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../lib/auth.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GACxB,QAAQ,GACR,WAAW,GACX,QAAQ,GACR,OAAO,GACP,UAAU,GACV,SAAS,GACT,UAAU,CAAC;AAEf,MAAM,MAAM,QAAQ,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,cAAc,GAAG,eAAe,CAAC;AAC7D,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG,eAAe,CAAC;AAE/D;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;OAGG;IACH,IAAI,EAAE,QAAQ,GAAG,SAAS,CAAC;IAE3B;;;OAGG;IACH,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,gBAAgB,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,GAAG,SAAS,CAAC;IAE1E;;OAEG;IACH,SAAS,EAAE,aAAa,GAAG,SAAS,CAAC;IAErC;;OAEG;IACH,QAAQ,EAAE;QAAE,IAAI,EAAE,eAAe,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC;IAE7D;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC"}
|
package/dist/files.d.ts
CHANGED
|
@@ -72,11 +72,11 @@ export type ALLOWED_CONTENT_TYPE = keyof typeof CONTENT_TYPE_TO_EXT;
|
|
|
72
72
|
export type ALLOWED_EXTENSION = (typeof CONTENT_TYPE_TO_EXT)[ALLOWED_CONTENT_TYPE][number];
|
|
73
73
|
export type FileType = {
|
|
74
74
|
acceptedContent: FieldFilter<{
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
75
|
+
image: 1;
|
|
76
|
+
audio: 1;
|
|
77
|
+
video: 1;
|
|
78
|
+
text: 1;
|
|
79
|
+
application: 1;
|
|
80
80
|
}>;
|
|
81
81
|
} | {
|
|
82
82
|
acceptedContentType: FieldFilter<typeof CONTENT_TYPE_TO_EXT>;
|
package/dist/files.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../lib/files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,GAAG,CAAC;AAEhC,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../lib/files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,GAAG,CAAC;AAEhC,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgFtB,CAAC;AAEX,MAAM,MAAM,oBAAoB,GAAG,MAAM,OAAO,mBAAmB,CAAC;AACpE,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3F,MAAM,MAAM,QAAQ,GAChB;IAAE,eAAe,EAAE,WAAW,CAAC;QAAE,KAAK,EAAE,CAAC,CAAC;QAAC,KAAK,EAAE,CAAC,CAAC;QAAC,KAAK,EAAE,CAAC,CAAC;QAAC,IAAI,EAAE,CAAC,CAAC;QAAC,WAAW,EAAE,CAAC,CAAA;KAAE,CAAC,CAAA;CAAE,GAC3F;IAAE,mBAAmB,EAAE,WAAW,CAAC,OAAO,mBAAmB,CAAC,CAAA;CAAE,GAChE;IAAE,iBAAiB,EAAE,WAAW,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC,CAAA;CAAE,GAChE,KAAK,CAAC;AAEV,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG;IACxC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC"}
|
package/dist/files.js
CHANGED
|
@@ -54,7 +54,19 @@ exports.CONTENT_TYPE_TO_EXT = {
|
|
|
54
54
|
"application/x-xpinstall": ["xpi"],
|
|
55
55
|
"application/xhtml+xml": ["xhtml"],
|
|
56
56
|
"application/zip": ["zip"],
|
|
57
|
-
"application/octet-stream": [
|
|
57
|
+
"application/octet-stream": [
|
|
58
|
+
"bin",
|
|
59
|
+
"exe",
|
|
60
|
+
"dll",
|
|
61
|
+
"deb",
|
|
62
|
+
"dmg",
|
|
63
|
+
"eot",
|
|
64
|
+
"iso",
|
|
65
|
+
"img",
|
|
66
|
+
"msi",
|
|
67
|
+
"msp",
|
|
68
|
+
"msm",
|
|
69
|
+
],
|
|
58
70
|
"audio/midi": ["mid", "midi", "kar"],
|
|
59
71
|
"audio/mpeg": ["mp3"],
|
|
60
72
|
"audio/ogg": ["ogg"],
|
package/dist/files.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.js","sourceRoot":"","sources":["../lib/files.ts"],"names":[],"mappings":";;;AAEa,QAAA,mBAAmB,GAAG;IACjC,WAAW,
|
|
1
|
+
{"version":3,"file":"files.js","sourceRoot":"","sources":["../lib/files.ts"],"names":[],"mappings":";;;AAEa,QAAA,mBAAmB,GAAG;IACjC,WAAW,EAAE,CAAC,MAAM,E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C;IAC3B,YAAY,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC;IAC7B,YAAY,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC;IAC7B,iBAAiB,EAAE,CAAC,KAAK,CAAC;IAC1B,aAAa,EAAE,CAAC,KAAK,CAAC;IACtB,aAAa,EAAE,CAAC,KAAK,CAAC;IACtB,gBAAgB,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;IAChC,gBAAgB,EAAE,CAAC,KAAK,CAAC;IACzB,iBAAiB,EAAE,CAAC,KAAK,CAAC;IAC1B,WAAW,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;IAC3B,YAAY,EAAE,CAAC,MAAM,CAAC;CACd,CAAC"}
|
package/dist/filters.d.ts
CHANGED
|
@@ -71,7 +71,7 @@ export declare const JsonbFilterKeys: ("@@" | "@>" | "<@" | "?" | "?|" | "?&" |
|
|
|
71
71
|
export declare const TextFilterKeys: readonly ["$ilike", "$like", "$nilike", "$nlike"];
|
|
72
72
|
export declare const TextFilterFTSKeys: readonly ["@@", "@>", "<@", "$contains", "$containedBy"];
|
|
73
73
|
export declare const TextFilter_FullTextSearchFilterKeys: readonly ["to_tsquery", "plainto_tsquery", "phraseto_tsquery", "websearch_to_tsquery"];
|
|
74
|
-
export type FullTextSearchFilter = ExactlyOne<Record<typeof TextFilter_FullTextSearchFilterKeys[number], string[]>>;
|
|
74
|
+
export type FullTextSearchFilter = ExactlyOne<Record<(typeof TextFilter_FullTextSearchFilterKeys)[number], string[]>>;
|
|
75
75
|
/**
|
|
76
76
|
* Example: col_name: { $gt: 2 }
|
|
77
77
|
*/
|
|
@@ -79,22 +79,22 @@ export type CompareFilter<T extends AllowedTSType = string> =
|
|
|
79
79
|
/**
|
|
80
80
|
* column value equals provided value
|
|
81
81
|
*/
|
|
82
|
-
T | ExactlyOne<Record<typeof CompareFilterKeys[number], T>> | ExactlyOne<Record<typeof CompareInFilterKeys[number], T[]>> | ExactlyOne<Record<typeof BetweenFilterKeys[number], [T, T]>>;
|
|
83
|
-
export type TextFilter = CompareFilter<string> | ExactlyOne<Record<typeof TextFilterKeys[number], string>> | ExactlyOne<Record<typeof TextFilterFTSKeys[number], FullTextSearchFilter>>;
|
|
82
|
+
T | ExactlyOne<Record<(typeof CompareFilterKeys)[number], T>> | ExactlyOne<Record<(typeof CompareInFilterKeys)[number], T[]>> | ExactlyOne<Record<(typeof BetweenFilterKeys)[number], [T, T]>>;
|
|
83
|
+
export type TextFilter = CompareFilter<string> | ExactlyOne<Record<(typeof TextFilterKeys)[number], string>> | ExactlyOne<Record<(typeof TextFilterFTSKeys)[number], FullTextSearchFilter>>;
|
|
84
84
|
export declare const ArrayFilterOperands: readonly ["@>", "<@", "=", "$eq", "$contains", "$containedBy", "&&", "$overlaps"];
|
|
85
|
-
export type ArrayFilter<T extends AllowedTSType[]> = Record<typeof ArrayFilterOperands[number], T> | ExactlyOne<Record<typeof ArrayFilterOperands[number], T>>;
|
|
85
|
+
export type ArrayFilter<T extends AllowedTSType[]> = Record<(typeof ArrayFilterOperands)[number], T> | ExactlyOne<Record<(typeof ArrayFilterOperands)[number], T>>;
|
|
86
86
|
/**
|
|
87
|
-
* Makes bounding box from NW and SE points
|
|
88
|
-
* float xmin, float ymin, float xmax, float ymax, integer srid=unknown
|
|
89
|
-
* https://postgis.net/docs/ST_MakeEnvelope.html
|
|
90
|
-
*/
|
|
87
|
+
* Makes bounding box from NW and SE points
|
|
88
|
+
* float xmin, float ymin, float xmax, float ymax, integer srid=unknown
|
|
89
|
+
* https://postgis.net/docs/ST_MakeEnvelope.html
|
|
90
|
+
*/
|
|
91
91
|
export type GeoBBox = {
|
|
92
92
|
ST_MakeEnvelope: number[];
|
|
93
93
|
};
|
|
94
94
|
/**
|
|
95
|
-
* Returns TRUE if A's 2D bounding box intersects B's 2D bounding box.
|
|
96
|
-
* https://postgis.net/docs/reference.html#Operators
|
|
97
|
-
*/
|
|
95
|
+
* Returns TRUE if A's 2D bounding box intersects B's 2D bounding box.
|
|
96
|
+
* https://postgis.net/docs/reference.html#Operators
|
|
97
|
+
*/
|
|
98
98
|
export type GeomFilter =
|
|
99
99
|
/**
|
|
100
100
|
* A's 2D bounding box intersects B's 2D bounding box.
|
|
@@ -108,12 +108,15 @@ export type GeomFilter =
|
|
|
108
108
|
| {
|
|
109
109
|
"@": GeoBBox;
|
|
110
110
|
};
|
|
111
|
+
/**
|
|
112
|
+
* A's bounding box contains B's.
|
|
113
|
+
*/
|
|
111
114
|
export declare const GeomFilterKeys: readonly ["~", "~=", "@", "|&>", "|>>", ">>", "=", "<<|", "<<", "&>", "&<|", "&<", "&&&", "&&"];
|
|
112
115
|
export declare const GeomFilter_Funcs: readonly ["ST_MakeEnvelope", "st_makeenvelope", "ST_MakePolygon", "st_makepolygon"];
|
|
113
116
|
export type AnyObject = Record<string, any>;
|
|
114
|
-
export type CastFromTSToPG<T extends AllowedTSType> = T extends number ?
|
|
117
|
+
export type CastFromTSToPG<T extends AllowedTSType> = T extends number ? T | string : T extends string ? T | number | Date : T extends boolean ? T | string : T extends Date ? T | string : T;
|
|
115
118
|
export declare const EXISTS_KEYS: readonly ["$exists", "$notExists", "$existsJoined", "$notExistsJoined"];
|
|
116
|
-
export type EXISTS_KEY = typeof EXISTS_KEYS[number];
|
|
119
|
+
export type EXISTS_KEY = (typeof EXISTS_KEYS)[number];
|
|
117
120
|
export declare const ComplexFilterComparisonKeys: readonly ["$ilike", "$like", "$nilike", "$nlike", ...("@@" | "@>" | "<@" | "?" | "?|" | "?&" | "||" | "-" | "#-" | "@?")[], "=", "$eq", "<>", ">", "<", ">=", "<=", "$eq", "$ne", "$gt", "$gte", "$lt", "$lte", "$isDistinctFrom", "$isNotDistinctFrom", "$between", "$notBetween", "$in", "$nin"];
|
|
118
121
|
export declare const COMPLEX_FILTER_KEY: "$filter";
|
|
119
122
|
/**
|
|
@@ -131,7 +134,7 @@ export type ComplexFilter = Record<typeof COMPLEX_FILTER_KEY, [
|
|
|
131
134
|
{
|
|
132
135
|
[funcName: string]: any[];
|
|
133
136
|
},
|
|
134
|
-
typeof ComplexFilterComparisonKeys[number]?,
|
|
137
|
+
(typeof ComplexFilterComparisonKeys)[number]?,
|
|
135
138
|
any?
|
|
136
139
|
]>;
|
|
137
140
|
export type KeyofString<T> = keyof T & string;
|
|
@@ -139,14 +142,14 @@ export type KeyofString<T> = keyof T & string;
|
|
|
139
142
|
* Shortened filter operands
|
|
140
143
|
*/
|
|
141
144
|
type BasicFilter<Field extends string, DataType extends any> = Partial<{
|
|
142
|
-
[K in Extract<typeof CompareFilterKeys[number], string> as `${Field}.${K}`]: CastFromTSToPG<DataType>;
|
|
145
|
+
[K in Extract<(typeof CompareFilterKeys)[number], string> as `${Field}.${K}`]: CastFromTSToPG<DataType>;
|
|
143
146
|
}> | Partial<{
|
|
144
|
-
[K in Extract<typeof CompareInFilterKeys[number], string> as `${Field}.${K}`]: CastFromTSToPG<DataType>[];
|
|
147
|
+
[K in Extract<(typeof CompareInFilterKeys)[number], string> as `${Field}.${K}`]: CastFromTSToPG<DataType>[];
|
|
145
148
|
}>;
|
|
146
149
|
type StringFilter<Field extends string, DataType extends any> = BasicFilter<Field, DataType> & (Partial<{
|
|
147
|
-
[K in Extract<typeof TextFilterKeys[number], string> as `${Field}.${K}`]: DataType;
|
|
150
|
+
[K in Extract<(typeof TextFilterKeys)[number], string> as `${Field}.${K}`]: DataType;
|
|
148
151
|
}> | Partial<{
|
|
149
|
-
[K in Extract<typeof TextFilterFTSKeys[number], string> as `${Field}.${K}`]: any;
|
|
152
|
+
[K in Extract<(typeof TextFilterFTSKeys)[number], string> as `${Field}.${K}`]: any;
|
|
150
153
|
}>);
|
|
151
154
|
export type ValueOf<T> = T[keyof T];
|
|
152
155
|
/**
|
|
@@ -159,7 +162,7 @@ export type EqualityFilter<T extends AnyObject> = {
|
|
|
159
162
|
/**
|
|
160
163
|
* Filter operators for each PG data type
|
|
161
164
|
*/
|
|
162
|
-
export type FilterDataType<T extends AllowedTSType> = T extends string ? TextFilter : T extends number ? CompareFilter<CastFromTSToPG<T>> : T extends boolean ? CompareFilter<CastFromTSToPG<T>> : T extends Date ? CompareFilter<CastFromTSToPG<T>> : T extends any[] ? ArrayFilter<T> :
|
|
165
|
+
export type FilterDataType<T extends AllowedTSType> = T extends string ? TextFilter : T extends number ? CompareFilter<CastFromTSToPG<T>> : T extends boolean ? CompareFilter<CastFromTSToPG<T>> : T extends Date ? CompareFilter<CastFromTSToPG<T>> : T extends any[] ? ArrayFilter<T> : CompareFilter<T> | TextFilter | GeomFilter;
|
|
163
166
|
/**
|
|
164
167
|
* Column filter with operators
|
|
165
168
|
* Multiple columns are combined with AND
|
package/dist/filters.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filters.d.ts","sourceRoot":"","sources":["../lib/filters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,GAAG,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAW,MAAM,QAAQ,CAAC;AAE7C,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,GAAG,CAAC;AACnE,MAAM,MAAM,cAAc,GAAG,aAAa,EAAE,CAAC;AAE7C,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"filters.d.ts","sourceRoot":"","sources":["../lib/filters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,GAAG,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAW,MAAM,QAAQ,CAAC;AAE7C,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,GAAG,CAAC;AACnE,MAAM,MAAM,cAAc,GAAG,aAAa,EAAE,CAAC;AAE7C,eAAO,MAAM,iBAAiB,wIAgBpB,CAAC;AACX,eAAO,MAAM,mBAAmB,0BAA2B,CAAC;AAC5D,eAAO,MAAM,i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,GAAG,GAAG;CACxD,CAAC"}
|
package/dist/filters.js
CHANGED
|
@@ -3,81 +3,128 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.COMPLEX_FILTER_KEY = exports.ComplexFilterComparisonKeys = exports.EXISTS_KEYS = exports.GeomFilter_Funcs = exports.GeomFilterKeys = exports.ArrayFilterOperands = exports.TextFilter_FullTextSearchFilterKeys = exports.TextFilterFTSKeys = exports.TextFilterKeys = exports.JsonbFilterKeys = exports.JsonbOperands = exports.BetweenFilterKeys = exports.CompareInFilterKeys = exports.CompareFilterKeys = void 0;
|
|
4
4
|
const util_1 = require("./util");
|
|
5
5
|
exports.CompareFilterKeys = [
|
|
6
|
-
"=",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
6
|
+
"=",
|
|
7
|
+
"$eq",
|
|
8
|
+
"<>",
|
|
9
|
+
">",
|
|
10
|
+
"<",
|
|
11
|
+
">=",
|
|
12
|
+
"<=",
|
|
13
|
+
"$eq",
|
|
14
|
+
"$ne",
|
|
15
|
+
"$gt",
|
|
16
|
+
"$gte",
|
|
17
|
+
"$lt",
|
|
18
|
+
"$lte",
|
|
19
|
+
"$isDistinctFrom",
|
|
20
|
+
"$isNotDistinctFrom",
|
|
10
21
|
];
|
|
11
22
|
exports.CompareInFilterKeys = ["$in", "$nin"];
|
|
12
23
|
exports.BetweenFilterKeys = ["$between", "$notBetween"];
|
|
13
24
|
exports.JsonbOperands = {
|
|
14
25
|
"@>": {
|
|
15
|
-
|
|
26
|
+
Operator: "@>",
|
|
16
27
|
"Right Operand Type": "jsonb",
|
|
17
|
-
|
|
18
|
-
|
|
28
|
+
Description: "Does the left JSON value contain the right JSON path/value entries at the top level?",
|
|
29
|
+
Example: '\'{"a":1, "b":2}\'::jsonb @> \'{"b":2}\'::jsonb',
|
|
19
30
|
},
|
|
20
31
|
"<@": {
|
|
21
|
-
|
|
32
|
+
Operator: "<@",
|
|
22
33
|
"Right Operand Type": "jsonb",
|
|
23
|
-
|
|
24
|
-
|
|
34
|
+
Description: "Are the left JSON path/value entries contained at the top level within the right JSON value?",
|
|
35
|
+
Example: '\'{"b":2}\'::jsonb <@ \'{"a":1, "b":2}\'::jsonb',
|
|
25
36
|
},
|
|
26
37
|
"?": {
|
|
27
|
-
|
|
38
|
+
Operator: "?",
|
|
28
39
|
"Right Operand Type": "text",
|
|
29
|
-
|
|
30
|
-
|
|
40
|
+
Description: "Does the string exist as a top-level key within the JSON value?",
|
|
41
|
+
Example: "'{\"a\":1, \"b\":2}'::jsonb ? 'b'",
|
|
31
42
|
},
|
|
32
43
|
"?|": {
|
|
33
|
-
|
|
44
|
+
Operator: "?|",
|
|
34
45
|
"Right Operand Type": "text[]",
|
|
35
|
-
|
|
36
|
-
|
|
46
|
+
Description: "Do any of these array strings exist as top-level keys?",
|
|
47
|
+
Example: "'{\"a\":1, \"b\":2, \"c\":3}'::jsonb ?| array['b', 'c']",
|
|
37
48
|
},
|
|
38
49
|
"?&": {
|
|
39
|
-
|
|
50
|
+
Operator: "?&",
|
|
40
51
|
"Right Operand Type": "text[]",
|
|
41
|
-
|
|
42
|
-
|
|
52
|
+
Description: "Do all of these array strings exist as top-level keys?",
|
|
53
|
+
Example: "'[\"a\", \"b\"]'::jsonb ?& array['a', 'b']",
|
|
43
54
|
},
|
|
44
55
|
"||": {
|
|
45
|
-
|
|
56
|
+
Operator: "||",
|
|
46
57
|
"Right Operand Type": "jsonb",
|
|
47
|
-
|
|
48
|
-
|
|
58
|
+
Description: "Concatenate two jsonb values into a new jsonb value",
|
|
59
|
+
Example: '\'["a", "b"]\'::jsonb || \'["c", "d"]\'::jsonb',
|
|
49
60
|
},
|
|
50
61
|
"-": {
|
|
51
|
-
|
|
62
|
+
Operator: "-",
|
|
52
63
|
"Right Operand Type": "integer",
|
|
53
|
-
|
|
54
|
-
|
|
64
|
+
Description: "Delete the array element with specified index (Negative integers count from the end). Throws an error if top level container is not an array.",
|
|
65
|
+
Example: '\'["a", "b"]\'::jsonb - 1',
|
|
55
66
|
},
|
|
56
67
|
"#-": {
|
|
57
|
-
|
|
68
|
+
Operator: "#-",
|
|
58
69
|
"Right Operand Type": "text[]",
|
|
59
|
-
|
|
60
|
-
|
|
70
|
+
Description: "Delete the field or element with specified path (for JSON arrays, negative integers count from the end)",
|
|
71
|
+
Example: "'[\"a\", {\"b\":1}]'::jsonb #- '{1,b}'",
|
|
61
72
|
},
|
|
62
73
|
"@?": {
|
|
63
|
-
|
|
74
|
+
Operator: "@?",
|
|
64
75
|
"Right Operand Type": "jsonpath",
|
|
65
|
-
|
|
66
|
-
|
|
76
|
+
Description: "Does JSON path return any item for the specified JSON value?",
|
|
77
|
+
Example: "'{\"a\":[1,2,3,4,5]}'::jsonb @? '$.a[*] ? (@ > 2)'",
|
|
67
78
|
},
|
|
68
79
|
"@@": {
|
|
69
|
-
|
|
80
|
+
Operator: "@@",
|
|
70
81
|
"Right Operand Type": "jsonpath",
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
82
|
+
Description: "Returns the result of JSON path predicate check for the specified JSON value. Only the first item of the result is taken into account. If the result is not Boolean, then null is returned.",
|
|
83
|
+
Example: "'{\"a\":[1,2,3,4,5]}'::jsonb @@ '$.a[*] > 2'",
|
|
84
|
+
},
|
|
74
85
|
};
|
|
75
86
|
exports.JsonbFilterKeys = (0, util_1.getKeys)(exports.JsonbOperands);
|
|
76
87
|
exports.TextFilterKeys = ["$ilike", "$like", "$nilike", "$nlike"];
|
|
77
88
|
exports.TextFilterFTSKeys = ["@@", "@>", "<@", "$contains", "$containedBy"];
|
|
78
|
-
exports.TextFilter_FullTextSearchFilterKeys = [
|
|
79
|
-
|
|
80
|
-
|
|
89
|
+
exports.TextFilter_FullTextSearchFilterKeys = [
|
|
90
|
+
"to_tsquery",
|
|
91
|
+
"plainto_tsquery",
|
|
92
|
+
"phraseto_tsquery",
|
|
93
|
+
"websearch_to_tsquery",
|
|
94
|
+
];
|
|
95
|
+
exports.ArrayFilterOperands = [
|
|
96
|
+
"@>",
|
|
97
|
+
"<@",
|
|
98
|
+
"=",
|
|
99
|
+
"$eq",
|
|
100
|
+
"$contains",
|
|
101
|
+
"$containedBy",
|
|
102
|
+
"&&",
|
|
103
|
+
"$overlaps",
|
|
104
|
+
];
|
|
105
|
+
// | { "|&>": GeoBBox }
|
|
106
|
+
// | { "|>>": GeoBBox }
|
|
107
|
+
/**
|
|
108
|
+
* A's bounding box contains B's.
|
|
109
|
+
*/
|
|
110
|
+
// | { "~": GeoBBox }
|
|
111
|
+
// | { "~=": GeoBBox }
|
|
112
|
+
exports.GeomFilterKeys = [
|
|
113
|
+
"~",
|
|
114
|
+
"~=",
|
|
115
|
+
"@",
|
|
116
|
+
"|&>",
|
|
117
|
+
"|>>",
|
|
118
|
+
">>",
|
|
119
|
+
"=",
|
|
120
|
+
"<<|",
|
|
121
|
+
"<<",
|
|
122
|
+
"&>",
|
|
123
|
+
"&<|",
|
|
124
|
+
"&<",
|
|
125
|
+
"&&&",
|
|
126
|
+
"&&",
|
|
127
|
+
];
|
|
81
128
|
exports.GeomFilter_Funcs = [
|
|
82
129
|
"ST_MakeEnvelope",
|
|
83
130
|
"st_makeenvelope",
|
|
@@ -90,21 +137,18 @@ exports.ComplexFilterComparisonKeys = [
|
|
|
90
137
|
...exports.JsonbFilterKeys,
|
|
91
138
|
...exports.CompareFilterKeys,
|
|
92
139
|
...exports.BetweenFilterKeys,
|
|
93
|
-
...exports.CompareInFilterKeys
|
|
140
|
+
...exports.CompareInFilterKeys,
|
|
94
141
|
];
|
|
95
142
|
exports.COMPLEX_FILTER_KEY = "$filter";
|
|
96
143
|
const _f = {
|
|
97
|
-
"h.$eq": ["2"]
|
|
144
|
+
"h.$eq": ["2"],
|
|
98
145
|
};
|
|
99
146
|
const forcedFilter = {
|
|
100
147
|
// "h.$eq": ["2"]
|
|
101
|
-
$and: [
|
|
102
|
-
{ "h.$eq": [] },
|
|
103
|
-
{ h: { "$containedBy": [] } }
|
|
104
|
-
]
|
|
148
|
+
$and: [{ "h.$eq": [] }, { h: { $containedBy: [] } }],
|
|
105
149
|
};
|
|
106
150
|
const _f2 = {
|
|
107
|
-
$filter: [{ $funcName: ["colname", "opts"] }, ">", 2]
|
|
151
|
+
$filter: [{ $funcName: ["colname", "opts"] }, ">", 2],
|
|
108
152
|
};
|
|
109
153
|
const _d = {
|
|
110
154
|
a: 2,
|
package/dist/filters.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filters.js","sourceRoot":"","sources":["../lib/filters.ts"],"names":[],"mappings":";;;AACA,iCAA6C;AAKhC,QAAA,iBAAiB,GAAG;IAC/B,GAAG,
|
|
1
|
+
{"version":3,"file":"filters.js","sourceRoot":"","sources":["../lib/filters.ts"],"names":[],"mappings":";;;AACA,iCAA6C;AAKhC,QAAA,iBAAiB,GAAG;IAC/B,GAAG;IACH,KAAK;IACL,IAAI;IACJ,GAAG;IACH,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,KAAK;IACL,KAAK;IACL,MAAM;IACN,KAAK;IACL,MAAM;IACN,iBAAiB;IACjB,oBAAoB;CACZ,CAAC;AACE,QAAA,mBAAmB,GAAG,CAAC,KAAK,EAAE,MAAM,CAAU,CAAC;AAC/C,QAAA,iBAAiB,GAAG,CAAC,UAAU,EAAE,aAAa,CAAU,CAAC;AAEzD,QAAA,aAAa,GAAG;IAC3B,IAAI,EAAE;QACJ,QAAQ,EAAE,IAAI;QACd,oBAAoB,EAAE,OAAO;QAC7B,WAAW,EACT,sFAAsF;QACxF,OAAO,EAAE,iDAAiD;KAC3D;IACD,IAAI,EAAE;QACJ,QAAQ,EAAE,IAAI;QACd,oBAAoB,EAAE,OAAO;QAC7B,WAAW,EACT,8FAA8F;QAChG,OAAO,EAAE,iDAAiD;KAC3D;IACD,GAAG,EAAE;QACH,QAAQ,EAAE,GAAG;QACb,oBAAoB,EAAE,MAAM;QAC5B,WAAW,EAAE,iEAAiE;QAC9E,OAAO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AAC;CACL,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export declare const _PG_date: readonly ["date", "timestamp", "timestamptz"];
|
|
|
13
13
|
export declare const _PG_interval: readonly ["interval"];
|
|
14
14
|
export declare const _PG_postgis: readonly ["geometry", "geography"];
|
|
15
15
|
export declare const _PG_geometric: readonly ["point", "line", "lseg", "box", "path", "polygon", "circle"];
|
|
16
|
-
export type PG_COLUMN_UDT_DATA_TYPE = typeof _PG_strings[number] | typeof _PG_numbers[number] | typeof _PG_geometric[number] | typeof _PG_json[number] | typeof _PG_bool[number] | typeof _PG_date[number] | typeof _PG_interval[number] | typeof _PG_postgis[number];
|
|
16
|
+
export type PG_COLUMN_UDT_DATA_TYPE = (typeof _PG_strings)[number] | (typeof _PG_numbers)[number] | (typeof _PG_geometric)[number] | (typeof _PG_json)[number] | (typeof _PG_bool)[number] | (typeof _PG_date)[number] | (typeof _PG_interval)[number] | (typeof _PG_postgis)[number];
|
|
17
17
|
export declare const TS_PG_Types: {
|
|
18
18
|
readonly "number[]": ("_int2" | "_int4" | "_float4" | "_float8" | "_oid")[];
|
|
19
19
|
readonly "boolean[]": "_bool"[];
|
|
@@ -217,7 +217,7 @@ export type JoinPath = {
|
|
|
217
217
|
on?: Record<string, string>[];
|
|
218
218
|
};
|
|
219
219
|
export type RawJoinPath = string | (JoinPath | string)[];
|
|
220
|
-
export type DetailedJoinSelect = Partial<Record<typeof JOIN_KEYS[number], RawJoinPath>> & {
|
|
220
|
+
export type DetailedJoinSelect = Partial<Record<(typeof JOIN_KEYS)[number], RawJoinPath>> & {
|
|
221
221
|
select: Select;
|
|
222
222
|
filter?: FullFilter<void, void>;
|
|
223
223
|
having?: FullFilter<void, void>;
|
|
@@ -244,13 +244,13 @@ type FunctionSelect = FunctionShorthand | FunctionFull;
|
|
|
244
244
|
*/
|
|
245
245
|
type FunctionAliasedSelect = Record<string, FunctionFull>;
|
|
246
246
|
type InclusiveSelect = true | 1 | FunctionSelect | JoinSelect;
|
|
247
|
-
type SelectFuncs<T extends AnyObject = AnyObject, IsTyped = false> = (
|
|
247
|
+
type SelectFuncs<T extends AnyObject = AnyObject, IsTyped = false> = ({
|
|
248
248
|
[K in keyof Partial<T>]: InclusiveSelect;
|
|
249
249
|
} & Record<string, IsTyped extends true ? FunctionFull : InclusiveSelect>) | FunctionAliasedSelect | {
|
|
250
250
|
[K in keyof Partial<T>]: true | 1 | string;
|
|
251
251
|
} | {
|
|
252
252
|
[K in keyof Partial<T>]: 0 | false;
|
|
253
|
-
} | CommonSelect | (keyof Partial<T>)[]
|
|
253
|
+
} | CommonSelect | (keyof Partial<T>)[];
|
|
254
254
|
/** S param is needed to ensure the non typed select works fine */
|
|
255
255
|
export type Select<T extends AnyObject | void = void, S extends DBSchema | void = void> = {
|
|
256
256
|
t: T;
|
|
@@ -266,6 +266,10 @@ export type Select<T extends AnyObject | void = void, S extends DBSchema | void
|
|
|
266
266
|
export type SelectBasic = {
|
|
267
267
|
[key: string]: any;
|
|
268
268
|
} | {} | undefined | "" | "*";
|
|
269
|
+
/**
|
|
270
|
+
* Will return the first row as an object. Will throw an error if more than a row is returned. Use limit: 1 to avoid error.
|
|
271
|
+
*/
|
|
272
|
+
type ReturnTypeRow = "row";
|
|
269
273
|
type CommonSelectParams = {
|
|
270
274
|
/**
|
|
271
275
|
* Max number of rows to return
|
|
@@ -290,30 +294,26 @@ type CommonSelectParams = {
|
|
|
290
294
|
* - statement-no-rls: sql statement without row level security
|
|
291
295
|
* - statement-where: sql statement where condition
|
|
292
296
|
*/
|
|
293
|
-
returnType?:
|
|
297
|
+
returnType?: ReturnTypeRow
|
|
294
298
|
/**
|
|
295
|
-
* Will return the first
|
|
299
|
+
* Will return the first value from the selected field
|
|
296
300
|
*/
|
|
297
|
-
"row"
|
|
298
|
-
/**
|
|
299
|
-
* Will return the first value from the selected field
|
|
300
|
-
*/
|
|
301
301
|
| "value"
|
|
302
302
|
/**
|
|
303
|
-
|
|
304
|
-
|
|
303
|
+
* Will return an array of values from the selected field. Similar to array_agg(field).
|
|
304
|
+
*/
|
|
305
305
|
| "values"
|
|
306
306
|
/**
|
|
307
|
-
|
|
308
|
-
|
|
307
|
+
* Will return the sql statement. Requires publishRawSQL privileges if called by client
|
|
308
|
+
*/
|
|
309
309
|
| "statement"
|
|
310
310
|
/**
|
|
311
|
-
|
|
312
|
-
|
|
311
|
+
* Will return the sql statement excluding the user header. Requires publishRawSQL privileges if called by client
|
|
312
|
+
*/
|
|
313
313
|
| "statement-no-rls"
|
|
314
314
|
/**
|
|
315
|
-
|
|
316
|
-
|
|
315
|
+
* Will return the sql statement where condition. Requires publishRawSQL privileges if called by client
|
|
316
|
+
*/
|
|
317
317
|
| "statement-where";
|
|
318
318
|
};
|
|
319
319
|
export type SelectParams<T extends AnyObject | void = void, S extends DBSchema | void = void> = CommonSelectParams & {
|
|
@@ -483,15 +483,19 @@ type GetColumns = (lang?: string, params?: {
|
|
|
483
483
|
data: AnyObject;
|
|
484
484
|
filter: AnyObject;
|
|
485
485
|
}) => Promise<ValidatedColumnInfo[]>;
|
|
486
|
+
/**
|
|
487
|
+
* Methods for interacting with a view
|
|
488
|
+
* - On client-side some methods are restricted (and undefined) based on publish rules on the server
|
|
489
|
+
*/
|
|
486
490
|
export type ViewHandler<TD extends AnyObject = AnyObject, S extends DBSchema | void = void> = {
|
|
487
491
|
/**
|
|
488
492
|
* Retrieves the table/view info
|
|
489
493
|
*/
|
|
490
|
-
getInfo
|
|
494
|
+
getInfo: (lang?: string) => Promise<TableInfo>;
|
|
491
495
|
/**
|
|
492
496
|
* Retrieves columns metadata of the table/view
|
|
493
497
|
*/
|
|
494
|
-
getColumns
|
|
498
|
+
getColumns: GetColumns;
|
|
495
499
|
/**
|
|
496
500
|
* Retrieves a list of matching records from the view/table
|
|
497
501
|
*/
|
|
@@ -519,6 +523,10 @@ export type ViewHandler<TD extends AnyObject = AnyObject, S extends DBSchema | v
|
|
|
519
523
|
};
|
|
520
524
|
type UpsertDataToPGCastLax<T extends AnyObject> = PartialLax<UpsertDataToPGCast<T>>;
|
|
521
525
|
type InsertData<T extends AnyObject> = UpsertDataToPGCast<T> | UpsertDataToPGCast<T>[];
|
|
526
|
+
/**
|
|
527
|
+
* Methods for interacting with a table
|
|
528
|
+
* - On client-side some methods are restricted (and undefined) based on publish rules on the server
|
|
529
|
+
*/
|
|
522
530
|
export type TableHandler<TD extends AnyObject = AnyObject, S extends DBSchema | void = void> = ViewHandler<TD, S> & {
|
|
523
531
|
/**
|
|
524
532
|
* Updates a record in the table based on the specified filter criteria
|
|
@@ -614,8 +622,8 @@ export type SocketSQLStreamHandlers = {
|
|
|
614
622
|
export type SocketSQLStreamClient = SocketSQLStreamServer & {
|
|
615
623
|
start: (listener: (packet: SocketSQLStreamPacket) => void) => Promise<SocketSQLStreamHandlers>;
|
|
616
624
|
};
|
|
617
|
-
export type CheckForListen<T, O extends SQLOptions> = O["allowListen"] extends true ?
|
|
618
|
-
export type GetSQLReturnType<O extends SQLOptions> = CheckForListen<
|
|
625
|
+
export type CheckForListen<T, O extends SQLOptions> = O["allowListen"] extends true ? DBEventHandles | T : T;
|
|
626
|
+
export type GetSQLReturnType<O extends SQLOptions> = CheckForListen<O["returnType"] extends "row" ? AnyObject | null : O["returnType"] extends "rows" ? AnyObject[] : O["returnType"] extends "value" ? any | null : O["returnType"] extends "values" ? any[] : O["returnType"] extends "statement" ? string : O["returnType"] extends "noticeSubscription" ? DBEventHandles : O["returnType"] extends "stream" ? SocketSQLStreamClient : SQLResult<O["returnType"]>, O>;
|
|
619
627
|
export type SQLHandler =
|
|
620
628
|
/**
|
|
621
629
|
*
|
|
@@ -742,10 +750,10 @@ export declare const RULE_METHODS: {
|
|
|
742
750
|
readonly sync: readonly ["sync", "unsync"];
|
|
743
751
|
readonly subscribe: readonly ["unsubscribe", "subscribe", "subscribeOne"];
|
|
744
752
|
};
|
|
745
|
-
export type MethodKey = typeof RULE_METHODS[keyof typeof RULE_METHODS][number];
|
|
746
|
-
export type TableSchemaForClient = Record<string, Partial<Record<MethodKey,
|
|
753
|
+
export type MethodKey = (typeof RULE_METHODS)[keyof typeof RULE_METHODS][number];
|
|
754
|
+
export type TableSchemaForClient = Record<string, Partial<Record<MethodKey, MethodKey extends "insert" ? {
|
|
747
755
|
allowedNestedInserts?: string[];
|
|
748
|
-
} : AnyObject
|
|
756
|
+
} : AnyObject>>>;
|
|
749
757
|
export type TableSchema = {
|
|
750
758
|
schema: string;
|
|
751
759
|
name: string;
|
|
@@ -763,7 +771,7 @@ export type TableSchema = {
|
|
|
763
771
|
delete: boolean;
|
|
764
772
|
};
|
|
765
773
|
};
|
|
766
|
-
export type MethodFunction = (...args: any) =>
|
|
774
|
+
export type MethodFunction = (...args: any) => any | Promise<any>;
|
|
767
775
|
export type MethodFullDef = {
|
|
768
776
|
input: Record<string, JSONB.JSONBSchema>;
|
|
769
777
|
run: MethodFunction;
|
|
@@ -795,10 +803,10 @@ export type ClientSchema = {
|
|
|
795
803
|
tableSchemaErrors: TableSchemaErrors;
|
|
796
804
|
tableSchema?: DBSchemaTable[];
|
|
797
805
|
schema: TableSchemaForClient;
|
|
798
|
-
methods: (string | {
|
|
806
|
+
methods: (string | ({
|
|
799
807
|
name: string;
|
|
800
808
|
description?: string;
|
|
801
|
-
} & Pick<MethodFullDef, "input" | "output">)[];
|
|
809
|
+
} & Pick<MethodFullDef, "input" | "output">))[];
|
|
802
810
|
};
|
|
803
811
|
export type ProstglesError = {
|
|
804
812
|
message: string;
|
|
@@ -815,7 +823,7 @@ export { CONTENT_TYPE_TO_EXT } from "./files";
|
|
|
815
823
|
export type { ALLOWED_CONTENT_TYPE, ALLOWED_EXTENSION, FileColumnConfig, FileType } from "./files";
|
|
816
824
|
export * from "./filters";
|
|
817
825
|
export * from "./jsonb";
|
|
818
|
-
export type { ClientExpressData, ClientSyncHandles, ClientSyncInfo, ClientSyncPullResponse, SyncBatchParams, SyncConfig, onUpdatesParams } from "./replication";
|
|
826
|
+
export type { ClientExpressData, ClientSyncHandles, ClientSyncInfo, ClientSyncPullResponse, SyncBatchParams, SyncConfig, onUpdatesParams, } from "./replication";
|
|
819
827
|
export * from "./util";
|
|
820
828
|
export * from "./auth";
|
|
821
829
|
//# sourceMappingURL=index.d.ts.map
|