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.
- 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/client.d.ts +3 -3
- package/dist/client.js +1 -1
- package/dist/client.mjs +2 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -3
- package/dist/index.mjs.map +1 -1
- package/dist/internals/{index-BnDahEvz.js → index-BEK58Z0z.js} +3 -3
- package/dist/internals/index-BEK58Z0z.js.map +1 -0
- package/dist/internals/{index-CmJh3t_k.mjs → index-CQdNVgOu.mjs} +3 -3
- package/dist/internals/index-CQdNVgOu.mjs.map +1 -0
- package/dist/internals/{index-Z57iS68O.d.ts → index-CT5PbMDJ.d.ts} +2 -2
- package/dist/internals/index-CT5PbMDJ.d.ts.map +1 -0
- package/dist/internals/{index-C1pF5Xzm.d.ts → index-CWGYv9An.d.ts} +2 -2
- package/dist/internals/index-CWGYv9An.d.ts.map +1 -0
- package/dist/internals/{index-YJ0pBNzy.d.ts → index-CvKCWBvj.d.ts} +10 -6
- package/dist/internals/index-CvKCWBvj.d.ts.map +1 -0
- package/package.json +1 -1
- package/dist/internals/index-BnDahEvz.js.map +0 -1
- package/dist/internals/index-C1pF5Xzm.d.ts.map +0 -1
- package/dist/internals/index-CmJh3t_k.mjs.map +0 -1
- package/dist/internals/index-YJ0pBNzy.d.ts.map +0 -1
- package/dist/internals/index-Z57iS68O.d.ts.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -3,8 +3,8 @@ import { Server } from '@o2ter/server-js';
|
|
|
3
3
|
import { Q as QueryValidator, r as resolveColumn, a as resolveDataType, g as generateId } from './internals/random-BtYyzHJD.mjs';
|
|
4
4
|
import { P as PVK } from './internals/private-CNw40LZ7.mjs';
|
|
5
5
|
import { asyncStream, prototypes, isBinaryData, base64ToBuffer } from '@o2ter/utils-js';
|
|
6
|
-
import { T as TQuery, P as PROTO_NOTY_MSG, M as MASTER_USER_HEADER_NAME, a as MASTER_PASS_HEADER_NAME, A as AUTH_COOKIE_KEY, b as TUser, c as ProtoType, s as serialize, d as deserialize, U as UPLOAD_TOKEN_HEADER_NAME } from './internals/index-
|
|
7
|
-
export { e as ProtoClient, f as classExtends, k as isFile, g as isObject, i as isQuery, j as isRole, h as isUser } from './internals/index-
|
|
6
|
+
import { T as TQuery, P as PROTO_NOTY_MSG, M as MASTER_USER_HEADER_NAME, a as MASTER_PASS_HEADER_NAME, A as AUTH_COOKIE_KEY, b as TUser, c as ProtoType, s as serialize, d as deserialize, U as UPLOAD_TOKEN_HEADER_NAME } from './internals/index-CQdNVgOu.mjs';
|
|
7
|
+
export { e as ProtoClient, f as classExtends, k as isFile, g as isObject, i as isQuery, j as isRole, h as isUser } from './internals/index-CQdNVgOu.mjs';
|
|
8
8
|
import { i as isPointer, a as isRelation, T as TObject, b as isShape, d as defaultObjectKeyTypes, c as isPrimitive } from './internals/index-DyjcBbS1.mjs';
|
|
9
9
|
import jwt from 'jsonwebtoken';
|
|
10
10
|
import { Blob } from 'node:buffer';
|
|
@@ -734,6 +734,8 @@ const validateForeignField = (schema, key, dataType) => {
|
|
|
734
734
|
throw Error(`Invalid foreign field: ${key}`);
|
|
735
735
|
};
|
|
736
736
|
const validateShapedObject = (schema, dataType) => {
|
|
737
|
+
if (_.isEmpty(dataType.shape))
|
|
738
|
+
throw Error('Invalid empty shape');
|
|
737
739
|
for (const [key, type] of _.entries(dataType.shape)) {
|
|
738
740
|
if (!key.match(QueryValidator.patterns.name))
|
|
739
741
|
throw Error(`Invalid field name: ${key}`);
|
|
@@ -1308,7 +1310,8 @@ const fetchSessionInfo = async (proto, userId) => {
|
|
|
1308
1310
|
const cache = userCacheMap.get(proto[PVK]);
|
|
1309
1311
|
if (_.isNil(cache[userId]))
|
|
1310
1312
|
cache[userId] = (async () => {
|
|
1311
|
-
const
|
|
1313
|
+
const _user = _.isString(userId) ? await proto.Query('User').get(userId, { master: true }) : undefined;
|
|
1314
|
+
const user = proto.req ? await proto[PVK].options.userResolver(proto, _user) : _user;
|
|
1312
1315
|
const _roles = user instanceof TUser ? _.filter(await proto.userRoles(user), x => !_.isEmpty(x.name)) : [];
|
|
1313
1316
|
cache[userId] = undefined;
|
|
1314
1317
|
return { user, _roles };
|
|
@@ -1460,6 +1463,7 @@ class ProtoService extends ProtoType {
|
|
|
1460
1463
|
constructor(options) {
|
|
1461
1464
|
super();
|
|
1462
1465
|
this[PVK] = new ProtoInternal({
|
|
1466
|
+
userResolver: (_req, user) => user,
|
|
1463
1467
|
roleResolver: {},
|
|
1464
1468
|
objectIdSize: 10,
|
|
1465
1469
|
maxFetchLimit: 1000,
|