prostgles-server 2.0.143 → 2.0.146

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.
@@ -7,7 +7,7 @@
7
7
  import { pgp, Filter, LocalParams, isPlainObject, TableHandler, ViewHandler, postgresToTsType } from "./DboBuilder";
8
8
  import { TableRule, flat } from "./Prostgles";
9
9
  import { SelectParamsBasic as SelectParams, isEmpty, FieldFilter, asName, TextFilter_FullTextSearchFilterKeys, TS_PG_Types, ColumnInfo, PG_COLUMN_UDT_DATA_TYPE } from "prostgles-types";
10
- import { get } from "./utils";
10
+ import { get, isObject } from "./utils";
11
11
 
12
12
 
13
13
  export type SelectItem = {
@@ -47,6 +47,65 @@ export const asNameAlias = (field: string, tableAlias?: string) => {
47
47
  return result;
48
48
  }
49
49
 
50
+ export const parseFunctionObject = (funcData: any): { funcName: string; args: any[] } => {
51
+ const makeErr = (msg: string) => `Function not specified correctly. Expecting { $funcName: ["columnName",...] } object but got: ${JSON.stringify(funcData)} \n ${msg}`
52
+ if(!isObject(funcData)) throw makeErr("");
53
+ const keys = Object.keys(funcData);
54
+ if(keys.length !== 1) throw makeErr("");
55
+ const funcName = keys[0];
56
+ const args = funcData[funcName];
57
+ if(!args || !Array.isArray(args)){
58
+ throw makeErr("Arguments missing or invalid");
59
+ }
60
+
61
+ return { funcName, args };
62
+ }
63
+
64
+ export const parseFunction = (funcData: { func: string | FunctionSpec, args: any[], functions: FunctionSpec[]; allowedFields: string[]; }): FunctionSpec => {
65
+ const { func, args, functions, allowedFields } = funcData;
66
+
67
+ /* Function is computed column. No checks needed */
68
+ if(typeof func !== "string"){
69
+ const computedCol = COMPUTED_FIELDS.find(c => c.name === func.name);
70
+ if(!computedCol) throw `Unexpected function: computed column spec not found for ${JSON.stringify(func.name)}`;
71
+ return func;
72
+ }
73
+
74
+ const funcName = func;
75
+ const makeErr = (msg: string): string => {
76
+ return `Issue with function ${JSON.stringify({ [funcName]: args })}: \n${msg}`
77
+ }
78
+
79
+ /* Find function */
80
+ const funcDef = functions.find(f => f.name === funcName);
81
+
82
+ if(!funcDef) {
83
+ const sf = functions.filter(f => f.name.toLowerCase().slice(1).startsWith(funcName.toLowerCase())).sort((a, b) => (a.name.length - b.name.length));
84
+ const hint = (sf.length? `. \n Maybe you meant: \n | ${sf.map(s => s.name + " " + (s.description || "")).join(" \n | ")} ?` : "");
85
+ throw "\n Function " + funcName + " does not exist or is not allowed " + hint;
86
+ }
87
+
88
+ /* Validate fields */
89
+ const fields = funcDef.getFields(args);
90
+ if(fields !== "*"){
91
+ fields.forEach(fieldKey => {
92
+ if(typeof fieldKey !== "string" || !allowedFields.includes(fieldKey)) {
93
+ throw makeErr(`getFields() => field name ${JSON.stringify(fieldKey)} is invalid or disallowed`)
94
+ }
95
+ });
96
+ if((funcDef.minCols ?? 0) > fields.length){
97
+ throw makeErr(`Less columns provided than necessary (minCols=${funcDef.minCols})`)
98
+ }
99
+ }
100
+
101
+ if(funcDef.numArgs && funcDef.minCols !== 0 && fields !== "*" && Array.isArray(fields) && !fields.length) {
102
+ throw `\n Function "${funcDef.name}" expects at least a field name but has not been provided with one`;
103
+ }
104
+
105
+ return funcDef;
106
+ }
107
+
108
+
50
109
  type GetQueryArgs = {
51
110
  allColumns: ColumnInfo[];
52
111
  allowedFields: string[];
@@ -84,13 +143,23 @@ export type FunctionSpec = {
84
143
  */
85
144
  // returnsBoolean?: boolean;
86
145
 
146
+ /**
147
+ * Number of arguments expected
148
+ */
87
149
  numArgs: number;
150
+
151
+ /**
152
+ * If provided then the number of column names provided to the function (from getFields()) must not be less than this
153
+ * By default every function is checked against numArgs
154
+ */
155
+ minCols?: number;
156
+
88
157
  type: "function" | "aggregation" | "computed";
89
158
  /**
90
159
  * getFields: string[] -> used to validate user supplied field names. It will be fired before querying to validate against allowed columns
91
160
  * if not field names are used from arguments then return an empty array
92
161
  */
93
- getFields: (args: any[], allowedFields: string[]) => "*" | string[];
162
+ getFields: (args: any[]) => "*" | string[];
94
163
  /**
95
164
  * allowedFields passed for multicol functions (e.g.: $rowhash)
96
165
  */
@@ -643,8 +712,9 @@ export const FUNCTIONS: FunctionSpec[] = [
643
712
  name: "$" + funcName,
644
713
  type: "function",
645
714
  numArgs: 1,
715
+ minCols: 0,
646
716
  singleColArg: false,
647
- getFields: (args: any[], allowedFields) => allowedFields.filter(fName => args?.[0]?.includes(`{${fName}}`)),
717
+ getFields: (args: any[], allowedFields) => [], // Fields not validated because we'll use the allowed ones anyway
648
718
  getQuery: ({ allowedFields, args, tableAlias }) => {
649
719
  let value = asValue(args[0]);
650
720
  if(typeof value !== "string") throw "expecting string argument";
@@ -947,28 +1017,16 @@ export class SelectItemBuilder {
947
1017
  this.select.push(item);
948
1018
  }
949
1019
 
950
- private addFunctionByName = (funcName: string, args: any[], alias: string) => {
951
- const funcDef = this.functions.find(f => f.name === funcName);
952
- if(!funcDef) {
953
- const sf = this.functions.filter(f => f.name.toLowerCase().slice(1).startsWith(funcName.toLowerCase())).sort((a, b) => (a.name.length - b.name.length));
954
- const hint = (sf.length? `. \n Maybe you meant: \n | ${sf.map(s => s.name + " " + (s.description || "")).join(" \n | ")} ?` : "");
955
- throw "\n Function " + funcName + " does not exist or is not allowed " + hint;
956
- }
957
- this.addFunction(funcDef, args, alias);
958
- }
1020
+ private addFunction = (func: FunctionSpec | string, args: any[], alias: string) => {
1021
+ const funcDef = parseFunction({
1022
+ func, args, functions: this.functions,
1023
+ allowedFields: this.allowedFieldsIncludingComputed,
1024
+ });
959
1025
 
960
- private addFunction = (funcDef: FunctionSpec, args: any[], alias: string) => {
961
- if(funcDef.numArgs) {
962
- const fields = funcDef.getFields(args, this.allowedFields);// && (! || !funcDef.getFields(args) !== "*" !funcDef.getFields(args).filter(f => f).length
963
- if(fields !== "*" && Array.isArray(fields) && !fields.length ){
964
- console.log(fields)
965
- throw `\n Function "${funcDef.name}" is missing a field name argument`;
966
- }
967
- }
968
1026
  this.addItem({
969
1027
  type: funcDef.type,
970
1028
  alias,
971
- getFields: () => funcDef.getFields(args, this.allowedFields),
1029
+ getFields: () => funcDef.getFields(args),
972
1030
  getQuery: (tableAlias?: string) => funcDef.getQuery({ allColumns: this.columns, allowedFields: this.allowedFields, args, tableAlias,
973
1031
  ctidField: undefined,
974
1032
 
@@ -1084,14 +1142,13 @@ export class SelectItemBuilder {
1084
1142
  }
1085
1143
  funcName = val;
1086
1144
  args = [key];
1145
+
1146
+ /** Function full notation { $funcName: ["colName", ...args] } */
1087
1147
  } else {
1088
- const callKeys = Object.keys(val);
1089
- if(callKeys.length !== 1 || !Array.isArray(val[callKeys[0]])) throw "\nIssue with select. \nUnexpected function definition. \nExpecting { field_name: func_name } OR { result_key: { func_name: [arg1, arg2 ...] } } \nBut got -> " + JSON.stringify({ [key]: val });
1090
- funcName = callKeys[0];
1091
- args = val[funcName];
1148
+ ({ funcName, args } = parseFunctionObject(val));
1092
1149
  }
1093
1150
 
1094
- this.addFunctionByName(funcName, args, key);
1151
+ this.addFunction(funcName, args, key);
1095
1152
 
1096
1153
  /* Join */
1097
1154
  } else {
package/lib/utils.ts CHANGED
@@ -1 +1,6 @@
1
- export { get } from "prostgles-types";
1
+ export { get } from "prostgles-types";
2
+
3
+
4
+ export function isObject(obj: any){
5
+ return Boolean(obj && typeof obj === "object" && !Array.isArray(obj) );
6
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prostgles-server",
3
- "version": "2.0.143",
3
+ "version": "2.0.146",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -24,15 +24,13 @@
24
24
  },
25
25
  "homepage": "https://github.com/prostgles/prostgles-server-js#readme",
26
26
  "dependencies": {
27
- "@aws-sdk/client-s3": "^3.86.0",
28
- "aws-sdk": "^2.1134.0",
27
+ "@aws-sdk/client-s3": "^3.95.0",
28
+ "aws-sdk": "^2.1141.0",
29
29
  "bluebird": "^3.7.2",
30
30
  "file-type": "^16.5.3",
31
- "i": "^0.3.7",
32
- "npm": "^8.1.4",
33
- "pg-promise": "^10.9.5",
31
+ "pg-promise": "^10.11.1",
34
32
  "prostgles-types": "^1.5.123",
35
- "sharp": "^0.30.4"
33
+ "sharp": "^0.30.5"
36
34
  },
37
35
  "devDependencies": {
38
36
  "@aws-sdk/types": "^3.34.0",
@@ -1 +1 @@
1
- 21982
1
+ 15765
@@ -13,13 +13,13 @@
13
13
  "@types/socket.io-client": "^1.4.35",
14
14
  "prostgles-client": "^1.5.132",
15
15
  "prostgles-types": "^1.5.68",
16
- "socket.io-client": "^4.2.0"
16
+ "socket.io-client": "^4.5.0"
17
17
  }
18
18
  },
19
- "node_modules/@types/component-emitter": {
20
- "version": "1.2.10",
21
- "resolved": "https://registry.npmjs.org/@types/component-emitter/-/component-emitter-1.2.10.tgz",
22
- "integrity": "sha512-bsjleuRKWmGqajMerkzox19aGbscQX5rmmvvXl3wlIp5gMG1HgkiwPxsN5p070fBDKTNSPgojVbuY1+HWMbFhg=="
19
+ "node_modules/@socket.io/component-emitter": {
20
+ "version": "3.1.0",
21
+ "resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.0.tgz",
22
+ "integrity": "sha512-+9jVqKhRSpsc591z5vX+X5Yyw+he/HCB4iQ/RYxw35CEPaY1gnsNE43nf9n9AaYjAQrTiI/mOwKUKdUs9vf7Xg=="
23
23
  },
24
24
  "node_modules/@types/node": {
25
25
  "version": "14.17.18",
@@ -31,28 +31,10 @@
31
31
  "resolved": "https://registry.npmjs.org/@types/socket.io-client/-/socket.io-client-1.4.36.tgz",
32
32
  "integrity": "sha512-ZJWjtFBeBy1kRSYpVbeGYTElf6BqPQUkXDlHHD4k/42byCN5Rh027f4yARHCink9sKAkbtGZXEAmR0ZCnc2/Ag=="
33
33
  },
34
- "node_modules/backo2": {
35
- "version": "1.0.2",
36
- "resolved": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz",
37
- "integrity": "sha1-MasayLEpNjRj41s+u2n038+6eUc="
38
- },
39
- "node_modules/base64-arraybuffer": {
40
- "version": "0.1.4",
41
- "resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.4.tgz",
42
- "integrity": "sha1-mBjHngWbE1X5fgQooBfIOOkLqBI=",
43
- "engines": {
44
- "node": ">= 0.6.0"
45
- }
46
- },
47
- "node_modules/component-emitter": {
48
- "version": "1.3.0",
49
- "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz",
50
- "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg=="
51
- },
52
34
  "node_modules/debug": {
53
- "version": "4.3.2",
54
- "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz",
55
- "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==",
35
+ "version": "4.3.4",
36
+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
37
+ "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
56
38
  "dependencies": {
57
39
  "ms": "2.1.2"
58
40
  },
@@ -66,53 +48,30 @@
66
48
  }
67
49
  },
68
50
  "node_modules/engine.io-client": {
69
- "version": "5.2.0",
70
- "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-5.2.0.tgz",
71
- "integrity": "sha512-BcIBXGBkT7wKecwnfrSV79G2X5lSUSgeAGgoo60plXf8UsQEvCQww/KMwXSMhVjb98fFYNq20CC5eo8IOAPqsg==",
51
+ "version": "6.2.2",
52
+ "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.2.2.tgz",
53
+ "integrity": "sha512-8ZQmx0LQGRTYkHuogVZuGSpDqYZtCM/nv8zQ68VZ+JkOpazJ7ICdsSpaO6iXwvaU30oFg5QJOJWj8zWqhbKjkQ==",
72
54
  "dependencies": {
73
- "base64-arraybuffer": "0.1.4",
74
- "component-emitter": "~1.3.0",
55
+ "@socket.io/component-emitter": "~3.1.0",
75
56
  "debug": "~4.3.1",
76
- "engine.io-parser": "~4.0.1",
77
- "has-cors": "1.1.0",
78
- "parseqs": "0.0.6",
79
- "parseuri": "0.0.6",
80
- "ws": "~7.4.2",
81
- "xmlhttprequest-ssl": "~2.0.0",
82
- "yeast": "0.1.2"
57
+ "engine.io-parser": "~5.0.3",
58
+ "ws": "~8.2.3",
59
+ "xmlhttprequest-ssl": "~2.0.0"
83
60
  }
84
61
  },
85
62
  "node_modules/engine.io-parser": {
86
- "version": "4.0.3",
87
- "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-4.0.3.tgz",
88
- "integrity": "sha512-xEAAY0msNnESNPc00e19y5heTPX4y/TJ36gr8t1voOaNmTojP9b3oK3BbJLFufW2XFPQaaijpFewm2g2Um3uqA==",
89
- "dependencies": {
90
- "base64-arraybuffer": "0.1.4"
91
- },
63
+ "version": "5.0.4",
64
+ "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.0.4.tgz",
65
+ "integrity": "sha512-+nVFp+5z1E3HcToEnO7ZIj3g+3k9389DvWtvJZz0T6/eOCPIyyxehFcedoYrZQrp0LgQbD9pPXhpMBKMd5QURg==",
92
66
  "engines": {
93
- "node": ">=8.0.0"
67
+ "node": ">=10.0.0"
94
68
  }
95
69
  },
96
- "node_modules/has-cors": {
97
- "version": "1.1.0",
98
- "resolved": "https://registry.npmjs.org/has-cors/-/has-cors-1.1.0.tgz",
99
- "integrity": "sha1-XkdHk/fqmEPRu5nCPu9J/xJv/zk="
100
- },
101
70
  "node_modules/ms": {
102
71
  "version": "2.1.2",
103
72
  "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
104
73
  "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
105
74
  },
106
- "node_modules/parseqs": {
107
- "version": "0.0.6",
108
- "resolved": "https://registry.npmjs.org/parseqs/-/parseqs-0.0.6.tgz",
109
- "integrity": "sha512-jeAGzMDbfSHHA091hr0r31eYfTig+29g3GKKE/PPbEQ65X0lmMwlEoqmhzu0iztID5uJpZsFlUPDP8ThPL7M8w=="
110
- },
111
- "node_modules/parseuri": {
112
- "version": "0.0.6",
113
- "resolved": "https://registry.npmjs.org/parseuri/-/parseuri-0.0.6.tgz",
114
- "integrity": "sha512-AUjen8sAkGgao7UyCX6Ahv0gIK2fABKmYjvP4xmy5JaKvcbTRueIqIPHLAfq30xJddqSE033IOMUSOMCcK3Sow=="
115
- },
116
75
  "node_modules/prostgles-client": {
117
76
  "version": "1.5.132",
118
77
  "resolved": "https://registry.npmjs.org/prostgles-client/-/prostgles-client-1.5.132.tgz",
@@ -127,29 +86,25 @@
127
86
  "integrity": "sha512-BL5I7lc8eqTa6z3SH5Z9g/1g1H+crlDoBCPH8zVEDBK3y5xMIiCW3SOYRZQfPfRM1lYnW4ljWzx3Cb2x9D1Ofg=="
128
87
  },
129
88
  "node_modules/socket.io-client": {
130
- "version": "4.2.0",
131
- "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-4.2.0.tgz",
132
- "integrity": "sha512-3GJ2KMh7inJUNAOjgf8NaKJZJa9uRyfryh2LrVJyKyxmzoXlfW9DeDNqylJn0ovOFt4e/kRLNWzMt/YqqEWYSA==",
89
+ "version": "4.5.0",
90
+ "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-4.5.0.tgz",
91
+ "integrity": "sha512-HW61c1G7OrYGxaI79WRn17+b03iBCdvhBj4iqyXHBoL5M8w2MSO/vChsjA93knG4GYEai1/vbXWJna9dzxXtSg==",
133
92
  "dependencies": {
134
- "@types/component-emitter": "^1.2.10",
135
- "backo2": "~1.0.2",
136
- "component-emitter": "~1.3.0",
93
+ "@socket.io/component-emitter": "~3.1.0",
137
94
  "debug": "~4.3.2",
138
- "engine.io-client": "~5.2.0",
139
- "parseuri": "0.0.6",
140
- "socket.io-parser": "~4.0.4"
95
+ "engine.io-client": "~6.2.1",
96
+ "socket.io-parser": "~4.2.0"
141
97
  },
142
98
  "engines": {
143
99
  "node": ">=10.0.0"
144
100
  }
145
101
  },
146
102
  "node_modules/socket.io-parser": {
147
- "version": "4.0.4",
148
- "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.0.4.tgz",
149
- "integrity": "sha512-t+b0SS+IxG7Rxzda2EVvyBZbvFPBCjJoyHuE0P//7OAsN23GItzDRdWa6ALxZI/8R5ygK7jAR6t028/z+7295g==",
103
+ "version": "4.2.0",
104
+ "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.0.tgz",
105
+ "integrity": "sha512-tLfmEwcEwnlQTxFB7jibL/q2+q8dlVQzj4JdRLJ/W/G1+Fu9VSxCx1Lo+n1HvXxKnM//dUuD0xgiA7tQf57Vng==",
150
106
  "dependencies": {
151
- "@types/component-emitter": "^1.2.10",
152
- "component-emitter": "~1.3.0",
107
+ "@socket.io/component-emitter": "~3.1.0",
153
108
  "debug": "~4.3.1"
154
109
  },
155
110
  "engines": {
@@ -157,11 +112,11 @@
157
112
  }
158
113
  },
159
114
  "node_modules/ws": {
160
- "version": "7.4.6",
161
- "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.6.tgz",
162
- "integrity": "sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A==",
115
+ "version": "8.2.3",
116
+ "resolved": "https://registry.npmjs.org/ws/-/ws-8.2.3.tgz",
117
+ "integrity": "sha512-wBuoj1BDpC6ZQ1B7DWQBYVLphPWkm8i9Y0/3YdHjHKHiohOJ1ws+3OccDWtH+PoC9DZD5WOTrJvNbWvjS6JWaA==",
163
118
  "engines": {
164
- "node": ">=8.3.0"
119
+ "node": ">=10.0.0"
165
120
  },
166
121
  "peerDependencies": {
167
122
  "bufferutil": "^4.0.1",
@@ -183,18 +138,13 @@
183
138
  "engines": {
184
139
  "node": ">=0.4.0"
185
140
  }
186
- },
187
- "node_modules/yeast": {
188
- "version": "0.1.2",
189
- "resolved": "https://registry.npmjs.org/yeast/-/yeast-0.1.2.tgz",
190
- "integrity": "sha1-AI4G2AlDIMNy28L47XagymyKxBk="
191
141
  }
192
142
  },
193
143
  "dependencies": {
194
- "@types/component-emitter": {
195
- "version": "1.2.10",
196
- "resolved": "https://registry.npmjs.org/@types/component-emitter/-/component-emitter-1.2.10.tgz",
197
- "integrity": "sha512-bsjleuRKWmGqajMerkzox19aGbscQX5rmmvvXl3wlIp5gMG1HgkiwPxsN5p070fBDKTNSPgojVbuY1+HWMbFhg=="
144
+ "@socket.io/component-emitter": {
145
+ "version": "3.1.0",
146
+ "resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.0.tgz",
147
+ "integrity": "sha512-+9jVqKhRSpsc591z5vX+X5Yyw+he/HCB4iQ/RYxw35CEPaY1gnsNE43nf9n9AaYjAQrTiI/mOwKUKdUs9vf7Xg=="
198
148
  },
199
149
  "@types/node": {
200
150
  "version": "14.17.18",
@@ -206,74 +156,36 @@
206
156
  "resolved": "https://registry.npmjs.org/@types/socket.io-client/-/socket.io-client-1.4.36.tgz",
207
157
  "integrity": "sha512-ZJWjtFBeBy1kRSYpVbeGYTElf6BqPQUkXDlHHD4k/42byCN5Rh027f4yARHCink9sKAkbtGZXEAmR0ZCnc2/Ag=="
208
158
  },
209
- "backo2": {
210
- "version": "1.0.2",
211
- "resolved": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz",
212
- "integrity": "sha1-MasayLEpNjRj41s+u2n038+6eUc="
213
- },
214
- "base64-arraybuffer": {
215
- "version": "0.1.4",
216
- "resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.4.tgz",
217
- "integrity": "sha1-mBjHngWbE1X5fgQooBfIOOkLqBI="
218
- },
219
- "component-emitter": {
220
- "version": "1.3.0",
221
- "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz",
222
- "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg=="
223
- },
224
159
  "debug": {
225
- "version": "4.3.2",
226
- "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz",
227
- "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==",
160
+ "version": "4.3.4",
161
+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
162
+ "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
228
163
  "requires": {
229
164
  "ms": "2.1.2"
230
165
  }
231
166
  },
232
167
  "engine.io-client": {
233
- "version": "5.2.0",
234
- "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-5.2.0.tgz",
235
- "integrity": "sha512-BcIBXGBkT7wKecwnfrSV79G2X5lSUSgeAGgoo60plXf8UsQEvCQww/KMwXSMhVjb98fFYNq20CC5eo8IOAPqsg==",
168
+ "version": "6.2.2",
169
+ "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.2.2.tgz",
170
+ "integrity": "sha512-8ZQmx0LQGRTYkHuogVZuGSpDqYZtCM/nv8zQ68VZ+JkOpazJ7ICdsSpaO6iXwvaU30oFg5QJOJWj8zWqhbKjkQ==",
236
171
  "requires": {
237
- "base64-arraybuffer": "0.1.4",
238
- "component-emitter": "~1.3.0",
172
+ "@socket.io/component-emitter": "~3.1.0",
239
173
  "debug": "~4.3.1",
240
- "engine.io-parser": "~4.0.1",
241
- "has-cors": "1.1.0",
242
- "parseqs": "0.0.6",
243
- "parseuri": "0.0.6",
244
- "ws": "~7.4.2",
245
- "xmlhttprequest-ssl": "~2.0.0",
246
- "yeast": "0.1.2"
174
+ "engine.io-parser": "~5.0.3",
175
+ "ws": "~8.2.3",
176
+ "xmlhttprequest-ssl": "~2.0.0"
247
177
  }
248
178
  },
249
179
  "engine.io-parser": {
250
- "version": "4.0.3",
251
- "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-4.0.3.tgz",
252
- "integrity": "sha512-xEAAY0msNnESNPc00e19y5heTPX4y/TJ36gr8t1voOaNmTojP9b3oK3BbJLFufW2XFPQaaijpFewm2g2Um3uqA==",
253
- "requires": {
254
- "base64-arraybuffer": "0.1.4"
255
- }
256
- },
257
- "has-cors": {
258
- "version": "1.1.0",
259
- "resolved": "https://registry.npmjs.org/has-cors/-/has-cors-1.1.0.tgz",
260
- "integrity": "sha1-XkdHk/fqmEPRu5nCPu9J/xJv/zk="
180
+ "version": "5.0.4",
181
+ "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.0.4.tgz",
182
+ "integrity": "sha512-+nVFp+5z1E3HcToEnO7ZIj3g+3k9389DvWtvJZz0T6/eOCPIyyxehFcedoYrZQrp0LgQbD9pPXhpMBKMd5QURg=="
261
183
  },
262
184
  "ms": {
263
185
  "version": "2.1.2",
264
186
  "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
265
187
  "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
266
188
  },
267
- "parseqs": {
268
- "version": "0.0.6",
269
- "resolved": "https://registry.npmjs.org/parseqs/-/parseqs-0.0.6.tgz",
270
- "integrity": "sha512-jeAGzMDbfSHHA091hr0r31eYfTig+29g3GKKE/PPbEQ65X0lmMwlEoqmhzu0iztID5uJpZsFlUPDP8ThPL7M8w=="
271
- },
272
- "parseuri": {
273
- "version": "0.0.6",
274
- "resolved": "https://registry.npmjs.org/parseuri/-/parseuri-0.0.6.tgz",
275
- "integrity": "sha512-AUjen8sAkGgao7UyCX6Ahv0gIK2fABKmYjvP4xmy5JaKvcbTRueIqIPHLAfq30xJddqSE033IOMUSOMCcK3Sow=="
276
- },
277
189
  "prostgles-client": {
278
190
  "version": "1.5.132",
279
191
  "resolved": "https://registry.npmjs.org/prostgles-client/-/prostgles-client-1.5.132.tgz",
@@ -288,44 +200,35 @@
288
200
  "integrity": "sha512-BL5I7lc8eqTa6z3SH5Z9g/1g1H+crlDoBCPH8zVEDBK3y5xMIiCW3SOYRZQfPfRM1lYnW4ljWzx3Cb2x9D1Ofg=="
289
201
  },
290
202
  "socket.io-client": {
291
- "version": "4.2.0",
292
- "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-4.2.0.tgz",
293
- "integrity": "sha512-3GJ2KMh7inJUNAOjgf8NaKJZJa9uRyfryh2LrVJyKyxmzoXlfW9DeDNqylJn0ovOFt4e/kRLNWzMt/YqqEWYSA==",
203
+ "version": "4.5.0",
204
+ "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-4.5.0.tgz",
205
+ "integrity": "sha512-HW61c1G7OrYGxaI79WRn17+b03iBCdvhBj4iqyXHBoL5M8w2MSO/vChsjA93knG4GYEai1/vbXWJna9dzxXtSg==",
294
206
  "requires": {
295
- "@types/component-emitter": "^1.2.10",
296
- "backo2": "~1.0.2",
297
- "component-emitter": "~1.3.0",
207
+ "@socket.io/component-emitter": "~3.1.0",
298
208
  "debug": "~4.3.2",
299
- "engine.io-client": "~5.2.0",
300
- "parseuri": "0.0.6",
301
- "socket.io-parser": "~4.0.4"
209
+ "engine.io-client": "~6.2.1",
210
+ "socket.io-parser": "~4.2.0"
302
211
  }
303
212
  },
304
213
  "socket.io-parser": {
305
- "version": "4.0.4",
306
- "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.0.4.tgz",
307
- "integrity": "sha512-t+b0SS+IxG7Rxzda2EVvyBZbvFPBCjJoyHuE0P//7OAsN23GItzDRdWa6ALxZI/8R5ygK7jAR6t028/z+7295g==",
214
+ "version": "4.2.0",
215
+ "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.0.tgz",
216
+ "integrity": "sha512-tLfmEwcEwnlQTxFB7jibL/q2+q8dlVQzj4JdRLJ/W/G1+Fu9VSxCx1Lo+n1HvXxKnM//dUuD0xgiA7tQf57Vng==",
308
217
  "requires": {
309
- "@types/component-emitter": "^1.2.10",
310
- "component-emitter": "~1.3.0",
218
+ "@socket.io/component-emitter": "~3.1.0",
311
219
  "debug": "~4.3.1"
312
220
  }
313
221
  },
314
222
  "ws": {
315
- "version": "7.4.6",
316
- "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.6.tgz",
317
- "integrity": "sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A==",
223
+ "version": "8.2.3",
224
+ "resolved": "https://registry.npmjs.org/ws/-/ws-8.2.3.tgz",
225
+ "integrity": "sha512-wBuoj1BDpC6ZQ1B7DWQBYVLphPWkm8i9Y0/3YdHjHKHiohOJ1ws+3OccDWtH+PoC9DZD5WOTrJvNbWvjS6JWaA==",
318
226
  "requires": {}
319
227
  },
320
228
  "xmlhttprequest-ssl": {
321
229
  "version": "2.0.0",
322
230
  "resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-2.0.0.tgz",
323
231
  "integrity": "sha512-QKxVRxiRACQcVuQEYFsI1hhkrMlrXHPegbbd1yn9UHOmRxY+si12nQYzri3vbzt8VdTTRviqcKxcyllFas5z2A=="
324
- },
325
- "yeast": {
326
- "version": "0.1.2",
327
- "resolved": "https://registry.npmjs.org/yeast/-/yeast-0.1.2.tgz",
328
- "integrity": "sha1-AI4G2AlDIMNy28L47XagymyKxBk="
329
232
  }
330
233
  }
331
234
  }
@@ -16,6 +16,6 @@
16
16
  "@types/socket.io-client": "^1.4.35",
17
17
  "prostgles-client": "^1.5.132",
18
18
  "prostgles-types": "^1.5.68",
19
- "socket.io-client": "^4.2.0"
19
+ "socket.io-client": "^4.5.0"
20
20
  }
21
21
  }
@@ -313,8 +313,30 @@ async function isomorphic(db) {
313
313
  const res = await db.various.count({ "jsn->a->>b": '3' });
314
314
  assert_1.strict.equal(res, 1);
315
315
  });
316
+ await tryRun("Complex filtering", async () => {
317
+ const res = await db.various.count({
318
+ $and: [
319
+ {
320
+ $filter: [
321
+ { $year: ["added"] },
322
+ "=",
323
+ '1996'
324
+ ]
325
+ },
326
+ {
327
+ $filter: [
328
+ { $Mon: ["added"] },
329
+ "=",
330
+ 'Dec'
331
+ ]
332
+ }
333
+ ]
334
+ });
335
+ assert_1.strict.equal(res, 1);
336
+ });
316
337
  await tryRun("template_string function", async () => {
317
338
  const res = await db.various.findOne({ name: 'abc9' }, { select: { tstr: { $template_string: ["{name} is hehe"] } } });
339
+ const res2 = await db.various.findOne({ name: 'abc9' }, { select: { tstr: { $template_string: ["is hehe"] } } });
318
340
  assert_1.strict.equal(res.tstr, "'abc9 is hehe'");
319
341
  });
320
342
  await tryRun("Between filtering", async () => {
@@ -353,8 +353,32 @@ export default async function isomorphic(db: Partial<DbHandler> | Partial<DBHand
353
353
  assert.equal(res, 1)
354
354
  });
355
355
 
356
+ await tryRun("Complex filtering", async () => {
357
+ const res = await db.various.count({
358
+ $and: [
359
+ {
360
+ $filter: [
361
+ { $year: ["added"] },
362
+ "=",
363
+ '1996'
364
+ ]
365
+ },
366
+ {
367
+ $filter: [
368
+ { $Mon: ["added"] },
369
+ "=",
370
+ 'Dec'
371
+ ]
372
+ }
373
+
374
+ ]
375
+ });
376
+ assert.equal(res, 1)
377
+ });
378
+
356
379
  await tryRun("template_string function", async () => {
357
380
  const res = await db.various.findOne({ name: 'abc9' }, { select: { tstr: { $template_string: ["{name} is hehe"] } } });
381
+ const res2 = await db.various.findOne({ name: 'abc9' }, { select: { tstr: { $template_string: ["is hehe"] } } });
358
382
  assert.equal(res.tstr, "'abc9 is hehe'")
359
383
  });
360
384