proto.io 0.0.171 → 0.0.172
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.
- package/dist/adapters/file/database.d.ts +2 -2
- package/dist/adapters/file/filesystem.d.ts +2 -2
- package/dist/adapters/file/google-cloud-storage.d.ts +2 -2
- package/dist/adapters/storage/progres.d.ts +1 -1
- package/dist/adapters/storage/progres.js +11 -7
- package/dist/adapters/storage/progres.js.map +1 -1
- package/dist/adapters/storage/progres.mjs +11 -7
- package/dist/adapters/storage/progres.mjs.map +1 -1
- package/dist/client.d.ts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +31 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -24
- package/dist/index.mjs.map +1 -1
- package/dist/internals/{index-BB2vDnq0.d.ts → index-BhWRmBiq.d.ts} +6 -3
- package/dist/internals/index-BhWRmBiq.d.ts.map +1 -0
- package/dist/internals/{index-D_GYwO8X.d.ts → index-DchUjNEf.d.ts} +2 -2
- package/dist/internals/index-DchUjNEf.d.ts.map +1 -0
- package/dist/internals/{index-B5u7VXjz.d.ts → index-K0jhERvZ.d.ts} +2 -2
- package/dist/internals/index-K0jhERvZ.d.ts.map +1 -0
- package/package.json +1 -1
- package/dist/internals/index-B5u7VXjz.d.ts.map +0 -1
- package/dist/internals/index-BB2vDnq0.d.ts.map +0 -1
- package/dist/internals/index-D_GYwO8X.d.ts.map +0 -1
package/dist/client.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { P as ProtoClient } from './internals/index-
|
|
2
|
-
export { c as classExtends, e as isFile, a as isObject, i as isQuery, d as isRole, b as isUser } from './internals/index-
|
|
1
|
+
import { P as ProtoClient } from './internals/index-DchUjNEf.js';
|
|
2
|
+
export { c as classExtends, e as isFile, a as isObject, i as isQuery, d as isRole, b as isUser } from './internals/index-DchUjNEf.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-
|
|
4
|
+
export { D as DeserializeOptions, S as SerializeOptions, d as TSerializable, e as deserialize, s as serialize } from './internals/index-BhWRmBiq.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-
|
|
5
|
-
export { D as DeserializeOptions, S as SerializeOptions, c as TFileStorage, d as TSerializable, e as deserialize, s as serialize } from './internals/index-
|
|
4
|
+
import { T as TSchema, _ as _TValue, P as ProtoService, a as ProtoServiceOptions, b as ProtoServiceKeyOptions } from './internals/index-BhWRmBiq.js';
|
|
5
|
+
export { D as DeserializeOptions, S as SerializeOptions, c as TFileStorage, d as TSerializable, e as deserialize, s as serialize } from './internals/index-BhWRmBiq.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-
|
|
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-DchUjNEf.js';
|
|
9
9
|
import '@o2ter/utils-js';
|
|
10
10
|
import 'jsonwebtoken';
|
|
11
11
|
import 'lodash';
|
package/dist/index.js
CHANGED
|
@@ -851,7 +851,7 @@ class ProtoInternal {
|
|
|
851
851
|
validateSchemaName(options.schema);
|
|
852
852
|
const schema = mergeSchema(defaultSchema, options.fileStorage.schema, options.schema);
|
|
853
853
|
validateSchema(schema);
|
|
854
|
-
if (!_.every(options.
|
|
854
|
+
if (!_.every(options.roleResolver?.inheritKeys, k => {
|
|
855
855
|
const type = random.resolveDataType(schema, 'Role', k);
|
|
856
856
|
return type && index$1.isRelation(type) && _.includes(['User', 'Role'], type.target);
|
|
857
857
|
})) {
|
|
@@ -1357,7 +1357,7 @@ class ProtoService extends index.ProtoType {
|
|
|
1357
1357
|
constructor(options) {
|
|
1358
1358
|
super();
|
|
1359
1359
|
this[_private.PVK] = new ProtoInternal({
|
|
1360
|
-
|
|
1360
|
+
roleResolver: {},
|
|
1361
1361
|
objectIdSize: 10,
|
|
1362
1362
|
maxFetchLimit: 1000,
|
|
1363
1363
|
maxUploadSize: 20 * 1024 * 1024,
|
|
@@ -1444,30 +1444,37 @@ class ProtoService extends index.ProtoType {
|
|
|
1444
1444
|
return _.assign(payload, _.isFunction(attrs) ? attrs(payload) : attrs);
|
|
1445
1445
|
}
|
|
1446
1446
|
async userRoles(user) {
|
|
1447
|
-
const
|
|
1448
|
-
const
|
|
1449
|
-
|
|
1450
|
-
const
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
.
|
|
1460
|
-
|
|
1461
|
-
let roles = queue;
|
|
1462
|
-
while (!_.isEmpty(queue)) {
|
|
1463
|
-
queue = await this.Query('Role')
|
|
1464
|
-
.or(_.map(_.uniq(['roles', ...roleKeys]), k => q => q.isIntersect(k, queue)))
|
|
1465
|
-
.notContainsIn('_id', _.compact(_.map(roles, x => x.objectId)))
|
|
1447
|
+
const self = this;
|
|
1448
|
+
const defaultResolver = async () => {
|
|
1449
|
+
const inheritKeys = self[_private.PVK].options.roleResolver?.inheritKeys ?? [];
|
|
1450
|
+
const schema = self.schema;
|
|
1451
|
+
const userKeys = _.filter(inheritKeys, k => {
|
|
1452
|
+
const type = random.resolveDataType(schema, 'Role', k);
|
|
1453
|
+
return !!type && index$1.isRelation(type) && type.target === 'User';
|
|
1454
|
+
});
|
|
1455
|
+
const roleKeys = _.filter(inheritKeys, k => {
|
|
1456
|
+
const type = random.resolveDataType(schema, 'Role', k);
|
|
1457
|
+
return !!type && index$1.isRelation(type) && type.target === 'Role';
|
|
1458
|
+
});
|
|
1459
|
+
let queue = await self.Query('Role')
|
|
1460
|
+
.or(_.map(_.uniq(['users', ...userKeys]), k => q => q.isIntersect(k, [user])))
|
|
1466
1461
|
.includes('name')
|
|
1467
1462
|
.find({ master: true });
|
|
1468
|
-
roles =
|
|
1469
|
-
|
|
1470
|
-
|
|
1463
|
+
let roles = queue;
|
|
1464
|
+
while (!_.isEmpty(queue)) {
|
|
1465
|
+
queue = await self.Query('Role')
|
|
1466
|
+
.or(_.map(_.uniq(['roles', ...roleKeys]), k => q => q.isIntersect(k, queue)))
|
|
1467
|
+
.notContainsIn('_id', _.compact(_.map(roles, x => x.objectId)))
|
|
1468
|
+
.includes('name')
|
|
1469
|
+
.find({ master: true });
|
|
1470
|
+
roles = _.uniqBy([...roles, ...queue], x => x.objectId);
|
|
1471
|
+
}
|
|
1472
|
+
return roles;
|
|
1473
|
+
};
|
|
1474
|
+
const resolver = self[_private.PVK].options.roleResolver?.resolver;
|
|
1475
|
+
if (resolver)
|
|
1476
|
+
return resolver(user, defaultResolver);
|
|
1477
|
+
return defaultResolver();
|
|
1471
1478
|
}
|
|
1472
1479
|
async becomeUser(req, user, options) {
|
|
1473
1480
|
if (!user.objectId)
|