proto.io 0.0.183 → 0.0.185
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 +5 -4
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +5 -5
- package/dist/index.d.ts +3 -3
- package/dist/index.js +8 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -29
- package/dist/index.mjs.map +1 -1
- package/dist/internals/{index-Z57iS68O.d.ts → index-C_l4FtV7.d.ts} +4 -3
- package/dist/internals/index-C_l4FtV7.d.ts.map +1 -0
- package/dist/internals/{index-BnDahEvz.js → index-DCWodSKL.js} +93 -83
- package/dist/internals/index-DCWodSKL.js.map +1 -0
- package/dist/internals/{index-C1pF5Xzm.d.ts → index-DS0eZOpV.d.ts} +2 -2
- package/dist/internals/index-DS0eZOpV.d.ts.map +1 -0
- package/dist/internals/{index-CmJh3t_k.mjs → index-DdXXYN4Z.mjs} +93 -84
- package/dist/internals/index-DdXXYN4Z.mjs.map +1 -0
- package/dist/internals/{index-YJ0pBNzy.d.ts → index-DoU5ipi_.d.ts} +17 -7
- package/dist/internals/index-DoU5ipi_.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-DdXXYN4Z.mjs';
|
|
7
|
+
export { e as ProtoClient, f as classExtends, k as isFile, l as isJob, g as isObject, i as isQuery, j as isRole, h as isUser } from './internals/index-DdXXYN4Z.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';
|
|
@@ -252,32 +252,6 @@ const dispatcher = (proto, options) => {
|
|
|
252
252
|
};
|
|
253
253
|
};
|
|
254
254
|
|
|
255
|
-
//
|
|
256
|
-
// options.ts
|
|
257
|
-
//
|
|
258
|
-
// The MIT License
|
|
259
|
-
// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
|
|
260
|
-
//
|
|
261
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
262
|
-
// of this software and associated documentation files (the "Software"), to deal
|
|
263
|
-
// in the Software without restriction, including without limitation the rights
|
|
264
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
265
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
266
|
-
// furnished to do so, subject to the following conditions:
|
|
267
|
-
//
|
|
268
|
-
// The above copyright notice and this permission notice shall be included in
|
|
269
|
-
// all copies or substantial portions of the Software.
|
|
270
|
-
//
|
|
271
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
272
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
273
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
274
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
275
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
276
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
277
|
-
// THE SOFTWARE.
|
|
278
|
-
//
|
|
279
|
-
const _serviceOf = (options) => options?.session instanceof ProtoService ? options?.session : undefined;
|
|
280
|
-
|
|
281
255
|
//
|
|
282
256
|
// methods.ts
|
|
283
257
|
//
|
|
@@ -734,6 +708,8 @@ const validateForeignField = (schema, key, dataType) => {
|
|
|
734
708
|
throw Error(`Invalid foreign field: ${key}`);
|
|
735
709
|
};
|
|
736
710
|
const validateShapedObject = (schema, dataType) => {
|
|
711
|
+
if (_.isEmpty(dataType.shape))
|
|
712
|
+
throw Error('Invalid empty shape');
|
|
737
713
|
for (const [key, type] of _.entries(dataType.shape)) {
|
|
738
714
|
if (!key.match(QueryValidator.patterns.name))
|
|
739
715
|
throw Error(`Invalid field name: ${key}`);
|
|
@@ -1308,7 +1284,8 @@ const fetchSessionInfo = async (proto, userId) => {
|
|
|
1308
1284
|
const cache = userCacheMap.get(proto[PVK]);
|
|
1309
1285
|
if (_.isNil(cache[userId]))
|
|
1310
1286
|
cache[userId] = (async () => {
|
|
1311
|
-
const
|
|
1287
|
+
const _user = _.isString(userId) ? await proto.Query('User').get(userId, { master: true }) : undefined;
|
|
1288
|
+
const user = proto.req ? await proto[PVK].options.userResolver(proto, _user) : _user;
|
|
1312
1289
|
const _roles = user instanceof TUser ? _.filter(await proto.userRoles(user), x => !_.isEmpty(x.name)) : [];
|
|
1313
1290
|
cache[userId] = undefined;
|
|
1314
1291
|
return { user, _roles };
|
|
@@ -1450,6 +1427,7 @@ const schedule = (proto) => {
|
|
|
1450
1427
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
1451
1428
|
// THE SOFTWARE.
|
|
1452
1429
|
//
|
|
1430
|
+
const _serviceOf = (options) => options?.session instanceof ProtoService ? options?.session : undefined;
|
|
1453
1431
|
class ProtoService extends ProtoType {
|
|
1454
1432
|
/** @internal */
|
|
1455
1433
|
[PVK];
|
|
@@ -1460,6 +1438,7 @@ class ProtoService extends ProtoType {
|
|
|
1460
1438
|
constructor(options) {
|
|
1461
1439
|
super();
|
|
1462
1440
|
this[PVK] = new ProtoInternal({
|
|
1441
|
+
userResolver: (_req, user) => user,
|
|
1463
1442
|
roleResolver: {},
|
|
1464
1443
|
objectIdSize: 10,
|
|
1465
1444
|
maxFetchLimit: 1000,
|