proto.io 0.0.207 → 0.0.209

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.
Files changed (58) hide show
  1. package/dist/adapters/file/aliyun-oss.d.ts +6 -6
  2. package/dist/adapters/file/aliyun-oss.js +16 -15
  3. package/dist/adapters/file/aliyun-oss.js.map +1 -1
  4. package/dist/adapters/file/aliyun-oss.mjs +16 -15
  5. package/dist/adapters/file/aliyun-oss.mjs.map +1 -1
  6. package/dist/adapters/file/database.d.ts +3 -3
  7. package/dist/adapters/file/database.js +2 -2
  8. package/dist/adapters/file/database.js.map +1 -1
  9. package/dist/adapters/file/database.mjs +2 -2
  10. package/dist/adapters/file/database.mjs.map +1 -1
  11. package/dist/adapters/file/filesystem.d.ts +5 -5
  12. package/dist/adapters/file/filesystem.js +11 -7
  13. package/dist/adapters/file/filesystem.js.map +1 -1
  14. package/dist/adapters/file/filesystem.mjs +11 -7
  15. package/dist/adapters/file/filesystem.mjs.map +1 -1
  16. package/dist/adapters/file/google-cloud-storage.d.ts +6 -6
  17. package/dist/adapters/file/google-cloud-storage.js +23 -13
  18. package/dist/adapters/file/google-cloud-storage.js.map +1 -1
  19. package/dist/adapters/file/google-cloud-storage.mjs +23 -13
  20. package/dist/adapters/file/google-cloud-storage.mjs.map +1 -1
  21. package/dist/adapters/storage/progres.d.ts +1 -1
  22. package/dist/client.d.ts +3 -3
  23. package/dist/client.js +1 -1
  24. package/dist/client.mjs +2 -2
  25. package/dist/index.d.ts +3 -3
  26. package/dist/index.js +127 -49
  27. package/dist/index.js.map +1 -1
  28. package/dist/index.mjs +129 -51
  29. package/dist/index.mjs.map +1 -1
  30. package/dist/internals/{base-CfQi0T0I.mjs → base-DYc1_peK.mjs} +3 -3
  31. package/dist/internals/{base-CfQi0T0I.mjs.map → base-DYc1_peK.mjs.map} +1 -1
  32. package/dist/internals/{base-DHkvlTFy.d.ts → base-DbSaGX_u.d.ts} +2 -2
  33. package/dist/internals/base-DbSaGX_u.d.ts.map +1 -0
  34. package/dist/internals/{base-BFKQpiws.js → base-NsJYo2MG.js} +3 -3
  35. package/dist/internals/{base-BFKQpiws.js.map → base-NsJYo2MG.js.map} +1 -1
  36. package/dist/internals/{chunk-BuMQw4dz.js → chunk-BuKmyceG.js} +5 -3
  37. package/dist/internals/chunk-BuKmyceG.js.map +1 -0
  38. package/dist/internals/{chunk-C7kDLOLD.d.ts → chunk-bYrnqXiI.d.ts} +6 -6
  39. package/dist/internals/chunk-bYrnqXiI.d.ts.map +1 -0
  40. package/dist/internals/{chunk-DxYhYVky.mjs → chunk-bpt1C6W4.mjs} +5 -3
  41. package/dist/internals/chunk-bpt1C6W4.mjs.map +1 -0
  42. package/dist/internals/{index-BRzKDwPs.js → index-CK1snZyh.js} +19 -17
  43. package/dist/internals/index-CK1snZyh.js.map +1 -0
  44. package/dist/internals/{index-PLz89AWF.d.ts → index-Dn1IkLDx.d.ts} +48 -2
  45. package/dist/internals/index-Dn1IkLDx.d.ts.map +1 -0
  46. package/dist/internals/{index-CKcESGqE.d.ts → index-Dx36qTUa.d.ts} +2 -2
  47. package/dist/internals/index-Dx36qTUa.d.ts.map +1 -0
  48. package/dist/internals/{index-DAkcqabS.mjs → index-Eo70ZAdZ.mjs} +19 -18
  49. package/dist/internals/index-Eo70ZAdZ.mjs.map +1 -0
  50. package/package.json +1 -1
  51. package/dist/internals/base-DHkvlTFy.d.ts.map +0 -1
  52. package/dist/internals/chunk-BuMQw4dz.js.map +0 -1
  53. package/dist/internals/chunk-C7kDLOLD.d.ts.map +0 -1
  54. package/dist/internals/chunk-DxYhYVky.mjs.map +0 -1
  55. package/dist/internals/index-BRzKDwPs.js.map +0 -1
  56. package/dist/internals/index-CKcESGqE.d.ts.map +0 -1
  57. package/dist/internals/index-DAkcqabS.mjs.map +0 -1
  58. package/dist/internals/index-PLz89AWF.d.ts.map +0 -1
@@ -69,9 +69,9 @@ class FileStorageBase {
69
69
  yield data;
70
70
  }
71
71
  else {
72
- const endBytes = startBytes + data.length - 1;
72
+ const endBytes = startBytes + data.length;
73
73
  const _start = _.isNumber(start) && start > startBytes ? start - startBytes : 0;
74
- const _end = _.isNumber(end) && end < endBytes ? end - startBytes + 1 : undefined;
74
+ const _end = _.isNumber(end) && end < endBytes ? end - startBytes : undefined;
75
75
  yield data.subarray(_start, _end);
76
76
  }
77
77
  }
@@ -79,4 +79,4 @@ class FileStorageBase {
79
79
  }
80
80
 
81
81
  export { FileStorageBase as F };
82
- //# sourceMappingURL=base-CfQi0T0I.mjs.map
82
+ //# sourceMappingURL=base-DYc1_peK.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"base-CfQi0T0I.mjs","sources":["../../../src/adapters/file/base/base.ts"],"sourcesContent":["//\n// base.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 { promisify } from 'util';\nimport { deflate as _deflate, unzip as _unzip } from 'zlib';\nimport { TFileInfo, TFileStorage } from '../../../server/file';\nimport { ProtoService } from '../../../server/proto';\nimport { TSchema } from '../../../internals/schema';\nimport { BinaryData, binaryStreamChunk, parallelEach, parallelMap } from '@o2ter/utils-js';\nimport { PVK } from '../../../internals/private';\n\nconst deflate = promisify(_deflate);\nconst unzip = promisify(_unzip);\n\nexport type FileStorageOptions = {\n chunkSize?: number;\n parallel?: number;\n};\n\nexport abstract class FileStorageBase implements TFileStorage {\n\n options: Required<FileStorageOptions>;\n\n constructor(options: FileStorageOptions) {\n this.options = {\n chunkSize: 16 * 1024,\n parallel: 8,\n ..._.pickBy(options, v => !_.isNil(v)),\n };\n }\n\n get schema(): Record<string, TSchema> {\n return {}\n }\n\n abstract createChunk<E>(proto: ProtoService<E>, token: string, start: number, end: number, compressed: Buffer): PromiseLike<void>;\n abstract readChunks<E>(proto: ProtoService<E>, token: string, start?: number, end?: number): AsyncGenerator<{\n start: number;\n data: Buffer | Uint8Array | PromiseLike<Buffer | Uint8Array>;\n }, void>;\n abstract destroy<E>(proto: ProtoService<E>, id: string): PromiseLike<void>;\n\n async create<E>(\n proto: ProtoService<E>,\n stream: BinaryData | AsyncIterable<BinaryData>,\n info: TFileInfo,\n maxUploadSize: number,\n ) {\n\n const token = proto[PVK].generateId();\n\n let size = 0;\n const _stream = async function* (stream: AsyncIterable<Buffer>) {\n for await (const data of stream) {\n yield { data, offset: size };\n size += data.byteLength;\n }\n };\n\n await parallelEach(\n _stream(binaryStreamChunk(stream, this.options.chunkSize)),\n this.options.parallel,\n async ({ data, offset }) => {\n const chunkSize = data.byteLength;\n await this.createChunk(proto, token, offset, offset + chunkSize, await deflate(data));\n if (offset + chunkSize > maxUploadSize) throw Error('Payload too large');\n }\n );\n\n return { _id: token, size };\n }\n\n async* fileData<E>(proto: ProtoService<E>, id: string, start?: number, end?: number) {\n\n const _stream = parallelMap(\n this.readChunks(proto, id, start, end),\n this.options.parallel,\n async chunk => ({\n start: chunk.start,\n data: await unzip(await chunk.data),\n })\n );\n\n for await (const { start: startBytes, data } of _stream) {\n\n if (!_.isNumber(start) && !_.isNumber(end)) {\n\n yield data;\n\n } else {\n\n const endBytes = startBytes + data.length - 1;\n const _start = _.isNumber(start) && start > startBytes ? start - startBytes : 0;\n const _end = _.isNumber(end) && end < endBytes ? end - startBytes + 1 : undefined;\n\n yield data.subarray(_start, _end);\n }\n }\n }\n};\n"],"names":["_deflate","_unzip"],"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;AAWA,MAAM,OAAO,GAAG,SAAS,CAACA,SAAQ,CAAC;AACnC,MAAM,KAAK,GAAG,SAAS,CAACC,OAAM,CAAC;MAOT,eAAe,CAAA;AAEnC,IAAA,OAAO;AAEP,IAAA,WAAA,CAAY,OAA2B,EAAA;QACrC,IAAI,CAAC,OAAO,GAAG;YACb,SAAS,EAAE,EAAE,GAAG,IAAI;AACpB,YAAA,QAAQ,EAAE,CAAC;AACX,YAAA,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;SACvC;;AAGH,IAAA,IAAI,MAAM,GAAA;AACR,QAAA,OAAO,EAAE;;IAUX,MAAM,MAAM,CACV,KAAsB,EACtB,MAA8C,EAC9C,IAAe,EACf,aAAqB,EAAA;QAGrB,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE;QAErC,IAAI,IAAI,GAAG,CAAC;AACZ,QAAA,MAAM,OAAO,GAAG,iBAAiB,MAA6B,EAAA;AAC5D,YAAA,WAAW,MAAM,IAAI,IAAI,MAAM,EAAE;AAC/B,gBAAA,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;AAC5B,gBAAA,IAAI,IAAI,IAAI,CAAC,UAAU;;AAE3B,SAAC;AA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7C,MAAM,MAAM,GAAG,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,UAAU,GAAG,KAAK,GAAG,UAAU,GAAG,CAAC;gBAC/E,MAAM,IAAI,GAAG,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,QAAQ,GAAG,GAAG,GAAG,UAAU,GAAG,CAAC,GAAG,SAAS;gBAEjF,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;;;;AAIxC;;;;"}
1
+ {"version":3,"file":"base-DYc1_peK.mjs","sources":["../../../src/adapters/file/base/base.ts"],"sourcesContent":["//\n// base.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 { promisify } from 'util';\nimport { deflate as _deflate, unzip as _unzip } from 'zlib';\nimport { TFileInfo, TFileStorage } from '../../../server/file';\nimport { ProtoService } from '../../../server/proto';\nimport { TSchema } from '../../../internals/schema';\nimport { BinaryData, binaryStreamChunk, parallelEach, parallelMap } from '@o2ter/utils-js';\nimport { PVK } from '../../../internals/private';\n\nconst deflate = promisify(_deflate);\nconst unzip = promisify(_unzip);\n\nexport type FileStorageOptions = {\n chunkSize?: number;\n parallel?: number;\n};\n\nexport abstract class FileStorageBase implements TFileStorage {\n\n options: Required<FileStorageOptions>;\n\n constructor(options: FileStorageOptions) {\n this.options = {\n chunkSize: 16 * 1024,\n parallel: 8,\n ..._.pickBy(options, v => !_.isNil(v)),\n };\n }\n\n get schema(): Record<string, TSchema> {\n return {}\n }\n\n abstract createChunk<E>(proto: ProtoService<E>, token: string, start: number, end: number, compressed: Buffer): PromiseLike<void>;\n abstract readChunks<E>(proto: ProtoService<E>, token: string, start?: number, end?: number): AsyncGenerator<{\n start: number;\n data: Buffer | Uint8Array | PromiseLike<Buffer | Uint8Array>;\n }, void>;\n abstract destroy<E>(proto: ProtoService<E>, id: string): PromiseLike<void>;\n\n async create<E>(\n proto: ProtoService<E>,\n stream: BinaryData | AsyncIterable<BinaryData>,\n info: TFileInfo,\n maxUploadSize: number,\n ) {\n\n const token = proto[PVK].generateId();\n\n let size = 0;\n const _stream = async function* (stream: AsyncIterable<Buffer>) {\n for await (const data of stream) {\n yield { data, offset: size };\n size += data.byteLength;\n }\n };\n\n await parallelEach(\n _stream(binaryStreamChunk(stream, this.options.chunkSize)),\n this.options.parallel,\n async ({ data, offset }) => {\n const chunkSize = data.byteLength;\n await this.createChunk(proto, token, offset, offset + chunkSize, await deflate(data));\n if (offset + chunkSize > maxUploadSize) throw Error('Payload too large');\n }\n );\n\n return { _id: token, size };\n }\n\n async* fileData<E>(proto: ProtoService<E>, id: string, start?: number, end?: number) {\n\n const _stream = parallelMap(\n this.readChunks(proto, id, start, end),\n this.options.parallel,\n async chunk => ({\n start: chunk.start,\n data: await unzip(await chunk.data),\n })\n );\n\n for await (const { start: startBytes, data } of _stream) {\n\n if (!_.isNumber(start) && !_.isNumber(end)) {\n\n yield data;\n\n } else {\n\n const endBytes = startBytes + data.length;\n const _start = _.isNumber(start) && start > startBytes ? start - startBytes : 0;\n const _end = _.isNumber(end) && end < endBytes ? end - startBytes : undefined;\n\n yield data.subarray(_start, _end);\n }\n }\n }\n};\n"],"names":["_deflate","_unzip"],"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;AAWA,MAAM,OAAO,GAAG,SAAS,CAACA,SAAQ,CAAC;AACnC,MAAM,KAAK,GAAG,SAAS,CAACC,OAAM,CAAC;MAOT,eAAe,CAAA;AAEnC,IAAA,OAAO;AAEP,IAAA,WAAA,CAAY,OAA2B,EAAA;QACrC,IAAI,CAAC,OAAO,GAAG;YACb,SAAS,EAAE,EAAE,GAAG,IAAI;AACpB,YAAA,QAAQ,EAAE,CAAC;AACX,YAAA,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;SACvC;;AAGH,IAAA,IAAI,MAAM,GAAA;AACR,QAAA,OAAO,EAAE;;IAUX,MAAM,MAAM,CACV,KAAsB,EACtB,MAA8C,EAC9C,IAAe,EACf,aAAqB,EAAA;QAGrB,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE;QAErC,IAAI,IAAI,GAAG,CAAC;AACZ,QAAA,MAAM,OAAO,GAAG,iBAAiB,MAA6B,EAAA;AAC5D,YAAA,WAAW,MAAM,IAAI,IAAI,MAAM,EAAE;AAC/B,gBAAA,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;AAC5B,gBAAA,IAAI,IAAI,IAAI,CAAC,UAAU;;AAE3B,SAAC;AAED,QAAA,MAAM,YAAY,CAChB,OAAO,CAAC,iBAAiB,CAAC,MAAM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KAAK,GAAG,UAAU,GAAG,KAAK,GAAG,UAAU,GAAG,CAAC;gBAC/E,MAAM,IAAI,GAAG,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,QAAQ,GAAG,GAAG,GAAG,UAAU,GAAG,SAAS;gBAE7E,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;;;;AAIxC;;;;"}
@@ -1,4 +1,4 @@
1
- import { d as TFileStorage, T as TSchema, P as ProtoService, J as TFileInfo } from './index-PLz89AWF.js';
1
+ import { d as TFileStorage, T as TSchema, P as ProtoService, J as TFileInfo } from './index-Dn1IkLDx.js';
2
2
  import { BinaryData } from '@o2ter/utils-js';
3
3
 
4
4
  type FileStorageOptions = {
@@ -23,4 +23,4 @@ declare abstract class FileStorageBase implements TFileStorage {
23
23
  }
24
24
 
25
25
  export { FileStorageBase as F, type FileStorageOptions as a };
26
- //# sourceMappingURL=base-DHkvlTFy.d.ts.map
26
+ //# sourceMappingURL=base-DbSaGX_u.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-DbSaGX_u.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -71,9 +71,9 @@ class FileStorageBase {
71
71
  yield data;
72
72
  }
73
73
  else {
74
- const endBytes = startBytes + data.length - 1;
74
+ const endBytes = startBytes + data.length;
75
75
  const _start = _.isNumber(start) && start > startBytes ? start - startBytes : 0;
76
- const _end = _.isNumber(end) && end < endBytes ? end - startBytes + 1 : undefined;
76
+ const _end = _.isNumber(end) && end < endBytes ? end - startBytes : undefined;
77
77
  yield data.subarray(_start, _end);
78
78
  }
79
79
  }
@@ -81,4 +81,4 @@ class FileStorageBase {
81
81
  }
82
82
 
83
83
  exports.FileStorageBase = FileStorageBase;
84
- //# sourceMappingURL=base-BFKQpiws.js.map
84
+ //# sourceMappingURL=base-NsJYo2MG.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"base-BFKQpiws.js","sources":["../../../src/adapters/file/base/base.ts"],"sourcesContent":["//\n// base.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 { promisify } from 'util';\nimport { deflate as _deflate, unzip as _unzip } from 'zlib';\nimport { TFileInfo, TFileStorage } from '../../../server/file';\nimport { ProtoService } from '../../../server/proto';\nimport { TSchema } from '../../../internals/schema';\nimport { BinaryData, binaryStreamChunk, parallelEach, parallelMap } from '@o2ter/utils-js';\nimport { PVK } from '../../../internals/private';\n\nconst deflate = promisify(_deflate);\nconst unzip = promisify(_unzip);\n\nexport type FileStorageOptions = {\n chunkSize?: number;\n parallel?: number;\n};\n\nexport abstract class FileStorageBase implements TFileStorage {\n\n options: Required<FileStorageOptions>;\n\n constructor(options: FileStorageOptions) {\n this.options = {\n chunkSize: 16 * 1024,\n parallel: 8,\n ..._.pickBy(options, v => !_.isNil(v)),\n };\n }\n\n get schema(): Record<string, TSchema> {\n return {}\n }\n\n abstract createChunk<E>(proto: ProtoService<E>, token: string, start: number, end: number, compressed: Buffer): PromiseLike<void>;\n abstract readChunks<E>(proto: ProtoService<E>, token: string, start?: number, end?: number): AsyncGenerator<{\n start: number;\n data: Buffer | Uint8Array | PromiseLike<Buffer | Uint8Array>;\n }, void>;\n abstract destroy<E>(proto: ProtoService<E>, id: string): PromiseLike<void>;\n\n async create<E>(\n proto: ProtoService<E>,\n stream: BinaryData | AsyncIterable<BinaryData>,\n info: TFileInfo,\n maxUploadSize: number,\n ) {\n\n const token = proto[PVK].generateId();\n\n let size = 0;\n const _stream = async function* (stream: AsyncIterable<Buffer>) {\n for await (const data of stream) {\n yield { data, offset: size };\n size += data.byteLength;\n }\n };\n\n await parallelEach(\n _stream(binaryStreamChunk(stream, this.options.chunkSize)),\n this.options.parallel,\n async ({ data, offset }) => {\n const chunkSize = data.byteLength;\n await this.createChunk(proto, token, offset, offset + chunkSize, await deflate(data));\n if (offset + chunkSize > maxUploadSize) throw Error('Payload too large');\n }\n );\n\n return { _id: token, size };\n }\n\n async* fileData<E>(proto: ProtoService<E>, id: string, start?: number, end?: number) {\n\n const _stream = parallelMap(\n this.readChunks(proto, id, start, end),\n this.options.parallel,\n async chunk => ({\n start: chunk.start,\n data: await unzip(await chunk.data),\n })\n );\n\n for await (const { start: startBytes, data } of _stream) {\n\n if (!_.isNumber(start) && !_.isNumber(end)) {\n\n yield data;\n\n } else {\n\n const endBytes = startBytes + data.length - 1;\n const _start = _.isNumber(start) && start > startBytes ? start - startBytes : 0;\n const _end = _.isNumber(end) && end < endBytes ? end - startBytes + 1 : undefined;\n\n yield data.subarray(_start, _end);\n }\n }\n }\n};\n"],"names":["promisify","_deflate","_unzip","PVK","parallelEach","binaryStreamChunk","parallelMap"],"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;AA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/base/base.ts"],"sourcesContent":["//\n// base.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 { promisify } from 'util';\nimport { deflate as _deflate, unzip as _unzip } from 'zlib';\nimport { TFileInfo, TFileStorage } from '../../../server/file';\nimport { ProtoService } from '../../../server/proto';\nimport { TSchema } from '../../../internals/schema';\nimport { BinaryData, binaryStreamChunk, parallelEach, parallelMap } from '@o2ter/utils-js';\nimport { PVK } from '../../../internals/private';\n\nconst deflate = promisify(_deflate);\nconst unzip = promisify(_unzip);\n\nexport type FileStorageOptions = {\n chunkSize?: number;\n parallel?: number;\n};\n\nexport abstract class FileStorageBase implements TFileStorage {\n\n options: Required<FileStorageOptions>;\n\n constructor(options: FileStorageOptions) {\n this.options = {\n chunkSize: 16 * 1024,\n parallel: 8,\n ..._.pickBy(options, v => !_.isNil(v)),\n };\n }\n\n get schema(): Record<string, TSchema> {\n return {}\n }\n\n abstract createChunk<E>(proto: ProtoService<E>, token: string, start: number, end: number, compressed: Buffer): PromiseLike<void>;\n abstract readChunks<E>(proto: ProtoService<E>, token: string, start?: number, end?: number): AsyncGenerator<{\n start: number;\n data: Buffer | Uint8Array | PromiseLike<Buffer | Uint8Array>;\n }, void>;\n abstract destroy<E>(proto: ProtoService<E>, id: string): PromiseLike<void>;\n\n async create<E>(\n proto: ProtoService<E>,\n stream: BinaryData | AsyncIterable<BinaryData>,\n info: TFileInfo,\n maxUploadSize: number,\n ) {\n\n const token = proto[PVK].generateId();\n\n let size = 0;\n const _stream = async function* (stream: AsyncIterable<Buffer>) {\n for await (const data of stream) {\n yield { data, offset: size };\n size += data.byteLength;\n }\n };\n\n await parallelEach(\n _stream(binaryStreamChunk(stream, this.options.chunkSize)),\n this.options.parallel,\n async ({ data, offset }) => {\n const chunkSize = data.byteLength;\n await this.createChunk(proto, token, offset, offset + chunkSize, await deflate(data));\n if (offset + chunkSize > maxUploadSize) throw Error('Payload too large');\n }\n );\n\n return { _id: token, size };\n }\n\n async* fileData<E>(proto: ProtoService<E>, id: string, start?: number, end?: number) {\n\n const _stream = parallelMap(\n this.readChunks(proto, id, start, end),\n this.options.parallel,\n async chunk => ({\n start: chunk.start,\n data: await unzip(await chunk.data),\n })\n );\n\n for await (const { start: startBytes, data } of _stream) {\n\n if (!_.isNumber(start) && !_.isNumber(end)) {\n\n yield data;\n\n } else {\n\n const endBytes = startBytes + data.length;\n const _start = _.isNumber(start) && start > startBytes ? start - startBytes : 0;\n const _end = _.isNumber(end) && end < endBytes ? end - startBytes : undefined;\n\n yield data.subarray(_start, _end);\n }\n }\n }\n};\n"],"names":["promisify","_deflate","_unzip","PVK","parallelEach","binaryStreamChunk","parallelMap"],"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;AAWA,MAAM,OAA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js');
4
+ var base = require('./base-NsJYo2MG.js');
5
+ var utilsJs = require('@o2ter/utils-js');
5
6
 
6
7
  //
7
8
  // object.ts
@@ -29,7 +30,8 @@ var base = require('./base-BFKQpiws.js');
29
30
  //
30
31
  class FileChunkStorageBase extends base.FileStorageBase {
31
32
  async *readChunks(proto, token, start, end) {
32
- const files = _.orderBy(await this.listChunks(proto, token), x => x.start);
33
+ const streams = await utilsJs.asyncIterableToArray(this.listChunks(proto, token, start, end));
34
+ const files = _.orderBy(streams, x => x.start);
33
35
  for (const [chunk, endBytes] of _.zip(files, _.slice(_.map(files, x => x.start), 1))) {
34
36
  if (_.isNumber(start) && _.isNumber(endBytes) && start >= endBytes)
35
37
  continue;
@@ -46,4 +48,4 @@ class FileChunkStorageBase extends base.FileStorageBase {
46
48
  }
47
49
 
48
50
  exports.FileChunkStorageBase = FileChunkStorageBase;
49
- //# sourceMappingURL=chunk-BuMQw4dz.js.map
51
+ //# sourceMappingURL=chunk-BuKmyceG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk-BuKmyceG.js","sources":["../../../src/adapters/file/base/chunk.ts"],"sourcesContent":["//\n// object.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 { FileStorageBase } from './base';\nimport { ProtoService } from '../../../server/proto';\nimport { asyncIterableToArray } from '@o2ter/utils-js';\n\nexport abstract class FileChunkStorageBase<File> extends FileStorageBase {\n\n abstract listChunks<E>(proto: ProtoService<E>, token: string, start?: number, end?: number): AsyncGenerator<{\n start: number;\n file: File;\n }>;\n\n abstract readChunk<E>(proto: ProtoService<E>, file: File): PromiseLike<Buffer>;\n\n async* readChunks<E>(proto: ProtoService<E>, token: string, start?: number, end?: number) {\n const streams = await asyncIterableToArray(this.listChunks(proto, token, start, end));\n const files = _.orderBy(streams, x => x.start);\n for (const [chunk, endBytes] of _.zip(files, _.slice(_.map(files, x => x.start), 1))) {\n if (_.isNumber(start) && _.isNumber(endBytes) && start >= endBytes) continue;\n if (_.isNumber(end) && end <= chunk!.start) continue;\n if (!chunk) continue;\n yield {\n start: chunk.start,\n data: (async () => this.readChunk(proto, chunk.file))(),\n };\n }\n }\n}"],"names":["FileStorageBase","asyncIterableToArray"],"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,MAAgB,oBAA2B,SAAQA,oBAAe,CAAA;IAStE,OAAO,UAAU,CAAI,KAAsB,EAAE,KAAa,EAAE,KAAc,EAAE,GAAY,EAAA;AACtF,QAAA,MAAM,OAAO,GAAG,MAAMC,4BAAoB,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;AACrF,QAAA,MAAM,KAAK,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC;AAC9C,QAAA,KAAK,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE;AACpF,YAAA,IAAI,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,KAAK,IAAI,QAAQ;gBAAE;YACpE,IAAI,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,KAAM,CAAC,KAAK;gBAAE;AAC5C,YAAA,IAAI,CAAC,KAAK;gBAAE;YACZ,MAAM;gBACJ,KAAK,EAAE,KAAK,CAAC,KAAK;AAClB,gBAAA,IAAI,EAAE,CAAC,YAAY,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG;aACxD;;;AAGN;;;;"}
@@ -1,17 +1,17 @@
1
- import { F as FileStorageBase } from './base-DHkvlTFy.js';
2
- import { P as ProtoService } from './index-PLz89AWF.js';
1
+ import { F as FileStorageBase } from './base-DbSaGX_u.js';
2
+ import { P as ProtoService } from './index-Dn1IkLDx.js';
3
3
 
4
4
  declare abstract class FileChunkStorageBase<File> extends FileStorageBase {
5
- abstract listChunks<E>(proto: ProtoService<E>, token: string): PromiseLike<{
5
+ abstract listChunks<E>(proto: ProtoService<E>, token: string, start?: number, end?: number): AsyncGenerator<{
6
6
  start: number;
7
7
  file: File;
8
- }[]>;
8
+ }>;
9
9
  abstract readChunk<E>(proto: ProtoService<E>, file: File): PromiseLike<Buffer>;
10
- readChunks<E>(proto: ProtoService<E>, token: string, start?: number | undefined, end?: number | undefined): AsyncGenerator<{
10
+ readChunks<E>(proto: ProtoService<E>, token: string, start?: number, end?: number): AsyncGenerator<{
11
11
  start: number;
12
12
  data: Promise<Buffer<ArrayBufferLike>>;
13
13
  }, void, unknown>;
14
14
  }
15
15
 
16
16
  export { FileChunkStorageBase as F };
17
- //# sourceMappingURL=chunk-C7kDLOLD.d.ts.map
17
+ //# sourceMappingURL=chunk-bYrnqXiI.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk-bYrnqXiI.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,5 +1,6 @@
1
1
  import _ from 'lodash';
2
- import { F as FileStorageBase } from './base-CfQi0T0I.mjs';
2
+ import { F as FileStorageBase } from './base-DYc1_peK.mjs';
3
+ import { asyncIterableToArray } from '@o2ter/utils-js';
3
4
 
4
5
  //
5
6
  // object.ts
@@ -27,7 +28,8 @@ import { F as FileStorageBase } from './base-CfQi0T0I.mjs';
27
28
  //
28
29
  class FileChunkStorageBase extends FileStorageBase {
29
30
  async *readChunks(proto, token, start, end) {
30
- const files = _.orderBy(await this.listChunks(proto, token), x => x.start);
31
+ const streams = await asyncIterableToArray(this.listChunks(proto, token, start, end));
32
+ const files = _.orderBy(streams, x => x.start);
31
33
  for (const [chunk, endBytes] of _.zip(files, _.slice(_.map(files, x => x.start), 1))) {
32
34
  if (_.isNumber(start) && _.isNumber(endBytes) && start >= endBytes)
33
35
  continue;
@@ -44,4 +46,4 @@ class FileChunkStorageBase extends FileStorageBase {
44
46
  }
45
47
 
46
48
  export { FileChunkStorageBase as F };
47
- //# sourceMappingURL=chunk-DxYhYVky.mjs.map
49
+ //# sourceMappingURL=chunk-bpt1C6W4.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk-bpt1C6W4.mjs","sources":["../../../src/adapters/file/base/chunk.ts"],"sourcesContent":["//\n// object.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 { FileStorageBase } from './base';\nimport { ProtoService } from '../../../server/proto';\nimport { asyncIterableToArray } from '@o2ter/utils-js';\n\nexport abstract class FileChunkStorageBase<File> extends FileStorageBase {\n\n abstract listChunks<E>(proto: ProtoService<E>, token: string, start?: number, end?: number): AsyncGenerator<{\n start: number;\n file: File;\n }>;\n\n abstract readChunk<E>(proto: ProtoService<E>, file: File): PromiseLike<Buffer>;\n\n async* readChunks<E>(proto: ProtoService<E>, token: string, start?: number, end?: number) {\n const streams = await asyncIterableToArray(this.listChunks(proto, token, start, end));\n const files = _.orderBy(streams, x => x.start);\n for (const [chunk, endBytes] of _.zip(files, _.slice(_.map(files, x => x.start), 1))) {\n if (_.isNumber(start) && _.isNumber(endBytes) && start >= endBytes) continue;\n if (_.isNumber(end) && end <= chunk!.start) continue;\n if (!chunk) continue;\n yield {\n start: chunk.start,\n data: (async () => this.readChunk(proto, chunk.file))(),\n };\n }\n }\n}"],"names":[],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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
+ const _logLevels = ['error', 'warn', 'info', 'debug', 'trace'];
1181
1182
  class ProtoType {
1182
1183
  isQuery = isQuery;
1183
1184
  isObject = isObject;
@@ -1269,15 +1270,15 @@ class _ProtoClientQuery extends TQuery {
1269
1270
  this._proto = proto;
1270
1271
  this._opts = opts;
1271
1272
  }
1272
- get _queryOptions() {
1273
+ _queryOptions({ silent, } = {}) {
1273
1274
  return {
1274
1275
  className: this.className,
1275
1276
  relatedBy: this._opts.relatedBy,
1277
+ silent,
1276
1278
  ...this[_private.PVK].options,
1277
1279
  };
1278
1280
  }
1279
- _requestOpt(options) {
1280
- const { ...opts } = options ?? {};
1281
+ _requestOpt({ silent, ...opts } = {}) {
1281
1282
  return {
1282
1283
  method: 'post',
1283
1284
  url: this.url,
@@ -1290,19 +1291,19 @@ class _ProtoClientQuery extends TQuery {
1290
1291
  explain(options) {
1291
1292
  return this._proto[_private.PVK].request(this._proto, {
1292
1293
  operation: 'explain',
1293
- ...this._queryOptions,
1294
+ ...this._queryOptions(options),
1294
1295
  }, this._requestOpt(options));
1295
1296
  }
1296
1297
  count(options) {
1297
1298
  return this._proto[_private.PVK].request(this._proto, {
1298
1299
  operation: 'count',
1299
- ...this._queryOptions,
1300
+ ...this._queryOptions(options),
1300
1301
  }, this._requestOpt(options));
1301
1302
  }
1302
1303
  find(options) {
1303
1304
  const request = () => this._proto[_private.PVK].request(this._proto, {
1304
1305
  operation: 'find',
1305
- ...this._queryOptions,
1306
+ ...this._queryOptions(options),
1306
1307
  }, this._requestOpt(options));
1307
1308
  return utilsJs.asyncStream(request);
1308
1309
  }
@@ -1310,14 +1311,14 @@ class _ProtoClientQuery extends TQuery {
1310
1311
  const request = () => this._proto[_private.PVK].request(this._proto, {
1311
1312
  operation: 'random',
1312
1313
  random: opts,
1313
- ...this._queryOptions,
1314
+ ...this._queryOptions(options),
1314
1315
  }, this._requestOpt(options));
1315
1316
  return utilsJs.asyncStream(request);
1316
1317
  }
1317
1318
  nonrefs(options) {
1318
1319
  const request = () => this._proto[_private.PVK].request(this._proto, {
1319
1320
  operation: 'nonrefs',
1320
- ...this._queryOptions,
1321
+ ...this._queryOptions(options),
1321
1322
  }, this._requestOpt(options));
1322
1323
  return utilsJs.asyncStream(request);
1323
1324
  }
@@ -1325,28 +1326,28 @@ class _ProtoClientQuery extends TQuery {
1325
1326
  return this._proto[_private.PVK].request(this._proto, {
1326
1327
  operation: 'insert',
1327
1328
  attributes: attrs,
1328
- ...this._queryOptions,
1329
+ ...this._queryOptions(options),
1329
1330
  }, this._requestOpt(options));
1330
1331
  }
1331
1332
  insertMany(values, options) {
1332
1333
  return this._proto[_private.PVK].request(this._proto, {
1333
1334
  operation: 'insertMany',
1334
1335
  attributes: values,
1335
- ...this._queryOptions,
1336
+ ...this._queryOptions(options),
1336
1337
  }, this._requestOpt(options));
1337
1338
  }
1338
1339
  updateOne(update, options) {
1339
1340
  return this._proto[_private.PVK].request(this._proto, {
1340
1341
  operation: 'updateOne',
1341
1342
  update,
1342
- ...this._queryOptions,
1343
+ ...this._queryOptions(options),
1343
1344
  }, this._requestOpt(options));
1344
1345
  }
1345
1346
  updateMany(update, options) {
1346
1347
  return this._proto[_private.PVK].request(this._proto, {
1347
1348
  operation: 'updateMany',
1348
1349
  update,
1349
- ...this._queryOptions,
1350
+ ...this._queryOptions(options),
1350
1351
  }, this._requestOpt(options));
1351
1352
  }
1352
1353
  upsertOne(update, setOnInsert, options) {
@@ -1354,7 +1355,7 @@ class _ProtoClientQuery extends TQuery {
1354
1355
  operation: 'upsertOne',
1355
1356
  update,
1356
1357
  setOnInsert,
1357
- ...this._queryOptions,
1358
+ ...this._queryOptions(options),
1358
1359
  }, this._requestOpt(options));
1359
1360
  }
1360
1361
  upsertMany(update, setOnInsert, options) {
@@ -1362,19 +1363,19 @@ class _ProtoClientQuery extends TQuery {
1362
1363
  operation: 'upsertMany',
1363
1364
  update,
1364
1365
  setOnInsert,
1365
- ...this._queryOptions,
1366
+ ...this._queryOptions(options),
1366
1367
  }, this._requestOpt(options));
1367
1368
  }
1368
1369
  deleteOne(options) {
1369
1370
  return this._proto[_private.PVK].request(this._proto, {
1370
1371
  operation: 'deleteOne',
1371
- ...this._queryOptions,
1372
+ ...this._queryOptions(options),
1372
1373
  }, this._requestOpt(options));
1373
1374
  }
1374
1375
  deleteMany(options) {
1375
1376
  return this._proto[_private.PVK].request(this._proto, {
1376
1377
  operation: 'deleteMany',
1377
- ...this._queryOptions,
1378
+ ...this._queryOptions(options),
1378
1379
  }, this._requestOpt(options));
1379
1380
  }
1380
1381
  }
@@ -1948,6 +1949,7 @@ exports.ProtoType = ProtoType;
1948
1949
  exports.TQuery = TQuery;
1949
1950
  exports.TUser = TUser;
1950
1951
  exports.UPLOAD_TOKEN_HEADER_NAME = UPLOAD_TOKEN_HEADER_NAME;
1952
+ exports._logLevels = _logLevels;
1951
1953
  exports.classExtends = classExtends;
1952
1954
  exports.deserialize = deserialize;
1953
1955
  exports.isFile = isFile;
@@ -1957,4 +1959,4 @@ exports.isQuery = isQuery;
1957
1959
  exports.isRole = isRole;
1958
1960
  exports.isUser = isUser;
1959
1961
  exports.serialize = serialize;
1960
- //# sourceMappingURL=index-BRzKDwPs.js.map
1962
+ //# sourceMappingURL=index-CK1snZyh.js.map