proto.io 0.0.205 → 0.0.207
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.js.map +1 -1
- package/dist/adapters/file/database.mjs +2 -2
- package/dist/adapters/file/database.mjs.map +1 -1
- 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 +9 -20
- package/dist/adapters/storage/progres.js +28 -109
- package/dist/adapters/storage/progres.js.map +1 -1
- package/dist/adapters/storage/progres.mjs +28 -109
- package/dist/adapters/storage/progres.mjs.map +1 -1
- package/dist/client.d.ts +3 -3
- package/dist/client.js +2 -1
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +3 -2
- package/dist/client.mjs.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +45 -109
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +46 -110
- package/dist/index.mjs.map +1 -1
- package/dist/internals/{base-Cf7WkDhO.d.ts → base-DHkvlTFy.d.ts} +2 -2
- package/dist/internals/base-DHkvlTFy.d.ts.map +1 -0
- package/dist/internals/{chunk-ONaLyXL0.d.ts → chunk-C7kDLOLD.d.ts} +3 -3
- package/dist/internals/chunk-C7kDLOLD.d.ts.map +1 -0
- package/dist/internals/{index-DByHjIHI.js → index-BRzKDwPs.js} +64 -22
- package/dist/internals/index-BRzKDwPs.js.map +1 -0
- package/dist/internals/{index-DI-jPA6f.d.ts → index-CKcESGqE.d.ts} +3 -3
- package/dist/internals/index-CKcESGqE.d.ts.map +1 -0
- package/dist/internals/{index-C4vwSN74.js → index-CkAvNaAe.js} +240 -1
- package/dist/internals/index-CkAvNaAe.js.map +1 -0
- package/dist/internals/{index-DtCgllhg.mjs → index-DAkcqabS.mjs} +64 -22
- package/dist/internals/index-DAkcqabS.mjs.map +1 -0
- package/dist/internals/{index-Blw7vAq5.mjs → index-DlY33lfO.mjs} +240 -1
- package/dist/internals/index-DlY33lfO.mjs.map +1 -0
- package/dist/internals/{index-JdEs5VLY.d.ts → index-PLz89AWF.d.ts} +23 -31
- package/dist/internals/index-PLz89AWF.d.ts.map +1 -0
- package/dist/internals/{random-Dk3OhDNU.js → random-B0V0EnjP.js} +2 -2
- package/dist/internals/random-B0V0EnjP.js.map +1 -0
- package/dist/internals/{random-6nHcBOxn.mjs → random-ZgzzM5v_.mjs} +2 -2
- package/dist/internals/random-ZgzzM5v_.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/internals/base-Cf7WkDhO.d.ts.map +0 -1
- package/dist/internals/chunk-ONaLyXL0.d.ts.map +0 -1
- package/dist/internals/index-Blw7vAq5.mjs.map +0 -1
- package/dist/internals/index-C4vwSN74.js.map +0 -1
- package/dist/internals/index-DByHjIHI.js.map +0 -1
- package/dist/internals/index-DI-jPA6f.d.ts.map +0 -1
- package/dist/internals/index-DtCgllhg.mjs.map +0 -1
- package/dist/internals/index-JdEs5VLY.d.ts.map +0 -1
- package/dist/internals/random-6nHcBOxn.mjs.map +0 -1
- package/dist/internals/random-Dk3OhDNU.js.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, f as isJob, a as isObject, i as isQuery, d as isRole, b as isUser } from './internals/index-
|
|
1
|
+
import { P as ProtoClient } from './internals/index-CKcESGqE.js';
|
|
2
|
+
export { c as classExtends, e as isFile, f as isJob, a as isObject, i as isQuery, d as isRole, b as isUser } from './internals/index-CKcESGqE.js';
|
|
3
3
|
export { Decimal } from 'decimal.js';
|
|
4
|
-
export { D as DeserializeOptions, S as SerializeOptions, e as
|
|
4
|
+
export { D as DeserializeOptions, S as SerializeOptions, e as TNumber, f as TSerializable, g as deserialize, s as serialize } from './internals/index-PLz89AWF.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-
|
|
5
|
+
var index = require('./internals/index-BRzKDwPs.js');
|
|
6
6
|
var Decimal = require('decimal.js');
|
|
7
7
|
require('@o2ter/utils-js');
|
|
8
8
|
require('./internals/private-Ciddhure.js');
|
|
@@ -11,6 +11,7 @@ require('./internals/index-B8TESzd9.js');
|
|
|
11
11
|
require('axios');
|
|
12
12
|
require('@o2ter/server-js/dist/const');
|
|
13
13
|
require('socket.io-client');
|
|
14
|
+
require('@o2ter/crypto-js');
|
|
14
15
|
|
|
15
16
|
//
|
|
16
17
|
// index.ts
|
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 '../common';\n\nexport { ProtoClient };\n\nexport default ProtoClient;"],"names":[],"mappings":"
|
|
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 '../common';\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,5 +1,5 @@
|
|
|
1
|
-
import { e as ProtoClient } from './internals/index-
|
|
2
|
-
export { f as classExtends, d as deserialize, k as isFile, l as isJob, g as isObject, i as isQuery, j as isRole, h as isUser, s as serialize } from './internals/index-
|
|
1
|
+
import { e as ProtoClient } from './internals/index-DAkcqabS.mjs';
|
|
2
|
+
export { f as classExtends, d as deserialize, k as isFile, l as isJob, g as isObject, i as isQuery, j as isRole, h as isUser, s as serialize } from './internals/index-DAkcqabS.mjs';
|
|
3
3
|
export { Decimal } from 'decimal.js';
|
|
4
4
|
import '@o2ter/utils-js';
|
|
5
5
|
import './internals/private-CNw40LZ7.mjs';
|
|
@@ -8,6 +8,7 @@ import './internals/index-al1N-qi7.mjs';
|
|
|
8
8
|
import 'axios';
|
|
9
9
|
import '@o2ter/server-js/dist/const';
|
|
10
10
|
import 'socket.io-client';
|
|
11
|
+
import '@o2ter/crypto-js';
|
|
11
12
|
|
|
12
13
|
//
|
|
13
14
|
// index.ts
|
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 '../common';\n\nexport { ProtoClient };\n\nexport default ProtoClient;"],"names":[],"mappings":"
|
|
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 '../common';\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
|
|
4
|
+
import { T as TSchema, a as TValueWithoutObject, P as ProtoService, b as ProtoServiceOptions, c as ProtoServiceKeyOptions } from './internals/index-PLz89AWF.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-PLz89AWF.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, f as isJob, 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, f as isJob, a as isObject, i as isQuery, d as isRole, b as isUser } from './internals/index-CKcESGqE.js';
|
|
9
9
|
import '@o2ter/utils-js';
|
|
10
10
|
import 'jsonwebtoken';
|
|
11
11
|
import 'lodash';
|
package/dist/index.js
CHANGED
|
@@ -4,10 +4,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var _ = require('lodash');
|
|
6
6
|
var serverJs = require('@o2ter/server-js');
|
|
7
|
-
var random = require('./internals/random-
|
|
7
|
+
var random = require('./internals/random-B0V0EnjP.js');
|
|
8
8
|
var _private = require('./internals/private-Ciddhure.js');
|
|
9
9
|
var utilsJs = require('@o2ter/utils-js');
|
|
10
|
-
var index = require('./internals/index-
|
|
10
|
+
var index = require('./internals/index-BRzKDwPs.js');
|
|
11
11
|
var index$1 = require('./internals/index-B8TESzd9.js');
|
|
12
12
|
var jwt = require('jsonwebtoken');
|
|
13
13
|
var node_buffer = require('node:buffer');
|
|
@@ -16,7 +16,7 @@ var node_crypto = require('node:crypto');
|
|
|
16
16
|
var util = require('util');
|
|
17
17
|
var cryptoJs = require('@o2ter/crypto-js');
|
|
18
18
|
var Decimal = require('decimal.js');
|
|
19
|
-
var index$2 = require('./internals/index-
|
|
19
|
+
var index$2 = require('./internals/index-CkAvNaAe.js');
|
|
20
20
|
var queryType = require('query-types');
|
|
21
21
|
var busboy = require('busboy');
|
|
22
22
|
require('axios');
|
|
@@ -88,6 +88,7 @@ const dispatcher = (proto, options) => {
|
|
|
88
88
|
master: options.master ?? false,
|
|
89
89
|
disableSecurity: options.disableSecurity,
|
|
90
90
|
});
|
|
91
|
+
const createFile = options.createFile;
|
|
91
92
|
return {
|
|
92
93
|
async explain(query) {
|
|
93
94
|
random.QueryValidator.recursiveCheck(query);
|
|
@@ -134,35 +135,9 @@ const dispatcher = (proto, options) => {
|
|
|
134
135
|
throw Error('No permission');
|
|
135
136
|
return proto.storage.random(decoded, opts);
|
|
136
137
|
},
|
|
137
|
-
async insert(options,
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
_validator.validateCountMatches(options.className, options.countMatches ?? []);
|
|
141
|
-
const _includes = _validator.decodeIncludes(options.className, options.includes ?? ['*']);
|
|
142
|
-
const _matches = _validator.decodeMatches(options.className, options.matches ?? {}, _includes);
|
|
143
|
-
if (!_validator.validateCLPs(options.className, 'create'))
|
|
144
|
-
throw Error('No permission');
|
|
145
|
-
const _attrs = normalize(_validator.validateFields(options.className, attrs, 'create', random.QueryValidator.patterns.path));
|
|
146
|
-
while (true) {
|
|
147
|
-
try {
|
|
148
|
-
return await proto.storage.atomic((storage) => storage.insert({
|
|
149
|
-
className: options.className,
|
|
150
|
-
includes: _includes,
|
|
151
|
-
matches: _matches,
|
|
152
|
-
countMatches: options.countMatches ?? [],
|
|
153
|
-
objectIdSize: proto[_private.PVK].options.objectIdSize
|
|
154
|
-
}, _attrs), { lockTable: options.className, retry: true });
|
|
155
|
-
}
|
|
156
|
-
catch (e) {
|
|
157
|
-
if (proto.storage.isDuplicateIdError(e))
|
|
158
|
-
continue;
|
|
159
|
-
throw e;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
},
|
|
163
|
-
async insertMany(options, values) {
|
|
164
|
-
if (options.className === 'File')
|
|
165
|
-
throw Error('File is not support insertMany');
|
|
138
|
+
async insert(options, values) {
|
|
139
|
+
if (!createFile && options.className === 'File')
|
|
140
|
+
throw Error('File is not support insert');
|
|
166
141
|
random.QueryValidator.recursiveCheck(values);
|
|
167
142
|
const _validator = await validator();
|
|
168
143
|
_validator.validateCountMatches(options.className, options.countMatches ?? []);
|
|
@@ -173,7 +148,7 @@ const dispatcher = (proto, options) => {
|
|
|
173
148
|
const _attrs = normalize(_.map(values, attr => _validator.validateFields(options.className, attr, 'create', random.QueryValidator.patterns.path)));
|
|
174
149
|
while (true) {
|
|
175
150
|
try {
|
|
176
|
-
return await proto.storage.atomic((storage) => storage.
|
|
151
|
+
return await proto.storage.atomic((storage) => storage.insert({
|
|
177
152
|
className: options.className,
|
|
178
153
|
includes: _includes,
|
|
179
154
|
matches: _matches,
|
|
@@ -188,44 +163,16 @@ const dispatcher = (proto, options) => {
|
|
|
188
163
|
}
|
|
189
164
|
}
|
|
190
165
|
},
|
|
191
|
-
async
|
|
192
|
-
random.QueryValidator.recursiveCheck(query, update);
|
|
193
|
-
const _validator = await validator();
|
|
194
|
-
if (!_validator.validateCLPs(query.className, 'update'))
|
|
195
|
-
throw Error('No permission');
|
|
196
|
-
return proto.storage.atomic((storage) => storage.updateOne(_validator.decodeQuery(normalize(query), 'update'), normalize(_validator.validateFields(query.className, update, 'update', random.QueryValidator.patterns.path))));
|
|
197
|
-
},
|
|
198
|
-
async updateMany(query, update) {
|
|
166
|
+
async update(query, update) {
|
|
199
167
|
random.QueryValidator.recursiveCheck(query, update);
|
|
200
168
|
const _validator = await validator();
|
|
201
169
|
if (!_validator.validateCLPs(query.className, 'update'))
|
|
202
170
|
throw Error('No permission');
|
|
203
|
-
return proto.storage.atomic((storage) => storage.
|
|
204
|
-
},
|
|
205
|
-
async upsertOne(query, update, setOnInsert) {
|
|
206
|
-
if (query.className === 'File')
|
|
207
|
-
throw Error('File is not support upsertOne');
|
|
208
|
-
random.QueryValidator.recursiveCheck(query, update, setOnInsert);
|
|
209
|
-
const _validator = await validator();
|
|
210
|
-
if (!_validator.validateCLPs(query.className, 'create', 'update'))
|
|
211
|
-
throw Error('No permission');
|
|
212
|
-
const _query = _validator.decodeQuery(normalize(query), 'update');
|
|
213
|
-
const _update = normalize(_validator.validateFields(query.className, update, 'update', random.QueryValidator.patterns.path));
|
|
214
|
-
const _setOnInsert = normalize(_validator.validateFields(query.className, setOnInsert, 'create', random.QueryValidator.patterns.path));
|
|
215
|
-
while (true) {
|
|
216
|
-
try {
|
|
217
|
-
return await proto.storage.atomic((storage) => storage.upsertOne(_query, _update, _setOnInsert), { lockTable: query.className, retry: true });
|
|
218
|
-
}
|
|
219
|
-
catch (e) {
|
|
220
|
-
if (proto.storage.isDuplicateIdError(e))
|
|
221
|
-
continue;
|
|
222
|
-
throw e;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
171
|
+
return proto.storage.atomic((storage) => storage.update(_validator.decodeQuery(normalize(query), 'update'), normalize(_validator.validateFields(query.className, update, 'update', random.QueryValidator.patterns.path))));
|
|
225
172
|
},
|
|
226
|
-
async
|
|
173
|
+
async upsert(query, update, setOnInsert) {
|
|
227
174
|
if (query.className === 'File')
|
|
228
|
-
throw Error('File is not support
|
|
175
|
+
throw Error('File is not support upsert');
|
|
229
176
|
random.QueryValidator.recursiveCheck(query, update, setOnInsert);
|
|
230
177
|
const _validator = await validator();
|
|
231
178
|
if (!_validator.validateCLPs(query.className, 'create', 'update'))
|
|
@@ -235,7 +182,7 @@ const dispatcher = (proto, options) => {
|
|
|
235
182
|
const _setOnInsert = normalize(_validator.validateFields(query.className, setOnInsert, 'create', random.QueryValidator.patterns.path));
|
|
236
183
|
while (true) {
|
|
237
184
|
try {
|
|
238
|
-
return await proto.storage.atomic((storage) => storage.
|
|
185
|
+
return await proto.storage.atomic((storage) => storage.upsert(_query, _update, _setOnInsert), { lockTable: query.className, retry: true });
|
|
239
186
|
}
|
|
240
187
|
catch (e) {
|
|
241
188
|
if (proto.storage.isDuplicateIdError(e))
|
|
@@ -244,19 +191,12 @@ const dispatcher = (proto, options) => {
|
|
|
244
191
|
}
|
|
245
192
|
}
|
|
246
193
|
},
|
|
247
|
-
async
|
|
194
|
+
async delete(query) {
|
|
248
195
|
random.QueryValidator.recursiveCheck(query);
|
|
249
196
|
const _validator = await validator();
|
|
250
197
|
if (!_validator.validateCLPs(query.className, 'delete'))
|
|
251
198
|
throw Error('No permission');
|
|
252
|
-
return proto.storage.atomic((storage) => storage.
|
|
253
|
-
},
|
|
254
|
-
async deleteMany(query) {
|
|
255
|
-
random.QueryValidator.recursiveCheck(query);
|
|
256
|
-
const _validator = await validator();
|
|
257
|
-
if (!_validator.validateCLPs(query.className, 'delete'))
|
|
258
|
-
throw Error('No permission');
|
|
259
|
-
return proto.storage.atomic((storage) => storage.deleteMany(_validator.decodeQuery(normalize(query), 'update')));
|
|
199
|
+
return proto.storage.atomic((storage) => storage.delete(_validator.decodeQuery(normalize(query), 'update')));
|
|
260
200
|
},
|
|
261
201
|
};
|
|
262
202
|
};
|
|
@@ -311,6 +251,7 @@ class _ProtoQuery extends index.TQuery {
|
|
|
311
251
|
return dispatcher(_serviceOf(options) ?? this._proto, {
|
|
312
252
|
...options ?? {},
|
|
313
253
|
disableSecurity: !!this._opts.insecure,
|
|
254
|
+
createFile: !!this._opts.createFile,
|
|
314
255
|
});
|
|
315
256
|
}
|
|
316
257
|
explain(options) {
|
|
@@ -346,45 +287,22 @@ class _ProtoQuery extends index.TQuery {
|
|
|
346
287
|
yield self._objectMethods(object);
|
|
347
288
|
});
|
|
348
289
|
}
|
|
349
|
-
async insert(attrs, options) {
|
|
350
|
-
const result = this._objectMethods(await this._dispatcher(options).insert({
|
|
351
|
-
className: this.className,
|
|
352
|
-
includes: this[_private.PVK].options.includes,
|
|
353
|
-
matches: this[_private.PVK].options.matches,
|
|
354
|
-
countMatches: this[_private.PVK].options.countMatches,
|
|
355
|
-
}, attrs));
|
|
356
|
-
if (!result)
|
|
357
|
-
throw Error('Unable to insert document');
|
|
358
|
-
return result;
|
|
359
|
-
}
|
|
360
290
|
async insertMany(values, options) {
|
|
361
|
-
return this._dispatcher(options).
|
|
291
|
+
return this._objectMethods(await this._dispatcher(options).insert({
|
|
362
292
|
className: this.className,
|
|
363
293
|
includes: this[_private.PVK].options.includes,
|
|
364
294
|
matches: this[_private.PVK].options.matches,
|
|
365
295
|
countMatches: this[_private.PVK].options.countMatches,
|
|
366
|
-
}, values);
|
|
367
|
-
}
|
|
368
|
-
async updateOne(update, options) {
|
|
369
|
-
return this._objectMethods(await this._dispatcher(options).updateOne(this._queryOptions, update));
|
|
296
|
+
}, values));
|
|
370
297
|
}
|
|
371
298
|
async updateMany(update, options) {
|
|
372
|
-
return this._dispatcher(options).
|
|
373
|
-
}
|
|
374
|
-
async upsertOne(update, setOnInsert, options) {
|
|
375
|
-
const result = this._objectMethods(await this._dispatcher(options).upsertOne(this._queryOptions, update, setOnInsert));
|
|
376
|
-
if (!result)
|
|
377
|
-
throw Error('Unable to upsert document');
|
|
378
|
-
return result;
|
|
299
|
+
return this._objectMethods(await this._dispatcher(options).update(this._queryOptions, update));
|
|
379
300
|
}
|
|
380
301
|
async upsertMany(update, setOnInsert, options) {
|
|
381
|
-
return this._dispatcher(options).
|
|
382
|
-
}
|
|
383
|
-
async deleteOne(options) {
|
|
384
|
-
return this._objectMethods(await this._dispatcher(options).deleteOne(this._queryOptions));
|
|
302
|
+
return this._objectMethods(await this._dispatcher(options).upsert(this._queryOptions, update, setOnInsert));
|
|
385
303
|
}
|
|
386
304
|
async deleteMany(options) {
|
|
387
|
-
return this._dispatcher(options).
|
|
305
|
+
return this._objectMethods(await this._dispatcher(options).delete(this._queryOptions));
|
|
388
306
|
}
|
|
389
307
|
}
|
|
390
308
|
class ProtoQuery extends _ProtoQuery {
|
|
@@ -961,9 +879,8 @@ class ProtoInternal {
|
|
|
961
879
|
object.set('size', file.size);
|
|
962
880
|
if (nonce)
|
|
963
881
|
object.set('nonce', nonce);
|
|
964
|
-
const
|
|
965
|
-
|
|
966
|
-
.insert(_.fromPairs([...object._set_entries()]), options);
|
|
882
|
+
const query = new ProtoQuery('File', proto, { createFile: true });
|
|
883
|
+
const created = await query.includes(...object.keys()).insert(_.fromPairs([...object._set_entries()]), options);
|
|
967
884
|
if (created) {
|
|
968
885
|
object[_private.PVK].attributes = created.attributes;
|
|
969
886
|
object[_private.PVK].mutated = {};
|
|
@@ -1643,8 +1560,11 @@ class ProtoService extends index.ProtoType {
|
|
|
1643
1560
|
notify(data) {
|
|
1644
1561
|
return this[_private.PVK].notify(this, data);
|
|
1645
1562
|
}
|
|
1646
|
-
listen(callback) {
|
|
1563
|
+
listen(callback, selector) {
|
|
1564
|
+
const _selector = !_.isNil(selector) ? index$2.QuerySelector.decode(selector) : undefined;
|
|
1647
1565
|
return this[_private.PVK].listen(this, data => {
|
|
1566
|
+
if (_selector && !_selector.eval(data))
|
|
1567
|
+
return;
|
|
1648
1568
|
callback(data);
|
|
1649
1569
|
});
|
|
1650
1570
|
}
|
|
@@ -1676,7 +1596,7 @@ class ProtoService extends index.ProtoType {
|
|
|
1676
1596
|
await this.fileStorage.destroy(this, token);
|
|
1677
1597
|
}
|
|
1678
1598
|
}
|
|
1679
|
-
await this.storage.
|
|
1599
|
+
await this.storage.delete({
|
|
1680
1600
|
className,
|
|
1681
1601
|
filter: index$2.QuerySelector.decode({ _expired_at: { $lt: time } }),
|
|
1682
1602
|
includes: ['_id', '_expired_at'],
|
|
@@ -2516,10 +2436,13 @@ const ProtoRoute = async (options) => {
|
|
|
2516
2436
|
const registerProtoSocket = (proto, server, endpoint) => {
|
|
2517
2437
|
const io = endpoint ? server.socket().of(endpoint) : server.socket();
|
|
2518
2438
|
io.on('connection', async (socket) => {
|
|
2439
|
+
let listeners = {};
|
|
2519
2440
|
const connect = async (token) => {
|
|
2520
2441
|
const payload = await proto.connectWithSessionToken(token);
|
|
2521
2442
|
const { remove } = payload.listen(data => {
|
|
2522
|
-
|
|
2443
|
+
const ids = _.keys(_.pickBy(listeners, v => v instanceof index$2.QuerySelector ? v.eval(data) : v));
|
|
2444
|
+
if (!_.isEmpty(ids))
|
|
2445
|
+
socket.emit('data', { ids, data });
|
|
2523
2446
|
});
|
|
2524
2447
|
return remove;
|
|
2525
2448
|
};
|
|
@@ -2532,6 +2455,19 @@ const registerProtoSocket = (proto, server, endpoint) => {
|
|
|
2532
2455
|
socket.on('disconnect', () => {
|
|
2533
2456
|
remove.then(rm => rm());
|
|
2534
2457
|
});
|
|
2458
|
+
socket.on('register', (payload) => {
|
|
2459
|
+
listeners = _.mapValues(payload, v => {
|
|
2460
|
+
if (_.isBoolean(v))
|
|
2461
|
+
return true;
|
|
2462
|
+
try {
|
|
2463
|
+
return index$2.QuerySelector.decode(v);
|
|
2464
|
+
}
|
|
2465
|
+
catch (error) {
|
|
2466
|
+
console.error(error);
|
|
2467
|
+
return false;
|
|
2468
|
+
}
|
|
2469
|
+
});
|
|
2470
|
+
});
|
|
2535
2471
|
});
|
|
2536
2472
|
return io;
|
|
2537
2473
|
};
|