@bernierllc/contentful-migration-service 1.6.3 → 1.6.5

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.
package/README.md CHANGED
@@ -345,19 +345,18 @@ for (const id of pending) {
345
345
  Uses `@bernierllc/logger` for structured logging throughout the service.
346
346
 
347
347
  **NeverHub Integration**: ✅ Implemented
348
- Automatically detects and integrates with NeverHub if available.
348
+ Registers with NeverHub on construction; works unchanged when NeverHub is unreachable.
349
349
 
350
350
  ## NeverHub Integration
351
351
 
352
- The service automatically detects and integrates with NeverHub if available:
352
+ The constructor registers the service with NeverHub (type `service`, the package's own name and version). Registration never throws. When NeverHub is unreachable it does nothing. A failed or rejected registration is logged as a `NeverHub registration failed` warning, and migrations keep running.
353
353
 
354
354
  ```typescript
355
- // Events emitted:
356
- // - migration.completed: When migration succeeds
357
- // - migration.failed: When migration fails
355
+ // Events emitted in the background once registration settles; runMigration() never waits on NeverHub (no-ops when unavailable):
356
+ // - migration.completed: { migrationId, name, duration, dryRun }
357
+ // - migration.failed: { migrationId, name, error, duration }
358
358
 
359
359
  const service = new ContentfulMigrationService(config);
360
- // NeverHub automatically initialized if available
361
360
  ```
362
361
 
363
362
  ## Best Practices
@@ -430,19 +429,32 @@ Break large changes into smaller, atomic migrations:
430
429
 
431
430
  ## Error Handling
432
431
 
433
- The service handles errors gracefully and tracks them in storage:
432
+ Errors use `ContentfulMigrationServiceError` (exported from the package root). Each one carries a `code`, optional `context`, and the original error as `cause` (ES2022 `Error.cause`).
433
+
434
+ | Code | When |
435
+ |------|------|
436
+ | `INVALID_INPUT` | `InMemoryMigrationStorage.updateMigrationStatus()` is called with an unknown migration id (`context.migrationId`) |
437
+ | `OPERATION_FAILED` | `validateMigration()` hit a storage failure. The wrapper is logged with the cause chain; `errors` holds the original storage error's message |
438
+ | `CONTENTFUL_MIGRATION_SERVICE_ERROR` | Default code |
439
+
440
+ - `runMigration()` does not throw when a migration fails. It records `status: 'failed'` with the error message in storage, logs the error, publishes `migration.failed`, and returns `{ success: false, error }`.
441
+ - Storage errors from `hasMigration()` and the initial `saveMigration()` reject `runMigration()` unchanged.
442
+ - Once the migration starts, a failing `updateMigrationStatus()` is handled like a migration failure. If recording the `failed` status also throws, that error rejects `runMigration()`.
443
+ - Errors are logged to the console with an `errorChain` metadata array (each entry carries `name`, `message`, `depth` and `code`), because the logger does not serialize `Error.cause`.
434
444
 
435
445
  ```typescript
446
+ import { ContentfulMigrationServiceError } from '@bernierllc/contentful-migration-service';
447
+
436
448
  try {
437
449
  const result = await service.runMigration(migrationFn, options);
438
-
439
450
  if (!result.success) {
440
- // Migration failed but error was caught
441
- console.error(result.error);
451
+ console.error('Migration failed:', result.error);
442
452
  }
443
453
  } catch (error) {
444
- // Unexpected error (storage failure, etc.)
445
- console.error('Unexpected error:', error);
454
+ if (error instanceof ContentfulMigrationServiceError) {
455
+ console.error(error.code, error.context, error.cause);
456
+ }
457
+ throw error;
446
458
  }
447
459
  ```
448
460
 
@@ -0,0 +1,57 @@
1
+ import { ContentfulCMAClient } from '@bernierllc/contentful-cma-client';
2
+ import { MigrationServiceConfig, MigrationOptions, MigrationResult, MigrationRecord, MigrationFunction, ValidationResult } from './types';
3
+ /**
4
+ * ContentfulMigrationService manages content model migrations with version control,
5
+ * rollback support, and migration history tracking.
6
+ */
7
+ export declare class ContentfulMigrationService {
8
+ private logger;
9
+ private cmaClient;
10
+ private config;
11
+ private readonly neverhub;
12
+ /** Settles when NeverHub registration finishes; never rejects. */
13
+ private readonly registration;
14
+ constructor(config: MigrationServiceConfig);
15
+ /**
16
+ * Register with NeverHub. register() no-ops when NeverHub is unreachable,
17
+ * so no detect() guard is needed.
18
+ */
19
+ private registerWithNeverHub;
20
+ /**
21
+ * Publish once registration has settled, without blocking the caller: registration can retry
22
+ * for tens of seconds, and NeverHub is optional. publishEvent() no-ops when NeverHub is unavailable.
23
+ */
24
+ private publish;
25
+ /**
26
+ * Run a migration function
27
+ */
28
+ runMigration(migrationFn: MigrationFunction, options: MigrationOptions): Promise<MigrationResult>;
29
+ /**
30
+ * Get migration history
31
+ */
32
+ getMigrationHistory(): Promise<MigrationRecord[]>;
33
+ /**
34
+ * Get a specific migration by ID
35
+ */
36
+ getMigration(id: string): Promise<MigrationRecord | null>;
37
+ /**
38
+ * Check if a migration has been executed
39
+ */
40
+ hasExecutedMigration(id: string): Promise<boolean>;
41
+ /**
42
+ * Validate a migration function without executing
43
+ */
44
+ validateMigration(migrationFn: MigrationFunction, options: Pick<MigrationOptions, 'id' | 'name' | 'description'>): Promise<ValidationResult>;
45
+ /**
46
+ * Get pending migrations (not yet executed)
47
+ */
48
+ getPendingMigrations(migrationIds: string[]): Promise<string[]>;
49
+ /**
50
+ * Get the Contentful CMA client (for advanced operations)
51
+ */
52
+ getCMAClient(): ContentfulCMAClient;
53
+ /**
54
+ * Close connections and cleanup
55
+ */
56
+ close(): Promise<void>;
57
+ }
@@ -0,0 +1,273 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (c) 2025 Bernier LLC
4
+
5
+ This file is licensed to the client under a limited-use license.
6
+ The client may use and modify this code *only within the scope of the project it was delivered for*.
7
+ Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.ContentfulMigrationService = void 0;
11
+ const contentful_migration_1 = require("contentful-migration");
12
+ const contentful_cma_client_1 = require("@bernierllc/contentful-cma-client");
13
+ const logger_1 = require("@bernierllc/logger");
14
+ const neverhub_adapter_1 = require("@bernierllc/neverhub-adapter");
15
+ const errors_1 = require("./errors");
16
+ // Read at runtime: Lerna bumps package.json, so a literal version drifts.
17
+ const pkg = require('../package.json');
18
+ /**
19
+ * ContentfulMigrationService manages content model migrations with version control,
20
+ * rollback support, and migration history tracking.
21
+ */
22
+ class ContentfulMigrationService {
23
+ logger;
24
+ cmaClient;
25
+ config;
26
+ neverhub = new neverhub_adapter_1.NeverHubAdapter();
27
+ /** Settles when NeverHub registration finishes; never rejects. */
28
+ registration;
29
+ constructor(config) {
30
+ this.config = {
31
+ ...config,
32
+ environmentId: config.environmentId || 'master',
33
+ };
34
+ this.logger = new logger_1.Logger({
35
+ level: 2, // INFO level
36
+ transports: [new logger_1.ConsoleTransport()],
37
+ context: {
38
+ service: 'ContentfulMigrationService',
39
+ version: pkg.version,
40
+ environment: process.env.NODE_ENV || 'development',
41
+ },
42
+ });
43
+ this.cmaClient = new contentful_cma_client_1.ContentfulCMAClient({
44
+ accessToken: config.accessToken,
45
+ spaceId: config.spaceId,
46
+ environmentId: this.config.environmentId,
47
+ });
48
+ this.registration = this.registerWithNeverHub();
49
+ }
50
+ /**
51
+ * Register with NeverHub. register() no-ops when NeverHub is unreachable,
52
+ * so no detect() guard is needed.
53
+ */
54
+ async registerWithNeverHub() {
55
+ try {
56
+ await this.neverhub.register({
57
+ type: 'service',
58
+ name: pkg.name,
59
+ version: pkg.version,
60
+ dependencies: Object.keys(pkg.dependencies ?? {}),
61
+ capabilities: [
62
+ {
63
+ type: 'migration',
64
+ name: 'contentful-migrations',
65
+ version: pkg.version,
66
+ },
67
+ ],
68
+ });
69
+ // register() resolves on timeouts and non-2xx responses, so check the outcome.
70
+ if (this.neverhub.isAvailable() && !this.neverhub.isRegistered()) {
71
+ this.logger.warn('NeverHub registration failed', { error: 'registration not accepted' });
72
+ }
73
+ }
74
+ catch (error) {
75
+ // NeverHub is optional: migrations keep running without it.
76
+ this.logger.warn('NeverHub registration failed', {
77
+ error: error instanceof Error ? error.message : String(error),
78
+ });
79
+ }
80
+ }
81
+ /**
82
+ * Publish once registration has settled, without blocking the caller: registration can retry
83
+ * for tens of seconds, and NeverHub is optional. publishEvent() no-ops when NeverHub is unavailable.
84
+ */
85
+ publish(event) {
86
+ this.registration
87
+ .then(() => this.neverhub.publishEvent(event))
88
+ .catch((error) => {
89
+ this.logger.warn('NeverHub event publish failed', {
90
+ event: event.type,
91
+ error: error instanceof Error ? error.message : String(error),
92
+ });
93
+ });
94
+ }
95
+ /**
96
+ * Run a migration function
97
+ */
98
+ async runMigration(migrationFn, options) {
99
+ const startTime = Date.now();
100
+ const { id, name, description, dryRun = false } = options;
101
+ this.logger.info(`Starting migration: ${name}`, { id, dryRun });
102
+ // Check if migration already executed
103
+ const alreadyExecuted = await this.config.storage.hasMigration(id, this.config.spaceId, this.config.environmentId);
104
+ if (alreadyExecuted && !dryRun) {
105
+ this.logger.warn(`Migration ${id} already executed, skipping`);
106
+ return {
107
+ success: true,
108
+ migrationId: id,
109
+ duration: 0,
110
+ dryRun: false,
111
+ error: 'Migration already executed',
112
+ };
113
+ }
114
+ // Create migration record
115
+ const record = {
116
+ id,
117
+ name,
118
+ description,
119
+ executedAt: new Date(),
120
+ executedBy: this.config.executedBy,
121
+ status: 'running',
122
+ spaceId: this.config.spaceId,
123
+ environmentId: this.config.environmentId,
124
+ dryRun,
125
+ };
126
+ await this.config.storage.saveMigration(record);
127
+ try {
128
+ // Run migration using contentful-migration
129
+ await (0, contentful_migration_1.runMigration)({
130
+ spaceId: this.config.spaceId,
131
+ environmentId: this.config.environmentId,
132
+ accessToken: this.config.accessToken,
133
+ yes: !dryRun,
134
+ migrationFunction: migrationFn,
135
+ });
136
+ const duration = Date.now() - startTime;
137
+ // Update status
138
+ await this.config.storage.updateMigrationStatus(id, 'completed', undefined, duration);
139
+ this.logger.info(`Migration completed: ${name}`, { id, duration, dryRun });
140
+ this.publish({
141
+ type: 'migration.completed',
142
+ data: {
143
+ migrationId: id,
144
+ name,
145
+ duration,
146
+ dryRun,
147
+ },
148
+ });
149
+ return {
150
+ success: true,
151
+ migrationId: id,
152
+ duration,
153
+ dryRun,
154
+ };
155
+ }
156
+ catch (error) {
157
+ const duration = Date.now() - startTime;
158
+ const errorMessage = error instanceof Error ? error.message : String(error);
159
+ const errorObj = error instanceof Error ? error : new Error(String(error));
160
+ await this.config.storage.updateMigrationStatus(id, 'failed', errorMessage, duration);
161
+ this.logger.error(`Migration failed: ${name}`, errorObj, {
162
+ migrationId: id,
163
+ errorChain: (0, logger_1.getErrorChainEntries)(errorObj),
164
+ });
165
+ this.publish({
166
+ type: 'migration.failed',
167
+ data: {
168
+ migrationId: id,
169
+ name,
170
+ error: errorMessage,
171
+ duration,
172
+ },
173
+ });
174
+ return {
175
+ success: false,
176
+ migrationId: id,
177
+ duration,
178
+ dryRun,
179
+ error: errorMessage,
180
+ };
181
+ }
182
+ }
183
+ /**
184
+ * Get migration history
185
+ */
186
+ async getMigrationHistory() {
187
+ this.logger.debug('Fetching migration history');
188
+ return this.config.storage.getMigrations(this.config.spaceId, this.config.environmentId);
189
+ }
190
+ /**
191
+ * Get a specific migration by ID
192
+ */
193
+ async getMigration(id) {
194
+ return this.config.storage.getMigration(id);
195
+ }
196
+ /**
197
+ * Check if a migration has been executed
198
+ */
199
+ async hasExecutedMigration(id) {
200
+ return this.config.storage.hasMigration(id, this.config.spaceId, this.config.environmentId);
201
+ }
202
+ /**
203
+ * Validate a migration function without executing
204
+ */
205
+ async validateMigration(migrationFn, options) {
206
+ this.logger.info('Validating migration', { id: options.id });
207
+ try {
208
+ // Run in dry-run mode for validation
209
+ const result = await this.runMigration(migrationFn, {
210
+ ...options,
211
+ dryRun: true,
212
+ });
213
+ if (result.success) {
214
+ return {
215
+ valid: true,
216
+ errors: [],
217
+ warnings: [],
218
+ };
219
+ }
220
+ return {
221
+ valid: false,
222
+ errors: result.error ? [result.error] : ['Unknown validation error'],
223
+ warnings: [],
224
+ };
225
+ }
226
+ catch (error) {
227
+ // runMigration() reports migration failures in its result; a throw here is a storage failure.
228
+ const failure = new errors_1.ContentfulMigrationServiceError('Migration validation failed', {
229
+ code: 'OPERATION_FAILED',
230
+ cause: error instanceof Error ? error : new Error(String(error)),
231
+ context: { migrationId: options.id },
232
+ });
233
+ // The logger drops Error.cause, so pass the chain explicitly.
234
+ this.logger.error(failure.message, failure, {
235
+ migrationId: options.id,
236
+ errorChain: (0, logger_1.getErrorChainEntries)(failure),
237
+ });
238
+ const errorMessage = error instanceof Error ? error.message : String(error);
239
+ return {
240
+ valid: false,
241
+ errors: [errorMessage],
242
+ warnings: [],
243
+ };
244
+ }
245
+ }
246
+ /**
247
+ * Get pending migrations (not yet executed)
248
+ */
249
+ async getPendingMigrations(migrationIds) {
250
+ const pending = [];
251
+ for (const id of migrationIds) {
252
+ const executed = await this.hasExecutedMigration(id);
253
+ if (!executed) {
254
+ pending.push(id);
255
+ }
256
+ }
257
+ return pending;
258
+ }
259
+ /**
260
+ * Get the Contentful CMA client (for advanced operations)
261
+ */
262
+ getCMAClient() {
263
+ return this.cmaClient;
264
+ }
265
+ /**
266
+ * Close connections and cleanup
267
+ */
268
+ async close() {
269
+ this.logger.info('Closing ContentfulMigrationService');
270
+ // No cleanup needed for current implementation
271
+ }
272
+ }
273
+ exports.ContentfulMigrationService = ContentfulMigrationService;
@@ -0,0 +1,11 @@
1
+ export type ContentfulMigrationServiceErrorCode = 'CONTENTFUL_MIGRATION_SERVICE_ERROR' | 'INVALID_INPUT' | 'OPERATION_FAILED';
2
+ export interface ContentfulMigrationServiceErrorOptions {
3
+ cause?: Error;
4
+ code?: ContentfulMigrationServiceErrorCode;
5
+ context?: Record<string, unknown>;
6
+ }
7
+ export declare class ContentfulMigrationServiceError extends Error {
8
+ readonly code: ContentfulMigrationServiceErrorCode;
9
+ readonly context?: Record<string, unknown>;
10
+ constructor(message: string, options?: ContentfulMigrationServiceErrorOptions);
11
+ }
package/dist/errors.js ADDED
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (c) 2025 Bernier LLC
4
+
5
+ This file is licensed to the client under a limited-use license.
6
+ The client may use and modify this code *only within the scope of the project it was delivered for*.
7
+ Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.ContentfulMigrationServiceError = void 0;
11
+ class ContentfulMigrationServiceError extends Error {
12
+ code;
13
+ context;
14
+ constructor(message, options) {
15
+ super(message, options?.cause ? { cause: options.cause } : undefined);
16
+ this.name = 'ContentfulMigrationServiceError';
17
+ this.code = options?.code ?? 'CONTENTFUL_MIGRATION_SERVICE_ERROR';
18
+ if (options?.context !== undefined) {
19
+ this.context = options.context;
20
+ }
21
+ Error.captureStackTrace?.(this, this.constructor);
22
+ }
23
+ }
24
+ exports.ContentfulMigrationServiceError = ContentfulMigrationServiceError;
@@ -0,0 +1,4 @@
1
+ export { ContentfulMigrationService } from './ContentfulMigrationService';
2
+ export { ContentfulMigrationServiceError, type ContentfulMigrationServiceErrorCode, type ContentfulMigrationServiceErrorOptions } from './errors';
3
+ export { InMemoryMigrationStorage } from './storage/InMemoryMigrationStorage';
4
+ export type { MigrationRecord, MigrationStorage, MigrationServiceConfig, MigrationOptions, MigrationResult, MigrationFunction, ValidationResult, } from './types';
package/dist/index.js ADDED
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (c) 2025 Bernier LLC
4
+
5
+ This file is licensed to the client under a limited-use license.
6
+ The client may use and modify this code *only within the scope of the project it was delivered for*.
7
+ Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.InMemoryMigrationStorage = exports.ContentfulMigrationServiceError = exports.ContentfulMigrationService = void 0;
11
+ var ContentfulMigrationService_1 = require("./ContentfulMigrationService");
12
+ Object.defineProperty(exports, "ContentfulMigrationService", { enumerable: true, get: function () { return ContentfulMigrationService_1.ContentfulMigrationService; } });
13
+ var errors_1 = require("./errors");
14
+ Object.defineProperty(exports, "ContentfulMigrationServiceError", { enumerable: true, get: function () { return errors_1.ContentfulMigrationServiceError; } });
15
+ var InMemoryMigrationStorage_1 = require("./storage/InMemoryMigrationStorage");
16
+ Object.defineProperty(exports, "InMemoryMigrationStorage", { enumerable: true, get: function () { return InMemoryMigrationStorage_1.InMemoryMigrationStorage; } });
@@ -0,0 +1,20 @@
1
+ import { MigrationStorage, MigrationRecord } from '../types';
2
+ /**
3
+ * In-memory implementation of MigrationStorage for testing and development
4
+ */
5
+ export declare class InMemoryMigrationStorage implements MigrationStorage {
6
+ private migrations;
7
+ saveMigration(record: MigrationRecord): Promise<void>;
8
+ getMigration(id: string): Promise<MigrationRecord | null>;
9
+ getMigrations(spaceId: string, environmentId: string): Promise<MigrationRecord[]>;
10
+ hasMigration(id: string, spaceId: string, environmentId: string): Promise<boolean>;
11
+ updateMigrationStatus(id: string, status: MigrationRecord['status'], error?: string, duration?: number): Promise<void>;
12
+ /**
13
+ * Clear all migrations (for testing)
14
+ */
15
+ clear(): void;
16
+ /**
17
+ * Get count of migrations (for testing)
18
+ */
19
+ count(): number;
20
+ }
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (c) 2025 Bernier LLC
4
+
5
+ This file is licensed to the client under a limited-use license.
6
+ The client may use and modify this code *only within the scope of the project it was delivered for*.
7
+ Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.InMemoryMigrationStorage = void 0;
11
+ const errors_1 = require("../errors");
12
+ /**
13
+ * In-memory implementation of MigrationStorage for testing and development
14
+ */
15
+ class InMemoryMigrationStorage {
16
+ migrations = new Map();
17
+ async saveMigration(record) {
18
+ this.migrations.set(record.id, { ...record });
19
+ }
20
+ async getMigration(id) {
21
+ return this.migrations.get(id) || null;
22
+ }
23
+ async getMigrations(spaceId, environmentId) {
24
+ return Array.from(this.migrations.values())
25
+ .filter(m => m.spaceId === spaceId && m.environmentId === environmentId)
26
+ .sort((a, b) => b.executedAt.getTime() - a.executedAt.getTime());
27
+ }
28
+ async hasMigration(id, spaceId, environmentId) {
29
+ const migration = this.migrations.get(id);
30
+ return !!(migration &&
31
+ migration.spaceId === spaceId &&
32
+ migration.environmentId === environmentId &&
33
+ migration.status === 'completed');
34
+ }
35
+ async updateMigrationStatus(id, status, error, duration) {
36
+ const migration = this.migrations.get(id);
37
+ if (!migration) {
38
+ throw new errors_1.ContentfulMigrationServiceError(`Migration ${id} not found`, {
39
+ code: 'INVALID_INPUT',
40
+ context: { migrationId: id },
41
+ });
42
+ }
43
+ migration.status = status;
44
+ if (error !== undefined) {
45
+ migration.error = error;
46
+ }
47
+ if (duration !== undefined) {
48
+ migration.duration = duration;
49
+ }
50
+ this.migrations.set(id, migration);
51
+ }
52
+ /**
53
+ * Clear all migrations (for testing)
54
+ */
55
+ clear() {
56
+ this.migrations.clear();
57
+ }
58
+ /**
59
+ * Get count of migrations (for testing)
60
+ */
61
+ count() {
62
+ return this.migrations.size;
63
+ }
64
+ }
65
+ exports.InMemoryMigrationStorage = InMemoryMigrationStorage;
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Migration record stored in persistent storage
3
+ */
4
+ export interface MigrationRecord {
5
+ id: string;
6
+ name: string;
7
+ description?: string;
8
+ executedAt: Date;
9
+ executedBy?: string;
10
+ status: 'pending' | 'running' | 'completed' | 'failed' | 'rolled_back';
11
+ spaceId: string;
12
+ environmentId: string;
13
+ dryRun: boolean;
14
+ duration?: number;
15
+ error?: string;
16
+ checksum?: string;
17
+ }
18
+ /**
19
+ * Abstract storage interface for migration history tracking
20
+ * Allows users to provide their own storage implementation
21
+ */
22
+ export interface MigrationStorage {
23
+ /**
24
+ * Save a migration record
25
+ */
26
+ saveMigration(record: MigrationRecord): Promise<void>;
27
+ /**
28
+ * Get a migration by ID
29
+ */
30
+ getMigration(id: string): Promise<MigrationRecord | null>;
31
+ /**
32
+ * Get all migrations for a space/environment
33
+ */
34
+ getMigrations(spaceId: string, environmentId: string): Promise<MigrationRecord[]>;
35
+ /**
36
+ * Check if a migration has been executed
37
+ */
38
+ hasMigration(id: string, spaceId: string, environmentId: string): Promise<boolean>;
39
+ /**
40
+ * Update migration status
41
+ */
42
+ updateMigrationStatus(id: string, status: MigrationRecord['status'], error?: string, duration?: number): Promise<void>;
43
+ }
44
+ /**
45
+ * Configuration for ContentfulMigrationService
46
+ */
47
+ export interface MigrationServiceConfig {
48
+ /**
49
+ * Contentful space ID
50
+ */
51
+ spaceId: string;
52
+ /**
53
+ * Contentful environment ID (default: 'master')
54
+ */
55
+ environmentId?: string;
56
+ /**
57
+ * Contentful CMA access token
58
+ */
59
+ accessToken: string;
60
+ /**
61
+ * Storage implementation for migration history
62
+ */
63
+ storage: MigrationStorage;
64
+ /**
65
+ * Optional identifier for who is executing migrations
66
+ */
67
+ executedBy?: string;
68
+ }
69
+ /**
70
+ * Options for running a migration
71
+ */
72
+ export interface MigrationOptions {
73
+ /**
74
+ * Migration ID (for tracking)
75
+ */
76
+ id: string;
77
+ /**
78
+ * Human-readable name
79
+ */
80
+ name: string;
81
+ /**
82
+ * Optional description
83
+ */
84
+ description?: string;
85
+ /**
86
+ * Run in dry-run mode (validation only)
87
+ */
88
+ dryRun?: boolean;
89
+ /**
90
+ * Timeout in milliseconds
91
+ */
92
+ timeout?: number;
93
+ }
94
+ /**
95
+ * Result of migration execution
96
+ */
97
+ export interface MigrationResult {
98
+ success: boolean;
99
+ migrationId: string;
100
+ duration: number;
101
+ dryRun: boolean;
102
+ error?: string;
103
+ }
104
+ /**
105
+ * Migration function type
106
+ * The migration parameter is the Contentful migration context object
107
+ * from the contentful-migration library (typed as any due to external library)
108
+ */
109
+ export type MigrationFunction = (migration: any) => void;
110
+ /**
111
+ * Validation result for migration
112
+ */
113
+ export interface ValidationResult {
114
+ valid: boolean;
115
+ errors: string[];
116
+ warnings: string[];
117
+ }
package/dist/types.js ADDED
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (c) 2025 Bernier LLC
4
+
5
+ This file is licensed to the client under a limited-use license.
6
+ The client may use and modify this code *only within the scope of the project it was delivered for*.
7
+ Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bernierllc/contentful-migration-service",
3
- "version": "1.6.3",
3
+ "version": "1.6.5",
4
4
  "description": "Content model migration management with version control, rollback support, and migration history tracking",
5
5
  "keywords": [
6
6
  "contentful",
@@ -21,9 +21,9 @@
21
21
  ],
22
22
  "dependencies": {
23
23
  "contentful-migration": "^4.0.0",
24
- "@bernierllc/contentful-cma-client": "^1.3.2",
24
+ "@bernierllc/contentful-cma-client": "^1.3.3",
25
25
  "@bernierllc/contentful-types": "^1.5.0",
26
- "@bernierllc/logger": "^2.0.0",
26
+ "@bernierllc/logger": "^2.0.1",
27
27
  "@bernierllc/neverhub-adapter": "^0.4.1"
28
28
  },
29
29
  "devDependencies": {