@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.
- package/.eslintrc.cjs +16 -0
- package/LICENSE +5 -0
- package/README.md +497 -0
- package/__mocks__/@bernierllc/contentful-cache-service.ts +12 -0
- package/__mocks__/@bernierllc/contentful-gateway-service.ts +21 -0
- package/__mocks__/@bernierllc/contentful-migration-service.ts +13 -0
- package/__mocks__/@bernierllc/contentful-sync-service.ts +14 -0
- package/__mocks__/@bernierllc/contentful-webhook-service.ts +15 -0
- package/__mocks__/@bernierllc/logger.ts +27 -0
- package/__mocks__/@bernierllc/neverhub-adapter.ts +17 -0
- package/coverage/clover.xml +192 -0
- package/coverage/coverage-final.json +5 -0
- package/coverage/coverage-summary.json +6 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +131 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +210 -0
- package/coverage/lcov-report/src/ContentfulSuite.ts.html +1330 -0
- package/coverage/lcov-report/src/index.html +116 -0
- package/coverage/lcov-report/src/storage/InMemoryContentStorage.ts.html +394 -0
- package/coverage/lcov-report/src/storage/InMemoryMigrationStorage.ts.html +304 -0
- package/coverage/lcov-report/src/storage/InMemorySyncStateStorage.ts.html +211 -0
- package/coverage/lcov-report/src/storage/index.html +146 -0
- package/coverage/lcov.info +349 -0
- package/dist/ContentfulSuite.d.ts +85 -0
- package/dist/ContentfulSuite.d.ts.map +1 -0
- package/dist/ContentfulSuite.js +352 -0
- package/dist/ContentfulSuite.js.map +1 -0
- package/dist/__tests__/ContentfulSuite.test.d.ts +2 -0
- package/dist/__tests__/ContentfulSuite.test.d.ts.map +1 -0
- package/dist/__tests__/ContentfulSuite.test.js +347 -0
- package/dist/__tests__/ContentfulSuite.test.js.map +1 -0
- package/dist/__tests__/storage.test.d.ts +2 -0
- package/dist/__tests__/storage.test.d.ts.map +1 -0
- package/dist/__tests__/storage.test.js +343 -0
- package/dist/__tests__/storage.test.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +45 -0
- package/dist/index.js.map +1 -0
- package/dist/storage/InMemoryContentStorage.d.ts +41 -0
- package/dist/storage/InMemoryContentStorage.d.ts.map +1 -0
- package/dist/storage/InMemoryContentStorage.js +88 -0
- package/dist/storage/InMemoryContentStorage.js.map +1 -0
- package/dist/storage/InMemoryMigrationStorage.d.ts +21 -0
- package/dist/storage/InMemoryMigrationStorage.d.ts.map +1 -0
- package/dist/storage/InMemoryMigrationStorage.js +61 -0
- package/dist/storage/InMemoryMigrationStorage.js.map +1 -0
- package/dist/storage/InMemorySyncStateStorage.d.ts +19 -0
- package/dist/storage/InMemorySyncStateStorage.d.ts.map +1 -0
- package/dist/storage/InMemorySyncStateStorage.js +41 -0
- package/dist/storage/InMemorySyncStateStorage.js.map +1 -0
- package/dist/storage/index.d.ts +4 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +17 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/types.d.ts +131 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +10 -0
- package/dist/types.js.map +1 -0
- package/jest.config.cjs +45 -0
- package/package.json +67 -0
- package/src/ContentfulSuite.ts +415 -0
- package/src/__tests__/ContentfulSuite.test.ts +424 -0
- package/src/__tests__/storage.test.ts +405 -0
- package/src/index.ts +60 -0
- package/src/storage/InMemoryContentStorage.ts +103 -0
- package/src/storage/InMemoryMigrationStorage.ts +73 -0
- package/src/storage/InMemorySyncStateStorage.ts +42 -0
- package/src/storage/index.ts +11 -0
- package/src/types.ts +158 -0
- package/tsconfig.json +21 -0
package/.eslintrc.cjs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
module.exports = {
|
|
10
|
+
extends: ['../../../.eslintrc.json'],
|
|
11
|
+
parserOptions: {
|
|
12
|
+
project: './tsconfig.json',
|
|
13
|
+
tsconfigRootDir: __dirname
|
|
14
|
+
},
|
|
15
|
+
ignorePatterns: ['**/__tests__/**', '**/*.test.ts', '**/*.spec.ts']
|
|
16
|
+
};
|
package/LICENSE
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
Copyright (c) 2025 Bernier LLC
|
|
2
|
+
|
|
3
|
+
This file is licensed to the client under a limited-use license.
|
|
4
|
+
The client may use and modify this code *only within the scope of the project it was delivered for*.
|
|
5
|
+
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
package/README.md
ADDED
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
# @bernierllc/contentful-suite
|
|
2
|
+
|
|
3
|
+
Complete Contentful integration suite with ML training pipeline, headless CMS proxy, and content syndication.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **ML Training Pipeline**: Full content export + incremental sync to local database
|
|
8
|
+
- **Headless CMS Proxy**: API gateway with OAuth management and response caching
|
|
9
|
+
- **Content Syndication**: Real-time webhook processing and event routing
|
|
10
|
+
- **Multi-Space Management**: Centralized credential management for multiple spaces
|
|
11
|
+
- **Migration Support**: Content model migrations with history tracking
|
|
12
|
+
- **NeverHub Integration**: Service mesh integration for distributed systems
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @bernierllc/contentful-suite
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
### Quick Start
|
|
23
|
+
|
|
24
|
+
#### Basic Setup
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import {
|
|
28
|
+
ContentfulSuite,
|
|
29
|
+
InMemoryContentStorage,
|
|
30
|
+
InMemorySyncStateStorage,
|
|
31
|
+
InMemoryMigrationStorage
|
|
32
|
+
} from '@bernierllc/contentful-suite';
|
|
33
|
+
|
|
34
|
+
const suite = new ContentfulSuite({
|
|
35
|
+
oauth: {
|
|
36
|
+
clientId: process.env.CONTENTFUL_CLIENT_ID!,
|
|
37
|
+
clientSecret: process.env.CONTENTFUL_CLIENT_SECRET!,
|
|
38
|
+
redirectUri: 'http://localhost:3000/oauth/callback'
|
|
39
|
+
},
|
|
40
|
+
gateway: {
|
|
41
|
+
enabled: true,
|
|
42
|
+
port: 3000,
|
|
43
|
+
apiKeys: ['your-internal-api-key']
|
|
44
|
+
},
|
|
45
|
+
sync: {
|
|
46
|
+
enabled: true,
|
|
47
|
+
interval: 300000, // 5 minutes
|
|
48
|
+
spaces: [
|
|
49
|
+
{
|
|
50
|
+
spaceId: 'your-space-id',
|
|
51
|
+
environmentId: 'master',
|
|
52
|
+
accessToken: 'your-cda-token'
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
webhooks: {
|
|
57
|
+
enabled: true,
|
|
58
|
+
port: 3001,
|
|
59
|
+
secret: 'your-webhook-secret'
|
|
60
|
+
},
|
|
61
|
+
cache: {
|
|
62
|
+
enabled: true,
|
|
63
|
+
backend: 'memory',
|
|
64
|
+
ttl: 300
|
|
65
|
+
},
|
|
66
|
+
migration: {
|
|
67
|
+
enabled: true
|
|
68
|
+
},
|
|
69
|
+
storage: {
|
|
70
|
+
contentStorage: new InMemoryContentStorage(),
|
|
71
|
+
syncStateStorage: new InMemorySyncStateStorage(),
|
|
72
|
+
migrationStorage: new InMemoryMigrationStorage()
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
await suite.initialize();
|
|
77
|
+
await suite.start();
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Use Cases
|
|
81
|
+
|
|
82
|
+
### 1. ML Training Pipeline
|
|
83
|
+
|
|
84
|
+
Export all content from Contentful to a local database for machine learning model training:
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
import { ContentfulSuite } from '@bernierllc/contentful-suite';
|
|
88
|
+
|
|
89
|
+
// Initialize suite with sync enabled
|
|
90
|
+
const suite = new ContentfulSuite({
|
|
91
|
+
sync: {
|
|
92
|
+
enabled: true,
|
|
93
|
+
spaces: [
|
|
94
|
+
{
|
|
95
|
+
spaceId: 'your-space-id',
|
|
96
|
+
environmentId: 'master',
|
|
97
|
+
accessToken: 'your-cda-token'
|
|
98
|
+
}
|
|
99
|
+
]
|
|
100
|
+
},
|
|
101
|
+
storage: {
|
|
102
|
+
contentStorage: new InMemoryContentStorage(),
|
|
103
|
+
syncStateStorage: new InMemorySyncStateStorage()
|
|
104
|
+
},
|
|
105
|
+
// ... other config
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
await suite.initialize();
|
|
109
|
+
|
|
110
|
+
// Get all content for training
|
|
111
|
+
const trainingData = await suite.getMLTrainingData('your-space-id');
|
|
112
|
+
|
|
113
|
+
// Filter by content type
|
|
114
|
+
const articles = await suite.getMLTrainingData('your-space-id', 'article');
|
|
115
|
+
|
|
116
|
+
// Train your ML model with the data
|
|
117
|
+
trainModel(trainingData);
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**Benefits:**
|
|
121
|
+
- No API rate limits during training (data is local)
|
|
122
|
+
- Automatic incremental updates via webhooks + Sync API
|
|
123
|
+
- Full content history and relationships preserved
|
|
124
|
+
|
|
125
|
+
### 2. Headless CMS Proxy
|
|
126
|
+
|
|
127
|
+
Create an API gateway that manages OAuth tokens and caches responses:
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
import { ContentfulSuite } from '@bernierllc/contentful-suite';
|
|
131
|
+
|
|
132
|
+
const suite = new ContentfulSuite({
|
|
133
|
+
oauth: {
|
|
134
|
+
clientId: process.env.CONTENTFUL_CLIENT_ID!,
|
|
135
|
+
clientSecret: process.env.CONTENTFUL_CLIENT_SECRET!,
|
|
136
|
+
redirectUri: 'http://localhost:3000/oauth/callback'
|
|
137
|
+
},
|
|
138
|
+
gateway: {
|
|
139
|
+
enabled: true,
|
|
140
|
+
port: 3000,
|
|
141
|
+
apiKeys: ['internal-api-key-1', 'internal-api-key-2']
|
|
142
|
+
},
|
|
143
|
+
cache: {
|
|
144
|
+
enabled: true,
|
|
145
|
+
backend: 'redis',
|
|
146
|
+
ttl: 300
|
|
147
|
+
},
|
|
148
|
+
webhooks: {
|
|
149
|
+
enabled: true,
|
|
150
|
+
port: 3001,
|
|
151
|
+
secret: 'webhook-secret'
|
|
152
|
+
},
|
|
153
|
+
// ... storage config
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
await suite.initialize();
|
|
157
|
+
await suite.start();
|
|
158
|
+
|
|
159
|
+
// Gateway is now running at http://localhost:3000
|
|
160
|
+
// Use internal API key to make requests:
|
|
161
|
+
// GET http://localhost:3000/cda/space-id/master/entries
|
|
162
|
+
// Header: X-API-Key: internal-api-key-1
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
**Benefits:**
|
|
166
|
+
- Centralized OAuth token management (no token refresh in clients)
|
|
167
|
+
- Response caching for better performance
|
|
168
|
+
- Webhook-based cache invalidation
|
|
169
|
+
- Rate limiting per client
|
|
170
|
+
- Multi-space routing
|
|
171
|
+
|
|
172
|
+
### 3. Content Syndication
|
|
173
|
+
|
|
174
|
+
Process webhooks in real-time and route content changes to subscribers:
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
import { ContentfulSuite } from '@bernierllc/contentful-suite';
|
|
178
|
+
|
|
179
|
+
const suite = new ContentfulSuite({
|
|
180
|
+
webhooks: {
|
|
181
|
+
enabled: true,
|
|
182
|
+
port: 3001,
|
|
183
|
+
secret: 'your-webhook-secret'
|
|
184
|
+
},
|
|
185
|
+
sync: {
|
|
186
|
+
enabled: true,
|
|
187
|
+
spaces: [{ spaceId: 'your-space-id', environmentId: 'master', accessToken: 'token' }]
|
|
188
|
+
},
|
|
189
|
+
// ... storage config
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
await suite.initialize();
|
|
193
|
+
|
|
194
|
+
// Subscribe to content events
|
|
195
|
+
const webhookService = suite.getWebhookService();
|
|
196
|
+
webhookService?.on('webhook.received', async (data) => {
|
|
197
|
+
console.log('Content changed:', data);
|
|
198
|
+
// Syndicate to other platforms
|
|
199
|
+
await publishToTwitter(data);
|
|
200
|
+
await publishToLinkedIn(data);
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
await suite.start();
|
|
204
|
+
|
|
205
|
+
// Configure Contentful webhook to POST to:
|
|
206
|
+
// http://your-domain:3001/webhooks/contentful
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
**Benefits:**
|
|
210
|
+
- Real-time content propagation
|
|
211
|
+
- Reliable delivery with retry logic
|
|
212
|
+
- Dead letter queue for failed events
|
|
213
|
+
- Event filtering and routing
|
|
214
|
+
|
|
215
|
+
### 4. Multi-Space Management
|
|
216
|
+
|
|
217
|
+
Manage multiple Contentful spaces from a single suite instance:
|
|
218
|
+
|
|
219
|
+
```typescript
|
|
220
|
+
import { ContentfulSuite } from '@bernierllc/contentful-suite';
|
|
221
|
+
|
|
222
|
+
const suite = new ContentfulSuite({
|
|
223
|
+
sync: {
|
|
224
|
+
enabled: true,
|
|
225
|
+
spaces: [
|
|
226
|
+
{
|
|
227
|
+
spaceId: 'space-1',
|
|
228
|
+
environmentId: 'master',
|
|
229
|
+
accessToken: 'token-1'
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
spaceId: 'space-2',
|
|
233
|
+
environmentId: 'staging',
|
|
234
|
+
accessToken: 'token-2'
|
|
235
|
+
}
|
|
236
|
+
]
|
|
237
|
+
},
|
|
238
|
+
migration: {
|
|
239
|
+
enabled: true
|
|
240
|
+
},
|
|
241
|
+
// ... storage config
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
await suite.initialize();
|
|
245
|
+
|
|
246
|
+
// Run migration on specific space
|
|
247
|
+
await suite.runMigration('space-1', migrationScript, {
|
|
248
|
+
id: 'migration-1',
|
|
249
|
+
name: 'Add author field'
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
// Get sync service for specific space
|
|
253
|
+
const syncService = suite.getSyncService('space-1');
|
|
254
|
+
await syncService?.initialSync();
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
## Storage Implementations
|
|
258
|
+
|
|
259
|
+
The suite uses abstract storage interfaces, allowing you to provide your own implementations:
|
|
260
|
+
|
|
261
|
+
### In-Memory Storage (Included)
|
|
262
|
+
|
|
263
|
+
For testing and simple use cases:
|
|
264
|
+
|
|
265
|
+
```typescript
|
|
266
|
+
import {
|
|
267
|
+
InMemoryContentStorage,
|
|
268
|
+
InMemorySyncStateStorage,
|
|
269
|
+
InMemoryMigrationStorage
|
|
270
|
+
} from '@bernierllc/contentful-suite';
|
|
271
|
+
|
|
272
|
+
const config = {
|
|
273
|
+
storage: {
|
|
274
|
+
contentStorage: new InMemoryContentStorage(),
|
|
275
|
+
syncStateStorage: new InMemorySyncStateStorage(),
|
|
276
|
+
migrationStorage: new InMemoryMigrationStorage()
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
### Custom Storage Implementation
|
|
282
|
+
|
|
283
|
+
Implement the storage interfaces for your database:
|
|
284
|
+
|
|
285
|
+
```typescript
|
|
286
|
+
import { ContentStorage, SyncStateStorage, MigrationStorage } from '@bernierllc/contentful-suite';
|
|
287
|
+
|
|
288
|
+
class PostgresContentStorage implements ContentStorage {
|
|
289
|
+
async storeEntries(entries: ContentfulEntry[]): Promise<void> {
|
|
290
|
+
// Store entries in PostgreSQL
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
async storeAssets(assets: ContentfulAsset[]): Promise<void> {
|
|
294
|
+
// Store assets in PostgreSQL
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// ... implement other methods
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
const suite = new ContentfulSuite({
|
|
301
|
+
storage: {
|
|
302
|
+
contentStorage: new PostgresContentStorage(),
|
|
303
|
+
syncStateStorage: new PostgresSyncStateStorage(),
|
|
304
|
+
migrationStorage: new PostgresMigrationStorage()
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
## Configuration
|
|
310
|
+
|
|
311
|
+
### OAuth Configuration
|
|
312
|
+
|
|
313
|
+
Required for gateway service:
|
|
314
|
+
|
|
315
|
+
```typescript
|
|
316
|
+
{
|
|
317
|
+
oauth: {
|
|
318
|
+
clientId: 'your-client-id',
|
|
319
|
+
clientSecret: 'your-client-secret',
|
|
320
|
+
redirectUri: 'http://localhost:3000/oauth/callback'
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
### Gateway Configuration
|
|
326
|
+
|
|
327
|
+
API gateway with internal authentication:
|
|
328
|
+
|
|
329
|
+
```typescript
|
|
330
|
+
{
|
|
331
|
+
gateway: {
|
|
332
|
+
enabled: true,
|
|
333
|
+
port: 3000,
|
|
334
|
+
apiKeys: ['key1', 'key2'] // Internal API keys for authentication
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
### Sync Configuration
|
|
340
|
+
|
|
341
|
+
Content sync with local storage:
|
|
342
|
+
|
|
343
|
+
```typescript
|
|
344
|
+
{
|
|
345
|
+
sync: {
|
|
346
|
+
enabled: true,
|
|
347
|
+
interval: 300000, // Polling interval in ms (default: 5 minutes)
|
|
348
|
+
spaces: [
|
|
349
|
+
{
|
|
350
|
+
spaceId: 'space-id',
|
|
351
|
+
environmentId: 'master',
|
|
352
|
+
accessToken: 'cda-token'
|
|
353
|
+
}
|
|
354
|
+
]
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
### Webhooks Configuration
|
|
360
|
+
|
|
361
|
+
Webhook receiving and processing:
|
|
362
|
+
|
|
363
|
+
```typescript
|
|
364
|
+
{
|
|
365
|
+
webhooks: {
|
|
366
|
+
enabled: true,
|
|
367
|
+
port: 3001,
|
|
368
|
+
secret: 'webhook-secret' // For signature validation
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
### Cache Configuration
|
|
374
|
+
|
|
375
|
+
Response caching:
|
|
376
|
+
|
|
377
|
+
```typescript
|
|
378
|
+
{
|
|
379
|
+
cache: {
|
|
380
|
+
enabled: true,
|
|
381
|
+
backend: 'memory' | 'redis',
|
|
382
|
+
ttl: 300 // Time to live in seconds
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
### Migration Configuration
|
|
388
|
+
|
|
389
|
+
Content model migrations:
|
|
390
|
+
|
|
391
|
+
```typescript
|
|
392
|
+
{
|
|
393
|
+
migration: {
|
|
394
|
+
enabled: true
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
## API Reference
|
|
400
|
+
|
|
401
|
+
### ContentfulSuite
|
|
402
|
+
|
|
403
|
+
Main orchestrator class.
|
|
404
|
+
|
|
405
|
+
#### Methods
|
|
406
|
+
|
|
407
|
+
##### `initialize(): Promise<void>`
|
|
408
|
+
|
|
409
|
+
Initialize all enabled services.
|
|
410
|
+
|
|
411
|
+
##### `start(): Promise<void>`
|
|
412
|
+
|
|
413
|
+
Start all services (gateway, webhooks, sync polling).
|
|
414
|
+
|
|
415
|
+
##### `stop(): Promise<void>`
|
|
416
|
+
|
|
417
|
+
Stop all services gracefully.
|
|
418
|
+
|
|
419
|
+
##### `getMLTrainingData(spaceId: string, contentType?: string): Promise<any[]>`
|
|
420
|
+
|
|
421
|
+
Get content from local storage for ML training.
|
|
422
|
+
|
|
423
|
+
##### `runMigration(spaceId: string, script: string, options: MigrationOptions): Promise<void>`
|
|
424
|
+
|
|
425
|
+
Run a migration on a specific space.
|
|
426
|
+
|
|
427
|
+
##### `getHealth(): SuiteHealth`
|
|
428
|
+
|
|
429
|
+
Get health status of all services.
|
|
430
|
+
|
|
431
|
+
##### Service Getters
|
|
432
|
+
|
|
433
|
+
- `getGateway(): ContentfulGatewayService | undefined`
|
|
434
|
+
- `getSyncService(spaceId: string): ContentfulSyncService | undefined`
|
|
435
|
+
- `getWebhookService(): ContentfulWebhookService | undefined`
|
|
436
|
+
- `getCacheService(): ContentfulCacheService | undefined`
|
|
437
|
+
- `getMigrationService(spaceId: string): ContentfulMigrationService | undefined`
|
|
438
|
+
|
|
439
|
+
## Integration Status
|
|
440
|
+
|
|
441
|
+
This package integrates with the following BernierLLC services:
|
|
442
|
+
|
|
443
|
+
- **Logger**: Integrated - Uses `@bernierllc/logger` for structured logging across all services
|
|
444
|
+
- **NeverHub**: Optional - Automatically detects and integrates with NeverHub service mesh when available
|
|
445
|
+
|
|
446
|
+
### Logger Integration
|
|
447
|
+
|
|
448
|
+
The suite uses `@bernierllc/logger` for consistent structured logging across all services:
|
|
449
|
+
- Gateway service logs API requests and OAuth events
|
|
450
|
+
- Sync service logs content synchronization operations
|
|
451
|
+
- Webhook service logs incoming webhook events
|
|
452
|
+
- Migration service logs schema changes
|
|
453
|
+
|
|
454
|
+
### NeverHub Integration
|
|
455
|
+
|
|
456
|
+
The suite automatically integrates with NeverHub if available:
|
|
457
|
+
|
|
458
|
+
```typescript
|
|
459
|
+
// NeverHub events published:
|
|
460
|
+
- contentful.suite.started
|
|
461
|
+
- contentful.suite.stopped
|
|
462
|
+
|
|
463
|
+
// NeverHub events subscribed:
|
|
464
|
+
- system.shutdown (graceful shutdown)
|
|
465
|
+
- config.updated (reload configuration)
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
## Dependencies
|
|
469
|
+
|
|
470
|
+
This suite bundles all Contentful packages:
|
|
471
|
+
|
|
472
|
+
### Core Packages
|
|
473
|
+
- @bernierllc/contentful-types
|
|
474
|
+
- @bernierllc/contentful-client-core
|
|
475
|
+
- @bernierllc/contentful-auth
|
|
476
|
+
- @bernierllc/contentful-cma-client
|
|
477
|
+
- @bernierllc/contentful-cda-client
|
|
478
|
+
- @bernierllc/contentful-graphql-client
|
|
479
|
+
- @bernierllc/contentful-webhook-handler
|
|
480
|
+
- @bernierllc/contentful-export-adapter
|
|
481
|
+
- @bernierllc/contentful-rich-text
|
|
482
|
+
|
|
483
|
+
### Service Packages
|
|
484
|
+
- @bernierllc/contentful-gateway-service
|
|
485
|
+
- @bernierllc/contentful-sync-service
|
|
486
|
+
- @bernierllc/contentful-webhook-service
|
|
487
|
+
- @bernierllc/contentful-cache-service
|
|
488
|
+
- @bernierllc/contentful-migration-service
|
|
489
|
+
|
|
490
|
+
### Infrastructure
|
|
491
|
+
- @bernierllc/config-manager
|
|
492
|
+
- @bernierllc/logger
|
|
493
|
+
- @bernierllc/neverhub-adapter
|
|
494
|
+
|
|
495
|
+
## License
|
|
496
|
+
|
|
497
|
+
Copyright (c) 2025 Bernier LLC. See LICENSE file for details.
|
|
@@ -0,0 +1,12 @@
|
|
|
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 class ContentfulCacheService {
|
|
10
|
+
constructor(_config: unknown) {}
|
|
11
|
+
async initialize(): Promise<void> {}
|
|
12
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
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 class InMemoryTokenStorage {
|
|
10
|
+
async getToken(_spaceId: string): Promise<unknown> {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
async saveToken(_spaceId: string, _token: unknown): Promise<void> {}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export class ContentfulGatewayService {
|
|
17
|
+
constructor(_config: unknown) {}
|
|
18
|
+
async initialize(): Promise<void> {}
|
|
19
|
+
async start(): Promise<void> {}
|
|
20
|
+
async stop(): Promise<void> {}
|
|
21
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
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 class ContentfulMigrationService {
|
|
10
|
+
constructor(_config: unknown) {}
|
|
11
|
+
async initialize(): Promise<void> {}
|
|
12
|
+
async runMigration(_script: unknown, _options: unknown): Promise<void> {}
|
|
13
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
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 class ContentfulSyncService {
|
|
10
|
+
constructor(_config: unknown) {}
|
|
11
|
+
async initialize(): Promise<void> {}
|
|
12
|
+
async initialSync(): Promise<void> {}
|
|
13
|
+
async incrementalSync(): Promise<void> {}
|
|
14
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
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 class ContentfulWebhookService {
|
|
10
|
+
constructor(_config: unknown) {}
|
|
11
|
+
async initialize(): Promise<void> {}
|
|
12
|
+
async start(_port: number): Promise<void> {}
|
|
13
|
+
async stop(): Promise<void> {}
|
|
14
|
+
on(_event: string, _handler: (data: unknown) => void): void {}
|
|
15
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
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 enum LogLevel {
|
|
10
|
+
DEBUG = 'debug',
|
|
11
|
+
INFO = 'info',
|
|
12
|
+
WARN = 'warn',
|
|
13
|
+
ERROR = 'error'
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export class Logger {
|
|
17
|
+
static getInstance(): Logger {
|
|
18
|
+
return new Logger();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
constructor(_config?: unknown) {}
|
|
22
|
+
|
|
23
|
+
debug(_message: string, ..._args: unknown[]): void {}
|
|
24
|
+
info(_message: string, ..._args: unknown[]): void {}
|
|
25
|
+
warn(_message: string, ..._args: unknown[]): void {}
|
|
26
|
+
error(_message: string, ..._args: unknown[]): void {}
|
|
27
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
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 class NeverHubAdapter {
|
|
10
|
+
static async detect(): Promise<boolean> {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async register(_config: Record<string, unknown>): Promise<void> {}
|
|
15
|
+
async publishEvent(_event: Record<string, unknown>): Promise<void> {}
|
|
16
|
+
async subscribe(_eventType: string, _handler: (event: unknown) => void): Promise<void> {}
|
|
17
|
+
}
|