proto.io 0.0.182 → 0.0.183

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 (30) hide show
  1. package/dist/adapters/file/database.d.ts +2 -2
  2. package/dist/adapters/file/filesystem.d.ts +2 -2
  3. package/dist/adapters/file/google-cloud-storage.d.ts +2 -2
  4. package/dist/adapters/storage/progres.d.ts +1 -1
  5. package/dist/adapters/storage/progres.js +1 -1
  6. package/dist/adapters/storage/progres.mjs +1 -1
  7. package/dist/client.d.ts +3 -3
  8. package/dist/index.d.ts +3 -3
  9. package/dist/index.js +13 -4
  10. package/dist/index.js.map +1 -1
  11. package/dist/index.mjs +13 -4
  12. package/dist/index.mjs.map +1 -1
  13. package/dist/internals/index-BnDahEvz.js.map +1 -1
  14. package/dist/internals/{index-BZupzq1Y.d.ts → index-C1pF5Xzm.d.ts} +2 -2
  15. package/dist/internals/index-C1pF5Xzm.d.ts.map +1 -0
  16. package/dist/internals/index-CmJh3t_k.mjs.map +1 -1
  17. package/dist/internals/{index-YpB-hXxf.d.ts → index-YJ0pBNzy.d.ts} +7 -11
  18. package/dist/internals/index-YJ0pBNzy.d.ts.map +1 -0
  19. package/dist/internals/{index-cKx59cIc.d.ts → index-Z57iS68O.d.ts} +2 -2
  20. package/dist/internals/index-Z57iS68O.d.ts.map +1 -0
  21. package/dist/internals/{random-CDtFUuES.js → random-80Vpxbxh.js} +9 -11
  22. package/dist/internals/random-80Vpxbxh.js.map +1 -0
  23. package/dist/internals/{random-BSyWEK8G.mjs → random-BtYyzHJD.mjs} +9 -11
  24. package/dist/internals/random-BtYyzHJD.mjs.map +1 -0
  25. package/package.json +1 -1
  26. package/dist/internals/index-BZupzq1Y.d.ts.map +0 -1
  27. package/dist/internals/index-YpB-hXxf.d.ts.map +0 -1
  28. package/dist/internals/index-cKx59cIc.d.ts.map +0 -1
  29. package/dist/internals/random-BSyWEK8G.mjs.map +0 -1
  30. package/dist/internals/random-CDtFUuES.js.map +0 -1
@@ -1,5 +1,5 @@
1
- import { T as TSchema, P as ProtoService } from '../../internals/index-YpB-hXxf.js';
2
- import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/index-BZupzq1Y.js';
1
+ import { T as TSchema, P as ProtoService } from '../../internals/index-YJ0pBNzy.js';
2
+ import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/index-C1pF5Xzm.js';
3
3
  import '@o2ter/utils-js';
4
4
  import 'jsonwebtoken';
5
5
  import '@o2ter/server-js';
@@ -1,5 +1,5 @@
1
- import { P as ProtoService } from '../../internals/index-YpB-hXxf.js';
2
- import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/index-BZupzq1Y.js';
1
+ import { P as ProtoService } from '../../internals/index-YJ0pBNzy.js';
2
+ import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/index-C1pF5Xzm.js';
3
3
  import '@o2ter/utils-js';
4
4
  import 'jsonwebtoken';
5
5
  import '@o2ter/server-js';
@@ -1,7 +1,7 @@
1
1
  import * as _google_cloud_storage from '@google-cloud/storage';
2
2
  import { Storage } from '@google-cloud/storage';
3
- import { P as ProtoService } from '../../internals/index-YpB-hXxf.js';
4
- import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/index-BZupzq1Y.js';
3
+ import { P as ProtoService } from '../../internals/index-YJ0pBNzy.js';
4
+ import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/index-C1pF5Xzm.js';
5
5
  import '@o2ter/utils-js';
6
6
  import 'jsonwebtoken';
7
7
  import '@o2ter/server-js';
@@ -1,5 +1,5 @@
1
1
  import { Pool, PoolClient, PoolConfig } from 'pg';
2
- import { _ as _TValue, T as TSchema, Q as QuerySelector, p as DecodedQuery, F as FindOptions, R as RelationOptions, q as DecodedSortOption, I as InsertOptions, r as TValue, t as FindOneOptions, u as TUpdateOp, v as FieldSelectorExpression, w as QueryExpression, x as TStorage, y as TransactionOptions, h as TObject, z as TQueryRandomOptions, A as TPubSub } from '../../internals/index-YpB-hXxf.js';
2
+ import { _ as _TValue, T as TSchema, Q as QuerySelector, p as DecodedQuery, F as FindOptions, R as RelationOptions, q as DecodedSortOption, I as InsertOptions, r as TValue, t as FindOneOptions, u as TUpdateOp, v as FieldSelectorExpression, w as QueryExpression, x as TStorage, y as TransactionOptions, h as TObject, z as TQueryRandomOptions, A as TPubSub } from '../../internals/index-YJ0pBNzy.js';
3
3
  import * as _o2ter_utils_js from '@o2ter/utils-js';
4
4
  import { asyncStream } from '@o2ter/utils-js';
5
5
  import 'jsonwebtoken';
@@ -11,7 +11,7 @@ var Decimal = require('decimal.js');
11
11
  var utils = require('pg/lib/utils');
12
12
  var index$1 = require('../../internals/index-DjrC854w.js');
13
13
  require('@o2ter/crypto-js');
14
- var random$1 = require('../../internals/random-CDtFUuES.js');
14
+ var random$1 = require('../../internals/random-80Vpxbxh.js');
15
15
  var _private = require('../../internals/private-Ciddhure.js');
16
16
 
17
17
  //
@@ -7,7 +7,7 @@ import Decimal from 'decimal.js';
7
7
  import { escapeLiteral, escapeIdentifier } from 'pg/lib/utils';
8
8
  import { a as QueryCoditionalSelector, b as QueryFieldSelector, c as QueryExpressionSelector, d as QueryDistanceExpression, e as QueryCoditionalExpression, f as QueryComparisonExpression, g as QueryNotExpression, h as QueryArrayExpression, i as QueryValueExpression, j as QueryKeyExpression, Q as QuerySelector, F as FieldSelectorExpression } from '../../internals/index-D9AowvHp.mjs';
9
9
  import '@o2ter/crypto-js';
10
- import { r as resolveColumn, a as resolveDataType, g as generateId, Q as QueryValidator } from '../../internals/random-BSyWEK8G.mjs';
10
+ import { r as resolveColumn, a as resolveDataType, g as generateId, Q as QueryValidator } from '../../internals/random-BtYyzHJD.mjs';
11
11
  import { P as PVK } from '../../internals/private-CNw40LZ7.mjs';
12
12
 
13
13
  //
package/dist/client.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { P as ProtoClient } from './internals/index-cKx59cIc.js';
2
- export { c as classExtends, e as isFile, a as isObject, i as isQuery, d as isRole, b as isUser } from './internals/index-cKx59cIc.js';
1
+ import { P as ProtoClient } from './internals/index-Z57iS68O.js';
2
+ export { c as classExtends, e as isFile, a as isObject, i as isQuery, d as isRole, b as isUser } from './internals/index-Z57iS68O.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-YpB-hXxf.js';
4
+ export { D as DeserializeOptions, S as SerializeOptions, d as TSerializable, e as deserialize, s as serialize } from './internals/index-YJ0pBNzy.js';
5
5
  import '@o2ter/utils-js';
6
6
  import 'socket.io-client';
7
7
  import '@socket.io/component-emitter';
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-YpB-hXxf.js';
5
- export { D as DeserializeOptions, S as SerializeOptions, c as TFileStorage, d as TSerializable, e as deserialize, s as serialize } from './internals/index-YpB-hXxf.js';
4
+ import { T as TSchema, _ as _TValue, P as ProtoService, a as ProtoServiceOptions, b as ProtoServiceKeyOptions } from './internals/index-YJ0pBNzy.js';
5
+ export { D as DeserializeOptions, S as SerializeOptions, c as TFileStorage, d as TSerializable, e as deserialize, s as serialize } from './internals/index-YJ0pBNzy.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-cKx59cIc.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-Z57iS68O.js';
9
9
  import '@o2ter/utils-js';
10
10
  import 'jsonwebtoken';
11
11
  import 'lodash';
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ 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-CDtFUuES.js');
7
+ var random = require('./internals/random-80Vpxbxh.js');
8
8
  var _private = require('./internals/private-Ciddhure.js');
9
9
  var utilsJs = require('@o2ter/utils-js');
10
10
  var index = require('./internals/index-BnDahEvz.js');
@@ -82,9 +82,12 @@ const normalize = (x) => {
82
82
  // THE SOFTWARE.
83
83
  //
84
84
  const fetchUserPerms = async (proto) => _.uniq(_.compact([..._.map(await proto.currentRoles(), x => `role:${x}`), (await proto.currentUser())?.objectId]));
85
- const dispatcher = (proto, options, disableSecurity) => {
85
+ const dispatcher = (proto, options) => {
86
86
  const acls = async () => options.master ? [] : await fetchUserPerms(proto);
87
- const validator = async () => new random.QueryValidator(proto, await acls(), options.master ?? false, disableSecurity);
87
+ const validator = async () => new random.QueryValidator(proto, await acls(), {
88
+ master: options.master ?? false,
89
+ disableSecurity: options.disableSecurity,
90
+ });
88
91
  return {
89
92
  async explain(query) {
90
93
  random.QueryValidator.recursiveCheck(query);
@@ -318,11 +321,17 @@ class _ProtoQuery extends index.TQuery {
318
321
  };
319
322
  }
320
323
  _dispatcher(options) {
324
+ const schema = this._proto.schema[this.className];
325
+ if (_.isNil(schema))
326
+ throw Error('Invalid className');
321
327
  if (this._opts.insecure) {
322
328
  if (options?.master !== true)
323
329
  throw Error('No permission');
324
330
  }
325
- return dispatcher(_serviceOf(options) ?? this._proto, options ?? {}, !!this._opts.insecure);
331
+ return dispatcher(_serviceOf(options) ?? this._proto, {
332
+ ...options ?? {},
333
+ disableSecurity: !!this._opts.insecure,
334
+ });
326
335
  }
327
336
  explain(options) {
328
337
  return this._dispatcher(options).explain(this._queryOptions);