@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,444 @@
1
+ "use strict";
2
+ // =============================================================================
3
+ // StorageMigrationService: start, list, read and cancel copy-only provider
4
+ // migrations, and the run bookkeeping both job handlers share (issue #1093)
5
+ // =============================================================================
6
+ //
7
+ // THE MODEL
8
+ //
9
+ // * A RUN copies every `ready` object recorded on `sourceProvider` to
10
+ // `targetProvider`. It is deployment-wide (storage configuration is system
11
+ // scope), so its `org_id` is NULL and every read or write of it goes through
12
+ // the bypass client with the `storage-migration` reason.
13
+ // * The planner job (`storage.migrate_plan`) lists the objects, creates one
14
+ // ITEM per object (carrying the object's org_id) and queues one
15
+ // `storage.migrate_object` job per item. Retried, it resumes: items are
16
+ // created with `skipDuplicates` against `@@unique([runId, objectId])`, and
17
+ // only items without a `jobId` are queued.
18
+ // * Each object job copies, verifies and repoints (see
19
+ // `storage-migrate-object.handler.ts`).
20
+ //
21
+ // ONE RUN AT A TIME is the raw-SQL partial unique index
22
+ // `storage_migration_runs_active_uniq_idx`: the database decides who wins a
23
+ // concurrent start, and the loser's P2002 becomes a 409 carrying the winner at
24
+ // `details.activeRunId` (under `details`, because the exception filter rebuilds
25
+ // the body from a fixed key allowlist). There is deliberately no findFirst
26
+ // pre-check: it would race.
27
+ //
28
+ // COUNTS ARE DERIVED. Every read recomputes migrated / failed / skipped /
29
+ // pending from the items (one `groupBy`), so a crash between an item write and
30
+ // a counter write never shows a wrong figure. The run's own counter columns are
31
+ // snapshots written when it finalizes or is cancelled.
32
+ //
33
+ // FINALIZATION IS RACE-SAFE. Whoever writes an item's terminal status then calls
34
+ // `finalizeIfDone`: one conditional `updateMany` (`status = 'running' AND
35
+ // planned_at IS NOT NULL`), so exactly one caller flips the run however many
36
+ // finish together, and the last item to commit always sees every other.
37
+ // =============================================================================
38
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
39
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
40
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
41
+ 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;
42
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
43
+ };
44
+ var __metadata = (this && this.__metadata) || function (k, v) {
45
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
46
+ };
47
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
48
+ return function (target, key) { decorator(target, key, paramIndex); }
49
+ };
50
+ var StorageMigrationService_1;
51
+ Object.defineProperty(exports, "__esModule", { value: true });
52
+ exports.StorageMigrationService = void 0;
53
+ exports.storageMigrationErrorText = storageMigrationErrorText;
54
+ const common_1 = require("@nestjs/common");
55
+ const index_1 = require("../../core/index");
56
+ const index_2 = require("../../jobs/index");
57
+ const storage_config_service_1 = require("../config/storage-config.service");
58
+ const storage_db_1 = require("../data/storage-db");
59
+ const storage_driver_1 = require("../drivers/storage-driver");
60
+ const ports_1 = require("../ports");
61
+ const storage_migration_constants_1 = require("./storage-migration.constants");
62
+ const EMPTY_COUNTS = { total: 0, migrated: 0, failed: 0, skipped: 0, pending: 0 };
63
+ const ACTIVE_STATUSES = [
64
+ storage_db_1.StorageMigrationRunStatus.pending,
65
+ storage_db_1.StorageMigrationRunStatus.running,
66
+ ];
67
+ /** The longest error kept on a row (the column is VARCHAR(1000)). */
68
+ const MAX_ERROR_LENGTH = 1000;
69
+ /**
70
+ * Truncates an error message to fit `last_error`.
71
+ *
72
+ * @param error - anything thrown.
73
+ * @returns at most 1000 characters.
74
+ *
75
+ * @internal
76
+ */
77
+ function storageMigrationErrorText(error) {
78
+ const text = error instanceof Error ? error.message : String(error);
79
+ return text.length <= MAX_ERROR_LENGTH ? text : `${text.slice(0, MAX_ERROR_LENGTH - 1)}…`;
80
+ }
81
+ function isActiveRunConflict(error) {
82
+ const candidate = error;
83
+ if (!candidate || candidate.code !== 'P2002')
84
+ return false;
85
+ const meta = candidate.meta ?? {};
86
+ const cause = meta.driverAdapterError?.cause;
87
+ const index = cause?.constraint?.index;
88
+ if (index === storage_migration_constants_1.STORAGE_MIGRATION_ACTIVE_INDEX)
89
+ return true;
90
+ if (typeof cause?.originalMessage === 'string' && cause.originalMessage.includes(storage_migration_constants_1.STORAGE_MIGRATION_ACTIVE_INDEX))
91
+ return true;
92
+ const target = meta.target;
93
+ if (target === storage_migration_constants_1.STORAGE_MIGRATION_ACTIVE_INDEX)
94
+ return true;
95
+ if (Array.isArray(target) && target.some((entry) => String(entry) === storage_migration_constants_1.STORAGE_MIGRATION_ACTIVE_INDEX))
96
+ return true;
97
+ // A run has no other unique constraint than its primary key (a fresh UUID),
98
+ // so any P2002 on create is the active-run index whatever the driver reports.
99
+ return true;
100
+ }
101
+ /**
102
+ * Whether two resolved configurations name the same physical bucket: copying
103
+ * onto the object being read would destroy it.
104
+ */
105
+ function sameLocation(a, b) {
106
+ return a.bucket === b.bucket && (a.endpoint ?? '') === (b.endpoint ?? '') && (a.region ?? '') === (b.region ?? '');
107
+ }
108
+ const iso = (value) => (value ? value.toISOString() : null);
109
+ /**
110
+ * 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.
111
+ *
112
+ * @stability experimental
113
+ */
114
+ let StorageMigrationService = StorageMigrationService_1 = class StorageMigrationService {
115
+ system;
116
+ prisma;
117
+ storageConfig;
118
+ jobs;
119
+ logger = new common_1.Logger(StorageMigrationService_1.name);
120
+ constructor(system, prisma, storageConfig, jobs) {
121
+ this.system = system;
122
+ this.prisma = prisma;
123
+ this.storageConfig = storageConfig;
124
+ this.jobs = jobs;
125
+ (0, storage_migration_constants_1.registerStorageMigrationSystemAccessReason)();
126
+ }
127
+ /** The bypass client, with this slice's reason. */
128
+ db() {
129
+ return this.system.asSystem(storage_migration_constants_1.STORAGE_MIGRATION_SYSTEM_ACCESS_REASON);
130
+ }
131
+ // ---------------------------------------------------------------------------
132
+ // Admin routes
133
+ // ---------------------------------------------------------------------------
134
+ /**
135
+ * Starts a run: validates both drivers, claims the one active slot and queues the planner.
136
+ *
137
+ * @param input - the source and target driver ids (they differ; the DTO checks it).
138
+ * @param userId - the administrator.
139
+ * @returns the new run.
140
+ * @throws BadRequestException (`details.reason`: `UNKNOWN_DRIVER`, `SOURCE_NOT_CONFIGURED`, `TARGET_NOT_CONFIGURED`, `SAME_LOCATION`).
141
+ * @throws ConflictException when a run is already pending or running (`details.activeRunId`).
142
+ */
143
+ async start(input, userId) {
144
+ const { sourceProvider, targetProvider } = input;
145
+ if (sourceProvider === targetProvider) {
146
+ throw new common_1.BadRequestException({ message: 'sourceProvider and targetProvider must differ', details: { reason: 'SAME_PROVIDER' } });
147
+ }
148
+ for (const provider of [sourceProvider, targetProvider]) {
149
+ if (!(0, storage_driver_1.getStorageDriver)(provider)) {
150
+ throw new common_1.BadRequestException({
151
+ message: `No storage driver "${provider}" is registered`,
152
+ details: { reason: 'UNKNOWN_DRIVER', provider },
153
+ });
154
+ }
155
+ }
156
+ // Both must be buildable: the router would otherwise serve an unbuildable
157
+ // source with the ACTIVE provider, and the copy would read the wrong bytes.
158
+ const source = await this.storageConfig.resolveDriver(sourceProvider, { fresh: true });
159
+ if (!source.configured) {
160
+ throw new common_1.BadRequestException({
161
+ message: `The source driver "${sourceProvider}" is not configured`,
162
+ details: { reason: 'SOURCE_NOT_CONFIGURED', provider: sourceProvider, missing: source.missing },
163
+ });
164
+ }
165
+ const target = await this.storageConfig.resolveDriver(targetProvider, { fresh: true });
166
+ if (!target.configured) {
167
+ throw new common_1.BadRequestException({
168
+ message: `The target driver "${targetProvider}" is not configured`,
169
+ details: { reason: 'TARGET_NOT_CONFIGURED', provider: targetProvider, missing: target.missing },
170
+ });
171
+ }
172
+ if (sameLocation(source.config, target.config)) {
173
+ throw new common_1.BadRequestException({
174
+ message: 'The source and target drivers point at the same bucket; there is nothing to copy',
175
+ details: { reason: 'SAME_LOCATION', bucket: target.config.bucket },
176
+ });
177
+ }
178
+ let run;
179
+ try {
180
+ run = await this.db().storageMigrationRun.create({
181
+ data: {
182
+ sourceProvider,
183
+ targetProvider,
184
+ status: storage_db_1.StorageMigrationRunStatus.pending,
185
+ startedById: userId,
186
+ },
187
+ });
188
+ }
189
+ catch (error) {
190
+ if (!isActiveRunConflict(error))
191
+ throw error;
192
+ const active = await this.db().storageMigrationRun.findFirst({
193
+ where: { status: { in: ACTIVE_STATUSES } },
194
+ select: { id: true },
195
+ });
196
+ throw new common_1.ConflictException({
197
+ message: 'A storage migration is already in progress',
198
+ details: { activeRunId: active?.id ?? null },
199
+ });
200
+ }
201
+ try {
202
+ await this.jobs.enqueue({
203
+ type: storage_migration_constants_1.STORAGE_MIGRATE_PLAN_TYPE,
204
+ reason: index_2.JobReason.backfill,
205
+ subjectType: storage_migration_constants_1.STORAGE_MIGRATION_RUN_SUBJECT_TYPE,
206
+ subjectId: run.id,
207
+ payload: { runId: run.id },
208
+ priority: storage_migration_constants_1.STORAGE_MIGRATION_PRIORITY,
209
+ orgId: null,
210
+ skipDedup: true,
211
+ });
212
+ }
213
+ catch (error) {
214
+ // Free the active slot: a run nobody will ever plan must not block the next.
215
+ await this.failRun(run.id, `Could not queue the planner: ${storageMigrationErrorText(error)}`);
216
+ throw error;
217
+ }
218
+ await this.audit(userId, storage_migration_constants_1.STORAGE_MIGRATION_AUDIT_ACTIONS.START, run.id, { sourceProvider, targetProvider });
219
+ this.logger.log(`Storage migration ${run.id} started: ${sourceProvider} -> ${targetProvider}`);
220
+ return this.view(run, EMPTY_COUNTS);
221
+ }
222
+ /**
223
+ * One page of runs, newest first, with live counts.
224
+ *
225
+ * @param query - page (1-based) and page size.
226
+ * @returns the page and its position.
227
+ */
228
+ async list(query) {
229
+ const db = this.db();
230
+ const [rows, totalItems] = await Promise.all([
231
+ db.storageMigrationRun.findMany({
232
+ orderBy: [{ createdAt: 'desc' }, { id: 'desc' }],
233
+ skip: (query.page - 1) * query.pageSize,
234
+ take: query.pageSize,
235
+ }),
236
+ db.storageMigrationRun.count(),
237
+ ]);
238
+ const counts = await this.countsFor(rows.map((row) => row.id));
239
+ return {
240
+ items: rows.map((row) => this.view(row, counts.get(row.id) ?? EMPTY_COUNTS)),
241
+ meta: { page: query.page, pageSize: query.pageSize, totalItems, totalPages: Math.ceil(totalItems / query.pageSize) },
242
+ };
243
+ }
244
+ /**
245
+ * One run, with live counts.
246
+ *
247
+ * @param runId - the run.
248
+ * @returns the run.
249
+ * @throws NotFoundException when there is no such run.
250
+ */
251
+ async get(runId) {
252
+ const run = await this.db().storageMigrationRun.findUnique({ where: { id: runId } });
253
+ if (!run)
254
+ throw new common_1.NotFoundException(`Storage migration ${runId} not found`);
255
+ const counts = await this.countsFor([run.id]);
256
+ return this.view(run, counts.get(run.id) ?? EMPTY_COUNTS);
257
+ }
258
+ /**
259
+ * Cancels a pending or running run. Queued items become `skipped` at once, so
260
+ * the run stops before its next unclaimed object; an object being copied right
261
+ * now finishes (its copy is verified and harmless) and the source of every
262
+ * object is untouched either way.
263
+ *
264
+ * @param runId - the run.
265
+ * @param userId - the administrator.
266
+ * @returns the cancelled run.
267
+ * @throws NotFoundException when there is no such run.
268
+ * @throws ConflictException when it already finished.
269
+ */
270
+ async cancel(runId, userId) {
271
+ const db = this.db();
272
+ const now = new Date();
273
+ const flipped = await db.storageMigrationRun.updateMany({
274
+ where: { id: runId, status: { in: ACTIVE_STATUSES } },
275
+ data: {
276
+ status: storage_db_1.StorageMigrationRunStatus.cancelled,
277
+ cancelledAt: now,
278
+ cancelledById: userId,
279
+ finishedAt: now,
280
+ },
281
+ });
282
+ if (flipped.count === 0) {
283
+ const existing = await db.storageMigrationRun.findUnique({ where: { id: runId }, select: { status: true } });
284
+ if (!existing)
285
+ throw new common_1.NotFoundException(`Storage migration ${runId} not found`);
286
+ throw new common_1.ConflictException({
287
+ message: `Storage migration ${runId} is already ${existing.status}`,
288
+ details: { status: existing.status },
289
+ });
290
+ }
291
+ await db.storageMigrationItem.updateMany({
292
+ where: { runId, status: storage_db_1.StorageMigrationItemStatus.pending },
293
+ data: { status: storage_db_1.StorageMigrationItemStatus.skipped, lastError: 'Run cancelled' },
294
+ });
295
+ await this.writeCounterSnapshot(runId);
296
+ await this.audit(userId, storage_migration_constants_1.STORAGE_MIGRATION_AUDIT_ACTIONS.CANCEL, runId, {});
297
+ this.logger.log(`Storage migration ${runId} cancelled`);
298
+ return this.get(runId);
299
+ }
300
+ // ---------------------------------------------------------------------------
301
+ // Run bookkeeping, shared by the two handlers
302
+ // ---------------------------------------------------------------------------
303
+ /**
304
+ * Item counts per run, by status, in one `groupBy`.
305
+ *
306
+ * @param runIds - the runs.
307
+ * @returns a map from run id to its counts (absent: no items).
308
+ */
309
+ async countsFor(runIds) {
310
+ const result = new Map();
311
+ if (runIds.length === 0)
312
+ return result;
313
+ const groups = await this.db().storageMigrationItem.groupBy({
314
+ by: ['runId', 'status'],
315
+ where: { runId: { in: [...runIds] } },
316
+ _count: { _all: true },
317
+ });
318
+ for (const group of groups) {
319
+ const counts = result.get(group.runId) ?? { ...EMPTY_COUNTS };
320
+ const n = group._count._all;
321
+ counts.total += n;
322
+ if (group.status === storage_db_1.StorageMigrationItemStatus.migrated)
323
+ counts.migrated += n;
324
+ else if (group.status === storage_db_1.StorageMigrationItemStatus.failed)
325
+ counts.failed += n;
326
+ else if (group.status === storage_db_1.StorageMigrationItemStatus.skipped)
327
+ counts.skipped += n;
328
+ else
329
+ counts.pending += n;
330
+ result.set(group.runId, counts);
331
+ }
332
+ return result;
333
+ }
334
+ /**
335
+ * Finalizes a running, fully planned run whose items are all terminal:
336
+ * `failed` when any item failed, `completed` otherwise. Safe to call from any
337
+ * number of finishing jobs at once (one conditional update wins).
338
+ *
339
+ * @param runId - the run.
340
+ * @returns the final status when this call finalized it, otherwise `null`.
341
+ */
342
+ async finalizeIfDone(runId) {
343
+ const counts = (await this.countsFor([runId])).get(runId) ?? EMPTY_COUNTS;
344
+ if (counts.pending > 0)
345
+ return null;
346
+ const status = counts.failed > 0 ? storage_db_1.StorageMigrationRunStatus.failed : storage_db_1.StorageMigrationRunStatus.completed;
347
+ const flipped = await this.db().storageMigrationRun.updateMany({
348
+ where: { id: runId, status: storage_db_1.StorageMigrationRunStatus.running, plannedAt: { not: null } },
349
+ data: {
350
+ status,
351
+ finishedAt: new Date(),
352
+ totalCount: counts.total,
353
+ migratedCount: counts.migrated,
354
+ failedCount: counts.failed,
355
+ skippedCount: counts.skipped,
356
+ },
357
+ });
358
+ if (flipped.count === 0)
359
+ return null;
360
+ this.logger.log(`Storage migration ${runId} ${status}: ${counts.migrated} migrated, ${counts.failed} failed, ${counts.skipped} skipped`);
361
+ return status;
362
+ }
363
+ /**
364
+ * Marks an active run `failed` with a reason (the planner gave up, or could not be queued).
365
+ *
366
+ * @param runId - the run.
367
+ * @param reason - why.
368
+ */
369
+ async failRun(runId, reason) {
370
+ await this.db().storageMigrationRun.updateMany({
371
+ where: { id: runId, status: { in: ACTIVE_STATUSES } },
372
+ data: { status: storage_db_1.StorageMigrationRunStatus.failed, finishedAt: new Date(), lastError: reason.slice(0, MAX_ERROR_LENGTH) },
373
+ });
374
+ await this.db().storageMigrationItem.updateMany({
375
+ where: { runId, status: storage_db_1.StorageMigrationItemStatus.pending },
376
+ data: { status: storage_db_1.StorageMigrationItemStatus.skipped, lastError: 'Run failed' },
377
+ });
378
+ await this.writeCounterSnapshot(runId);
379
+ }
380
+ /**
381
+ * Records an error on the run (the most recent item failure), without changing its status.
382
+ *
383
+ * @param runId - the run.
384
+ * @param message - the error.
385
+ */
386
+ async recordRunError(runId, message) {
387
+ await this.db().storageMigrationRun.updateMany({
388
+ where: { id: runId },
389
+ data: { lastError: message.slice(0, MAX_ERROR_LENGTH) },
390
+ });
391
+ }
392
+ async writeCounterSnapshot(runId) {
393
+ const counts = (await this.countsFor([runId])).get(runId) ?? EMPTY_COUNTS;
394
+ await this.db().storageMigrationRun.updateMany({
395
+ where: { id: runId },
396
+ data: {
397
+ totalCount: counts.total,
398
+ migratedCount: counts.migrated,
399
+ failedCount: counts.failed,
400
+ skippedCount: counts.skipped,
401
+ },
402
+ });
403
+ }
404
+ view(run, counts) {
405
+ return {
406
+ id: run.id,
407
+ sourceProvider: run.sourceProvider,
408
+ targetProvider: run.targetProvider,
409
+ status: run.status,
410
+ totalCount: counts.total,
411
+ migratedCount: counts.migrated,
412
+ failedCount: counts.failed,
413
+ skippedCount: counts.skipped,
414
+ pendingCount: counts.pending,
415
+ startedById: run.startedById,
416
+ startedAt: iso(run.startedAt),
417
+ plannedAt: iso(run.plannedAt),
418
+ finishedAt: iso(run.finishedAt),
419
+ cancelledAt: iso(run.cancelledAt),
420
+ lastError: run.lastError,
421
+ createdAt: run.createdAt.toISOString(),
422
+ };
423
+ }
424
+ async audit(userId, action, runId, meta) {
425
+ try {
426
+ await this.prisma.auditEvent.create({
427
+ data: { actorUserId: userId, action, targetType: 'storage_migration_run', targetId: runId, meta },
428
+ });
429
+ }
430
+ catch (error) {
431
+ // The run is real either way; a lost audit row must not fail the request.
432
+ this.logger.warn(`Could not audit ${action} for storage migration ${runId}: ${storageMigrationErrorText(error)}`);
433
+ }
434
+ }
435
+ };
436
+ exports.StorageMigrationService = StorageMigrationService;
437
+ exports.StorageMigrationService = StorageMigrationService = StorageMigrationService_1 = __decorate([
438
+ (0, common_1.Injectable)(),
439
+ __param(0, (0, common_1.Inject)(ports_1.STORAGE_SYSTEM_DATA)),
440
+ __param(1, (0, common_1.Inject)(index_1.PLATFORM_PRISMA)),
441
+ __metadata("design:paramtypes", [Object, Object, storage_config_service_1.StorageConfigService,
442
+ index_2.JobsService])
443
+ ], StorageMigrationService);
444
+ //# sourceMappingURL=storage-migration.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage-migration.service.js","sourceRoot":"","sources":["../../../src/storage/migration/storage-migration.service.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,2EAA2E;AAC3E,4EAA4E;AAC5E,gFAAgF;AAChF,EAAE;AACF,YAAY;AACZ,EAAE;AACF,wEAAwE;AACxE,+EAA+E;AAC/E,iFAAiF;AACjF,6DAA6D;AAC7D,8EAA8E;AAC9E,oEAAoE;AACpE,4EAA4E;AAC5E,+EAA+E;AAC/E,+CAA+C;AAC/C,yDAAyD;AACzD,4CAA4C;AAC5C,EAAE;AACF,wDAAwD;AACxD,4EAA4E;AAC5E,+EAA+E;AAC/E,gFAAgF;AAChF,2EAA2E;AAC3E,4BAA4B;AAC5B,EAAE;AACF,0EAA0E;AAC1E,+EAA+E;AAC/E,gFAAgF;AAChF,uDAAuD;AACvD,EAAE;AACF,iFAAiF;AACjF,0EAA0E;AAC1E,6EAA6E;AAC7E,wEAAwE;AACxE,gFAAgF;;;;;;;;;;;;;;;;AAoIhF,8DAGC;AArID,2CAO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EAAE,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC;YAC7B,UAAU,EAAE,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC;YAC/B,WAAW,EAAE,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC;YACjC,SAAS,EAAE,GAAG,CAAC,SAAS;YACxB,SAAS,EAAE,GAAG,CAAC,SAAS,CAAC,WAAW,EAAE;SACvC,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,KAAK,CAAC,MAAc,EAAE,MAAc,EAAE,KAAa,EAAE,IAA4B;QAC7F,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC;gBAClC,IAAI,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,uBAAuB,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE;aAClG,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,0EAA0E;YAC1E,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,mBAAmB,MAAM,0BAA0B,KAAK,KAAK,yBAAyB,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACpH,CAAC;IACH,CAAC;CACF,CAAA;AAlVY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,mBAAU,GAAE;IAKR,WAAA,IAAA,eAAM,EAAC,2BAAmB,CAAC,CAAA;IAC3B,WAAA,IAAA,eAAM,EAAC,uBAAe,CAAC,CAAA;qDACQ,6CAAoB;QAC7B,mBAAW;GAPzB,uBAAuB,CAkVnC"}
@@ -34,6 +34,6 @@ export interface StorageSystemData {
34
34
  * @param reason - why (`'purge'`, `'admin-aggregate'`); recorded on the active span.
35
35
  * @returns the client, seen as {@link StoragePrisma}.
36
36
  */
37
- asSystem(reason: SystemAccessReason): Pick<StoragePrisma, 'storageObject' | 'storageObjectChunk'>;
37
+ asSystem(reason: SystemAccessReason): Pick<StoragePrisma, 'storageObject' | 'storageObjectChunk' | 'storageMigrationRun' | 'storageMigrationItem'>;
38
38
  }
39
39
  //# sourceMappingURL=ports.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ports.d.ts","sourceRoot":"","sources":["../../src/storage/ports.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,mBAAmB,EAAE,OAAO,MAA+D,CAAC;AAEzG;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;;OAMG;IACH,QAAQ,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAAC,aAAa,EAAE,eAAe,GAAG,oBAAoB,CAAC,CAAC;CACnG"}
1
+ {"version":3,"file":"ports.d.ts","sourceRoot":"","sources":["../../src/storage/ports.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,mBAAmB,EAAE,OAAO,MAA+D,CAAC;AAEzG;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;;OAMG;IACH,QAAQ,CACN,MAAM,EAAE,kBAAkB,GACzB,IAAI,CAAC,aAAa,EAAE,eAAe,GAAG,oBAAoB,GAAG,qBAAqB,GAAG,sBAAsB,CAAC,CAAC;CACjH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marinoscar/platform-api",
3
- "version": "0.1.0-next.25",
3
+ "version": "0.1.0-next.27",
4
4
  "description": "NestJS dynamic modules of the platform (CommonJS, built with tsc for decorator metadata).",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",
@@ -232,8 +232,8 @@
232
232
  "@aws-sdk/lib-storage": "^3.975.0",
233
233
  "@aws-sdk/s3-request-presigner": "^3.975.0",
234
234
  "@google/genai": "^2.24.0",
235
- "@marinoscar/platform-ai-providers": "0.1.0-next.25",
236
- "@marinoscar/platform-contract": "0.1.0-next.25",
235
+ "@marinoscar/platform-ai-providers": "0.1.0-next.27",
236
+ "@marinoscar/platform-contract": "0.1.0-next.27",
237
237
  "@opentelemetry/auto-instrumentations-node": "^0.79.0",
238
238
  "@opentelemetry/core": "^2.10.0",
239
239
  "@opentelemetry/exporter-logs-otlp-http": "^0.221.0",