@bernierllc/contentful-suite 1.0.3

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 (76) hide show
  1. package/.eslintrc.cjs +16 -0
  2. package/LICENSE +5 -0
  3. package/README.md +497 -0
  4. package/__mocks__/@bernierllc/contentful-cache-service.ts +12 -0
  5. package/__mocks__/@bernierllc/contentful-gateway-service.ts +21 -0
  6. package/__mocks__/@bernierllc/contentful-migration-service.ts +13 -0
  7. package/__mocks__/@bernierllc/contentful-sync-service.ts +14 -0
  8. package/__mocks__/@bernierllc/contentful-webhook-service.ts +15 -0
  9. package/__mocks__/@bernierllc/logger.ts +27 -0
  10. package/__mocks__/@bernierllc/neverhub-adapter.ts +17 -0
  11. package/coverage/clover.xml +192 -0
  12. package/coverage/coverage-final.json +5 -0
  13. package/coverage/coverage-summary.json +6 -0
  14. package/coverage/lcov-report/base.css +224 -0
  15. package/coverage/lcov-report/block-navigation.js +87 -0
  16. package/coverage/lcov-report/favicon.png +0 -0
  17. package/coverage/lcov-report/index.html +131 -0
  18. package/coverage/lcov-report/prettify.css +1 -0
  19. package/coverage/lcov-report/prettify.js +2 -0
  20. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  21. package/coverage/lcov-report/sorter.js +210 -0
  22. package/coverage/lcov-report/src/ContentfulSuite.ts.html +1330 -0
  23. package/coverage/lcov-report/src/index.html +116 -0
  24. package/coverage/lcov-report/src/storage/InMemoryContentStorage.ts.html +394 -0
  25. package/coverage/lcov-report/src/storage/InMemoryMigrationStorage.ts.html +304 -0
  26. package/coverage/lcov-report/src/storage/InMemorySyncStateStorage.ts.html +211 -0
  27. package/coverage/lcov-report/src/storage/index.html +146 -0
  28. package/coverage/lcov.info +349 -0
  29. package/dist/ContentfulSuite.d.ts +85 -0
  30. package/dist/ContentfulSuite.d.ts.map +1 -0
  31. package/dist/ContentfulSuite.js +352 -0
  32. package/dist/ContentfulSuite.js.map +1 -0
  33. package/dist/__tests__/ContentfulSuite.test.d.ts +2 -0
  34. package/dist/__tests__/ContentfulSuite.test.d.ts.map +1 -0
  35. package/dist/__tests__/ContentfulSuite.test.js +347 -0
  36. package/dist/__tests__/ContentfulSuite.test.js.map +1 -0
  37. package/dist/__tests__/storage.test.d.ts +2 -0
  38. package/dist/__tests__/storage.test.d.ts.map +1 -0
  39. package/dist/__tests__/storage.test.js +343 -0
  40. package/dist/__tests__/storage.test.js.map +1 -0
  41. package/dist/index.d.ts +20 -0
  42. package/dist/index.d.ts.map +1 -0
  43. package/dist/index.js +45 -0
  44. package/dist/index.js.map +1 -0
  45. package/dist/storage/InMemoryContentStorage.d.ts +41 -0
  46. package/dist/storage/InMemoryContentStorage.d.ts.map +1 -0
  47. package/dist/storage/InMemoryContentStorage.js +88 -0
  48. package/dist/storage/InMemoryContentStorage.js.map +1 -0
  49. package/dist/storage/InMemoryMigrationStorage.d.ts +21 -0
  50. package/dist/storage/InMemoryMigrationStorage.d.ts.map +1 -0
  51. package/dist/storage/InMemoryMigrationStorage.js +61 -0
  52. package/dist/storage/InMemoryMigrationStorage.js.map +1 -0
  53. package/dist/storage/InMemorySyncStateStorage.d.ts +19 -0
  54. package/dist/storage/InMemorySyncStateStorage.d.ts.map +1 -0
  55. package/dist/storage/InMemorySyncStateStorage.js +41 -0
  56. package/dist/storage/InMemorySyncStateStorage.js.map +1 -0
  57. package/dist/storage/index.d.ts +4 -0
  58. package/dist/storage/index.d.ts.map +1 -0
  59. package/dist/storage/index.js +17 -0
  60. package/dist/storage/index.js.map +1 -0
  61. package/dist/types.d.ts +131 -0
  62. package/dist/types.d.ts.map +1 -0
  63. package/dist/types.js +10 -0
  64. package/dist/types.js.map +1 -0
  65. package/jest.config.cjs +45 -0
  66. package/package.json +67 -0
  67. package/src/ContentfulSuite.ts +415 -0
  68. package/src/__tests__/ContentfulSuite.test.ts +424 -0
  69. package/src/__tests__/storage.test.ts +405 -0
  70. package/src/index.ts +60 -0
  71. package/src/storage/InMemoryContentStorage.ts +103 -0
  72. package/src/storage/InMemoryMigrationStorage.ts +73 -0
  73. package/src/storage/InMemorySyncStateStorage.ts +42 -0
  74. package/src/storage/index.ts +11 -0
  75. package/src/types.ts +158 -0
  76. package/tsconfig.json +21 -0
@@ -0,0 +1,405 @@
1
+ /*
2
+ Copyright (c) 2025 Bernier LLC
3
+
4
+ This file is licensed to the client under a limited-use license.
5
+ The client may use and modify this code *only within the scope of the project it was delivered for*.
6
+ Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
7
+ */
8
+
9
+ import { InMemoryContentStorage } from '../storage/InMemoryContentStorage';
10
+ import { InMemorySyncStateStorage } from '../storage/InMemorySyncStateStorage';
11
+ import { InMemoryMigrationStorage } from '../storage/InMemoryMigrationStorage';
12
+ import type { ContentfulEntry, ContentfulAsset, ContentfulContentType } from '@bernierllc/contentful-types';
13
+ import type { MigrationRecord } from '@bernierllc/contentful-migration-service';
14
+
15
+ describe('InMemoryContentStorage', () => {
16
+ let storage: InMemoryContentStorage;
17
+
18
+ beforeEach(() => {
19
+ storage = new InMemoryContentStorage();
20
+ });
21
+
22
+ const mockEntry: ContentfulEntry = {
23
+ sys: {
24
+ id: 'entry-1',
25
+ type: 'Entry',
26
+ contentType: { sys: { id: 'article', type: 'Link', linkType: 'ContentType' } },
27
+ createdAt: '2025-01-01T00:00:00Z',
28
+ updatedAt: '2025-01-01T00:00:00Z',
29
+ version: 1,
30
+ space: { sys: { id: 'test-space', type: 'Link', linkType: 'Space' } },
31
+ environment: { sys: { id: 'master', type: 'Link', linkType: 'Environment' } }
32
+ },
33
+ fields: { title: { 'en-US': 'Test Entry' } }
34
+ };
35
+
36
+ const mockAsset: ContentfulAsset = {
37
+ sys: {
38
+ id: 'asset-1',
39
+ type: 'Asset',
40
+ createdAt: '2025-01-01T00:00:00Z',
41
+ updatedAt: '2025-01-01T00:00:00Z',
42
+ version: 1,
43
+ space: { sys: { id: 'test-space', type: 'Link', linkType: 'Space' } },
44
+ environment: { sys: { id: 'master', type: 'Link', linkType: 'Environment' } }
45
+ },
46
+ fields: {
47
+ title: { 'en-US': 'Test Asset' },
48
+ file: {
49
+ 'en-US': {
50
+ url: '//images.ctfassets.net/test.jpg',
51
+ fileName: 'test.jpg',
52
+ contentType: 'image/jpeg',
53
+ details: {
54
+ size: 1024,
55
+ image: {
56
+ width: 100,
57
+ height: 100
58
+ }
59
+ }
60
+ }
61
+ }
62
+ }
63
+ };
64
+
65
+ const mockContentType: ContentfulContentType = {
66
+ sys: {
67
+ id: 'article',
68
+ type: 'ContentType',
69
+ createdAt: '2025-01-01T00:00:00Z',
70
+ updatedAt: '2025-01-01T00:00:00Z',
71
+ version: 1,
72
+ space: { sys: { id: 'test-space', type: 'Link', linkType: 'Space' } },
73
+ environment: { sys: { id: 'master', type: 'Link', linkType: 'Environment' } }
74
+ },
75
+ name: 'Article',
76
+ description: 'Article content type',
77
+ displayField: 'title',
78
+ fields: [
79
+ {
80
+ id: 'title',
81
+ name: 'Title',
82
+ type: 'Symbol',
83
+ required: true,
84
+ localized: false,
85
+ disabled: false,
86
+ omitted: false
87
+ }
88
+ ]
89
+ };
90
+
91
+ describe('storeContentTypes', () => {
92
+ it('should store content types', async () => {
93
+ await storage.storeContentTypes([mockContentType]);
94
+ const types = storage.getAllContentTypes();
95
+ expect(types).toHaveLength(1);
96
+ expect(types[0]).toEqual(mockContentType);
97
+ });
98
+ });
99
+
100
+ describe('storeEntries', () => {
101
+ it('should store entries', async () => {
102
+ await storage.storeEntries([mockEntry]);
103
+ const entries = storage.getAllEntries();
104
+ expect(entries).toHaveLength(1);
105
+ expect(entries[0]).toEqual(mockEntry);
106
+ });
107
+ });
108
+
109
+ describe('storeAssets', () => {
110
+ it('should store assets', async () => {
111
+ await storage.storeAssets([mockAsset]);
112
+ const assets = storage.getAllAssets();
113
+ expect(assets).toHaveLength(1);
114
+ expect(assets[0]).toEqual(mockAsset);
115
+ });
116
+ });
117
+
118
+ describe('updateEntry', () => {
119
+ it('should update existing entry', async () => {
120
+ await storage.storeEntries([mockEntry]);
121
+
122
+ const updatedEntry = {
123
+ ...mockEntry,
124
+ fields: { title: { 'en-US': 'Updated Title' } }
125
+ };
126
+
127
+ await storage.updateEntry(updatedEntry);
128
+
129
+ const entry = await storage.getEntry('entry-1');
130
+ expect((entry?.fields.title as { 'en-US': string })['en-US']).toBe('Updated Title');
131
+ });
132
+ });
133
+
134
+ describe('updateAsset', () => {
135
+ it('should update existing asset', async () => {
136
+ await storage.storeAssets([mockAsset]);
137
+
138
+ const updatedAsset = {
139
+ ...mockAsset,
140
+ fields: {
141
+ ...mockAsset.fields,
142
+ title: { 'en-US': 'Updated Asset' }
143
+ }
144
+ };
145
+
146
+ await storage.updateAsset(updatedAsset);
147
+
148
+ const asset = await storage.getAsset('asset-1');
149
+ expect(asset?.fields.title['en-US']).toBe('Updated Asset');
150
+ });
151
+ });
152
+
153
+ describe('deleteEntry', () => {
154
+ it('should delete entry', async () => {
155
+ await storage.storeEntries([mockEntry]);
156
+ await storage.deleteEntry('entry-1');
157
+
158
+ const entry = await storage.getEntry('entry-1');
159
+ expect(entry).toBeNull();
160
+ });
161
+ });
162
+
163
+ describe('deleteAsset', () => {
164
+ it('should delete asset', async () => {
165
+ await storage.storeAssets([mockAsset]);
166
+ await storage.deleteAsset('asset-1');
167
+
168
+ const asset = await storage.getAsset('asset-1');
169
+ expect(asset).toBeNull();
170
+ });
171
+ });
172
+
173
+ describe('getEntry', () => {
174
+ it('should return entry by id', async () => {
175
+ await storage.storeEntries([mockEntry]);
176
+ const entry = await storage.getEntry('entry-1');
177
+ expect(entry).toEqual(mockEntry);
178
+ });
179
+
180
+ it('should return null for non-existent entry', async () => {
181
+ const entry = await storage.getEntry('non-existent');
182
+ expect(entry).toBeNull();
183
+ });
184
+ });
185
+
186
+ describe('getAsset', () => {
187
+ it('should return asset by id', async () => {
188
+ await storage.storeAssets([mockAsset]);
189
+ const asset = await storage.getAsset('asset-1');
190
+ expect(asset).toEqual(mockAsset);
191
+ });
192
+
193
+ it('should return null for non-existent asset', async () => {
194
+ const asset = await storage.getAsset('non-existent');
195
+ expect(asset).toBeNull();
196
+ });
197
+ });
198
+
199
+ describe('clearSpace', () => {
200
+ it('should clear all content', async () => {
201
+ await storage.storeContentTypes([mockContentType]);
202
+ await storage.storeEntries([mockEntry]);
203
+ await storage.storeAssets([mockAsset]);
204
+
205
+ await storage.clearSpace('test-space');
206
+
207
+ expect(storage.getAllContentTypes()).toHaveLength(0);
208
+ expect(storage.getAllEntries()).toHaveLength(0);
209
+ expect(storage.getAllAssets()).toHaveLength(0);
210
+ });
211
+ });
212
+
213
+ describe('getStats', () => {
214
+ it('should return storage stats', async () => {
215
+ await storage.storeContentTypes([mockContentType]);
216
+ await storage.storeEntries([mockEntry]);
217
+ await storage.storeAssets([mockAsset]);
218
+
219
+ const stats = storage.getStats();
220
+ expect(stats).toEqual({
221
+ contentTypes: 1,
222
+ entries: 1,
223
+ assets: 1
224
+ });
225
+ });
226
+ });
227
+ });
228
+
229
+ describe('InMemorySyncStateStorage', () => {
230
+ let storage: InMemorySyncStateStorage;
231
+
232
+ beforeEach(() => {
233
+ storage = new InMemorySyncStateStorage();
234
+ });
235
+
236
+ describe('setSyncToken', () => {
237
+ it('should store sync token', async () => {
238
+ await storage.setSyncToken('space-1', 'token-123');
239
+ const token = await storage.getSyncToken('space-1');
240
+ expect(token).toBe('token-123');
241
+ });
242
+ });
243
+
244
+ describe('getSyncToken', () => {
245
+ it('should return null for non-existent token', async () => {
246
+ const token = await storage.getSyncToken('non-existent');
247
+ expect(token).toBeNull();
248
+ });
249
+ });
250
+
251
+ describe('clearSyncToken', () => {
252
+ it('should clear sync token', async () => {
253
+ await storage.setSyncToken('space-1', 'token-123');
254
+ await storage.clearSyncToken('space-1');
255
+
256
+ const token = await storage.getSyncToken('space-1');
257
+ expect(token).toBeNull();
258
+ });
259
+ });
260
+
261
+ describe('getAllTokens', () => {
262
+ it('should return all tokens', async () => {
263
+ await storage.setSyncToken('space-1', 'token-1');
264
+ await storage.setSyncToken('space-2', 'token-2');
265
+
266
+ const tokens = storage.getAllTokens();
267
+ expect(tokens).toEqual({
268
+ 'space-1': 'token-1',
269
+ 'space-2': 'token-2'
270
+ });
271
+ });
272
+ });
273
+
274
+ describe('clearAll', () => {
275
+ it('should clear all tokens', async () => {
276
+ await storage.setSyncToken('space-1', 'token-1');
277
+ await storage.setSyncToken('space-2', 'token-2');
278
+
279
+ storage.clearAll();
280
+
281
+ const tokens = storage.getAllTokens();
282
+ expect(tokens).toEqual({});
283
+ });
284
+ });
285
+ });
286
+
287
+ describe('InMemoryMigrationStorage', () => {
288
+ let storage: InMemoryMigrationStorage;
289
+
290
+ beforeEach(() => {
291
+ storage = new InMemoryMigrationStorage();
292
+ });
293
+
294
+ const mockMigration: MigrationRecord = {
295
+ id: 'migration-1',
296
+ name: 'Test Migration',
297
+ description: 'Test description',
298
+ executedAt: new Date('2025-01-01T00:00:00Z'),
299
+ executedBy: 'test-user',
300
+ status: 'completed',
301
+ spaceId: 'space-1',
302
+ environmentId: 'master',
303
+ dryRun: false,
304
+ duration: 1000
305
+ };
306
+
307
+ describe('saveMigration', () => {
308
+ it('should save migration record', async () => {
309
+ await storage.saveMigration(mockMigration);
310
+ const migration = await storage.getMigration('migration-1');
311
+ expect(migration).toEqual(mockMigration);
312
+ });
313
+ });
314
+
315
+ describe('getMigration', () => {
316
+ it('should return null for non-existent migration', async () => {
317
+ const migration = await storage.getMigration('non-existent');
318
+ expect(migration).toBeNull();
319
+ });
320
+ });
321
+
322
+ describe('getMigrations', () => {
323
+ it('should return migrations for space and environment', async () => {
324
+ await storage.saveMigration(mockMigration);
325
+ await storage.saveMigration({
326
+ ...mockMigration,
327
+ id: 'migration-2',
328
+ spaceId: 'space-2'
329
+ });
330
+
331
+ const migrations = await storage.getMigrations('space-1', 'master');
332
+ expect(migrations).toHaveLength(1);
333
+ expect(migrations[0].id).toBe('migration-1');
334
+ });
335
+ });
336
+
337
+ describe('hasMigration', () => {
338
+ it('should return true for completed migration', async () => {
339
+ await storage.saveMigration(mockMigration);
340
+
341
+ const has = await storage.hasMigration('migration-1', 'space-1', 'master');
342
+ expect(has).toBe(true);
343
+ });
344
+
345
+ it('should return false for non-completed migration', async () => {
346
+ await storage.saveMigration({
347
+ ...mockMigration,
348
+ status: 'failed'
349
+ });
350
+
351
+ const has = await storage.hasMigration('migration-1', 'space-1', 'master');
352
+ expect(has).toBe(false);
353
+ });
354
+
355
+ it('should return false for non-existent migration', async () => {
356
+ const has = await storage.hasMigration('non-existent', 'space-1', 'master');
357
+ expect(has).toBe(false);
358
+ });
359
+ });
360
+
361
+ describe('updateMigrationStatus', () => {
362
+ it('should update migration status', async () => {
363
+ await storage.saveMigration({
364
+ ...mockMigration,
365
+ status: 'running'
366
+ });
367
+
368
+ await storage.updateMigrationStatus('migration-1', 'completed', undefined, 2000);
369
+
370
+ const migration = await storage.getMigration('migration-1');
371
+ expect(migration?.status).toBe('completed');
372
+ expect(migration?.duration).toBe(2000);
373
+ });
374
+
375
+ it('should update error message', async () => {
376
+ await storage.saveMigration(mockMigration);
377
+
378
+ await storage.updateMigrationStatus('migration-1', 'failed', 'Test error');
379
+
380
+ const migration = await storage.getMigration('migration-1');
381
+ expect(migration?.status).toBe('failed');
382
+ expect(migration?.error).toBe('Test error');
383
+ });
384
+ });
385
+
386
+ describe('getAllMigrations', () => {
387
+ it('should return all migrations', async () => {
388
+ await storage.saveMigration(mockMigration);
389
+ await storage.saveMigration({ ...mockMigration, id: 'migration-2' });
390
+
391
+ const migrations = storage.getAllMigrations();
392
+ expect(migrations).toHaveLength(2);
393
+ });
394
+ });
395
+
396
+ describe('clearAll', () => {
397
+ it('should clear all migrations', async () => {
398
+ await storage.saveMigration(mockMigration);
399
+ storage.clearAll();
400
+
401
+ const migrations = storage.getAllMigrations();
402
+ expect(migrations).toHaveLength(0);
403
+ });
404
+ });
405
+ });
package/src/index.ts ADDED
@@ -0,0 +1,60 @@
1
+ /*
2
+ Copyright (c) 2025 Bernier LLC
3
+
4
+ This file is licensed to the client under a limited-use license.
5
+ The client may use and modify this code *only within the scope of the project it was delivered for*.
6
+ Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
7
+ */
8
+
9
+ // Main suite orchestrator
10
+ export { ContentfulSuite } from './ContentfulSuite';
11
+
12
+ // Suite types
13
+ export type {
14
+ ContentfulSuiteConfig,
15
+ OAuthConfig,
16
+ SpaceConfig,
17
+ GatewayConfig,
18
+ SyncConfig,
19
+ WebhooksConfig,
20
+ CacheConfig,
21
+ MigrationConfig,
22
+ StorageConfig,
23
+ ServiceStatus,
24
+ SuiteHealth
25
+ } from './types';
26
+
27
+ // Storage implementations
28
+ export {
29
+ InMemoryContentStorage,
30
+ InMemorySyncStateStorage,
31
+ InMemoryMigrationStorage
32
+ } from './storage';
33
+
34
+ // Re-export Contentful packages (selective to avoid conflicts)
35
+ export type {
36
+ ContentfulEntry,
37
+ ContentfulAsset,
38
+ ContentfulContentType,
39
+ ContentfulSpace,
40
+ ContentfulEnvironment,
41
+ ContentfulLocale
42
+ } from '@bernierllc/contentful-types';
43
+
44
+ export { ContentfulClientCore } from '@bernierllc/contentful-client-core';
45
+ export { ContentfulAuth } from '@bernierllc/contentful-auth';
46
+ export { ContentfulCMAClient } from '@bernierllc/contentful-cma-client';
47
+ export { ContentfulCDAClient } from '@bernierllc/contentful-cda-client';
48
+ export { ContentfulGraphQLClient } from '@bernierllc/contentful-graphql-client';
49
+ export { ContentfulWebhookHandler } from '@bernierllc/contentful-webhook-handler';
50
+ export { ContentfulExportAdapter } from '@bernierllc/contentful-export-adapter';
51
+ export { ContentfulRichTextRenderer } from '@bernierllc/contentful-rich-text';
52
+ export { ContentfulGatewayService } from '@bernierllc/contentful-gateway-service';
53
+ export { ContentfulSyncService } from '@bernierllc/contentful-sync-service';
54
+ export { ContentfulWebhookService } from '@bernierllc/contentful-webhook-service';
55
+ export { ContentfulCacheService } from '@bernierllc/contentful-cache-service';
56
+ export { ContentfulMigrationService } from '@bernierllc/contentful-migration-service';
57
+
58
+ // Re-export storage interfaces
59
+ export type { ContentStorage, SyncStateStorage } from '@bernierllc/contentful-sync-service';
60
+ export type { MigrationStorage } from '@bernierllc/contentful-migration-service';
@@ -0,0 +1,103 @@
1
+ /*
2
+ Copyright (c) 2025 Bernier LLC
3
+
4
+ This file is licensed to the client under a limited-use license.
5
+ The client may use and modify this code *only within the scope of the project it was delivered for*.
6
+ Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
7
+ */
8
+
9
+ import type {
10
+ ContentfulEntry,
11
+ ContentfulAsset,
12
+ ContentfulContentType
13
+ } from '@bernierllc/contentful-types';
14
+ import type { ContentStorage } from '@bernierllc/contentful-sync-service';
15
+
16
+ /**
17
+ * In-memory implementation of ContentStorage for testing and simple use cases
18
+ */
19
+ export class InMemoryContentStorage implements ContentStorage {
20
+ private contentTypes: Map<string, ContentfulContentType> = new Map();
21
+ private entries: Map<string, ContentfulEntry> = new Map();
22
+ private assets: Map<string, ContentfulAsset> = new Map();
23
+
24
+ async storeContentTypes(contentTypes: ContentfulContentType[]): Promise<void> {
25
+ for (const ct of contentTypes) {
26
+ this.contentTypes.set(ct.sys.id, ct);
27
+ }
28
+ }
29
+
30
+ async storeEntries(entries: ContentfulEntry[]): Promise<void> {
31
+ for (const entry of entries) {
32
+ this.entries.set(entry.sys.id, entry);
33
+ }
34
+ }
35
+
36
+ async storeAssets(assets: ContentfulAsset[]): Promise<void> {
37
+ for (const asset of assets) {
38
+ this.assets.set(asset.sys.id, asset);
39
+ }
40
+ }
41
+
42
+ async updateEntry(entry: ContentfulEntry): Promise<void> {
43
+ this.entries.set(entry.sys.id, entry);
44
+ }
45
+
46
+ async updateAsset(asset: ContentfulAsset): Promise<void> {
47
+ this.assets.set(asset.sys.id, asset);
48
+ }
49
+
50
+ async deleteEntry(entryId: string): Promise<void> {
51
+ this.entries.delete(entryId);
52
+ }
53
+
54
+ async deleteAsset(assetId: string): Promise<void> {
55
+ this.assets.delete(assetId);
56
+ }
57
+
58
+ async getEntry(entryId: string): Promise<ContentfulEntry | null> {
59
+ return this.entries.get(entryId) || null;
60
+ }
61
+
62
+ async getAsset(assetId: string): Promise<ContentfulAsset | null> {
63
+ return this.assets.get(assetId) || null;
64
+ }
65
+
66
+ async clearSpace(_spaceId: string): Promise<void> {
67
+ this.contentTypes.clear();
68
+ this.entries.clear();
69
+ this.assets.clear();
70
+ }
71
+
72
+ /**
73
+ * Get all entries (for ML training use case)
74
+ */
75
+ getAllEntries(): ContentfulEntry[] {
76
+ return Array.from(this.entries.values());
77
+ }
78
+
79
+ /**
80
+ * Get all assets
81
+ */
82
+ getAllAssets(): ContentfulAsset[] {
83
+ return Array.from(this.assets.values());
84
+ }
85
+
86
+ /**
87
+ * Get all content types
88
+ */
89
+ getAllContentTypes(): ContentfulContentType[] {
90
+ return Array.from(this.contentTypes.values());
91
+ }
92
+
93
+ /**
94
+ * Get stats for monitoring
95
+ */
96
+ getStats() {
97
+ return {
98
+ contentTypes: this.contentTypes.size,
99
+ entries: this.entries.size,
100
+ assets: this.assets.size
101
+ };
102
+ }
103
+ }
@@ -0,0 +1,73 @@
1
+ /*
2
+ Copyright (c) 2025 Bernier LLC
3
+
4
+ This file is licensed to the client under a limited-use license.
5
+ The client may use and modify this code *only within the scope of the project it was delivered for*.
6
+ Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
7
+ */
8
+
9
+ import type { MigrationStorage, MigrationRecord } from '@bernierllc/contentful-migration-service';
10
+
11
+ /**
12
+ * In-memory implementation of MigrationStorage for testing and simple use cases
13
+ */
14
+ export class InMemoryMigrationStorage implements MigrationStorage {
15
+ private migrations: Map<string, MigrationRecord> = new Map();
16
+
17
+ async saveMigration(record: MigrationRecord): Promise<void> {
18
+ this.migrations.set(record.id, record);
19
+ }
20
+
21
+ async getMigration(id: string): Promise<MigrationRecord | null> {
22
+ return this.migrations.get(id) || null;
23
+ }
24
+
25
+ async getMigrations(spaceId: string, environmentId: string): Promise<MigrationRecord[]> {
26
+ return Array.from(this.migrations.values()).filter(
27
+ (m) => m.spaceId === spaceId && m.environmentId === environmentId
28
+ );
29
+ }
30
+
31
+ async hasMigration(id: string, spaceId: string, environmentId: string): Promise<boolean> {
32
+ const migration = this.migrations.get(id);
33
+ return (
34
+ migration !== undefined &&
35
+ migration.spaceId === spaceId &&
36
+ migration.environmentId === environmentId &&
37
+ migration.status === 'completed'
38
+ );
39
+ }
40
+
41
+ async updateMigrationStatus(
42
+ id: string,
43
+ status: MigrationRecord['status'],
44
+ error?: string,
45
+ duration?: number
46
+ ): Promise<void> {
47
+ const migration = this.migrations.get(id);
48
+ if (migration) {
49
+ migration.status = status;
50
+ if (error !== undefined) {
51
+ migration.error = error;
52
+ }
53
+ if (duration !== undefined) {
54
+ migration.duration = duration;
55
+ }
56
+ this.migrations.set(id, migration);
57
+ }
58
+ }
59
+
60
+ /**
61
+ * Get all migrations (for debugging)
62
+ */
63
+ getAllMigrations(): MigrationRecord[] {
64
+ return Array.from(this.migrations.values());
65
+ }
66
+
67
+ /**
68
+ * Clear all migrations
69
+ */
70
+ clearAll(): void {
71
+ this.migrations.clear();
72
+ }
73
+ }
@@ -0,0 +1,42 @@
1
+ /*
2
+ Copyright (c) 2025 Bernier LLC
3
+
4
+ This file is licensed to the client under a limited-use license.
5
+ The client may use and modify this code *only within the scope of the project it was delivered for*.
6
+ Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
7
+ */
8
+
9
+ import type { SyncStateStorage } from '@bernierllc/contentful-sync-service';
10
+
11
+ /**
12
+ * In-memory implementation of SyncStateStorage for testing and simple use cases
13
+ */
14
+ export class InMemorySyncStateStorage implements SyncStateStorage {
15
+ private tokens: Map<string, string> = new Map();
16
+
17
+ async getSyncToken(spaceId: string): Promise<string | null> {
18
+ return this.tokens.get(spaceId) || null;
19
+ }
20
+
21
+ async setSyncToken(spaceId: string, token: string): Promise<void> {
22
+ this.tokens.set(spaceId, token);
23
+ }
24
+
25
+ async clearSyncToken(spaceId: string): Promise<void> {
26
+ this.tokens.delete(spaceId);
27
+ }
28
+
29
+ /**
30
+ * Get all tokens (for debugging)
31
+ */
32
+ getAllTokens(): Record<string, string> {
33
+ return Object.fromEntries(this.tokens);
34
+ }
35
+
36
+ /**
37
+ * Clear all tokens
38
+ */
39
+ clearAll(): void {
40
+ this.tokens.clear();
41
+ }
42
+ }
@@ -0,0 +1,11 @@
1
+ /*
2
+ Copyright (c) 2025 Bernier LLC
3
+
4
+ This file is licensed to the client under a limited-use license.
5
+ The client may use and modify this code *only within the scope of the project it was delivered for*.
6
+ Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
7
+ */
8
+
9
+ export { InMemoryContentStorage } from './InMemoryContentStorage';
10
+ export { InMemorySyncStateStorage } from './InMemorySyncStateStorage';
11
+ export { InMemoryMigrationStorage } from './InMemoryMigrationStorage';