proto.io 0.0.199 → 0.0.201

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 (36) hide show
  1. package/dist/adapters/file/aliyun-oss.d.ts +26 -0
  2. package/dist/adapters/file/aliyun-oss.d.ts.map +1 -0
  3. package/dist/adapters/file/aliyun-oss.js +88 -0
  4. package/dist/adapters/file/aliyun-oss.js.map +1 -0
  5. package/dist/adapters/file/aliyun-oss.mjs +83 -0
  6. package/dist/adapters/file/aliyun-oss.mjs.map +1 -0
  7. package/dist/adapters/file/database.d.ts +1 -1
  8. package/dist/adapters/file/database.js +4 -4
  9. package/dist/adapters/file/database.js.map +1 -1
  10. package/dist/adapters/file/database.mjs +1 -1
  11. package/dist/adapters/file/filesystem.d.ts +7 -5
  12. package/dist/adapters/file/filesystem.js +11 -17
  13. package/dist/adapters/file/filesystem.js.map +1 -1
  14. package/dist/adapters/file/filesystem.mjs +11 -17
  15. package/dist/adapters/file/filesystem.mjs.map +1 -1
  16. package/dist/adapters/file/google-cloud-storage.d.ts +8 -6
  17. package/dist/adapters/file/google-cloud-storage.js +14 -22
  18. package/dist/adapters/file/google-cloud-storage.js.map +1 -1
  19. package/dist/adapters/file/google-cloud-storage.mjs +14 -22
  20. package/dist/adapters/file/google-cloud-storage.mjs.map +1 -1
  21. package/dist/internals/{index-BAFVUYCo.mjs → base-DYc1_peK.mjs} +2 -2
  22. package/dist/internals/base-DYc1_peK.mjs.map +1 -0
  23. package/dist/internals/{index-DvpJENaG.d.ts → base-DvpJENaG.d.ts} +1 -1
  24. package/dist/internals/base-DvpJENaG.d.ts.map +1 -0
  25. package/dist/internals/{index-DfPY7Xbb.js → base-NsJYo2MG.js} +2 -2
  26. package/dist/internals/base-NsJYo2MG.js.map +1 -0
  27. package/dist/internals/chunk-3nNdftWC.mjs +47 -0
  28. package/dist/internals/chunk-3nNdftWC.mjs.map +1 -0
  29. package/dist/internals/chunk-BZdO1nZ9.d.ts +17 -0
  30. package/dist/internals/chunk-BZdO1nZ9.d.ts.map +1 -0
  31. package/dist/internals/chunk-CdEGTub2.js +49 -0
  32. package/dist/internals/chunk-CdEGTub2.js.map +1 -0
  33. package/package.json +4 -1
  34. package/dist/internals/index-BAFVUYCo.mjs.map +0 -1
  35. package/dist/internals/index-DfPY7Xbb.js.map +0 -1
  36. package/dist/internals/index-DvpJENaG.d.ts.map +0 -1
@@ -0,0 +1,26 @@
1
+ import { P as ProtoService } from '../../internals/index-C8EuFNYa.js';
2
+ import OSS from 'ali-oss';
3
+ import { a as FileStorageOptions } from '../../internals/base-DvpJENaG.js';
4
+ import { F as FileChunkStorageBase } from '../../internals/chunk-BZdO1nZ9.js';
5
+ import '@o2ter/utils-js';
6
+ import 'jsonwebtoken';
7
+ import '@o2ter/server-js';
8
+ import 'decimal.js';
9
+ import 'lodash';
10
+ import 'node:stream';
11
+ import 'socket.io-client';
12
+
13
+ declare class AliyunObjectStorage extends FileChunkStorageBase<OSS.ObjectMeta> {
14
+ private _storage;
15
+ constructor(storage: OSS, options?: FileStorageOptions);
16
+ createChunk<E>(proto: ProtoService<E>, token: string, start: number, end: number, compressed: Buffer): Promise<void>;
17
+ listChunks<E>(proto: ProtoService<E>, token: string): Promise<{
18
+ file: OSS.ObjectMeta;
19
+ start: number;
20
+ }[]>;
21
+ readChunk<E>(proto: ProtoService<E>, file: OSS.ObjectMeta): Promise<any>;
22
+ destroy<E>(proto: ProtoService<E>, token: string): Promise<void>;
23
+ }
24
+
25
+ export { AliyunObjectStorage, AliyunObjectStorage as default };
26
+ //# sourceMappingURL=aliyun-oss.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aliyun-oss.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,88 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _ = require('lodash');
6
+ require('../../internals/base-NsJYo2MG.js');
7
+ var chunk = require('../../internals/chunk-CdEGTub2.js');
8
+ require('util');
9
+ require('zlib');
10
+ require('@o2ter/utils-js');
11
+ require('../../internals/private-Ciddhure.js');
12
+
13
+ //
14
+ // index.ts
15
+ //
16
+ // The MIT License
17
+ // Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
18
+ //
19
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
20
+ // of this software and associated documentation files (the "Software"), to deal
21
+ // in the Software without restriction, including without limitation the rights
22
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
23
+ // copies of the Software, and to permit persons to whom the Software is
24
+ // furnished to do so, subject to the following conditions:
25
+ //
26
+ // The above copyright notice and this permission notice shall be included in
27
+ // all copies or substantial portions of the Software.
28
+ //
29
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
35
+ // THE SOFTWARE.
36
+ //
37
+ class AliyunObjectStorage extends chunk.FileChunkStorageBase {
38
+ _storage;
39
+ constructor(storage, options = {}) {
40
+ super(options);
41
+ this._storage = storage;
42
+ }
43
+ async createChunk(proto, token, start, end, compressed) {
44
+ await this._storage.put(`${token}/${start}.chunk`, compressed);
45
+ }
46
+ async listChunks(proto, token) {
47
+ const response = [];
48
+ let next;
49
+ while (true) {
50
+ const { objects, nextContinuationToken } = await this._storage.listV2({
51
+ prefix: `${token}/`,
52
+ delimiter: '/',
53
+ continuationToken: next,
54
+ }, {});
55
+ if (_.isEmpty(objects))
56
+ break;
57
+ response.push(...objects);
58
+ next = nextContinuationToken;
59
+ }
60
+ const files = _.map(response, x => ({
61
+ file: x,
62
+ name: _.last(_.split(x.name, '/')),
63
+ }));
64
+ return _.map(_.filter(files, x => !!x.name?.match(/^\d+\.chunk$/)), x => ({
65
+ file: x.file,
66
+ start: parseInt(x.name.slice(0, -6)),
67
+ }));
68
+ }
69
+ async readChunk(proto, file) {
70
+ const { content } = await this._storage.get(file.name);
71
+ return content;
72
+ }
73
+ async destroy(proto, token) {
74
+ while (true) {
75
+ const { objects } = await this._storage.listV2({
76
+ prefix: `${token}/`,
77
+ delimiter: '/',
78
+ }, {});
79
+ if (_.isEmpty(objects))
80
+ return;
81
+ await this._storage.deleteMulti(_.map(objects, x => x.name));
82
+ }
83
+ }
84
+ }
85
+
86
+ exports.AliyunObjectStorage = AliyunObjectStorage;
87
+ exports.default = AliyunObjectStorage;
88
+ //# sourceMappingURL=aliyun-oss.js.map
@@ -0,0 +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 while (true) {\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 }\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":["FileChunkStorageBase"],"mappings":";;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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AAA,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC,KAAK;YACxE,IAAI,EAAE,CAAC,CAAC,IAAI;AACZ,YAAA,KAAK,EAAE,QAAQ,CAAC,CAAC,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;;;;;"}
@@ -0,0 +1,83 @@
1
+ import _ from 'lodash';
2
+ import '../../internals/base-DYc1_peK.mjs';
3
+ import { F as FileChunkStorageBase } from '../../internals/chunk-3nNdftWC.mjs';
4
+ import 'util';
5
+ import 'zlib';
6
+ import '@o2ter/utils-js';
7
+ import '../../internals/private-CNw40LZ7.mjs';
8
+
9
+ //
10
+ // index.ts
11
+ //
12
+ // The MIT License
13
+ // Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
14
+ //
15
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
16
+ // of this software and associated documentation files (the "Software"), to deal
17
+ // in the Software without restriction, including without limitation the rights
18
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19
+ // copies of the Software, and to permit persons to whom the Software is
20
+ // furnished to do so, subject to the following conditions:
21
+ //
22
+ // The above copyright notice and this permission notice shall be included in
23
+ // all copies or substantial portions of the Software.
24
+ //
25
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
31
+ // THE SOFTWARE.
32
+ //
33
+ class AliyunObjectStorage extends FileChunkStorageBase {
34
+ _storage;
35
+ constructor(storage, options = {}) {
36
+ super(options);
37
+ this._storage = storage;
38
+ }
39
+ async createChunk(proto, token, start, end, compressed) {
40
+ await this._storage.put(`${token}/${start}.chunk`, compressed);
41
+ }
42
+ async listChunks(proto, token) {
43
+ const response = [];
44
+ let next;
45
+ while (true) {
46
+ const { objects, nextContinuationToken } = await this._storage.listV2({
47
+ prefix: `${token}/`,
48
+ delimiter: '/',
49
+ continuationToken: next,
50
+ }, {});
51
+ if (_.isEmpty(objects))
52
+ break;
53
+ response.push(...objects);
54
+ next = nextContinuationToken;
55
+ }
56
+ const files = _.map(response, x => ({
57
+ file: x,
58
+ name: _.last(_.split(x.name, '/')),
59
+ }));
60
+ return _.map(_.filter(files, x => !!x.name?.match(/^\d+\.chunk$/)), x => ({
61
+ file: x.file,
62
+ start: parseInt(x.name.slice(0, -6)),
63
+ }));
64
+ }
65
+ async readChunk(proto, file) {
66
+ const { content } = await this._storage.get(file.name);
67
+ return content;
68
+ }
69
+ async destroy(proto, token) {
70
+ while (true) {
71
+ const { objects } = await this._storage.listV2({
72
+ prefix: `${token}/`,
73
+ delimiter: '/',
74
+ }, {});
75
+ if (_.isEmpty(objects))
76
+ return;
77
+ await this._storage.deleteMulti(_.map(objects, x => x.name));
78
+ }
79
+ }
80
+ }
81
+
82
+ export { AliyunObjectStorage, AliyunObjectStorage as default };
83
+ //# sourceMappingURL=aliyun-oss.mjs.map
@@ -0,0 +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 while (true) {\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 }\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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,CAAC,KAAK;YACxE,IAAI,EAAE,CAAC,CAAC,IAAI;AACZ,YAAA,KAAK,EAAE,QAAQ,CAAC,CAAC,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
1
  import { T as TSchema, P as ProtoService } from '../../internals/index-C8EuFNYa.js';
2
- import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/index-DvpJENaG.js';
2
+ import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/base-DvpJENaG.js';
3
3
  import '@o2ter/utils-js';
4
4
  import 'jsonwebtoken';
5
5
  import '@o2ter/server-js';
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var _ = require('lodash');
6
- var index = require('../../internals/index-DfPY7Xbb.js');
7
- var index$1 = require('../../internals/index-DIFr-lHN.js');
6
+ var base = require('../../internals/base-NsJYo2MG.js');
7
+ var index = require('../../internals/index-DIFr-lHN.js');
8
8
  var utilsJs = require('@o2ter/utils-js');
9
9
  require('util');
10
10
  require('zlib');
@@ -36,7 +36,7 @@ require('decimal.js');
36
36
  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
37
37
  // THE SOFTWARE.
38
38
  //
39
- class DatabaseFileStorage extends index.FileStorageBase {
39
+ class DatabaseFileStorage extends base.FileStorageBase {
40
40
  constructor(options = {}) {
41
41
  super(options);
42
42
  }
@@ -101,7 +101,7 @@ class DatabaseFileStorage extends index.FileStorageBase {
101
101
  async destroy(proto, token) {
102
102
  proto.storage.deleteMany({
103
103
  className: '_FileChunk',
104
- filter: index$1.QuerySelector.decode({ token: { $eq: token } }),
104
+ filter: index.QuerySelector.decode({ token: { $eq: token } }),
105
105
  includes: ['_id'],
106
106
  matches: {},
107
107
  countMatches: [],
@@ -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.deleteMany({\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,qBAAe,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;AACxC,iBAAA;AACD,gBAAA,OAAO,EAAE;AACP,oBAAA,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE;oBACxC,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG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AC,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,UAAU,CAAC;AACvB,YAAA,SAAS,EAAE,YAAY;AACvB,YAAA,MAAM,EAAEC,qBAAa,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
+ {"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.deleteMany({\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,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;AACxC,iBAAA;AACD,gBAAA,OAAO,EAAE;AACP,oBAAA,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE;oBACxC,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,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C,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,UAAU,CAAC;AACvB,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,5 +1,5 @@
1
1
  import _ from 'lodash';
2
- import { F as FileStorageBase } from '../../internals/index-BAFVUYCo.mjs';
2
+ import { F as FileStorageBase } from '../../internals/base-DYc1_peK.mjs';
3
3
  import { Q as QuerySelector } from '../../internals/index-DAtoqvEN.mjs';
4
4
  import { bufferToBase64, base64ToBuffer } from '@o2ter/utils-js';
5
5
  import 'util';
@@ -1,5 +1,6 @@
1
1
  import { P as ProtoService } from '../../internals/index-C8EuFNYa.js';
2
- import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/index-DvpJENaG.js';
2
+ import { a as FileStorageOptions } from '../../internals/base-DvpJENaG.js';
3
+ import { F as FileChunkStorageBase } from '../../internals/chunk-BZdO1nZ9.js';
3
4
  import '@o2ter/utils-js';
4
5
  import 'jsonwebtoken';
5
6
  import '@o2ter/server-js';
@@ -8,14 +9,15 @@ import 'lodash';
8
9
  import 'node:stream';
9
10
  import 'socket.io-client';
10
11
 
11
- declare class FileSystemStorage extends FileStorageBase {
12
+ declare class FileSystemStorage extends FileChunkStorageBase<string> {
12
13
  volumn: string;
13
14
  constructor(volumn: string, options?: FileStorageOptions);
14
15
  createChunk<E>(proto: ProtoService<E>, token: string, start: number, end: number, compressed: Buffer): Promise<void>;
15
- readChunks<E>(proto: ProtoService<E>, token: string, start?: number | undefined, end?: number | undefined): AsyncGenerator<{
16
+ listChunks<E>(proto: ProtoService<E>, token: string): Promise<{
16
17
  start: number;
17
- data: Promise<Buffer<ArrayBufferLike>>;
18
- }, void, unknown>;
18
+ file: string;
19
+ }[]>;
20
+ readChunk<E>(proto: ProtoService<E>, file: string): Promise<Buffer<ArrayBufferLike>>;
19
21
  destroy<E>(proto: ProtoService<E>, token: string): Promise<void>;
20
22
  }
21
23
 
@@ -5,7 +5,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var _ = require('lodash');
6
6
  var path = require('path');
7
7
  var fs = require('fs/promises');
8
- var index = require('../../internals/index-DfPY7Xbb.js');
8
+ var chunk = require('../../internals/chunk-CdEGTub2.js');
9
+ require('../../internals/base-NsJYo2MG.js');
9
10
  require('util');
10
11
  require('zlib');
11
12
  require('@o2ter/utils-js');
@@ -35,7 +36,7 @@ require('../../internals/private-Ciddhure.js');
35
36
  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
36
37
  // THE SOFTWARE.
37
38
  //
38
- class FileSystemStorage extends index.FileStorageBase {
39
+ class FileSystemStorage extends chunk.FileChunkStorageBase {
39
40
  volumn;
40
41
  constructor(volumn, options = {}) {
41
42
  super(options);
@@ -49,23 +50,16 @@ class FileSystemStorage extends index.FileStorageBase {
49
50
  catch { }
50
51
  await fs.writeFile(path.join(directory, `${start}.chunk`), compressed);
51
52
  }
52
- async *readChunks(proto, token, start, end) {
53
+ async listChunks(proto, token) {
53
54
  const directory = path.resolve(this.volumn, token);
54
- const _files = _.filter(await fs.readdir(directory), x => !!x.match(/^\d+\.chunk$/));
55
- const files = _.orderBy(_.map(_files, x => ({
56
- path: path.resolve(directory, x),
55
+ const files = _.filter(await fs.readdir(directory), x => !!x.match(/^\d+\.chunk$/));
56
+ return _.map(files, x => ({
57
57
  start: parseInt(x.slice(0, -6)),
58
- })), x => x.start);
59
- for (const [chunk, endBytes] of _.zip(files, _.slice(_.map(files, x => x.start), 1))) {
60
- if (_.isNumber(start) && _.isNumber(endBytes) && start >= endBytes)
61
- continue;
62
- if (_.isNumber(end) && end <= chunk.start)
63
- continue;
64
- yield {
65
- start: chunk.start,
66
- data: fs.readFile(chunk.path),
67
- };
68
- }
58
+ file: path.resolve(directory, x),
59
+ }));
60
+ }
61
+ async readChunk(proto, file) {
62
+ return fs.readFile(file);
69
63
  }
70
64
  async destroy(proto, token) {
71
65
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"filesystem.js","sources":["../../../../src/adapters/file/filesystem/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 path from 'path';\nimport fs from 'fs/promises';\nimport { ProtoService } from '../../../server/proto';\nimport FileStorageBase, { FileStorageOptions } from '../base';\n\nexport class FileSystemStorage extends FileStorageBase {\n\n volumn: string;\n\n constructor(volumn: string, options: FileStorageOptions = {}) {\n super(options);\n this.volumn = volumn;\n }\n\n async createChunk<E>(proto: ProtoService<E>, token: string, start: number, end: number, compressed: Buffer) {\n const directory = path.resolve(this.volumn, token);\n try {\n await fs.mkdir(directory, { recursive: true });\n } catch { }\n await fs.writeFile(path.join(directory, `${start}.chunk`), compressed);\n }\n\n async* readChunks<E>(proto: ProtoService<E>, token: string, start?: number | undefined, end?: number | undefined) {\n const directory = path.resolve(this.volumn, token);\n const _files = _.filter(await fs.readdir(directory), x => !!x.match(/^\\d+\\.chunk$/));\n const files = _.orderBy(_.map(_files, x => ({\n path: path.resolve(directory, x),\n start: parseInt(x.slice(0, -6)),\n })), 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 yield {\n start: chunk!.start,\n data: fs.readFile(chunk!.path),\n };\n }\n }\n\n async destroy<E>(proto: ProtoService<E>, token: string) {\n try {\n const directory = path.resolve(this.volumn, token);\n await fs.rm(directory, { recursive: true, force: true });\n } catch { }\n }\n};\n\nexport default FileSystemStorage;"],"names":["FileStorageBase"],"mappings":";;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAQM,MAAO,iBAAkB,SAAQA,qBAAe,CAAA;AAEpD,IAAA,MAAM;IAEN,WAAY,CAAA,MAAc,EAAE,OAAA,GAA8B,EAAE,EAAA;QACxD,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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;YAC5C,MAAM;gBACJ,KAAK,EAAE,KAAM,CAAC,KAAK;gBACnB,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAM,CAAC,IAAI,CAAC;aAC/B;;;AAIL,IAAA,MAAM,OAAO,CAAI,KAAsB,EAAE,KAAa,EAAA;AACpD,QAAA,IAAI;AACF,YAAA,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC;AAClD,YAAA,MAAM,EAAE,CAAC,EAAE,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;;QACxD,MAAM;;AAEX;;;;;"}
1
+ {"version":3,"file":"filesystem.js","sources":["../../../../src/adapters/file/filesystem/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 path from 'path';\nimport fs from 'fs/promises';\nimport { ProtoService } from '../../../server/proto';\nimport { FileStorageOptions } from '../base';\nimport { FileChunkStorageBase } from '../base/chunk';\n\nexport class FileSystemStorage extends FileChunkStorageBase<string> {\n\n volumn: string;\n\n constructor(volumn: string, options: FileStorageOptions = {}) {\n super(options);\n this.volumn = volumn;\n }\n\n async createChunk<E>(proto: ProtoService<E>, token: string, start: number, end: number, compressed: Buffer) {\n const directory = path.resolve(this.volumn, token);\n try {\n await fs.mkdir(directory, { recursive: true });\n } catch { }\n await fs.writeFile(path.join(directory, `${start}.chunk`), compressed);\n }\n\n async listChunks<E>(proto: ProtoService<E>, token: string) {\n const directory = path.resolve(this.volumn, token);\n const files = _.filter(await fs.readdir(directory), x => !!x.match(/^\\d+\\.chunk$/));\n return _.map(files, x => ({\n start: parseInt(x.slice(0, -6)),\n file: path.resolve(directory, x),\n }));\n }\n\n async readChunk<E>(proto: ProtoService<E>, file: string) {\n return fs.readFile(file);\n }\n\n async destroy<E>(proto: ProtoService<E>, token: string) {\n try {\n const directory = path.resolve(this.volumn, token);\n await fs.rm(directory, { recursive: true, force: true });\n } catch { }\n }\n};\n\nexport default FileSystemStorage;"],"names":["FileChunkStorageBase"],"mappings":";;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,SAAS,CAAI,KAAsB,EAAE,IAAY,EAAA;AACrD,QAAA,OAAO,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC;;AAG1B,IAAA,MAAM,OAAO,CAAI,KAAsB,EAAE,KAAa,EAAA;AACpD,QAAA,IAAI;AACF,YAAA,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC;AAClD,YAAA,MAAM,EAAE,CAAC,EAAE,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;;QACxD,MAAM;;AAEX;;;;;"}
@@ -1,7 +1,8 @@
1
1
  import _ from 'lodash';
2
2
  import path from 'path';
3
3
  import fs from 'fs/promises';
4
- import { F as FileStorageBase } from '../../internals/index-BAFVUYCo.mjs';
4
+ import { F as FileChunkStorageBase } from '../../internals/chunk-3nNdftWC.mjs';
5
+ import '../../internals/base-DYc1_peK.mjs';
5
6
  import 'util';
6
7
  import 'zlib';
7
8
  import '@o2ter/utils-js';
@@ -31,7 +32,7 @@ import '../../internals/private-CNw40LZ7.mjs';
31
32
  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
32
33
  // THE SOFTWARE.
33
34
  //
34
- class FileSystemStorage extends FileStorageBase {
35
+ class FileSystemStorage extends FileChunkStorageBase {
35
36
  volumn;
36
37
  constructor(volumn, options = {}) {
37
38
  super(options);
@@ -45,23 +46,16 @@ class FileSystemStorage extends FileStorageBase {
45
46
  catch { }
46
47
  await fs.writeFile(path.join(directory, `${start}.chunk`), compressed);
47
48
  }
48
- async *readChunks(proto, token, start, end) {
49
+ async listChunks(proto, token) {
49
50
  const directory = path.resolve(this.volumn, token);
50
- const _files = _.filter(await fs.readdir(directory), x => !!x.match(/^\d+\.chunk$/));
51
- const files = _.orderBy(_.map(_files, x => ({
52
- path: path.resolve(directory, x),
51
+ const files = _.filter(await fs.readdir(directory), x => !!x.match(/^\d+\.chunk$/));
52
+ return _.map(files, x => ({
53
53
  start: parseInt(x.slice(0, -6)),
54
- })), x => x.start);
55
- for (const [chunk, endBytes] of _.zip(files, _.slice(_.map(files, x => x.start), 1))) {
56
- if (_.isNumber(start) && _.isNumber(endBytes) && start >= endBytes)
57
- continue;
58
- if (_.isNumber(end) && end <= chunk.start)
59
- continue;
60
- yield {
61
- start: chunk.start,
62
- data: fs.readFile(chunk.path),
63
- };
64
- }
54
+ file: path.resolve(directory, x),
55
+ }));
56
+ }
57
+ async readChunk(proto, file) {
58
+ return fs.readFile(file);
65
59
  }
66
60
  async destroy(proto, token) {
67
61
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"filesystem.mjs","sources":["../../../../src/adapters/file/filesystem/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 path from 'path';\nimport fs from 'fs/promises';\nimport { ProtoService } from '../../../server/proto';\nimport FileStorageBase, { FileStorageOptions } from '../base';\n\nexport class FileSystemStorage extends FileStorageBase {\n\n volumn: string;\n\n constructor(volumn: string, options: FileStorageOptions = {}) {\n super(options);\n this.volumn = volumn;\n }\n\n async createChunk<E>(proto: ProtoService<E>, token: string, start: number, end: number, compressed: Buffer) {\n const directory = path.resolve(this.volumn, token);\n try {\n await fs.mkdir(directory, { recursive: true });\n } catch { }\n await fs.writeFile(path.join(directory, `${start}.chunk`), compressed);\n }\n\n async* readChunks<E>(proto: ProtoService<E>, token: string, start?: number | undefined, end?: number | undefined) {\n const directory = path.resolve(this.volumn, token);\n const _files = _.filter(await fs.readdir(directory), x => !!x.match(/^\\d+\\.chunk$/));\n const files = _.orderBy(_.map(_files, x => ({\n path: path.resolve(directory, x),\n start: parseInt(x.slice(0, -6)),\n })), 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 yield {\n start: chunk!.start,\n data: fs.readFile(chunk!.path),\n };\n }\n }\n\n async destroy<E>(proto: ProtoService<E>, token: string) {\n try {\n const directory = path.resolve(this.volumn, token);\n await fs.rm(directory, { recursive: true, force: true });\n } catch { }\n }\n};\n\nexport default FileSystemStorage;"],"names":[],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAQM,MAAO,iBAAkB,SAAQ,eAAe,CAAA;AAEpD,IAAA,MAAM;IAEN,WAAY,CAAA,MAAc,EAAE,OAAA,GAA8B,EAAE,EAAA;QACxD,KAAK,CAAC,OAAO,CAAC;AAChB,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;;IAGtB,MAAM,WAAW,CAAI,KAAsB,EAAE,KAAa,EAAE,K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,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;YAC5C,MAAM;gBACJ,KAAK,EAAE,KAAM,CAAC,KAAK;gBACnB,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAM,CAAC,IAAI,CAAC;aAC/B;;;AAIL,IAAA,MAAM,OAAO,CAAI,KAAsB,EAAE,KAAa,EAAA;AACpD,QAAA,IAAI;AACF,YAAA,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC;AAClD,YAAA,MAAM,EAAE,CAAC,EAAE,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;;QACxD,MAAM;;AAEX;;;;"}
1
+ {"version":3,"file":"filesystem.mjs","sources":["../../../../src/adapters/file/filesystem/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 path from 'path';\nimport fs from 'fs/promises';\nimport { ProtoService } from '../../../server/proto';\nimport { FileStorageOptions } from '../base';\nimport { FileChunkStorageBase } from '../base/chunk';\n\nexport class FileSystemStorage extends FileChunkStorageBase<string> {\n\n volumn: string;\n\n constructor(volumn: string, options: FileStorageOptions = {}) {\n super(options);\n this.volumn = volumn;\n }\n\n async createChunk<E>(proto: ProtoService<E>, token: string, start: number, end: number, compressed: Buffer) {\n const directory = path.resolve(this.volumn, token);\n try {\n await fs.mkdir(directory, { recursive: true });\n } catch { }\n await fs.writeFile(path.join(directory, `${start}.chunk`), compressed);\n }\n\n async listChunks<E>(proto: ProtoService<E>, token: string) {\n const directory = path.resolve(this.volumn, token);\n const files = _.filter(await fs.readdir(directory), x => !!x.match(/^\\d+\\.chunk$/));\n return _.map(files, x => ({\n start: parseInt(x.slice(0, -6)),\n file: path.resolve(directory, x),\n }));\n }\n\n async readChunk<E>(proto: ProtoService<E>, file: string) {\n return fs.readFile(file);\n }\n\n async destroy<E>(proto: ProtoService<E>, token: string) {\n try {\n const directory = path.resolve(this.volumn, token);\n await fs.rm(directory, { recursive: true, force: true });\n } catch { }\n }\n};\n\nexport default FileSystemStorage;"],"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,iBAAkB,SAAQ,oBAA4B,CAAA;AAEjE,IAAA,MAAM;IAEN,WAAY,CAAA,MAAc,EAAE,OAAA,GAA8B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AE,KAAa,EAAA;AACpD,QAAA,IAAI;AACF,YAAA,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC;AAClD,YAAA,MAAM,EAAE,CAAC,EAAE,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;;QACxD,MAAM;;AAEX;;;;"}
@@ -1,7 +1,8 @@
1
1
  import * as _google_cloud_storage from '@google-cloud/storage';
2
- import { Storage } from '@google-cloud/storage';
2
+ import { File, Storage } from '@google-cloud/storage';
3
3
  import { P as ProtoService } from '../../internals/index-C8EuFNYa.js';
4
- import { F as FileStorageBase, a as FileStorageOptions } from '../../internals/index-DvpJENaG.js';
4
+ import { a as FileStorageOptions } from '../../internals/base-DvpJENaG.js';
5
+ import { F as FileChunkStorageBase } from '../../internals/chunk-BZdO1nZ9.js';
5
6
  import '@o2ter/utils-js';
6
7
  import 'jsonwebtoken';
7
8
  import '@o2ter/server-js';
@@ -10,16 +11,17 @@ import 'lodash';
10
11
  import 'node:stream';
11
12
  import 'socket.io-client';
12
13
 
13
- declare class GoogleCloudStorage extends FileStorageBase {
14
+ declare class GoogleCloudStorage extends FileChunkStorageBase<File> {
14
15
  private _storage;
15
16
  private _bucket;
16
17
  constructor(storage: Storage, bucket: string, options?: FileStorageOptions);
17
18
  get bucket(): _google_cloud_storage.Bucket;
18
19
  createChunk<E>(proto: ProtoService<E>, token: string, start: number, end: number, compressed: Buffer): Promise<void>;
19
- readChunks<E>(proto: ProtoService<E>, token: string, start?: number | undefined, end?: number | undefined): AsyncGenerator<{
20
+ listChunks<E>(proto: ProtoService<E>, token: string): Promise<{
21
+ file: File;
20
22
  start: number;
21
- data: Promise<Buffer<ArrayBufferLike>>;
22
- }, void, unknown>;
23
+ }[]>;
24
+ readChunk<E>(proto: ProtoService<E>, file: File): Promise<Buffer<ArrayBufferLike>>;
23
25
  destroy<E>(proto: ProtoService<E>, token: string): Promise<void>;
24
26
  }
25
27
 
@@ -3,7 +3,8 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var _ = require('lodash');
6
- var index = require('../../internals/index-DfPY7Xbb.js');
6
+ var chunk = require('../../internals/chunk-CdEGTub2.js');
7
+ require('../../internals/base-NsJYo2MG.js');
7
8
  require('util');
8
9
  require('zlib');
9
10
  require('@o2ter/utils-js');
@@ -33,7 +34,7 @@ require('../../internals/private-Ciddhure.js');
33
34
  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
34
35
  // THE SOFTWARE.
35
36
  //
36
- class GoogleCloudStorage extends index.FileStorageBase {
37
+ class GoogleCloudStorage extends chunk.FileChunkStorageBase {
37
38
  _storage;
38
39
  _bucket;
39
40
  constructor(storage, bucket, options = {}) {
@@ -47,34 +48,25 @@ class GoogleCloudStorage extends index.FileStorageBase {
47
48
  async createChunk(proto, token, start, end, compressed) {
48
49
  await this.bucket.file(`${token}/${start}.chunk`).save(compressed);
49
50
  }
50
- async *readChunks(proto, token, start, end) {
51
+ async listChunks(proto, token) {
51
52
  const [response] = await this.bucket.getFiles({
52
53
  prefix: `${token}/`,
53
54
  delimiter: '/',
54
55
  });
55
- const _files = _.filter(_.map(response, x => ({
56
+ const files = _.map(response, x => ({
56
57
  file: x,
57
58
  name: _.last(_.split(x.name, '/')),
58
- })), x => !!x.name?.match(/^\d+\.chunk$/));
59
- const files = _.orderBy(_.map(_files, x => ({
59
+ }));
60
+ return _.map(_.filter(files, x => !!x.name?.match(/^\d+\.chunk$/)), x => ({
60
61
  file: x.file,
61
62
  start: parseInt(x.name.slice(0, -6)),
62
- })), x => x.start);
63
- for (const [chunk, endBytes] of _.zip(files, _.slice(_.map(files, x => x.start), 1))) {
64
- if (_.isNumber(start) && _.isNumber(endBytes) && start >= endBytes)
65
- continue;
66
- if (_.isNumber(end) && end <= chunk.start)
67
- continue;
68
- yield {
69
- start: chunk.start,
70
- data: (async () => {
71
- const [buffer] = await chunk?.file.download() ?? [];
72
- if (!buffer)
73
- throw Error('Unable to connect cloud storage');
74
- return buffer;
75
- })(),
76
- };
77
- }
63
+ }));
64
+ }
65
+ async readChunk(proto, file) {
66
+ const [buffer] = await file.download() ?? [];
67
+ if (!buffer)
68
+ throw Error('Unable to connect cloud storage');
69
+ return buffer;
78
70
  }
79
71
  async destroy(proto, token) {
80
72
  await this.bucket.deleteFiles({ prefix: `${token}/` });
@@ -1 +1 @@
1
- {"version":3,"file":"google-cloud-storage.js","sources":["../../../../src/adapters/file/google-cloud-storage/index.ts"],"sourcesContent":["//\n// index.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { ProtoService } from '../../../server/proto';\nimport { Storage } from '@google-cloud/storage';\nimport FileStorageBase, { FileStorageOptions } from '../base';\n\nexport class GoogleCloudStorage extends FileStorageBase {\n\n private _storage: Storage;\n private _bucket: string;\n\n constructor(storage: Storage, bucket: string, options: FileStorageOptions = {}) {\n super(options);\n this._storage = storage;\n this._bucket = bucket;\n }\n\n get bucket() {\n return this._storage.bucket(this._bucket);\n }\n\n async createChunk<E>(proto: ProtoService<E>, token: string, start: number, end: number, compressed: Buffer) {\n await this.bucket.file(`${token}/${start}.chunk`).save(compressed);\n }\n\n async* readChunks<E>(proto: ProtoService<E>, token: string, start?: number | undefined, end?: number | undefined) {\n const [response] = await this.bucket.getFiles({\n prefix: `${token}/`,\n delimiter: '/',\n });\n const _files = _.filter(_.map(response, x => ({\n file: x,\n name: _.last(_.split(x.name, '/')),\n })), x => !!x.name?.match(/^\\d+\\.chunk$/));\n const files = _.orderBy(_.map(_files, x => ({\n file: x.file,\n start: parseInt(x.name!.slice(0, -6)),\n })), 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 yield {\n start: chunk!.start,\n data: (async () => {\n const [buffer] = await chunk?.file.download() ?? [];\n if (!buffer) throw Error('Unable to connect cloud storage');\n return buffer;\n })(),\n };\n }\n }\n\n async destroy<E>(proto: ProtoService<E>, token: string) {\n await this.bucket.deleteFiles({ prefix: `${token}/` });\n }\n};\n\nexport default GoogleCloudStorage;"],"names":["FileStorageBase"],"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,kBAAmB,SAAQA,qBAAe,CAAA;AAE7C,IAAA,QAAQ;AACR,IAAA,OAAO;AAEf,IAAA,WAAA,CAAY,OAAgB,EAAE,MAAc,EAAE,UAA8B,EAAE,EAAA;QAC5E,KAAK,CAAC,OAAO,CAAC;AACd,QAAA,IAAI,CAAC,QAAQ,GAAG,OAAO;AACvB,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AAC;SACtC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC;AAClB,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;YAC5C,MAAM;gBACJ,KAAK,EAAE,KAAM,CAAC,KAAK;AACnB,gBAAA,IAAI,EAAE,CAAC,YAAW;AAChB,oBAAA,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE;AACnD,oBAAA,IAAI,CAAC,MAAM;AAAE,wBAAA,MAAM,KAAK,CAAC,iCAAiC,CAAC;AAC3D,oBAAA,OAAO,MAAM;AACf,iBAAC,GAAG;aACL;;;AAIL,IAAA,MAAM,OAAO,CAAI,KAAsB,EAAE,KAAa,EAAA;AACpD,QAAA,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAG,EAAA,KAAK,CAAG,CAAA,CAAA,EAAE,CAAC;;AAEzD;;;;;"}
1
+ {"version":3,"file":"google-cloud-storage.js","sources":["../../../../src/adapters/file/google-cloud-storage/index.ts"],"sourcesContent":["//\n// index.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { ProtoService } from '../../../server/proto';\nimport { Storage, File } from '@google-cloud/storage';\nimport { FileStorageOptions } from '../base';\nimport { FileChunkStorageBase } from '../base/chunk';\n\nexport class GoogleCloudStorage extends FileChunkStorageBase<File> {\n\n private _storage: Storage;\n private _bucket: string;\n\n constructor(storage: Storage, bucket: string, options: FileStorageOptions = {}) {\n super(options);\n this._storage = storage;\n this._bucket = bucket;\n }\n\n get bucket() {\n return this._storage.bucket(this._bucket);\n }\n\n async createChunk<E>(proto: ProtoService<E>, token: string, start: number, end: number, compressed: Buffer) {\n await this.bucket.file(`${token}/${start}.chunk`).save(compressed);\n }\n\n async listChunks<E>(proto: ProtoService<E>, token: string) {\n const [response] = await this.bucket.getFiles({\n prefix: `${token}/`,\n delimiter: '/',\n });\n const files = _.map(response, x => ({\n file: x,\n name: _.last(_.split(x.name, '/'))!,\n }));\n return _.map(_.filter(files, x => !!x.name?.match(/^\\d+\\.chunk$/)), x => ({\n file: x.file,\n start: parseInt(x.name.slice(0, -6)),\n }));\n }\n\n async readChunk<E>(proto: ProtoService<E>, file: File) {\n const [buffer] = await file.download() ?? [];\n if (!buffer) throw Error('Unable to connect cloud storage');\n return buffer;\n }\n\n async destroy<E>(proto: ProtoService<E>, token: string) {\n await this.bucket.deleteFiles({ prefix: `${token}/` });\n }\n};\n\nexport default GoogleCloudStorage;"],"names":["FileChunkStorageBase"],"mappings":";;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAQM,MAAO,kBAAmB,SAAQA,0BAA0B,CAAA;AAExD,IAAA,QAAQ;AACR,IAAA,OAAO;AAEf,IAAA,WAAA,CAAY,OAAgB,EAAE,MAAc,EAAE,UAA8B,EAAE,EAAA;QAC5E,KAAK,CAAC,OAAO,CAAC;AACd,QAAA,IAAI,CAAC,QAAQ,GAAG,OAAO;AACvB,QAAA,IAAI,CAAC,OAAO,GAAG,MAAM;;AAGvB,IAAA,IAAI,MAAM,GAAA;QACR,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;;IAG3C,MAAM,WAAW,CAAI,KAAsB,EAAE,KAAa,EAAE,KAAa,EAAE,GAAW,EAAE,UAAkB,EAAA;AACxG,QAAA,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAG,EAAA,KAAK,CAAI,CAAA,EAAA,KAAK,QAAQ,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC;;AAGpE,IAAA,MAAM,UAAU,CAAI,KAAsB,EAAE,KAAa,EAAA;QACvD,MAAM,CAAC,QAAQ,CAAC,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;YAC5C,MAAM,EAAE,CAAG,EAAA,KAAK,CAAG,CAAA,CAAA;AACnB,YAAA,SAAS,EAAE,GAAG;AACf,SAAA,CAAC;AACF,QAAA,MAAM,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,KAAK;AAClC,YAAA,IAAI,EAAE,CAAC;AACP,YAAA,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,GAAG,CAAC,CAAE;AACpC,SAAA,CAAC,CAAC;AACH,QAAA,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC,KAAK;YACxE,IAAI,EAAE,CAAC,CAAC,IAAI;AACZ,YAAA,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACrC,SAAA,CAAC,CAAC;;AAGL,IAAA,MAAM,SAAS,CAAI,KAAsB,EAAE,IAAU,EAAA;QACnD,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE;AAC5C,QAAA,IAAI,CAAC,MAAM;AAAE,YAAA,MAAM,KAAK,CAAC,iCAAiC,CAAC;AAC3D,QAAA,OAAO,MAAM;;AAGf,IAAA,MAAM,OAAO,CAAI,KAAsB,EAAE,KAAa,EAAA;AACpD,QAAA,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAG,EAAA,KAAK,CAAG,CAAA,CAAA,EAAE,CAAC;;AAEzD;;;;;"}
@@ -1,5 +1,6 @@
1
1
  import _ from 'lodash';
2
- import { F as FileStorageBase } from '../../internals/index-BAFVUYCo.mjs';
2
+ import { F as FileChunkStorageBase } from '../../internals/chunk-3nNdftWC.mjs';
3
+ import '../../internals/base-DYc1_peK.mjs';
3
4
  import 'util';
4
5
  import 'zlib';
5
6
  import '@o2ter/utils-js';
@@ -29,7 +30,7 @@ import '../../internals/private-CNw40LZ7.mjs';
29
30
  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30
31
  // THE SOFTWARE.
31
32
  //
32
- class GoogleCloudStorage extends FileStorageBase {
33
+ class GoogleCloudStorage extends FileChunkStorageBase {
33
34
  _storage;
34
35
  _bucket;
35
36
  constructor(storage, bucket, options = {}) {
@@ -43,34 +44,25 @@ class GoogleCloudStorage extends FileStorageBase {
43
44
  async createChunk(proto, token, start, end, compressed) {
44
45
  await this.bucket.file(`${token}/${start}.chunk`).save(compressed);
45
46
  }
46
- async *readChunks(proto, token, start, end) {
47
+ async listChunks(proto, token) {
47
48
  const [response] = await this.bucket.getFiles({
48
49
  prefix: `${token}/`,
49
50
  delimiter: '/',
50
51
  });
51
- const _files = _.filter(_.map(response, x => ({
52
+ const files = _.map(response, x => ({
52
53
  file: x,
53
54
  name: _.last(_.split(x.name, '/')),
54
- })), x => !!x.name?.match(/^\d+\.chunk$/));
55
- const files = _.orderBy(_.map(_files, x => ({
55
+ }));
56
+ return _.map(_.filter(files, x => !!x.name?.match(/^\d+\.chunk$/)), x => ({
56
57
  file: x.file,
57
58
  start: parseInt(x.name.slice(0, -6)),
58
- })), x => x.start);
59
- for (const [chunk, endBytes] of _.zip(files, _.slice(_.map(files, x => x.start), 1))) {
60
- if (_.isNumber(start) && _.isNumber(endBytes) && start >= endBytes)
61
- continue;
62
- if (_.isNumber(end) && end <= chunk.start)
63
- continue;
64
- yield {
65
- start: chunk.start,
66
- data: (async () => {
67
- const [buffer] = await chunk?.file.download() ?? [];
68
- if (!buffer)
69
- throw Error('Unable to connect cloud storage');
70
- return buffer;
71
- })(),
72
- };
73
- }
59
+ }));
60
+ }
61
+ async readChunk(proto, file) {
62
+ const [buffer] = await file.download() ?? [];
63
+ if (!buffer)
64
+ throw Error('Unable to connect cloud storage');
65
+ return buffer;
74
66
  }
75
67
  async destroy(proto, token) {
76
68
  await this.bucket.deleteFiles({ prefix: `${token}/` });
@@ -1 +1 @@
1
- {"version":3,"file":"google-cloud-storage.mjs","sources":["../../../../src/adapters/file/google-cloud-storage/index.ts"],"sourcesContent":["//\n// index.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { ProtoService } from '../../../server/proto';\nimport { Storage } from '@google-cloud/storage';\nimport FileStorageBase, { FileStorageOptions } from '../base';\n\nexport class GoogleCloudStorage extends FileStorageBase {\n\n private _storage: Storage;\n private _bucket: string;\n\n constructor(storage: Storage, bucket: string, options: FileStorageOptions = {}) {\n super(options);\n this._storage = storage;\n this._bucket = bucket;\n }\n\n get bucket() {\n return this._storage.bucket(this._bucket);\n }\n\n async createChunk<E>(proto: ProtoService<E>, token: string, start: number, end: number, compressed: Buffer) {\n await this.bucket.file(`${token}/${start}.chunk`).save(compressed);\n }\n\n async* readChunks<E>(proto: ProtoService<E>, token: string, start?: number | undefined, end?: number | undefined) {\n const [response] = await this.bucket.getFiles({\n prefix: `${token}/`,\n delimiter: '/',\n });\n const _files = _.filter(_.map(response, x => ({\n file: x,\n name: _.last(_.split(x.name, '/')),\n })), x => !!x.name?.match(/^\\d+\\.chunk$/));\n const files = _.orderBy(_.map(_files, x => ({\n file: x.file,\n start: parseInt(x.name!.slice(0, -6)),\n })), 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 yield {\n start: chunk!.start,\n data: (async () => {\n const [buffer] = await chunk?.file.download() ?? [];\n if (!buffer) throw Error('Unable to connect cloud storage');\n return buffer;\n })(),\n };\n }\n }\n\n async destroy<E>(proto: ProtoService<E>, token: string) {\n await this.bucket.deleteFiles({ prefix: `${token}/` });\n }\n};\n\nexport default GoogleCloudStorage;"],"names":[],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAOM,MAAO,kBAAmB,SAAQ,eAAe,CAAA;AAE7C,IAAA,QAAQ;AACR,IAAA,OAAO;AAEf,IAAA,WAAA,CAAY,OAAgB,EAAE,MAAc,EAAE,UAA8B,EAAE,EAAA;QAC5E,KAAK,CAAC,OAAO,CAAC;AACd,QAAA,IAAI,CAAC,QAAQ,GAAG,OAAO;AACvB,QAAA,IAAI,CAAC,OAAO,GAAG,MAAM;;AAGvB,IAAA,IAAI,MAAM,GAAA;QACR,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;;IAG3C,MAAM,WAAW,CAAI,KAAsB,EAAE,KAAa,EAAE,KAAa,EAAE,GAAW,EAAE,UAAkB,EAAA;AACxG,QAAA,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAG,EAAA,KAAK,CAAI,CAAA,EAAA,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AAQ,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;YAC5C,MAAM;gBACJ,KAAK,EAAE,KAAM,CAAC,KAAK;AACnB,gBAAA,IAAI,EAAE,CAAC,YAAW;AAChB,oBAAA,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE;AACnD,oBAAA,IAAI,CAAC,MAAM;AAAE,wBAAA,MAAM,KAAK,CAAC,iCAAiC,CAAC;AAC3D,oBAAA,OAAO,MAAM;AACf,iBAAC,GAAG;aACL;;;AAIL,IAAA,MAAM,OAAO,CAAI,KAAsB,EAAE,KAAa,EAAA;AACpD,QAAA,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAG,EAAA,KAAK,CAAG,CAAA,CAAA,EAAE,CAAC;;AAEzD;;;;"}
1
+ {"version":3,"file":"google-cloud-storage.mjs","sources":["../../../../src/adapters/file/google-cloud-storage/index.ts"],"sourcesContent":["//\n// index.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { ProtoService } from '../../../server/proto';\nimport { Storage, File } from '@google-cloud/storage';\nimport { FileStorageOptions } from '../base';\nimport { FileChunkStorageBase } from '../base/chunk';\n\nexport class GoogleCloudStorage extends FileChunkStorageBase<File> {\n\n private _storage: Storage;\n private _bucket: string;\n\n constructor(storage: Storage, bucket: string, options: FileStorageOptions = {}) {\n super(options);\n this._storage = storage;\n this._bucket = bucket;\n }\n\n get bucket() {\n return this._storage.bucket(this._bucket);\n }\n\n async createChunk<E>(proto: ProtoService<E>, token: string, start: number, end: number, compressed: Buffer) {\n await this.bucket.file(`${token}/${start}.chunk`).save(compressed);\n }\n\n async listChunks<E>(proto: ProtoService<E>, token: string) {\n const [response] = await this.bucket.getFiles({\n prefix: `${token}/`,\n delimiter: '/',\n });\n const files = _.map(response, x => ({\n file: x,\n name: _.last(_.split(x.name, '/'))!,\n }));\n return _.map(_.filter(files, x => !!x.name?.match(/^\\d+\\.chunk$/)), x => ({\n file: x.file,\n start: parseInt(x.name.slice(0, -6)),\n }));\n }\n\n async readChunk<E>(proto: ProtoService<E>, file: File) {\n const [buffer] = await file.download() ?? [];\n if (!buffer) throw Error('Unable to connect cloud storage');\n return buffer;\n }\n\n async destroy<E>(proto: ProtoService<E>, token: string) {\n await this.bucket.deleteFiles({ prefix: `${token}/` });\n }\n};\n\nexport default GoogleCloudStorage;"],"names":[],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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Ac,CAAC,CAAC,EAAE,CAAC,KAAK;YACxE,IAAI,EAAE,CAAC,CAAC,IAAI;AACZ,YAAA,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACrC,SAAA,CAAC,CAAC;;AAGL,IAAA,MAAM,SAAS,CAAI,KAAsB,EAAE,IAAU,EAAA;QACnD,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE;AAC5C,QAAA,IAAI,CAAC,MAAM;AAAE,YAAA,MAAM,KAAK,CAAC,iCAAiC,CAAC;AAC3D,QAAA,OAAO,MAAM;;AAGf,IAAA,MAAM,OAAO,CAAI,KAAsB,EAAE,KAAa,EAAA;AACpD,QAAA,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAG,EAAA,KAAK,CAAG,CAAA,CAAA,EAAE,CAAC;;AAEzD;;;;"}
@@ -5,7 +5,7 @@ import { parallelEach, binaryStreamChunk, parallelMap } from '@o2ter/utils-js';
5
5
  import { P as PVK } from './private-CNw40LZ7.mjs';
6
6
 
7
7
  //
8
- // index.ts
8
+ // base.ts
9
9
  //
10
10
  // The MIT License
11
11
  // Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
@@ -79,4 +79,4 @@ class FileStorageBase {
79
79
  }
80
80
 
81
81
  export { FileStorageBase as F };
82
- //# sourceMappingURL=index-BAFVUYCo.mjs.map
82
+ //# sourceMappingURL=base-DYc1_peK.mjs.map
@@ -0,0 +1 @@
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,IA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jF,QAAA,MAAM,OAAO,GAAG,WAAW,CACzB,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,CAAC,EACtC,IAAI,CAAC,OAAO,CAAC,QAAQ,EACrB,OAAM,KAAK,MAAK;YACd,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,IAAI,EAAE,MAAM,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC;AACpC,SAAA,CAAC,CACH;AAED,QAAA,WAAW,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,OAAO,EAAE;AAEvD,YAAA,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;AAE1C,gBAAA,MAAM,IAAI;;iBAEL;AAEL,gBAAA,MAAM,QAAQ,GAAG,UAAU,GAAG,IAAI,CAAC,MAAM;gBACzC,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,SAAS;gBAE7E,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;;;;AAIxC;;;;"}
@@ -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=index-DvpJENaG.d.ts.map
26
+ //# sourceMappingURL=base-DvpJENaG.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-DvpJENaG.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -7,7 +7,7 @@ var utilsJs = require('@o2ter/utils-js');
7
7
  var _private = require('./private-Ciddhure.js');
8
8
 
9
9
  //
10
- // index.ts
10
+ // base.ts
11
11
  //
12
12
  // The MIT License
13
13
  // Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
@@ -81,4 +81,4 @@ class FileStorageBase {
81
81
  }
82
82
 
83
83
  exports.FileStorageBase = FileStorageBase;
84
- //# sourceMappingURL=index-DfPY7Xbb.js.map
84
+ //# sourceMappingURL=base-NsJYo2MG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-NsJYo2MG.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;\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,OAAO,GAAGA,cAAS,CAACC,YAAQ,CAAC;AACnC,MAAM,KAAK,GAAGD,cAAS,CAACE,UAAM,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,CAACC,YAAG,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,MAAMC,oBAAY,CAChB,OAAO,CAACC,yBAAiB,CAAC,M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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,SAAS;gBAE7E,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;;;;AAIxC;;;;"}
@@ -0,0 +1,47 @@
1
+ import _ from 'lodash';
2
+ import { F as FileStorageBase } from './base-DYc1_peK.mjs';
3
+
4
+ //
5
+ // object.ts
6
+ //
7
+ // The MIT License
8
+ // Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
9
+ //
10
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ // of this software and associated documentation files (the "Software"), to deal
12
+ // in the Software without restriction, including without limitation the rights
13
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ // copies of the Software, and to permit persons to whom the Software is
15
+ // furnished to do so, subject to the following conditions:
16
+ //
17
+ // The above copyright notice and this permission notice shall be included in
18
+ // all copies or substantial portions of the Software.
19
+ //
20
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26
+ // THE SOFTWARE.
27
+ //
28
+ class FileChunkStorageBase extends FileStorageBase {
29
+ async *readChunks(proto, token, start, end) {
30
+ const files = _.orderBy(await this.listChunks(proto, token), x => x.start);
31
+ for (const [chunk, endBytes] of _.zip(files, _.slice(_.map(files, x => x.start), 1))) {
32
+ if (_.isNumber(start) && _.isNumber(endBytes) && start >= endBytes)
33
+ continue;
34
+ if (_.isNumber(end) && end <= chunk.start)
35
+ continue;
36
+ if (!chunk)
37
+ continue;
38
+ yield {
39
+ start: chunk.start,
40
+ data: (async () => this.readChunk(proto, chunk.file))(),
41
+ };
42
+ }
43
+ }
44
+ }
45
+
46
+ export { FileChunkStorageBase as F };
47
+ //# sourceMappingURL=chunk-3nNdftWC.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk-3nNdftWC.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';\n\nexport abstract class FileChunkStorageBase<File> extends FileStorageBase {\n\n abstract listChunks<E>(proto: ProtoService<E>, token: string): PromiseLike<{\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 | undefined, end?: number | undefined) {\n const files = _.orderBy(await this.listChunks(proto, token), 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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMM,MAAgB,oBAA2B,SAAQ,eAAe,CAAA;IAStE,OAAO,UAAU,CAAI,KAAsB,EAAE,KAAa,EAAE,KAA0B,EAAE,GAAwB,EAAA;QAC9G,MAAM,KAAK,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC;AAC1E,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;;;;"}
@@ -0,0 +1,17 @@
1
+ import { F as FileStorageBase } from './base-DvpJENaG.js';
2
+ import { P as ProtoService } from './index-C8EuFNYa.js';
3
+
4
+ declare abstract class FileChunkStorageBase<File> extends FileStorageBase {
5
+ abstract listChunks<E>(proto: ProtoService<E>, token: string): PromiseLike<{
6
+ start: number;
7
+ file: File;
8
+ }[]>;
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<{
11
+ start: number;
12
+ data: Promise<Buffer<ArrayBufferLike>>;
13
+ }, void, unknown>;
14
+ }
15
+
16
+ export { FileChunkStorageBase as F };
17
+ //# sourceMappingURL=chunk-BZdO1nZ9.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk-BZdO1nZ9.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,49 @@
1
+ 'use strict';
2
+
3
+ var _ = require('lodash');
4
+ var base = require('./base-NsJYo2MG.js');
5
+
6
+ //
7
+ // object.ts
8
+ //
9
+ // The MIT License
10
+ // Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.
11
+ //
12
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ // of this software and associated documentation files (the "Software"), to deal
14
+ // in the Software without restriction, including without limitation the rights
15
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ // copies of the Software, and to permit persons to whom the Software is
17
+ // furnished to do so, subject to the following conditions:
18
+ //
19
+ // The above copyright notice and this permission notice shall be included in
20
+ // all copies or substantial portions of the Software.
21
+ //
22
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28
+ // THE SOFTWARE.
29
+ //
30
+ class FileChunkStorageBase extends base.FileStorageBase {
31
+ async *readChunks(proto, token, start, end) {
32
+ const files = _.orderBy(await this.listChunks(proto, token), x => x.start);
33
+ for (const [chunk, endBytes] of _.zip(files, _.slice(_.map(files, x => x.start), 1))) {
34
+ if (_.isNumber(start) && _.isNumber(endBytes) && start >= endBytes)
35
+ continue;
36
+ if (_.isNumber(end) && end <= chunk.start)
37
+ continue;
38
+ if (!chunk)
39
+ continue;
40
+ yield {
41
+ start: chunk.start,
42
+ data: (async () => this.readChunk(proto, chunk.file))(),
43
+ };
44
+ }
45
+ }
46
+ }
47
+
48
+ exports.FileChunkStorageBase = FileChunkStorageBase;
49
+ //# sourceMappingURL=chunk-CdEGTub2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk-CdEGTub2.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';\n\nexport abstract class FileChunkStorageBase<File> extends FileStorageBase {\n\n abstract listChunks<E>(proto: ProtoService<E>, token: string): PromiseLike<{\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 | undefined, end?: number | undefined) {\n const files = _.orderBy(await this.listChunks(proto, token), 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"],"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;AAMM,MAAgB,oBAA2B,SAAQA,oBAAe,CAAA;IAStE,OAAO,UAAU,CAAI,KAAsB,EAAE,KAAa,EAAE,KAA0B,EAAE,GAAwB,EAAA;QAC9G,MAAM,KAAK,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC;AAC1E,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;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "proto.io",
3
- "version": "0.0.199",
3
+ "version": "0.0.201",
4
4
  "main": "dist/index",
5
5
  "module": "dist/index",
6
6
  "types": "dist/index",
@@ -19,6 +19,7 @@
19
19
  "@google-cloud/storage": "^7.14.0",
20
20
  "@o2ter/crypto-js": "^0.0.7",
21
21
  "@o2ter/utils-js": "^0.0.17",
22
+ "ali-oss": "^6.22.0",
22
23
  "axios": "^1.7.7",
23
24
  "busboy": "^1.6.0",
24
25
  "decimal.js": "^10.4.3",
@@ -26,6 +27,7 @@
26
27
  "lodash": ">=4.17.21",
27
28
  "pg": "^8.13.1",
28
29
  "pg-query-stream": "^4.7.1",
30
+ "proxy-agent": "^6.5.0",
29
31
  "query-types": "^0.1.4",
30
32
  "socket.io-client": "^4.8.1"
31
33
  },
@@ -39,6 +41,7 @@
39
41
  "@rollup/plugin-json": "^6.1.0",
40
42
  "@rollup/plugin-node-resolve": "^15.3.0",
41
43
  "@rollup/plugin-typescript": "^12.1.1",
44
+ "@types/ali-oss": "^6.16.11",
42
45
  "@types/busboy": "^1.5.4",
43
46
  "@types/jsonwebtoken": "^9.0.7",
44
47
  "@types/lodash": "^4.17.13",
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-BAFVUYCo.mjs","sources":["../../../src/adapters/file/base/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 { 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\nexport default FileStorageBase;"],"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,C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AAI,CAAC,MAAM;gBACzC,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,SAAS;gBAE7E,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;;;;AAIxC;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-DfPY7Xbb.js","sources":["../../../src/adapters/file/base/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 { 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\nexport default FileStorageBase;"],"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,OAAO,GAAGA,cAAS,CAACC,YAAQ,CAAC;AACnC,MAAM,KAAK,GAAGD,cAAS,CAACE,UAAM,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,CAACC,YAAG,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,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