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/client.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { P as ProtoClient } from './internals/index-B9CWU0y7.js';
2
- export { c as classExtends, e as isFile, a as isObject, i as isQuery, d as isRole, b as isUser } from './internals/index-B9CWU0y7.js';
1
+ import { P as ProtoClient } from './internals/index-Bh60s4Tq.js';
2
+ export { c as classExtends, e as isFile, a as isObject, i as isQuery, d as isRole, b as isUser } from './internals/index-Bh60s4Tq.js';
3
3
  export { Decimal } from 'decimal.js';
4
- export { D as DeserializeOptions, S as SerializeOptions, d as TSerializable, e as deserialize, s as serialize } from './internals/index-BYZpj31o.js';
4
+ export { D as DeserializeOptions, S as SerializeOptions, d as TSerializable, e as deserialize, s as serialize } from './internals/index-BZcW5wgM.js';
5
5
  import '@o2ter/utils-js';
6
6
  import 'socket.io-client';
7
7
  import '@socket.io/component-emitter';
package/dist/client.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./internals/index-CvA0tbwx.js');
5
+ var index = require('./internals/index-Cd6nNb--.js');
6
6
  var Decimal = require('decimal.js');
7
7
  require('./internals/index-DXuW8UiB.js');
8
8
  require('lodash');
package/dist/client.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { c as ProtoClient } from './internals/index-BPbXumUi.mjs';
2
- export { e as classExtends, d as deserialize, j as isFile, f as isObject, i as isQuery, h as isRole, g as isUser, s as serialize } from './internals/index-BPbXumUi.mjs';
1
+ import { c as ProtoClient } from './internals/index-tEsKpX2d.mjs';
2
+ export { e as classExtends, d as deserialize, j as isFile, f as isObject, i as isQuery, h as isRole, g as isUser, s as serialize } from './internals/index-tEsKpX2d.mjs';
3
3
  export { Decimal } from 'decimal.js';
4
4
  import './internals/index-CTsc042s.mjs';
5
5
  import 'lodash';
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import * as socket_io from 'socket.io';
2
2
  import { Router } from 'express';
3
3
  import { Server } from '@o2ter/server-js';
4
- import { T as TSchema, _ as _TValue, P as ProtoService, a as ProtoServiceOptions, b as ProtoServiceKeyOptions } from './internals/index-BYZpj31o.js';
5
- export { D as DeserializeOptions, S as SerializeOptions, c as TFileStorage, d as TSerializable, e as deserialize, s as serialize } from './internals/index-BYZpj31o.js';
4
+ import { T as TSchema, _ as _TValue, P as ProtoService, a as ProtoServiceOptions, b as ProtoServiceKeyOptions } from './internals/index-BZcW5wgM.js';
5
+ export { D as DeserializeOptions, S as SerializeOptions, c as TFileStorage, d as TSerializable, e as deserialize, s as serialize } from './internals/index-BZcW5wgM.js';
6
6
  import Decimal from 'decimal.js';
7
7
  export { Decimal } from 'decimal.js';
8
- export { P as ProtoClient, c as classExtends, e as isFile, a as isObject, i as isQuery, d as isRole, b as isUser } from './internals/index-B9CWU0y7.js';
8
+ export { P as ProtoClient, c as classExtends, e as isFile, a as isObject, i as isQuery, d as isRole, b as isUser } from './internals/index-Bh60s4Tq.js';
9
9
  import '@o2ter/utils-js';
10
10
  import 'jsonwebtoken';
11
11
  import 'lodash';
package/dist/index.js CHANGED
@@ -4,10 +4,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var _ = require('lodash');
6
6
  var serverJs = require('@o2ter/server-js');
7
- var random = require('./internals/random-DVOUDDGg.js');
7
+ var random = require('./internals/random-CvVZek_8.js');
8
8
  var _private = require('./internals/private-CSB1Ep4g.js');
9
9
  var utilsJs = require('@o2ter/utils-js');
10
- var index = require('./internals/index-CvA0tbwx.js');
10
+ var index = require('./internals/index-Cd6nNb--.js');
11
11
  var index$1 = require('./internals/index-DXuW8UiB.js');
12
12
  var jwt = require('jsonwebtoken');
13
13
  var node_buffer = require('node:buffer');
@@ -134,6 +134,7 @@ const dispatcher = (proto, options, disableSecurity) => {
134
134
  async insert(options, attrs) {
135
135
  random.QueryValidator.recursiveCheck(attrs);
136
136
  const _validator = await validator();
137
+ _validator.validateCountMatches(options.className, options.countMatches ?? []);
137
138
  const _includes = _validator.decodeIncludes(options.className, options.includes ?? ['*']);
138
139
  const _matches = _validator.decodeMatches(options.className, options.matches ?? {}, _includes);
139
140
  if (!_validator.validateCLPs(options.className, 'create'))
@@ -145,6 +146,7 @@ const dispatcher = (proto, options, disableSecurity) => {
145
146
  className: options.className,
146
147
  includes: _includes,
147
148
  matches: _matches,
149
+ countMatches: options.countMatches ?? [],
148
150
  objectIdSize: proto[_private.PVK].options.objectIdSize
149
151
  }, _attrs), { lockTable: options.className, retry: true });
150
152
  }
@@ -158,6 +160,7 @@ const dispatcher = (proto, options, disableSecurity) => {
158
160
  async insertMany(options, values) {
159
161
  random.QueryValidator.recursiveCheck(values);
160
162
  const _validator = await validator();
163
+ _validator.validateCountMatches(options.className, options.countMatches ?? []);
161
164
  const _includes = _validator.decodeIncludes(options.className, options.includes ?? ['*']);
162
165
  const _matches = _validator.decodeMatches(options.className, options.matches ?? {}, _includes);
163
166
  if (!_validator.validateCLPs(options.className, 'create'))
@@ -169,6 +172,7 @@ const dispatcher = (proto, options, disableSecurity) => {
169
172
  className: options.className,
170
173
  includes: _includes,
171
174
  matches: _matches,
175
+ countMatches: options.countMatches ?? [],
172
176
  objectIdSize: proto[_private.PVK].options.objectIdSize
173
177
  }, _attrs), { lockTable: options.className, retry: true });
174
178
  }
@@ -358,6 +362,7 @@ class _ProtoQuery extends index.TQuery {
358
362
  className: this.className,
359
363
  includes: this[_private.PVK].options.includes,
360
364
  matches: this[_private.PVK].options.matches,
365
+ countMatches: this[_private.PVK].options.countMatches,
361
366
  }, attrs));
362
367
  if (!result)
363
368
  throw Error('Unable to insert document');
@@ -368,6 +373,7 @@ class _ProtoQuery extends index.TQuery {
368
373
  className: this.className,
369
374
  includes: this[_private.PVK].options.includes,
370
375
  matches: this[_private.PVK].options.matches,
376
+ countMatches: this[_private.PVK].options.countMatches,
371
377
  }, values);
372
378
  }
373
379
  async updateOne(update, options) {
@@ -1462,12 +1468,14 @@ class ProtoService extends index.ProtoType {
1462
1468
  });
1463
1469
  }
1464
1470
  async gc(classNames) {
1471
+ const time = new Date();
1465
1472
  for (const className of _.castArray(classNames ?? this.classes())) {
1466
1473
  if (className === 'File') {
1467
1474
  const found = this.storage.find({
1468
1475
  className: 'File',
1469
- filter: index$2.QuerySelector.decode({ _expired_at: { $lt: new Date() } }),
1476
+ filter: index$2.QuerySelector.decode({ _expired_at: { $lt: time } }),
1470
1477
  matches: {},
1478
+ countMatches: [],
1471
1479
  includes: ['_id', '_expired_at', 'token'],
1472
1480
  objectIdSize: 0
1473
1481
  });
@@ -1479,9 +1487,10 @@ class ProtoService extends index.ProtoType {
1479
1487
  }
1480
1488
  await this.storage.deleteMany({
1481
1489
  className,
1482
- filter: index$2.QuerySelector.decode({ _expired_at: { $lt: new Date() } }),
1490
+ filter: index$2.QuerySelector.decode({ _expired_at: { $lt: time } }),
1483
1491
  includes: ['_id', '_expired_at'],
1484
1492
  matches: {},
1493
+ countMatches: [],
1485
1494
  objectIdSize: 0
1486
1495
  });
1487
1496
  }