proto.io 0.0.211 → 0.0.212
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 +1 -1
- 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 +8 -6
- package/dist/adapters/storage/progres.js +142 -78
- package/dist/adapters/storage/progres.js.map +1 -1
- package/dist/adapters/storage/progres.mjs +143 -79
- package/dist/adapters/storage/progres.mjs.map +1 -1
- package/dist/client.d.ts +3 -3
- package/dist/client.js +1 -1
- package/dist/client.mjs +2 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -10
- package/dist/index.mjs.map +1 -1
- package/dist/internals/{base-BCWOHUaQ.d.ts → base-CZGalGrd.d.ts} +2 -2
- package/dist/internals/base-CZGalGrd.d.ts.map +1 -0
- package/dist/internals/{chunk-2pKgkO5-.d.ts → chunk-BsT9SYny.d.ts} +3 -3
- package/dist/internals/chunk-BsT9SYny.d.ts.map +1 -0
- package/dist/internals/{index-lTzbCO8S.d.ts → index-Boxwkqe0.d.ts} +32 -15
- package/dist/internals/index-Boxwkqe0.d.ts.map +1 -0
- package/dist/internals/{index-DPPLcZx8.mjs → index-DG9HHO_U.mjs} +2 -2
- package/dist/internals/{index-DPPLcZx8.mjs.map → index-DG9HHO_U.mjs.map} +1 -1
- package/dist/internals/{index-Btxxs0KS.js → index-DfnPpl1I.js} +16 -10
- package/dist/internals/index-DfnPpl1I.js.map +1 -0
- package/dist/internals/{index-8AdKlZUU.d.ts → index-NF-U_3zG.d.ts} +2 -2
- package/dist/internals/index-NF-U_3zG.d.ts.map +1 -0
- package/dist/internals/{index-CoeDMG5V.mjs → index-ZPbBr9Db.mjs} +16 -10
- package/dist/internals/index-ZPbBr9Db.mjs.map +1 -0
- package/dist/internals/{random-ycCeBd0S.mjs → random-CufRbivU.mjs} +121 -19
- package/dist/internals/random-CufRbivU.mjs.map +1 -0
- package/dist/internals/{random-CyU_Y2Ay.js → random-DzvxbWAc.js} +161 -58
- package/dist/internals/random-DzvxbWAc.js.map +1 -0
- package/package.json +1 -1
- package/dist/internals/base-BCWOHUaQ.d.ts.map +0 -1
- package/dist/internals/chunk-2pKgkO5-.d.ts.map +0 -1
- package/dist/internals/index-8AdKlZUU.d.ts.map +0 -1
- package/dist/internals/index-Btxxs0KS.js.map +0 -1
- package/dist/internals/index-CoeDMG5V.mjs.map +0 -1
- package/dist/internals/index-lTzbCO8S.d.ts.map +0 -1
- package/dist/internals/random-CyU_Y2Ay.js.map +0 -1
- package/dist/internals/random-ycCeBd0S.mjs.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { P as ProtoService } from '../../internals/index-
|
|
1
|
+
import { P as ProtoService } from '../../internals/index-Boxwkqe0.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-CZGalGrd.js';
|
|
4
|
+
import { F as FileChunkStorageBase } from '../../internals/chunk-BsT9SYny.js';
|
|
5
5
|
import '@o2ter/utils-js';
|
|
6
6
|
import 'jsonwebtoken';
|
|
7
7
|
import '@o2ter/server-js';
|
|
@@ -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-Boxwkqe0.js';
|
|
2
|
+
import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/base-CZGalGrd.js';
|
|
3
3
|
import '@o2ter/utils-js';
|
|
4
4
|
import 'jsonwebtoken';
|
|
5
5
|
import '@o2ter/server-js';
|
|
@@ -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, end?: number) {\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
|
|
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, end?: number) {\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 groupMatches: {},\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,EAAE,QAAQ;AACjB,iBAAA;AACD,gBAAA,qBAAqB,EAAE;AACrB,oBAAA,GAAG,EAAE,EAAE;AACP,oBAAA,IAAI,EAAE,EAAE;AACR,oBAAA,KAAK,EAAE,EAAE;AACT,oBAAA,MAAM,EAAE,EAAE;AACV,oBAAA,MAAM,EAAE,EAAE;AACV,oBAAA,MAAM,EAAE,EAAE;AACX,iBAAA;AACD,gBAAA,qBAAqB,EAAE;oBACrB,WAAW,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;A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AAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE;YACtD,MAAM,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC;YACrC,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC;AAClC,YAAA,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC;AAAE,gBAAA,MAAM,KAAK,CAAC,gBAAgB,CAAC;YACjF,MAAM;AACJ,gBAAA,KAAK,EAAE,UAAU;AACjB,gBAAA,IAAI,EAAEC,sBAAc,CAAC,MAAM,CAAC;aAC7B;;;AAIL,IAAA,MAAM,OAAO,CAAI,KAAsB,EAAE,KAAa,EAAA;AACpD,QAAA,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;AACnB,YAAA,SAAS,EAAE,YAAY;AACvB,YAAA,MAAM,EAAEC,mBAAa,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC;YACvD,QAAQ,EAAE,CAAC,KAAK,CAAC;AACjB,YAAA,OAAO,EAAE,EAAE;AACX,YAAA,YAAY,EAAE,EAAE;AAChB,YAAA,YAAY,EAAE;AACf,SAAA,CAAC;;AAEL;;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import { F as FileStorageBase } from '../../internals/base-DYc1_peK.mjs';
|
|
3
3
|
import { bufferToBase64, base64ToBuffer } from '@o2ter/utils-js';
|
|
4
|
-
import { Q as QuerySelector } from '../../internals/index-
|
|
4
|
+
import { Q as QuerySelector } from '../../internals/index-DG9HHO_U.mjs';
|
|
5
5
|
import 'util';
|
|
6
6
|
import 'zlib';
|
|
7
7
|
import '../../internals/private-CNw40LZ7.mjs';
|
|
@@ -100,7 +100,7 @@ class DatabaseFileStorage extends FileStorageBase {
|
|
|
100
100
|
filter: QuerySelector.decode({ token: { $eq: token } }),
|
|
101
101
|
includes: ['_id'],
|
|
102
102
|
matches: {},
|
|
103
|
-
|
|
103
|
+
groupMatches: {},
|
|
104
104
|
objectIdSize: 0
|
|
105
105
|
});
|
|
106
106
|
}
|
|
@@ -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, end?: number) {\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
|
|
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, end?: number) {\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 groupMatches: {},\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,QAAQ;AACf,oBAAA,GAAG,EAAE,QAAQ;AACb,oBAAA,IAAI,EAAE,QAAQ;AACd,oBAAA,MAAM,EAAE,QAAQ;AACjB,iBAAA;AACD,gBAAA,qBAAqB,EAAE;AACrB,oBAAA,GAAG,EAAE,EAAE;AACP,oBAAA,IAAI,EAAE,EAAE;AACR,oBAAA,KAAK,EAAE,EAAE;AACT,oBAAA,MAAM,EAAE,EAAE;AACV,oBAAA,MAAM,EAAE,EAAE;AACV,oBAAA,MAAM,EAAE,EAAE;AACX,iBAAA;AACD,gBAAA,qBAAqB,EAAE;oBACrB,WAAW,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EA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,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE;YACtD,MAAM,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC;YACrC,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC;AAClC,YAAA,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC;AAAE,gBAAA,MAAM,KAAK,CAAC,gBAAgB,CAAC;YACjF,MAAM;AACJ,gBAAA,KAAK,EAAE,UAAU;AACjB,gBAAA,IAAI,EAAE,cAAc,CAAC,MAAM,CAAC;aAC7B;;;AAIL,IAAA,MAAM,OAAO,CAAI,KAAsB,EAAE,KAAa,EAAA;AACpD,QAAA,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;AACnB,YAAA,SAAS,EAAE,YAAY;AACvB,YAAA,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC;YACvD,QAAQ,EAAE,CAAC,KAAK,CAAC;AACjB,YAAA,OAAO,EAAE,EAAE;AACX,YAAA,YAAY,EAAE,EAAE;AAChB,YAAA,YAAY,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-Boxwkqe0.js';
|
|
2
|
+
import { a as FileStorageOptions } from '../../internals/base-CZGalGrd.js';
|
|
3
|
+
import { F as FileChunkStorageBase } from '../../internals/chunk-BsT9SYny.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-Boxwkqe0.js';
|
|
4
|
+
import { a as FileStorageOptions } from '../../internals/base-CZGalGrd.js';
|
|
5
|
+
import { F as FileChunkStorageBase } from '../../internals/chunk-BsT9SYny.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
|
|
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 QueryAccumulator, y as QuerySelector, z as DecodedSortOption, A as DecodedQuery, B as FindOptions, I as InsertOptions, C as TStorage, G as TransactionOptions, j as TObject, H as TQueryRandomOptions, J as TPubSub } from '../../internals/index-Boxwkqe0.js';
|
|
3
3
|
import * as _o2ter_utils_js from '@o2ter/utils-js';
|
|
4
4
|
import { asyncStream } from '@o2ter/utils-js';
|
|
5
5
|
import 'jsonwebtoken';
|
|
@@ -56,7 +56,7 @@ interface SqlDialect {
|
|
|
56
56
|
updateOperation(paths: string[], dataType: TSchema.DataType, operation: TUpdateOp): SQL;
|
|
57
57
|
selectPopulate(compiler: QueryCompiler, parent: QueryContext & {
|
|
58
58
|
className: string;
|
|
59
|
-
}, populate: Populate, field: string
|
|
59
|
+
}, populate: Populate, field: string): {
|
|
60
60
|
columns: SQL[];
|
|
61
61
|
join?: SQL;
|
|
62
62
|
};
|
|
@@ -103,7 +103,7 @@ type QueryContext = {
|
|
|
103
103
|
className?: string;
|
|
104
104
|
includes?: Record<string, TSchema.DataType>;
|
|
105
105
|
populates?: Record<string, Populate>;
|
|
106
|
-
|
|
106
|
+
groupMatches?: Record<string, Record<string, QueryAccumulator>>;
|
|
107
107
|
};
|
|
108
108
|
type Populate = Required<QueryContext> & {
|
|
109
109
|
colname: string;
|
|
@@ -146,7 +146,7 @@ declare class QueryCompiler {
|
|
|
146
146
|
private _encodeObjectAttrs;
|
|
147
147
|
private _encodeCoditionalSelector;
|
|
148
148
|
_encodeFilter(parent: QueryContext, filter: QuerySelector): SQL | undefined;
|
|
149
|
-
|
|
149
|
+
_selectIncludes(className: string, includes: Record<string, TSchema.DataType>): SQL[];
|
|
150
150
|
_encodeSort(sort: Record<string, 1 | -1> | DecodedSortOption[], parent: QueryContext): SQL;
|
|
151
151
|
private _selectPopulateMap;
|
|
152
152
|
insert(options: InsertOptions, values: Record<string, TValueWithUndefined>[]): SQL;
|
|
@@ -177,11 +177,13 @@ declare abstract class SqlStorage implements TStorage {
|
|
|
177
177
|
abstract _refs(schema: Record<string, TSchema>, className: string, keys: string[], item: SQL): SQL;
|
|
178
178
|
query(sql: SQL): _o2ter_utils_js.AsyncStream<any>;
|
|
179
179
|
abstract _explain(compiler: QueryCompiler, query: DecodedQuery<FindOptions & RelationOptions>): PromiseLike<any>;
|
|
180
|
+
private _decodeMatchTypes;
|
|
180
181
|
private _decodeShapedObject;
|
|
181
|
-
protected _decodeObject(className: string, attrs: Record<string, any>): TObject;
|
|
182
|
+
protected _decodeObject(className: string, attrs: Record<string, any>, matchesType: Record<string, any>): TObject;
|
|
182
183
|
private _makeCompiler;
|
|
183
184
|
explain(query: DecodedQuery<FindOptions & RelationOptions>): Promise<any>;
|
|
184
185
|
count(query: DecodedQuery<FindOptions & RelationOptions>): Promise<number>;
|
|
186
|
+
private _matchesType;
|
|
185
187
|
find(query: DecodedQuery<FindOptions & RelationOptions>): AsyncGenerator<TObject, void, unknown>;
|
|
186
188
|
random(query: DecodedQuery<FindOptions & RelationOptions>, opts?: TQueryRandomOptions): AsyncGenerator<TObject, void, unknown>;
|
|
187
189
|
refs(object: TObject, classNames: string[], roles?: string[]): AsyncGenerator<TObject, void, unknown>;
|
|
@@ -205,7 +207,7 @@ declare class PostgresStorageClient<Driver extends PostgresClientDriver> extends
|
|
|
205
207
|
updateOperation: (paths: string[], dataType: TSchema.DataType, operation: TUpdateOp) => SQL;
|
|
206
208
|
selectPopulate: (compiler: QueryCompiler, parent: QueryContext & {
|
|
207
209
|
className: string;
|
|
208
|
-
}, populate: Populate, field: string
|
|
210
|
+
}, populate: Populate, field: string) => {
|
|
209
211
|
columns: SQL[];
|
|
210
212
|
join?: SQL;
|
|
211
213
|
};
|