@bernierllc/contentful-sync-service 1.1.1 → 1.3.1

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.
@@ -21,6 +21,14 @@ const neverhub_adapter_1 = require("@bernierllc/neverhub-adapter");
21
21
  * Performs initial full export, then maintains sync via CDA Sync API + webhook processing.
22
22
  */
23
23
  class ContentfulSyncService {
24
+ config;
25
+ exportAdapter;
26
+ cdaClient;
27
+ webhookHandler;
28
+ queue;
29
+ logger;
30
+ neverhub;
31
+ syncIntervalId;
24
32
  constructor(config) {
25
33
  this.config = {
26
34
  syncInterval: 300000, // 5 minutes default
@@ -0,0 +1,11 @@
1
+ export type ContentfulSyncServiceErrorCode = 'CONTENTFUL_SYNC_SERVICE_ERROR' | 'INVALID_INPUT' | 'OPERATION_FAILED';
2
+ export interface ContentfulSyncServiceErrorOptions {
3
+ cause?: Error;
4
+ code?: ContentfulSyncServiceErrorCode;
5
+ context?: Record<string, unknown>;
6
+ }
7
+ export declare class ContentfulSyncServiceError extends Error {
8
+ readonly code: ContentfulSyncServiceErrorCode;
9
+ readonly context?: Record<string, unknown>;
10
+ constructor(message: string, options?: ContentfulSyncServiceErrorOptions);
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.ContentfulSyncServiceError = void 0;
11
+ class ContentfulSyncServiceError extends Error {
12
+ code;
13
+ context;
14
+ constructor(message, options) {
15
+ super(message, options?.cause ? { cause: options.cause } : undefined);
16
+ this.name = 'ContentfulSyncServiceError';
17
+ this.code = options?.code ?? 'CONTENTFUL_SYNC_SERVICE_ERROR';
18
+ if (options?.context !== undefined) {
19
+ this.context = options.context;
20
+ }
21
+ Error.captureStackTrace?.(this, this.constructor);
22
+ }
23
+ }
24
+ exports.ContentfulSyncServiceError = ContentfulSyncServiceError;
@@ -12,11 +12,9 @@ exports.InMemorySyncStateStorage = exports.InMemoryContentStorage = void 0;
12
12
  * In-memory implementation of ContentStorage for testing
13
13
  */
14
14
  class InMemoryContentStorage {
15
- constructor() {
16
- this.contentTypes = new Map();
17
- this.entries = new Map();
18
- this.assets = new Map();
19
- }
15
+ contentTypes = new Map();
16
+ entries = new Map();
17
+ assets = new Map();
20
18
  async storeContentTypes(contentTypes) {
21
19
  for (const contentType of contentTypes) {
22
20
  this.contentTypes.set(contentType.sys.id, contentType);
@@ -80,9 +78,7 @@ exports.InMemoryContentStorage = InMemoryContentStorage;
80
78
  * In-memory implementation of SyncStateStorage for testing
81
79
  */
82
80
  class InMemorySyncStateStorage {
83
- constructor() {
84
- this.syncTokens = new Map();
85
- }
81
+ syncTokens = new Map();
86
82
  async getSyncToken(spaceId) {
87
83
  return this.syncTokens.get(spaceId) || null;
88
84
  }
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { ContentfulSyncService } from './contentful-sync-service';
2
+ export { ContentfulSyncServiceError, type ContentfulSyncServiceErrorCode, type ContentfulSyncServiceErrorOptions } from './errors';
2
3
  export { InMemoryContentStorage, InMemorySyncStateStorage } from './in-memory-storage';
3
4
  export type { ContentStorage, SyncStateStorage, SyncServiceConfig, SyncStats, SyncResult } from './types';
package/dist/index.js CHANGED
@@ -7,9 +7,11 @@ The client may use and modify this code *only within the scope of the project it
7
7
  Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.InMemorySyncStateStorage = exports.InMemoryContentStorage = exports.ContentfulSyncService = void 0;
10
+ exports.InMemorySyncStateStorage = exports.InMemoryContentStorage = exports.ContentfulSyncServiceError = exports.ContentfulSyncService = void 0;
11
11
  var contentful_sync_service_1 = require("./contentful-sync-service");
12
12
  Object.defineProperty(exports, "ContentfulSyncService", { enumerable: true, get: function () { return contentful_sync_service_1.ContentfulSyncService; } });
13
+ var errors_1 = require("./errors");
14
+ Object.defineProperty(exports, "ContentfulSyncServiceError", { enumerable: true, get: function () { return errors_1.ContentfulSyncServiceError; } });
13
15
  var in_memory_storage_1 = require("./in-memory-storage");
14
16
  Object.defineProperty(exports, "InMemoryContentStorage", { enumerable: true, get: function () { return in_memory_storage_1.InMemoryContentStorage; } });
15
17
  Object.defineProperty(exports, "InMemorySyncStateStorage", { enumerable: true, get: function () { return in_memory_storage_1.InMemorySyncStateStorage; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bernierllc/contentful-sync-service",
3
- "version": "1.1.1",
3
+ "version": "1.3.1",
4
4
  "description": "Full export + incremental webhook sync to local storage for Contentful content",
5
5
  "keywords": [
6
6
  "contentful",
@@ -23,10 +23,10 @@
23
23
  "@bernierllc/contentful-cda-client": "1.4.1",
24
24
  "@bernierllc/contentful-export-adapter": "1.4.0",
25
25
  "@bernierllc/contentful-webhook-handler": "1.2.0",
26
+ "@bernierllc/contentful-types": "1.4.0",
26
27
  "@bernierllc/logger": "1.6.0",
27
- "@bernierllc/neverhub-adapter": "0.3.0",
28
- "@bernierllc/message-queue": "1.2.0",
29
- "@bernierllc/contentful-types": "1.4.0"
28
+ "@bernierllc/message-queue": "1.4.0",
29
+ "@bernierllc/neverhub-adapter": "0.3.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/jest": "^29.5.14",