proto.io 0.0.175 → 0.0.176

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.
Files changed (42) hide show
  1. package/dist/adapters/file/database.d.ts +2 -2
  2. package/dist/adapters/file/database.js +1 -0
  3. package/dist/adapters/file/database.js.map +1 -1
  4. package/dist/adapters/file/database.mjs +1 -0
  5. package/dist/adapters/file/database.mjs.map +1 -1
  6. package/dist/adapters/file/filesystem.d.ts +2 -2
  7. package/dist/adapters/file/google-cloud-storage.d.ts +2 -2
  8. package/dist/adapters/storage/progres.d.ts +3 -2
  9. package/dist/adapters/storage/progres.js +51 -29
  10. package/dist/adapters/storage/progres.js.map +1 -1
  11. package/dist/adapters/storage/progres.mjs +52 -30
  12. package/dist/adapters/storage/progres.mjs.map +1 -1
  13. package/dist/client.d.ts +3 -3
  14. package/dist/client.js +1 -1
  15. package/dist/client.mjs +2 -2
  16. package/dist/index.d.ts +3 -3
  17. package/dist/index.js +13 -4
  18. package/dist/index.js.map +1 -1
  19. package/dist/index.mjs +14 -5
  20. package/dist/index.mjs.map +1 -1
  21. package/dist/internals/{index-BQqYdjaH.d.ts → index-B0DE6MVr.d.ts} +2 -2
  22. package/dist/internals/index-B0DE6MVr.d.ts.map +1 -0
  23. package/dist/internals/{index-BYZpj31o.d.ts → index-BZcW5wgM.d.ts} +16 -1
  24. package/dist/internals/index-BZcW5wgM.d.ts.map +1 -0
  25. package/dist/internals/{index-B9CWU0y7.d.ts → index-Bh60s4Tq.d.ts} +2 -2
  26. package/dist/internals/index-Bh60s4Tq.d.ts.map +1 -0
  27. package/dist/internals/{index-CvA0tbwx.js → index-Cd6nNb--.js} +15 -1
  28. package/dist/internals/index-Cd6nNb--.js.map +1 -0
  29. package/dist/internals/{index-BPbXumUi.mjs → index-tEsKpX2d.mjs} +15 -1
  30. package/dist/internals/index-tEsKpX2d.mjs.map +1 -0
  31. package/dist/internals/{random-DVOUDDGg.js → random-CvVZek_8.js} +13 -1
  32. package/dist/internals/random-CvVZek_8.js.map +1 -0
  33. package/dist/internals/{random-BMQpRlGH.mjs → random-DGiu1IIq.mjs} +14 -2
  34. package/dist/internals/random-DGiu1IIq.mjs.map +1 -0
  35. package/package.json +1 -1
  36. package/dist/internals/index-B9CWU0y7.d.ts.map +0 -1
  37. package/dist/internals/index-BPbXumUi.mjs.map +0 -1
  38. package/dist/internals/index-BQqYdjaH.d.ts.map +0 -1
  39. package/dist/internals/index-BYZpj31o.d.ts.map +0 -1
  40. package/dist/internals/index-CvA0tbwx.js.map +0 -1
  41. package/dist/internals/random-BMQpRlGH.mjs.map +0 -1
  42. package/dist/internals/random-DVOUDDGg.js.map +0 -1
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  import _ from 'lodash';
2
2
  import { Server } from '@o2ter/server-js';
3
- import { Q as QueryValidator, r as resolveColumn, a as resolveDataType, g as generateId } from './internals/random-BMQpRlGH.mjs';
3
+ import { Q as QueryValidator, r as resolveColumn, a as resolveDataType, g as generateId } from './internals/random-DGiu1IIq.mjs';
4
4
  import { P as PVK } from './internals/private-BUpLAMZi.mjs';
5
5
  import { asyncStream, prototypes, isBinaryData, base64ToBuffer } from '@o2ter/utils-js';
6
- import { T as TQuery, M as MASTER_USER_HEADER_NAME, a as MASTER_PASS_HEADER_NAME, A as AUTH_COOKIE_KEY, b as TUser, P as ProtoType, s as serialize, d as deserialize, U as UPLOAD_TOKEN_HEADER_NAME } from './internals/index-BPbXumUi.mjs';
7
- export { c as ProtoClient, e as classExtends, j as isFile, f as isObject, i as isQuery, h as isRole, g as isUser } from './internals/index-BPbXumUi.mjs';
6
+ import { T as TQuery, M as MASTER_USER_HEADER_NAME, a as MASTER_PASS_HEADER_NAME, A as AUTH_COOKIE_KEY, b as TUser, P as ProtoType, s as serialize, d as deserialize, U as UPLOAD_TOKEN_HEADER_NAME } from './internals/index-tEsKpX2d.mjs';
7
+ export { c as ProtoClient, e as classExtends, j as isFile, f as isObject, i as isQuery, h as isRole, g as isUser } from './internals/index-tEsKpX2d.mjs';
8
8
  import { i as isPointer, a as isRelation, T as TObject, b as isShape, d as defaultObjectKeyTypes, c as isPrimitive } from './internals/index-CTsc042s.mjs';
9
9
  import jwt from 'jsonwebtoken';
10
10
  import { Blob } from 'node:buffer';
@@ -131,6 +131,7 @@ const dispatcher = (proto, options, disableSecurity) => {
131
131
  async insert(options, attrs) {
132
132
  QueryValidator.recursiveCheck(attrs);
133
133
  const _validator = await validator();
134
+ _validator.validateCountMatches(options.className, options.countMatches ?? []);
134
135
  const _includes = _validator.decodeIncludes(options.className, options.includes ?? ['*']);
135
136
  const _matches = _validator.decodeMatches(options.className, options.matches ?? {}, _includes);
136
137
  if (!_validator.validateCLPs(options.className, 'create'))
@@ -142,6 +143,7 @@ const dispatcher = (proto, options, disableSecurity) => {
142
143
  className: options.className,
143
144
  includes: _includes,
144
145
  matches: _matches,
146
+ countMatches: options.countMatches ?? [],
145
147
  objectIdSize: proto[PVK].options.objectIdSize
146
148
  }, _attrs), { lockTable: options.className, retry: true });
147
149
  }
@@ -155,6 +157,7 @@ const dispatcher = (proto, options, disableSecurity) => {
155
157
  async insertMany(options, values) {
156
158
  QueryValidator.recursiveCheck(values);
157
159
  const _validator = await validator();
160
+ _validator.validateCountMatches(options.className, options.countMatches ?? []);
158
161
  const _includes = _validator.decodeIncludes(options.className, options.includes ?? ['*']);
159
162
  const _matches = _validator.decodeMatches(options.className, options.matches ?? {}, _includes);
160
163
  if (!_validator.validateCLPs(options.className, 'create'))
@@ -166,6 +169,7 @@ const dispatcher = (proto, options, disableSecurity) => {
166
169
  className: options.className,
167
170
  includes: _includes,
168
171
  matches: _matches,
172
+ countMatches: options.countMatches ?? [],
169
173
  objectIdSize: proto[PVK].options.objectIdSize
170
174
  }, _attrs), { lockTable: options.className, retry: true });
171
175
  }
@@ -355,6 +359,7 @@ class _ProtoQuery extends TQuery {
355
359
  className: this.className,
356
360
  includes: this[PVK].options.includes,
357
361
  matches: this[PVK].options.matches,
362
+ countMatches: this[PVK].options.countMatches,
358
363
  }, attrs));
359
364
  if (!result)
360
365
  throw Error('Unable to insert document');
@@ -365,6 +370,7 @@ class _ProtoQuery extends TQuery {
365
370
  className: this.className,
366
371
  includes: this[PVK].options.includes,
367
372
  matches: this[PVK].options.matches,
373
+ countMatches: this[PVK].options.countMatches,
368
374
  }, values);
369
375
  }
370
376
  async updateOne(update, options) {
@@ -1459,12 +1465,14 @@ class ProtoService extends ProtoType {
1459
1465
  });
1460
1466
  }
1461
1467
  async gc(classNames) {
1468
+ const time = new Date();
1462
1469
  for (const className of _.castArray(classNames ?? this.classes())) {
1463
1470
  if (className === 'File') {
1464
1471
  const found = this.storage.find({
1465
1472
  className: 'File',
1466
- filter: QuerySelector.decode({ _expired_at: { $lt: new Date() } }),
1473
+ filter: QuerySelector.decode({ _expired_at: { $lt: time } }),
1467
1474
  matches: {},
1475
+ countMatches: [],
1468
1476
  includes: ['_id', '_expired_at', 'token'],
1469
1477
  objectIdSize: 0
1470
1478
  });
@@ -1476,9 +1484,10 @@ class ProtoService extends ProtoType {
1476
1484
  }
1477
1485
  await this.storage.deleteMany({
1478
1486
  className,
1479
- filter: QuerySelector.decode({ _expired_at: { $lt: new Date() } }),
1487
+ filter: QuerySelector.decode({ _expired_at: { $lt: time } }),
1480
1488
  includes: ['_id', '_expired_at'],
1481
1489
  matches: {},
1490
+ countMatches: [],
1482
1491
  objectIdSize: 0
1483
1492
  });
1484
1493
  }