@marinoscar/platform-api 0.1.0-next.25 → 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 (118) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/dist/identity/auth/decorators/current-user.decorator.d.ts +30 -5
  3. package/dist/identity/auth/decorators/current-user.decorator.d.ts.map +1 -1
  4. package/dist/identity/auth/decorators/current-user.decorator.js +31 -6
  5. package/dist/identity/auth/decorators/current-user.decorator.js.map +1 -1
  6. package/dist/manifest/platform-model-ownership.d.ts.map +1 -1
  7. package/dist/manifest/platform-model-ownership.js +19 -0
  8. package/dist/manifest/platform-model-ownership.js.map +1 -1
  9. package/dist/manifest/platform-user-owned-models.d.ts.map +1 -1
  10. package/dist/manifest/platform-user-owned-models.js +15 -0
  11. package/dist/manifest/platform-user-owned-models.js.map +1 -1
  12. package/dist/notifications/dto/notification.dto.d.ts +24 -2
  13. package/dist/notifications/dto/notification.dto.d.ts.map +1 -1
  14. package/dist/notifications/dto/notification.dto.js +19 -1
  15. package/dist/notifications/dto/notification.dto.js.map +1 -1
  16. package/dist/notifications/index.d.ts +3 -2
  17. package/dist/notifications/index.d.ts.map +1 -1
  18. package/dist/notifications/index.js +9 -2
  19. package/dist/notifications/index.js.map +1 -1
  20. package/dist/notifications/notification-dismissal.d.ts +49 -0
  21. package/dist/notifications/notification-dismissal.d.ts.map +1 -0
  22. package/dist/notifications/notification-dismissal.js +109 -0
  23. package/dist/notifications/notification-dismissal.js.map +1 -0
  24. package/dist/notifications/notification-store.service.d.ts +12 -0
  25. package/dist/notifications/notification-store.service.d.ts.map +1 -1
  26. package/dist/notifications/notification-store.service.js +32 -6
  27. package/dist/notifications/notification-store.service.js.map +1 -1
  28. package/dist/notifications/notification-stream.service.d.ts +42 -1
  29. package/dist/notifications/notification-stream.service.d.ts.map +1 -1
  30. package/dist/notifications/notification-stream.service.js +97 -4
  31. package/dist/notifications/notification-stream.service.js.map +1 -1
  32. package/dist/notifications/notifications.controller.d.ts +2 -1
  33. package/dist/notifications/notifications.controller.d.ts.map +1 -1
  34. package/dist/notifications/notifications.controller.js +44 -3
  35. package/dist/notifications/notifications.controller.js.map +1 -1
  36. package/dist/notifications/notifications.system-settings.d.ts +13 -0
  37. package/dist/notifications/notifications.system-settings.d.ts.map +1 -1
  38. package/dist/notifications/notifications.system-settings.js +10 -0
  39. package/dist/notifications/notifications.system-settings.js.map +1 -1
  40. package/dist/notifications/notifications.user-settings.d.ts +8 -0
  41. package/dist/notifications/notifications.user-settings.d.ts.map +1 -1
  42. package/dist/notifications/notifications.user-settings.js +11 -0
  43. package/dist/notifications/notifications.user-settings.js.map +1 -1
  44. package/dist/settings/data/settings-db.d.ts +28 -0
  45. package/dist/settings/data/settings-db.d.ts.map +1 -1
  46. package/dist/settings/index.d.ts +2 -1
  47. package/dist/settings/index.d.ts.map +1 -1
  48. package/dist/settings/index.js.map +1 -1
  49. package/dist/settings/registry/system-settings-namespace.d.ts +9 -0
  50. package/dist/settings/registry/system-settings-namespace.d.ts.map +1 -1
  51. package/dist/settings/registry/system-settings-namespace.js +2 -0
  52. package/dist/settings/registry/system-settings-namespace.js.map +1 -1
  53. package/dist/settings/registry/user-settings-namespace.d.ts +9 -0
  54. package/dist/settings/registry/user-settings-namespace.d.ts.map +1 -1
  55. package/dist/settings/registry/user-settings-namespace.js +3 -0
  56. package/dist/settings/registry/user-settings-namespace.js.map +1 -1
  57. package/dist/settings/system-settings/system-settings.service.d.ts +7 -0
  58. package/dist/settings/system-settings/system-settings.service.d.ts.map +1 -1
  59. package/dist/settings/system-settings/system-settings.service.js +22 -4
  60. package/dist/settings/system-settings/system-settings.service.js.map +1 -1
  61. package/dist/settings/user-settings/user-settings.service.d.ts +9 -0
  62. package/dist/settings/user-settings/user-settings.service.d.ts.map +1 -1
  63. package/dist/settings/user-settings/user-settings.service.js +24 -4
  64. package/dist/settings/user-settings/user-settings.service.js.map +1 -1
  65. package/dist/settings/write-hooks.d.ts +53 -0
  66. package/dist/settings/write-hooks.d.ts.map +1 -0
  67. package/dist/settings/write-hooks.js +55 -0
  68. package/dist/settings/write-hooks.js.map +1 -0
  69. package/dist/storage/config/storage-config.module.d.ts.map +1 -1
  70. package/dist/storage/config/storage-config.module.js +10 -1
  71. package/dist/storage/config/storage-config.module.js.map +1 -1
  72. package/dist/storage/data/storage-db.d.ts +118 -1
  73. package/dist/storage/data/storage-db.d.ts.map +1 -1
  74. package/dist/storage/data/storage-db.js +25 -1
  75. package/dist/storage/data/storage-db.js.map +1 -1
  76. package/dist/storage/index.d.ts +5 -2
  77. package/dist/storage/index.d.ts.map +1 -1
  78. package/dist/storage/index.js +25 -1
  79. package/dist/storage/index.js.map +1 -1
  80. package/dist/storage/migration/copy-and-verify.d.ts +39 -0
  81. package/dist/storage/migration/copy-and-verify.d.ts.map +1 -0
  82. package/dist/storage/migration/copy-and-verify.js +94 -0
  83. package/dist/storage/migration/copy-and-verify.js.map +1 -0
  84. package/dist/storage/migration/dto/storage-migration.dto.d.ts +73 -0
  85. package/dist/storage/migration/dto/storage-migration.dto.d.ts.map +1 -0
  86. package/dist/storage/migration/dto/storage-migration.dto.js +34 -0
  87. package/dist/storage/migration/dto/storage-migration.dto.js.map +1 -0
  88. package/dist/storage/migration/index.d.ts +11 -0
  89. package/dist/storage/migration/index.d.ts.map +1 -0
  90. package/dist/storage/migration/index.js +27 -0
  91. package/dist/storage/migration/index.js.map +1 -0
  92. package/dist/storage/migration/storage-migrate-object.handler.d.ts +40 -0
  93. package/dist/storage/migration/storage-migrate-object.handler.d.ts.map +1 -0
  94. package/dist/storage/migration/storage-migrate-object.handler.js +177 -0
  95. package/dist/storage/migration/storage-migrate-object.handler.js.map +1 -0
  96. package/dist/storage/migration/storage-migrate-plan.handler.d.ts +34 -0
  97. package/dist/storage/migration/storage-migrate-plan.handler.d.ts.map +1 -0
  98. package/dist/storage/migration/storage-migrate-plan.handler.js +168 -0
  99. package/dist/storage/migration/storage-migrate-plan.handler.js.map +1 -0
  100. package/dist/storage/migration/storage-migration-settled.listener.d.ts +15 -0
  101. package/dist/storage/migration/storage-migration-settled.listener.d.ts.map +1 -0
  102. package/dist/storage/migration/storage-migration-settled.listener.js +87 -0
  103. package/dist/storage/migration/storage-migration-settled.listener.js.map +1 -0
  104. package/dist/storage/migration/storage-migration.constants.d.ts +69 -0
  105. package/dist/storage/migration/storage-migration.constants.d.ts.map +1 -0
  106. package/dist/storage/migration/storage-migration.constants.js +83 -0
  107. package/dist/storage/migration/storage-migration.constants.js.map +1 -0
  108. package/dist/storage/migration/storage-migration.controller.d.ts +26 -0
  109. package/dist/storage/migration/storage-migration.controller.d.ts.map +1 -0
  110. package/dist/storage/migration/storage-migration.controller.js +135 -0
  111. package/dist/storage/migration/storage-migration.controller.js.map +1 -0
  112. package/dist/storage/migration/storage-migration.service.d.ts +182 -0
  113. package/dist/storage/migration/storage-migration.service.d.ts.map +1 -0
  114. package/dist/storage/migration/storage-migration.service.js +444 -0
  115. package/dist/storage/migration/storage-migration.service.js.map +1 -0
  116. package/dist/storage/ports.d.ts +1 -1
  117. package/dist/storage/ports.d.ts.map +1 -1
  118. package/package.json +3 -3
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ // =============================================================================
3
+ // Copy-only storage provider migration: the permanent strings (issue #1093)
4
+ // =============================================================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.STORAGE_MIGRATION_AUDIT_ACTIONS = exports.STORAGE_MIGRATION_SYSTEM_ACCESS_REASON = exports.STORAGE_MIGRATION_ACTIVE_INDEX = exports.STORAGE_MIGRATION_PRIORITY = exports.STORAGE_MIGRATION_ITEM_SUBJECT_TYPE = exports.STORAGE_MIGRATION_RUN_SUBJECT_TYPE = exports.STORAGE_MIGRATE_OBJECT_TYPE = exports.STORAGE_MIGRATE_PLAN_TYPE = void 0;
7
+ exports.registerStorageMigrationSystemAccessReason = registerStorageMigrationSystemAccessReason;
8
+ const index_1 = require("../../core/index");
9
+ const index_2 = require("../../jobs/index");
10
+ /**
11
+ * The job type that lists a run's objects, creates one item per object and
12
+ * queues one {@link STORAGE_MIGRATE_OBJECT_TYPE} job per item. PERMANENT:
13
+ * rows outlive handlers. Server-only (no `nodeResultSchema`).
14
+ *
15
+ * @stability experimental
16
+ */
17
+ exports.STORAGE_MIGRATE_PLAN_TYPE = 'storage.migrate_plan';
18
+ /**
19
+ * The job type that copies ONE object to the run's target driver, verifies it
20
+ * and repoints its row. PERMANENT. Server-only: it needs both drivers' secrets,
21
+ * which are never brokered to a worker node.
22
+ *
23
+ * @stability experimental
24
+ */
25
+ exports.STORAGE_MIGRATE_OBJECT_TYPE = 'storage.migrate_object';
26
+ /**
27
+ * The `subjectType` of a planner job (`subjectId` is the run id).
28
+ *
29
+ * @stability experimental
30
+ */
31
+ exports.STORAGE_MIGRATION_RUN_SUBJECT_TYPE = 'storage_migration_run';
32
+ /**
33
+ * The `subjectType` of a per-object job (`subjectId` is the item id).
34
+ *
35
+ * @stability experimental
36
+ */
37
+ exports.STORAGE_MIGRATION_ITEM_SUBJECT_TYPE = 'storage_migration_item';
38
+ /**
39
+ * The queue priority of both job types: background, the housekeeping value,
40
+ * so a migration never delays an upload's processing.
41
+ *
42
+ * @stability experimental
43
+ */
44
+ exports.STORAGE_MIGRATION_PRIORITY = index_2.HOUSEKEEPING_PRIORITY;
45
+ /**
46
+ * The raw-SQL partial unique index that allows one pending or running run.
47
+ *
48
+ * @stability experimental
49
+ */
50
+ exports.STORAGE_MIGRATION_ACTIVE_INDEX = 'storage_migration_runs_active_uniq_idx';
51
+ /**
52
+ * The system access reason every migration query names: a run is
53
+ * deployment-wide (its `org_id` is NULL) and spans every organization's objects.
54
+ *
55
+ * @stability experimental
56
+ */
57
+ exports.STORAGE_MIGRATION_SYSTEM_ACCESS_REASON = 'storage-migration';
58
+ /**
59
+ * The audit actions the migration writes.
60
+ *
61
+ * @stability experimental
62
+ */
63
+ exports.STORAGE_MIGRATION_AUDIT_ACTIONS = {
64
+ START: 'storage.migration.start',
65
+ CANCEL: 'storage.migration.cancel',
66
+ };
67
+ /**
68
+ * Registers {@link STORAGE_MIGRATION_SYSTEM_ACCESS_REASON} with core's
69
+ * registry, once. The service and both handlers call it from their
70
+ * constructors (bootstrap, before the registry freezes), so code that builds
71
+ * them by hand (a database test) is covered too.
72
+ *
73
+ * @stability experimental
74
+ */
75
+ function registerStorageMigrationSystemAccessReason() {
76
+ if (index_1.systemAccessReasonRegistry.has(exports.STORAGE_MIGRATION_SYSTEM_ACCESS_REASON))
77
+ return;
78
+ (0, index_1.registerSystemAccessReason)({
79
+ id: exports.STORAGE_MIGRATION_SYSTEM_ACCESS_REASON,
80
+ description: 'Copy-only storage provider migration: deployment-wide runs (NULL org_id) and the objects of every organization they copy.',
81
+ });
82
+ }
83
+ //# sourceMappingURL=storage-migration.constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage-migration.constants.js","sourceRoot":"","sources":["../../../src/storage/migration/storage-migration.constants.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,4EAA4E;AAC5E,gFAAgF;;;AAmFhF,gGAOC;AAxFD,4CAA0F;AAC1F,4CAAyD;AAEzD;;;;;;GAMG;AACU,QAAA,yBAAyB,GAAG,sBAAsB,CAAC;AAEhE;;;;;;GAMG;AACU,QAAA,2BAA2B,GAAG,wBAAwB,CAAC;AAEpE;;;;GAIG;AACU,QAAA,kCAAkC,GAAG,uBAAuB,CAAC;AAE1E;;;;GAIG;AACU,QAAA,mCAAmC,GAAG,wBAAwB,CAAC;AAE5E;;;;;GAKG;AACU,QAAA,0BAA0B,GAAW,6BAAqB,CAAC;AAExE;;;;GAIG;AACU,QAAA,8BAA8B,GAAG,wCAAwC,CAAC;AAEvF;;;;;GAKG;AACU,QAAA,sCAAsC,GAAG,mBAAmB,CAAC;AAE1E;;;;GAIG;AACU,QAAA,+BAA+B,GAKxC;IACF,KAAK,EAAE,yBAAyB;IAChC,MAAM,EAAE,0BAA0B;CAC1B,CAAC;AAEX;;;;;;;GAOG;AACH,SAAgB,0CAA0C;IACxD,IAAI,kCAA0B,CAAC,GAAG,CAAC,8CAAsC,CAAC;QAAE,OAAO;IACnF,IAAA,kCAA0B,EAAC;QACzB,EAAE,EAAE,8CAAsC;QAC1C,WAAW,EACT,2HAA2H;KAC9H,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { StartStorageMigrationDto, type StorageMigrationListQuery } from './dto/storage-migration.dto';
2
+ import { StorageMigrationService, type StorageMigrationRunPage, type StorageMigrationRunView } from './storage-migration.service';
3
+ /**
4
+ * The `/api/admin/storage/migrations` routes (`storage_config:read|write`): start, list, read and cancel a copy-only provider migration.
5
+ *
6
+ * @internal
7
+ *
8
+ * @stability experimental
9
+ */
10
+ export declare class StorageMigrationController {
11
+ private readonly migrations;
12
+ constructor(migrations: StorageMigrationService);
13
+ start(dto: StartStorageMigrationDto, userId: string): Promise<{
14
+ data: StorageMigrationRunView;
15
+ }>;
16
+ list(query: StorageMigrationListQuery): Promise<{
17
+ data: StorageMigrationRunPage;
18
+ }>;
19
+ get(runId: string): Promise<{
20
+ data: StorageMigrationRunView;
21
+ }>;
22
+ cancel(runId: string, userId: string): Promise<{
23
+ data: StorageMigrationRunView;
24
+ }>;
25
+ }
26
+ //# sourceMappingURL=storage-migration.controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage-migration.controller.d.ts","sourceRoot":"","sources":["../../../src/storage/migration/storage-migration.controller.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,wBAAwB,EAIxB,KAAK,yBAAyB,EAC/B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,uBAAuB,EAAE,KAAK,uBAAuB,EAAE,KAAK,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAYlI;;;;;;GAMG;AACH,qBAEa,0BAA0B;IACzB,OAAO,CAAC,QAAQ,CAAC,UAAU;gBAAV,UAAU,EAAE,uBAAuB;IAkB1D,KAAK,CACD,GAAG,EAAE,wBAAwB,EAClB,MAAM,EAAE,MAAM,GAChC,OAAO,CAAC;QAAE,IAAI,EAAE,uBAAuB,CAAA;KAAE,CAAC;IAavC,IAAI,CACuD,KAAK,EAAE,yBAAyB,GAC9F,OAAO,CAAC;QAAE,IAAI,EAAE,uBAAuB,CAAA;KAAE,CAAC;IAavC,GAAG,CAAgC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,uBAAuB,CAAA;KAAE,CAAC;IAkB7F,MAAM,CACqB,KAAK,EAAE,MAAM,EACzB,MAAM,EAAE,MAAM,GAChC,OAAO,CAAC;QAAE,IAAI,EAAE,uBAAuB,CAAA;KAAE,CAAC;CAG9C"}
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ 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;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.StorageMigrationController = void 0;
16
+ const common_1 = require("@nestjs/common");
17
+ const swagger_1 = require("@nestjs/swagger");
18
+ const nestjs_zod_1 = require("nestjs-zod");
19
+ const index_1 = require("../../identity/index");
20
+ const storage_constants_1 = require("../storage.constants");
21
+ const storage_migration_dto_1 = require("./dto/storage-migration.dto");
22
+ const storage_migration_service_1 = require("./storage-migration.service");
23
+ // =============================================================================
24
+ // /api/admin/storage/migrations — copy-only storage provider migration (#1093)
25
+ // =============================================================================
26
+ //
27
+ // The same permission pair as `/api/admin/storage-config` (`storage_config:*`):
28
+ // a migration decides where the deployment's bytes live, exactly the authority
29
+ // the configuration screen already grants. Starting and cancelling write;
30
+ // listing and reading read.
31
+ // =============================================================================
32
+ /**
33
+ * The `/api/admin/storage/migrations` routes (`storage_config:read|write`): start, list, read and cancel a copy-only provider migration.
34
+ *
35
+ * @internal
36
+ *
37
+ * @stability experimental
38
+ */
39
+ let StorageMigrationController = class StorageMigrationController {
40
+ migrations;
41
+ constructor(migrations) {
42
+ this.migrations = migrations;
43
+ }
44
+ async start(dto, userId) {
45
+ return { data: await this.migrations.start(dto, userId) };
46
+ }
47
+ async list(query) {
48
+ return { data: await this.migrations.list(query) };
49
+ }
50
+ async get(runId) {
51
+ return { data: await this.migrations.get(runId) };
52
+ }
53
+ async cancel(runId, userId) {
54
+ return { data: await this.migrations.cancel(runId, userId) };
55
+ }
56
+ };
57
+ exports.StorageMigrationController = StorageMigrationController;
58
+ __decorate([
59
+ (0, common_1.Post)(),
60
+ (0, index_1.Auth)({ permissions: [storage_constants_1.PERMISSIONS.STORAGE_CONFIG_WRITE] }),
61
+ (0, common_1.HttpCode)(common_1.HttpStatus.CREATED),
62
+ (0, swagger_1.ApiOperation)({
63
+ summary: 'Start a copy-only storage provider migration (Admin only)',
64
+ description: 'Copies every `ready` object recorded on `sourceProvider` to `targetProvider`, one queue job per ' +
65
+ 'object: the bytes are streamed (never buffered), verified by reading them back (byte count and ' +
66
+ 'sha256), and only then is the row repointed. **The source object is never deleted**; it stays as a ' +
67
+ 'fallback. Returns at once; poll `GET /api/admin/storage/migrations/:runId` for progress.\n\n' +
68
+ 'Both drivers must be registered and configured, and must not name the same bucket (`400`, ' +
69
+ '`details.reason`). **One run at a time**: `409` with the active run at `details.activeRunId`.',
70
+ }),
71
+ (0, swagger_1.ApiResponse)({ status: 201, description: 'The run was started', type: storage_migration_dto_1.StorageMigrationRunDto }),
72
+ (0, swagger_1.ApiResponse)({ status: 400, description: 'Validation error, an unknown or unconfigured driver, or the same bucket on both sides' }),
73
+ (0, swagger_1.ApiResponse)({ status: 409, description: 'A run is already pending or running (`details.activeRunId`)' }),
74
+ __param(0, (0, common_1.Body)()),
75
+ __param(1, (0, index_1.CurrentUser)('id')),
76
+ __metadata("design:type", Function),
77
+ __metadata("design:paramtypes", [storage_migration_dto_1.StartStorageMigrationDto, String]),
78
+ __metadata("design:returntype", Promise)
79
+ ], StorageMigrationController.prototype, "start", null);
80
+ __decorate([
81
+ (0, common_1.Get)(),
82
+ (0, index_1.Auth)({ permissions: [storage_constants_1.PERMISSIONS.STORAGE_CONFIG_READ] }),
83
+ (0, swagger_1.ApiOperation)({
84
+ summary: 'List storage provider migrations (Admin only)',
85
+ description: 'Runs newest first. The counts are recomputed from the runs\' items on every read.',
86
+ }),
87
+ (0, swagger_1.ApiQuery)({ name: 'page', required: false, type: Number, description: 'Page number (default: 1)' }),
88
+ (0, swagger_1.ApiQuery)({ name: 'pageSize', required: false, type: Number, description: 'Runs per page (default: 20, max: 100)' }),
89
+ (0, swagger_1.ApiResponse)({ status: 200, description: 'One page of runs', type: storage_migration_dto_1.StorageMigrationRunListDto }),
90
+ __param(0, (0, common_1.Query)(new nestjs_zod_1.ZodValidationPipe(storage_migration_dto_1.storageMigrationListQuerySchema))),
91
+ __metadata("design:type", Function),
92
+ __metadata("design:paramtypes", [Object]),
93
+ __metadata("design:returntype", Promise)
94
+ ], StorageMigrationController.prototype, "list", null);
95
+ __decorate([
96
+ (0, common_1.Get)(':runId'),
97
+ (0, index_1.Auth)({ permissions: [storage_constants_1.PERMISSIONS.STORAGE_CONFIG_READ] }),
98
+ (0, swagger_1.ApiOperation)({
99
+ summary: 'Get a storage provider migration (Admin only)',
100
+ description: 'One run with live counts: total, migrated, failed, skipped and pending (queued or being copied).',
101
+ }),
102
+ (0, swagger_1.ApiParam)({ name: 'runId', type: String, format: 'uuid' }),
103
+ (0, swagger_1.ApiResponse)({ status: 200, description: 'The run', type: storage_migration_dto_1.StorageMigrationRunDto }),
104
+ (0, swagger_1.ApiResponse)({ status: 404, description: 'No such run' }),
105
+ __param(0, (0, common_1.Param)('runId', common_1.ParseUUIDPipe)),
106
+ __metadata("design:type", Function),
107
+ __metadata("design:paramtypes", [String]),
108
+ __metadata("design:returntype", Promise)
109
+ ], StorageMigrationController.prototype, "get", null);
110
+ __decorate([
111
+ (0, common_1.Post)(':runId/cancel'),
112
+ (0, index_1.Auth)({ permissions: [storage_constants_1.PERMISSIONS.STORAGE_CONFIG_WRITE] }),
113
+ (0, common_1.HttpCode)(common_1.HttpStatus.OK),
114
+ (0, swagger_1.ApiOperation)({
115
+ summary: 'Cancel a storage provider migration (Admin only)',
116
+ description: 'Stops a pending or running run before its next unclaimed object: queued objects are marked ' +
117
+ '`skipped` at once. An object being copied at that moment finishes (its copy is verified). ' +
118
+ 'Objects already repointed stay on the target, and every source object is untouched.',
119
+ }),
120
+ (0, swagger_1.ApiParam)({ name: 'runId', type: String, format: 'uuid' }),
121
+ (0, swagger_1.ApiResponse)({ status: 200, description: 'The cancelled run', type: storage_migration_dto_1.StorageMigrationRunDto }),
122
+ (0, swagger_1.ApiResponse)({ status: 404, description: 'No such run' }),
123
+ (0, swagger_1.ApiResponse)({ status: 409, description: 'The run already finished' }),
124
+ __param(0, (0, common_1.Param)('runId', common_1.ParseUUIDPipe)),
125
+ __param(1, (0, index_1.CurrentUser)('id')),
126
+ __metadata("design:type", Function),
127
+ __metadata("design:paramtypes", [String, String]),
128
+ __metadata("design:returntype", Promise)
129
+ ], StorageMigrationController.prototype, "cancel", null);
130
+ exports.StorageMigrationController = StorageMigrationController = __decorate([
131
+ (0, swagger_1.ApiTags)('Storage Configuration'),
132
+ (0, common_1.Controller)('admin/storage/migrations'),
133
+ __metadata("design:paramtypes", [storage_migration_service_1.StorageMigrationService])
134
+ ], StorageMigrationController);
135
+ //# sourceMappingURL=storage-migration.controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage-migration.controller.js","sourceRoot":"","sources":["../../../src/storage/migration/storage-migration.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAgH;AAChH,6CAAyF;AACzF,2CAA+C;AAE/C,gDAAyD;AACzD,4DAAmD;AACnD,uEAMqC;AACrC,2EAAkI;AAElI,gFAAgF;AAChF,+EAA+E;AAC/E,gFAAgF;AAChF,EAAE;AACF,gFAAgF;AAChF,+EAA+E;AAC/E,0EAA0E;AAC1E,4BAA4B;AAC5B,gFAAgF;AAEhF;;;;;;GAMG;AAGI,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IACR;IAA7B,YAA6B,UAAmC;QAAnC,eAAU,GAAV,UAAU,CAAyB;IAAG,CAAC;IAkB9D,AAAN,KAAK,CAAC,KAAK,CACD,GAA6B,EAClB,MAAc;QAEjC,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,CAAC;IAC5D,CAAC;IAWK,AAAN,KAAK,CAAC,IAAI,CACuD,KAAgC;QAE/F,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;IACrD,CAAC;IAWK,AAAN,KAAK,CAAC,GAAG,CAAgC,KAAa;QACpD,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;IACpD,CAAC;IAgBK,AAAN,KAAK,CAAC,MAAM,CACqB,KAAa,EACzB,MAAc;QAEjC,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,CAAC;IAC/D,CAAC;CACF,CAAA;AA1EY,gEAA0B;AAmB/B;IAhBL,IAAA,aAAI,GA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AW,EAAE,mBAAmB,EAAE,IAAI,EAAE,8CAAsB,EAAE,CAAC;IAC5F,IAAA,qBAAW,EAAC,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,aAAa,EAAE,CAAC;IACxD,IAAA,qBAAW,EAAC,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,0BAA0B,EAAE,CAAC;IAEnE,WAAA,IAAA,cAAK,EAAC,OAAO,EAAE,sBAAa,CAAC,CAAA;IAC7B,WAAA,IAAA,mBAAW,EAAC,IAAI,CAAC,CAAA;;;;wDAGnB;qCAzEU,0BAA0B;IAFtC,IAAA,iBAAO,EAAC,uBAAuB,CAAC;IAChC,IAAA,mBAAU,EAAC,0BAA0B,CAAC;qCAEI,mDAAuB;GADrD,0BAA0B,CA0EtC"}
@@ -0,0 +1,182 @@
1
+ import { JobsService } from '../../jobs/index';
2
+ import { StorageConfigService } from '../config/storage-config.service';
3
+ import { StorageMigrationRunStatus, type StoragePrisma } from '../data/storage-db';
4
+ import { type StorageSystemData } from '../ports';
5
+ /**
6
+ * A run as the admin routes return it (the contract's `StorageMigrationRun`).
7
+ *
8
+ * @stability experimental
9
+ */
10
+ export interface StorageMigrationRunView {
11
+ /** The run id. */
12
+ id: string;
13
+ /** The driver copied from. */
14
+ sourceProvider: string;
15
+ /** The driver copied to. */
16
+ targetProvider: string;
17
+ /** Lifecycle status. */
18
+ status: StorageMigrationRunStatus;
19
+ /** Items the run holds. */
20
+ totalCount: number;
21
+ /** Migrated items. */
22
+ migratedCount: number;
23
+ /** Failed items. */
24
+ failedCount: number;
25
+ /** Skipped items. */
26
+ skippedCount: number;
27
+ /** Queued or copying items. */
28
+ pendingCount: number;
29
+ /** Who started it. */
30
+ startedById: string | null;
31
+ /** ISO 8601 or null. */
32
+ startedAt: string | null;
33
+ /** ISO 8601 or null. */
34
+ plannedAt: string | null;
35
+ /** ISO 8601 or null. */
36
+ finishedAt: string | null;
37
+ /** ISO 8601 or null. */
38
+ cancelledAt: string | null;
39
+ /** The last error recorded. */
40
+ lastError: string | null;
41
+ /** ISO 8601. */
42
+ createdAt: string;
43
+ }
44
+ /**
45
+ * The per-status item counts of one run.
46
+ *
47
+ * @stability experimental
48
+ */
49
+ export interface StorageMigrationItemCounts {
50
+ /** Every item. */
51
+ total: number;
52
+ /** `migrated`. */
53
+ migrated: number;
54
+ /** `failed`. */
55
+ failed: number;
56
+ /** `skipped`. */
57
+ skipped: number;
58
+ /** `pending` or `copying`. */
59
+ pending: number;
60
+ }
61
+ /**
62
+ * One page of runs, newest first.
63
+ *
64
+ * @stability experimental
65
+ */
66
+ export interface StorageMigrationRunPage {
67
+ /** The page's runs. */
68
+ items: StorageMigrationRunView[];
69
+ /** The page's position in the list. */
70
+ meta: {
71
+ /** The page, 1-based. */
72
+ page: number;
73
+ /** Runs per page. */
74
+ pageSize: number;
75
+ /** Runs across pages. */
76
+ totalItems: number;
77
+ /** How many pages there are. */
78
+ totalPages: number;
79
+ };
80
+ }
81
+ /**
82
+ * Truncates an error message to fit `last_error`.
83
+ *
84
+ * @param error - anything thrown.
85
+ * @returns at most 1000 characters.
86
+ *
87
+ * @internal
88
+ */
89
+ export declare function storageMigrationErrorText(error: unknown): string;
90
+ /**
91
+ * Starts, lists, reads and cancels copy-only storage provider migrations, and owns the run bookkeeping (item counts, race-safe finalization) the two migration job handlers share.
92
+ *
93
+ * @stability experimental
94
+ */
95
+ export declare class StorageMigrationService {
96
+ private readonly system;
97
+ private readonly prisma;
98
+ private readonly storageConfig;
99
+ private readonly jobs;
100
+ private readonly logger;
101
+ constructor(system: StorageSystemData, prisma: StoragePrisma, storageConfig: StorageConfigService, jobs: JobsService);
102
+ /** The bypass client, with this slice's reason. */
103
+ db(): ReturnType<StorageSystemData['asSystem']>;
104
+ /**
105
+ * Starts a run: validates both drivers, claims the one active slot and queues the planner.
106
+ *
107
+ * @param input - the source and target driver ids (they differ; the DTO checks it).
108
+ * @param userId - the administrator.
109
+ * @returns the new run.
110
+ * @throws BadRequestException (`details.reason`: `UNKNOWN_DRIVER`, `SOURCE_NOT_CONFIGURED`, `TARGET_NOT_CONFIGURED`, `SAME_LOCATION`).
111
+ * @throws ConflictException when a run is already pending or running (`details.activeRunId`).
112
+ */
113
+ start(input: {
114
+ sourceProvider: string;
115
+ targetProvider: string;
116
+ }, userId: string): Promise<StorageMigrationRunView>;
117
+ /**
118
+ * One page of runs, newest first, with live counts.
119
+ *
120
+ * @param query - page (1-based) and page size.
121
+ * @returns the page and its position.
122
+ */
123
+ list(query: {
124
+ page: number;
125
+ pageSize: number;
126
+ }): Promise<StorageMigrationRunPage>;
127
+ /**
128
+ * One run, with live counts.
129
+ *
130
+ * @param runId - the run.
131
+ * @returns the run.
132
+ * @throws NotFoundException when there is no such run.
133
+ */
134
+ get(runId: string): Promise<StorageMigrationRunView>;
135
+ /**
136
+ * Cancels a pending or running run. Queued items become `skipped` at once, so
137
+ * the run stops before its next unclaimed object; an object being copied right
138
+ * now finishes (its copy is verified and harmless) and the source of every
139
+ * object is untouched either way.
140
+ *
141
+ * @param runId - the run.
142
+ * @param userId - the administrator.
143
+ * @returns the cancelled run.
144
+ * @throws NotFoundException when there is no such run.
145
+ * @throws ConflictException when it already finished.
146
+ */
147
+ cancel(runId: string, userId: string): Promise<StorageMigrationRunView>;
148
+ /**
149
+ * Item counts per run, by status, in one `groupBy`.
150
+ *
151
+ * @param runIds - the runs.
152
+ * @returns a map from run id to its counts (absent: no items).
153
+ */
154
+ countsFor(runIds: readonly string[]): Promise<Map<string, StorageMigrationItemCounts>>;
155
+ /**
156
+ * Finalizes a running, fully planned run whose items are all terminal:
157
+ * `failed` when any item failed, `completed` otherwise. Safe to call from any
158
+ * number of finishing jobs at once (one conditional update wins).
159
+ *
160
+ * @param runId - the run.
161
+ * @returns the final status when this call finalized it, otherwise `null`.
162
+ */
163
+ finalizeIfDone(runId: string): Promise<StorageMigrationRunStatus | null>;
164
+ /**
165
+ * Marks an active run `failed` with a reason (the planner gave up, or could not be queued).
166
+ *
167
+ * @param runId - the run.
168
+ * @param reason - why.
169
+ */
170
+ failRun(runId: string, reason: string): Promise<void>;
171
+ /**
172
+ * Records an error on the run (the most recent item failure), without changing its status.
173
+ *
174
+ * @param runId - the run.
175
+ * @param message - the error.
176
+ */
177
+ recordRunError(runId: string, message: string): Promise<void>;
178
+ private writeCounterSnapshot;
179
+ private view;
180
+ private audit;
181
+ }
182
+ //# sourceMappingURL=storage-migration.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage-migration.service.d.ts","sourceRoot":"","sources":["../../../src/storage/migration/storage-migration.service.ts"],"names":[],"mappings":"AA+CA,OAAO,EAAa,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAExE,OAAO,EAEL,yBAAyB,EAEzB,KAAK,aAAa,EACnB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAuB,KAAK,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAWvE;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC,kBAAkB;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,8BAA8B;IAC9B,cAAc,EAAE,MAAM,CAAC;IACvB,4BAA4B;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,wBAAwB;IACxB,MAAM,EAAE,yBAAyB,CAAC;IAClC,2BAA2B;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,sBAAsB;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,oBAAoB;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,qBAAqB;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,+BAA+B;IAC/B,YAAY,EAAE,MAAM,CAAC;IACrB,sBAAsB;IACtB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,wBAAwB;IACxB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,wBAAwB;IACxB,SAAS,EAAE,MAAM,GAAG,IAAI,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