@cyberismo/data-handler 0.0.17 → 0.0.19

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 (112) hide show
  1. package/dist/command-handler.d.ts +2 -0
  2. package/dist/command-handler.js +26 -2
  3. package/dist/command-handler.js.map +1 -1
  4. package/dist/command-manager.d.ts +2 -0
  5. package/dist/command-manager.js +3 -0
  6. package/dist/command-manager.js.map +1 -1
  7. package/dist/commands/create.d.ts +3 -1
  8. package/dist/commands/create.js +10 -1
  9. package/dist/commands/create.js.map +1 -1
  10. package/dist/commands/migrate.d.ts +33 -0
  11. package/dist/commands/migrate.js +66 -0
  12. package/dist/commands/migrate.js.map +1 -0
  13. package/dist/containers/project/card-cache.js +13 -1
  14. package/dist/containers/project/card-cache.js.map +1 -1
  15. package/dist/containers/project/project-paths.d.ts +1 -0
  16. package/dist/containers/project/project-paths.js +5 -2
  17. package/dist/containers/project/project-paths.js.map +1 -1
  18. package/dist/containers/project.d.ts +10 -0
  19. package/dist/containers/project.js +39 -2
  20. package/dist/containers/project.js.map +1 -1
  21. package/dist/containers/template.js +2 -0
  22. package/dist/containers/template.js.map +1 -1
  23. package/dist/interfaces/command-options.d.ts +6 -1
  24. package/dist/interfaces/project-interfaces.d.ts +4 -0
  25. package/dist/interfaces/project-interfaces.js.map +1 -1
  26. package/dist/migrations/index.d.ts +14 -0
  27. package/dist/migrations/index.js +14 -0
  28. package/dist/migrations/index.js.map +1 -0
  29. package/dist/migrations/migration-executor.d.ts +79 -0
  30. package/dist/migrations/migration-executor.js +312 -0
  31. package/dist/migrations/migration-executor.js.map +1 -0
  32. package/dist/migrations/migration-worker.d.ts +13 -0
  33. package/dist/migrations/migration-worker.js +156 -0
  34. package/dist/migrations/migration-worker.js.map +1 -0
  35. package/dist/migrations/worker-executor.d.ts +24 -0
  36. package/dist/migrations/worker-executor.js +157 -0
  37. package/dist/migrations/worker-executor.js.map +1 -0
  38. package/dist/project-settings.d.ts +2 -0
  39. package/dist/project-settings.js +7 -0
  40. package/dist/project-settings.js.map +1 -1
  41. package/dist/resources/calculation-resource.d.ts +9 -0
  42. package/dist/resources/calculation-resource.js +13 -2
  43. package/dist/resources/calculation-resource.js.map +1 -1
  44. package/dist/resources/card-type-resource.d.ts +12 -3
  45. package/dist/resources/card-type-resource.js +73 -91
  46. package/dist/resources/card-type-resource.js.map +1 -1
  47. package/dist/resources/field-type-resource.d.ts +10 -1
  48. package/dist/resources/field-type-resource.js +62 -61
  49. package/dist/resources/field-type-resource.js.map +1 -1
  50. package/dist/resources/file-resource.d.ts +27 -2
  51. package/dist/resources/file-resource.js +46 -8
  52. package/dist/resources/file-resource.js.map +1 -1
  53. package/dist/resources/graph-model-resource.d.ts +5 -0
  54. package/dist/resources/graph-model-resource.js +6 -0
  55. package/dist/resources/graph-model-resource.js.map +1 -1
  56. package/dist/resources/graph-view-resource.d.ts +5 -0
  57. package/dist/resources/graph-view-resource.js +6 -0
  58. package/dist/resources/graph-view-resource.js.map +1 -1
  59. package/dist/resources/link-type-resource.d.ts +11 -1
  60. package/dist/resources/link-type-resource.js +54 -30
  61. package/dist/resources/link-type-resource.js.map +1 -1
  62. package/dist/resources/report-resource.d.ts +6 -1
  63. package/dist/resources/report-resource.js +7 -1
  64. package/dist/resources/report-resource.js.map +1 -1
  65. package/dist/resources/resource-object.d.ts +22 -7
  66. package/dist/resources/resource-object.js +44 -15
  67. package/dist/resources/resource-object.js.map +1 -1
  68. package/dist/resources/template-resource.d.ts +5 -1
  69. package/dist/resources/template-resource.js +11 -27
  70. package/dist/resources/template-resource.js.map +1 -1
  71. package/dist/resources/workflow-resource.d.ts +7 -3
  72. package/dist/resources/workflow-resource.js +90 -82
  73. package/dist/resources/workflow-resource.js.map +1 -1
  74. package/dist/utils/card-utils.d.ts +1 -1
  75. package/dist/utils/common-utils.d.ts +8 -0
  76. package/dist/utils/common-utils.js +14 -0
  77. package/dist/utils/common-utils.js.map +1 -1
  78. package/dist/utils/file-utils.d.ts +15 -3
  79. package/dist/utils/file-utils.js +48 -9
  80. package/dist/utils/file-utils.js.map +1 -1
  81. package/dist/utils/json.js +2 -2
  82. package/dist/utils/json.js.map +1 -1
  83. package/package.json +5 -3
  84. package/src/command-handler.ts +38 -1
  85. package/src/command-manager.ts +3 -0
  86. package/src/commands/create.ts +11 -0
  87. package/src/commands/migrate.ts +88 -0
  88. package/src/containers/project/card-cache.ts +18 -1
  89. package/src/containers/project/project-paths.ts +6 -2
  90. package/src/containers/project.ts +66 -1
  91. package/src/containers/template.ts +5 -0
  92. package/src/interfaces/command-options.ts +8 -0
  93. package/src/interfaces/project-interfaces.ts +4 -0
  94. package/src/migrations/index.ts +20 -0
  95. package/src/migrations/migration-executor.ts +478 -0
  96. package/src/migrations/migration-worker.ts +190 -0
  97. package/src/migrations/worker-executor.ts +185 -0
  98. package/src/project-settings.ts +7 -0
  99. package/src/resources/calculation-resource.ts +13 -2
  100. package/src/resources/card-type-resource.ts +101 -114
  101. package/src/resources/field-type-resource.ts +78 -71
  102. package/src/resources/file-resource.ts +68 -9
  103. package/src/resources/graph-model-resource.ts +6 -0
  104. package/src/resources/graph-view-resource.ts +6 -0
  105. package/src/resources/link-type-resource.ts +66 -36
  106. package/src/resources/report-resource.ts +7 -1
  107. package/src/resources/resource-object.ts +57 -18
  108. package/src/resources/template-resource.ts +12 -27
  109. package/src/resources/workflow-resource.ts +119 -100
  110. package/src/utils/common-utils.ts +15 -0
  111. package/src/utils/file-utils.ts +56 -12
  112. package/src/utils/json.ts +2 -6
@@ -0,0 +1,312 @@
1
+ /**
2
+ Cyberismo
3
+ Copyright © Cyberismo Ltd and contributors 2025
4
+ This program is free software: you can redistribute it and/or modify it under
5
+ the terms of the GNU Affero General Public License version 3 as published by
6
+ the Free Software Foundation.
7
+ This program is distributed in the hope that it will be useful, but WITHOUT
8
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9
+ FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
10
+ details. You should have received a copy of the GNU Affero General Public
11
+ License along with this program. If not, see <https://www.gnu.org/licenses/>.
12
+ */
13
+ import { dirname, join } from 'node:path';
14
+ import { fileURLToPath } from 'node:url';
15
+ import { availableMigrations, migration } from '@cyberismo/migrations';
16
+ import { availableSpace, folderSize } from '../utils/file-utils.js';
17
+ import { executeStep } from './worker-executor.js';
18
+ import { getChildLogger } from '../utils/log-utils.js';
19
+ import { Validate } from '../commands/validate.js';
20
+ const DEFAULT_MIGRATION_TIMEOUT_MS = 2 * 60 * 1000; // 2 minutes
21
+ const MEGABYTES = 1024 * 1024; // 1 MB
22
+ /**
23
+ * Executes schema migrations for a project.
24
+ */
25
+ export class MigrationExecutor {
26
+ project;
27
+ backupDir;
28
+ logger = getChildLogger({ module: 'MigrationExecutor' });
29
+ timeoutMilliSeconds;
30
+ /**
31
+ * Constructs instance of MigrationExecutor
32
+ * @param project Project instance to use
33
+ * @param backupDir Backup directory, if any.
34
+ * @param timeoutMilliSeconds Timeout in milliseconds (defaults to 2 minutes)
35
+ */
36
+ constructor(project, backupDir, timeoutMilliSeconds) {
37
+ this.project = project;
38
+ this.backupDir = backupDir;
39
+ this.timeoutMilliSeconds =
40
+ timeoutMilliSeconds ?? DEFAULT_MIGRATION_TIMEOUT_MS;
41
+ }
42
+ // Helper to create failure result from ExecutionState
43
+ createFailureResult(state, message, error) {
44
+ return {
45
+ success: false,
46
+ message,
47
+ error,
48
+ stepsExecuted: state.stepsExecuted,
49
+ };
50
+ }
51
+ // Execute a single migration step and handle failure
52
+ async executeStep(stepName, migrationPath, state) {
53
+ const result = await executeStep(migrationPath, stepName, state.context, this.timeoutMilliSeconds);
54
+ state.stepsExecuted.push(stepName);
55
+ if (!result.success) {
56
+ const messagePrefix = {
57
+ before: 'Pre-migration check failed',
58
+ backup: 'Backup failed',
59
+ migrate: 'Migration failed',
60
+ after: 'Post-migration step failed',
61
+ }[stepName] || `Step '${stepName}' failed`;
62
+ return this.createFailureResult(state, `${messagePrefix}: ${result.message || 'Unknown error'}`, result.error);
63
+ }
64
+ return { success: true };
65
+ }
66
+ // Execute a single migration.
67
+ async executeMigration(migrationPath, fromVersion, toVersion, updateVersionCallback) {
68
+ this.logger.info({ fromVersion, toVersion }, `Executing migration from version ${fromVersion} to ${toVersion}`);
69
+ const state = {
70
+ context: {
71
+ cardRootPath: this.project.paths.cardRootFolder,
72
+ cardsConfigPath: this.project.paths.internalRootFolder,
73
+ fromVersion,
74
+ toVersion,
75
+ },
76
+ stepsExecuted: [],
77
+ };
78
+ try {
79
+ // Load migration to check which steps exist
80
+ const migration = this.loadMigration(toVersion);
81
+ if (!migration) {
82
+ return this.createFailureResult(state, `Failed to load migration for version ${toVersion}`);
83
+ }
84
+ if (migration.before) {
85
+ const result = await this.executeStep('before', migrationPath, state);
86
+ if (!result.success)
87
+ return result;
88
+ }
89
+ if (migration.backup && this.backupDir !== undefined) {
90
+ state.context.backupDir = this.backupDir;
91
+ const result = await this.executeStep('backup', migrationPath, state);
92
+ if (!result.success)
93
+ return result;
94
+ }
95
+ const migrateResult = await this.executeStep('migrate', migrationPath, state);
96
+ if (!migrateResult.success)
97
+ return migrateResult;
98
+ // Update schema version in project after successful migration
99
+ await updateVersionCallback(toVersion);
100
+ state.stepsExecuted.push('update-version');
101
+ if (migration.after) {
102
+ const result = await this.executeStep('after', migrationPath, state);
103
+ if (!result.success)
104
+ return result;
105
+ }
106
+ // Run validation after migration
107
+ state.stepsExecuted.push('validate');
108
+ const validationErrors = await this.validate();
109
+ if (validationErrors) {
110
+ return this.createFailureResult(state, `Post-migration validation failed: ${validationErrors}`);
111
+ }
112
+ this.logger.info('Post-migration validation passed');
113
+ return {
114
+ success: true,
115
+ message: `Successfully migrated from version ${fromVersion} to ${toVersion}`,
116
+ stepsExecuted: state.stepsExecuted,
117
+ };
118
+ }
119
+ catch (error) {
120
+ return this.createFailureResult(state, `Migration threw an exception: ${error}`, error instanceof Error ? error : new Error(String(error)));
121
+ }
122
+ }
123
+ // Checks if pre-migration validation succeeds.
124
+ async preMigrateValidation(fromVersion, toVersion, stepsExecuted) {
125
+ const validationErrors = await this.validate();
126
+ if (validationErrors) {
127
+ this.logger.error({ errors: validationErrors }, 'Pre-migration validation failed');
128
+ return {
129
+ success: false,
130
+ message: `Pre-migration validation failed. Please fix the following errors before migrating:\n${validationErrors}`,
131
+ stepsExecuted,
132
+ };
133
+ }
134
+ this.logger.info('Pre-migration validation passed');
135
+ return {
136
+ success: true,
137
+ stepsExecuted,
138
+ };
139
+ }
140
+ // Validate the project.
141
+ async validate() {
142
+ const validator = Validate.getInstance();
143
+ return await validator.validate(this.project.basePath, () => this.project);
144
+ }
145
+ // Validates that migration versions are valid.
146
+ validateMigrationVersions(fromVersion, toVersion, stepsExecuted) {
147
+ const valid = fromVersion < toVersion;
148
+ return {
149
+ success: valid,
150
+ message: valid
151
+ ? undefined
152
+ : `Current version (${fromVersion}) is not lower than target version (${toVersion})`,
153
+ stepsExecuted,
154
+ };
155
+ }
156
+ // Checks if there is enough disk space.
157
+ async checkDiskSpace(fromVersion, toVersion, stepsExecuted) {
158
+ try {
159
+ const internalSize = await folderSize(this.project.paths.internalRootFolder);
160
+ const cardRootSize = await folderSize(this.project.paths.cardRootFolder);
161
+ const projectSize = internalSize + cardRootSize;
162
+ const requiredSpace = projectSize * 2;
163
+ const spaceAvailable = await availableSpace(this.project.basePath);
164
+ const projectSizeMB = (projectSize / MEGABYTES).toFixed(2);
165
+ const requiredSpaceMB = (requiredSpace / MEGABYTES).toFixed(2);
166
+ const availableSpaceMB = (spaceAvailable / MEGABYTES).toFixed(2);
167
+ if (spaceAvailable < requiredSpace) {
168
+ return {
169
+ success: false,
170
+ message: `Insufficient disk space. Required: ${requiredSpaceMB} MB, Available: ${availableSpaceMB} MB. Migration needs at least 2x the project size (${projectSizeMB} MB).`,
171
+ stepsExecuted,
172
+ };
173
+ }
174
+ this.logger.info('Disk space check passed');
175
+ return {
176
+ success: true,
177
+ stepsExecuted,
178
+ };
179
+ }
180
+ catch (error) {
181
+ this.logger.error({ error }, 'Failed to check disk space');
182
+ return {
183
+ success: false,
184
+ message: `Failed to check disk space: ${error instanceof Error ? error.message : String(error)}`,
185
+ error: error instanceof Error ? error : new Error(String(error)),
186
+ stepsExecuted,
187
+ };
188
+ }
189
+ }
190
+ /**
191
+ * Discover available migrations between two versions.
192
+ * @param fromVersion Starting version (exclusive)
193
+ * @param toVersion Target version (inclusive)
194
+ * @returns Sorted list of migration version numbers
195
+ */
196
+ migrationsAvailable(fromVersion, toVersion) {
197
+ const allVersions = availableMigrations();
198
+ return allVersions.filter((version) => version > fromVersion && version <= toVersion);
199
+ }
200
+ // Validates and discovers available migrations
201
+ availableMigrations(fromVersion, toVersion, stepsExecuted) {
202
+ const migrationVersions = this.migrationsAvailable(fromVersion, toVersion);
203
+ const found = migrationVersions.length > 0;
204
+ if (found) {
205
+ this.logger.info({ versions: migrationVersions }, `Found ${migrationVersions.length} migration(s)`);
206
+ }
207
+ return {
208
+ success: found,
209
+ message: found
210
+ ? undefined
211
+ : `No migrations found between version ${fromVersion} and ${toVersion}`,
212
+ stepsExecuted,
213
+ migrationVersions,
214
+ };
215
+ }
216
+ // Load a migration module for a specific version.
217
+ loadMigration(version) {
218
+ this.logger.debug({ version }, 'Loading migration');
219
+ try {
220
+ const migrationObject = migration(version);
221
+ if (!migrationObject) {
222
+ this.logger.error({ version }, `Migration not found`);
223
+ return undefined;
224
+ }
225
+ if (typeof migrationObject.migrate !== 'function') {
226
+ throw new Error(`Migration ${version} does not implement migrate() function`);
227
+ }
228
+ return migrationObject;
229
+ }
230
+ catch (error) {
231
+ this.logger.error({ error, version }, `Failed to load migration`);
232
+ return undefined;
233
+ }
234
+ }
235
+ /**
236
+ * Get the file path for a migration worker.
237
+ * @param version Migration version number
238
+ * @returns Path to migration file
239
+ */
240
+ migrationWorkerPath(version) {
241
+ const migrationsPackageUrl = import.meta.resolve('@cyberismo/migrations');
242
+ const migrationsIndexPath = fileURLToPath(migrationsPackageUrl);
243
+ const migrationsDistDir = dirname(migrationsIndexPath);
244
+ return join(migrationsDistDir, version.toString(), 'index.js');
245
+ }
246
+ /**
247
+ * Execute all necessary migrations to bring project to target version.
248
+ * @param fromVersion Current project version
249
+ * @param toVersion Target version
250
+ * @param updateVersionCallback Callback to update project schema version after each migration
251
+ * @returns Overall migration result
252
+ */
253
+ async migrate(fromVersion, toVersion, updateVersionCallback) {
254
+ const stepsDone = [];
255
+ // Step: Validate migration versions
256
+ const versionResult = this.validateMigrationVersions(fromVersion, toVersion, stepsDone);
257
+ if (!versionResult.success)
258
+ return versionResult;
259
+ stepsDone.push('version-validation');
260
+ // Step: Pre-migration validation
261
+ const validationResult = await this.preMigrateValidation(fromVersion, toVersion, stepsDone);
262
+ if (!validationResult.success)
263
+ return validationResult;
264
+ stepsDone.push('pre-validation');
265
+ // Step: Check disk space
266
+ const diskSpaceResult = await this.checkDiskSpace(fromVersion, toVersion, stepsDone);
267
+ if (!diskSpaceResult.success)
268
+ return diskSpaceResult;
269
+ stepsDone.push('disk-space-check');
270
+ // Step: Discover available migrations
271
+ const discoveryResult = this.availableMigrations(fromVersion, toVersion, stepsDone);
272
+ if (!discoveryResult.success)
273
+ return discoveryResult;
274
+ stepsDone.push('migration-versions');
275
+ const migrationVersions = discoveryResult.migrationVersions;
276
+ // Step(s): Execute migrations in sequence
277
+ let currentVersion = fromVersion;
278
+ try {
279
+ for (const targetVersion of migrationVersions) {
280
+ const migrationPath = this.migrationWorkerPath(targetVersion);
281
+ const result = await this.executeMigration(migrationPath, currentVersion, targetVersion, updateVersionCallback);
282
+ if (!result.success) {
283
+ return {
284
+ success: false,
285
+ message: result.message || 'Migration failed',
286
+ error: result.error,
287
+ stepsExecuted: stepsDone,
288
+ };
289
+ }
290
+ stepsDone.push(...result.stepsExecuted.map((step) => `v${targetVersion}:${step}`));
291
+ currentVersion = targetVersion;
292
+ this.logger.info({ targetVersion }, `Migration to version ${targetVersion} completed successfully`);
293
+ }
294
+ }
295
+ catch (error) {
296
+ return {
297
+ success: false,
298
+ message: error instanceof Error
299
+ ? error.message
300
+ : `Migration timeout or error: ${error}`,
301
+ error: error instanceof Error ? error : new Error(String(error)),
302
+ stepsExecuted: stepsDone,
303
+ };
304
+ }
305
+ return {
306
+ success: true,
307
+ message: `Successfully migrated from version ${fromVersion} to ${currentVersion}`,
308
+ stepsExecuted: stepsDone,
309
+ };
310
+ }
311
+ }
312
+ //# sourceMappingURL=migration-executor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration-executor.js","sourceRoot":"","sources":["../../src/migrations/migration-executor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE;AAEF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAUnD,MAAM,4BAA4B,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,YAAY;AAChE,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,OAAO;AA6BtC;;GAEG;AACH,MAAM,OAAO,iBAAiB;IAWlB;IACA;IAXF,MAAM,GAAG,cAAc,CAAC,EAAE,MAAM,EAAE,mBAAmB,EAAE,CAAC,CAAC;IACzD,mBAAmB,CAAS;IAEpC;;;;;OAKG;IACH,YACU,OAAgB,EAChB,SAAkB,EAC1B,mBAA4B;QAFpB,YAAO,GAAP,OAAO,CAAS;QAChB,cAAS,GAAT,SAAS,CAAS;QAG1B,IAAI,CAAC,mBAAmB;YACtB,mBAA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AAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBAChE,aAAa,EAAE,SAAS;aACzB,CAAC;QACJ,CAAC;QACD,OAAO;YACL,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,sCAAsC,WAAW,OAAO,cAAc,EAAE;YACjF,aAAa,EAAE,SAAS;SACzB,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ Cyberismo
3
+ Copyright © Cyberismo Ltd and contributors 2025
4
+ This program is free software: you can redistribute it and/or modify it under
5
+ the terms of the GNU Affero General Public License version 3 as published by
6
+ the Free Software Foundation.
7
+ This program is distributed in the hope that it will be useful, but WITHOUT
8
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9
+ FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
10
+ details. You should have received a copy of the GNU Affero General Public
11
+ License along with this program. If not, see <https://www.gnu.org/licenses/>.
12
+ */
13
+ export {};
@@ -0,0 +1,156 @@
1
+ /**
2
+ Cyberismo
3
+ Copyright © Cyberismo Ltd and contributors 2025
4
+ This program is free software: you can redistribute it and/or modify it under
5
+ the terms of the GNU Affero General Public License version 3 as published by
6
+ the Free Software Foundation.
7
+ This program is distributed in the hope that it will be useful, but WITHOUT
8
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9
+ FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
10
+ details. You should have received a copy of the GNU Affero General Public
11
+ License along with this program. If not, see <https://www.gnu.org/licenses/>.
12
+ */
13
+ import { parentPort } from 'node:worker_threads';
14
+ import { pathToFileURL } from 'node:url';
15
+ let currentMigration;
16
+ let abortController;
17
+ /**
18
+ * Execute a specific step of a migration.
19
+ *
20
+ * Runs one of the migration steps (before, backup, migrate, after).
21
+ * Checks for cancellation before and after execution.
22
+ *
23
+ * @param migration The loaded migration object
24
+ * @param stepName Which step to execute ('before', 'backup', 'migrate', or 'after')
25
+ * @param context Migration context with paths and version information
26
+ * @returns Migration step result
27
+ */
28
+ async function executeStep(migration, stepName, context) {
29
+ if (abortController?.signal.aborted) {
30
+ return {
31
+ success: false,
32
+ error: new Error('Migration cancelled'),
33
+ };
34
+ }
35
+ try {
36
+ let result;
37
+ switch (stepName) {
38
+ case 'before':
39
+ if (!migration.before) {
40
+ return { success: true, message: `No 'before' step` };
41
+ }
42
+ result = await migration.before(context);
43
+ break;
44
+ case 'backup':
45
+ if (!migration.backup) {
46
+ return { success: true, message: `No 'backup' step` };
47
+ }
48
+ result = await migration.backup(context);
49
+ break;
50
+ case 'migrate':
51
+ result = await migration.migrate(context);
52
+ break;
53
+ case 'after':
54
+ if (!migration.after) {
55
+ return { success: true, message: `No 'after' step` };
56
+ }
57
+ result = await migration.after(context);
58
+ break;
59
+ default:
60
+ return {
61
+ success: false,
62
+ error: new Error(`Unknown migration step: ${stepName}`),
63
+ };
64
+ }
65
+ if (abortController?.signal.aborted) {
66
+ return {
67
+ success: false,
68
+ error: new Error('Migration cancelled'),
69
+ };
70
+ }
71
+ return result;
72
+ }
73
+ catch (error) {
74
+ return {
75
+ success: false,
76
+ error: error instanceof Error ? error : new Error(String(error)),
77
+ };
78
+ }
79
+ }
80
+ /**
81
+ * Handle a cancellation request from the main thread.
82
+ */
83
+ async function handleCancel() {
84
+ abortController?.abort();
85
+ if (currentMigration?.cancel) {
86
+ try {
87
+ await currentMigration.cancel();
88
+ }
89
+ catch {
90
+ // Ignore errors during cancellation - we're cancelling anyway
91
+ }
92
+ }
93
+ }
94
+ /**
95
+ * Worker thread message handler.
96
+ *
97
+ * Listens for messages from the main thread:
98
+ * - 'execute': Run a migration step
99
+ * - 'cancel': Cancel the currently running migration
100
+ *
101
+ * Responds with:
102
+ * - 'result': The migration step result
103
+ * - 'error': An error message when execution failed
104
+ */
105
+ if (parentPort) {
106
+ parentPort.on('message', (message) => {
107
+ if (!parentPort)
108
+ return;
109
+ void (async () => {
110
+ try {
111
+ if (message.type === 'cancel') {
112
+ await handleCancel();
113
+ const response = {
114
+ type: 'result',
115
+ result: {
116
+ success: false,
117
+ error: new Error('Migration cancelled'),
118
+ },
119
+ };
120
+ parentPort.postMessage(response);
121
+ return;
122
+ }
123
+ if (message.type === 'execute') {
124
+ if (!message.migrationPath || !message.stepName || !message.context) {
125
+ throw new Error('Missing required parameters for "execute"');
126
+ }
127
+ abortController = new AbortController();
128
+ const migrationUrl = pathToFileURL(message.migrationPath).href;
129
+ const migrationModule = await import(migrationUrl);
130
+ currentMigration = migrationModule.default || migrationModule;
131
+ if (typeof currentMigration?.migrate !== 'function') {
132
+ throw new Error(`Migration does not implement migrate() function: ${message.migrationPath}`);
133
+ }
134
+ const contextWithSignal = {
135
+ ...message.context,
136
+ signal: abortController.signal,
137
+ };
138
+ const result = await executeStep(currentMigration, message.stepName, contextWithSignal);
139
+ const response = {
140
+ type: 'result',
141
+ result,
142
+ };
143
+ parentPort.postMessage(response);
144
+ }
145
+ }
146
+ catch (error) {
147
+ const response = {
148
+ type: 'error',
149
+ error: error instanceof Error ? error.message : String(error),
150
+ };
151
+ parentPort.postMessage(response);
152
+ }
153
+ })();
154
+ });
155
+ }
156
+ //# sourceMappingURL=migration-worker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration-worker.js","sourceRoot":"","sources":["../../src/migrations/migration-worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;EAWE;AAEF,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AASzC,IAAI,gBAAuC,CAAC;AAC5C,IAAI,eAA4C,CAAC;AAEjD;;;;;;;;;;GAUG;AACH,KAAK,UAAU,WAAW,CACxB,SAAoB,EACpB,QAAgB,EAChB,OAAyB;IAEzB,IAAI,eAAe,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;QACpC,OAAO;YACL,O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© Cyberismo Ltd and contributors 2025
4
+ This program is free software: you can redistribute it and/or modify it under
5
+ the terms of the GNU Affero General Public License version 3 as published by
6
+ the Free Software Foundation.
7
+ This program is distributed in the hope that it will be useful, but WITHOUT
8
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9
+ FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
10
+ details. You should have received a copy of the GNU Affero General Public
11
+ License along with this program. If not, see <https://www.gnu.org/licenses/>.
12
+ */
13
+ import type { MigrationContext, MigrationStepResult } from '@cyberismo/migrations';
14
+ /**
15
+ * Execute a migration step in a separate worker thread.
16
+ * The worker loads the migration program dynamically and executes the specified step.
17
+ *
18
+ * @param migrationPath Absolute path to the migration's 'index.js' file
19
+ * @param stepName The migration step to execute
20
+ * @param context Migration context
21
+ * @param timeoutMilliSeconds Timeout in milliseconds to wait for the step to complete
22
+ * @returns Migration step result
23
+ */
24
+ export declare function executeStep(migrationPath: string, stepName: string, context: MigrationContext, timeoutMilliSeconds: number): Promise<MigrationStepResult>;