prostgles-types 4.0.82 → 4.0.84
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 +5 -5
- package/dist/filters.d.ts.map +1 -1
- package/dist/filters.js +15 -2
- package/dist/filters.js.map +1 -1
- package/dist/index_umd.js +1 -1
- package/lib/filters.ts +29 -11
- package/package.json +1 -1
package/dist/filters.d.ts
CHANGED
|
@@ -2,8 +2,9 @@ import { DBSchema, RawJoinPath } from ".";
|
|
|
2
2
|
import { ExactlyOne } from "./util";
|
|
3
3
|
export type AllowedTSType = string | number | boolean | Date | any;
|
|
4
4
|
export type AllowedTSTypes = AllowedTSType[];
|
|
5
|
-
export declare const CompareFilterKeys: readonly ["=", "$eq", "<>", ">", "<", ">=", "<=", "$eq", "$ne", "$gt", "$gte", "$lt", "$lte"];
|
|
5
|
+
export declare const CompareFilterKeys: readonly ["=", "$eq", "<>", ">", "<", ">=", "<=", "$eq", "$ne", "$gt", "$gte", "$lt", "$lte", "$isDistinctFrom", "$isNotDistinctFrom"];
|
|
6
6
|
export declare const CompareInFilterKeys: readonly ["$in", "$nin"];
|
|
7
|
+
export declare const BetweenFilterKeys: readonly ["$between", "$notBetween"];
|
|
7
8
|
export declare const JsonbOperands: {
|
|
8
9
|
readonly "@>": {
|
|
9
10
|
readonly Operator: "@>";
|
|
@@ -67,13 +68,11 @@ export declare const JsonbOperands: {
|
|
|
67
68
|
};
|
|
68
69
|
};
|
|
69
70
|
export declare const JsonbFilterKeys: ("@@" | "@>" | "<@" | "?" | "?|" | "?&" | "||" | "-" | "#-" | "@?")[];
|
|
70
|
-
export type CompareFilter<T extends AllowedTSType = string> = T | ExactlyOne<Record<typeof CompareFilterKeys[number], T>> | ExactlyOne<Record<typeof CompareInFilterKeys[number], T[]>> | {
|
|
71
|
-
"$between": [T, T];
|
|
72
|
-
};
|
|
73
71
|
export declare const TextFilterKeys: readonly ["$ilike", "$like", "$nilike", "$nlike"];
|
|
74
72
|
export declare const TextFilterFTSKeys: readonly ["@@", "@>", "<@", "$contains", "$containedBy"];
|
|
75
73
|
export declare const TextFilter_FullTextSearchFilterKeys: readonly ["to_tsquery", "plainto_tsquery", "phraseto_tsquery", "websearch_to_tsquery"];
|
|
76
74
|
export type FullTextSearchFilter = ExactlyOne<Record<typeof TextFilter_FullTextSearchFilterKeys[number], string[]>>;
|
|
75
|
+
export type CompareFilter<T extends AllowedTSType = string> = T | ExactlyOne<Record<typeof CompareFilterKeys[number], T>> | ExactlyOne<Record<typeof CompareInFilterKeys[number], T[]>> | ExactlyOne<Record<typeof BetweenFilterKeys[number], [T, T]>>;
|
|
77
76
|
export type TextFilter = CompareFilter<string> | ExactlyOne<Record<typeof TextFilterKeys[number], string>> | ExactlyOne<Record<typeof TextFilterFTSKeys[number], FullTextSearchFilter>>;
|
|
78
77
|
export declare const ArrayFilterOperands: readonly ["@>", "<@", "=", "$eq", "$contains", "$containedBy", "&&", "$overlaps"];
|
|
79
78
|
export type ArrayFilter<T extends AllowedTSType[]> = Record<typeof ArrayFilterOperands[number], T> | ExactlyOne<Record<typeof ArrayFilterOperands[number], T>>;
|
|
@@ -94,12 +93,13 @@ export type CastFromTSToPG<T extends AllowedTSType> = T extends number ? (T | st
|
|
|
94
93
|
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);
|
|
95
94
|
export declare const EXISTS_KEYS: readonly ["$exists", "$notExists", "$existsJoined", "$notExistsJoined"];
|
|
96
95
|
export type EXISTS_KEY = typeof EXISTS_KEYS[number];
|
|
96
|
+
export declare const ComplexFilterComparisonKeys: readonly ["$ilike", "$like", "$nilike", "$nlike", ...("@@" | "@>" | "<@" | "?" | "?|" | "?&" | "||" | "-" | "#-" | "@?")[], "=", "$eq", "<>", ">", "<", ">=", "<=", "$eq", "$ne", "$gt", "$gte", "$lt", "$lte", "$isDistinctFrom", "$isNotDistinctFrom", "$between", "$notBetween", "$in", "$nin"];
|
|
97
97
|
export declare const COMPLEX_FILTER_KEY: "$filter";
|
|
98
98
|
export type ComplexFilter = Record<typeof COMPLEX_FILTER_KEY, [
|
|
99
99
|
{
|
|
100
100
|
[funcName: string]: any[];
|
|
101
101
|
},
|
|
102
|
-
typeof
|
|
102
|
+
typeof ComplexFilterComparisonKeys[number]?,
|
|
103
103
|
any?
|
|
104
104
|
]>;
|
|
105
105
|
type BasicFilter<Field extends string, DataType extends any> = 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,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,wIAKpB,CAAC;AACX,eAAO,MAAM,mBAAmB,0BAA2B,CAAC;AAC5D,eA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AKX,CAAC,CAAC;AAOH,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,IAClD,eAAe,CAAC,CAAC,CAAC,CAAA;AAGtB,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,SAAS,GAAG,IAAI,IAAI,CAAC,SAAS,SAAS,GAAE,CAAC,GAAG,SAAS,CAAC;AAK1F,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,SAAS,GAAG,IAAI,EAAE,CAAC,SAAS,QAAQ,GAAG,IAAI,IACzE;IAAE,IAAI,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAA;CAAE,GAC5B;IAAE,GAAG,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAA;CAAE,GAC3B,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GAC3B,YAAY,CAAC,CAAC,CAAC,GACf,aAAa,CAIf;AAKD,MAAM,MAAM,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,9 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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;
|
|
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
|
-
exports.CompareFilterKeys = [
|
|
5
|
+
exports.CompareFilterKeys = [
|
|
6
|
+
"=", "$eq",
|
|
7
|
+
"<>", ">", "<", ">=", "<=",
|
|
8
|
+
"$eq", "$ne", "$gt", "$gte", "$lt", "$lte",
|
|
9
|
+
"$isDistinctFrom", "$isNotDistinctFrom",
|
|
10
|
+
];
|
|
6
11
|
exports.CompareInFilterKeys = ["$in", "$nin"];
|
|
12
|
+
exports.BetweenFilterKeys = ["$between", "$notBetween"];
|
|
7
13
|
exports.JsonbOperands = {
|
|
8
14
|
"@>": {
|
|
9
15
|
"Operator": "@>",
|
|
@@ -79,6 +85,13 @@ exports.GeomFilter_Funcs = [
|
|
|
79
85
|
"st_makepolygon",
|
|
80
86
|
];
|
|
81
87
|
exports.EXISTS_KEYS = ["$exists", "$notExists", "$existsJoined", "$notExistsJoined"];
|
|
88
|
+
exports.ComplexFilterComparisonKeys = [
|
|
89
|
+
...exports.TextFilterKeys,
|
|
90
|
+
...exports.JsonbFilterKeys,
|
|
91
|
+
...exports.CompareFilterKeys,
|
|
92
|
+
...exports.BetweenFilterKeys,
|
|
93
|
+
...exports.CompareInFilterKeys
|
|
94
|
+
];
|
|
82
95
|
exports.COMPLEX_FILTER_KEY = "$filter";
|
|
83
96
|
const _f = {
|
|
84
97
|
"h.$eq": ["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,
|
|
1
|
+
{"version":3,"file":"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B;IACjB,iBAAiB;IACjB,gBAAgB;IAChB,gBAAgB;CACR,CAAC;AAsBE,QAAA,WAAW,GAAG,CAAC,SAAS,EAAE,YAAY,EAAE,eAAe,EAAE,kBAAkB,CAAU,CAAC;AActF,QAAA,2BAA2B,GAAG;IACzC,GAAG,sBAAc;IACjB,GAAG,uBAAe;IAClB,GAAG,yBAAiB;IACpB,GAAG,yBAAiB;IACpB,GAAG,2BAAmB;CACd,CAAC;AAEE,QAAA,kBAAkB,GAAG,SAAkB,CAAC;AAsGrD,MAAM,EAAE,GAAmB;IACxB,OAAO,EAAE,CAAC,GAAG,CAAC;CAChB,CAAA;AACD,MAAM,YAAY,GAAuB;IAEvC,IAAI,EAAE;QACJ,EAAE,OAAO,EAAE,EAAE,EAAE;QACf,EAAE,CAAC,EAAE,EAAE,cAAc,EAAE,EAAE,EAAE,EAAE;KAC9B;CACF,CAAA;AACD,MAAM,GAAG,GAAmB;IACzB,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,SAAS,EAAE,MAAM,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;CACvD,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,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","$lt","$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=["@>","<@","=","$eq","$contains","$containedBy","&&","$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.RULE_METHODS=t.CHANNELS=t.JOIN_PARAMS=t.JOIN_KEYS=t.TS_PG_Types=t._PG_geometric=t._PG_postgis=t._PG_interval=t._PG_date=t._PG_bool=t._PG_json=t._PG_numbers=t._PG_numbers_str=t._PG_numbers_num=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_num=["int2","int4","float4","float8","oid"],t._PG_numbers_str=["int8","numeric","money"],t._PG_numbers=[...t._PG_numbers_num,...t._PG_numbers_str],t._PG_json=["json","jsonb"],t._PG_bool=["bool"],t._PG_date=["date","timestamp","timestamptz"],t._PG_interval=["interval"],t._PG_postgis=["geometry","geography"],t._PG_geometric=["point","line","lseg","box","path","polygon","circle"];const s={string:[...t._PG_strings,...t._PG_numbers_str,...t._PG_date,...t._PG_geometric,...t._PG_postgis,"lseg"],number:t._PG_numbers_num,boolean:t._PG_bool,any:[...t._PG_json,...t._PG_interval]};t.TS_PG_Types={...s,"number[]":s.number.map((e=>`_${e}`)),"boolean[]":s.boolean.map((e=>`_${e}`)),"string[]":s.string.map((e=>`_${e}`)),"any[]":s.any.map((e=>`_${e}`))},t.JOIN_KEYS=["$innerJoin","$leftJoin"],t.JOIN_PARAMS=["select","filter","$path","$condition","offset","limit","orderBy"];const o="_psqlWS_.";t.CHANNELS={SCHEMA_CHANGED:o+"schema-changed",SCHEMA:o+"schema",DEFAULT:o,SQL:`${o}sql`,SQL_STREAM:`${o}sql-stream`,METHOD:`${o}method`,NOTICE_EV:`${o}notice`,LISTEN_EV:`${o}listen`,REGISTER:`${o}register`,LOGIN:`${o}login`,LOGOUT:`${o}logout`,AUTHGUARD:`${o}authguard`,CONNECTION:`${o}connection`,_preffix:o},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 a=i(31);Object.defineProperty(t,"CONTENT_TYPE_TO_EXT",{enumerable:!0,get:function(){return a.CONTENT_TYPE_TO_EXT}}),r(i(444),t),r(i(929),t),r(i(128),t)},929:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getJSONBSchemaAsJSONSchema=t.DATA_TYPES=t.PrimitiveArrayTypes=t.PrimitiveTypes=void 0;const n=i(128);t.PrimitiveTypes=["boolean","number","integer","string","Date","time","timestamp","any"],t.PrimitiveArrayTypes=t.PrimitiveTypes.map((e=>`${e}[]`)),t.DATA_TYPES=[...t.PrimitiveTypes,...t.PrimitiveArrayTypes];const r=(e,t)=>{const{type:i,arrayOf:s,arrayOfType:o,description:a,nullable:l,oneOf:c,oneOfType:p,title:d,record:u,...m}="string"==typeof e?{type:e}:e;let h={};const f={...(m.enum||m.allowedValues?.length)&&{enum:m.allowedValues?.slice(0)??m.enum.slice(0)},...!!a&&{description:a},...!!d&&{title:d}};if(m.enum?.length&&(f.type=typeof m.enum[0]),"string"==typeof i||s||o){if(i&&"string"!=typeof i)throw"Not expected";h=s||o||i?.endsWith("[]")?{type:"array",items:s||o?r(s||{type:o}):i?.startsWith("any")?{type:void 0}:{type:i?.slice(0,-2),...m.allowedValues&&{enum:m.allowedValues.slice(0)}}}:{type:i}}else if((0,n.isObject)(i))h={type:"object",required:(0,n.getKeys)(i).filter((e=>{const t=i[e];return"string"==typeof t||!t.optional})),properties:(0,n.getKeys)(i).reduce(((e,t)=>({...e,[t]:r(i[t])})),{})};else if(c||p){const e=c||p.map((e=>({type:e})));h={oneOf:e.map((e=>r(e)))}}else u&&(h={type:"object",...u.values&&!u.keysEnum&&{additionalProperties:r(u.values)},...u.keysEnum&&{properties:u.keysEnum.reduce(((e,t)=>({...e,[t]:u.values?r(u.values):{type:{}}})),{})}});if(l){const e={type:"null"};h.oneOf?h.oneOf.push(e):h.enum&&!h.enum.includes(null)?h.enum.push(null):h={oneOf:[h,e]}}return{...t?{$id:t?.id,$schema:"https://json-schema.org/draft/2020-12/schema"}:void 0,...f,...h}};t.getJSONBSchemaAsJSONSchema=function(e,t,i){return r(i,{id:`${e}.${t}`})}},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.reverseParsedPath=t.reverseJoinOn=t.getJoinHandlers=t.tryCatch=t.getKeys=t.isDefined=t.isObject=t.get=t.isEmpty=t.WAL=t.unpatchText=t.getTextPatch=t.stableStringify=t.includes=t.find=t.filter=t.omitKeys=t.pickKeys=t.asName=void 0;const n=i(899);function r(e,i){return(0,t.pickKeys)(e,l(e).filter((e=>!i.includes(e))))}function s(e,t){return e.filter((e=>Object.entries(t).every((([t,i])=>e[t]===i))))}function o(e){for(var t in e)return!1;return!0}function a(e){return null!=e}function l(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=(e,t=[],i=!0)=>{if(!t.length)return{};if(e&&t.length){let n={};return t.forEach((t=>{i&&void 0===e[t]||(n[t]=e[t])})),n}return e},t.omitKeys=r,t.filter=s,t.find=function(e,t){return s(e,t)[0]},t.includes=function(e,t){return e.some((e=>e===t))},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=>{o(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:s=2}=this.options;if(this.isSendingTimeout||this.sending&&!o(this.sending))return;if(!this.changed||o(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,o(this.changed)||this.sendItems()}),r)),this.isOnSending=!0;try{await t(l,c),s&&(this.sentHistory={...this.sentHistory,...p},this.willDeleteHistory||(this.willDeleteHistory=setTimeout((()=>{this.willDeleteHistory=void 0,this.sentHistory={}}),1e3*s)))}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]),o(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||!(o(this.sending)&&o(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=o,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=a,t.getKeys=l,t.tryCatch=async e=>{const t=Date.now();try{return{...await e(),duration:Date.now()-t}}catch(e){return{error:e,duration:Date.now()-t}}},t.getJoinHandlers=e=>{const t=(t,i)=>(i,n,s={})=>({[t?"$leftJoin":"$innerJoin"]:s.path??e,filter:i,...r(s,["path","select"]),select:n});return{innerJoin:t(!1),leftJoin:t(!0),innerJoinOne:t(!1),leftJoinOne:t(!0)}},t.reverseJoinOn=e=>e.map((e=>Object.fromEntries(Object.entries(e).map((([e,t])=>[t,e]))))),t.reverseParsedPath=(e,i)=>{const n=[{table:i,on:[{}]},...e??[]];return n.map(((e,i)=>{const r=n[i+1];if(r)return{table:e.table,on:(0,t.reverseJoinOn)(r.on)}})).filter(a).reverse()}}},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.ComplexFilterComparisonKeys=t.EXISTS_KEYS=t.GeomFilter_Funcs=t.GeomFilterKeys=t.ArrayFilterOperands=t.TextFilter_FullTextSearchFilterKeys=t.TextFilterFTSKeys=t.TextFilterKeys=t.JsonbFilterKeys=t.JsonbOperands=t.BetweenFilterKeys=t.CompareInFilterKeys=t.CompareFilterKeys=void 0;const n=i(128);t.CompareFilterKeys=["=","$eq","<>",">","<",">=","<=","$eq","$ne","$gt","$gte","$lt","$lte","$isDistinctFrom","$isNotDistinctFrom"],t.CompareInFilterKeys=["$in","$nin"],t.BetweenFilterKeys=["$between","$notBetween"],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=["@>","<@","=","$eq","$contains","$containedBy","&&","$overlaps"],t.GeomFilterKeys=["~","~=","@","|&>","|>>",">>","=","<<|","<<","&>","&<|","&<","&&&","&&"],t.GeomFilter_Funcs=["ST_MakeEnvelope","st_makeenvelope","ST_MakePolygon","st_makepolygon"],t.EXISTS_KEYS=["$exists","$notExists","$existsJoined","$notExistsJoined"],t.ComplexFilterComparisonKeys=[...t.TextFilterKeys,...t.JsonbFilterKeys,...t.CompareFilterKeys,...t.BetweenFilterKeys,...t.CompareInFilterKeys],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.RULE_METHODS=t.CHANNELS=t.JOIN_PARAMS=t.JOIN_KEYS=t.TS_PG_Types=t._PG_geometric=t._PG_postgis=t._PG_interval=t._PG_date=t._PG_bool=t._PG_json=t._PG_numbers=t._PG_numbers_str=t._PG_numbers_num=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_num=["int2","int4","float4","float8","oid"],t._PG_numbers_str=["int8","numeric","money"],t._PG_numbers=[...t._PG_numbers_num,...t._PG_numbers_str],t._PG_json=["json","jsonb"],t._PG_bool=["bool"],t._PG_date=["date","timestamp","timestamptz"],t._PG_interval=["interval"],t._PG_postgis=["geometry","geography"],t._PG_geometric=["point","line","lseg","box","path","polygon","circle"];const s={string:[...t._PG_strings,...t._PG_numbers_str,...t._PG_date,...t._PG_geometric,...t._PG_postgis,"lseg"],number:t._PG_numbers_num,boolean:t._PG_bool,any:[...t._PG_json,...t._PG_interval]};t.TS_PG_Types={...s,"number[]":s.number.map((e=>`_${e}`)),"boolean[]":s.boolean.map((e=>`_${e}`)),"string[]":s.string.map((e=>`_${e}`)),"any[]":s.any.map((e=>`_${e}`))},t.JOIN_KEYS=["$innerJoin","$leftJoin"],t.JOIN_PARAMS=["select","filter","$path","$condition","offset","limit","orderBy"];const o="_psqlWS_.";t.CHANNELS={SCHEMA_CHANGED:o+"schema-changed",SCHEMA:o+"schema",DEFAULT:o,SQL:`${o}sql`,SQL_STREAM:`${o}sql-stream`,METHOD:`${o}method`,NOTICE_EV:`${o}notice`,LISTEN_EV:`${o}listen`,REGISTER:`${o}register`,LOGIN:`${o}login`,LOGOUT:`${o}logout`,AUTHGUARD:`${o}authguard`,CONNECTION:`${o}connection`,_preffix:o},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 a=i(31);Object.defineProperty(t,"CONTENT_TYPE_TO_EXT",{enumerable:!0,get:function(){return a.CONTENT_TYPE_TO_EXT}}),r(i(444),t),r(i(929),t),r(i(128),t)},929:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getJSONBSchemaAsJSONSchema=t.DATA_TYPES=t.PrimitiveArrayTypes=t.PrimitiveTypes=void 0;const n=i(128);t.PrimitiveTypes=["boolean","number","integer","string","Date","time","timestamp","any"],t.PrimitiveArrayTypes=t.PrimitiveTypes.map((e=>`${e}[]`)),t.DATA_TYPES=[...t.PrimitiveTypes,...t.PrimitiveArrayTypes];const r=(e,t)=>{const{type:i,arrayOf:s,arrayOfType:o,description:a,nullable:l,oneOf:c,oneOfType:p,title:d,record:u,...m}="string"==typeof e?{type:e}:e;let h={};const f={...(m.enum||m.allowedValues?.length)&&{enum:m.allowedValues?.slice(0)??m.enum.slice(0)},...!!a&&{description:a},...!!d&&{title:d}};if(m.enum?.length&&(f.type=typeof m.enum[0]),"string"==typeof i||s||o){if(i&&"string"!=typeof i)throw"Not expected";h=s||o||i?.endsWith("[]")?{type:"array",items:s||o?r(s||{type:o}):i?.startsWith("any")?{type:void 0}:{type:i?.slice(0,-2),...m.allowedValues&&{enum:m.allowedValues.slice(0)}}}:{type:i}}else if((0,n.isObject)(i))h={type:"object",required:(0,n.getKeys)(i).filter((e=>{const t=i[e];return"string"==typeof t||!t.optional})),properties:(0,n.getKeys)(i).reduce(((e,t)=>({...e,[t]:r(i[t])})),{})};else if(c||p){const e=c||p.map((e=>({type:e})));h={oneOf:e.map((e=>r(e)))}}else u&&(h={type:"object",...u.values&&!u.keysEnum&&{additionalProperties:r(u.values)},...u.keysEnum&&{properties:u.keysEnum.reduce(((e,t)=>({...e,[t]:u.values?r(u.values):{type:{}}})),{})}});if(l){const e={type:"null"};h.oneOf?h.oneOf.push(e):h.enum&&!h.enum.includes(null)?h.enum.push(null):h={oneOf:[h,e]}}return{...t?{$id:t?.id,$schema:"https://json-schema.org/draft/2020-12/schema"}:void 0,...f,...h}};t.getJSONBSchemaAsJSONSchema=function(e,t,i){return r(i,{id:`${e}.${t}`})}},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.reverseParsedPath=t.reverseJoinOn=t.getJoinHandlers=t.tryCatch=t.getKeys=t.isDefined=t.isObject=t.get=t.isEmpty=t.WAL=t.unpatchText=t.getTextPatch=t.stableStringify=t.includes=t.find=t.filter=t.omitKeys=t.pickKeys=t.asName=void 0;const n=i(899);function r(e,i){return(0,t.pickKeys)(e,l(e).filter((e=>!i.includes(e))))}function s(e,t){return e.filter((e=>Object.entries(t).every((([t,i])=>e[t]===i))))}function o(e){for(var t in e)return!1;return!0}function a(e){return null!=e}function l(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=(e,t=[],i=!0)=>{if(!t.length)return{};if(e&&t.length){let n={};return t.forEach((t=>{i&&void 0===e[t]||(n[t]=e[t])})),n}return e},t.omitKeys=r,t.filter=s,t.find=function(e,t){return s(e,t)[0]},t.includes=function(e,t){return e.some((e=>e===t))},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=>{o(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:s=2}=this.options;if(this.isSendingTimeout||this.sending&&!o(this.sending))return;if(!this.changed||o(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,o(this.changed)||this.sendItems()}),r)),this.isOnSending=!0;try{await t(l,c),s&&(this.sentHistory={...this.sentHistory,...p},this.willDeleteHistory||(this.willDeleteHistory=setTimeout((()=>{this.willDeleteHistory=void 0,this.sentHistory={}}),1e3*s)))}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]),o(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||!(o(this.sending)&&o(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=o,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=a,t.getKeys=l,t.tryCatch=async e=>{const t=Date.now();try{return{...await e(),duration:Date.now()-t}}catch(e){return{error:e,duration:Date.now()-t}}},t.getJoinHandlers=e=>{const t=(t,i)=>(i,n,s={})=>({[t?"$leftJoin":"$innerJoin"]:s.path??e,filter:i,...r(s,["path","select"]),select:n});return{innerJoin:t(!1),leftJoin:t(!0),innerJoinOne:t(!1),leftJoinOne:t(!0)}},t.reverseJoinOn=e=>e.map((e=>Object.fromEntries(Object.entries(e).map((([e,t])=>[t,e]))))),t.reverseParsedPath=(e,i)=>{const n=[{table:i,on:[{}]},...e??[]];return n.map(((e,i)=>{const r=n[i+1];if(r)return{table:e.table,on:(0,t.reverseJoinOn)(r.on)}})).filter(a).reverse()}}},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
|
@@ -4,8 +4,15 @@ import { ExactlyOne, getKeys } from "./util";
|
|
|
4
4
|
export type AllowedTSType = string | number | boolean | Date | any;
|
|
5
5
|
export type AllowedTSTypes = AllowedTSType[];
|
|
6
6
|
|
|
7
|
-
export const CompareFilterKeys = [
|
|
7
|
+
export const CompareFilterKeys = [
|
|
8
|
+
"=", "$eq",
|
|
9
|
+
"<>",">","<",">=","<=",
|
|
10
|
+
"$eq","$ne","$gt","$gte","$lt","$lte",
|
|
11
|
+
"$isDistinctFrom","$isNotDistinctFrom",
|
|
12
|
+
] as const;
|
|
8
13
|
export const CompareInFilterKeys = ["$in", "$nin"] as const;
|
|
14
|
+
export const BetweenFilterKeys = ["$between", "$notBetween"] as const;
|
|
15
|
+
|
|
9
16
|
|
|
10
17
|
export const JsonbOperands = {
|
|
11
18
|
"@>": {
|
|
@@ -72,6 +79,15 @@ export const JsonbOperands = {
|
|
|
72
79
|
|
|
73
80
|
export const JsonbFilterKeys = getKeys(JsonbOperands);
|
|
74
81
|
|
|
82
|
+
export const TextFilterKeys = ["$ilike", "$like", "$nilike", "$nlike"] as const;
|
|
83
|
+
|
|
84
|
+
export const TextFilterFTSKeys = ["@@", "@>", "<@", "$contains", "$containedBy"] as const;
|
|
85
|
+
|
|
86
|
+
export const TextFilter_FullTextSearchFilterKeys = ["to_tsquery","plainto_tsquery","phraseto_tsquery","websearch_to_tsquery"] as const;
|
|
87
|
+
export type FullTextSearchFilter =
|
|
88
|
+
| ExactlyOne<Record<typeof TextFilter_FullTextSearchFilterKeys[number], string[]>>
|
|
89
|
+
;
|
|
90
|
+
|
|
75
91
|
/**
|
|
76
92
|
* Example: col_name: { $gt: 2 }
|
|
77
93
|
*/
|
|
@@ -83,15 +99,7 @@ export const JsonbFilterKeys = getKeys(JsonbOperands);
|
|
|
83
99
|
| ExactlyOne<Record<typeof CompareFilterKeys[number], T>>
|
|
84
100
|
|
|
85
101
|
| ExactlyOne<Record<typeof CompareInFilterKeys[number], T[]>>
|
|
86
|
-
|
|
|
87
|
-
;
|
|
88
|
-
export const TextFilterKeys = ["$ilike", "$like", "$nilike", "$nlike"] as const;
|
|
89
|
-
|
|
90
|
-
export const TextFilterFTSKeys = ["@@", "@>", "<@", "$contains", "$containedBy"] as const;
|
|
91
|
-
|
|
92
|
-
export const TextFilter_FullTextSearchFilterKeys = ["to_tsquery","plainto_tsquery","phraseto_tsquery","websearch_to_tsquery"] as const;
|
|
93
|
-
export type FullTextSearchFilter =
|
|
94
|
-
| ExactlyOne<Record<typeof TextFilter_FullTextSearchFilterKeys[number], string[]>>
|
|
102
|
+
| ExactlyOne<Record<typeof BetweenFilterKeys[number],[T, T]>>
|
|
95
103
|
;
|
|
96
104
|
|
|
97
105
|
export type TextFilter =
|
|
@@ -190,10 +198,20 @@ export type EXISTS_KEY = typeof EXISTS_KEYS[number];
|
|
|
190
198
|
* ]
|
|
191
199
|
* }
|
|
192
200
|
*/
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
export const ComplexFilterComparisonKeys = [
|
|
204
|
+
...TextFilterKeys,
|
|
205
|
+
...JsonbFilterKeys,
|
|
206
|
+
...CompareFilterKeys,
|
|
207
|
+
...BetweenFilterKeys,
|
|
208
|
+
...CompareInFilterKeys
|
|
209
|
+
] as const;
|
|
210
|
+
|
|
193
211
|
export const COMPLEX_FILTER_KEY = "$filter" as const;
|
|
194
212
|
export type ComplexFilter = Record<typeof COMPLEX_FILTER_KEY, [
|
|
195
213
|
{ [funcName: string]: any[] },
|
|
196
|
-
typeof
|
|
214
|
+
typeof ComplexFilterComparisonKeys[number]?,
|
|
197
215
|
any?
|
|
198
216
|
]>;
|
|
199
217
|
|