prostgles-server 2.0.162 → 2.0.165

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prostgles-server",
3
- "version": "2.0.162",
3
+ "version": "2.0.165",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -29,7 +29,7 @@
29
29
  "bluebird": "^3.7.2",
30
30
  "file-type": "^16.5.3",
31
31
  "pg-promise": "^10.11.1",
32
- "prostgles-types": "^1.5.132",
32
+ "prostgles-types": "^1.5.134",
33
33
  "sharp": "^0.30.5"
34
34
  },
35
35
  "devDependencies": {
@@ -1 +1 @@
1
- 75837
1
+ 26450
@@ -10,7 +10,7 @@
10
10
  "license": "ISC",
11
11
  "dependencies": {
12
12
  "@types/node": "^14.14.16",
13
- "prostgles-client": "^1.5.146",
13
+ "prostgles-client": "^1.5.147",
14
14
  "prostgles-types": "^1.5.68",
15
15
  "socket.io-client": "^4.5.1"
16
16
  }
@@ -67,17 +67,17 @@
67
67
  "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
68
68
  },
69
69
  "node_modules/prostgles-client": {
70
- "version": "1.5.146",
71
- "resolved": "https://registry.npmjs.org/prostgles-client/-/prostgles-client-1.5.146.tgz",
72
- "integrity": "sha512-yslX4cBxLUelQfs+4051lv3CITl61YsuQLMNaw+B33ck0fTmN8ZhUVjDS0N4BCipM94i4kMbjLSz8BUCG54X4g==",
70
+ "version": "1.5.147",
71
+ "resolved": "https://registry.npmjs.org/prostgles-client/-/prostgles-client-1.5.147.tgz",
72
+ "integrity": "sha512-OHKHn9/Ynv/v3QSB53ZvhVvWp4pWsrLIy8ZDXloQprB8IUXSS2SdCWnbdkBoD9JH9Z4tUBoq88lTdS7G1KZY3w==",
73
73
  "dependencies": {
74
- "prostgles-types": "^1.5.132"
74
+ "prostgles-types": "^1.5.133"
75
75
  }
76
76
  },
77
77
  "node_modules/prostgles-types": {
78
- "version": "1.5.132",
79
- "resolved": "https://registry.npmjs.org/prostgles-types/-/prostgles-types-1.5.132.tgz",
80
- "integrity": "sha512-Ol+NTzRpcyQS4ED/Ptx9RAfnEXzHBNt/e70bo9LeQ5phLNUbAqjNQkksJLU5SPnu39+egRzRW8fNn5XSd9EySw=="
78
+ "version": "1.5.133",
79
+ "resolved": "https://registry.npmjs.org/prostgles-types/-/prostgles-types-1.5.133.tgz",
80
+ "integrity": "sha512-WVSuoiWAo1hgDl+9QSBPVhszwhxuX1WRi6CdE4epede1eD2Q5rQfO22bli0BBCQXyhE6l/A0Tt6UxhAIlDDSmw=="
81
81
  },
82
82
  "node_modules/socket.io-client": {
83
83
  "version": "4.5.1",
@@ -176,17 +176,17 @@
176
176
  "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
177
177
  },
178
178
  "prostgles-client": {
179
- "version": "1.5.146",
180
- "resolved": "https://registry.npmjs.org/prostgles-client/-/prostgles-client-1.5.146.tgz",
181
- "integrity": "sha512-yslX4cBxLUelQfs+4051lv3CITl61YsuQLMNaw+B33ck0fTmN8ZhUVjDS0N4BCipM94i4kMbjLSz8BUCG54X4g==",
179
+ "version": "1.5.147",
180
+ "resolved": "https://registry.npmjs.org/prostgles-client/-/prostgles-client-1.5.147.tgz",
181
+ "integrity": "sha512-OHKHn9/Ynv/v3QSB53ZvhVvWp4pWsrLIy8ZDXloQprB8IUXSS2SdCWnbdkBoD9JH9Z4tUBoq88lTdS7G1KZY3w==",
182
182
  "requires": {
183
- "prostgles-types": "^1.5.132"
183
+ "prostgles-types": "^1.5.133"
184
184
  }
185
185
  },
186
186
  "prostgles-types": {
187
- "version": "1.5.132",
188
- "resolved": "https://registry.npmjs.org/prostgles-types/-/prostgles-types-1.5.132.tgz",
189
- "integrity": "sha512-Ol+NTzRpcyQS4ED/Ptx9RAfnEXzHBNt/e70bo9LeQ5phLNUbAqjNQkksJLU5SPnu39+egRzRW8fNn5XSd9EySw=="
187
+ "version": "1.5.133",
188
+ "resolved": "https://registry.npmjs.org/prostgles-types/-/prostgles-types-1.5.133.tgz",
189
+ "integrity": "sha512-WVSuoiWAo1hgDl+9QSBPVhszwhxuX1WRi6CdE4epede1eD2Q5rQfO22bli0BBCQXyhE6l/A0Tt6UxhAIlDDSmw=="
190
190
  },
191
191
  "socket.io-client": {
192
192
  "version": "4.5.1",
@@ -13,7 +13,7 @@
13
13
  "license": "ISC",
14
14
  "dependencies": {
15
15
  "@types/node": "^14.14.16",
16
- "prostgles-client": "^1.5.146",
16
+ "prostgles-client": "^1.5.147",
17
17
  "prostgles-types": "^1.5.68",
18
18
  "socket.io-client": "^4.5.1"
19
19
  }
@@ -170,6 +170,14 @@ async function client_only(db, auth, log, methods) {
170
170
  { id: 1, public: 'public data' },
171
171
  { id: 2, public: 'public data' }
172
172
  ]);
173
+ const cols = await db.insert_rules.getColumns();
174
+ assert_1.strict.equal(cols.filter(({ insert, update: u, select: s, delete: d }) => insert && !u && !s && !d).length, 3, "Validated getColumns failed");
175
+ /* Validated insert */
176
+ const expectB = await db.insert_rules.insert({ name: "a" }, { returning: "*" });
177
+ assert_1.strict.deepStrictEqual(expectB, { name: "b" }, "Validated insert failed");
178
+ /* forced UUID insert */
179
+ const row = await db.uuid_text.insert({}, { returning: "*" });
180
+ assert_1.strict.equal(row.id, 'c81089e1-c4c1-45d7-a73d-e2d613cb7c3e');
173
181
  });
174
182
  // await tryRun("Duplicate subscription", async () => {
175
183
  // return new Promise(async (resolve, reject) => {
@@ -193,14 +201,6 @@ async function client_only(db, auth, log, methods) {
193
201
  // });
194
202
  // })
195
203
  // })
196
- const cols = await db.insert_rules.getColumns();
197
- assert_1.strict.equal(cols.filter(({ insert, update: u, select: s, delete: d }) => insert && !u && !s && !d).length, 3, "Validated getColumns failed");
198
- /* Validated insert */
199
- const expectB = await db.insert_rules.insert({ name: "a" }, { returning: "*" });
200
- assert_1.strict.deepStrictEqual(expectB, { name: "b" }, "Validated insert failed");
201
- /* forced UUID insert */
202
- const row = await db.uuid_text.insert({}, { returning: "*" });
203
- assert_1.strict.equal(row.id, 'c81089e1-c4c1-45d7-a73d-e2d613cb7c3e');
204
204
  await testRealtime();
205
205
  // auth.login({ username: "john", password: "secret" });
206
206
  // await tout();
@@ -214,6 +214,27 @@ async function client_only(db, auth, log, methods) {
214
214
  { id: 1, public: 'public data' },
215
215
  { id: 2, public: 'public data' }
216
216
  ]);
217
+ const dynamicCols = await db.uuid_text.getColumns(undefined, {
218
+ rule: "update",
219
+ filter: {
220
+ id: 'c81089e1-c4c1-45d7-a73d-e2d613cb7c3e'
221
+ },
222
+ data: {
223
+ id: "dwadwa"
224
+ }
225
+ });
226
+ assert_1.strict.equal(dynamicCols.length, 1);
227
+ assert_1.strict.equal(dynamicCols[0].name, "id");
228
+ const defaultCols = await db.uuid_text.getColumns(undefined, {
229
+ rule: "update",
230
+ filter: {
231
+ id: 'not matching'
232
+ },
233
+ data: {
234
+ id: "dwadwa"
235
+ }
236
+ });
237
+ throw defaultCols.map(c => c.name);
217
238
  }, log);
218
239
  }
219
240
  }
@@ -201,6 +201,18 @@ export default async function client_only(db: DBHandlerClient, auth: Auth, log:
201
201
  { id: 1, public: 'public data' },
202
202
  { id: 2, public: 'public data' }
203
203
  ]);
204
+
205
+
206
+ const cols = await db.insert_rules.getColumns();
207
+ assert.equal(cols.filter(({ insert, update: u, select: s, delete: d }) => insert && !u && !s && !d).length, 3, "Validated getColumns failed")
208
+
209
+ /* Validated insert */
210
+ const expectB = await db.insert_rules.insert({ name: "a" }, { returning: "*" });
211
+ assert.deepStrictEqual(expectB, { name: "b" }, "Validated insert failed");
212
+
213
+ /* forced UUID insert */
214
+ const row: any = await db.uuid_text.insert({}, {returning: "*"});
215
+ assert.equal(row.id, 'c81089e1-c4c1-45d7-a73d-e2d613cb7c3e');
204
216
  });
205
217
 
206
218
  // await tryRun("Duplicate subscription", async () => {
@@ -228,16 +240,7 @@ export default async function client_only(db: DBHandlerClient, auth: Auth, log:
228
240
  // })
229
241
  // })
230
242
 
231
- const cols = await db.insert_rules.getColumns();
232
- assert.equal(cols.filter(({ insert, update: u, select: s, delete: d }) => insert && !u && !s && !d).length, 3, "Validated getColumns failed")
233
-
234
- /* Validated insert */
235
- const expectB = await db.insert_rules.insert({ name: "a" }, { returning: "*" });
236
- assert.deepStrictEqual(expectB, { name: "b" }, "Validated insert failed");
237
243
 
238
- /* forced UUID insert */
239
- const row: any = await db.uuid_text.insert({}, {returning: "*"});
240
- assert.equal(row.id, 'c81089e1-c4c1-45d7-a73d-e2d613cb7c3e')
241
244
 
242
245
  await testRealtime();
243
246
 
@@ -254,6 +257,29 @@ export default async function client_only(db: DBHandlerClient, auth: Auth, log:
254
257
  { id: 1, public: 'public data' },
255
258
  { id: 2, public: 'public data' }
256
259
  ]);
260
+
261
+
262
+ const dynamicCols = await db.uuid_text.getColumns(undefined, {
263
+ rule: "update",
264
+ filter: {
265
+ id: 'c81089e1-c4c1-45d7-a73d-e2d613cb7c3e'
266
+ },
267
+ data: {
268
+ id: "dwadwa"
269
+ }
270
+ });
271
+ assert.equal(dynamicCols.length, 1);
272
+ assert.equal(dynamicCols[0].name, "id");
273
+ const defaultCols = await db.uuid_text.getColumns(undefined, {
274
+ rule: "update",
275
+ filter: {
276
+ id: 'not matching'
277
+ },
278
+ data: {
279
+ id: "dwadwa"
280
+ }
281
+ });
282
+ throw defaultCols.map(c => c.name);
257
283
  }, log);
258
284
  }
259
285
 
@@ -87,7 +87,7 @@ async function isomorphic(db) {
87
87
  await tryRun("getColumns definition", async () => {
88
88
  const res = await db.tr2.getColumns("fr");
89
89
  // console.log(JSON.stringify(res, null, 2))
90
- assert_1.strict.deepStrictEqual(res, [
90
+ const expected = [
91
91
  {
92
92
  "label": "Id",
93
93
  "name": "id",
@@ -180,7 +180,10 @@ async function isomorphic(db) {
180
180
  "update": true,
181
181
  "delete": true
182
182
  }
183
- ]);
183
+ ];
184
+ assert_1.strict.deepStrictEqual(res, expected);
185
+ const resDynamic = await db.tr2.getColumns("fr", { rule: "update", filter: {}, data: { t2: "a" } });
186
+ assert_1.strict.deepStrictEqual(resDynamic, expected);
184
187
  });
185
188
  await tryRun("$unnest_words", async () => {
186
189
  const res = await db.various.find({}, { returnType: "values", select: { name: "$unnest_words" } });
@@ -73,9 +73,7 @@ export default async function isomorphic(db: Partial<DbHandler> | Partial<DBHand
73
73
  await tryRun("getColumns definition", async () => {
74
74
  const res = await db.tr2.getColumns("fr");
75
75
  // console.log(JSON.stringify(res, null, 2))
76
- assert.deepStrictEqual(
77
- res,
78
- [
76
+ const expected = [
79
77
  {
80
78
  "label": "Id",
81
79
  "name": "id",
@@ -168,7 +166,17 @@ export default async function isomorphic(db: Partial<DbHandler> | Partial<DBHand
168
166
  "update": true,
169
167
  "delete": true
170
168
  }
171
- ]
169
+ ];
170
+
171
+ assert.deepStrictEqual(
172
+ res,
173
+ expected
174
+ );
175
+
176
+ const resDynamic = await db.tr2.getColumns("fr", { rule: "update", filter: {}, data: { t2: "a" } });
177
+ assert.deepStrictEqual(
178
+ resDynamic,
179
+ expected
172
180
  );
173
181
  });
174
182
 
@@ -268,6 +268,15 @@ const dbConnection = {
268
268
  forcedData: {
269
269
  id: 'c81089e1-c4c1-45d7-a73d-e2d613cb7c3e'
270
270
  }
271
+ },
272
+ update: {
273
+ fields: [],
274
+ dynamicFields: [{
275
+ fields: { id: 1 },
276
+ filter: {
277
+ id: 'c81089e1-c4c1-45d7-a73d-e2d613cb7c3e'
278
+ }
279
+ }]
271
280
  }
272
281
  }
273
282
  };
@@ -290,6 +290,15 @@ const dbConnection = {
290
290
  forcedData: {
291
291
  id: 'c81089e1-c4c1-45d7-a73d-e2d613cb7c3e'
292
292
  }
293
+ },
294
+ update: {
295
+ fields: [],
296
+ dynamicFields: [{
297
+ fields: { id: 1 },
298
+ filter: {
299
+ id: 'c81089e1-c4c1-45d7-a73d-e2d613cb7c3e'
300
+ }
301
+ }]
293
302
  }
294
303
  }
295
304
  };
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "../..": {
23
23
  "name": "prostgles-server",
24
- "version": "2.0.161",
24
+ "version": "2.0.164",
25
25
  "license": "MIT",
26
26
  "dependencies": {
27
27
  "@aws-sdk/client-s3": "^3.95.0",
@@ -29,7 +29,7 @@
29
29
  "bluebird": "^3.7.2",
30
30
  "file-type": "^16.5.3",
31
31
  "pg-promise": "^10.11.1",
32
- "prostgles-types": "^1.5.132",
32
+ "prostgles-types": "^1.5.134",
33
33
  "sharp": "^0.30.5"
34
34
  },
35
35
  "devDependencies": {
@@ -1371,7 +1371,7 @@
1371
1371
  "bluebird": "^3.7.2",
1372
1372
  "file-type": "^16.5.3",
1373
1373
  "pg-promise": "^10.11.1",
1374
- "prostgles-types": "^1.5.132",
1374
+ "prostgles-types": "^1.5.134",
1375
1375
  "sharp": "^0.30.5",
1376
1376
  "typescript": "^4.7.2"
1377
1377
  }