proto.io 0.0.183 → 0.0.184

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.
@@ -1,5 +1,5 @@
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';
1
+ import { T as TSchema, P as ProtoService } from '../../internals/index-CvKCWBvj.js';
2
+ import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/index-CWGYv9An.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-YJ0pBNzy.js';
2
- import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/index-C1pF5Xzm.js';
1
+ import { P as ProtoService } from '../../internals/index-CvKCWBvj.js';
2
+ import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/index-CWGYv9An.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-YJ0pBNzy.js';
4
- import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/index-C1pF5Xzm.js';
3
+ import { P as ProtoService } from '../../internals/index-CvKCWBvj.js';
4
+ import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/index-CWGYv9An.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-YJ0pBNzy.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-CvKCWBvj.js';
3
3
  import * as _o2ter_utils_js from '@o2ter/utils-js';
4
4
  import { asyncStream } from '@o2ter/utils-js';
5
5
  import 'jsonwebtoken';
package/dist/client.d.ts CHANGED
@@ -1,7 +1,7 @@
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';
1
+ import { P as ProtoClient } from './internals/index-CT5PbMDJ.js';
2
+ export { c as classExtends, e as isFile, a as isObject, i as isQuery, d as isRole, b as isUser } from './internals/index-CT5PbMDJ.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-YJ0pBNzy.js';
4
+ export { D as DeserializeOptions, S as SerializeOptions, d as TSerializable, e as deserialize, s as serialize } from './internals/index-CvKCWBvj.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-BnDahEvz.js');
5
+ var index = require('./internals/index-BEK58Z0z.js');
6
6
  var Decimal = require('decimal.js');
7
7
  require('./internals/index-DRq6T_5w.js');
8
8
  require('lodash');
package/dist/client.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { e as ProtoClient } from './internals/index-CmJh3t_k.mjs';
2
- export { f as classExtends, d as deserialize, k as isFile, g as isObject, i as isQuery, j as isRole, h as isUser, s as serialize } from './internals/index-CmJh3t_k.mjs';
1
+ import { e as ProtoClient } from './internals/index-CQdNVgOu.mjs';
2
+ export { f as classExtends, d as deserialize, k as isFile, g as isObject, i as isQuery, j as isRole, h as isUser, s as serialize } from './internals/index-CQdNVgOu.mjs';
3
3
  export { Decimal } from 'decimal.js';
4
4
  import './internals/index-DyjcBbS1.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-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';
4
+ import { T as TSchema, _ as _TValue, P as ProtoService, a as ProtoServiceOptions, b as ProtoServiceKeyOptions } from './internals/index-CvKCWBvj.js';
5
+ export { D as DeserializeOptions, S as SerializeOptions, c as TFileStorage, d as TSerializable, e as deserialize, s as serialize } from './internals/index-CvKCWBvj.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-Z57iS68O.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-CT5PbMDJ.js';
9
9
  import '@o2ter/utils-js';
10
10
  import 'jsonwebtoken';
11
11
  import 'lodash';
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ var serverJs = require('@o2ter/server-js');
7
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
- var index = require('./internals/index-BnDahEvz.js');
10
+ var index = require('./internals/index-BEK58Z0z.js');
11
11
  var index$1 = require('./internals/index-DRq6T_5w.js');
12
12
  var jwt = require('jsonwebtoken');
13
13
  var node_buffer = require('node:buffer');
@@ -737,6 +737,8 @@ const validateForeignField = (schema, key, dataType) => {
737
737
  throw Error(`Invalid foreign field: ${key}`);
738
738
  };
739
739
  const validateShapedObject = (schema, dataType) => {
740
+ if (_.isEmpty(dataType.shape))
741
+ throw Error('Invalid empty shape');
740
742
  for (const [key, type] of _.entries(dataType.shape)) {
741
743
  if (!key.match(random.QueryValidator.patterns.name))
742
744
  throw Error(`Invalid field name: ${key}`);
@@ -1311,7 +1313,8 @@ const fetchSessionInfo = async (proto, userId) => {
1311
1313
  const cache = userCacheMap.get(proto[_private.PVK]);
1312
1314
  if (_.isNil(cache[userId]))
1313
1315
  cache[userId] = (async () => {
1314
- const user = _.isString(userId) ? await proto.Query('User').get(userId, { master: true }) : undefined;
1316
+ const _user = _.isString(userId) ? await proto.Query('User').get(userId, { master: true }) : undefined;
1317
+ const user = proto.req ? await proto[_private.PVK].options.userResolver(proto, _user) : _user;
1315
1318
  const _roles = user instanceof index.TUser ? _.filter(await proto.userRoles(user), x => !_.isEmpty(x.name)) : [];
1316
1319
  cache[userId] = undefined;
1317
1320
  return { user, _roles };
@@ -1463,6 +1466,7 @@ class ProtoService extends index.ProtoType {
1463
1466
  constructor(options) {
1464
1467
  super();
1465
1468
  this[_private.PVK] = new ProtoInternal({
1469
+ userResolver: (_req, user) => user,
1466
1470
  roleResolver: {},
1467
1471
  objectIdSize: 10,
1468
1472
  maxFetchLimit: 1000,