proto.io 0.0.141 → 0.0.143

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 +15 -14
  10. package/dist/index.js.map +1 -1
  11. package/dist/index.mjs +15 -14
  12. package/dist/index.mjs.map +1 -1
  13. package/dist/internals/index-C6zdNpc_.js.map +1 -1
  14. package/dist/internals/{index-BabXTvEZ.d.ts → index-DW9_3n_K.d.ts} +2 -1
  15. package/dist/internals/index-DW9_3n_K.d.ts.map +1 -0
  16. package/dist/internals/{index-BtnEuEVn.d.ts → index-DWyLziGT.d.ts} +2 -2
  17. package/dist/internals/index-DWyLziGT.d.ts.map +1 -0
  18. package/dist/internals/index-EOtjV6U_.mjs.map +1 -1
  19. package/dist/internals/{index-DCjn9EDu.d.ts → index-i4lOAqi2.d.ts} +2 -2
  20. package/dist/internals/index-i4lOAqi2.d.ts.map +1 -0
  21. package/dist/internals/{random-Dn9rhwfh.mjs → random-BjV_01xP.mjs} +21 -7
  22. package/dist/internals/random-BjV_01xP.mjs.map +1 -0
  23. package/dist/internals/{random-CiJ8I0Cd.js → random-XGNkddOu.js} +21 -7
  24. package/dist/internals/random-XGNkddOu.js.map +1 -0
  25. package/package.json +1 -1
  26. package/dist/internals/index-BabXTvEZ.d.ts.map +0 -1
  27. package/dist/internals/index-BtnEuEVn.d.ts.map +0 -1
  28. package/dist/internals/index-DCjn9EDu.d.ts.map +0 -1
  29. package/dist/internals/random-CiJ8I0Cd.js.map +0 -1
  30. package/dist/internals/random-Dn9rhwfh.mjs.map +0 -1
@@ -1,5 +1,5 @@
1
- import { T as TSchema, P as ProtoService } from '../../internals/index-BabXTvEZ.js';
2
- import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/index-DCjn9EDu.js';
1
+ import { T as TSchema, P as ProtoService } from '../../internals/index-DW9_3n_K.js';
2
+ import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/index-i4lOAqi2.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-BabXTvEZ.js';
2
- import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/index-DCjn9EDu.js';
1
+ import { P as ProtoService } from '../../internals/index-DW9_3n_K.js';
2
+ import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/index-i4lOAqi2.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-BabXTvEZ.js';
4
- import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/index-DCjn9EDu.js';
3
+ import { P as ProtoService } from '../../internals/index-DW9_3n_K.js';
4
+ import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/index-i4lOAqi2.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, o as EventData, T as TSchema, q as DecodedQuery, F as FindOptions, Q as QuerySelector, r as DecodedSortOption, I as InsertOptions, t as TValue, u as FindOneOptions, v as TUpdateOp, w as FieldSelectorExpression, x as QueryExpression, y as TStorage, z as TransactionOptions, h as TObject, A as TQueryRandomOptions, B as TPubSub } from '../../internals/index-BabXTvEZ.js';
2
+ import { _ as _TValue, o as EventData, T as TSchema, q as DecodedQuery, F as FindOptions, Q as QuerySelector, r as DecodedSortOption, I as InsertOptions, t as TValue, u as FindOneOptions, v as TUpdateOp, w as FieldSelectorExpression, x as QueryExpression, y as TStorage, z as TransactionOptions, h as TObject, A as TQueryRandomOptions, B as TPubSub } from '../../internals/index-DW9_3n_K.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-DZS2c96L.js');
13
13
  require('@o2ter/crypto-js');
14
- var random$1 = require('../../internals/random-CiJ8I0Cd.js');
14
+ var random$1 = require('../../internals/random-XGNkddOu.js');
15
15
  var _private = require('../../internals/private-CSB1Ep4g.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-DTZ5uRgF.mjs';
9
9
  import '@o2ter/crypto-js';
10
- import { _ as _resolveColumn, g as generateId, Q as QueryValidator } from '../../internals/random-Dn9rhwfh.mjs';
10
+ import { _ as _resolveColumn, g as generateId, Q as QueryValidator } from '../../internals/random-BjV_01xP.mjs';
11
11
  import { P as PVK } from '../../internals/private-BUpLAMZi.mjs';
12
12
 
13
13
  //
package/dist/client.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { P as ProtoClient } from './internals/index-BtnEuEVn.js';
2
- export { c as classExtends, e as isFile, a as isObject, i as isQuery, d as isRole, b as isUser } from './internals/index-BtnEuEVn.js';
1
+ import { P as ProtoClient } from './internals/index-DWyLziGT.js';
2
+ export { c as classExtends, e as isFile, a as isObject, i as isQuery, d as isRole, b as isUser } from './internals/index-DWyLziGT.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-BabXTvEZ.js';
4
+ export { D as DeserializeOptions, S as SerializeOptions, d as TSerializable, e as deserialize, s as serialize } from './internals/index-DW9_3n_K.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
@@ -2,11 +2,11 @@ import * as socket_io from 'socket.io';
2
2
  import * as socket_io_dist_typed_events from 'socket.io/dist/typed-events';
3
3
  import * as express_serve_static_core from 'express-serve-static-core';
4
4
  import { Server, RequestHandler } from '@o2ter/server-js';
5
- import { T as TSchema, _ as _TValue, P as ProtoService, a as ProtoServiceOptions, b as ProtoServiceKeyOptions } from './internals/index-BabXTvEZ.js';
6
- export { D as DeserializeOptions, S as SerializeOptions, c as TFileStorage, d as TSerializable, e as deserialize, s as serialize } from './internals/index-BabXTvEZ.js';
5
+ import { T as TSchema, _ as _TValue, P as ProtoService, a as ProtoServiceOptions, b as ProtoServiceKeyOptions } from './internals/index-DW9_3n_K.js';
6
+ export { D as DeserializeOptions, S as SerializeOptions, c as TFileStorage, d as TSerializable, e as deserialize, s as serialize } from './internals/index-DW9_3n_K.js';
7
7
  import Decimal from 'decimal.js';
8
8
  export { Decimal } from 'decimal.js';
9
- 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-BtnEuEVn.js';
9
+ 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-DWyLziGT.js';
10
10
  import '@o2ter/utils-js';
11
11
  import 'jsonwebtoken';
12
12
  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-CiJ8I0Cd.js');
7
+ var random = require('./internals/random-XGNkddOu.js');
8
8
  var _private = require('./internals/private-CSB1Ep4g.js');
9
9
  var utilsJs = require('@o2ter/utils-js');
10
10
  var index = require('./internals/index-D5nf79vF.js');
@@ -695,7 +695,7 @@ const validateShapedObject = (schema, dataType) => {
695
695
  }
696
696
  }
697
697
  };
698
- const validateSchemaPermission = (schema) => {
698
+ const validateSchemaName = (schema) => {
699
699
  if (!_.isNil(schema['_Schema']) || !_.isNil(schema['_Config']))
700
700
  throw Error('Reserved name of class');
701
701
  for (const [, _schema] of _.toPairs(schema)) {
@@ -703,15 +703,6 @@ const validateSchemaPermission = (schema) => {
703
703
  if (_.includes(index$1.TObject.defaultKeys, key))
704
704
  throw Error(`Reserved field name: ${key}`);
705
705
  }
706
- const fields = _.keys(_schema.fields);
707
- for (const key of _.keys(_schema.fieldLevelPermissions)) {
708
- if (!fields.includes(key))
709
- throw Error(`Invalid field permission: ${key}`);
710
- }
711
- for (const key of _schema.secureFields ?? []) {
712
- if (!fields.includes(key))
713
- throw Error(`Invalid field permission: ${key}`);
714
- }
715
706
  }
716
707
  };
717
708
  const validateSchema = (schema) => {
@@ -733,6 +724,15 @@ const validateSchema = (schema) => {
733
724
  throw Error(`Invalid target: ${key}`);
734
725
  validateForeignField(schema, key, dataType);
735
726
  }
727
+ const fields = _.keys(_schema.fields);
728
+ for (const key of _.keys(_schema.fieldLevelPermissions)) {
729
+ if (!fields.includes(key))
730
+ throw Error(`Invalid field permission: ${key}`);
731
+ }
732
+ for (const key of _schema.secureFields ?? []) {
733
+ if (!fields.includes(key))
734
+ throw Error(`Invalid field permission: ${key}`);
735
+ }
736
736
  }
737
737
  }
738
738
  };
@@ -744,8 +744,9 @@ const mergeSchema = (...schemas) => _.reduce(schemas, (acc, schema) => ({
744
744
  ...(acc[className]?.fields ?? {}),
745
745
  ...s.fields,
746
746
  },
747
- classLevelPermissions: _.mergeWith(acc[className]?.classLevelPermissions, s.classLevelPermissions, (l, r) => _.isArray(l) ? [...l, ...r] : undefined),
748
- fieldLevelPermissions: _.mergeWith(acc[className]?.fieldLevelPermissions, s.fieldLevelPermissions, (l, r) => _.isArray(l) ? [...l, ...r] : undefined),
747
+ classLevelPermissions: _.mergeWith(acc[className]?.classLevelPermissions ?? {}, s.classLevelPermissions, (l, r) => _.isArray(l) ? [...l, ...r] : undefined),
748
+ additionalObjectPermissions: _.mergeWith(acc[className]?.additionalObjectPermissions ?? {}, s.additionalObjectPermissions, (l, r) => _.isArray(l) ? [...l, ...r] : undefined),
749
+ fieldLevelPermissions: _.mergeWith(acc[className]?.fieldLevelPermissions ?? {}, s.fieldLevelPermissions, (l, r) => _.isArray(l) ? [...l, ...r] : undefined),
749
750
  secureFields: [
750
751
  ...(acc[className]?.secureFields ?? []),
751
752
  ...(s.secureFields ?? []),
@@ -765,7 +766,7 @@ class ProtoInternal {
765
766
  functions = {};
766
767
  triggers = {};
767
768
  constructor(options) {
768
- validateSchemaPermission(options.schema);
769
+ validateSchemaName(options.schema);
769
770
  const schema = mergeSchema(defaultSchema, options.fileStorage.schema, options.schema);
770
771
  validateSchema(schema);
771
772
  this.options = {