@devrev/airsync-sdk 2.0.0-beta.4 → 2.0.0-beta.6

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/MIGRATION.md +1028 -0
  2. package/dist/attachments-streaming/attachments-streaming-pool.d.ts +6 -0
  3. package/dist/attachments-streaming/attachments-streaming-pool.d.ts.map +1 -1
  4. package/dist/attachments-streaming/attachments-streaming-pool.interfaces.d.ts +2 -2
  5. package/dist/attachments-streaming/attachments-streaming-pool.interfaces.d.ts.map +1 -1
  6. package/dist/attachments-streaming/attachments-streaming-pool.js +47 -21
  7. package/dist/common/constants.d.ts +3 -5
  8. package/dist/common/constants.d.ts.map +1 -1
  9. package/dist/common/constants.js +4 -6
  10. package/dist/common/helpers.d.ts +3 -21
  11. package/dist/common/helpers.d.ts.map +1 -1
  12. package/dist/common/helpers.js +6 -15
  13. package/dist/http/client.d.ts.map +1 -1
  14. package/dist/http/client.js +4 -8
  15. package/dist/index.d.ts +11 -11
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +11 -18
  18. package/dist/logger/logger.d.ts +8 -63
  19. package/dist/logger/logger.d.ts.map +1 -1
  20. package/dist/logger/logger.interfaces.d.ts +0 -1
  21. package/dist/logger/logger.interfaces.d.ts.map +1 -1
  22. package/dist/logger/logger.js +14 -93
  23. package/dist/mappers/mappers.d.ts +2 -40
  24. package/dist/mappers/mappers.d.ts.map +1 -1
  25. package/dist/mappers/mappers.interfaces.d.ts +35 -154
  26. package/dist/mappers/mappers.interfaces.d.ts.map +1 -1
  27. package/dist/mappers/mappers.interfaces.js +1 -10
  28. package/dist/mappers/mappers.js +2 -40
  29. package/dist/multithreading/adapters/base-adapter.d.ts +19 -36
  30. package/dist/multithreading/adapters/base-adapter.d.ts.map +1 -1
  31. package/dist/multithreading/adapters/base-adapter.js +73 -71
  32. package/dist/multithreading/adapters/extraction-adapter.d.ts +12 -24
  33. package/dist/multithreading/adapters/extraction-adapter.d.ts.map +1 -1
  34. package/dist/multithreading/adapters/extraction-adapter.js +199 -200
  35. package/dist/multithreading/adapters/loading-adapter.d.ts +1 -6
  36. package/dist/multithreading/adapters/loading-adapter.d.ts.map +1 -1
  37. package/dist/multithreading/adapters/loading-adapter.helpers.d.ts +2 -12
  38. package/dist/multithreading/adapters/loading-adapter.helpers.d.ts.map +1 -1
  39. package/dist/multithreading/adapters/loading-adapter.helpers.js +2 -12
  40. package/dist/multithreading/adapters/loading-adapter.js +292 -314
  41. package/dist/multithreading/emit.d.ts +3 -2
  42. package/dist/multithreading/emit.d.ts.map +1 -1
  43. package/dist/multithreading/emit.js +3 -5
  44. package/dist/multithreading/process-task.d.ts +2 -12
  45. package/dist/multithreading/process-task.d.ts.map +1 -1
  46. package/dist/multithreading/process-task.js +45 -59
  47. package/dist/multithreading/spawn/spawn.d.ts +3 -9
  48. package/dist/multithreading/spawn/spawn.d.ts.map +1 -1
  49. package/dist/multithreading/spawn/spawn.helpers.d.ts +6 -25
  50. package/dist/multithreading/spawn/spawn.helpers.d.ts.map +1 -1
  51. package/dist/multithreading/spawn/spawn.helpers.js +7 -49
  52. package/dist/multithreading/spawn/spawn.js +18 -33
  53. package/dist/multithreading/worker.js +2 -4
  54. package/dist/repo/repo.d.ts +10 -0
  55. package/dist/repo/repo.d.ts.map +1 -1
  56. package/dist/repo/repo.helpers.d.ts +6 -0
  57. package/dist/repo/repo.helpers.d.ts.map +1 -0
  58. package/dist/repo/repo.helpers.js +16 -0
  59. package/dist/repo/repo.interfaces.d.ts +4 -16
  60. package/dist/repo/repo.interfaces.d.ts.map +1 -1
  61. package/dist/repo/repo.js +23 -8
  62. package/dist/state/base-state.d.ts +14 -36
  63. package/dist/state/base-state.d.ts.map +1 -1
  64. package/dist/state/base-state.js +16 -38
  65. package/dist/state/extraction-state.d.ts +4 -19
  66. package/dist/state/extraction-state.d.ts.map +1 -1
  67. package/dist/state/extraction-state.js +6 -23
  68. package/dist/state/install-initial-domain-mapping.d.ts +1 -1
  69. package/dist/state/install-initial-domain-mapping.d.ts.map +1 -1
  70. package/dist/state/install-initial-domain-mapping.js +1 -3
  71. package/dist/state/loading-state.d.ts +1 -11
  72. package/dist/state/loading-state.d.ts.map +1 -1
  73. package/dist/state/loading-state.js +2 -12
  74. package/dist/state/state.d.ts +2 -2
  75. package/dist/state/state.d.ts.map +1 -1
  76. package/dist/state/state.interfaces.d.ts +10 -24
  77. package/dist/state/state.interfaces.d.ts.map +1 -1
  78. package/dist/state/state.interfaces.js +9 -11
  79. package/dist/state/state.js +3 -3
  80. package/dist/state/time-value-resolver.d.ts +7 -36
  81. package/dist/state/time-value-resolver.d.ts.map +1 -1
  82. package/dist/state/time-value-resolver.js +7 -40
  83. package/dist/testing/mock-event.d.ts +2 -10
  84. package/dist/testing/mock-event.d.ts.map +1 -1
  85. package/dist/testing/mock-event.js +3 -11
  86. package/dist/testing/mock-server.d.ts +4 -27
  87. package/dist/testing/mock-server.d.ts.map +1 -1
  88. package/dist/testing/mock-server.interfaces.d.ts +10 -35
  89. package/dist/testing/mock-server.interfaces.d.ts.map +1 -1
  90. package/dist/testing/mock-server.js +19 -36
  91. package/dist/types/common.d.ts +1 -12
  92. package/dist/types/common.d.ts.map +1 -1
  93. package/dist/types/common.js +1 -6
  94. package/dist/types/external-domain-metadata.d.ts +30 -171
  95. package/dist/types/external-domain-metadata.d.ts.map +1 -1
  96. package/dist/types/extraction.d.ts +35 -120
  97. package/dist/types/extraction.d.ts.map +1 -1
  98. package/dist/types/extraction.js +5 -31
  99. package/dist/types/loading.d.ts.map +1 -1
  100. package/dist/types/workers.d.ts +18 -116
  101. package/dist/types/workers.d.ts.map +1 -1
  102. package/dist/types/workers.js +0 -6
  103. package/dist/uploader/uploader.d.ts +6 -58
  104. package/dist/uploader/uploader.d.ts.map +1 -1
  105. package/dist/uploader/uploader.helpers.d.ts +4 -27
  106. package/dist/uploader/uploader.helpers.d.ts.map +1 -1
  107. package/dist/uploader/uploader.helpers.js +64 -30
  108. package/dist/uploader/uploader.interfaces.d.ts +15 -25
  109. package/dist/uploader/uploader.interfaces.d.ts.map +1 -1
  110. package/dist/uploader/uploader.interfaces.js +8 -0
  111. package/dist/uploader/uploader.js +18 -84
  112. package/package.json +6 -4
@@ -1 +1 @@
1
- {"version":3,"file":"state.interfaces.d.ts","sourceRoot":"","sources":["../../src/state/state.interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,MAAM,WAAW,QAAQ;IACvB;gHAC4G;IAC5G,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;gHAC4G;IAC5G,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,2DAA2D;IAC3D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,2DAA2D;IAC3D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB,CAAC,cAAc;IAClD,cAAc,EAAE,cAAc,CAAC;IAC/B,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED,MAAM,WAAW,QAAQ;IACvB,mBAAmB,EAAE;QACnB,WAAW,EAAE,MAAM,EAAE,CAAC;QACtB,aAAa,EAAE,MAAM,CAAC;QACtB,+BAA+B,CAAC,EAAE,mBAAmB,EAAE,CAAC;KACzD,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW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AC;QACtB,+BAA+B,CAAC,EAAE,mBAAmB,EAAE,CAAC;KACzD,CAAC;CACH;AAED,oBAAY,yBAAyB;IACnC,OAAO,YAAY;IACnB,MAAM,WAAW;CAClB;AAED,wEAAwE;AACxE,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,yBAAyB,CAAC;CACnC;AAED,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,cAAc,CAAC,cAAc;IAC5C,KAAK,EAAE,YAAY,CAAC;IACpB,YAAY,EAAE,cAAc,CAAC;IAC7B,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C,OAAO,CAAC,EAAE,oBAAoB,CAAC;CAChC;AAED,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;CAa9B,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;CAK3B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,WAAW,CAAC,MAAM,CAKhD,CAAC"}
@@ -1,6 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.V1_SDK_STATE_KEYS = exports.loadingSdkState = exports.extractionSdkState = void 0;
3
+ exports.V1_SDK_STATE_KEYS = exports.loadingSdkState = exports.extractionSdkState = exports.ProcessedAttachmentStatus = void 0;
4
+ var ProcessedAttachmentStatus;
5
+ (function (ProcessedAttachmentStatus) {
6
+ ProcessedAttachmentStatus["Success"] = "success";
7
+ ProcessedAttachmentStatus["Failed"] = "failed";
8
+ })(ProcessedAttachmentStatus || (exports.ProcessedAttachmentStatus = ProcessedAttachmentStatus = {}));
4
9
  exports.extractionSdkState = {
5
10
  pendingWorkersOldest: '',
6
11
  pendingWorkersNewest: '',
@@ -22,16 +27,9 @@ exports.loadingSdkState = {
22
27
  },
23
28
  };
24
29
  /**
25
- * The set of top-level state keys owned by the SDK. Derived from the initial
26
- * SDK state constants so it auto-updates whenever a new SDK field is added.
27
- * Used by the migration shim to split a flat v1 state blob into the
28
- * `{ connectorState, sdkState }` envelope: keys in this set go to `sdkState`,
29
- * everything else is connector state.
30
- *
31
- * `lastSyncStarted` / `lastSuccessfulSyncStarted` are retained here even though
32
- * they are no longer fields on `SdkState`: a flat v1 blob may still carry them,
33
- * and they must be recognized as SDK-owned so they are stripped out rather than
34
- * leaking into connector state during migration.
30
+ * SDK-owned top-level state keys, used to split a flat v1 blob during migration.
31
+ * `lastSyncStarted` / `lastSuccessfulSyncStarted` are no longer on `SdkState` but
32
+ * stay listed so v1 blobs carrying them don't leak them into connector state.
35
33
  */
36
34
  exports.V1_SDK_STATE_KEYS = new Set([
37
35
  ...Object.keys(exports.extractionSdkState),
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createLoadingState = exports.LoadingState = exports.createExtractionState = exports.ExtractionState = exports.BaseState = void 0;
3
+ exports.LoadingState = exports.createLoadingState = exports.ExtractionState = exports.createExtractionState = exports.BaseState = void 0;
4
4
  var base_state_1 = require("./base-state");
5
5
  Object.defineProperty(exports, "BaseState", { enumerable: true, get: function () { return base_state_1.BaseState; } });
6
6
  var extraction_state_1 = require("./extraction-state");
7
- Object.defineProperty(exports, "ExtractionState", { enumerable: true, get: function () { return extraction_state_1.ExtractionState; } });
8
7
  Object.defineProperty(exports, "createExtractionState", { enumerable: true, get: function () { return extraction_state_1.createExtractionState; } });
8
+ Object.defineProperty(exports, "ExtractionState", { enumerable: true, get: function () { return extraction_state_1.ExtractionState; } });
9
9
  var loading_state_1 = require("./loading-state");
10
- Object.defineProperty(exports, "LoadingState", { enumerable: true, get: function () { return loading_state_1.LoadingState; } });
11
10
  Object.defineProperty(exports, "createLoadingState", { enumerable: true, get: function () { return loading_state_1.createLoadingState; } });
11
+ Object.defineProperty(exports, "LoadingState", { enumerable: true, get: function () { return loading_state_1.LoadingState; } });
@@ -1,46 +1,17 @@
1
- import { TimeUnit, TimeValue } from '../types/extraction';
2
1
  import { SdkState } from '../state/state.interfaces';
3
- /**
4
- * Parses a shorthand duration string into its numeric value and unit.
5
- * Supported units:
6
- * - 'ns' for nanoseconds
7
- * - 'us' or 'µs' for microseconds
8
- * - 'ms' for milliseconds
9
- * - 's' for seconds
10
- * - 'm' for minutes
11
- * - 'h' for hours
12
- *
13
- * @throws Error if the format is invalid
14
- */
2
+ import { TimeUnit, TimeValue } from '../types/extraction';
3
+ /** Parses a shorthand duration (e.g. '100ns', '500ms', '5m', '2h'); units are the `TimeUnit` values. */
15
4
  export declare function parseDuration(shorthand: string): {
16
5
  value: number;
17
6
  unit: TimeUnit;
18
7
  };
19
- /**
20
- * Applies a shorthand duration to a base ISO 8601 timestamp.
21
- *
22
- * @param baseTimestamp - ISO 8601 timestamp to apply duration to
23
- * @param duration - Shorthand duration string (e.g. '100ns', '500ms', '30s', '5m', '2h')
24
- * @param operation - Whether to 'add' or 'subtract' the duration
25
- * @returns ISO 8601 timestamp with the duration applied
26
- */
8
+ /** Adds/subtracts a shorthand duration to/from an ISO 8601 timestamp. */
27
9
  export declare function applyDuration(baseTimestamp: string, duration: string, operation: 'add' | 'subtract'): string;
28
10
  /**
29
- * Resolves a TimeValue into a concrete ISO 8601 timestamp string.
30
- *
31
- * Resolution rules:
32
- * - ABSOLUTE: Returns the value directly (must be an ISO 8601 timestamp)
33
- * - NOW: Returns the current time as ISO 8601
34
- * - UNBOUNDED: Returns UNBOUNDED_DATE_TIME_VALUE ('1970-01-01T00:00:00.000Z')
35
- * - WORKERS_OLDEST: Returns workersOldest from state, or UNBOUNDED if not set
36
- * - WORKERS_NEWEST: Returns workersNewest from state, or UNBOUNDED if not set
37
- * - WORKERS_OLDEST_MINUS_WINDOW: Subtracts duration from workersOldest, or UNBOUNDED if not set
38
- * - WORKERS_NEWEST_PLUS_WINDOW: Adds duration to workersNewest, or UNBOUNDED if not set
39
- *
40
- * @param timeValue - The TimeValue to resolve
41
- * @param state - The current SDK state containing workersOldest and workersNewest
42
- * @returns Resolved ISO 8601 timestamp string
43
- * @throws Error if required TimeValue.value is missing for ABSOLUTE or *_WINDOW types
11
+ * Resolves a TimeValue into a concrete ISO 8601 timestamp. WORKERS_* types
12
+ * read the boundaries from state and fall back to UNBOUNDED when unset
13
+ * (backwards compatibility with old state); *_WINDOW types apply the duration
14
+ * in `timeValue.value` to the boundary.
44
15
  */
45
16
  export declare function resolveTimeValue(timeValue: TimeValue, state: SdkState): string;
46
17
  //# sourceMappingURL=time-value-resolver.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"time-value-resolver.d.ts","sourceRoot":"","sources":["../../src/state/time-value-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAiB,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAGrD;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG;IAChD,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,QAAQ,CAAC;CAChB,CAcA;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,KAAK,GAAG,UAAU,GAC5B,MAAM,CA6BR;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,QAAQ,GACd,MAAM,CAyER"}
1
+ {"version":3,"file":"time-value-resolver.d.ts","sourceRoot":"","sources":["../../src/state/time-value-resolver.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAiB,MAAM,qBAAqB,CAAC;AAEzE,wGAAwG;AACxG,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG;IAChD,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,QAAQ,CAAC;CAChB,CAcA;AAED,yEAAyE;AACzE,wBAAgB,aAAa,CAC3B,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,KAAK,GAAG,UAAU,GAC5B,MAAM,CA6BR;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,QAAQ,GACd,MAAM,CAqER"}
@@ -3,20 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseDuration = parseDuration;
4
4
  exports.applyDuration = applyDuration;
5
5
  exports.resolveTimeValue = resolveTimeValue;
6
- const extraction_1 = require("../types/extraction");
7
6
  const constants_1 = require("../common/constants");
8
- /**
9
- * Parses a shorthand duration string into its numeric value and unit.
10
- * Supported units:
11
- * - 'ns' for nanoseconds
12
- * - 'us' or 'µs' for microseconds
13
- * - 'ms' for milliseconds
14
- * - 's' for seconds
15
- * - 'm' for minutes
16
- * - 'h' for hours
17
- *
18
- * @throws Error if the format is invalid
19
- */
7
+ const extraction_1 = require("../types/extraction");
8
+ /** Parses a shorthand duration (e.g. '100ns', '500ms', '5m', '2h'); units are the `TimeUnit` values. */
20
9
  function parseDuration(shorthand) {
21
10
  const validUnits = Object.values(extraction_1.TimeUnit).join('|');
22
11
  const match = shorthand.match(new RegExp(`^(\\d+(?:\\.\\d+)?)(${validUnits})$`));
@@ -28,14 +17,7 @@ function parseDuration(shorthand) {
28
17
  unit: match[2],
29
18
  };
30
19
  }
31
- /**
32
- * Applies a shorthand duration to a base ISO 8601 timestamp.
33
- *
34
- * @param baseTimestamp - ISO 8601 timestamp to apply duration to
35
- * @param duration - Shorthand duration string (e.g. '100ns', '500ms', '30s', '5m', '2h')
36
- * @param operation - Whether to 'add' or 'subtract' the duration
37
- * @returns ISO 8601 timestamp with the duration applied
38
- */
20
+ /** Adds/subtracts a shorthand duration to/from an ISO 8601 timestamp. */
39
21
  function applyDuration(baseTimestamp, duration, operation) {
40
22
  const { value, unit } = parseDuration(duration);
41
23
  const date = new Date(baseTimestamp);
@@ -65,21 +47,10 @@ function applyDuration(baseTimestamp, duration, operation) {
65
47
  return date.toISOString();
66
48
  }
67
49
  /**
68
- * Resolves a TimeValue into a concrete ISO 8601 timestamp string.
69
- *
70
- * Resolution rules:
71
- * - ABSOLUTE: Returns the value directly (must be an ISO 8601 timestamp)
72
- * - NOW: Returns the current time as ISO 8601
73
- * - UNBOUNDED: Returns UNBOUNDED_DATE_TIME_VALUE ('1970-01-01T00:00:00.000Z')
74
- * - WORKERS_OLDEST: Returns workersOldest from state, or UNBOUNDED if not set
75
- * - WORKERS_NEWEST: Returns workersNewest from state, or UNBOUNDED if not set
76
- * - WORKERS_OLDEST_MINUS_WINDOW: Subtracts duration from workersOldest, or UNBOUNDED if not set
77
- * - WORKERS_NEWEST_PLUS_WINDOW: Adds duration to workersNewest, or UNBOUNDED if not set
78
- *
79
- * @param timeValue - The TimeValue to resolve
80
- * @param state - The current SDK state containing workersOldest and workersNewest
81
- * @returns Resolved ISO 8601 timestamp string
82
- * @throws Error if required TimeValue.value is missing for ABSOLUTE or *_WINDOW types
50
+ * Resolves a TimeValue into a concrete ISO 8601 timestamp. WORKERS_* types
51
+ * read the boundaries from state and fall back to UNBOUNDED when unset
52
+ * (backwards compatibility with old state); *_WINDOW types apply the duration
53
+ * in `timeValue.value` to the boundary.
83
54
  */
84
55
  function resolveTimeValue(timeValue, state) {
85
56
  switch (timeValue.type) {
@@ -103,14 +74,12 @@ function resolveTimeValue(timeValue, state) {
103
74
  }
104
75
  case extraction_1.TimeValueType.WORKERS_OLDEST: {
105
76
  if (!state.workersOldest) {
106
- // To support backwards-compatibility for the old state
107
77
  return constants_1.UNBOUNDED_DATE_TIME_VALUE;
108
78
  }
109
79
  return state.workersOldest;
110
80
  }
111
81
  case extraction_1.TimeValueType.WORKERS_NEWEST: {
112
82
  if (!state.workersNewest) {
113
- // To support backwards-compatibility for the old state
114
83
  return constants_1.UNBOUNDED_DATE_TIME_VALUE;
115
84
  }
116
85
  return state.workersNewest;
@@ -120,7 +89,6 @@ function resolveTimeValue(timeValue, state) {
120
89
  throw new Error("TimeValue of type WORKERS_OLDEST_MINUS_WINDOW must have a value (duration, e.g. '30s', '5m', '2h').");
121
90
  }
122
91
  if (!state.workersOldest) {
123
- // To support backwards-compatibility for the old state
124
92
  return constants_1.UNBOUNDED_DATE_TIME_VALUE;
125
93
  }
126
94
  return applyDuration(state.workersOldest, timeValue.value, 'subtract');
@@ -130,7 +98,6 @@ function resolveTimeValue(timeValue, state) {
130
98
  throw new Error("TimeValue of type WORKERS_NEWEST_PLUS_WINDOW must have a value (duration, e.g. '30s', '5m', '2h').");
131
99
  }
132
100
  if (!state.workersNewest) {
133
- // To support backwards-compatibility for the old state
134
101
  return constants_1.UNBOUNDED_DATE_TIME_VALUE;
135
102
  }
136
103
  return applyDuration(state.workersNewest, timeValue.value, 'add');
@@ -1,18 +1,10 @@
1
1
  import { AirSyncEvent } from '../types/extraction';
2
- /**
3
- * Recursively makes all properties of T optional.
4
- */
5
2
  export type DeepPartial<T> = {
6
3
  [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
7
4
  };
8
5
  /**
9
- * Creates a mock AirSyncEvent for testing.
10
- *
11
- * @param mockServerUrl - Base URL for the mock server. Defaults to {@link MOCK_SERVER_DEFAULT_URL}.
12
- * The `callback_url`, `worker_data_url`, and `devrev_endpoint` fields are
13
- * derived from this value unless explicitly overridden.
14
- * @param overrides - Deep partial of AirSyncEvent. Any provided fields are
15
- * deep-merged on top of the defaults.
6
+ * Creates a mock AirSyncEvent for testing. `callback_url`, `worker_data_url`,
7
+ * and `devrev_endpoint` derive from `mockServerUrl` unless explicitly overridden.
16
8
  */
17
9
  export declare function createMockEvent(mockServerUrl?: string, overrides?: DeepPartial<AirSyncEvent>): AirSyncEvent;
18
10
  //# sourceMappingURL=mock-event.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mock-event.d.ts","sourceRoot":"","sources":["../../src/testing/mock-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAa,MAAM,qBAAqB,CAAC;AAI9D;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;KAC1B,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAChE,CAAC;AAoCF;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,aAAa,GAAE,MAAgC,EAC/C,SAAS,GAAE,WAAW,CAAC,YAAY,CAAM,GACxC,YAAY,CA+Ed"}
1
+ {"version":3,"file":"mock-event.d.ts","sourceRoot":"","sources":["../../src/testing/mock-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAa,MAAM,qBAAqB,CAAC;AAI9D,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;KAC1B,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAChE,CAAC;AAiCF;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,aAAa,GAAE,MAAgC,EAC/C,SAAS,GAAE,WAAW,CAAC,YAAY,CAAM,GACxC,YAAY,CA+Ed"}
@@ -3,10 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createMockEvent = createMockEvent;
4
4
  const extraction_1 = require("../types/extraction");
5
5
  const mock_server_1 = require("./mock-server");
6
- /**
7
- * Deep merges source into target. Arrays and primitives from source replace
8
- * those in target; plain objects are merged recursively.
9
- */
6
+ /** Arrays and primitives from source replace target's; plain objects merge recursively. */
10
7
  function deepMerge(target, source) {
11
8
  const result = Object.assign({}, target);
12
9
  for (const key of Object.keys(source)) {
@@ -27,13 +24,8 @@ function deepMerge(target, source) {
27
24
  return result;
28
25
  }
29
26
  /**
30
- * Creates a mock AirSyncEvent for testing.
31
- *
32
- * @param mockServerUrl - Base URL for the mock server. Defaults to {@link MOCK_SERVER_DEFAULT_URL}.
33
- * The `callback_url`, `worker_data_url`, and `devrev_endpoint` fields are
34
- * derived from this value unless explicitly overridden.
35
- * @param overrides - Deep partial of AirSyncEvent. Any provided fields are
36
- * deep-merged on top of the defaults.
27
+ * Creates a mock AirSyncEvent for testing. `callback_url`, `worker_data_url`,
28
+ * and `devrev_endpoint` derive from `mockServerUrl` unless explicitly overridden.
37
29
  */
38
30
  function createMockEvent(mockServerUrl = mock_server_1.MOCK_SERVER_DEFAULT_URL, overrides = {}) {
39
31
  var _a, _b, _c, _d;
@@ -1,13 +1,8 @@
1
1
  import { RequestInfo, RouteConfig } from './mock-server.interfaces';
2
- /**
3
- * Default base URL for the mock server. The port `0` lets the OS assign a free
4
- * port at listen time; tests read the resolved URL from `mockServer.baseUrl`.
5
- */
6
2
  export declare const MOCK_SERVER_DEFAULT_URL = "http://localhost:0";
7
3
  /**
8
- * MockServer used in tests to mock internal AirSync endpoints.
9
- * This is a simple mock server that listens on a port and responds to requests.
10
- * Supports per-test route configuration to simulate different response scenarios.
4
+ * Mocks internal AirSync endpoints in tests, with per-test route
5
+ * configuration to simulate different response scenarios.
11
6
  */
12
7
  export declare class MockServer {
13
8
  private server;
@@ -21,32 +16,14 @@ export declare class MockServer {
21
16
  start(): Promise<void>;
22
17
  stop(): Promise<void>;
23
18
  private handleRequest;
24
- /**
25
- * Default route handler for the mock server. Returns { success: true } for
26
- * routes that are not explicitly set.
27
- */
19
+ /** Falls back to { success: true } for routes not explicitly set. */
28
20
  private defaultRouteHandler;
29
21
  private getRouteKey;
30
- /**
31
- * Configures a route to return a specific status code and optional response body.
32
- */
33
22
  setRoute(config: RouteConfig): void;
34
- /**
35
- * Resets all custom route handlers, restoring all default handlers.
36
- * Also clears request tracking data.
37
- */
23
+ /** Restores default handlers and clears request tracking data. */
38
24
  resetRoutes(): void;
39
- /**
40
- * Returns the most recent request or undefined if no requests exist.
41
- */
42
25
  getLastRequest(): RequestInfo | undefined;
43
- /**
44
- * Gets the number of requests made to a specific endpoint.
45
- */
46
26
  getRequestCount(method: string, path: string): number;
47
- /**
48
- * Gets all requests made to a specific endpoint.
49
- */
50
27
  getRequests(method: string, path: string): RequestInfo[];
51
28
  }
52
29
  //# sourceMappingURL=mock-server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mock-server.d.ts","sourceRoot":"","sources":["../../src/testing/mock-server.ts"],"names":[],"mappings":"AAEA,OAAO,EAKL,WAAW,EACX,WAAW,EAEZ,MAAM,0BAA0B,CAAC;AAElC;;;GAGG;AACH,eAAO,MAAM,uBAAuB,uBAAuB,CAAC;AAuE5D;;;;GAIG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,YAAY,CAAS;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,aAAa,CAA4B;IACjD,OAAO,CAAC,QAAQ,CAAqB;IACrC,OAAO,CAAC,aAAa,CAA4B;gBAErC,IAAI,GAAE,MAAiC;IAMtC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAsBtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;YAkBpB,aAAa;IA+B3B;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IA6B3B,OAAO,CAAC,WAAW;IAInB;;OAEG;IACI,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;IAyE1C;;;OAGG;IACI,WAAW,IAAI,IAAI;IAM1B;;OAEG;IACI,cAAc,IAAI,WAAW,GAAG,SAAS;IAOhD;;OAEG;IACI,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM;IAI5D;;OAEG;IACI,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,WAAW,EAAE;CAQhE"}
1
+ {"version":3,"file":"mock-server.d.ts","sourceRoot":"","sources":["../../src/testing/mock-server.ts"],"names":[],"mappings":"AAEA,OAAO,EAKL,WAAW,EACX,WAAW,EAEZ,MAAM,0BAA0B,CAAC;AAIlC,eAAO,MAAM,uBAAuB,uBAAuB,CAAC;AAsE5D;;;GAGG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,YAAY,CAAS;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,aAAa,CAA4B;IACjD,OAAO,CAAC,QAAQ,CAAqB;IACrC,OAAO,CAAC,aAAa,CAA4B;gBAErC,IAAI,GAAE,MAAiC;IAMtC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAsBtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;YAkBpB,aAAa;IA+B3B,qEAAqE;IACrE,OAAO,CAAC,mBAAmB;IA6B3B,OAAO,CAAC,WAAW;IAIZ,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;IA8E1C,kEAAkE;IAC3D,WAAW,IAAI,IAAI;IAMnB,cAAc,IAAI,WAAW,GAAG,SAAS;IAOzC,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM;IAIrD,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,WAAW,EAAE;CAQhE"}
@@ -1,73 +1,48 @@
1
1
  import { IncomingMessage, ServerResponse } from 'http';
2
2
  export declare const DEFAULT_MOCK_SERVER_PORT = 3001;
3
3
  export interface ParsedRequest extends IncomingMessage {
4
- /** Parsed URL path (without query string) */
4
+ /** URL path without query string */
5
5
  path: string;
6
6
  /** Parsed JSON body (if any) */
7
7
  body?: unknown;
8
8
  }
9
9
  export interface MockResponse extends ServerResponse {
10
- /** Set response headers from a record */
11
10
  set(headers: Record<string, string>): MockResponse;
12
- /** Set the HTTP status code */
13
11
  status(code: number): MockResponse;
14
- /** Send a JSON response */
15
12
  json(data: unknown): void;
16
- /** Send an empty response */
13
+ buffer(data: Buffer): void;
17
14
  send(): void;
18
15
  }
19
- /**
20
- * Configuration for retry simulation behavior.
21
- */
16
+ /** Simulates failures before succeeding. */
22
17
  export interface RetryConfig {
23
- /** Number of times to return error before succeeding (default: 4) */
18
+ /** Failures before success (default: 4) */
24
19
  failureCount?: number;
25
- /** 5xx status code to return during failures (default: 500) */
20
+ /** Status code during failures (default: 500) */
26
21
  errorStatus?: number;
27
- /** Optional error response body to send as JSON during failures */
28
22
  errorBody?: unknown;
29
- /** Optional headers to send with the error response */
30
23
  headers?: Record<string, string>;
31
- /** Optional delay in milliseconds before sending each failure response */
24
+ /** Delay in ms before each failure response */
32
25
  delay?: number;
33
26
  }
34
- /**
35
- * Configuration object for setting up a route response.
36
- */
37
27
  export interface RouteConfig {
38
- /** The path of the route (e.g., '/callback_url', '/worker_data_url.get') */
39
28
  path: string;
40
- /** The HTTP method (e.g., 'GET', 'POST', 'PUT', 'DELETE') */
41
29
  method: string;
42
- /** The HTTP status code to return (e.g., 200, 401, 500) */
43
30
  status: number;
44
- /** Optional response body to send as JSON */
45
31
  body?: unknown;
46
- /** Optional headers to send with the response */
32
+ /** Raw binary body, e.g. gzipped JSONL (takes precedence over `body`) */
33
+ bodyBuffer?: Buffer;
47
34
  headers?: Record<string, string>;
48
- /** Optional retry configuration for simulating failures before success */
49
35
  retry?: RetryConfig;
50
- /** Optional delay in milliseconds before sending the response */
36
+ /** Delay in ms before sending the response */
51
37
  delay?: number;
52
38
  }
53
- /**
54
- * Type for custom route handler functions.
55
- */
56
39
  export type RouteHandler = (req: ParsedRequest, res: MockResponse) => unknown;
57
- /**
58
- * Information about a request received by the mock server.
59
- */
60
40
  export interface RequestInfo {
61
- /** The HTTP method (e.g., 'GET', 'POST') */
62
41
  method: string;
63
- /** The full URL path of the request */
64
42
  url: string;
65
- /** Optional request body (for POST/PUT requests) */
66
43
  body?: unknown;
67
44
  }
68
45
  export type RouteHandlers = Map<string, RouteHandler>;
69
- /**
70
- * Type for tracking request counts per route.
71
- */
46
+ /** Request counts per route. */
72
47
  export type RequestCounts = Map<string, number>;
73
48
  //# sourceMappingURL=mock-server.interfaces.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mock-server.interfaces.d.ts","sourceRoot":"","sources":["../../src/testing/mock-server.interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAEvD,eAAO,MAAM,wBAAwB,OAAO,CAAC;AAE7C,MAAM,WAAW,aAAc,SAAQ,eAAe;IACpD,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,gCAAgC;IAChC,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,YAAa,SAAQ,cAAc;IAClD,yCAAyC;IACzC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,YAAY,CAAC;IACnD,+BAA+B;IAC/B,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAAC;IACnC,2BAA2B;IAC3B,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;IAC1B,6BAA6B;IAC7B,IAAI,IAAI,IAAI,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,qEAAqE;IACrE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,+DAA+D;IAC/D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mEAAmE;IACnE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAA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,OAAO,CAAC;CAChB;AAED,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AAEtD,gCAAgC;AAChC,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC"}
@@ -3,15 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MockServer = exports.MOCK_SERVER_DEFAULT_URL = void 0;
4
4
  const http_1 = require("http");
5
5
  const mock_server_interfaces_1 = require("./mock-server.interfaces");
6
- /**
7
- * Default base URL for the mock server. The port `0` lets the OS assign a free
8
- * port at listen time; tests read the resolved URL from `mockServer.baseUrl`.
9
- */
6
+ // Port 0 lets the OS assign a free port at listen time; tests read the
7
+ // resolved URL from `mockServer.baseUrl`.
10
8
  exports.MOCK_SERVER_DEFAULT_URL = 'http://localhost:0';
11
9
  const MAX_BODY_SIZE = 10 * 1024 * 1024; // 10mb
12
- /**
13
- * Parses the JSON body from an incoming request.
14
- */
15
10
  async function parseJsonBody(req) {
16
11
  return new Promise((resolve, reject) => {
17
12
  const chunks = [];
@@ -41,9 +36,6 @@ async function parseJsonBody(req) {
41
36
  req.on('error', reject);
42
37
  });
43
38
  }
44
- /**
45
- * Wraps a ServerResponse with helper methods (status, json, set, send).
46
- */
47
39
  function wrapResponse(res) {
48
40
  const mock = res;
49
41
  let statusCode = 200;
@@ -61,6 +53,10 @@ function wrapResponse(res) {
61
53
  res.writeHead(statusCode, { 'Content-Type': 'application/json' });
62
54
  res.end(JSON.stringify(data));
63
55
  };
56
+ mock.buffer = (data) => {
57
+ res.writeHead(statusCode, { 'Content-Type': 'application/octet-stream' });
58
+ res.end(data);
59
+ };
64
60
  mock.send = () => {
65
61
  res.writeHead(statusCode);
66
62
  res.end();
@@ -68,9 +64,8 @@ function wrapResponse(res) {
68
64
  return mock;
69
65
  }
70
66
  /**
71
- * MockServer used in tests to mock internal AirSync endpoints.
72
- * This is a simple mock server that listens on a port and responds to requests.
73
- * Supports per-test route configuration to simulate different response scenarios.
67
+ * Mocks internal AirSync endpoints in tests, with per-test route
68
+ * configuration to simulate different response scenarios.
74
69
  */
75
70
  class MockServer {
76
71
  constructor(port = mock_server_interfaces_1.DEFAULT_MOCK_SERVER_PORT) {
@@ -139,10 +134,7 @@ class MockServer {
139
134
  this.defaultRouteHandler(req, res);
140
135
  }
141
136
  }
142
- /**
143
- * Default route handler for the mock server. Returns { success: true } for
144
- * routes that are not explicitly set.
145
- */
137
+ /** Falls back to { success: true } for routes not explicitly set. */
146
138
  defaultRouteHandler(req, res) {
147
139
  if (req.method === 'GET' && req.path === '/worker_data_url.get') {
148
140
  res.status(200).json({
@@ -175,11 +167,8 @@ class MockServer {
175
167
  getRouteKey(method, path) {
176
168
  return `${method.toUpperCase()}:${path}`;
177
169
  }
178
- /**
179
- * Configures a route to return a specific status code and optional response body.
180
- */
181
170
  setRoute(config) {
182
- const { path, method, status, body, retry, headers, delay } = config;
171
+ const { path, method, status, body, bodyBuffer, retry, headers, delay } = config;
183
172
  const key = this.getRouteKey(method, path);
184
173
  if (retry) {
185
174
  this.requestCounts.set(key, 0);
@@ -217,7 +206,10 @@ class MockServer {
217
206
  if (headers) {
218
207
  res.set(headers);
219
208
  }
220
- if (body !== undefined) {
209
+ if (bodyBuffer !== undefined) {
210
+ res.status(status).buffer(bodyBuffer);
211
+ }
212
+ else if (body !== undefined) {
221
213
  res.status(status).json(body);
222
214
  }
223
215
  else {
@@ -229,7 +221,10 @@ class MockServer {
229
221
  if (headers) {
230
222
  res.set(headers);
231
223
  }
232
- if (body !== undefined) {
224
+ if (bodyBuffer !== undefined) {
225
+ res.status(status).buffer(bodyBuffer);
226
+ }
227
+ else if (body !== undefined) {
233
228
  res.status(status).json(body);
234
229
  }
235
230
  else {
@@ -247,33 +242,21 @@ class MockServer {
247
242
  sendResponse(delay);
248
243
  });
249
244
  }
250
- /**
251
- * Resets all custom route handlers, restoring all default handlers.
252
- * Also clears request tracking data.
253
- */
245
+ /** Restores default handlers and clears request tracking data. */
254
246
  resetRoutes() {
255
247
  this.routeHandlers.clear();
256
248
  this.requestCounts.clear();
257
249
  this.requests = [];
258
250
  }
259
- /**
260
- * Returns the most recent request or undefined if no requests exist.
261
- */
262
251
  getLastRequest() {
263
252
  if (this.requests.length === 0) {
264
253
  return undefined;
265
254
  }
266
255
  return this.requests[this.requests.length - 1];
267
256
  }
268
- /**
269
- * Gets the number of requests made to a specific endpoint.
270
- */
271
257
  getRequestCount(method, path) {
272
258
  return this.getRequests(method, path).length;
273
259
  }
274
- /**
275
- * Gets all requests made to a specific endpoint.
276
- */
277
260
  getRequests(method, path) {
278
261
  const pathWithoutQuery = path.split('?')[0];
279
262
  return this.requests.filter((req) => req.method.toUpperCase() === method.toUpperCase() &&
@@ -1,22 +1,11 @@
1
- /**
2
- * ErrorRecord is an interface that defines the structure of an error record.
3
- */
4
1
  export interface ErrorRecord {
5
2
  message: string;
6
3
  }
7
- /**
8
- * InitialDomainMapping is an interface that defines the structure of the initial domain mapping.
9
- */
10
4
  export interface InitialDomainMapping {
11
5
  starting_recipe_blueprint?: object;
12
6
  additional_mappings?: object;
13
7
  }
14
- /**
15
- * SyncMode is an enum that defines the different modes of sync that can be used by the external extractor.
16
- * It can be either INITIAL, INCREMENTAL or LOADING. INITIAL mode is used for
17
- * the first/initial import, while INCREMENTAL mode is used for doing syncs. LOADING mode is used for
18
- * loading data from DevRev to the external system.
19
- */
8
+ /** INITIAL = first import, INCREMENTAL = subsequent syncs, LOADING = DevRev -> external system. */
20
9
  export declare enum SyncMode {
21
10
  INITIAL = "INITIAL",
22
11
  INCREMENTAL = "INCREMENTAL",
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/types/common.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;;;;GAKG;AACH,oBAAY,QAAQ;IAClB,OAAO,YAAY;IACnB,WAAW,gBAAgB;IAC3B,OAAO,YAAY;CACpB"}
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/types/common.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,oBAAoB;IACnC,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,mGAAmG;AACnG,oBAAY,QAAQ;IAClB,OAAO,YAAY;IACnB,WAAW,gBAAgB;IAC3B,OAAO,YAAY;CACpB"}
@@ -1,12 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SyncMode = void 0;
4
- /**
5
- * SyncMode is an enum that defines the different modes of sync that can be used by the external extractor.
6
- * It can be either INITIAL, INCREMENTAL or LOADING. INITIAL mode is used for
7
- * the first/initial import, while INCREMENTAL mode is used for doing syncs. LOADING mode is used for
8
- * loading data from DevRev to the external system.
9
- */
4
+ /** INITIAL = first import, INCREMENTAL = subsequent syncs, LOADING = DevRev -> external system. */
10
5
  var SyncMode;
11
6
  (function (SyncMode) {
12
7
  SyncMode["INITIAL"] = "INITIAL";