proto.io 0.0.216 → 0.0.218
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/aliyun-oss.d.ts +3 -3
- package/dist/adapters/file/database.d.ts +2 -2
- package/dist/adapters/file/database.js +2 -2
- package/dist/adapters/file/database.mjs +2 -2
- package/dist/adapters/file/filesystem.d.ts +3 -3
- package/dist/adapters/file/google-cloud-storage.d.ts +3 -3
- package/dist/adapters/storage/progres.d.ts +5 -3
- package/dist/adapters/storage/progres.js +511 -148
- package/dist/adapters/storage/progres.js.map +1 -1
- package/dist/adapters/storage/progres.mjs +511 -148
- package/dist/adapters/storage/progres.mjs.map +1 -1
- package/dist/client.d.ts +3 -3
- package/dist/client.js +2 -8
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +3 -3
- package/dist/client.mjs.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +28 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -29
- package/dist/index.mjs.map +1 -1
- package/dist/internals/{base-BO3ZP6EF.d.ts → base-CqeIQTE9.d.ts} +2 -2
- package/dist/internals/base-CqeIQTE9.d.ts.map +1 -0
- package/dist/internals/{chunk-DDkLpKXp.d.ts → chunk-CLKTwfRe.d.ts} +3 -3
- package/dist/internals/chunk-CLKTwfRe.d.ts.map +1 -0
- package/dist/internals/{index-B8TESzd9.js → index-CLKTEIj0.js} +2 -2
- package/dist/internals/index-CLKTEIj0.js.map +1 -0
- package/dist/internals/{index-DF2AfSGK.mjs → index-CZ5fKgiJ.mjs} +159 -166
- package/dist/internals/index-CZ5fKgiJ.mjs.map +1 -0
- package/dist/internals/{index-CYhA8SU8.d.ts → index-Ci8d33k-.d.ts} +3 -9
- package/dist/internals/index-Ci8d33k-.d.ts.map +1 -0
- package/dist/internals/{index-HdMgLYtD.d.ts → index-DQHWdslW.d.ts} +59 -22
- package/dist/internals/index-DQHWdslW.d.ts.map +1 -0
- package/dist/internals/{index-BzDsTt4R.mjs → index-gWcE22mf.mjs} +2 -2
- package/dist/internals/index-gWcE22mf.mjs.map +1 -0
- package/dist/internals/{index-DfnPpl1I.js → index-xHeu-AjT.js} +158 -171
- package/dist/internals/index-xHeu-AjT.js.map +1 -0
- package/dist/internals/{validator-BBjOdLiT.js → validator-B5yHpyvb.js} +743 -36
- package/dist/internals/validator-B5yHpyvb.js.map +1 -0
- package/dist/internals/{validator-LNgZGT_l.mjs → validator-DX2nXeQo.mjs} +736 -35
- package/dist/internals/validator-DX2nXeQo.mjs.map +1 -0
- package/package.json +2 -2
- package/dist/internals/base-BO3ZP6EF.d.ts.map +0 -1
- package/dist/internals/chunk-DDkLpKXp.d.ts.map +0 -1
- package/dist/internals/index-B8TESzd9.js.map +0 -1
- package/dist/internals/index-BzDsTt4R.mjs.map +0 -1
- package/dist/internals/index-CYhA8SU8.d.ts.map +0 -1
- package/dist/internals/index-DF2AfSGK.mjs.map +0 -1
- package/dist/internals/index-DfnPpl1I.js.map +0 -1
- package/dist/internals/index-HdMgLYtD.d.ts.map +0 -1
- package/dist/internals/validator-BBjOdLiT.js.map +0 -1
- package/dist/internals/validator-LNgZGT_l.mjs.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
|
|
1
|
+
import { P as ProtoClient } from './internals/index-Ci8d33k-.js';
|
|
2
|
+
export { c as classExtends } from './internals/index-Ci8d33k-.js';
|
|
3
|
+
export { D as DeserializeOptions, S as SerializeOptions, e as TNumber, f as TSerializable, g as deserialize, s as serialize } from './internals/index-DQHWdslW.js';
|
|
3
4
|
export { Decimal } from 'decimal.js';
|
|
4
|
-
export { D as DeserializeOptions, S as SerializeOptions, e as TNumber, f as TSerializable, g as deserialize, s as serialize } from './internals/index-HdMgLYtD.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,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var index = require('./internals/index-
|
|
5
|
+
var index = require('./internals/index-xHeu-AjT.js');
|
|
6
6
|
var Decimal = require('decimal.js');
|
|
7
7
|
require('@o2ter/utils-js');
|
|
8
8
|
require('./internals/private-Ciddhure.js');
|
|
9
9
|
require('lodash');
|
|
10
|
-
require('./internals/index-
|
|
10
|
+
require('./internals/index-CLKTEIj0.js');
|
|
11
11
|
require('axios');
|
|
12
12
|
require('./internals/const-C3I6cfav.js');
|
|
13
13
|
require('@o2ter/server-js/dist/const');
|
|
@@ -43,12 +43,6 @@ exports.ProtoClient = index.ProtoClient;
|
|
|
43
43
|
exports.classExtends = index.classExtends;
|
|
44
44
|
exports.default = index.ProtoClient;
|
|
45
45
|
exports.deserialize = index.deserialize;
|
|
46
|
-
exports.isFile = index.isFile;
|
|
47
|
-
exports.isJob = index.isJob;
|
|
48
|
-
exports.isObject = index.isObject;
|
|
49
|
-
exports.isQuery = index.isQuery;
|
|
50
|
-
exports.isRole = index.isRole;
|
|
51
|
-
exports.isUser = index.isUser;
|
|
52
46
|
exports.serialize = index.serialize;
|
|
53
47
|
Object.defineProperty(exports, "Decimal", {
|
|
54
48
|
enumerable: true,
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sources":["../../src/client/index.ts"],"sourcesContent":["//\n// index.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport { ProtoClient } from './proto';\n\nexport * from '../
|
|
1
|
+
{"version":3,"file":"client.js","sources":["../../src/client/index.ts"],"sourcesContent":["//\n// index.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport { ProtoClient } from './proto';\n\nexport * from '../internals/codec';\nexport { classExtends } from '../internals/utils';\n\nexport { ProtoClient };\n\nexport default ProtoClient;"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;"}
|
package/dist/client.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { b as ProtoClient } from './internals/index-
|
|
2
|
-
export { c as classExtends, d as deserialize,
|
|
1
|
+
import { b as ProtoClient } from './internals/index-CZ5fKgiJ.mjs';
|
|
2
|
+
export { c as classExtends, d as deserialize, s as serialize } from './internals/index-CZ5fKgiJ.mjs';
|
|
3
3
|
export { Decimal } from 'decimal.js';
|
|
4
4
|
import '@o2ter/utils-js';
|
|
5
5
|
import './internals/private-CNw40LZ7.mjs';
|
|
6
6
|
import 'lodash';
|
|
7
|
-
import './internals/index-
|
|
7
|
+
import './internals/index-gWcE22mf.mjs';
|
|
8
8
|
import 'axios';
|
|
9
9
|
import './internals/const-Dkp7Nsv5.mjs';
|
|
10
10
|
import '@o2ter/server-js/dist/const';
|
package/dist/client.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.mjs","sources":["../../src/client/index.ts"],"sourcesContent":["//\n// index.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport { ProtoClient } from './proto';\n\nexport * from '../
|
|
1
|
+
{"version":3,"file":"client.mjs","sources":["../../src/client/index.ts"],"sourcesContent":["//\n// index.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport { ProtoClient } from './proto';\n\nexport * from '../internals/codec';\nexport { classExtends } from '../internals/utils';\n\nexport { ProtoClient };\n\nexport default ProtoClient;"],"names":[],"mappings":";;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;"}
|
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, a as TValueWithoutObject, P as ProtoService, b as ProtoServiceOptions, c as ProtoServiceKeyOptions } from './internals/index-
|
|
5
|
-
export { D as DeserializeOptions, S as SerializeOptions, d as TFileStorage, e as TNumber, f as TSerializable, g as deserialize, s as serialize } from './internals/index-
|
|
4
|
+
import { T as TSchema, a as TValueWithoutObject, P as ProtoService, b as ProtoServiceOptions, c as ProtoServiceKeyOptions } from './internals/index-DQHWdslW.js';
|
|
5
|
+
export { D as DeserializeOptions, S as SerializeOptions, d as TFileStorage, e as TNumber, f as TSerializable, g as deserialize, s as serialize } from './internals/index-DQHWdslW.js';
|
|
6
6
|
import Decimal from 'decimal.js';
|
|
7
7
|
export { Decimal } from 'decimal.js';
|
|
8
|
-
export { P as ProtoClient, c as classExtends
|
|
8
|
+
export { P as ProtoClient, c as classExtends } from './internals/index-Ci8d33k-.js';
|
|
9
9
|
import '@o2ter/utils-js';
|
|
10
10
|
import 'jsonwebtoken';
|
|
11
11
|
import 'lodash';
|
package/dist/index.js
CHANGED
|
@@ -4,11 +4,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var _ = require('lodash');
|
|
6
6
|
var serverJs = require('@o2ter/server-js');
|
|
7
|
-
var validator = require('./internals/validator-
|
|
7
|
+
var validator = require('./internals/validator-B5yHpyvb.js');
|
|
8
8
|
var _private = require('./internals/private-Ciddhure.js');
|
|
9
9
|
var utilsJs = require('@o2ter/utils-js');
|
|
10
|
-
var index = require('./internals/index-
|
|
11
|
-
var index$1 = require('./internals/index-
|
|
10
|
+
var index = require('./internals/index-xHeu-AjT.js');
|
|
11
|
+
var index$1 = require('./internals/index-CLKTEIj0.js');
|
|
12
12
|
var jwt = require('jsonwebtoken');
|
|
13
13
|
var node_buffer = require('node:buffer');
|
|
14
14
|
var node_stream = require('node:stream');
|
|
@@ -17,9 +17,9 @@ var node_crypto = require('node:crypto');
|
|
|
17
17
|
var util = require('util');
|
|
18
18
|
var cryptoJs = require('@o2ter/crypto-js');
|
|
19
19
|
var _const = require('./internals/const-C3I6cfav.js');
|
|
20
|
-
var Decimal = require('decimal.js');
|
|
21
20
|
var queryType = require('query-types');
|
|
22
21
|
var busboy = require('busboy');
|
|
22
|
+
var Decimal = require('decimal.js');
|
|
23
23
|
require('axios');
|
|
24
24
|
require('@o2ter/server-js/dist/const');
|
|
25
25
|
require('socket.io-client');
|
|
@@ -82,7 +82,7 @@ const normalize = (x) => {
|
|
|
82
82
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
83
83
|
// THE SOFTWARE.
|
|
84
84
|
//
|
|
85
|
-
const fetchUserPerms = async (proto) => _.uniq(_.compact([..._.map(await proto.currentRoles(), x => `role:${x}`), (await proto.currentUser())?.
|
|
85
|
+
const fetchUserPerms = async (proto) => _.uniq(_.compact([..._.map(await proto.currentRoles(), x => `role:${x}`), (await proto.currentUser())?.id]));
|
|
86
86
|
const dispatcher = (proto, options) => {
|
|
87
87
|
const acls = async () => options.master ? [] : await fetchUserPerms(proto);
|
|
88
88
|
const validator$1 = async () => new validator.QueryValidator(proto, await acls(), {
|
|
@@ -852,34 +852,34 @@ class ProtoInternal {
|
|
|
852
852
|
return callback(proxy(payload ?? proto));
|
|
853
853
|
}
|
|
854
854
|
async varifyPassword(proto, user, password, options) {
|
|
855
|
-
if (!user.
|
|
855
|
+
if (!user.id)
|
|
856
856
|
throw Error('Invalid user object');
|
|
857
857
|
const _user = await proto.InsecureQuery('User')
|
|
858
|
-
.equalTo('_id', user.
|
|
858
|
+
.equalTo('_id', user.id)
|
|
859
859
|
.includes('_id', 'password')
|
|
860
860
|
.first(options);
|
|
861
861
|
const { alg, ...opts } = _user?.get('password') ?? {};
|
|
862
862
|
return varifyPassword(alg, password, opts);
|
|
863
863
|
}
|
|
864
864
|
async setPassword(proto, user, password, options) {
|
|
865
|
-
if (!user.
|
|
865
|
+
if (!user.id)
|
|
866
866
|
throw Error('Invalid user object');
|
|
867
867
|
if (_.isEmpty(password))
|
|
868
868
|
throw Error('Invalid password');
|
|
869
869
|
const { alg, ...opts } = this.options.passwordHashOptions;
|
|
870
870
|
const hashed = await passwordHash(alg, password, opts);
|
|
871
871
|
await proto.InsecureQuery('User')
|
|
872
|
-
.equalTo('_id', user.
|
|
872
|
+
.equalTo('_id', user.id)
|
|
873
873
|
.includes('_id')
|
|
874
874
|
.updateOne({
|
|
875
875
|
password: { $set: hashed },
|
|
876
876
|
}, options);
|
|
877
877
|
}
|
|
878
878
|
async unsetPassword(proto, user, options) {
|
|
879
|
-
if (!user.
|
|
879
|
+
if (!user.id)
|
|
880
880
|
throw Error('Invalid user object');
|
|
881
881
|
await proto.InsecureQuery('User')
|
|
882
|
-
.equalTo('_id', user.
|
|
882
|
+
.equalTo('_id', user.id)
|
|
883
883
|
.includes('_id')
|
|
884
884
|
.updateOne({
|
|
885
885
|
password: { $set: {} },
|
|
@@ -890,7 +890,7 @@ class ProtoInternal {
|
|
|
890
890
|
throw Error('Invalid filename');
|
|
891
891
|
}
|
|
892
892
|
const updated = await proto.Query(object.className)
|
|
893
|
-
.equalTo('_id', object.
|
|
893
|
+
.equalTo('_id', object.id)
|
|
894
894
|
.includes(...object.keys())
|
|
895
895
|
.updateOne(object[_private.PVK].mutated, options);
|
|
896
896
|
if (updated) {
|
|
@@ -970,7 +970,7 @@ class ProtoInternal {
|
|
|
970
970
|
}
|
|
971
971
|
}
|
|
972
972
|
async saveFile(proto, object, options) {
|
|
973
|
-
if (object.
|
|
973
|
+
if (object.id) {
|
|
974
974
|
object = await this.updateFile(proto, object, options);
|
|
975
975
|
}
|
|
976
976
|
else {
|
|
@@ -981,7 +981,7 @@ class ProtoInternal {
|
|
|
981
981
|
async deleteFile(proto, object, options) {
|
|
982
982
|
object = await object.fetchIfNeeded(['token'], options);
|
|
983
983
|
const deleted = await proto.Query('File')
|
|
984
|
-
.equalTo('_id', object.
|
|
984
|
+
.equalTo('_id', object.id)
|
|
985
985
|
.deleteOne(options);
|
|
986
986
|
if (deleted) {
|
|
987
987
|
object[_private.PVK].attributes = deleted.attributes;
|
|
@@ -1390,11 +1390,11 @@ const signUser = async (proto, res, user, options) => {
|
|
|
1390
1390
|
sessionId: session?.sessionId ?? cryptoJs.randomUUID(),
|
|
1391
1391
|
createdAt: session?.createdAt?.getTime() ?? Date.now(),
|
|
1392
1392
|
loginedAt: user ? session?.loginedAt?.getTime() ?? Date.now() : undefined,
|
|
1393
|
-
user: user?.
|
|
1393
|
+
user: user?.id,
|
|
1394
1394
|
cookieOptions,
|
|
1395
1395
|
}, options?.jwtSignOptions ?? 'login');
|
|
1396
1396
|
res.cookie(_const.AUTH_COOKIE_KEY, token, cookieOptions);
|
|
1397
|
-
sessionInfoMap.set(res.req, user ? await fetchSessionInfo(proto, user.
|
|
1397
|
+
sessionInfoMap.set(res.req, user ? await fetchSessionInfo(proto, user.id) : {});
|
|
1398
1398
|
};
|
|
1399
1399
|
|
|
1400
1400
|
//
|
|
@@ -1542,13 +1542,13 @@ class ProtoService extends index.ProtoType {
|
|
|
1542
1542
|
return new ProtoQuery(className, this, {});
|
|
1543
1543
|
}
|
|
1544
1544
|
Relation(object, key) {
|
|
1545
|
-
const
|
|
1546
|
-
if (!
|
|
1545
|
+
const id = object.id;
|
|
1546
|
+
if (!id)
|
|
1547
1547
|
throw Error('Invalid object');
|
|
1548
1548
|
return new ProtoRelationQuery(this, {
|
|
1549
1549
|
relatedBy: {
|
|
1550
1550
|
className: object.className,
|
|
1551
|
-
|
|
1551
|
+
id: id,
|
|
1552
1552
|
key,
|
|
1553
1553
|
},
|
|
1554
1554
|
});
|
|
@@ -1614,10 +1614,10 @@ class ProtoService extends index.ProtoType {
|
|
|
1614
1614
|
while (!_.isEmpty(queue)) {
|
|
1615
1615
|
queue = await self.Query('Role')
|
|
1616
1616
|
.or(_.map(_.uniq(['roles', ...roleKeys]), k => q => q.isIntersect(k, queue)))
|
|
1617
|
-
.notContainedIn('_id', _.compact(_.map(roles, x => x.
|
|
1617
|
+
.notContainedIn('_id', _.compact(_.map(roles, x => x.id)))
|
|
1618
1618
|
.includes('name')
|
|
1619
1619
|
.find({ master: true });
|
|
1620
|
-
roles = _.uniqBy([...roles, ...queue], x => x.
|
|
1620
|
+
roles = _.uniqBy([...roles, ...queue], x => x.id);
|
|
1621
1621
|
}
|
|
1622
1622
|
return roles;
|
|
1623
1623
|
};
|
|
@@ -1626,7 +1626,7 @@ class ProtoService extends index.ProtoType {
|
|
|
1626
1626
|
return defaultResolver();
|
|
1627
1627
|
}
|
|
1628
1628
|
async becomeUser(req, user, options) {
|
|
1629
|
-
if (!user.
|
|
1629
|
+
if (!user.id)
|
|
1630
1630
|
throw Error('Invalid user object');
|
|
1631
1631
|
if (req.res)
|
|
1632
1632
|
await signUser(this, req.res, user, options);
|
|
@@ -1728,7 +1728,7 @@ class ProtoService extends index.ProtoType {
|
|
|
1728
1728
|
});
|
|
1729
1729
|
}
|
|
1730
1730
|
refs(object, options) {
|
|
1731
|
-
if (!object.
|
|
1731
|
+
if (!object.id)
|
|
1732
1732
|
throw Error('Invalid object');
|
|
1733
1733
|
const self = this;
|
|
1734
1734
|
return utilsJs.asyncStream(async function* () {
|
|
@@ -1892,7 +1892,7 @@ const verifyRelatedBy = (relatedBy) => {
|
|
|
1892
1892
|
return;
|
|
1893
1893
|
if (!_.isString(relatedBy.className) || _.isEmpty(relatedBy.className))
|
|
1894
1894
|
throw Error('Invalid option');
|
|
1895
|
-
if (!_.isString(relatedBy.
|
|
1895
|
+
if (!_.isString(relatedBy.id) || _.isEmpty(relatedBy.id))
|
|
1896
1896
|
throw Error('Invalid option');
|
|
1897
1897
|
if (!_.isString(relatedBy.key) || _.isEmpty(relatedBy.key))
|
|
1898
1898
|
throw Error('Invalid option');
|
|
@@ -1903,7 +1903,7 @@ var classesRoute = (router, proto) => {
|
|
|
1903
1903
|
const { operation, random, attributes, update, setOnInsert, relatedBy, silent, ...options } = index.deserialize(req.body);
|
|
1904
1904
|
verifyRelatedBy(relatedBy);
|
|
1905
1905
|
const payload = proto.connect(req);
|
|
1906
|
-
const query = relatedBy ? payload.Relation(payload.Object(relatedBy.className, relatedBy.
|
|
1906
|
+
const query = relatedBy ? payload.Relation(payload.Object(relatedBy.className, relatedBy.id), relatedBy.key) : payload.Query(name);
|
|
1907
1907
|
query[_private.PVK].options = options;
|
|
1908
1908
|
const opts = { master: payload.isMaster, silent };
|
|
1909
1909
|
if (_.includes(['File', '_Job', '_JobScope'], name) &&
|
|
@@ -1966,7 +1966,7 @@ var classesRoute = (router, proto) => {
|
|
|
1966
1966
|
const { name } = req.params;
|
|
1967
1967
|
const { filter, sort, includes, skip, limit, relatedBy, } = req.query;
|
|
1968
1968
|
verifyRelatedBy(relatedBy);
|
|
1969
|
-
const query = relatedBy ? payload.Relation(payload.Object(relatedBy.className, relatedBy.
|
|
1969
|
+
const query = relatedBy ? payload.Relation(payload.Object(relatedBy.className, relatedBy.id), relatedBy.key) : payload.Query(name);
|
|
1970
1970
|
query[_private.PVK].options.filter = !_.isEmpty(filter) && _.isString(filter) ? _.castArray(index.deserialize(filter)) : [];
|
|
1971
1971
|
query[_private.PVK].options.sort = _.isPlainObject(sort) && _.every(_.values(sort), _.isNumber) ? sort : undefined;
|
|
1972
1972
|
query[_private.PVK].options.includes = _.isArray(includes) && _.every(includes, _.isString) ? includes : undefined;
|
|
@@ -2604,7 +2604,7 @@ const registerProtoSocket = (proto, server, endpoint) => {
|
|
|
2604
2604
|
const { remove: remove_livequery } = payload[_private.PVK]._liveQuery(payload, (ev, objs) => {
|
|
2605
2605
|
const ids = {};
|
|
2606
2606
|
for (const obj of objs) {
|
|
2607
|
-
ids[obj.
|
|
2607
|
+
ids[obj.id] = _.keys(_.pickBy(queries, v => {
|
|
2608
2608
|
if (v.event !== ev || v.className !== obj.className)
|
|
2609
2609
|
return false;
|
|
2610
2610
|
return v.filter instanceof validator.QuerySelector ? v.filter.eval(obj) : v.filter;
|
|
@@ -2612,7 +2612,7 @@ const registerProtoSocket = (proto, server, endpoint) => {
|
|
|
2612
2612
|
}
|
|
2613
2613
|
if (_.isEmpty(ids))
|
|
2614
2614
|
return;
|
|
2615
|
-
const payload = JSON.parse(index.serialize(_.filter(objs, obj => !_.isEmpty(ids[obj.
|
|
2615
|
+
const payload = JSON.parse(index.serialize(_.filter(objs, obj => !_.isEmpty(ids[obj.id]))));
|
|
2616
2616
|
socket.emit('ON_EV_LIVEQUERY', { ids, data: payload });
|
|
2617
2617
|
});
|
|
2618
2618
|
return () => {
|
|
@@ -2663,12 +2663,6 @@ const registerProtoSocket = (proto, server, endpoint) => {
|
|
|
2663
2663
|
exports.ProtoClient = index.ProtoClient;
|
|
2664
2664
|
exports.classExtends = index.classExtends;
|
|
2665
2665
|
exports.deserialize = index.deserialize;
|
|
2666
|
-
exports.isFile = index.isFile;
|
|
2667
|
-
exports.isJob = index.isJob;
|
|
2668
|
-
exports.isObject = index.isObject;
|
|
2669
|
-
exports.isQuery = index.isQuery;
|
|
2670
|
-
exports.isRole = index.isRole;
|
|
2671
|
-
exports.isUser = index.isUser;
|
|
2672
2666
|
exports.serialize = index.serialize;
|
|
2673
2667
|
Object.defineProperty(exports, "Decimal", {
|
|
2674
2668
|
enumerable: true,
|