proto.io 0.0.206 → 0.0.208
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/aliyun-oss.js +2 -2
- package/dist/adapters/file/aliyun-oss.js.map +1 -1
- package/dist/adapters/file/aliyun-oss.mjs +2 -2
- package/dist/adapters/file/aliyun-oss.mjs.map +1 -1
- package/dist/adapters/file/database.d.ts +2 -2
- package/dist/adapters/file/database.js +3 -3
- package/dist/adapters/file/database.js.map +1 -1
- package/dist/adapters/file/database.mjs +3 -3
- 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 -17
- package/dist/adapters/storage/progres.js +24 -101
- package/dist/adapters/storage/progres.js.map +1 -1
- package/dist/adapters/storage/progres.mjs +24 -101
- package/dist/adapters/storage/progres.mjs.map +1 -1
- package/dist/client.d.ts +3 -3
- package/dist/client.js +2 -2
- package/dist/client.mjs +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +123 -144
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +125 -146
- package/dist/index.mjs.map +1 -1
- package/dist/internals/{base-Be7PFKEC.d.ts → base-wSknxBv7.d.ts} +2 -2
- package/dist/internals/base-wSknxBv7.d.ts.map +1 -0
- package/dist/internals/{chunk-CEQtSsWb.d.ts → chunk-C_BXf1Er.d.ts} +3 -3
- package/dist/internals/chunk-C_BXf1Er.d.ts.map +1 -0
- package/dist/internals/{index-DnbbpIaO.d.ts → index-A-hoMfDO.d.ts} +48 -20
- package/dist/internals/index-A-hoMfDO.d.ts.map +1 -0
- package/dist/internals/{index-CsmAYB_t.js → index-B8TESzd9.js} +1 -2
- package/dist/internals/{index-CsmAYB_t.js.map → index-B8TESzd9.js.map} +1 -1
- package/dist/internals/{index-CSnRU_KQ.mjs → index-BvwYz4Yp.mjs} +60 -18
- package/dist/internals/index-BvwYz4Yp.mjs.map +1 -0
- package/dist/internals/{index-CyPxh5dl.js → index-CkAvNaAe.js} +2 -2
- package/dist/internals/{index-CyPxh5dl.js.map → index-CkAvNaAe.js.map} +1 -1
- package/dist/internals/{index-BFZlY3IO.js → index-DVUiXLfI.js} +60 -18
- package/dist/internals/index-DVUiXLfI.js.map +1 -0
- package/dist/internals/{index-iRVgw566.mjs → index-DlY33lfO.mjs} +2 -2
- package/dist/internals/{index-iRVgw566.mjs.map → index-DlY33lfO.mjs.map} +1 -1
- package/dist/internals/{index-DpN9tcbY.mjs → index-al1N-qi7.mjs} +2 -2
- package/dist/internals/{index-DpN9tcbY.mjs.map → index-al1N-qi7.mjs.map} +1 -1
- package/dist/internals/{index-CURcwPBG.d.ts → index-iqOd-Wdg.d.ts} +2 -2
- package/dist/internals/index-iqOd-Wdg.d.ts.map +1 -0
- package/dist/internals/{random-D7S1XD7F.js → random-B0V0EnjP.js} +3 -3
- package/dist/internals/random-B0V0EnjP.js.map +1 -0
- package/dist/internals/{random-BnGB_bVS.mjs → random-ZgzzM5v_.mjs} +3 -3
- package/dist/internals/random-ZgzzM5v_.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/internals/base-Be7PFKEC.d.ts.map +0 -1
- package/dist/internals/chunk-CEQtSsWb.d.ts.map +0 -1
- package/dist/internals/index-BFZlY3IO.js.map +0 -1
- package/dist/internals/index-CSnRU_KQ.mjs.map +0 -1
- package/dist/internals/index-CURcwPBG.d.ts.map +0 -1
- package/dist/internals/index-DnbbpIaO.d.ts.map +0 -1
- package/dist/internals/random-BnGB_bVS.mjs.map +0 -1
- package/dist/internals/random-D7S1XD7F.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { P as ProtoService } from '../../internals/index-
|
|
1
|
+
import { P as ProtoService } from '../../internals/index-A-hoMfDO.js';
|
|
2
2
|
import OSS from 'ali-oss';
|
|
3
|
-
import { a as FileStorageOptions } from '../../internals/base-
|
|
4
|
-
import { F as FileChunkStorageBase } from '../../internals/chunk-
|
|
3
|
+
import { a as FileStorageOptions } from '../../internals/base-wSknxBv7.js';
|
|
4
|
+
import { F as FileChunkStorageBase } from '../../internals/chunk-C_BXf1Er.js';
|
|
5
5
|
import '@o2ter/utils-js';
|
|
6
6
|
import 'jsonwebtoken';
|
|
7
7
|
import '@o2ter/server-js';
|
|
@@ -46,7 +46,7 @@ class AliyunObjectStorage extends chunk.FileChunkStorageBase {
|
|
|
46
46
|
async listChunks(proto, token) {
|
|
47
47
|
const response = [];
|
|
48
48
|
let next;
|
|
49
|
-
|
|
49
|
+
do {
|
|
50
50
|
const { objects, nextContinuationToken } = await this._storage.listV2({
|
|
51
51
|
prefix: `${token}/`,
|
|
52
52
|
delimiter: '/',
|
|
@@ -56,7 +56,7 @@ class AliyunObjectStorage extends chunk.FileChunkStorageBase {
|
|
|
56
56
|
break;
|
|
57
57
|
response.push(...objects);
|
|
58
58
|
next = nextContinuationToken;
|
|
59
|
-
}
|
|
59
|
+
} while (next);
|
|
60
60
|
const files = _.map(response, x => ({
|
|
61
61
|
file: x,
|
|
62
62
|
name: _.last(_.split(x.name, '/')),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aliyun-oss.js","sources":["../../../../src/adapters/file/aliyun-oss/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 OSS from 'ali-oss';\nimport { FileChunkStorageBase, FileStorageOptions } from '../base';\n\nexport class AliyunObjectStorage extends FileChunkStorageBase<OSS.ObjectMeta> {\n\n private _storage: OSS;\n\n constructor(storage: OSS, options: FileStorageOptions = {}) {\n super(options);\n this._storage = storage;\n }\n\n async createChunk<E>(proto: ProtoService<E>, token: string, start: number, end: number, compressed: Buffer) {\n await this._storage.put(`${token}/${start}.chunk`, compressed);\n }\n\n async listChunks<E>(proto: ProtoService<E>, token: string) {\n const response: OSS.ObjectMeta[] = [];\n let next: string | undefined;\n
|
|
1
|
+
{"version":3,"file":"aliyun-oss.js","sources":["../../../../src/adapters/file/aliyun-oss/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 OSS from 'ali-oss';\nimport { FileChunkStorageBase, FileStorageOptions } from '../base';\n\nexport class AliyunObjectStorage extends FileChunkStorageBase<OSS.ObjectMeta> {\n\n private _storage: OSS;\n\n constructor(storage: OSS, options: FileStorageOptions = {}) {\n super(options);\n this._storage = storage;\n }\n\n async createChunk<E>(proto: ProtoService<E>, token: string, start: number, end: number, compressed: Buffer) {\n await this._storage.put(`${token}/${start}.chunk`, compressed);\n }\n\n async listChunks<E>(proto: ProtoService<E>, token: string) {\n const response: OSS.ObjectMeta[] = [];\n let next: string | undefined;\n do {\n const { objects, nextContinuationToken } = await (this._storage as any).listV2({\n prefix: `${token}/`,\n delimiter: '/',\n continuationToken: next,\n }, {});\n if (_.isEmpty(objects)) break;\n response.push(...objects);\n next = nextContinuationToken;\n } while (next);\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: OSS.ObjectMeta) {\n const { content } = await this._storage.get(file.name);\n return content;\n }\n\n async destroy<E>(proto: ProtoService<E>, token: string) {\n while (true) {\n const { objects } = await this._storage.listV2({\n prefix: `${token}/`,\n delimiter: '/',\n }, {});\n if (_.isEmpty(objects)) return;\n await this._storage.deleteMulti(_.map(objects, x => x.name));\n }\n }\n};\n\nexport default AliyunObjectStorage;"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|
const response = [];
|
|
44
44
|
let next;
|
|
45
|
-
|
|
45
|
+
do {
|
|
46
46
|
const { objects, nextContinuationToken } = await this._storage.listV2({
|
|
47
47
|
prefix: `${token}/`,
|
|
48
48
|
delimiter: '/',
|
|
@@ -52,7 +52,7 @@ class AliyunObjectStorage extends FileChunkStorageBase {
|
|
|
52
52
|
break;
|
|
53
53
|
response.push(...objects);
|
|
54
54
|
next = nextContinuationToken;
|
|
55
|
-
}
|
|
55
|
+
} while (next);
|
|
56
56
|
const files = _.map(response, x => ({
|
|
57
57
|
file: x,
|
|
58
58
|
name: _.last(_.split(x.name, '/')),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aliyun-oss.mjs","sources":["../../../../src/adapters/file/aliyun-oss/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 OSS from 'ali-oss';\nimport { FileChunkStorageBase, FileStorageOptions } from '../base';\n\nexport class AliyunObjectStorage extends FileChunkStorageBase<OSS.ObjectMeta> {\n\n private _storage: OSS;\n\n constructor(storage: OSS, options: FileStorageOptions = {}) {\n super(options);\n this._storage = storage;\n }\n\n async createChunk<E>(proto: ProtoService<E>, token: string, start: number, end: number, compressed: Buffer) {\n await this._storage.put(`${token}/${start}.chunk`, compressed);\n }\n\n async listChunks<E>(proto: ProtoService<E>, token: string) {\n const response: OSS.ObjectMeta[] = [];\n let next: string | undefined;\n
|
|
1
|
+
{"version":3,"file":"aliyun-oss.mjs","sources":["../../../../src/adapters/file/aliyun-oss/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 OSS from 'ali-oss';\nimport { FileChunkStorageBase, FileStorageOptions } from '../base';\n\nexport class AliyunObjectStorage extends FileChunkStorageBase<OSS.ObjectMeta> {\n\n private _storage: OSS;\n\n constructor(storage: OSS, options: FileStorageOptions = {}) {\n super(options);\n this._storage = storage;\n }\n\n async createChunk<E>(proto: ProtoService<E>, token: string, start: number, end: number, compressed: Buffer) {\n await this._storage.put(`${token}/${start}.chunk`, compressed);\n }\n\n async listChunks<E>(proto: ProtoService<E>, token: string) {\n const response: OSS.ObjectMeta[] = [];\n let next: string | undefined;\n do {\n const { objects, nextContinuationToken } = await (this._storage as any).listV2({\n prefix: `${token}/`,\n delimiter: '/',\n continuationToken: next,\n }, {});\n if (_.isEmpty(objects)) break;\n response.push(...objects);\n next = nextContinuationToken;\n } while (next);\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: OSS.ObjectMeta) {\n const { content } = await this._storage.get(file.name);\n return content;\n }\n\n async destroy<E>(proto: ProtoService<E>, token: string) {\n while (true) {\n const { objects } = await this._storage.listV2({\n prefix: `${token}/`,\n delimiter: '/',\n }, {});\n if (_.isEmpty(objects)) return;\n await this._storage.deleteMulti(_.map(objects, x => x.name));\n }\n }\n};\n\nexport default AliyunObjectStorage;"],"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;AAOM,MAAO,mBAAoB,SAAQ,oBAAoC,CAAA;AAEnE,IAAA,QAAQ;IAEhB,WAAY,CAAA,OAAY,EAAE,OAAA,GAA8B,EAAE,EAAA;QACxD,KAAK,CAAC,OAAO,CAAC;AACd,QAAA,IAAI,CAAC,QAAQ,GAAG,OAAO;;IAGzB,MAAM,WAAW,CAAI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AAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACrC,SAAA,CAAC,CAAC;;AAGL,IAAA,MAAM,SAAS,CAAI,KAAsB,EAAE,IAAoB,EAAA;AAC7D,QAAA,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;AACtD,QAAA,OAAO,OAAO;;AAGhB,IAAA,MAAM,OAAO,CAAI,KAAsB,EAAE,KAAa,EAAA;QACpD,OAAO,IAAI,EAAE;YACX,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;gBAC7C,MAAM,EAAE,CAAG,EAAA,KAAK,CAAG,CAAA,CAAA;AACnB,gBAAA,SAAS,EAAE,GAAG;aACf,EAAE,EAAE,CAAC;AACN,YAAA,IAAI,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;gBAAE;YACxB,MAAM,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;;;AAGjE;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as TSchema, P as ProtoService } from '../../internals/index-
|
|
2
|
-
import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/base-
|
|
1
|
+
import { T as TSchema, P as ProtoService } from '../../internals/index-A-hoMfDO.js';
|
|
2
|
+
import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/base-wSknxBv7.js';
|
|
3
3
|
import '@o2ter/utils-js';
|
|
4
4
|
import 'jsonwebtoken';
|
|
5
5
|
import '@o2ter/server-js';
|
|
@@ -4,12 +4,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var _ = require('lodash');
|
|
6
6
|
var base = require('../../internals/base-BFKQpiws.js');
|
|
7
|
-
var index = require('../../internals/index-
|
|
7
|
+
var index = require('../../internals/index-CkAvNaAe.js');
|
|
8
8
|
var utilsJs = require('@o2ter/utils-js');
|
|
9
9
|
require('util');
|
|
10
10
|
require('zlib');
|
|
11
11
|
require('../../internals/private-Ciddhure.js');
|
|
12
|
-
require('../../internals/index-
|
|
12
|
+
require('../../internals/index-B8TESzd9.js');
|
|
13
13
|
require('decimal.js');
|
|
14
14
|
|
|
15
15
|
//
|
|
@@ -99,7 +99,7 @@ class DatabaseFileStorage extends base.FileStorageBase {
|
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
async destroy(proto, token) {
|
|
102
|
-
proto.storage.
|
|
102
|
+
proto.storage.delete({
|
|
103
103
|
className: '_FileChunk',
|
|
104
104
|
filter: index.QuerySelector.decode({ token: { $eq: token } }),
|
|
105
105
|
includes: ['_id'],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.js","sources":["../../../../src/adapters/file/database/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 { TSchema } from '../../../internals/schema';\nimport FileStorageBase, { FileStorageOptions } from '../base';\nimport { QuerySelector } from '../../../server/query/dispatcher/parser';\nimport { base64ToBuffer, bufferToBase64 } from '@o2ter/utils-js';\n\nexport class DatabaseFileStorage extends FileStorageBase {\n\n constructor(options: FileStorageOptions = {}) {\n super(options);\n }\n\n get schema(): Record<string, TSchema> {\n return {\n '_FileChunk': {\n fields: {\n token: 'string',\n start: 'number',\n end: 'number',\n size: 'number',\n base64: 'string',\n },\n classLevelPermissions: {\n get: [],\n find: [],\n count: [],\n create: [],\n update: [],\n delete: [],\n },\n fieldLevelPermissions: {\n _expired_at: { create: [], update: [] },\n },\n indexes: [\n { keys: { token: 1, start: 1, end: 1 } },\n { keys: { token: 1, end: 1 } },\n ]\n },\n }\n }\n\n async createChunk<E>(proto: ProtoService<E>, token: string, start: number, end: number, compressed: Buffer) {\n\n const created = await proto.Query('_FileChunk').insert({\n token,\n start: start,\n end: end,\n size: end - start,\n base64: bufferToBase64(compressed),\n }, { master: true });\n\n if (!created) throw Error('Unable to save file');\n\n }\n\n async* readChunks<E>(proto: ProtoService<E>, token: string, start?: number | undefined, end?: number | undefined) {\n const query = proto.Query('_FileChunk')\n .sort({ start: 1 })\n .filter({\n token: { $eq: token },\n ...start ? { end: { $gt: start } } : {},\n ...end ? { start: { $lt: end } } : {},\n });\n for await (const chunk of query.find({ master: true })) {\n const startBytes = chunk.get('start');\n const base64 = chunk.get('base64');\n if (!_.isNumber(startBytes) || !_.isString(base64)) throw Error('Corrupted data');\n yield {\n start: startBytes,\n data: base64ToBuffer(base64),\n };\n }\n }\n\n async destroy<E>(proto: ProtoService<E>, token: string) {\n proto.storage.
|
|
1
|
+
{"version":3,"file":"database.js","sources":["../../../../src/adapters/file/database/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 { TSchema } from '../../../internals/schema';\nimport FileStorageBase, { FileStorageOptions } from '../base';\nimport { QuerySelector } from '../../../server/query/dispatcher/parser';\nimport { base64ToBuffer, bufferToBase64 } from '@o2ter/utils-js';\n\nexport class DatabaseFileStorage extends FileStorageBase {\n\n constructor(options: FileStorageOptions = {}) {\n super(options);\n }\n\n get schema(): Record<string, TSchema> {\n return {\n '_FileChunk': {\n fields: {\n token: 'string',\n start: 'number',\n end: 'number',\n size: 'number',\n base64: 'string',\n },\n classLevelPermissions: {\n get: [],\n find: [],\n count: [],\n create: [],\n update: [],\n delete: [],\n },\n fieldLevelPermissions: {\n _expired_at: { create: [], update: [] },\n },\n indexes: [\n { keys: { token: 1, start: 1, end: 1 } },\n { keys: { token: 1, end: 1 } },\n ]\n },\n }\n }\n\n async createChunk<E>(proto: ProtoService<E>, token: string, start: number, end: number, compressed: Buffer) {\n\n const created = await proto.Query('_FileChunk').insert({\n token,\n start: start,\n end: end,\n size: end - start,\n base64: bufferToBase64(compressed),\n }, { master: true });\n\n if (!created) throw Error('Unable to save file');\n\n }\n\n async* readChunks<E>(proto: ProtoService<E>, token: string, start?: number | undefined, end?: number | undefined) {\n const query = proto.Query('_FileChunk')\n .sort({ start: 1 })\n .filter({\n token: { $eq: token },\n ...start ? { end: { $gt: start } } : {},\n ...end ? { start: { $lt: end } } : {},\n });\n for await (const chunk of query.find({ master: true })) {\n const startBytes = chunk.get('start');\n const base64 = chunk.get('base64');\n if (!_.isNumber(startBytes) || !_.isString(base64)) throw Error('Corrupted data');\n yield {\n start: startBytes,\n data: base64ToBuffer(base64),\n };\n }\n }\n\n async destroy<E>(proto: ProtoService<E>, token: string) {\n proto.storage.delete({\n className: '_FileChunk',\n filter: QuerySelector.decode({ token: { $eq: token } }),\n includes: ['_id'],\n matches: {},\n countMatches: [],\n objectIdSize: 0\n });\n }\n};\n\nexport default DatabaseFileStorage;"],"names":["FileStorageBase","bufferToBase64","base64ToBuffer","QuerySelector"],"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;AASM,MAAO,mBAAoB,SAAQA,oBAAe,CAAA;AAEtD,IAAA,WAAA,CAAY,UAA8B,EAAE,EAAA;QAC1C,KAAK,CAAC,OAAO,CAAC;;AAGhB,IAAA,IAAI,MAAM,GAAA;QACR,OAAO;AACL,YAAA,YAAY,EAAE;AACZ,gBAAA,MAAM,EAAE;AACN,oBAAA,KAAK,EAAE,QAAQ;AACf,oBAAA,KAAK,EAAE,QAAQ;AACf,oBAAA,GAAG,EAAE,QAAQ;AACb,oBAAA,IAAI,EAAE,QAAQ;AACd,oBAAA,MAAM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
|
import _ from 'lodash';
|
|
2
2
|
import { F as FileStorageBase } from '../../internals/base-CfQi0T0I.mjs';
|
|
3
|
-
import { Q as QuerySelector } from '../../internals/index-
|
|
3
|
+
import { Q as QuerySelector } from '../../internals/index-DlY33lfO.mjs';
|
|
4
4
|
import { bufferToBase64, base64ToBuffer } from '@o2ter/utils-js';
|
|
5
5
|
import 'util';
|
|
6
6
|
import 'zlib';
|
|
7
7
|
import '../../internals/private-CNw40LZ7.mjs';
|
|
8
|
-
import '../../internals/index-
|
|
8
|
+
import '../../internals/index-al1N-qi7.mjs';
|
|
9
9
|
import 'decimal.js';
|
|
10
10
|
|
|
11
11
|
//
|
|
@@ -95,7 +95,7 @@ class DatabaseFileStorage extends FileStorageBase {
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
async destroy(proto, token) {
|
|
98
|
-
proto.storage.
|
|
98
|
+
proto.storage.delete({
|
|
99
99
|
className: '_FileChunk',
|
|
100
100
|
filter: QuerySelector.decode({ token: { $eq: token } }),
|
|
101
101
|
includes: ['_id'],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.mjs","sources":["../../../../src/adapters/file/database/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 { TSchema } from '../../../internals/schema';\nimport FileStorageBase, { FileStorageOptions } from '../base';\nimport { QuerySelector } from '../../../server/query/dispatcher/parser';\nimport { base64ToBuffer, bufferToBase64 } from '@o2ter/utils-js';\n\nexport class DatabaseFileStorage extends FileStorageBase {\n\n constructor(options: FileStorageOptions = {}) {\n super(options);\n }\n\n get schema(): Record<string, TSchema> {\n return {\n '_FileChunk': {\n fields: {\n token: 'string',\n start: 'number',\n end: 'number',\n size: 'number',\n base64: 'string',\n },\n classLevelPermissions: {\n get: [],\n find: [],\n count: [],\n create: [],\n update: [],\n delete: [],\n },\n fieldLevelPermissions: {\n _expired_at: { create: [], update: [] },\n },\n indexes: [\n { keys: { token: 1, start: 1, end: 1 } },\n { keys: { token: 1, end: 1 } },\n ]\n },\n }\n }\n\n async createChunk<E>(proto: ProtoService<E>, token: string, start: number, end: number, compressed: Buffer) {\n\n const created = await proto.Query('_FileChunk').insert({\n token,\n start: start,\n end: end,\n size: end - start,\n base64: bufferToBase64(compressed),\n }, { master: true });\n\n if (!created) throw Error('Unable to save file');\n\n }\n\n async* readChunks<E>(proto: ProtoService<E>, token: string, start?: number | undefined, end?: number | undefined) {\n const query = proto.Query('_FileChunk')\n .sort({ start: 1 })\n .filter({\n token: { $eq: token },\n ...start ? { end: { $gt: start } } : {},\n ...end ? { start: { $lt: end } } : {},\n });\n for await (const chunk of query.find({ master: true })) {\n const startBytes = chunk.get('start');\n const base64 = chunk.get('base64');\n if (!_.isNumber(startBytes) || !_.isString(base64)) throw Error('Corrupted data');\n yield {\n start: startBytes,\n data: base64ToBuffer(base64),\n };\n }\n }\n\n async destroy<E>(proto: ProtoService<E>, token: string) {\n proto.storage.
|
|
1
|
+
{"version":3,"file":"database.mjs","sources":["../../../../src/adapters/file/database/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 { TSchema } from '../../../internals/schema';\nimport FileStorageBase, { FileStorageOptions } from '../base';\nimport { QuerySelector } from '../../../server/query/dispatcher/parser';\nimport { base64ToBuffer, bufferToBase64 } from '@o2ter/utils-js';\n\nexport class DatabaseFileStorage extends FileStorageBase {\n\n constructor(options: FileStorageOptions = {}) {\n super(options);\n }\n\n get schema(): Record<string, TSchema> {\n return {\n '_FileChunk': {\n fields: {\n token: 'string',\n start: 'number',\n end: 'number',\n size: 'number',\n base64: 'string',\n },\n classLevelPermissions: {\n get: [],\n find: [],\n count: [],\n create: [],\n update: [],\n delete: [],\n },\n fieldLevelPermissions: {\n _expired_at: { create: [], update: [] },\n },\n indexes: [\n { keys: { token: 1, start: 1, end: 1 } },\n { keys: { token: 1, end: 1 } },\n ]\n },\n }\n }\n\n async createChunk<E>(proto: ProtoService<E>, token: string, start: number, end: number, compressed: Buffer) {\n\n const created = await proto.Query('_FileChunk').insert({\n token,\n start: start,\n end: end,\n size: end - start,\n base64: bufferToBase64(compressed),\n }, { master: true });\n\n if (!created) throw Error('Unable to save file');\n\n }\n\n async* readChunks<E>(proto: ProtoService<E>, token: string, start?: number | undefined, end?: number | undefined) {\n const query = proto.Query('_FileChunk')\n .sort({ start: 1 })\n .filter({\n token: { $eq: token },\n ...start ? { end: { $gt: start } } : {},\n ...end ? { start: { $lt: end } } : {},\n });\n for await (const chunk of query.find({ master: true })) {\n const startBytes = chunk.get('start');\n const base64 = chunk.get('base64');\n if (!_.isNumber(startBytes) || !_.isString(base64)) throw Error('Corrupted data');\n yield {\n start: startBytes,\n data: base64ToBuffer(base64),\n };\n }\n }\n\n async destroy<E>(proto: ProtoService<E>, token: string) {\n proto.storage.delete({\n className: '_FileChunk',\n filter: QuerySelector.decode({ token: { $eq: token } }),\n includes: ['_id'],\n matches: {},\n countMatches: [],\n objectIdSize: 0\n });\n }\n};\n\nexport default DatabaseFileStorage;"],"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;AASM,MAAO,mBAAoB,SAAQ,eAAe,CAAA;AAEtD,IAAA,WAAA,CAAY,UAA8B,EAAE,EAAA;QAC1C,KAAK,CAAC,OAAO,CAAC;;AAGhB,IAAA,IAAI,MAAM,GAAA;QACR,OAAO;AACL,YAAA,YAAY,EAAE;AACZ,gBAAA,MAAM,EAAE;AACN,oBAAA,KAAK,EAAE,QAAQ;AACf,oBAAA,KAAK,EAAE,QAA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Y,EAAE;AACf,SAAA,CAAC;;AAEL;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as ProtoService } from '../../internals/index-
|
|
2
|
-
import { a as FileStorageOptions } from '../../internals/base-
|
|
3
|
-
import { F as FileChunkStorageBase } from '../../internals/chunk-
|
|
1
|
+
import { P as ProtoService } from '../../internals/index-A-hoMfDO.js';
|
|
2
|
+
import { a as FileStorageOptions } from '../../internals/base-wSknxBv7.js';
|
|
3
|
+
import { F as FileChunkStorageBase } from '../../internals/chunk-C_BXf1Er.js';
|
|
4
4
|
import '@o2ter/utils-js';
|
|
5
5
|
import 'jsonwebtoken';
|
|
6
6
|
import '@o2ter/server-js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as _google_cloud_storage from '@google-cloud/storage';
|
|
2
2
|
import { File, Storage } from '@google-cloud/storage';
|
|
3
|
-
import { P as ProtoService } from '../../internals/index-
|
|
4
|
-
import { a as FileStorageOptions } from '../../internals/base-
|
|
5
|
-
import { F as FileChunkStorageBase } from '../../internals/chunk-
|
|
3
|
+
import { P as ProtoService } from '../../internals/index-A-hoMfDO.js';
|
|
4
|
+
import { a as FileStorageOptions } from '../../internals/base-wSknxBv7.js';
|
|
5
|
+
import { F as FileChunkStorageBase } from '../../internals/chunk-C_BXf1Er.js';
|
|
6
6
|
import '@o2ter/utils-js';
|
|
7
7
|
import 'jsonwebtoken';
|
|
8
8
|
import '@o2ter/server-js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Pool, PoolClient, PoolConfig } from 'pg';
|
|
2
|
-
import { a as TValueWithoutObject, T as TSchema, u as TValueWithUndefined, v as TValue, w as TUpdateOp, F as FieldSelectorExpression, Q as QueryExpression, R as RelationOptions, x as QuerySelector, y as DecodedSortOption, z as DecodedQuery, A as FindOptions, I as InsertOptions, B as
|
|
2
|
+
import { a as TValueWithoutObject, T as TSchema, u as TValueWithUndefined, v as TValue, w as TUpdateOp, F as FieldSelectorExpression, Q as QueryExpression, R as RelationOptions, x as QuerySelector, y as DecodedSortOption, z as DecodedQuery, A as FindOptions, I as InsertOptions, B as TStorage, C as TransactionOptions, j as TObject, G as TQueryRandomOptions, H as TPubSub } from '../../internals/index-A-hoMfDO.js';
|
|
3
3
|
import * as _o2ter_utils_js from '@o2ter/utils-js';
|
|
4
4
|
import { asyncStream } from '@o2ter/utils-js';
|
|
5
5
|
import 'jsonwebtoken';
|
|
@@ -149,14 +149,10 @@ declare class QueryCompiler {
|
|
|
149
149
|
private _selectIncludes;
|
|
150
150
|
_encodeSort(sort: Record<string, 1 | -1> | DecodedSortOption[], parent: QueryContext): SQL;
|
|
151
151
|
private _selectPopulateMap;
|
|
152
|
-
insert(options: InsertOptions,
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
upsertOne(query: DecodedQuery<FindOneOptions>, update: Record<string, TUpdateOp>, setOnInsert: Record<string, TValueWithUndefined>): SQL;
|
|
157
|
-
upsertMany(query: DecodedQuery<FindOneOptions>, update: Record<string, TUpdateOp>, setOnInsert: Record<string, TValueWithUndefined>): SQL;
|
|
158
|
-
deleteOne(query: DecodedQuery<FindOneOptions>): SQL;
|
|
159
|
-
deleteMany(query: DecodedQuery<FindOptions>): SQL;
|
|
152
|
+
insert(options: InsertOptions, values: Record<string, TValueWithUndefined>[]): SQL;
|
|
153
|
+
update(query: DecodedQuery<FindOptions>, update: Record<string, TUpdateOp>): SQL;
|
|
154
|
+
upsert(query: DecodedQuery<FindOptions>, update: Record<string, TUpdateOp>, setOnInsert: Record<string, TValueWithUndefined>): SQL;
|
|
155
|
+
delete(query: DecodedQuery<FindOptions>): SQL;
|
|
160
156
|
}
|
|
161
157
|
|
|
162
158
|
declare abstract class SqlStorage implements TStorage {
|
|
@@ -190,14 +186,10 @@ declare abstract class SqlStorage implements TStorage {
|
|
|
190
186
|
random(query: DecodedQuery<FindOptions & RelationOptions>, opts?: TQueryRandomOptions): AsyncGenerator<TObject, void, unknown>;
|
|
191
187
|
refs(object: TObject, classNames: string[], roles?: string[]): AsyncGenerator<TObject, void, unknown>;
|
|
192
188
|
nonrefs(query: DecodedQuery<FindOptions>): AsyncGenerator<TObject, void, unknown>;
|
|
193
|
-
insert(options: InsertOptions,
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
upsertOne(query: DecodedQuery<FindOneOptions>, update: Record<string, TUpdateOp>, setOnInsert: Record<string, TValueWithUndefined>): Promise<TObject | undefined>;
|
|
198
|
-
upsertMany(query: DecodedQuery<FindOptions>, update: Record<string, TUpdateOp>, setOnInsert: Record<string, TValueWithUndefined>): Promise<TObject[]>;
|
|
199
|
-
deleteOne(query: DecodedQuery<FindOneOptions>): Promise<TObject | undefined>;
|
|
200
|
-
deleteMany(query: DecodedQuery<FindOptions>): Promise<TObject[]>;
|
|
189
|
+
insert(options: InsertOptions, values: Record<string, TValueWithUndefined>[]): Promise<TObject[]>;
|
|
190
|
+
update(query: DecodedQuery<FindOptions>, update: Record<string, TUpdateOp>): Promise<TObject[]>;
|
|
191
|
+
upsert(query: DecodedQuery<FindOptions>, update: Record<string, TUpdateOp>, setOnInsert: Record<string, TValueWithUndefined>): Promise<TObject[]>;
|
|
192
|
+
delete(query: DecodedQuery<FindOptions>): Promise<TObject[]>;
|
|
201
193
|
}
|
|
202
194
|
|
|
203
195
|
declare class PostgresStorageClient<Driver extends PostgresClientDriver> extends SqlStorage implements TPubSub {
|
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var _ = require('lodash');
|
|
6
|
-
var index = require('../../internals/index-
|
|
6
|
+
var index = require('../../internals/index-B8TESzd9.js');
|
|
7
7
|
var pg = require('pg');
|
|
8
8
|
var QueryStream = require('pg-query-stream');
|
|
9
9
|
var utilsJs = require('@o2ter/utils-js');
|
|
10
10
|
var Decimal = require('decimal.js');
|
|
11
11
|
var utils = require('pg/lib/utils');
|
|
12
|
-
var index$1 = require('../../internals/index-
|
|
12
|
+
var index$1 = require('../../internals/index-CkAvNaAe.js');
|
|
13
13
|
require('@o2ter/crypto-js');
|
|
14
|
-
var random$1 = require('../../internals/random-
|
|
14
|
+
var random$1 = require('../../internals/random-B0V0EnjP.js');
|
|
15
15
|
var _private = require('../../internals/private-Ciddhure.js');
|
|
16
16
|
|
|
17
17
|
//
|
|
@@ -431,11 +431,12 @@ class QueryCompiler {
|
|
|
431
431
|
_selectPopulateMap(context) {
|
|
432
432
|
return _.map(context.populates, (populate, field) => this.dialect.selectPopulate(this, context, populate, field, _.includes(context.countMatches, field)));
|
|
433
433
|
}
|
|
434
|
-
insert(options,
|
|
435
|
-
const
|
|
434
|
+
insert(options, values) {
|
|
435
|
+
const _values = _.map(values, attr => ({
|
|
436
436
|
..._defaultInsertOpts(options),
|
|
437
|
-
...this._encodeObjectAttrs(options.className,
|
|
438
|
-
});
|
|
437
|
+
...this._encodeObjectAttrs(options.className, attr),
|
|
438
|
+
}));
|
|
439
|
+
const keys = _.uniq(_.flatMap(_values, x => _.keys(x)));
|
|
439
440
|
const name = `_insert_$${options.className.toLowerCase()}`;
|
|
440
441
|
const context = { ...this._encodeIncludes(options), name };
|
|
441
442
|
const populates = _.mapValues(context.populates, (populate) => this.dialect.encodePopulate(this, populate));
|
|
@@ -445,8 +446,8 @@ class QueryCompiler {
|
|
|
445
446
|
return sql `
|
|
446
447
|
WITH ${{ identifier: name }} AS (
|
|
447
448
|
INSERT INTO ${{ identifier: options.className }}
|
|
448
|
-
(${_.map(
|
|
449
|
-
VALUES (${_.map(
|
|
449
|
+
(${_.map(keys, x => sql `${{ identifier: x }}`)})
|
|
450
|
+
VALUES ${_.map(_values, v => sql `(${_.map(keys, k => sql `${v[k]}`)})`)}
|
|
450
451
|
RETURNING *
|
|
451
452
|
)${!_.isEmpty(stages) ? sql `, ${_.map(stages, (q, n) => sql `${{ identifier: n }} AS (${q})`)}` : sql ``}
|
|
452
453
|
SELECT ${{
|
|
@@ -459,21 +460,8 @@ class QueryCompiler {
|
|
|
459
460
|
${!_.isEmpty(joins) ? { literal: joins, separator: '\n' } : sql ``}
|
|
460
461
|
`;
|
|
461
462
|
}
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
..._defaultInsertOpts(options),
|
|
465
|
-
...this._encodeObjectAttrs(options.className, attr),
|
|
466
|
-
}));
|
|
467
|
-
const keys = _.uniq(_.flatMap(_values, x => _.keys(x)));
|
|
468
|
-
return sql `
|
|
469
|
-
INSERT INTO ${{ identifier: options.className }}
|
|
470
|
-
(${_.map(keys, x => sql `${{ identifier: x }}`)})
|
|
471
|
-
VALUES ${_.map(_values, v => sql `(${_.map(keys, k => sql `${v[k]}`)})`)}
|
|
472
|
-
RETURNING ${_.map(index.defaultObjectKeys, k => sql `${{ identifier: k }}`)}
|
|
473
|
-
`;
|
|
474
|
-
}
|
|
475
|
-
updateOne(query, update) {
|
|
476
|
-
return this._modifyQuery({ ...query, limit: 1 }, (fetchName) => {
|
|
463
|
+
update(query, update) {
|
|
464
|
+
return this._modifyQuery(query, (fetchName) => {
|
|
477
465
|
const name = `_update_$${query.className.toLowerCase()}`;
|
|
478
466
|
return sql `
|
|
479
467
|
, ${{ identifier: name }} AS (
|
|
@@ -486,22 +474,12 @@ class QueryCompiler {
|
|
|
486
474
|
`;
|
|
487
475
|
});
|
|
488
476
|
}
|
|
489
|
-
|
|
490
|
-
return this._modifyQuery(query, (fetchName) => {
|
|
491
|
-
return sql `
|
|
492
|
-
UPDATE ${{ identifier: query.className }}
|
|
493
|
-
SET ${this._encodeUpdateAttrs(query.className, update)}
|
|
494
|
-
WHERE ${{ identifier: query.className }}._id IN (SELECT ${{ identifier: fetchName }}._id FROM ${{ identifier: fetchName }})
|
|
495
|
-
RETURNING ${_.map(index.defaultObjectKeys, k => sql `${{ identifier: k }}`)}
|
|
496
|
-
`;
|
|
497
|
-
});
|
|
498
|
-
}
|
|
499
|
-
upsertOne(query, update, setOnInsert) {
|
|
477
|
+
upsert(query, update, setOnInsert) {
|
|
500
478
|
const _insert = _.toPairs({
|
|
501
479
|
..._defaultInsertOpts(query),
|
|
502
480
|
...this._encodeObjectAttrs(query.className, setOnInsert),
|
|
503
481
|
});
|
|
504
|
-
return this._modifyQuery(
|
|
482
|
+
return this._modifyQuery(query, (fetchName) => {
|
|
505
483
|
const updateName = `_update_$${query.className.toLowerCase()}`;
|
|
506
484
|
const insertName = `_insert_$${query.className.toLowerCase()}`;
|
|
507
485
|
const upsertName = `_upsert_$${query.className.toLowerCase()}`;
|
|
@@ -528,36 +506,8 @@ class QueryCompiler {
|
|
|
528
506
|
`;
|
|
529
507
|
});
|
|
530
508
|
}
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
..._defaultInsertOpts(query),
|
|
534
|
-
...this._encodeObjectAttrs(query.className, setOnInsert),
|
|
535
|
-
});
|
|
536
|
-
return this._modifyQuery(query, (fetchName) => {
|
|
537
|
-
const updateName = `_update_$${query.className.toLowerCase()}`;
|
|
538
|
-
const insertName = `_insert_$${query.className.toLowerCase()}`;
|
|
539
|
-
return sql `
|
|
540
|
-
, ${{ identifier: updateName }} AS (
|
|
541
|
-
UPDATE ${{ identifier: query.className }}
|
|
542
|
-
SET ${this._encodeUpdateAttrs(query.className, update)}
|
|
543
|
-
WHERE ${{ identifier: query.className }}._id IN (SELECT ${{ identifier: fetchName }}._id FROM ${{ identifier: fetchName }})
|
|
544
|
-
RETURNING ${_.map(index.defaultObjectKeys, k => sql `${{ identifier: k }}`)}
|
|
545
|
-
)
|
|
546
|
-
, ${{ identifier: insertName }} AS (
|
|
547
|
-
INSERT INTO ${{ identifier: query.className }}
|
|
548
|
-
(${_.map(_insert, x => sql `${{ identifier: x[0] }}`)})
|
|
549
|
-
SELECT ${_.map(_insert, x => sql `${x[1]} AS ${{ identifier: x[0] }}`)}
|
|
550
|
-
WHERE NOT EXISTS(SELECT * FROM ${{ identifier: updateName }})
|
|
551
|
-
RETURNING ${_.map(index.defaultObjectKeys, k => sql `${{ identifier: k }}`)}
|
|
552
|
-
)
|
|
553
|
-
SELECT * FROM ${{ identifier: updateName }}
|
|
554
|
-
UNION
|
|
555
|
-
SELECT * FROM ${{ identifier: insertName }}
|
|
556
|
-
`;
|
|
557
|
-
});
|
|
558
|
-
}
|
|
559
|
-
deleteOne(query) {
|
|
560
|
-
return this._modifyQuery({ ...query, limit: 1 }, (fetchName, context) => {
|
|
509
|
+
delete(query) {
|
|
510
|
+
return this._modifyQuery(query, (fetchName, context) => {
|
|
561
511
|
const name = `_delete_$${query.className.toLowerCase()}`;
|
|
562
512
|
const populates = this._selectPopulateMap({ ...context, name });
|
|
563
513
|
const joins = _.compact(_.map(populates, ({ join }) => join));
|
|
@@ -578,13 +528,6 @@ class QueryCompiler {
|
|
|
578
528
|
`;
|
|
579
529
|
});
|
|
580
530
|
}
|
|
581
|
-
deleteMany(query) {
|
|
582
|
-
return this._modifyQuery(query, (fetchName) => sql `
|
|
583
|
-
DELETE FROM ${{ identifier: query.className }}
|
|
584
|
-
WHERE ${{ identifier: query.className }}._id IN (SELECT ${{ identifier: fetchName }}._id FROM ${{ identifier: fetchName }})
|
|
585
|
-
RETURNING ${_.map(index.defaultObjectKeys, k => sql `${{ identifier: k }}`)}
|
|
586
|
-
`);
|
|
587
|
-
}
|
|
588
531
|
}
|
|
589
532
|
|
|
590
533
|
//
|
|
@@ -765,44 +708,24 @@ class SqlStorage {
|
|
|
765
708
|
}
|
|
766
709
|
})();
|
|
767
710
|
}
|
|
768
|
-
async insert(options,
|
|
769
|
-
const compiler = this._makeCompiler(true);
|
|
770
|
-
const result = _.first(await this.query(compiler.insert(options, attrs)));
|
|
771
|
-
return _.isNil(result) ? undefined : this._decodeObject(options.className, result);
|
|
772
|
-
}
|
|
773
|
-
async insertMany(options, values) {
|
|
711
|
+
async insert(options, values) {
|
|
774
712
|
const compiler = this._makeCompiler(true);
|
|
775
|
-
const result = await this.query(compiler.
|
|
713
|
+
const result = await this.query(compiler.insert(options, values));
|
|
776
714
|
return _.map(result, x => this._decodeObject(options.className, x));
|
|
777
715
|
}
|
|
778
|
-
async
|
|
716
|
+
async update(query, update) {
|
|
779
717
|
const compiler = this._makeCompiler(true, query.extraFilter);
|
|
780
|
-
const updated =
|
|
781
|
-
return _.isNil(updated) ? undefined : this._decodeObject(query.className, updated);
|
|
782
|
-
}
|
|
783
|
-
async updateMany(query, update) {
|
|
784
|
-
const compiler = this._makeCompiler(true, query.extraFilter);
|
|
785
|
-
const updated = await this.query(compiler.updateMany(query, update));
|
|
718
|
+
const updated = await this.query(compiler.update(query, update));
|
|
786
719
|
return _.map(updated, x => this._decodeObject(query.className, x));
|
|
787
720
|
}
|
|
788
|
-
async
|
|
789
|
-
const compiler = this._makeCompiler(true, query.extraFilter);
|
|
790
|
-
const upserted = _.first(await this.query(compiler.upsertOne(query, update, setOnInsert)));
|
|
791
|
-
return _.isNil(upserted) ? undefined : this._decodeObject(query.className, upserted);
|
|
792
|
-
}
|
|
793
|
-
async upsertMany(query, update, setOnInsert) {
|
|
721
|
+
async upsert(query, update, setOnInsert) {
|
|
794
722
|
const compiler = this._makeCompiler(true, query.extraFilter);
|
|
795
|
-
const upserted = await this.query(compiler.
|
|
723
|
+
const upserted = await this.query(compiler.upsert(query, update, setOnInsert));
|
|
796
724
|
return _.map(upserted, x => this._decodeObject(query.className, x));
|
|
797
725
|
}
|
|
798
|
-
async
|
|
799
|
-
const compiler = this._makeCompiler(true, query.extraFilter);
|
|
800
|
-
const deleted = _.first(await this.query(compiler.deleteOne(query)));
|
|
801
|
-
return _.isNil(deleted) ? undefined : this._decodeObject(query.className, deleted);
|
|
802
|
-
}
|
|
803
|
-
async deleteMany(query) {
|
|
726
|
+
async delete(query) {
|
|
804
727
|
const compiler = this._makeCompiler(true, query.extraFilter);
|
|
805
|
-
const deleted = await this.query(compiler.
|
|
728
|
+
const deleted = await this.query(compiler.delete(query));
|
|
806
729
|
return _.map(deleted, x => this._decodeObject(query.className, x));
|
|
807
730
|
}
|
|
808
731
|
}
|