@marinoscar/platform-api 0.1.0-next.26 → 0.1.0-next.27

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 (57) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/manifest/platform-model-ownership.d.ts.map +1 -1
  3. package/dist/manifest/platform-model-ownership.js +19 -0
  4. package/dist/manifest/platform-model-ownership.js.map +1 -1
  5. package/dist/manifest/platform-user-owned-models.d.ts.map +1 -1
  6. package/dist/manifest/platform-user-owned-models.js +15 -0
  7. package/dist/manifest/platform-user-owned-models.js.map +1 -1
  8. package/dist/storage/config/storage-config.module.d.ts.map +1 -1
  9. package/dist/storage/config/storage-config.module.js +10 -1
  10. package/dist/storage/config/storage-config.module.js.map +1 -1
  11. package/dist/storage/data/storage-db.d.ts +118 -1
  12. package/dist/storage/data/storage-db.d.ts.map +1 -1
  13. package/dist/storage/data/storage-db.js +25 -1
  14. package/dist/storage/data/storage-db.js.map +1 -1
  15. package/dist/storage/index.d.ts +5 -2
  16. package/dist/storage/index.d.ts.map +1 -1
  17. package/dist/storage/index.js +25 -1
  18. package/dist/storage/index.js.map +1 -1
  19. package/dist/storage/migration/copy-and-verify.d.ts +39 -0
  20. package/dist/storage/migration/copy-and-verify.d.ts.map +1 -0
  21. package/dist/storage/migration/copy-and-verify.js +94 -0
  22. package/dist/storage/migration/copy-and-verify.js.map +1 -0
  23. package/dist/storage/migration/dto/storage-migration.dto.d.ts +73 -0
  24. package/dist/storage/migration/dto/storage-migration.dto.d.ts.map +1 -0
  25. package/dist/storage/migration/dto/storage-migration.dto.js +34 -0
  26. package/dist/storage/migration/dto/storage-migration.dto.js.map +1 -0
  27. package/dist/storage/migration/index.d.ts +11 -0
  28. package/dist/storage/migration/index.d.ts.map +1 -0
  29. package/dist/storage/migration/index.js +27 -0
  30. package/dist/storage/migration/index.js.map +1 -0
  31. package/dist/storage/migration/storage-migrate-object.handler.d.ts +40 -0
  32. package/dist/storage/migration/storage-migrate-object.handler.d.ts.map +1 -0
  33. package/dist/storage/migration/storage-migrate-object.handler.js +177 -0
  34. package/dist/storage/migration/storage-migrate-object.handler.js.map +1 -0
  35. package/dist/storage/migration/storage-migrate-plan.handler.d.ts +34 -0
  36. package/dist/storage/migration/storage-migrate-plan.handler.d.ts.map +1 -0
  37. package/dist/storage/migration/storage-migrate-plan.handler.js +168 -0
  38. package/dist/storage/migration/storage-migrate-plan.handler.js.map +1 -0
  39. package/dist/storage/migration/storage-migration-settled.listener.d.ts +15 -0
  40. package/dist/storage/migration/storage-migration-settled.listener.d.ts.map +1 -0
  41. package/dist/storage/migration/storage-migration-settled.listener.js +87 -0
  42. package/dist/storage/migration/storage-migration-settled.listener.js.map +1 -0
  43. package/dist/storage/migration/storage-migration.constants.d.ts +69 -0
  44. package/dist/storage/migration/storage-migration.constants.d.ts.map +1 -0
  45. package/dist/storage/migration/storage-migration.constants.js +83 -0
  46. package/dist/storage/migration/storage-migration.constants.js.map +1 -0
  47. package/dist/storage/migration/storage-migration.controller.d.ts +26 -0
  48. package/dist/storage/migration/storage-migration.controller.d.ts.map +1 -0
  49. package/dist/storage/migration/storage-migration.controller.js +135 -0
  50. package/dist/storage/migration/storage-migration.controller.js.map +1 -0
  51. package/dist/storage/migration/storage-migration.service.d.ts +182 -0
  52. package/dist/storage/migration/storage-migration.service.d.ts.map +1 -0
  53. package/dist/storage/migration/storage-migration.service.js +444 -0
  54. package/dist/storage/migration/storage-migration.service.js.map +1 -0
  55. package/dist/storage/ports.d.ts +1 -1
  56. package/dist/storage/ports.d.ts.map +1 -1
  57. package/package.json +3 -3
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ // =============================================================================
3
+ // Stream one object from a source provider to a target provider, then prove it
4
+ // (issue #1093)
5
+ // =============================================================================
6
+ //
7
+ // NEVER BUFFERED. The source download is piped through a metering transform
8
+ // (sha256 and byte count, computed on the same pass) straight into the target's
9
+ // `upload`, so memory is bounded by the stream's high-water mark whatever the
10
+ // object's size.
11
+ //
12
+ // VERIFIED BEFORE ANY REPOINT. After the upload resolves, the object is read
13
+ // BACK from the target, streamed through a second hash, and three facts must
14
+ // agree: the bytes read from the source, the bytes read back from the target,
15
+ // and the row's recorded size. A target that acknowledged an upload it did not
16
+ // keep, truncated it, or a source that changed under the copy, all fail here,
17
+ // and the caller leaves the row pointing at the source.
18
+ // =============================================================================
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.StorageCopyVerificationError = void 0;
21
+ exports.copyAndVerify = copyAndVerify;
22
+ const node_crypto_1 = require("node:crypto");
23
+ const node_stream_1 = require("node:stream");
24
+ /**
25
+ * A copy that did not verify. Thrown by {@link copyAndVerify}; the job retries it.
26
+ *
27
+ * @stability experimental
28
+ */
29
+ class StorageCopyVerificationError extends Error {
30
+ /** @param message - which fact disagreed. */
31
+ constructor(message) {
32
+ super(message);
33
+ this.name = 'StorageCopyVerificationError';
34
+ }
35
+ }
36
+ exports.StorageCopyVerificationError = StorageCopyVerificationError;
37
+ function meter() {
38
+ const hash = (0, node_crypto_1.createHash)('sha256');
39
+ let bytes = 0n;
40
+ const transform = new node_stream_1.Transform({
41
+ transform(chunk, _encoding, callback) {
42
+ hash.update(chunk);
43
+ bytes += BigInt(chunk.length);
44
+ callback(null, chunk);
45
+ },
46
+ });
47
+ return { transform, digest: () => ({ bytes, sha256: hash.digest('hex') }) };
48
+ }
49
+ async function hashStream(stream) {
50
+ const hash = (0, node_crypto_1.createHash)('sha256');
51
+ let bytes = 0n;
52
+ for await (const chunk of stream) {
53
+ const buffer = typeof chunk === 'string' ? Buffer.from(chunk) : chunk;
54
+ hash.update(buffer);
55
+ bytes += BigInt(buffer.length);
56
+ }
57
+ return { bytes, sha256: hash.digest('hex') };
58
+ }
59
+ /**
60
+ * Copies `key` from `source` to `target` under the same key, by streaming, and
61
+ * verifies the copy by reading it back.
62
+ *
63
+ * @param source - the provider the row records.
64
+ * @param target - the provider the run copies to.
65
+ * @param object - the row's key, media type and size.
66
+ * @returns the verified byte count and sha256.
67
+ * @throws StorageCopyVerificationError when a size or checksum disagrees; any provider error as thrown.
68
+ *
69
+ * @stability experimental
70
+ */
71
+ async function copyAndVerify(source, target, object) {
72
+ const input = await source.download(object.storageKey);
73
+ const metered = meter();
74
+ // A source error must abort the upload, not leave it waiting for more bytes.
75
+ input.once('error', (error) => metered.transform.destroy(error));
76
+ input.pipe(metered.transform);
77
+ await target.upload(object.storageKey, metered.transform, {
78
+ mimeType: object.mimeType,
79
+ contentLength: Number(object.size),
80
+ });
81
+ const sent = metered.digest();
82
+ if (sent.bytes !== object.size) {
83
+ throw new StorageCopyVerificationError(`read ${sent.bytes} byte(s) from the source but the row records ${object.size}`);
84
+ }
85
+ const readBack = await hashStream(await target.download(object.storageKey));
86
+ if (readBack.bytes !== sent.bytes) {
87
+ throw new StorageCopyVerificationError(`the target holds ${readBack.bytes} byte(s), ${sent.bytes} were sent`);
88
+ }
89
+ if (readBack.sha256 !== sent.sha256) {
90
+ throw new StorageCopyVerificationError('the checksum of the bytes read back from the target differs from the source');
91
+ }
92
+ return sent;
93
+ }
94
+ //# sourceMappingURL=copy-and-verify.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copy-and-verify.js","sourceRoot":"","sources":["../../../src/storage/migration/copy-and-verify.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,+EAA+E;AAC/E,gBAAgB;AAChB,gFAAgF;AAChF,EAAE;AACF,4EAA4E;AAC5E,gFAAgF;AAChF,8EAA8E;AAC9E,iBAAiB;AACjB,EAAE;AACF,6EAA6E;AAC7E,6EAA6E;AAC7E,8EAA8E;AAC9E,+EAA+E;AAC/E,8EAA8E;AAC9E,wDAAwD;AACxD,gFAAgF;;;AAyEhF,sCAkCC;AAzGD,6CAAyC;AACzC,6CAAuD;AAgBvD;;;;GAIG;AACH,MAAa,4BAA6B,SAAQ,KAAK;IACrD,6CAA6C;IAC7C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf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C;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,73 @@
1
+ import { startStorageMigrationSchema, storageMigrationListQuerySchema, storageMigrationRunListSchema, storageMigrationRunSchema } from '@marinoscar/platform-contract/storage';
2
+ export { startStorageMigrationSchema, storageMigrationListQuerySchema, storageMigrationRunListSchema, storageMigrationRunSchema };
3
+ export type { StartStorageMigrationInput, StorageMigrationListQuery, StorageMigrationRun, StorageMigrationRunList, } from '@marinoscar/platform-contract/storage';
4
+ declare const StartStorageMigrationDto_base: import("nestjs-zod").ZodDto<import("zod").ZodObject<{
5
+ sourceProvider: import("zod").ZodString;
6
+ targetProvider: import("zod").ZodString;
7
+ }, import("zod/v4/core").$strict>, false>;
8
+ /**
9
+ * `startStorageMigrationSchema` (`@marinoscar/platform-contract/storage`) as a Nest DTO: the OpenAPI component and the validated body.
10
+ *
11
+ * @stability experimental
12
+ */
13
+ export declare class StartStorageMigrationDto extends StartStorageMigrationDto_base {
14
+ }
15
+ declare const StorageMigrationRunDto_base: import("nestjs-zod").ZodDto<import("zod").ZodObject<{
16
+ id: import("zod").ZodString;
17
+ sourceProvider: import("zod").ZodString;
18
+ targetProvider: import("zod").ZodString;
19
+ status: import("zod").ZodEnum<import("@marinoscar/platform-contract/storage").StorageEnum<typeof import("@marinoscar/platform-contract/storage").STORAGE_MIGRATION_RUN_STATUSES>>;
20
+ totalCount: import("zod").ZodNumber;
21
+ migratedCount: import("zod").ZodNumber;
22
+ failedCount: import("zod").ZodNumber;
23
+ skippedCount: import("zod").ZodNumber;
24
+ pendingCount: import("zod").ZodNumber;
25
+ startedById: import("zod").ZodNullable<import("zod").ZodString>;
26
+ startedAt: import("zod").ZodNullable<import("zod").ZodString>;
27
+ plannedAt: import("zod").ZodNullable<import("zod").ZodString>;
28
+ finishedAt: import("zod").ZodNullable<import("zod").ZodString>;
29
+ cancelledAt: import("zod").ZodNullable<import("zod").ZodString>;
30
+ lastError: import("zod").ZodNullable<import("zod").ZodString>;
31
+ createdAt: import("zod").ZodString;
32
+ }, import("zod/v4/core").$strip>, false>;
33
+ /**
34
+ * `storageMigrationRunSchema` (`@marinoscar/platform-contract/storage`) as a Nest DTO: the OpenAPI component of one run.
35
+ *
36
+ * @stability experimental
37
+ */
38
+ export declare class StorageMigrationRunDto extends StorageMigrationRunDto_base {
39
+ }
40
+ declare const StorageMigrationRunListDto_base: import("nestjs-zod").ZodDto<import("zod").ZodObject<{
41
+ items: import("zod").ZodArray<import("zod").ZodObject<{
42
+ id: import("zod").ZodString;
43
+ sourceProvider: import("zod").ZodString;
44
+ targetProvider: import("zod").ZodString;
45
+ status: import("zod").ZodEnum<import("@marinoscar/platform-contract/storage").StorageEnum<typeof import("@marinoscar/platform-contract/storage").STORAGE_MIGRATION_RUN_STATUSES>>;
46
+ totalCount: import("zod").ZodNumber;
47
+ migratedCount: import("zod").ZodNumber;
48
+ failedCount: import("zod").ZodNumber;
49
+ skippedCount: import("zod").ZodNumber;
50
+ pendingCount: import("zod").ZodNumber;
51
+ startedById: import("zod").ZodNullable<import("zod").ZodString>;
52
+ startedAt: import("zod").ZodNullable<import("zod").ZodString>;
53
+ plannedAt: import("zod").ZodNullable<import("zod").ZodString>;
54
+ finishedAt: import("zod").ZodNullable<import("zod").ZodString>;
55
+ cancelledAt: import("zod").ZodNullable<import("zod").ZodString>;
56
+ lastError: import("zod").ZodNullable<import("zod").ZodString>;
57
+ createdAt: import("zod").ZodString;
58
+ }, import("zod/v4/core").$strip>>;
59
+ meta: import("zod").ZodObject<{
60
+ page: import("zod").ZodNumber;
61
+ pageSize: import("zod").ZodNumber;
62
+ totalItems: import("zod").ZodNumber;
63
+ totalPages: import("zod").ZodNumber;
64
+ }, import("zod/v4/core").$strip>;
65
+ }, import("zod/v4/core").$strip>, false>;
66
+ /**
67
+ * `storageMigrationRunListSchema` (`@marinoscar/platform-contract/storage`) as a Nest DTO: the OpenAPI component of one page of runs.
68
+ *
69
+ * @stability experimental
70
+ */
71
+ export declare class StorageMigrationRunListDto extends StorageMigrationRunListDto_base {
72
+ }
73
+ //# sourceMappingURL=storage-migration.dto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage-migration.dto.d.ts","sourceRoot":"","sources":["../../../../src/storage/migration/dto/storage-migration.dto.ts"],"names":[],"mappings":"AACA,OAAO,EACL,2BAA2B,EAC3B,+BAA+B,EAC/B,6BAA6B,EAC7B,yBAAyB,EAC1B,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,2BAA2B,EAAE,+BAA+B,EAAE,6BAA6B,EAAE,yBAAyB,EAAE,CAAC;AAClI,YAAY,EACV,0BAA0B,EAC1B,yBAAyB,EACzB,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,uCAAuC,CAAC;;;;;AAE/C;;;;GAIG;AACH,qBAAa,wBAAyB,SAAQ,6BAAyC;CAAG;;;;;;;;;;;;;;;;;;;AAE1F;;;;GAIG;AACH,qBAAa,sBAAuB,SAAQ,2BAAuC;CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtF;;;;GAIG;AACH,qBAAa,0BAA2B,SAAQ,+BAA2C;CAAG"}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StorageMigrationRunListDto = exports.StorageMigrationRunDto = exports.StartStorageMigrationDto = exports.storageMigrationRunSchema = exports.storageMigrationRunListSchema = exports.storageMigrationListQuerySchema = exports.startStorageMigrationSchema = void 0;
4
+ const nestjs_zod_1 = require("nestjs-zod");
5
+ const storage_1 = require("@marinoscar/platform-contract/storage");
6
+ Object.defineProperty(exports, "startStorageMigrationSchema", { enumerable: true, get: function () { return storage_1.startStorageMigrationSchema; } });
7
+ Object.defineProperty(exports, "storageMigrationListQuerySchema", { enumerable: true, get: function () { return storage_1.storageMigrationListQuerySchema; } });
8
+ Object.defineProperty(exports, "storageMigrationRunListSchema", { enumerable: true, get: function () { return storage_1.storageMigrationRunListSchema; } });
9
+ Object.defineProperty(exports, "storageMigrationRunSchema", { enumerable: true, get: function () { return storage_1.storageMigrationRunSchema; } });
10
+ /**
11
+ * `startStorageMigrationSchema` (`@marinoscar/platform-contract/storage`) as a Nest DTO: the OpenAPI component and the validated body.
12
+ *
13
+ * @stability experimental
14
+ */
15
+ class StartStorageMigrationDto extends (0, nestjs_zod_1.createZodDto)(storage_1.startStorageMigrationSchema) {
16
+ }
17
+ exports.StartStorageMigrationDto = StartStorageMigrationDto;
18
+ /**
19
+ * `storageMigrationRunSchema` (`@marinoscar/platform-contract/storage`) as a Nest DTO: the OpenAPI component of one run.
20
+ *
21
+ * @stability experimental
22
+ */
23
+ class StorageMigrationRunDto extends (0, nestjs_zod_1.createZodDto)(storage_1.storageMigrationRunSchema) {
24
+ }
25
+ exports.StorageMigrationRunDto = StorageMigrationRunDto;
26
+ /**
27
+ * `storageMigrationRunListSchema` (`@marinoscar/platform-contract/storage`) as a Nest DTO: the OpenAPI component of one page of runs.
28
+ *
29
+ * @stability experimental
30
+ */
31
+ class StorageMigrationRunListDto extends (0, nestjs_zod_1.createZodDto)(storage_1.storageMigrationRunListSchema) {
32
+ }
33
+ exports.StorageMigrationRunListDto = StorageMigrationRunListDto;
34
+ //# sourceMappingURL=storage-migration.dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage-migration.dto.js","sourceRoot":"","sources":["../../../../src/storage/migration/dto/storage-migration.dto.ts"],"names":[],"mappings":";;;AAAA,2CAA0C;AAC1C,mEAK+C;AAEtC,4GANP,qCAA2B,OAMO;AAAE,gHALpC,yCAA+B,OAKoC;AAAE,8GAJrE,uCAA6B,OAIqE;AAAE,0GAHpG,mCAAyB,OAGoG;AAQ/H;;;;GAIG;AACH,MAAa,wBAAyB,SAAQ,IAAA,yBAAY,EAAC,qCAA2B,CAAC;CAAG;AAA1F,4DAA0F;AAE1F;;;;GAIG;AACH,MAAa,sBAAuB,SAAQ,IAAA,yBAAY,EAAC,mCAAyB,CAAC;CAAG;AAAtF,wDAAsF;AAEtF;;;;GAIG;AACH,MAAa,0BAA2B,SAAQ,IAAA,yBAAY,EAAC,uCAA6B,CAAC;CAAG;AAA9F,gEAA8F"}
@@ -0,0 +1,11 @@
1
+ export { StorageMigrationService } from './storage-migration.service';
2
+ export type { StorageMigrationItemCounts, StorageMigrationRunPage, StorageMigrationRunView } from './storage-migration.service';
3
+ export { StorageMigratePlanHandler } from './storage-migrate-plan.handler';
4
+ export type { StorageMigratePlanPayload } from './storage-migrate-plan.handler';
5
+ export { StorageMigrateObjectHandler } from './storage-migrate-object.handler';
6
+ export type { StorageMigrateObjectPayload } from './storage-migrate-object.handler';
7
+ export { StorageCopyVerificationError, copyAndVerify } from './copy-and-verify';
8
+ export type { VerifiedCopy } from './copy-and-verify';
9
+ export { STORAGE_MIGRATE_OBJECT_TYPE, STORAGE_MIGRATE_PLAN_TYPE, STORAGE_MIGRATION_ACTIVE_INDEX, STORAGE_MIGRATION_AUDIT_ACTIONS, STORAGE_MIGRATION_ITEM_SUBJECT_TYPE, STORAGE_MIGRATION_PRIORITY, STORAGE_MIGRATION_RUN_SUBJECT_TYPE, STORAGE_MIGRATION_SYSTEM_ACCESS_REASON, registerStorageMigrationSystemAccessReason, } from './storage-migration.constants';
10
+ export { StorageMigrationSettledListener } from './storage-migration-settled.listener';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/migration/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,YAAY,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAChI,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,YAAY,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAChF,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,YAAY,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AACpF,OAAO,EAAE,4BAA4B,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAChF,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EACL,2BAA2B,EAC3B,yBAAyB,EACzB,8BAA8B,EAC9B,+BAA+B,EAC/B,mCAAmC,EACnC,0BAA0B,EAC1B,kCAAkC,EAClC,sCAAsC,EACtC,0CAA0C,GAC3C,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StorageMigrationSettledListener = exports.registerStorageMigrationSystemAccessReason = exports.STORAGE_MIGRATION_SYSTEM_ACCESS_REASON = exports.STORAGE_MIGRATION_RUN_SUBJECT_TYPE = exports.STORAGE_MIGRATION_PRIORITY = exports.STORAGE_MIGRATION_ITEM_SUBJECT_TYPE = exports.STORAGE_MIGRATION_AUDIT_ACTIONS = exports.STORAGE_MIGRATION_ACTIVE_INDEX = exports.STORAGE_MIGRATE_PLAN_TYPE = exports.STORAGE_MIGRATE_OBJECT_TYPE = exports.copyAndVerify = exports.StorageCopyVerificationError = exports.StorageMigrateObjectHandler = exports.StorageMigratePlanHandler = exports.StorageMigrationService = void 0;
4
+ // Copy-only storage provider migration (issue #1093). Exported from the
5
+ // storage slice index.
6
+ var storage_migration_service_1 = require("./storage-migration.service");
7
+ Object.defineProperty(exports, "StorageMigrationService", { enumerable: true, get: function () { return storage_migration_service_1.StorageMigrationService; } });
8
+ var storage_migrate_plan_handler_1 = require("./storage-migrate-plan.handler");
9
+ Object.defineProperty(exports, "StorageMigratePlanHandler", { enumerable: true, get: function () { return storage_migrate_plan_handler_1.StorageMigratePlanHandler; } });
10
+ var storage_migrate_object_handler_1 = require("./storage-migrate-object.handler");
11
+ Object.defineProperty(exports, "StorageMigrateObjectHandler", { enumerable: true, get: function () { return storage_migrate_object_handler_1.StorageMigrateObjectHandler; } });
12
+ var copy_and_verify_1 = require("./copy-and-verify");
13
+ Object.defineProperty(exports, "StorageCopyVerificationError", { enumerable: true, get: function () { return copy_and_verify_1.StorageCopyVerificationError; } });
14
+ Object.defineProperty(exports, "copyAndVerify", { enumerable: true, get: function () { return copy_and_verify_1.copyAndVerify; } });
15
+ var storage_migration_constants_1 = require("./storage-migration.constants");
16
+ Object.defineProperty(exports, "STORAGE_MIGRATE_OBJECT_TYPE", { enumerable: true, get: function () { return storage_migration_constants_1.STORAGE_MIGRATE_OBJECT_TYPE; } });
17
+ Object.defineProperty(exports, "STORAGE_MIGRATE_PLAN_TYPE", { enumerable: true, get: function () { return storage_migration_constants_1.STORAGE_MIGRATE_PLAN_TYPE; } });
18
+ Object.defineProperty(exports, "STORAGE_MIGRATION_ACTIVE_INDEX", { enumerable: true, get: function () { return storage_migration_constants_1.STORAGE_MIGRATION_ACTIVE_INDEX; } });
19
+ Object.defineProperty(exports, "STORAGE_MIGRATION_AUDIT_ACTIONS", { enumerable: true, get: function () { return storage_migration_constants_1.STORAGE_MIGRATION_AUDIT_ACTIONS; } });
20
+ Object.defineProperty(exports, "STORAGE_MIGRATION_ITEM_SUBJECT_TYPE", { enumerable: true, get: function () { return storage_migration_constants_1.STORAGE_MIGRATION_ITEM_SUBJECT_TYPE; } });
21
+ Object.defineProperty(exports, "STORAGE_MIGRATION_PRIORITY", { enumerable: true, get: function () { return storage_migration_constants_1.STORAGE_MIGRATION_PRIORITY; } });
22
+ Object.defineProperty(exports, "STORAGE_MIGRATION_RUN_SUBJECT_TYPE", { enumerable: true, get: function () { return storage_migration_constants_1.STORAGE_MIGRATION_RUN_SUBJECT_TYPE; } });
23
+ Object.defineProperty(exports, "STORAGE_MIGRATION_SYSTEM_ACCESS_REASON", { enumerable: true, get: function () { return storage_migration_constants_1.STORAGE_MIGRATION_SYSTEM_ACCESS_REASON; } });
24
+ Object.defineProperty(exports, "registerStorageMigrationSystemAccessReason", { enumerable: true, get: function () { return storage_migration_constants_1.registerStorageMigrationSystemAccessReason; } });
25
+ var storage_migration_settled_listener_1 = require("./storage-migration-settled.listener");
26
+ Object.defineProperty(exports, "StorageMigrationSettledListener", { enumerable: true, get: function () { return storage_migration_settled_listener_1.StorageMigrationSettledListener; } });
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/storage/migration/index.ts"],"names":[],"mappings":";;;AAAA,wEAAwE;AACxE,uBAAuB;AACvB,yEAAsE;AAA7D,oIAAA,uBAAuB,OAAA;AAEhC,+EAA2E;AAAlE,yIAAA,yBAAyB,OAAA;AAElC,mFAA+E;AAAtE,6IAAA,2BAA2B,OAAA;AAEpC,qDAAgF;AAAvE,+HAAA,4BAA4B,OAAA;AAAE,gHAAA,aAAa,OAAA;AAEpD,6EAUuC;AATrC,0IAAA,2BAA2B,OAAA;AAC3B,wIAAA,yBAAyB,OAAA;AACzB,6IAAA,8BAA8B,OAAA;AAC9B,8IAAA,+BAA+B,OAAA;AAC/B,kJAAA,mCAAmC,OAAA;AACnC,yIAAA,0BAA0B,OAAA;AAC1B,iJAAA,kCAAkC,OAAA;AAClC,qJAAA,sCAAsC,OAAA;AACtC,yJAAA,0CAA0C,OAAA;AAE5C,2FAAuF;AAA9E,qJAAA,+BAA+B,OAAA"}
@@ -0,0 +1,40 @@
1
+ import { OnModuleInit } from '@nestjs/common';
2
+ import { JobHandlerRegistry, JobScope, type Job, type JobExecutionProfile, type JobHandler } from '../../jobs/index';
3
+ import { StorageConfigService } from '../config/storage-config.service';
4
+ import { StorageProviderRouter } from '../providers/storage-provider-router';
5
+ import { StorageMigrationService } from './storage-migration.service';
6
+ /**
7
+ * The per-object job's payload.
8
+ *
9
+ * @stability experimental
10
+ */
11
+ export interface StorageMigrateObjectPayload {
12
+ /** The run. */
13
+ runId: string;
14
+ /** The item (one object of the run). */
15
+ itemId: string;
16
+ }
17
+ /**
18
+ * The server-only `storage.migrate_object` job: streams one object from the run's source driver to its target, verifies size and sha256 by reading it back, repoints the row and leaves the source in place.
19
+ *
20
+ * @stability experimental
21
+ */
22
+ export declare class StorageMigrateObjectHandler implements JobHandler, OnModuleInit {
23
+ private readonly registry;
24
+ private readonly migrations;
25
+ private readonly jobScope;
26
+ private readonly router;
27
+ private readonly storageConfig;
28
+ private readonly logger;
29
+ readonly type = "storage.migrate_object";
30
+ readonly label = "Storage migration (copy object)";
31
+ /** One object can be several gigabytes, copied and then read back. */
32
+ readonly profile: JobExecutionProfile;
33
+ constructor(registry: JobHandlerRegistry, migrations: StorageMigrationService, jobScope: JobScope, router: StorageProviderRouter, storageConfig: StorageConfigService);
34
+ /** Self-registration. */
35
+ onModuleInit(): void;
36
+ /** Copies, verifies and repoints the job's object; see the file header. */
37
+ process(job: Job): Promise<void>;
38
+ private skip;
39
+ }
40
+ //# sourceMappingURL=storage-migrate-object.handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage-migrate-object.handler.d.ts","sourceRoot":"","sources":["../../../src/storage/migration/storage-migrate-object.handler.ts"],"names":[],"mappings":"AAmCA,OAAO,EAAsB,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAElE,OAAO,EACL,kBAAkB,EAClB,QAAQ,EACR,KAAK,GAAG,EACR,KAAK,mBAAmB,EACxB,KAAK,UAAU,EAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AASxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAG7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAEtE;;;;GAIG;AACH,MAAM,WAAW,2BAA2B;IAC1C,eAAe;IACf,KAAK,EAAE,MAAM,CAAC;IACd,wCAAwC;IACxC,MAAM,EAAE,MAAM,CAAC;CAChB;AAYD;;;;GAIG;AACH,qBACa,2BAA4B,YAAW,UAAU,EAAE,YAAY;IAWxE,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAdhC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgD;IAEvE,QAAQ,CAAC,IAAI,4BAA+B;IAE5C,QAAQ,CAAC,KAAK,qCAAqC;IAEnD,sEAAsE;IACtE,QAAQ,CAAC,OAAO,EAAE,mBAAmB,CAAiD;gBAGnE,QAAQ,EAAE,kBAAkB,EAC5B,UAAU,EAAE,uBAAuB,EACnC,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,qBAAqB,EAC7B,aAAa,EAAE,oBAAoB;IAGtD,yBAAyB;IACzB,YAAY,IAAI,IAAI;IAIpB,2EAA2E;IACrE,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;YA8ExB,IAAI;CAMnB"}
@@ -0,0 +1,177 @@
1
+ "use strict";
2
+ // =============================================================================
3
+ // `storage.migrate_object` — copy one object to the run's target driver,
4
+ // verify it, repoint its row, leave the source (issue #1093)
5
+ // =============================================================================
6
+ //
7
+ // ORDER, AND WHY IT IS THE WHOLE DESIGN
8
+ //
9
+ // 1. The run must still be running. A cancelled (or finished) run's item is
10
+ // marked `skipped` and nothing is copied: a cancelled run stops before its
11
+ // next unclaimed object.
12
+ // 2. The item and its object are read in the object's organization
13
+ // (`JobScope.run`, the job carries the object's `orgId`). An object that is
14
+ // gone, not `ready`, or no longer recorded on the source (repointed by an
15
+ // earlier run, re-uploaded elsewhere) is `skipped`: a re-run never copies
16
+ // an already-migrated object twice.
17
+ // 3. The bytes are STREAMED from the source into the target and read back
18
+ // (`copyAndVerify`): the byte count and the sha256 must agree on both sides
19
+ // and with the row's size. Nothing is buffered.
20
+ // 4. Only then is the row repointed, in one org-scoped transaction, guarded by
21
+ // `storage_provider = source AND storage_key = key`: an object changed while
22
+ // it was being copied is not repointed (it is `skipped`), so the row never
23
+ // points at bytes that are not its own.
24
+ // 5. The source object is NEVER deleted: it is the fallback.
25
+ //
26
+ // FAILURE. A thrown error (a network glitch, throttling, a verification
27
+ // mismatch) is retried by the queue with backoff; the item stays `copying`.
28
+ // When the job gives up, `StorageMigrationSettledListener` marks a still-open item `failed` — a
29
+ // listener rather than an "is this my last attempt?" check, because a timeout
30
+ // or a dead executor never returns into `process`.
31
+ //
32
+ // SERVER-ONLY BY DERIVATION: neither `nodeResultSchema` nor `persistNodeResult`.
33
+ // The copy needs BOTH drivers' secrets, which are never brokered to a worker
34
+ // node.
35
+ // =============================================================================
36
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
37
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
38
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
39
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
40
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
41
+ };
42
+ var __metadata = (this && this.__metadata) || function (k, v) {
43
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
44
+ };
45
+ var StorageMigrateObjectHandler_1;
46
+ Object.defineProperty(exports, "__esModule", { value: true });
47
+ exports.StorageMigrateObjectHandler = void 0;
48
+ const common_1 = require("@nestjs/common");
49
+ const index_1 = require("../../jobs/index");
50
+ const storage_config_service_1 = require("../config/storage-config.service");
51
+ const storage_db_1 = require("../data/storage-db");
52
+ const storage_provider_router_1 = require("../providers/storage-provider-router");
53
+ const copy_and_verify_1 = require("./copy-and-verify");
54
+ const storage_migration_constants_1 = require("./storage-migration.constants");
55
+ const storage_migration_service_1 = require("./storage-migration.service");
56
+ function readPayload(job) {
57
+ const payload = job.payload;
58
+ if (!payload || typeof payload.runId !== 'string' || typeof payload.itemId !== 'string') {
59
+ throw new Error(`${storage_migration_constants_1.STORAGE_MIGRATE_OBJECT_TYPE} job ${job.id} has an invalid payload`);
60
+ }
61
+ return { runId: payload.runId, itemId: payload.itemId };
62
+ }
63
+ /**
64
+ * The server-only `storage.migrate_object` job: streams one object from the run's source driver to its target, verifies size and sha256 by reading it back, repoints the row and leaves the source in place.
65
+ *
66
+ * @stability experimental
67
+ */
68
+ let StorageMigrateObjectHandler = StorageMigrateObjectHandler_1 = class StorageMigrateObjectHandler {
69
+ registry;
70
+ migrations;
71
+ jobScope;
72
+ router;
73
+ storageConfig;
74
+ logger = new common_1.Logger(StorageMigrateObjectHandler_1.name);
75
+ type = storage_migration_constants_1.STORAGE_MIGRATE_OBJECT_TYPE;
76
+ label = 'Storage migration (copy object)';
77
+ /** One object can be several gigabytes, copied and then read back. */
78
+ profile = { maxRuntimeMs: 60 * 60_000, maxAttempts: 3 };
79
+ constructor(registry, migrations, jobScope, router, storageConfig) {
80
+ this.registry = registry;
81
+ this.migrations = migrations;
82
+ this.jobScope = jobScope;
83
+ this.router = router;
84
+ this.storageConfig = storageConfig;
85
+ }
86
+ /** Self-registration. */
87
+ onModuleInit() {
88
+ this.registry.register(this);
89
+ }
90
+ /** Copies, verifies and repoints the job's object; see the file header. */
91
+ async process(job) {
92
+ const { runId, itemId } = readPayload(job);
93
+ const run = await this.migrations.db().storageMigrationRun.findUnique({ where: { id: runId } });
94
+ if (!run)
95
+ return;
96
+ const claim = await this.jobScope.run(job, async (tx) => {
97
+ const item = await tx.storageMigrationItem.findUnique({ where: { id: itemId } });
98
+ if (!item || (item.status !== storage_db_1.StorageMigrationItemStatus.pending && item.status !== storage_db_1.StorageMigrationItemStatus.copying)) {
99
+ return { kind: 'done' };
100
+ }
101
+ if (run.status !== storage_db_1.StorageMigrationRunStatus.running) {
102
+ await this.skip(tx, itemId, `Run ${run.status}`);
103
+ return { kind: 'skipped' };
104
+ }
105
+ const object = await tx.storageObject.findUnique({ where: { id: item.objectId } });
106
+ if (!object || object.status !== storage_db_1.StorageObjectStatus.ready) {
107
+ await this.skip(tx, itemId, 'The object is gone or not ready');
108
+ return { kind: 'skipped' };
109
+ }
110
+ if (object.storageProvider !== run.sourceProvider) {
111
+ await this.skip(tx, itemId, `The object is recorded on "${object.storageProvider}", not on the source`);
112
+ return { kind: 'skipped' };
113
+ }
114
+ await tx.storageMigrationItem.update({ where: { id: itemId }, data: { status: storage_db_1.StorageMigrationItemStatus.copying } });
115
+ return { kind: 'copy', object };
116
+ });
117
+ if (claim.kind === 'done')
118
+ return;
119
+ if (claim.kind === 'skipped') {
120
+ await this.migrations.finalizeIfDone(runId);
121
+ return;
122
+ }
123
+ const { object } = claim;
124
+ // Both drivers must be buildable: the router would serve an unbuildable one
125
+ // with the ACTIVE provider, which is the wrong place to read or write.
126
+ for (const provider of [run.sourceProvider, run.targetProvider]) {
127
+ const resolution = await this.storageConfig.resolveDriver(provider);
128
+ if (!resolution.configured) {
129
+ throw new Error(`Storage driver "${provider}" is not configured (missing ${resolution.missing.join(', ')})`);
130
+ }
131
+ }
132
+ const source = await this.router.forObject(object);
133
+ const target = await this.router.forLocation({ provider: run.targetProvider, bucket: '' });
134
+ const verified = await (0, copy_and_verify_1.copyAndVerify)(source, target, object);
135
+ const targetBucket = target.getBucket();
136
+ const repointed = await this.jobScope.run(job, async (tx) => {
137
+ const moved = await tx.storageObject.updateMany({
138
+ where: { id: object.id, storageProvider: run.sourceProvider, storageKey: object.storageKey },
139
+ data: { storageProvider: run.targetProvider, bucket: targetBucket },
140
+ });
141
+ if (moved.count === 0) {
142
+ await this.skip(tx, itemId, 'The object changed while it was being copied; not repointed');
143
+ return false;
144
+ }
145
+ await tx.storageMigrationItem.update({
146
+ where: { id: itemId },
147
+ data: {
148
+ status: storage_db_1.StorageMigrationItemStatus.migrated,
149
+ sizeBytes: verified.bytes,
150
+ checksumSha256: verified.sha256,
151
+ lastError: null,
152
+ },
153
+ });
154
+ return true;
155
+ });
156
+ if (repointed) {
157
+ this.logger.log(`Storage migration ${runId}: object ${object.id} copied ${run.sourceProvider} -> ${run.targetProvider} (${verified.bytes} bytes, verified)`);
158
+ }
159
+ await this.migrations.finalizeIfDone(runId);
160
+ }
161
+ async skip(tx, itemId, reason) {
162
+ await tx.storageMigrationItem.update({
163
+ where: { id: itemId },
164
+ data: { status: storage_db_1.StorageMigrationItemStatus.skipped, lastError: reason },
165
+ });
166
+ }
167
+ };
168
+ exports.StorageMigrateObjectHandler = StorageMigrateObjectHandler;
169
+ exports.StorageMigrateObjectHandler = StorageMigrateObjectHandler = StorageMigrateObjectHandler_1 = __decorate([
170
+ (0, common_1.Injectable)(),
171
+ __metadata("design:paramtypes", [index_1.JobHandlerRegistry,
172
+ storage_migration_service_1.StorageMigrationService,
173
+ index_1.JobScope,
174
+ storage_provider_router_1.StorageProviderRouter,
175
+ storage_config_service_1.StorageConfigService])
176
+ ], StorageMigrateObjectHandler);
177
+ //# sourceMappingURL=storage-migrate-object.handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage-migrate-object.handler.js","sourceRoot":"","sources":["../../../src/storage/migration/storage-migrate-object.handler.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yEAAyE;AACzE,6DAA6D;AAC7D,gFAAgF;AAChF,EAAE;AACF,wCAAwC;AACxC,EAAE;AACF,8EAA8E;AAC9E,gFAAgF;AAChF,8BAA8B;AAC9B,qEAAqE;AACrE,iFAAiF;AACjF,+EAA+E;AAC/E,+EAA+E;AAC/E,yCAAyC;AACzC,4EAA4E;AAC5E,iFAAiF;AACjF,qDAAqD;AACrD,iFAAiF;AACjF,kFAAkF;AAClF,gFAAgF;AAChF,6CAA6C;AAC7C,+DAA+D;AAC/D,EAAE;AACF,wEAAwE;AACxE,4EAA4E;AAC5E,gGAAgG;AAChG,8EAA8E;AAC9E,mDAAmD;AACnD,EAAE;AACF,iFAAiF;AACjF,6E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uCAA0B,CAAC,QAAQ;oBAC3C,SAAS,EAAE,QAAQ,CAAC,KAAK;oBACzB,cAAc,EAAE,QAAQ,CAAC,MAAM;oBAC/B,SAAS,EAAE,IAAI;iBAChB;aACF,CAAC,CAAC;YACH,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;QAEH,IAAI,SAAS,EAAE,CAAC;YACd,IAAI,CAAC,MAAM,CAAC,GAAG,CACb,qBAAqB,KAAK,YAAY,MAAM,CAAC,EAAE,WAAW,GAAG,CAAC,cAAc,OAAO,GAAG,CAAC,cAAc,KAAK,QAAQ,CAAC,KAAK,mBAAmB,CAC5I,CAAC;QACJ,CAAC;QACD,MAAM,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC;IAEO,KAAK,CAAC,IAAI,CAAC,EAAM,EAAE,MAAc,EAAE,MAAc;QACvD,MAAM,EAAE,CAAC,oBAAoB,CAAC,MAAM,CAAC;YACnC,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE;YACrB,IAAI,EAAE,EAAE,MAAM,EAAE,uCAA0B,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE;SACxE,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AA5GY,kEAA2B;sCAA3B,2BAA2B;IADvC,IAAA,mBAAU,GAAE;qCAYkB,0BAAkB;QAChB,mDAAuB;QACzB,gBAAQ;QACV,+CAAqB;QACd,6CAAoB;GAf3C,2BAA2B,CA4GvC"}
@@ -0,0 +1,34 @@
1
+ import { OnModuleInit } from '@nestjs/common';
2
+ import { JobHandlerRegistry, JobsService, type Job, type JobExecutionProfile, type JobHandler } from '../../jobs/index';
3
+ import { StorageMigrationService } from './storage-migration.service';
4
+ /**
5
+ * The planner job's payload.
6
+ *
7
+ * @stability experimental
8
+ */
9
+ export interface StorageMigratePlanPayload {
10
+ /** The run to plan. */
11
+ runId: string;
12
+ }
13
+ /**
14
+ * The server-only `storage.migrate_plan` job: creates one item per `ready` object on the run's source driver and queues one `storage.migrate_object` job per item, resumably; a planner that gives up fails its run.
15
+ *
16
+ * @stability experimental
17
+ */
18
+ export declare class StorageMigratePlanHandler implements JobHandler, OnModuleInit {
19
+ private readonly registry;
20
+ private readonly migrations;
21
+ private readonly jobs;
22
+ private readonly logger;
23
+ readonly type = "storage.migrate_plan";
24
+ readonly label = "Storage migration (plan)";
25
+ /** Listing and queueing a large deployment's objects is long but bounded work. */
26
+ readonly profile: JobExecutionProfile;
27
+ constructor(registry: JobHandlerRegistry, migrations: StorageMigrationService, jobs: JobsService);
28
+ /** Self-registration. */
29
+ onModuleInit(): void;
30
+ /** Plans the run named in the payload. */
31
+ process(job: Job): Promise<void>;
32
+ private cancelled;
33
+ }
34
+ //# sourceMappingURL=storage-migrate-plan.handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage-migrate-plan.handler.d.ts","sourceRoot":"","sources":["../../../src/storage/migration/storage-migrate-plan.handler.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAsB,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAElE,OAAO,EACL,kBAAkB,EAElB,WAAW,EACX,KAAK,GAAG,EACR,KAAK,mBAAmB,EACxB,KAAK,UAAU,EAChB,MAAM,kBAAkB,CAAC;AAQ1B,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAKtE;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACxC,uBAAuB;IACvB,KAAK,EAAE,MAAM,CAAC;CACf;AAUD;;;;GAIG;AACH,qBACa,yBAA0B,YAAW,UAAU,EAAE,YAAY;IAWtE,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,IAAI;IAZvB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA8C;IAErE,QAAQ,CAAC,IAAI,0BAA6B;IAE1C,QAAQ,CAAC,KAAK,8BAA8B;IAE5C,kFAAkF;IAClF,QAAQ,CAAC,OAAO,EAAE,mBAAmB,CAAiD;gBAGnE,QAAQ,EAAE,kBAAkB,EAC5B,UAAU,EAAE,uBAAuB,EACnC,IAAI,EAAE,WAAW;IAGpC,yBAAyB;IACzB,YAAY,IAAI,IAAI;IAIpB,0CAA0C;IACpC,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;YAoFxB,SAAS;CAIxB"}