prostgles-types 3.0.18 → 3.0.20
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/filters.d.ts +66 -2
- package/dist/filters.d.ts.map +1 -1
- package/dist/filters.js +73 -4
- package/dist/filters.js.map +1 -1
- package/dist/index_umd.js +1 -1
- package/lib/filters.ts +84 -5
- package/package.json +1 -1
package/dist/filters.d.ts
CHANGED
|
@@ -2,10 +2,73 @@ import { DBSchema } from ".";
|
|
|
2
2
|
import { ExactlyOne } from "./util";
|
|
3
3
|
export declare const CompareFilterKeys: readonly ["=", "$eq", "<>", ">", "<", ">=", "<=", "$eq", "$ne", "$gt", "$gte", "$lte"];
|
|
4
4
|
export declare const CompareInFilterKeys: readonly ["$in", "$nin"];
|
|
5
|
+
export declare const JsonbOperands: {
|
|
6
|
+
readonly "@>": {
|
|
7
|
+
readonly Operator: "@>";
|
|
8
|
+
readonly "Right Operand Type": "jsonb";
|
|
9
|
+
readonly Description: "Does the left JSON value contain the right JSON path/value entries at the top level?";
|
|
10
|
+
readonly Example: "'{\"a\":1, \"b\":2}'::jsonb @> '{\"b\":2}'::jsonb";
|
|
11
|
+
};
|
|
12
|
+
readonly "<@": {
|
|
13
|
+
readonly Operator: "<@";
|
|
14
|
+
readonly "Right Operand Type": "jsonb";
|
|
15
|
+
readonly Description: "Are the left JSON path/value entries contained at the top level within the right JSON value?";
|
|
16
|
+
readonly Example: "'{\"b\":2}'::jsonb <@ '{\"a\":1, \"b\":2}'::jsonb";
|
|
17
|
+
};
|
|
18
|
+
readonly "?": {
|
|
19
|
+
readonly Operator: "?";
|
|
20
|
+
readonly "Right Operand Type": "text";
|
|
21
|
+
readonly Description: "Does the string exist as a top-level key within the JSON value?";
|
|
22
|
+
readonly Example: "'{\"a\":1, \"b\":2}'::jsonb ? 'b'";
|
|
23
|
+
};
|
|
24
|
+
readonly "?|": {
|
|
25
|
+
readonly Operator: "?|";
|
|
26
|
+
readonly "Right Operand Type": "text[]";
|
|
27
|
+
readonly Description: "Do any of these array strings exist as top-level keys?";
|
|
28
|
+
readonly Example: "'{\"a\":1, \"b\":2, \"c\":3}'::jsonb ?| array['b', 'c']";
|
|
29
|
+
};
|
|
30
|
+
readonly "?&": {
|
|
31
|
+
readonly Operator: "?&";
|
|
32
|
+
readonly "Right Operand Type": "text[]";
|
|
33
|
+
readonly Description: "Do all of these array strings exist as top-level keys?";
|
|
34
|
+
readonly Example: "'[\"a\", \"b\"]'::jsonb ?& array['a', 'b']";
|
|
35
|
+
};
|
|
36
|
+
readonly "||": {
|
|
37
|
+
readonly Operator: "||";
|
|
38
|
+
readonly "Right Operand Type": "jsonb";
|
|
39
|
+
readonly Description: "Concatenate two jsonb values into a new jsonb value";
|
|
40
|
+
readonly Example: "'[\"a\", \"b\"]'::jsonb || '[\"c\", \"d\"]'::jsonb";
|
|
41
|
+
};
|
|
42
|
+
readonly "-": {
|
|
43
|
+
readonly Operator: "-";
|
|
44
|
+
readonly "Right Operand Type": "integer";
|
|
45
|
+
readonly 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.";
|
|
46
|
+
readonly Example: "'[\"a\", \"b\"]'::jsonb - 1";
|
|
47
|
+
};
|
|
48
|
+
readonly "#-": {
|
|
49
|
+
readonly Operator: "#-";
|
|
50
|
+
readonly "Right Operand Type": "text[]";
|
|
51
|
+
readonly Description: "Delete the field or element with specified path (for JSON arrays, negative integers count from the end)";
|
|
52
|
+
readonly Example: "'[\"a\", {\"b\":1}]'::jsonb #- '{1,b}'";
|
|
53
|
+
};
|
|
54
|
+
readonly "@?": {
|
|
55
|
+
readonly Operator: "@?";
|
|
56
|
+
readonly "Right Operand Type": "jsonpath";
|
|
57
|
+
readonly Description: "Does JSON path return any item for the specified JSON value?";
|
|
58
|
+
readonly Example: "'{\"a\":[1,2,3,4,5]}'::jsonb @? '$.a[*] ? (@ > 2)'";
|
|
59
|
+
};
|
|
60
|
+
readonly "@@": {
|
|
61
|
+
readonly Operator: "@@";
|
|
62
|
+
readonly "Right Operand Type": "jsonpath";
|
|
63
|
+
readonly 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.";
|
|
64
|
+
readonly Example: "'{\"a\":[1,2,3,4,5]}'::jsonb @@ '$.a[*] > 2'";
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
export declare const JsonbFilterKeys: ("@>" | "<@" | "?" | "?|" | "?&" | "||" | "-" | "#-" | "@?" | "@@")[];
|
|
5
68
|
export declare type CompareFilter<T = Date | number | string | boolean> = T | ExactlyOne<Record<typeof CompareFilterKeys[number], T>> | ExactlyOne<Record<typeof CompareInFilterKeys[number], T[]>> | {
|
|
6
69
|
"$between": [T, T];
|
|
7
70
|
};
|
|
8
|
-
export declare const TextFilterKeys: readonly ["$ilike", "$like"];
|
|
71
|
+
export declare const TextFilterKeys: readonly ["$ilike", "$like", "$nilike", "$nlike"];
|
|
9
72
|
export declare const TextFilterFTSKeys: readonly ["@@", "@>", "<@", "$contains", "$containedBy"];
|
|
10
73
|
export declare const TextFilter_FullTextSearchFilterKeys: readonly ["to_tsquery", "plainto_tsquery", "phraseto_tsquery", "websearch_to_tsquery"];
|
|
11
74
|
export declare type FullTextSearchFilter = ExactlyOne<Record<typeof TextFilter_FullTextSearchFilterKeys[number], string[]>>;
|
|
@@ -21,7 +84,7 @@ export declare type GeomFilter = {
|
|
|
21
84
|
"@": GeoBBox;
|
|
22
85
|
};
|
|
23
86
|
export declare const GeomFilterKeys: readonly ["~", "~=", "@", "|&>", "|>>", ">>", "=", "<<|", "<<", "&>", "&<|", "&<", "&&&", "&&"];
|
|
24
|
-
export declare const GeomFilter_Funcs:
|
|
87
|
+
export declare const GeomFilter_Funcs: readonly ["ST_MakeEnvelope", "st_makeenvelope", "ST_MakePolygon", "st_makepolygon"];
|
|
25
88
|
export declare type AllowedTSTypes = string | number | boolean | Date | any[];
|
|
26
89
|
export declare type AnyObject = {
|
|
27
90
|
[key: string]: any;
|
|
@@ -29,6 +92,7 @@ export declare type AnyObject = {
|
|
|
29
92
|
export declare type FilterDataType<T = any> = T extends string ? TextFilter : T extends number ? CompareFilter<T> : T extends boolean ? CompareFilter<T> : T extends Date ? CompareFilter<T> : T extends any[] ? ArrayFilter<T> : (CompareFilter<T> | ArrayFilter<T> | TextFilter | GeomFilter);
|
|
30
93
|
export declare const EXISTS_KEYS: readonly ["$exists", "$notExists", "$existsJoined", "$notExistsJoined"];
|
|
31
94
|
export declare type EXISTS_KEY = typeof EXISTS_KEYS[number];
|
|
95
|
+
export declare const COMPLEX_FILTER_KEY: "$filter";
|
|
32
96
|
declare type BasicFilter<Field extends string, DataType extends any> = Partial<{
|
|
33
97
|
[K in Extract<typeof CompareFilterKeys[number], string> as `${Field}.${K}`]: DataType;
|
|
34
98
|
}> | Partial<{
|
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,MAAM,GAAG,CAAC;AAC7B,OAAO,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"filters.d.ts","sourceRoot":"","sources":["../lib/filters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAW,MAAM,QAAQ,CAAC;AAG7C,eAAO,MAAM,iBAAiB,wFAA+E,CAAC;AAC9G,eAAO,MAAM,mBAAmB,0BAA2B,CAAC;AAE5D,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6DhB,CAAC;AAEX,eAAO,MAAM,eAAe,uEAAyB,CAAC;AAKrD,oBAAY,aAAa,CAAC,CAAC,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,IAI5D,CAAC,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,EAAE,MAAM,GAAG,UAAU,CAAA;KAAE;CAChC,CAAC,CAAA;AAMF,oBAAY,UAAU,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,IAClD,eAAe,CAAC,CAAC,CAAC,CAAA;AAOtB,oBAAY,UAAU,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,EAAE,CAAC,GAAG,IAAI,IAC7D;IAAE,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,CAAA;CAAE,GACzB;IAAE,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,CAAA;CAAE,GACxB,UAAU,CAAC,CAAC,CAAC,GACb,YAAY,CAAC,CAAC,CAAC,CAIjB;AAsBD,oBAAY,eAAe,CAAC,CAAC,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,IAAI;KACvD,GAAG,IAAI,MAAM,OAAO,CAAC,CAAC,GAAG;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC,GAAG,GAAG;CACxD,CAAA"}
|
package/dist/filters.js
CHANGED
|
@@ -1,16 +1,85 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EXISTS_KEYS = exports.GeomFilter_Funcs = exports.GeomFilterKeys = exports.ArrayFilterOperands = exports.TextFilter_FullTextSearchFilterKeys = exports.TextFilterFTSKeys = exports.TextFilterKeys = exports.CompareInFilterKeys = exports.CompareFilterKeys = void 0;
|
|
3
|
+
exports.COMPLEX_FILTER_KEY = exports.EXISTS_KEYS = exports.GeomFilter_Funcs = exports.GeomFilterKeys = exports.ArrayFilterOperands = exports.TextFilter_FullTextSearchFilterKeys = exports.TextFilterFTSKeys = exports.TextFilterKeys = exports.JsonbFilterKeys = exports.JsonbOperands = exports.CompareInFilterKeys = exports.CompareFilterKeys = void 0;
|
|
4
|
+
const util_1 = require("./util");
|
|
4
5
|
exports.CompareFilterKeys = ["=", "$eq", "<>", ">", "<", ">=", "<=", "$eq", "$ne", "$gt", "$gte", "$lte"];
|
|
5
6
|
exports.CompareInFilterKeys = ["$in", "$nin"];
|
|
6
|
-
exports.
|
|
7
|
+
exports.JsonbOperands = {
|
|
8
|
+
"@>": {
|
|
9
|
+
"Operator": "@>",
|
|
10
|
+
"Right Operand Type": "jsonb",
|
|
11
|
+
"Description": "Does the left JSON value contain the right JSON path/value entries at the top level?",
|
|
12
|
+
"Example": "'{\"a\":1, \"b\":2}'::jsonb @> '{\"b\":2}'::jsonb"
|
|
13
|
+
},
|
|
14
|
+
"<@": {
|
|
15
|
+
"Operator": "<@",
|
|
16
|
+
"Right Operand Type": "jsonb",
|
|
17
|
+
"Description": "Are the left JSON path/value entries contained at the top level within the right JSON value?",
|
|
18
|
+
"Example": "'{\"b\":2}'::jsonb <@ '{\"a\":1, \"b\":2}'::jsonb"
|
|
19
|
+
},
|
|
20
|
+
"?": {
|
|
21
|
+
"Operator": "?",
|
|
22
|
+
"Right Operand Type": "text",
|
|
23
|
+
"Description": "Does the string exist as a top-level key within the JSON value?",
|
|
24
|
+
"Example": "'{\"a\":1, \"b\":2}'::jsonb ? 'b'"
|
|
25
|
+
},
|
|
26
|
+
"?|": {
|
|
27
|
+
"Operator": "?|",
|
|
28
|
+
"Right Operand Type": "text[]",
|
|
29
|
+
"Description": "Do any of these array strings exist as top-level keys?",
|
|
30
|
+
"Example": "'{\"a\":1, \"b\":2, \"c\":3}'::jsonb ?| array['b', 'c']"
|
|
31
|
+
},
|
|
32
|
+
"?&": {
|
|
33
|
+
"Operator": "?&",
|
|
34
|
+
"Right Operand Type": "text[]",
|
|
35
|
+
"Description": "Do all of these array strings exist as top-level keys?",
|
|
36
|
+
"Example": "'[\"a\", \"b\"]'::jsonb ?& array['a', 'b']"
|
|
37
|
+
},
|
|
38
|
+
"||": {
|
|
39
|
+
"Operator": "||",
|
|
40
|
+
"Right Operand Type": "jsonb",
|
|
41
|
+
"Description": "Concatenate two jsonb values into a new jsonb value",
|
|
42
|
+
"Example": "'[\"a\", \"b\"]'::jsonb || '[\"c\", \"d\"]'::jsonb"
|
|
43
|
+
},
|
|
44
|
+
"-": {
|
|
45
|
+
"Operator": "-",
|
|
46
|
+
"Right Operand Type": "integer",
|
|
47
|
+
"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.",
|
|
48
|
+
"Example": "'[\"a\", \"b\"]'::jsonb - 1"
|
|
49
|
+
},
|
|
50
|
+
"#-": {
|
|
51
|
+
"Operator": "#-",
|
|
52
|
+
"Right Operand Type": "text[]",
|
|
53
|
+
"Description": "Delete the field or element with specified path (for JSON arrays, negative integers count from the end)",
|
|
54
|
+
"Example": "'[\"a\", {\"b\":1}]'::jsonb #- '{1,b}'"
|
|
55
|
+
},
|
|
56
|
+
"@?": {
|
|
57
|
+
"Operator": "@?",
|
|
58
|
+
"Right Operand Type": "jsonpath",
|
|
59
|
+
"Description": "Does JSON path return any item for the specified JSON value?",
|
|
60
|
+
"Example": "'{\"a\":[1,2,3,4,5]}'::jsonb @? '$.a[*] ? (@ > 2)'"
|
|
61
|
+
},
|
|
62
|
+
"@@": {
|
|
63
|
+
"Operator": "@@",
|
|
64
|
+
"Right Operand Type": "jsonpath",
|
|
65
|
+
"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.",
|
|
66
|
+
"Example": "'{\"a\":[1,2,3,4,5]}'::jsonb @@ '$.a[*] > 2'"
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
exports.JsonbFilterKeys = (0, util_1.getKeys)(exports.JsonbOperands);
|
|
70
|
+
exports.TextFilterKeys = ["$ilike", "$like", "$nilike", "$nlike"];
|
|
7
71
|
exports.TextFilterFTSKeys = ["@@", "@>", "<@", "$contains", "$containedBy"];
|
|
8
72
|
exports.TextFilter_FullTextSearchFilterKeys = ["to_tsquery", "plainto_tsquery", "phraseto_tsquery", "websearch_to_tsquery"];
|
|
9
73
|
exports.ArrayFilterOperands = [...exports.TextFilterFTSKeys, "&&", "$overlaps"];
|
|
10
74
|
exports.GeomFilterKeys = ["~", "~=", "@", "|&>", "|>>", ">>", "=", "<<|", "<<", "&>", "&<|", "&<", "&&&", "&&"];
|
|
11
|
-
|
|
12
|
-
|
|
75
|
+
exports.GeomFilter_Funcs = [
|
|
76
|
+
"ST_MakeEnvelope",
|
|
77
|
+
"st_makeenvelope",
|
|
78
|
+
"ST_MakePolygon",
|
|
79
|
+
"st_makepolygon",
|
|
80
|
+
];
|
|
13
81
|
exports.EXISTS_KEYS = ["$exists", "$notExists", "$existsJoined", "$notExistsJoined"];
|
|
82
|
+
exports.COMPLEX_FILTER_KEY = "$filter";
|
|
14
83
|
const f = {
|
|
15
84
|
"h.$eq": ["2"]
|
|
16
85
|
};
|
package/dist/filters.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filters.js","sourceRoot":"","sources":["../lib/filters.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"filters.js","sourceRoot":"","sources":["../lib/filters.ts"],"names":[],"mappings":";;;AACA,iCAA6C;AAGhC,QAAA,iBAAiB,GAAG,CAAC,GAAG,EAAE,KAAK,EAAC,IAAI,EAAC,GAAG,EAAC,GAAG,EAAC,IAAI,EAAC,IAAI,EAAC,KAAK,EAAC,KAAK,EAAC,KAAK,EAAC,MAAM,EAAC,MAAM,CAAU,CAAC;AACjG,QAAA,mBAAmB,GAAG,CAAC,KAAK,EAAE,MAAM,CAAU,CAAC;AAE/C,QAAA,aAAa,GAAG;IAC3B,IAAI,EAAE;QACJ,UAAU,EAAE,IAAI;QAChB,oBAAoB,EAAE,OAAO;QAC7B,aAAa,EAAE,sFAAsF;QACrG,SAAS,EAAE,mDAAmD;KAC/D;IACD,IAAI,EAAE;QACJ,UAAU,EAAE,IAAI;QAChB,oBAAoB,EAAE,OAAO;QAC7B,aAAa,EAAE,8FAA8F;QAC7G,SAAS,EAAE,mDAAm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AAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,cAAc,CAAU,CAAC;AAE7E,QAAA,mCAAmC,GAAG,CAAC,YAAY,EAAC,iBAAiB,EAAC,kBAAkB,EAAC,sBAAsB,CAAU,CAAC;AAW1H,QAAA,mBAAmB,GAAG,CAAC,GAAG,yBAAiB,EAAE,IAAI,EAAE,WAAW,CAAU,CAAC;AAiDzE,QAAA,cAAc,GAAG,CAAC,GAAG,EAAC,IAAI,EAAC,GAAG,EAAC,KAAK,EAAC,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAU,CAAC;AAC7G,QAAA,gBAAgB,GAAI;IAC/B,iBAAiB;IACjB,iBAAiB;IACjB,gBAAgB;IAChB,gBAAgB;CACR,CAAC;AAeE,QAAA,WAAW,GAAG,CAAC,SAAS,EAAE,YAAY,EAAE,eAAe,EAAE,kBAAkB,CAAU,CAAC;AAYtF,QAAA,kBAAkB,GAAG,SAAkB,CAAC;AAqErD,MAAM,CAAC,GAAmB;IACvB,OAAO,EAAE,CAAC,GAAG,CAAC;CAChB,CAAA;AACD,MAAM,YAAY,GAAmB;IAEnC,IAAI,EAAE;QACJ,EAAE,OAAO,EAAE,EAAE,EAAE;QACf,EAAE,CAAC,EAAE,EAAE,cAAc,EAAE,EAAE,EAAE,EAAE;KAC9B;CACF,CAAA"}
|
package/dist/index_umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var i=t();for(var n in i)("object"==typeof exports?exports:e)[n]=i[n]}}(this||window,(()=>(()=>{"use strict";var e={31:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CONTENT_TYPE_TO_EXT=void 0,t.CONTENT_TYPE_TO_EXT={"text/html":["html","htm","shtml"],"text/css":["css"],"text/csv":["csv"],"text/tsv":["tsv"],"text/xml":["xml"],"text/mathml":["mml"],"text/plain":["txt"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/x-component":["htc"],"image/gif":["gif"],"image/jpeg":["jpeg","jpg"],"image/png":["png"],"image/tiff":["tif","tiff"],"image/vnd.wap.wbmp":["wbmp"],"image/x-icon":["ico"],"image/x-jng":["jng"],"image/x-ms-bmp":["bmp"],"image/svg+xml":["svg"],"image/webp":["webp"],"application/sql":["sql"],"application/x-javascript":["js"],"application/atom+xml":["atom"],"application/rss+xml":["rss"],"application/java-archive":["jar","war","ear"],"application/mac-binhex40":["hqx"],"application/msword":["doc","docx"],"application/pdf":["pdf"],"application/postscript":["ps","eps","ai"],"application/rtf":["rtf"],"application/vnd.ms-excel":["xls","xlsx"],"application/vnd.ms-powerpoint":["ppt","pptx"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/x-7z-compressed":["7z"],"application/x-cocoa":["cco"],"application/x-java-archive-diff":["jardiff"],"application/x-java-jnlp-file":["jnlp"],"application/x-makeself":["run"],"application/x-perl":["pl","pm"],"application/x-pilot":["prc","pdb"],"application/x-rar-compressed":["rar"],"application/x-redhat-package-manager":["rpm"],"application/x-sea":["sea"],"application/x-shockwave-flash":["swf"],"application/x-stuffit":["sit"],"application/x-tcl":["tcl","tk"],"application/x-x509-ca-cert":["der","pem","crt"],"application/x-xpinstall":["xpi"],"application/xhtml+xml":["xhtml"],"application/zip":["zip"],"application/octet-stream":["bin","exe","dll","deb","dmg","eot","iso","img","msi","msp","msm"],"audio/midi":["mid","midi","kar"],"audio/mpeg":["mp3"],"audio/ogg":["ogg"],"audio/x-realaudio":["ra"],"video/3gpp":["3gpp","3gp"],"video/mpeg":["mpeg","mpg"],"video/quicktime":["mov"],"video/x-flv":["flv"],"video/x-mng":["mng"],"video/x-ms-asf":["asx","asf"],"video/x-ms-wmv":["wmv"],"video/x-msvideo":["avi"],"video/mp4":["m4v","mp4"],"video/webm":["webm"]}},444:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EXISTS_KEYS=t.GeomFilter_Funcs=t.GeomFilterKeys=t.ArrayFilterOperands=t.TextFilter_FullTextSearchFilterKeys=t.TextFilterFTSKeys=t.TextFilterKeys=t.CompareInFilterKeys=t.CompareFilterKeys=void 0,t.CompareFilterKeys=["=","$eq","<>",">","<",">=","<=","$eq","$ne","$gt","$gte","$lte"],t.CompareInFilterKeys=["$in","$nin"],t.TextFilterKeys=["$ilike","$like"],t.TextFilterFTSKeys=["@@","@>","<@","$contains","$containedBy"],t.TextFilter_FullTextSearchFilterKeys=["to_tsquery","plainto_tsquery","phraseto_tsquery","websearch_to_tsquery"],t.ArrayFilterOperands=[...t.TextFilterFTSKeys,"&&","$overlaps"],t.GeomFilterKeys=["~","~=","@","|&>","|>>",">>","=","<<|","<<","&>","&<|","&<","&&&","&&"];const i=["ST_MakeEnvelope","ST_MakePolygon"];t.GeomFilter_Funcs=i.concat(i.map((e=>e.toLowerCase()))),t.EXISTS_KEYS=["$exists","$notExists","$existsJoined","$notExistsJoined"]},590:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var r=Object.getOwnPropertyDescriptor(t,i);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,r)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),r=this&&this.__exportStar||function(e,t){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(t,i)||n(t,e,i)};Object.defineProperty(t,"__esModule",{value:!0}),t.CONTENT_TYPE_TO_EXT=t.getKeys=t.isObject=t.isDefined=t.get=t.WAL=t.unpatchText=t.stableStringify=t.isEmpty=t.getTextPatch=t.omitKeys=t.pickKeys=t.asName=t.RULE_METHODS=t.CHANNELS=t.TS_PG_Types=t._PG_geometric=t._PG_postgis=t._PG_date=t._PG_bool=t._PG_json=t._PG_numbers=t._PG_strings=void 0,t._PG_strings=["bpchar","char","varchar","text","citext","uuid","bytea","time","timetz","interval","name","cidr","inet","macaddr","macaddr8","int4range","int8range","numrange","tsvector"],t._PG_numbers=["int2","int4","int8","float4","float8","numeric","money","oid"],t._PG_json=["json","jsonb"],t._PG_bool=["bool"],t._PG_date=["date","timestamp","timestamptz"],t._PG_postgis=["geometry","geography"],t._PG_geometric=["point","line","lseg","box","path","polygon","circle"],t.TS_PG_Types={string:[...t._PG_strings,"lseg"],number:t._PG_numbers,boolean:t._PG_bool,Date:t._PG_date,"Array<number>":t._PG_numbers.map((e=>`_${e}`)),"Array<boolean>":t._PG_bool.map((e=>`_${e}`)),"Array<string>":t._PG_strings.map((e=>`_${e}`)),"Array<Object>":t._PG_json.map((e=>`_${e}`)),"Array<Date>":t._PG_date.map((e=>`_${e}`)),any:[]};const s="_psqlWS_.";t.CHANNELS={SCHEMA_CHANGED:s+"schema-changed",SCHEMA:s+"schema",DEFAULT:s,SQL:"_psqlWS_.sql",METHOD:"_psqlWS_.method",NOTICE_EV:"_psqlWS_.notice",LISTEN_EV:"_psqlWS_.listen",REGISTER:"_psqlWS_.register",LOGIN:"_psqlWS_.login",LOGOUT:"_psqlWS_.logout",AUTHGUARD:"_psqlWS_.authguard",CONNECTION:"_psqlWS_.connection",_preffix:s},t.RULE_METHODS={getColumns:["getColumns"],getInfo:["getInfo"],insert:["insert","upsert"],update:["update","upsert","updateBatch"],select:["findOne","find","count","size"],delete:["delete","remove"],sync:["sync","unsync"],subscribe:["unsubscribe","subscribe","subscribeOne"]};var o=i(128);Object.defineProperty(t,"asName",{enumerable:!0,get:function(){return o.asName}}),Object.defineProperty(t,"pickKeys",{enumerable:!0,get:function(){return o.pickKeys}}),Object.defineProperty(t,"omitKeys",{enumerable:!0,get:function(){return o.omitKeys}}),Object.defineProperty(t,"getTextPatch",{enumerable:!0,get:function(){return o.getTextPatch}}),Object.defineProperty(t,"isEmpty",{enumerable:!0,get:function(){return o.isEmpty}}),Object.defineProperty(t,"stableStringify",{enumerable:!0,get:function(){return o.stableStringify}}),Object.defineProperty(t,"unpatchText",{enumerable:!0,get:function(){return o.unpatchText}}),Object.defineProperty(t,"WAL",{enumerable:!0,get:function(){return o.WAL}}),Object.defineProperty(t,"get",{enumerable:!0,get:function(){return o.get}}),Object.defineProperty(t,"isDefined",{enumerable:!0,get:function(){return o.isDefined}}),Object.defineProperty(t,"isObject",{enumerable:!0,get:function(){return o.isObject}}),Object.defineProperty(t,"getKeys",{enumerable:!0,get:function(){return o.getKeys}}),r(i(444),t);var a=i(31);Object.defineProperty(t,"CONTENT_TYPE_TO_EXT",{enumerable:!0,get:function(){return a.CONTENT_TYPE_TO_EXT}})},899:(e,t)=>{function i(e,t){var i=e[0],n=e[1],c=e[2],l=e[3];i=r(i,n,c,l,t[0],7,-680876936),l=r(l,i,n,c,t[1],12,-389564586),c=r(c,l,i,n,t[2],17,606105819),n=r(n,c,l,i,t[3],22,-1044525330),i=r(i,n,c,l,t[4],7,-176418897),l=r(l,i,n,c,t[5],12,1200080426),c=r(c,l,i,n,t[6],17,-1473231341),n=r(n,c,l,i,t[7],22,-45705983),i=r(i,n,c,l,t[8],7,1770035416),l=r(l,i,n,c,t[9],12,-1958414417),c=r(c,l,i,n,t[10],17,-42063),n=r(n,c,l,i,t[11],22,-1990404162),i=r(i,n,c,l,t[12],7,1804603682),l=r(l,i,n,c,t[13],12,-40341101),c=r(c,l,i,n,t[14],17,-1502002290),i=s(i,n=r(n,c,l,i,t[15],22,1236535329),c,l,t[1],5,-165796510),l=s(l,i,n,c,t[6],9,-1069501632),c=s(c,l,i,n,t[11],14,643717713),n=s(n,c,l,i,t[0],20,-373897302),i=s(i,n,c,l,t[5],5,-701558691),l=s(l,i,n,c,t[10],9,38016083),c=s(c,l,i,n,t[15],14,-660478335),n=s(n,c,l,i,t[4],20,-405537848),i=s(i,n,c,l,t[9],5,568446438),l=s(l,i,n,c,t[14],9,-1019803690),c=s(c,l,i,n,t[3],14,-187363961),n=s(n,c,l,i,t[8],20,1163531501),i=s(i,n,c,l,t[13],5,-1444681467),l=s(l,i,n,c,t[2],9,-51403784),c=s(c,l,i,n,t[7],14,1735328473),i=o(i,n=s(n,c,l,i,t[12],20,-1926607734),c,l,t[5],4,-378558),l=o(l,i,n,c,t[8],11,-2022574463),c=o(c,l,i,n,t[11],16,1839030562),n=o(n,c,l,i,t[14],23,-35309556),i=o(i,n,c,l,t[1],4,-1530992060),l=o(l,i,n,c,t[4],11,1272893353),c=o(c,l,i,n,t[7],16,-155497632),n=o(n,c,l,i,t[10],23,-1094730640),i=o(i,n,c,l,t[13],4,681279174),l=o(l,i,n,c,t[0],11,-358537222),c=o(c,l,i,n,t[3],16,-722521979),n=o(n,c,l,i,t[6],23,76029189),i=o(i,n,c,l,t[9],4,-640364487),l=o(l,i,n,c,t[12],11,-421815835),c=o(c,l,i,n,t[15],16,530742520),i=a(i,n=o(n,c,l,i,t[2],23,-995338651),c,l,t[0],6,-198630844),l=a(l,i,n,c,t[7],10,1126891415),c=a(c,l,i,n,t[14],15,-1416354905),n=a(n,c,l,i,t[5],21,-57434055),i=a(i,n,c,l,t[12],6,1700485571),l=a(l,i,n,c,t[3],10,-1894986606),c=a(c,l,i,n,t[10],15,-1051523),n=a(n,c,l,i,t[1],21,-2054922799),i=a(i,n,c,l,t[8],6,1873313359),l=a(l,i,n,c,t[15],10,-30611744),c=a(c,l,i,n,t[6],15,-1560198380),n=a(n,c,l,i,t[13],21,1309151649),i=a(i,n,c,l,t[4],6,-145523070),l=a(l,i,n,c,t[11],10,-1120210379),c=a(c,l,i,n,t[2],15,718787259),n=a(n,c,l,i,t[9],21,-343485551),e[0]=u(i,e[0]),e[1]=u(n,e[1]),e[2]=u(c,e[2]),e[3]=u(l,e[3])}function n(e,t,i,n,r,s){return t=u(u(t,e),u(n,s)),u(t<<r|t>>>32-r,i)}function r(e,t,i,r,s,o,a){return n(t&i|~t&r,e,t,s,o,a)}function s(e,t,i,r,s,o,a){return n(t&r|i&~r,e,t,s,o,a)}function o(e,t,i,r,s,o,a){return n(t^i^r,e,t,s,o,a)}function a(e,t,i,r,s,o,a){return n(i^(t|~r),e,t,s,o,a)}function c(e){var t,i=[];for(t=0;t<64;t+=4)i[t>>2]=e.charCodeAt(t)+(e.charCodeAt(t+1)<<8)+(e.charCodeAt(t+2)<<16)+(e.charCodeAt(t+3)<<24);return i}Object.defineProperty(t,"__esModule",{value:!0}),t.md5=t.md5cycle=void 0,t.md5cycle=i;var l="0123456789abcdef".split("");function p(e){for(var t="",i=0;i<4;i++)t+=l[e>>8*i+4&15]+l[e>>8*i&15];return t}function d(e){return function(e){for(var t=0;t<e.length;t++)e[t]=p(e[t]);return e.join("")}(function(e){var t,n=e.length,r=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=e.length;t+=64)i(r,c(e.substring(t-64,t)));e=e.substring(t-64);var s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<e.length;t++)s[t>>2]|=e.charCodeAt(t)<<(t%4<<3);if(s[t>>2]|=128<<(t%4<<3),t>55)for(i(r,s),t=0;t<16;t++)s[t]=0;return s[14]=8*n,i(r,s),r}(e))}function u(e,t){return e+t&4294967295}t.md5=d,d("hello")},128:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getKeys=t.isDefined=t.isObject=t.get=t.isEmpty=t.WAL=t.unpatchText=t.getTextPatch=t.stableStringify=t.omitKeys=t.pickKeys=t.asName=void 0;const n=i(899);function r(e,t=[],i=!1){let n=t;if(!n.length)return{};if(e&&n.length){let t={};return n.forEach((n=>{i&&void 0===e[n]||(t[n]=e[n])})),t}return e}function s(e){for(var t in e)return!1;return!0}function o(e){return Object.keys(e)}t.asName=function(e){if(null==e||!e.toString||!e.toString())throw"Expecting a non empty string";return`"${e.toString().replace(/"/g,'""')}"`},t.pickKeys=r,t.omitKeys=function(e,t){return r(e,o(e).filter((e=>!t.includes(e))))},t.stableStringify=function(e,t){t||(t={}),"function"==typeof t&&(t={cmp:t});var i,n="boolean"==typeof t.cycles&&t.cycles,r=t.cmp&&(i=t.cmp,function(e){return function(t,n){var r={key:t,value:e[t]},s={key:n,value:e[n]};return i(r,s)}}),s=[];return function e(t){if(t&&t.toJSON&&"function"==typeof t.toJSON&&(t=t.toJSON()),void 0!==t){if("number"==typeof t)return isFinite(t)?""+t:"null";if("object"!=typeof t)return JSON.stringify(t);var i,o;if(Array.isArray(t)){for(o="[",i=0;i<t.length;i++)i&&(o+=","),o+=e(t[i])||"null";return o+"]"}if(null===t)return"null";if(-1!==s.indexOf(t)){if(n)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var a=s.push(t)-1,c=Object.keys(t).sort(r&&r(t));for(o="",i=0;i<c.length;i++){var l=c[i],p=e(t[l]);p&&(o&&(o+=","),o+=JSON.stringify(l)+":"+p)}return s.splice(a,1),"{"+o+"}"}}(e)},t.getTextPatch=function(e,t){if(!(e&&t&&e.trim().length&&t.trim().length))return t;if(e===t)return{from:0,to:0,text:"",md5:(0,n.md5)(t)};function i(i=1){let n=i<1?-1:0,r=!1;for(;!r&&Math.abs(n)<=t.length;){const s=i<1?[n]:[0,n];e.slice(...s)!==t.slice(...s)?r=!0:n+=1*Math.sign(i)}return n}let r=i()-1,s=e.length+i(-1)+1,o=t.length+i(-1)+1;return{from:r,to:s,text:t.slice(r,o),md5:(0,n.md5)(t)}},t.unpatchText=function(e,t){if(!t||"string"==typeof t)return t;const{from:i,to:r,text:s,md5:o}=t;if(null===s||null===e)return s;let a=e.slice(0,i)+s+e.slice(r);if(o&&(0,n.md5)(a)!==o)throw"Patch text error: Could not match md5 hash: (original/result) \n"+e+"\n"+a;return a},t.WAL=class{constructor(e){if(this.changed={},this.sending={},this.sentHistory={},this.callbacks=[],this.sort=(e,t)=>{const{orderBy:i}=this.options;return i&&e&&t&&i.map((i=>{if(!(i.fieldName in e)||!(i.fieldName in t))throw"Replication error: \n some orderBy fields missing from data";let n=i.asc?e[i.fieldName]:t[i.fieldName],r=i.asc?t[i.fieldName]:e[i.fieldName],s=+n-+r,o=n<r?-1:n==r?0:1;return"number"===i.tsDataType&&Number.isFinite(s)?s:o})).find((e=>e))||0},this.isInHistory=e=>{if(!e)throw"Provide item";const t=e[this.options.synced_field];if(!Number.isFinite(+t))throw"Provided item Synced field value is missing/invalid ";const i=this.sentHistory[this.getIdStr(e)],n=i?.[this.options.synced_field];if(i){if(!Number.isFinite(+n))throw"Provided historic item Synced field value is missing/invalid";if(+n==+t)return!0}return!1},this.addData=e=>{s(this.changed)&&this.options.onSendStart&&this.options.onSendStart(),e.map((e=>{var t;const{initial:i,current:n,delta:r}={...e};if(!n)throw"Expecting { current: object, initial?: object }";const s=this.getIdStr(n);this.changed??(this.changed={}),(t=this.changed)[s]??(t[s]={initial:i,current:n,delta:r}),this.changed[s].current={...this.changed[s].current,...n},this.changed[s].delta={...this.changed[s].delta,...r}})),this.sendItems()},this.isOnSending=!1,this.isSendingTimeout=void 0,this.willDeleteHistory=void 0,this.sendItems=async()=>{const{DEBUG_MODE:e,onSend:t,onSendEnd:i,batch_size:n,throttle:r,historyAgeSeconds:o=2}=this.options;if(this.isSendingTimeout||this.sending&&!s(this.sending))return;if(!this.changed||s(this.changed))return;let a,c=[],l=[],p={};Object.keys(this.changed).sort(((e,t)=>this.sort(this.changed[e].current,this.changed[t].current))).slice(0,n).map((e=>{let t={...this.changed[e]};this.sending[e]={...t},l.push({...t}),p[e]={...t.current},delete this.changed[e]})),c=l.map((e=>{let t={};return Object.keys(e.current).map((i=>{const n=e.initial?.[i],r=e.current[i];var s,o;![this.options.synced_field,...this.options.id_fields].includes(i)&&((s=n)===(o=r)||(["number","string","boolean"].includes(typeof s)?s===o:JSON.stringify(s)===JSON.stringify(o)))||(t[i]=r)})),t})),e&&console.log(this.options.id," SENDING lr->",c[c.length-1]),this.isSendingTimeout||(this.isSendingTimeout=setTimeout((()=>{this.isSendingTimeout=void 0,s(this.changed)||this.sendItems()}),r)),this.isOnSending=!0;try{await t(c,l),o&&(this.sentHistory={...this.sentHistory,...p},this.willDeleteHistory||(this.willDeleteHistory=setTimeout((()=>{this.willDeleteHistory=void 0,this.sentHistory={}}),1e3*o)))}catch(e){a=e,console.error("WAL onSend failed:",e,c,l)}if(this.isOnSending=!1,this.callbacks.length){const e=Object.keys(this.sending);this.callbacks.forEach(((t,i)=>{t.idStrs=t.idStrs.filter((t=>e.includes(t))),t.idStrs.length||t.cb(a)})),this.callbacks=this.callbacks.filter((e=>e.idStrs.length))}this.sending={},e&&console.log(this.options.id," SENT lr->",c[c.length-1]),s(this.changed)?i&&i(c,l,a):this.sendItems()},this.options={...e},!this.options.orderBy){const{synced_field:t,id_fields:i}=e;this.options.orderBy=[t,...i.sort()].map((e=>({fieldName:e,tsDataType:e===t?"number":"string",asc:!0})))}}isSending(){const e=this.isOnSending||!(s(this.sending)&&s(this.changed));return this.options.DEBUG_MODE&&console.log(this.options.id," CHECKING isSending ->",e),e}getIdStr(e){return this.options.id_fields.sort().map((t=>`${e[t]||""}`)).join(".")}getIdObj(e){let t={};return this.options.id_fields.sort().map((i=>{t[i]=e[i]})),t}getDeltaObj(e){let t={};return Object.keys(e).map((i=>{this.options.id_fields.includes(i)||(t[i]=e[i])})),t}},t.isEmpty=s,t.get=function(e,t){let i=t,n=e;return e?("string"==typeof i&&(i=i.split(".")),i.reduce(((e,t)=>e&&e[t]?e[t]:void 0),n)):e},t.isObject=function(e){return Boolean(e&&"object"==typeof e&&!Array.isArray(e))},t.isDefined=function(e){return null!=e},t.getKeys=o}},t={};return function i(n){var r=t[n];if(void 0!==r)return r.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,i),s.exports}(590)})()));
|
|
1
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var i=t();for(var n in i)("object"==typeof exports?exports:e)[n]=i[n]}}(this||window,(()=>(()=>{"use strict";var e={31:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CONTENT_TYPE_TO_EXT=void 0,t.CONTENT_TYPE_TO_EXT={"text/html":["html","htm","shtml"],"text/css":["css"],"text/csv":["csv"],"text/tsv":["tsv"],"text/xml":["xml"],"text/mathml":["mml"],"text/plain":["txt"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/x-component":["htc"],"image/gif":["gif"],"image/jpeg":["jpeg","jpg"],"image/png":["png"],"image/tiff":["tif","tiff"],"image/vnd.wap.wbmp":["wbmp"],"image/x-icon":["ico"],"image/x-jng":["jng"],"image/x-ms-bmp":["bmp"],"image/svg+xml":["svg"],"image/webp":["webp"],"application/sql":["sql"],"application/x-javascript":["js"],"application/atom+xml":["atom"],"application/rss+xml":["rss"],"application/java-archive":["jar","war","ear"],"application/mac-binhex40":["hqx"],"application/msword":["doc","docx"],"application/pdf":["pdf"],"application/postscript":["ps","eps","ai"],"application/rtf":["rtf"],"application/vnd.ms-excel":["xls","xlsx"],"application/vnd.ms-powerpoint":["ppt","pptx"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/x-7z-compressed":["7z"],"application/x-cocoa":["cco"],"application/x-java-archive-diff":["jardiff"],"application/x-java-jnlp-file":["jnlp"],"application/x-makeself":["run"],"application/x-perl":["pl","pm"],"application/x-pilot":["prc","pdb"],"application/x-rar-compressed":["rar"],"application/x-redhat-package-manager":["rpm"],"application/x-sea":["sea"],"application/x-shockwave-flash":["swf"],"application/x-stuffit":["sit"],"application/x-tcl":["tcl","tk"],"application/x-x509-ca-cert":["der","pem","crt"],"application/x-xpinstall":["xpi"],"application/xhtml+xml":["xhtml"],"application/zip":["zip"],"application/octet-stream":["bin","exe","dll","deb","dmg","eot","iso","img","msi","msp","msm"],"audio/midi":["mid","midi","kar"],"audio/mpeg":["mp3"],"audio/ogg":["ogg"],"audio/x-realaudio":["ra"],"video/3gpp":["3gpp","3gp"],"video/mpeg":["mpeg","mpg"],"video/quicktime":["mov"],"video/x-flv":["flv"],"video/x-mng":["mng"],"video/x-ms-asf":["asx","asf"],"video/x-ms-wmv":["wmv"],"video/x-msvideo":["avi"],"video/mp4":["m4v","mp4"],"video/webm":["webm"]}},444:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.COMPLEX_FILTER_KEY=t.EXISTS_KEYS=t.GeomFilter_Funcs=t.GeomFilterKeys=t.ArrayFilterOperands=t.TextFilter_FullTextSearchFilterKeys=t.TextFilterFTSKeys=t.TextFilterKeys=t.JsonbFilterKeys=t.JsonbOperands=t.CompareInFilterKeys=t.CompareFilterKeys=void 0;const n=i(128);t.CompareFilterKeys=["=","$eq","<>",">","<",">=","<=","$eq","$ne","$gt","$gte","$lte"],t.CompareInFilterKeys=["$in","$nin"],t.JsonbOperands={"@>":{Operator:"@>","Right Operand Type":"jsonb",Description:"Does the left JSON value contain the right JSON path/value entries at the top level?",Example:'\'{"a":1, "b":2}\'::jsonb @> \'{"b":2}\'::jsonb'},"<@":{Operator:"<@","Right Operand Type":"jsonb",Description:"Are the left JSON path/value entries contained at the top level within the right JSON value?",Example:'\'{"b":2}\'::jsonb <@ \'{"a":1, "b":2}\'::jsonb'},"?":{Operator:"?","Right Operand Type":"text",Description:"Does the string exist as a top-level key within the JSON value?",Example:"'{\"a\":1, \"b\":2}'::jsonb ? 'b'"},"?|":{Operator:"?|","Right Operand Type":"text[]",Description:"Do any of these array strings exist as top-level keys?",Example:"'{\"a\":1, \"b\":2, \"c\":3}'::jsonb ?| array['b', 'c']"},"?&":{Operator:"?&","Right Operand Type":"text[]",Description:"Do all of these array strings exist as top-level keys?",Example:"'[\"a\", \"b\"]'::jsonb ?& array['a', 'b']"},"||":{Operator:"||","Right Operand Type":"jsonb",Description:"Concatenate two jsonb values into a new jsonb value",Example:'\'["a", "b"]\'::jsonb || \'["c", "d"]\'::jsonb'},"-":{Operator:"-","Right Operand Type":"integer",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.",Example:'\'["a", "b"]\'::jsonb - 1'},"#-":{Operator:"#-","Right Operand Type":"text[]",Description:"Delete the field or element with specified path (for JSON arrays, negative integers count from the end)",Example:"'[\"a\", {\"b\":1}]'::jsonb #- '{1,b}'"},"@?":{Operator:"@?","Right Operand Type":"jsonpath",Description:"Does JSON path return any item for the specified JSON value?",Example:"'{\"a\":[1,2,3,4,5]}'::jsonb @? '$.a[*] ? (@ > 2)'"},"@@":{Operator:"@@","Right Operand Type":"jsonpath",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.",Example:"'{\"a\":[1,2,3,4,5]}'::jsonb @@ '$.a[*] > 2'"}},t.JsonbFilterKeys=(0,n.getKeys)(t.JsonbOperands),t.TextFilterKeys=["$ilike","$like","$nilike","$nlike"],t.TextFilterFTSKeys=["@@","@>","<@","$contains","$containedBy"],t.TextFilter_FullTextSearchFilterKeys=["to_tsquery","plainto_tsquery","phraseto_tsquery","websearch_to_tsquery"],t.ArrayFilterOperands=[...t.TextFilterFTSKeys,"&&","$overlaps"],t.GeomFilterKeys=["~","~=","@","|&>","|>>",">>","=","<<|","<<","&>","&<|","&<","&&&","&&"],t.GeomFilter_Funcs=["ST_MakeEnvelope","st_makeenvelope","ST_MakePolygon","st_makepolygon"],t.EXISTS_KEYS=["$exists","$notExists","$existsJoined","$notExistsJoined"],t.COMPLEX_FILTER_KEY="$filter"},590:function(e,t,i){var n=this&&this.__createBinding||(Object.create?function(e,t,i,n){void 0===n&&(n=i);var r=Object.getOwnPropertyDescriptor(t,i);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,n,r)}:function(e,t,i,n){void 0===n&&(n=i),e[n]=t[i]}),r=this&&this.__exportStar||function(e,t){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(t,i)||n(t,e,i)};Object.defineProperty(t,"__esModule",{value:!0}),t.CONTENT_TYPE_TO_EXT=t.getKeys=t.isObject=t.isDefined=t.get=t.WAL=t.unpatchText=t.stableStringify=t.isEmpty=t.getTextPatch=t.omitKeys=t.pickKeys=t.asName=t.RULE_METHODS=t.CHANNELS=t.TS_PG_Types=t._PG_geometric=t._PG_postgis=t._PG_date=t._PG_bool=t._PG_json=t._PG_numbers=t._PG_strings=void 0,t._PG_strings=["bpchar","char","varchar","text","citext","uuid","bytea","time","timetz","interval","name","cidr","inet","macaddr","macaddr8","int4range","int8range","numrange","tsvector"],t._PG_numbers=["int2","int4","int8","float4","float8","numeric","money","oid"],t._PG_json=["json","jsonb"],t._PG_bool=["bool"],t._PG_date=["date","timestamp","timestamptz"],t._PG_postgis=["geometry","geography"],t._PG_geometric=["point","line","lseg","box","path","polygon","circle"],t.TS_PG_Types={string:[...t._PG_strings,"lseg"],number:t._PG_numbers,boolean:t._PG_bool,Date:t._PG_date,"Array<number>":t._PG_numbers.map((e=>`_${e}`)),"Array<boolean>":t._PG_bool.map((e=>`_${e}`)),"Array<string>":t._PG_strings.map((e=>`_${e}`)),"Array<Object>":t._PG_json.map((e=>`_${e}`)),"Array<Date>":t._PG_date.map((e=>`_${e}`)),any:[]};const s="_psqlWS_.";t.CHANNELS={SCHEMA_CHANGED:s+"schema-changed",SCHEMA:s+"schema",DEFAULT:s,SQL:"_psqlWS_.sql",METHOD:"_psqlWS_.method",NOTICE_EV:"_psqlWS_.notice",LISTEN_EV:"_psqlWS_.listen",REGISTER:"_psqlWS_.register",LOGIN:"_psqlWS_.login",LOGOUT:"_psqlWS_.logout",AUTHGUARD:"_psqlWS_.authguard",CONNECTION:"_psqlWS_.connection",_preffix:s},t.RULE_METHODS={getColumns:["getColumns"],getInfo:["getInfo"],insert:["insert","upsert"],update:["update","upsert","updateBatch"],select:["findOne","find","count","size"],delete:["delete","remove"],sync:["sync","unsync"],subscribe:["unsubscribe","subscribe","subscribeOne"]};var o=i(128);Object.defineProperty(t,"asName",{enumerable:!0,get:function(){return o.asName}}),Object.defineProperty(t,"pickKeys",{enumerable:!0,get:function(){return o.pickKeys}}),Object.defineProperty(t,"omitKeys",{enumerable:!0,get:function(){return o.omitKeys}}),Object.defineProperty(t,"getTextPatch",{enumerable:!0,get:function(){return o.getTextPatch}}),Object.defineProperty(t,"isEmpty",{enumerable:!0,get:function(){return o.isEmpty}}),Object.defineProperty(t,"stableStringify",{enumerable:!0,get:function(){return o.stableStringify}}),Object.defineProperty(t,"unpatchText",{enumerable:!0,get:function(){return o.unpatchText}}),Object.defineProperty(t,"WAL",{enumerable:!0,get:function(){return o.WAL}}),Object.defineProperty(t,"get",{enumerable:!0,get:function(){return o.get}}),Object.defineProperty(t,"isDefined",{enumerable:!0,get:function(){return o.isDefined}}),Object.defineProperty(t,"isObject",{enumerable:!0,get:function(){return o.isObject}}),Object.defineProperty(t,"getKeys",{enumerable:!0,get:function(){return o.getKeys}}),r(i(444),t);var a=i(31);Object.defineProperty(t,"CONTENT_TYPE_TO_EXT",{enumerable:!0,get:function(){return a.CONTENT_TYPE_TO_EXT}})},899:(e,t)=>{function i(e,t){var i=e[0],n=e[1],l=e[2],c=e[3];i=r(i,n,l,c,t[0],7,-680876936),c=r(c,i,n,l,t[1],12,-389564586),l=r(l,c,i,n,t[2],17,606105819),n=r(n,l,c,i,t[3],22,-1044525330),i=r(i,n,l,c,t[4],7,-176418897),c=r(c,i,n,l,t[5],12,1200080426),l=r(l,c,i,n,t[6],17,-1473231341),n=r(n,l,c,i,t[7],22,-45705983),i=r(i,n,l,c,t[8],7,1770035416),c=r(c,i,n,l,t[9],12,-1958414417),l=r(l,c,i,n,t[10],17,-42063),n=r(n,l,c,i,t[11],22,-1990404162),i=r(i,n,l,c,t[12],7,1804603682),c=r(c,i,n,l,t[13],12,-40341101),l=r(l,c,i,n,t[14],17,-1502002290),i=s(i,n=r(n,l,c,i,t[15],22,1236535329),l,c,t[1],5,-165796510),c=s(c,i,n,l,t[6],9,-1069501632),l=s(l,c,i,n,t[11],14,643717713),n=s(n,l,c,i,t[0],20,-373897302),i=s(i,n,l,c,t[5],5,-701558691),c=s(c,i,n,l,t[10],9,38016083),l=s(l,c,i,n,t[15],14,-660478335),n=s(n,l,c,i,t[4],20,-405537848),i=s(i,n,l,c,t[9],5,568446438),c=s(c,i,n,l,t[14],9,-1019803690),l=s(l,c,i,n,t[3],14,-187363961),n=s(n,l,c,i,t[8],20,1163531501),i=s(i,n,l,c,t[13],5,-1444681467),c=s(c,i,n,l,t[2],9,-51403784),l=s(l,c,i,n,t[7],14,1735328473),i=o(i,n=s(n,l,c,i,t[12],20,-1926607734),l,c,t[5],4,-378558),c=o(c,i,n,l,t[8],11,-2022574463),l=o(l,c,i,n,t[11],16,1839030562),n=o(n,l,c,i,t[14],23,-35309556),i=o(i,n,l,c,t[1],4,-1530992060),c=o(c,i,n,l,t[4],11,1272893353),l=o(l,c,i,n,t[7],16,-155497632),n=o(n,l,c,i,t[10],23,-1094730640),i=o(i,n,l,c,t[13],4,681279174),c=o(c,i,n,l,t[0],11,-358537222),l=o(l,c,i,n,t[3],16,-722521979),n=o(n,l,c,i,t[6],23,76029189),i=o(i,n,l,c,t[9],4,-640364487),c=o(c,i,n,l,t[12],11,-421815835),l=o(l,c,i,n,t[15],16,530742520),i=a(i,n=o(n,l,c,i,t[2],23,-995338651),l,c,t[0],6,-198630844),c=a(c,i,n,l,t[7],10,1126891415),l=a(l,c,i,n,t[14],15,-1416354905),n=a(n,l,c,i,t[5],21,-57434055),i=a(i,n,l,c,t[12],6,1700485571),c=a(c,i,n,l,t[3],10,-1894986606),l=a(l,c,i,n,t[10],15,-1051523),n=a(n,l,c,i,t[1],21,-2054922799),i=a(i,n,l,c,t[8],6,1873313359),c=a(c,i,n,l,t[15],10,-30611744),l=a(l,c,i,n,t[6],15,-1560198380),n=a(n,l,c,i,t[13],21,1309151649),i=a(i,n,l,c,t[4],6,-145523070),c=a(c,i,n,l,t[11],10,-1120210379),l=a(l,c,i,n,t[2],15,718787259),n=a(n,l,c,i,t[9],21,-343485551),e[0]=u(i,e[0]),e[1]=u(n,e[1]),e[2]=u(l,e[2]),e[3]=u(c,e[3])}function n(e,t,i,n,r,s){return t=u(u(t,e),u(n,s)),u(t<<r|t>>>32-r,i)}function r(e,t,i,r,s,o,a){return n(t&i|~t&r,e,t,s,o,a)}function s(e,t,i,r,s,o,a){return n(t&r|i&~r,e,t,s,o,a)}function o(e,t,i,r,s,o,a){return n(t^i^r,e,t,s,o,a)}function a(e,t,i,r,s,o,a){return n(i^(t|~r),e,t,s,o,a)}function l(e){var t,i=[];for(t=0;t<64;t+=4)i[t>>2]=e.charCodeAt(t)+(e.charCodeAt(t+1)<<8)+(e.charCodeAt(t+2)<<16)+(e.charCodeAt(t+3)<<24);return i}Object.defineProperty(t,"__esModule",{value:!0}),t.md5=t.md5cycle=void 0,t.md5cycle=i;var c="0123456789abcdef".split("");function p(e){for(var t="",i=0;i<4;i++)t+=c[e>>8*i+4&15]+c[e>>8*i&15];return t}function d(e){return function(e){for(var t=0;t<e.length;t++)e[t]=p(e[t]);return e.join("")}(function(e){var t,n=e.length,r=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=e.length;t+=64)i(r,l(e.substring(t-64,t)));e=e.substring(t-64);var s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<e.length;t++)s[t>>2]|=e.charCodeAt(t)<<(t%4<<3);if(s[t>>2]|=128<<(t%4<<3),t>55)for(i(r,s),t=0;t<16;t++)s[t]=0;return s[14]=8*n,i(r,s),r}(e))}function u(e,t){return e+t&4294967295}t.md5=d,d("hello")},128:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getKeys=t.isDefined=t.isObject=t.get=t.isEmpty=t.WAL=t.unpatchText=t.getTextPatch=t.stableStringify=t.omitKeys=t.pickKeys=t.asName=void 0;const n=i(899);function r(e,t=[],i=!1){let n=t;if(!n.length)return{};if(e&&n.length){let t={};return n.forEach((n=>{i&&void 0===e[n]||(t[n]=e[n])})),t}return e}function s(e){for(var t in e)return!1;return!0}function o(e){return Object.keys(e)}t.asName=function(e){if(null==e||!e.toString||!e.toString())throw"Expecting a non empty string";return`"${e.toString().replace(/"/g,'""')}"`},t.pickKeys=r,t.omitKeys=function(e,t){return r(e,o(e).filter((e=>!t.includes(e))))},t.stableStringify=function(e,t){t||(t={}),"function"==typeof t&&(t={cmp:t});var i,n="boolean"==typeof t.cycles&&t.cycles,r=t.cmp&&(i=t.cmp,function(e){return function(t,n){var r={key:t,value:e[t]},s={key:n,value:e[n]};return i(r,s)}}),s=[];return function e(t){if(t&&t.toJSON&&"function"==typeof t.toJSON&&(t=t.toJSON()),void 0!==t){if("number"==typeof t)return isFinite(t)?""+t:"null";if("object"!=typeof t)return JSON.stringify(t);var i,o;if(Array.isArray(t)){for(o="[",i=0;i<t.length;i++)i&&(o+=","),o+=e(t[i])||"null";return o+"]"}if(null===t)return"null";if(-1!==s.indexOf(t)){if(n)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var a=s.push(t)-1,l=Object.keys(t).sort(r&&r(t));for(o="",i=0;i<l.length;i++){var c=l[i],p=e(t[c]);p&&(o&&(o+=","),o+=JSON.stringify(c)+":"+p)}return s.splice(a,1),"{"+o+"}"}}(e)},t.getTextPatch=function(e,t){if(!(e&&t&&e.trim().length&&t.trim().length))return t;if(e===t)return{from:0,to:0,text:"",md5:(0,n.md5)(t)};function i(i=1){let n=i<1?-1:0,r=!1;for(;!r&&Math.abs(n)<=t.length;){const s=i<1?[n]:[0,n];e.slice(...s)!==t.slice(...s)?r=!0:n+=1*Math.sign(i)}return n}let r=i()-1,s=e.length+i(-1)+1,o=t.length+i(-1)+1;return{from:r,to:s,text:t.slice(r,o),md5:(0,n.md5)(t)}},t.unpatchText=function(e,t){if(!t||"string"==typeof t)return t;const{from:i,to:r,text:s,md5:o}=t;if(null===s||null===e)return s;let a=e.slice(0,i)+s+e.slice(r);if(o&&(0,n.md5)(a)!==o)throw"Patch text error: Could not match md5 hash: (original/result) \n"+e+"\n"+a;return a},t.WAL=class{constructor(e){if(this.changed={},this.sending={},this.sentHistory={},this.callbacks=[],this.sort=(e,t)=>{const{orderBy:i}=this.options;return i&&e&&t&&i.map((i=>{if(!(i.fieldName in e)||!(i.fieldName in t))throw"Replication error: \n some orderBy fields missing from data";let n=i.asc?e[i.fieldName]:t[i.fieldName],r=i.asc?t[i.fieldName]:e[i.fieldName],s=+n-+r,o=n<r?-1:n==r?0:1;return"number"===i.tsDataType&&Number.isFinite(s)?s:o})).find((e=>e))||0},this.isInHistory=e=>{if(!e)throw"Provide item";const t=e[this.options.synced_field];if(!Number.isFinite(+t))throw"Provided item Synced field value is missing/invalid ";const i=this.sentHistory[this.getIdStr(e)],n=i?.[this.options.synced_field];if(i){if(!Number.isFinite(+n))throw"Provided historic item Synced field value is missing/invalid";if(+n==+t)return!0}return!1},this.addData=e=>{s(this.changed)&&this.options.onSendStart&&this.options.onSendStart(),e.map((e=>{var t;const{initial:i,current:n,delta:r}={...e};if(!n)throw"Expecting { current: object, initial?: object }";const s=this.getIdStr(n);this.changed??(this.changed={}),(t=this.changed)[s]??(t[s]={initial:i,current:n,delta:r}),this.changed[s].current={...this.changed[s].current,...n},this.changed[s].delta={...this.changed[s].delta,...r}})),this.sendItems()},this.isOnSending=!1,this.isSendingTimeout=void 0,this.willDeleteHistory=void 0,this.sendItems=async()=>{const{DEBUG_MODE:e,onSend:t,onSendEnd:i,batch_size:n,throttle:r,historyAgeSeconds:o=2}=this.options;if(this.isSendingTimeout||this.sending&&!s(this.sending))return;if(!this.changed||s(this.changed))return;let a,l=[],c=[],p={};Object.keys(this.changed).sort(((e,t)=>this.sort(this.changed[e].current,this.changed[t].current))).slice(0,n).map((e=>{let t={...this.changed[e]};this.sending[e]={...t},c.push({...t}),p[e]={...t.current},delete this.changed[e]})),l=c.map((e=>{let t={};return Object.keys(e.current).map((i=>{const n=e.initial?.[i],r=e.current[i];var s,o;![this.options.synced_field,...this.options.id_fields].includes(i)&&((s=n)===(o=r)||(["number","string","boolean"].includes(typeof s)?s===o:JSON.stringify(s)===JSON.stringify(o)))||(t[i]=r)})),t})),e&&console.log(this.options.id," SENDING lr->",l[l.length-1]),this.isSendingTimeout||(this.isSendingTimeout=setTimeout((()=>{this.isSendingTimeout=void 0,s(this.changed)||this.sendItems()}),r)),this.isOnSending=!0;try{await t(l,c),o&&(this.sentHistory={...this.sentHistory,...p},this.willDeleteHistory||(this.willDeleteHistory=setTimeout((()=>{this.willDeleteHistory=void 0,this.sentHistory={}}),1e3*o)))}catch(e){a=e,console.error("WAL onSend failed:",e,l,c)}if(this.isOnSending=!1,this.callbacks.length){const e=Object.keys(this.sending);this.callbacks.forEach(((t,i)=>{t.idStrs=t.idStrs.filter((t=>e.includes(t))),t.idStrs.length||t.cb(a)})),this.callbacks=this.callbacks.filter((e=>e.idStrs.length))}this.sending={},e&&console.log(this.options.id," SENT lr->",l[l.length-1]),s(this.changed)?i&&i(l,c,a):this.sendItems()},this.options={...e},!this.options.orderBy){const{synced_field:t,id_fields:i}=e;this.options.orderBy=[t,...i.sort()].map((e=>({fieldName:e,tsDataType:e===t?"number":"string",asc:!0})))}}isSending(){const e=this.isOnSending||!(s(this.sending)&&s(this.changed));return this.options.DEBUG_MODE&&console.log(this.options.id," CHECKING isSending ->",e),e}getIdStr(e){return this.options.id_fields.sort().map((t=>`${e[t]||""}`)).join(".")}getIdObj(e){let t={};return this.options.id_fields.sort().map((i=>{t[i]=e[i]})),t}getDeltaObj(e){let t={};return Object.keys(e).map((i=>{this.options.id_fields.includes(i)||(t[i]=e[i])})),t}},t.isEmpty=s,t.get=function(e,t){let i=t,n=e;return e?("string"==typeof i&&(i=i.split(".")),i.reduce(((e,t)=>e&&e[t]?e[t]:void 0),n)):e},t.isObject=function(e){return Boolean(e&&"object"==typeof e&&!Array.isArray(e))},t.isDefined=function(e){return null!=e},t.getKeys=o}},t={};return function i(n){var r=t[n];if(void 0!==r)return r.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,i),s.exports}(590)})()));
|
package/lib/filters.ts
CHANGED
|
@@ -1,10 +1,75 @@
|
|
|
1
1
|
import { DBSchema } from ".";
|
|
2
|
-
import { ExactlyOne } from "./util";
|
|
2
|
+
import { ExactlyOne, getKeys } from "./util";
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
export const CompareFilterKeys = ["=", "$eq","<>",">","<",">=","<=","$eq","$ne","$gt","$gte","$lte"] as const;
|
|
6
6
|
export const CompareInFilterKeys = ["$in", "$nin"] as const;
|
|
7
7
|
|
|
8
|
+
export const JsonbOperands = {
|
|
9
|
+
"@>": {
|
|
10
|
+
"Operator": "@>",
|
|
11
|
+
"Right Operand Type": "jsonb",
|
|
12
|
+
"Description": "Does the left JSON value contain the right JSON path/value entries at the top level?",
|
|
13
|
+
"Example": "'{\"a\":1, \"b\":2}'::jsonb @> '{\"b\":2}'::jsonb"
|
|
14
|
+
},
|
|
15
|
+
"<@": {
|
|
16
|
+
"Operator": "<@",
|
|
17
|
+
"Right Operand Type": "jsonb",
|
|
18
|
+
"Description": "Are the left JSON path/value entries contained at the top level within the right JSON value?",
|
|
19
|
+
"Example": "'{\"b\":2}'::jsonb <@ '{\"a\":1, \"b\":2}'::jsonb"
|
|
20
|
+
},
|
|
21
|
+
"?": {
|
|
22
|
+
"Operator": "?",
|
|
23
|
+
"Right Operand Type": "text",
|
|
24
|
+
"Description": "Does the string exist as a top-level key within the JSON value?",
|
|
25
|
+
"Example": "'{\"a\":1, \"b\":2}'::jsonb ? 'b'"
|
|
26
|
+
},
|
|
27
|
+
"?|": {
|
|
28
|
+
"Operator": "?|",
|
|
29
|
+
"Right Operand Type": "text[]",
|
|
30
|
+
"Description": "Do any of these array strings exist as top-level keys?",
|
|
31
|
+
"Example": "'{\"a\":1, \"b\":2, \"c\":3}'::jsonb ?| array['b', 'c']"
|
|
32
|
+
},
|
|
33
|
+
"?&": {
|
|
34
|
+
"Operator": "?&",
|
|
35
|
+
"Right Operand Type": "text[]",
|
|
36
|
+
"Description": "Do all of these array strings exist as top-level keys?",
|
|
37
|
+
"Example": "'[\"a\", \"b\"]'::jsonb ?& array['a', 'b']"
|
|
38
|
+
},
|
|
39
|
+
"||": {
|
|
40
|
+
"Operator": "||",
|
|
41
|
+
"Right Operand Type": "jsonb",
|
|
42
|
+
"Description": "Concatenate two jsonb values into a new jsonb value",
|
|
43
|
+
"Example": "'[\"a\", \"b\"]'::jsonb || '[\"c\", \"d\"]'::jsonb"
|
|
44
|
+
},
|
|
45
|
+
"-": {
|
|
46
|
+
"Operator": "-",
|
|
47
|
+
"Right Operand Type": "integer",
|
|
48
|
+
"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.",
|
|
49
|
+
"Example": "'[\"a\", \"b\"]'::jsonb - 1"
|
|
50
|
+
},
|
|
51
|
+
"#-": {
|
|
52
|
+
"Operator": "#-",
|
|
53
|
+
"Right Operand Type": "text[]",
|
|
54
|
+
"Description": "Delete the field or element with specified path (for JSON arrays, negative integers count from the end)",
|
|
55
|
+
"Example": "'[\"a\", {\"b\":1}]'::jsonb #- '{1,b}'"
|
|
56
|
+
},
|
|
57
|
+
"@?": {
|
|
58
|
+
"Operator": "@?",
|
|
59
|
+
"Right Operand Type": "jsonpath",
|
|
60
|
+
"Description": "Does JSON path return any item for the specified JSON value?",
|
|
61
|
+
"Example": "'{\"a\":[1,2,3,4,5]}'::jsonb @? '$.a[*] ? (@ > 2)'"
|
|
62
|
+
},
|
|
63
|
+
"@@": {
|
|
64
|
+
"Operator": "@@",
|
|
65
|
+
"Right Operand Type": "jsonpath",
|
|
66
|
+
"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.",
|
|
67
|
+
"Example": "'{\"a\":[1,2,3,4,5]}'::jsonb @@ '$.a[*] > 2'"
|
|
68
|
+
}
|
|
69
|
+
} as const;
|
|
70
|
+
|
|
71
|
+
export const JsonbFilterKeys = getKeys(JsonbOperands);
|
|
72
|
+
|
|
8
73
|
/**
|
|
9
74
|
* Example: col_name: { $gt: 2 }
|
|
10
75
|
*/
|
|
@@ -18,7 +83,7 @@ export const CompareInFilterKeys = ["$in", "$nin"] as const;
|
|
|
18
83
|
| ExactlyOne<Record<typeof CompareInFilterKeys[number], T[]>>
|
|
19
84
|
| { "$between": [T, T] }
|
|
20
85
|
;
|
|
21
|
-
export const TextFilterKeys = ["$ilike", "$like"] as const;
|
|
86
|
+
export const TextFilterKeys = ["$ilike", "$like", "$nilike", "$nlike"] as const;
|
|
22
87
|
|
|
23
88
|
export const TextFilterFTSKeys = ["@@", "@>", "<@", "$contains", "$containedBy"] as const;
|
|
24
89
|
|
|
@@ -83,15 +148,19 @@ export type GeomFilter =
|
|
|
83
148
|
// | { "~=": GeoBBox }
|
|
84
149
|
;
|
|
85
150
|
export const GeomFilterKeys = ["~","~=","@","|&>","|>>", ">>", "=", "<<|", "<<", "&>", "&<|", "&<", "&&&", "&&"] as const;
|
|
86
|
-
const
|
|
87
|
-
|
|
151
|
+
export const GeomFilter_Funcs = [
|
|
152
|
+
"ST_MakeEnvelope",
|
|
153
|
+
"st_makeenvelope",
|
|
154
|
+
"ST_MakePolygon",
|
|
155
|
+
"st_makepolygon",
|
|
156
|
+
] as const;
|
|
88
157
|
|
|
89
158
|
export type AllowedTSTypes = string | number | boolean | Date | any[];
|
|
90
159
|
// export type AnyObject = { [key: string]: AllowedTSTypes };
|
|
91
160
|
export type AnyObject = { [key: string]: any };
|
|
92
161
|
|
|
93
162
|
export type FilterDataType<T = any> =
|
|
94
|
-
|
|
163
|
+
T extends string ? TextFilter
|
|
95
164
|
: T extends number ? CompareFilter<T>
|
|
96
165
|
: T extends boolean ? CompareFilter<T>
|
|
97
166
|
: T extends Date ? CompareFilter<T>
|
|
@@ -102,6 +171,16 @@ export type FilterDataType<T = any> =
|
|
|
102
171
|
export const EXISTS_KEYS = ["$exists", "$notExists", "$existsJoined", "$notExistsJoined"] as const;
|
|
103
172
|
export type EXISTS_KEY = typeof EXISTS_KEYS[number];
|
|
104
173
|
|
|
174
|
+
/**
|
|
175
|
+
* {
|
|
176
|
+
* $filter: [
|
|
177
|
+
* { $funcName: [...args] },
|
|
178
|
+
* operand,
|
|
179
|
+
* value | funcFilter
|
|
180
|
+
* ]
|
|
181
|
+
* }
|
|
182
|
+
*/
|
|
183
|
+
export const COMPLEX_FILTER_KEY = "$filter" as const;
|
|
105
184
|
|
|
106
185
|
/**
|
|
107
186
|
* Shortened filter operands
|