proto.io 0.0.198 → 0.0.200
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 +26 -0
- package/dist/adapters/file/aliyun-oss.d.ts.map +1 -0
- package/dist/adapters/file/aliyun-oss.js +88 -0
- package/dist/adapters/file/aliyun-oss.js.map +1 -0
- package/dist/adapters/file/aliyun-oss.mjs +83 -0
- package/dist/adapters/file/aliyun-oss.mjs.map +1 -0
- package/dist/adapters/file/database.d.ts +1 -1
- package/dist/adapters/file/database.js +4 -4
- package/dist/adapters/file/database.js.map +1 -1
- package/dist/adapters/file/database.mjs +1 -1
- package/dist/adapters/file/filesystem.d.ts +7 -5
- package/dist/adapters/file/filesystem.js +11 -17
- package/dist/adapters/file/filesystem.js.map +1 -1
- package/dist/adapters/file/filesystem.mjs +11 -17
- package/dist/adapters/file/filesystem.mjs.map +1 -1
- package/dist/adapters/file/google-cloud-storage.d.ts +8 -6
- package/dist/adapters/file/google-cloud-storage.js +14 -22
- package/dist/adapters/file/google-cloud-storage.js.map +1 -1
- package/dist/adapters/file/google-cloud-storage.mjs +14 -22
- package/dist/adapters/file/google-cloud-storage.mjs.map +1 -1
- package/dist/adapters/storage/progres.js +1 -1
- package/dist/adapters/storage/progres.mjs +1 -1
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -7
- package/dist/index.mjs.map +1 -1
- package/dist/internals/{index-BAFVUYCo.mjs → base-DYc1_peK.mjs} +2 -2
- package/dist/internals/base-DYc1_peK.mjs.map +1 -0
- package/dist/internals/{index-DvpJENaG.d.ts → base-DvpJENaG.d.ts} +1 -1
- package/dist/internals/base-DvpJENaG.d.ts.map +1 -0
- package/dist/internals/{index-DfPY7Xbb.js → base-NsJYo2MG.js} +2 -2
- package/dist/internals/base-NsJYo2MG.js.map +1 -0
- package/dist/internals/chunk-3nNdftWC.mjs +47 -0
- package/dist/internals/chunk-3nNdftWC.mjs.map +1 -0
- package/dist/internals/chunk-BZdO1nZ9.d.ts +17 -0
- package/dist/internals/chunk-BZdO1nZ9.d.ts.map +1 -0
- package/dist/internals/chunk-CdEGTub2.js +49 -0
- package/dist/internals/chunk-CdEGTub2.js.map +1 -0
- package/dist/internals/{random-Cuj4jIuw.js → random-CM_i1mxR.js} +3 -2
- package/dist/internals/random-CM_i1mxR.js.map +1 -0
- package/dist/internals/{random-CalKTKvO.mjs → random-l5S7hC1z.mjs} +3 -2
- package/dist/internals/random-l5S7hC1z.mjs.map +1 -0
- package/package.json +3 -1
- package/dist/internals/index-BAFVUYCo.mjs.map +0 -1
- package/dist/internals/index-DfPY7Xbb.js.map +0 -1
- package/dist/internals/index-DvpJENaG.d.ts.map +0 -1
- package/dist/internals/random-CalKTKvO.mjs.map +0 -1
- package/dist/internals/random-Cuj4jIuw.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-cloud-storage.js","sources":["../../../../src/adapters/file/google-cloud-storage/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 _ from 'lodash';\nimport { ProtoService } from '../../../server/proto';\nimport { Storage } from '@google-cloud/storage';\nimport
|
|
1
|
+
{"version":3,"file":"google-cloud-storage.js","sources":["../../../../src/adapters/file/google-cloud-storage/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 _ from 'lodash';\nimport { ProtoService } from '../../../server/proto';\nimport { Storage, File } from '@google-cloud/storage';\nimport { FileStorageOptions } from '../base';\nimport { FileChunkStorageBase } from '../base/chunk';\n\nexport class GoogleCloudStorage extends FileChunkStorageBase<File> {\n\n private _storage: Storage;\n private _bucket: string;\n\n constructor(storage: Storage, bucket: string, options: FileStorageOptions = {}) {\n super(options);\n this._storage = storage;\n this._bucket = bucket;\n }\n\n get bucket() {\n return this._storage.bucket(this._bucket);\n }\n\n async createChunk<E>(proto: ProtoService<E>, token: string, start: number, end: number, compressed: Buffer) {\n await this.bucket.file(`${token}/${start}.chunk`).save(compressed);\n }\n\n async listChunks<E>(proto: ProtoService<E>, token: string) {\n const [response] = await this.bucket.getFiles({\n prefix: `${token}/`,\n delimiter: '/',\n });\n const files = _.map(response, x => ({\n file: x,\n name: _.last(_.split(x.name, '/'))!,\n }));\n return _.map(_.filter(files, x => !!x.name?.match(/^\\d+\\.chunk$/)), x => ({\n file: x.file,\n start: parseInt(x.name.slice(0, -6)),\n }));\n }\n\n async readChunk<E>(proto: ProtoService<E>, file: File) {\n const [buffer] = await file.download() ?? [];\n if (!buffer) throw Error('Unable to connect cloud storage');\n return buffer;\n }\n\n async destroy<E>(proto: ProtoService<E>, token: string) {\n await this.bucket.deleteFiles({ prefix: `${token}/` });\n }\n};\n\nexport default GoogleCloudStorage;"],"names":["FileChunkStorageBase"],"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;AAQM,MAAO,kBAAmB,SAAQA,0BAA0B,CAAA;AAExD,IAAA,QAAQ;AACR,IAAA,OAAO;AAEf,IAAA,WAAA,CAAY,OAAgB,EAAE,MAAc,EAAE,UAA8B,EAAE,EAAA;QAC5E,KAAK,CAAC,OAAO,CAAC;AACd,QAAA,IAAI,CAAC,QAAQ,GAAG,OAAO;AACvB,QAAA,IAAI,CAAC,OAAO,GAAG,MAAM;;AAGvB,IAAA,IAAI,MAAM,GAAA;QACR,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;;IAG3C,MAAM,WAAW,CAAI,KAAsB,EAAE,KAAa,EAAE,KAAa,EAAE,GAAW,EAAE,UAAkB,EAAA;AACxG,QAAA,MA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AE,KAAa,EAAA;AACpD,QAAA,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAG,EAAA,KAAK,CAAG,CAAA,CAAA,EAAE,CAAC;;AAEzD;;;;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
|
-
import { F as
|
|
2
|
+
import { F as FileChunkStorageBase } from '../../internals/chunk-3nNdftWC.mjs';
|
|
3
|
+
import '../../internals/base-DYc1_peK.mjs';
|
|
3
4
|
import 'util';
|
|
4
5
|
import 'zlib';
|
|
5
6
|
import '@o2ter/utils-js';
|
|
@@ -29,7 +30,7 @@ import '../../internals/private-CNw40LZ7.mjs';
|
|
|
29
30
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
30
31
|
// THE SOFTWARE.
|
|
31
32
|
//
|
|
32
|
-
class GoogleCloudStorage extends
|
|
33
|
+
class GoogleCloudStorage extends FileChunkStorageBase {
|
|
33
34
|
_storage;
|
|
34
35
|
_bucket;
|
|
35
36
|
constructor(storage, bucket, options = {}) {
|
|
@@ -43,34 +44,25 @@ class GoogleCloudStorage extends FileStorageBase {
|
|
|
43
44
|
async createChunk(proto, token, start, end, compressed) {
|
|
44
45
|
await this.bucket.file(`${token}/${start}.chunk`).save(compressed);
|
|
45
46
|
}
|
|
46
|
-
async
|
|
47
|
+
async listChunks(proto, token) {
|
|
47
48
|
const [response] = await this.bucket.getFiles({
|
|
48
49
|
prefix: `${token}/`,
|
|
49
50
|
delimiter: '/',
|
|
50
51
|
});
|
|
51
|
-
const
|
|
52
|
+
const files = _.map(response, x => ({
|
|
52
53
|
file: x,
|
|
53
54
|
name: _.last(_.split(x.name, '/')),
|
|
54
|
-
}))
|
|
55
|
-
|
|
55
|
+
}));
|
|
56
|
+
return _.map(_.filter(files, x => !!x.name?.match(/^\d+\.chunk$/)), x => ({
|
|
56
57
|
file: x.file,
|
|
57
58
|
start: parseInt(x.name.slice(0, -6)),
|
|
58
|
-
}))
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
start: chunk.start,
|
|
66
|
-
data: (async () => {
|
|
67
|
-
const [buffer] = await chunk?.file.download() ?? [];
|
|
68
|
-
if (!buffer)
|
|
69
|
-
throw Error('Unable to connect cloud storage');
|
|
70
|
-
return buffer;
|
|
71
|
-
})(),
|
|
72
|
-
};
|
|
73
|
-
}
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
async readChunk(proto, file) {
|
|
62
|
+
const [buffer] = await file.download() ?? [];
|
|
63
|
+
if (!buffer)
|
|
64
|
+
throw Error('Unable to connect cloud storage');
|
|
65
|
+
return buffer;
|
|
74
66
|
}
|
|
75
67
|
async destroy(proto, token) {
|
|
76
68
|
await this.bucket.deleteFiles({ prefix: `${token}/` });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-cloud-storage.mjs","sources":["../../../../src/adapters/file/google-cloud-storage/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 _ from 'lodash';\nimport { ProtoService } from '../../../server/proto';\nimport { Storage } from '@google-cloud/storage';\nimport
|
|
1
|
+
{"version":3,"file":"google-cloud-storage.mjs","sources":["../../../../src/adapters/file/google-cloud-storage/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 _ from 'lodash';\nimport { ProtoService } from '../../../server/proto';\nimport { Storage, File } from '@google-cloud/storage';\nimport { FileStorageOptions } from '../base';\nimport { FileChunkStorageBase } from '../base/chunk';\n\nexport class GoogleCloudStorage extends FileChunkStorageBase<File> {\n\n private _storage: Storage;\n private _bucket: string;\n\n constructor(storage: Storage, bucket: string, options: FileStorageOptions = {}) {\n super(options);\n this._storage = storage;\n this._bucket = bucket;\n }\n\n get bucket() {\n return this._storage.bucket(this._bucket);\n }\n\n async createChunk<E>(proto: ProtoService<E>, token: string, start: number, end: number, compressed: Buffer) {\n await this.bucket.file(`${token}/${start}.chunk`).save(compressed);\n }\n\n async listChunks<E>(proto: ProtoService<E>, token: string) {\n const [response] = await this.bucket.getFiles({\n prefix: `${token}/`,\n delimiter: '/',\n });\n const files = _.map(response, x => ({\n file: x,\n name: _.last(_.split(x.name, '/'))!,\n }));\n return _.map(_.filter(files, x => !!x.name?.match(/^\\d+\\.chunk$/)), x => ({\n file: x.file,\n start: parseInt(x.name.slice(0, -6)),\n }));\n }\n\n async readChunk<E>(proto: ProtoService<E>, file: File) {\n const [buffer] = await file.download() ?? [];\n if (!buffer) throw Error('Unable to connect cloud storage');\n return buffer;\n }\n\n async destroy<E>(proto: ProtoService<E>, token: string) {\n await this.bucket.deleteFiles({ prefix: `${token}/` });\n }\n};\n\nexport default GoogleCloudStorage;"],"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;AAQM,MAAO,kBAAmB,SAAQ,oBAA0B,CAAA;AAExD,IAAA,QAAQ;AACR,IAAA,OAAO;AAEf,IAAA,WAAA,CAAY,OAAgB,EAAE,MAAc,EAAE,UAA8B,EAAE,EAAA;QAC5E,KAAK,CAAC,OAAO,CAAC;AACd,QAAA,IAAI,CAAC,QAAQ,GAAG,OAAO;AACvB,QAAA,IAAI,CAAC,OAAO,GAAG,MAAM;;AAGvB,IAAA,IAAI,MAAM,GAAA;QACR,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;;IAG3C,MAAM,WAAW,CAAI,KAAsB,EAAE,KAAa,EAAE,KAAa,EAAE,GAAW,EAAE,UAAkB,EAAA;AACxG,QAAA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,EAAE,KAAa,EAAA;AACpD,QAAA,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAG,EAAA,KAAK,CAAG,CAAA,CAAA,EAAE,CAAC;;AAEzD;;;;"}
|
|
@@ -11,7 +11,7 @@ var Decimal = require('decimal.js');
|
|
|
11
11
|
var utils = require('pg/lib/utils');
|
|
12
12
|
var index$1 = require('../../internals/index-DIFr-lHN.js');
|
|
13
13
|
require('@o2ter/crypto-js');
|
|
14
|
-
var random$1 = require('../../internals/random-
|
|
14
|
+
var random$1 = require('../../internals/random-CM_i1mxR.js');
|
|
15
15
|
var _private = require('../../internals/private-Ciddhure.js');
|
|
16
16
|
|
|
17
17
|
//
|
|
@@ -7,7 +7,7 @@ import Decimal from 'decimal.js';
|
|
|
7
7
|
import { escapeLiteral, escapeIdentifier } from 'pg/lib/utils';
|
|
8
8
|
import { a as QueryCoditionalSelector, b as QueryFieldSelector, c as QueryExpressionSelector, d as QueryDistanceExpression, e as QueryCoditionalExpression, f as QueryComparisonExpression, g as QueryNotExpression, h as QueryArrayExpression, i as QueryValueExpression, j as QueryKeyExpression, Q as QuerySelector, F as FieldSelectorExpression } from '../../internals/index-DAtoqvEN.mjs';
|
|
9
9
|
import '@o2ter/crypto-js';
|
|
10
|
-
import { r as resolveColumn, a as resolveDataType$1, g as generateId, Q as QueryValidator } from '../../internals/random-
|
|
10
|
+
import { r as resolveColumn, a as resolveDataType$1, g as generateId, Q as QueryValidator } from '../../internals/random-l5S7hC1z.mjs';
|
|
11
11
|
import { P as PVK } from '../../internals/private-CNw40LZ7.mjs';
|
|
12
12
|
|
|
13
13
|
//
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ 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-CM_i1mxR.js');
|
|
8
8
|
var _private = require('./internals/private-Ciddhure.js');
|
|
9
9
|
var utilsJs = require('@o2ter/utils-js');
|
|
10
10
|
var index = require('./internals/index-CGO-xORH.js');
|
|
@@ -130,7 +130,7 @@ const dispatcher = (proto, options) => {
|
|
|
130
130
|
const isGet = _validator.isGetMethod(decoded.filter);
|
|
131
131
|
if (!_validator.validateCLPs(query.className, isGet ? 'get' : 'find'))
|
|
132
132
|
throw Error('No permission');
|
|
133
|
-
if (opts?.weight && !_validator.validateKey(query.className, opts.weight, 'read', random.QueryValidator.patterns.
|
|
133
|
+
if (opts?.weight && !_validator.validateKey(query.className, opts.weight, 'read', random.QueryValidator.patterns.path))
|
|
134
134
|
throw Error('No permission');
|
|
135
135
|
return proto.storage.random(decoded, opts);
|
|
136
136
|
},
|
|
@@ -211,7 +211,7 @@ const dispatcher = (proto, options) => {
|
|
|
211
211
|
throw Error('No permission');
|
|
212
212
|
const _query = _validator.decodeQuery(normalize(query), 'update');
|
|
213
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.
|
|
214
|
+
const _setOnInsert = normalize(_validator.validateFields(query.className, setOnInsert, 'create', random.QueryValidator.patterns.path));
|
|
215
215
|
while (true) {
|
|
216
216
|
try {
|
|
217
217
|
return await proto.storage.atomic((storage) => storage.upsertOne(_query, _update, _setOnInsert), { lockTable: query.className, retry: true });
|
|
@@ -232,7 +232,7 @@ const dispatcher = (proto, options) => {
|
|
|
232
232
|
throw Error('No permission');
|
|
233
233
|
const _query = _validator.decodeQuery(normalize(query), 'update');
|
|
234
234
|
const _update = normalize(_validator.validateFields(query.className, update, 'update', random.QueryValidator.patterns.path));
|
|
235
|
-
const _setOnInsert = normalize(_validator.validateFields(query.className, setOnInsert, 'create', random.QueryValidator.patterns.
|
|
235
|
+
const _setOnInsert = normalize(_validator.validateFields(query.className, setOnInsert, 'create', random.QueryValidator.patterns.path));
|
|
236
236
|
while (true) {
|
|
237
237
|
try {
|
|
238
238
|
return await proto.storage.atomic((storage) => storage.upsertMany(_query, _update, _setOnInsert), { lockTable: query.className, retry: true });
|
|
@@ -716,7 +716,7 @@ const validateShapedObject = (schema, dataType) => {
|
|
|
716
716
|
if (_.isEmpty(dataType.shape))
|
|
717
717
|
throw Error('Invalid empty shape');
|
|
718
718
|
for (const [key, type] of _.entries(dataType.shape)) {
|
|
719
|
-
if (!key.match(random.QueryValidator.patterns.
|
|
719
|
+
if (!key.match(random.QueryValidator.patterns.fieldName))
|
|
720
720
|
throw Error(`Invalid field name: ${key}`);
|
|
721
721
|
if (index$1.isShape(type)) {
|
|
722
722
|
validateShapedObject(schema, type);
|
|
@@ -740,10 +740,10 @@ const validateSchemaName = (schema) => {
|
|
|
740
740
|
};
|
|
741
741
|
const validateSchema = (schema) => {
|
|
742
742
|
for (const [className, _schema] of _.toPairs(schema)) {
|
|
743
|
-
if (!className.match(random.QueryValidator.patterns.
|
|
743
|
+
if (!className.match(random.QueryValidator.patterns.className))
|
|
744
744
|
throw Error(`Invalid class name: ${className}`);
|
|
745
745
|
for (const [key, dataType] of _.toPairs(_schema.fields)) {
|
|
746
|
-
if (!key.match(random.QueryValidator.patterns.
|
|
746
|
+
if (!key.match(random.QueryValidator.patterns.fieldName))
|
|
747
747
|
throw Error(`Invalid field name: ${key}`);
|
|
748
748
|
if (index$1.isShape(dataType)) {
|
|
749
749
|
validateShapedObject(schema, dataType);
|