@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
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateRange = updateRange;
4
+ exports.toValidTimestamp = toValidTimestamp;
5
+ function updateRange(range, ms) {
6
+ if (range.oldest === undefined || ms < range.oldest) {
7
+ range.oldest = ms;
8
+ }
9
+ if (range.newest === undefined || ms > range.newest) {
10
+ range.newest = ms;
11
+ }
12
+ }
13
+ function toValidTimestamp(value) {
14
+ const ms = new Date(value).getTime();
15
+ return Number.isFinite(ms) ? ms : undefined;
16
+ }
@@ -1,17 +1,12 @@
1
- import { Artifact } from '../uploader/uploader.interfaces';
2
1
  import { AirSyncEvent } from '../types/extraction';
3
2
  import { WorkerAdapterOptions } from '../types/workers';
4
- /**
5
- * RepoInterface is an interface that defines the structure of a repo which is used to store and upload extracted data.
6
- */
3
+ import { Artifact } from '../uploader/uploader.interfaces';
4
+ /** Stores and uploads extracted data. */
7
5
  export interface RepoInterface {
8
6
  itemType: string;
9
7
  normalize?: (record: object) => NormalizedItem | NormalizedAttachment;
10
8
  overridenOptions?: WorkerAdapterOptions;
11
9
  }
12
- /**
13
- * RepoFactoryInterface is an interface that defines the structure of a repo factory which is used to create a repo.
14
- */
15
10
  export interface RepoFactoryInterface {
16
11
  event: AirSyncEvent;
17
12
  itemType: string;
@@ -19,18 +14,12 @@ export interface RepoFactoryInterface {
19
14
  onUpload: (artifact: Artifact) => void;
20
15
  options?: WorkerAdapterOptions;
21
16
  }
22
- /**
23
- * NormalizedItem is an interface of item after normalization.
24
- */
25
17
  export interface NormalizedItem {
26
18
  id: string;
27
19
  created_date: string;
28
20
  modified_date: string;
29
21
  data: object;
30
22
  }
31
- /**
32
- * NormalizedAttachment is an interface of attachment after normalization.
33
- */
34
23
  export interface NormalizedAttachment {
35
24
  url: string;
36
25
  id: string;
@@ -39,10 +28,9 @@ export interface NormalizedAttachment {
39
28
  author_id?: string;
40
29
  inline?: boolean;
41
30
  content_type?: string;
31
+ created_date?: string;
32
+ modified_date?: string;
42
33
  grand_parent_id?: number | string;
43
34
  }
44
- /**
45
- * Item is an interface that defines the structure of an item.
46
- */
47
35
  export type Item = Record<string, any>;
48
36
  //# sourceMappingURL=repo.interfaces.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"repo.interfaces.d.ts","sourceRoot":"","sources":["../../src/repo/repo.interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,cAAc,GAAG,oBAAoB,CAAC;IACtE,gBAAgB,CAAC,EAAE,oBAAoB,CAAC;CACzC;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,YAAY,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,cAAc,GAAG,oBAAoB,CAAC;IACtE,QAAQ,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAC;IACvC,OAAO,CAAC,EAAE,oBAAoB,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IAC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,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IAGvB,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACnC;AAGD,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC"}
package/dist/repo/repo.js CHANGED
@@ -3,9 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Repo = void 0;
4
4
  const constants_1 = require("../common/constants");
5
5
  const uploader_1 = require("../uploader/uploader");
6
- const logger_1 = require("../logger/logger");
6
+ const repo_helpers_1 = require("./repo.helpers");
7
7
  class Repo {
8
8
  constructor({ event, itemType, normalize, onUpload, options, }) {
9
+ this.dateRanges = {
10
+ creationDate: {},
11
+ modifiedDate: {},
12
+ };
9
13
  this.items = [];
10
14
  this.itemType = itemType;
11
15
  this.normalize = normalize;
@@ -20,6 +24,22 @@ class Repo {
20
24
  async upload(batch) {
21
25
  const itemsToUpload = batch || this.items;
22
26
  if (itemsToUpload.length > 0) {
27
+ for (const item of itemsToUpload) {
28
+ const createdDate = item === null || item === void 0 ? void 0 : item.created_date;
29
+ if (createdDate != null) {
30
+ const createdMs = (0, repo_helpers_1.toValidTimestamp)(createdDate);
31
+ if (createdMs !== undefined) {
32
+ (0, repo_helpers_1.updateRange)(this.dateRanges.creationDate, createdMs);
33
+ }
34
+ }
35
+ const modifiedDate = item === null || item === void 0 ? void 0 : item.modified_date;
36
+ if (modifiedDate != null && modifiedDate !== '') {
37
+ const modifiedMs = (0, repo_helpers_1.toValidTimestamp)(modifiedDate);
38
+ if (modifiedMs !== undefined) {
39
+ (0, repo_helpers_1.updateRange)(this.dateRanges.modifiedDate, modifiedMs);
40
+ }
41
+ }
42
+ }
23
43
  console.log(`Uploading ${itemsToUpload.length} items of type ${this.itemType}. `);
24
44
  const { artifact, error } = await this.uploader.upload(this.itemType, itemsToUpload);
25
45
  if (error || !artifact) {
@@ -28,7 +48,7 @@ class Repo {
28
48
  }
29
49
  this.onUpload(artifact);
30
50
  this.uploadedArtifacts.push(artifact);
31
- // Clear the uploaded items from the main items array if no batch was specified
51
+ // An explicit batch was already spliced out of this.items by the caller
32
52
  if (!batch) {
33
53
  this.items = [];
34
54
  }
@@ -45,24 +65,19 @@ class Repo {
45
65
  console.log(`No items to push for type ${this.itemType}. Skipping push.`);
46
66
  return true;
47
67
  }
48
- // Normalize items if needed
49
68
  if (this.normalize &&
50
69
  this.itemType != constants_1.AirSyncDefaultItemTypes.EXTERNAL_DOMAIN_METADATA &&
51
70
  this.itemType != constants_1.SSOR_ATTACHMENT) {
52
- recordsToPush = (0, logger_1.runWithUserLogContext)(() => items.map((item) => this.normalize(item)));
71
+ recordsToPush = items.map((item) => this.normalize(item));
53
72
  }
54
73
  else {
55
74
  recordsToPush = items;
56
75
  }
57
- // Add the new records to the items array
58
76
  this.items.push(...recordsToPush);
59
- // Upload in batches while the number of items exceeds the batch size
60
77
  const batchSize = ((_a = this.options) === null || _a === void 0 ? void 0 : _a.batchSize) || constants_1.ARTIFACT_BATCH_SIZE;
61
78
  while (this.items.length >= batchSize) {
62
- // Slice out a batch of batchSize items to upload
63
79
  const batch = this.items.splice(0, batchSize);
64
80
  try {
65
- // Upload the batch
66
81
  await this.upload(batch);
67
82
  }
68
83
  catch (error) {
@@ -3,14 +3,9 @@ import { AirSyncEvent } from '../types/extraction';
3
3
  import { ExtractionScope } from '../types/workers';
4
4
  import { SdkState, StateInterface } from './state.interfaces';
5
5
  /**
6
- * BaseState owns the state lifecycle shared by every sync mode: connector vs.
7
- * SDK state separation, fetch/init/post against the platform, the v1->v2
8
- * migration shim, and the snap-in-version-gated initial domain mapping install.
9
- *
10
- * Mode-specific subclasses (`ExtractionState`, `LoadingState`) seed the
11
- * SDK-owned portion of the state and add mode-specific setup in their factories.
12
- *
13
- * @typeParam ConnectorState - the connector-owned state shape
6
+ * State lifecycle shared by all sync modes: connector/SDK state separation,
7
+ * fetch/init/post, the v1->v2 migration shim, and the snap-in-version-gated
8
+ * initial domain mapping install. Subclasses seed the SDK-owned state.
14
9
  */
15
10
  export declare abstract class BaseState<ConnectorState> {
16
11
  protected _connectorState: ConnectorState;
@@ -23,7 +18,7 @@ export declare abstract class BaseState<ConnectorState> {
23
18
  private syncUnitId;
24
19
  private requestId;
25
20
  constructor({ event, initialState }: StateInterface<ConnectorState>, initialSdkState: SdkState);
26
- /** Connector-owned state. This is what `adapter.state` exposes to snap-in code. */
21
+ /** Connector-owned state; what `adapter.state` exposes to snap-in code. */
27
22
  get state(): ConnectorState;
28
23
  set state(value: ConnectorState);
29
24
  /** SDK-internal bookkeeping state. Never exposed to connector code. */
@@ -31,42 +26,25 @@ export declare abstract class BaseState<ConnectorState> {
31
26
  set sdkState(value: SdkState);
32
27
  get extractionScope(): ExtractionScope;
33
28
  /**
34
- * Installs the initial domain mapping when the snap-in version in state does
35
- * not match the version in the event context. Shared by all modes so that a
36
- * loading run still installs the mapping if extraction has not done so.
37
- * @param initialDomainMapping The initial domain mapping passed to spawn
29
+ * Installs the initial domain mapping when the snap-in version in state
30
+ * differs from the event context. Shared by all modes so a loading run still
31
+ * installs the mapping if extraction has not done so.
38
32
  */
39
33
  installInitialDomainMappingIfNeeded(initialDomainMapping?: InitialDomainMapping): Promise<void>;
40
34
  /**
41
- * Initializes the state for this adapter instance by fetching from API
42
- * or creating an initial state if none exists (404).
43
- *
44
- * Reads both the v2 `{ connectorState, sdkState }` envelope and a legacy flat
45
- * v1 blob (connector keys merged with SDK keys), migrating the latter on read.
46
- * Always persists the v2 envelope going forward.
47
- * @param initialState The initial connector state provided by the spawn function
35
+ * Fetches state from API, or creates the initial state on 404. Reads both
36
+ * the v2 envelope and a legacy flat v1 blob (migrated on read); always
37
+ * persists the v2 envelope going forward.
48
38
  */
49
39
  init(initialState: ConnectorState): Promise<void>;
50
40
  /**
51
- * Normalizes a parsed on-disk state into the `{ connectorState, sdkState }`
52
- * envelope, migrating a legacy flat v1 blob if needed.
53
- *
54
- * - v2 envelope (`{ connectorState, sdkState }`): used as-is.
55
- * - v1 flat blob: SDK-owned keys (`V1_SDK_STATE_KEYS`) split into `sdkState`,
56
- * everything else becomes connector state.
57
- * - Malformed envelope (one side present, the other missing) fails loud.
41
+ * Normalizes fetched state into the `{ connectorState, sdkState }` envelope.
42
+ * A flat v1 blob is split by `V1_SDK_STATE_KEYS`; an envelope with only one
43
+ * side present fails loud.
58
44
  */
59
45
  private normalizeFetchedState;
60
- /**
61
- * Updates the state of the adapter by posting to API.
62
- * Persists the v2 `{ connectorState, sdkState }` envelope.
63
- * @param {object} state - The connector state to be updated
64
- */
46
+ /** Posts the v2 `{ connectorState, sdkState }` envelope to the API. */
65
47
  postState(state?: ConnectorState): Promise<void>;
66
- /**
67
- * Fetches the state of the adapter from API.
68
- * @return The raw state data from API
69
- */
70
48
  fetchState(): Promise<{
71
49
  state: string;
72
50
  objects?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"base-state.d.ts","sourceRoot":"","sources":["../../src/state/base-state.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAEL,QAAQ,EACR,cAAc,EAEf,MAAM,oBAAoB,CAAC;AAE5B;;;;;;;;;GASG;AACH,8BAAsB,SAAS,CAAC,cAAc;IAC5C,SAAS,CAAC,eAAe,EAAE,cAAc,CAAC;IAC1C,SAAS,CAAC,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AAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAqBjE"}
@@ -4,22 +4,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.BaseState = void 0;
7
- const axios_1 = __importDefault(require("axios"));
8
7
  const node_worker_threads_1 = require("node:worker_threads");
9
- const install_initial_domain_mapping_1 = require("./install-initial-domain-mapping");
8
+ const axios_1 = __importDefault(require("axios"));
10
9
  const client_1 = require("../http/client");
11
10
  const logger_1 = require("../logger/logger");
12
11
  const workers_1 = require("../types/workers");
12
+ const install_initial_domain_mapping_1 = require("./install-initial-domain-mapping");
13
13
  const state_interfaces_1 = require("./state.interfaces");
14
14
  /**
15
- * BaseState owns the state lifecycle shared by every sync mode: connector vs.
16
- * SDK state separation, fetch/init/post against the platform, the v1->v2
17
- * migration shim, and the snap-in-version-gated initial domain mapping install.
18
- *
19
- * Mode-specific subclasses (`ExtractionState`, `LoadingState`) seed the
20
- * SDK-owned portion of the state and add mode-specific setup in their factories.
21
- *
22
- * @typeParam ConnectorState - the connector-owned state shape
15
+ * State lifecycle shared by all sync modes: connector/SDK state separation,
16
+ * fetch/init/post, the v1->v2 migration shim, and the snap-in-version-gated
17
+ * initial domain mapping install. Subclasses seed the SDK-owned state.
23
18
  */
24
19
  class BaseState {
25
20
  constructor({ event, initialState }, initialSdkState) {
@@ -33,7 +28,7 @@ class BaseState {
33
28
  this.syncUnitId = event.payload.event_context.sync_unit_id;
34
29
  this.requestId = event.payload.event_context.request_id_adaas;
35
30
  }
36
- /** Connector-owned state. This is what `adapter.state` exposes to snap-in code. */
31
+ /** Connector-owned state; what `adapter.state` exposes to snap-in code. */
37
32
  get state() {
38
33
  return this._connectorState;
39
34
  }
@@ -51,10 +46,9 @@ class BaseState {
51
46
  return this._extractionScope;
52
47
  }
53
48
  /**
54
- * Installs the initial domain mapping when the snap-in version in state does
55
- * not match the version in the event context. Shared by all modes so that a
56
- * loading run still installs the mapping if extraction has not done so.
57
- * @param initialDomainMapping The initial domain mapping passed to spawn
49
+ * Installs the initial domain mapping when the snap-in version in state
50
+ * differs from the event context. Shared by all modes so a loading run still
51
+ * installs the mapping if extraction has not done so.
58
52
  */
59
53
  async installInitialDomainMappingIfNeeded(initialDomainMapping) {
60
54
  const snapInVersionId = this.event.context.snap_in_version_id;
@@ -86,13 +80,9 @@ class BaseState {
86
80
  }
87
81
  }
88
82
  /**
89
- * Initializes the state for this adapter instance by fetching from API
90
- * or creating an initial state if none exists (404).
91
- *
92
- * Reads both the v2 `{ connectorState, sdkState }` envelope and a legacy flat
93
- * v1 blob (connector keys merged with SDK keys), migrating the latter on read.
94
- * Always persists the v2 envelope going forward.
95
- * @param initialState The initial connector state provided by the spawn function
83
+ * Fetches state from API, or creates the initial state on 404. Reads both
84
+ * the v2 envelope and a legacy flat v1 blob (migrated on read); always
85
+ * persists the v2 envelope going forward.
96
86
  */
97
87
  async init(initialState) {
98
88
  var _a;
@@ -143,13 +133,9 @@ class BaseState {
143
133
  }
144
134
  }
145
135
  /**
146
- * Normalizes a parsed on-disk state into the `{ connectorState, sdkState }`
147
- * envelope, migrating a legacy flat v1 blob if needed.
148
- *
149
- * - v2 envelope (`{ connectorState, sdkState }`): used as-is.
150
- * - v1 flat blob: SDK-owned keys (`V1_SDK_STATE_KEYS`) split into `sdkState`,
151
- * everything else becomes connector state.
152
- * - Malformed envelope (one side present, the other missing) fails loud.
136
+ * Normalizes fetched state into the `{ connectorState, sdkState }` envelope.
137
+ * A flat v1 blob is split by `V1_SDK_STATE_KEYS`; an envelope with only one
138
+ * side present fails loud.
153
139
  */
154
140
  normalizeFetchedState(parsed) {
155
141
  if (parsed === null || typeof parsed !== 'object') {
@@ -183,11 +169,7 @@ class BaseState {
183
169
  sdkState: Object.assign(Object.assign({}, this.initialSdkState), sdkState),
184
170
  };
185
171
  }
186
- /**
187
- * Updates the state of the adapter by posting to API.
188
- * Persists the v2 `{ connectorState, sdkState }` envelope.
189
- * @param {object} state - The connector state to be updated
190
- */
172
+ /** Posts the v2 `{ connectorState, sdkState }` envelope to the API. */
191
173
  async postState(state) {
192
174
  const url = this.workerUrl + '.update';
193
175
  this.state = state || this.state;
@@ -235,10 +217,6 @@ class BaseState {
235
217
  process.exit(1);
236
218
  }
237
219
  }
238
- /**
239
- * Fetches the state of the adapter from API.
240
- * @return The raw state data from API
241
- */
242
220
  async fetchState() {
243
221
  var _a, _b;
244
222
  console.log(`Fetching state with sync unit id ${this.syncUnitId} and request id ${this.requestId}.`);
@@ -1,29 +1,14 @@
1
1
  import { BaseState } from './base-state';
2
2
  import { StateInterface } from './state.interfaces';
3
- /**
4
- * ExtractionState is the per-mode state for extraction workers. It seeds the
5
- * extraction SDK state (extraction boundaries + attachments bookkeeping) on top
6
- * of the shared lifecycle provided by `BaseState` and adds extraction-window
7
- * resolution.
8
- */
3
+ /** State for extraction workers: seeds extraction SDK state and adds extraction-window resolution. */
9
4
  export declare class ExtractionState<ConnectorState> extends BaseState<ConnectorState> {
10
5
  constructor(params: StateInterface<ConnectorState>);
11
6
  /**
12
- * Resolves the extraction window onto the event context.
13
- *
14
- * On StartExtractingMetadata: resolve fresh from the TimeValue objects in the
15
- * event context and cache them as pending boundaries (always overwrite).
16
- * On all other events: reuse the pending boundaries cached during
17
- * StartExtractingMetadata. Finally, validate that extract_from < extract_to.
7
+ * Resolves the extraction window onto the event context. StartExtractingMetadata
8
+ * resolves fresh from the event's TimeValues and overwrites the pending boundaries;
9
+ * all other events reuse those cached boundaries. Validates extract_from < extract_to.
18
10
  */
19
11
  resolveExtractionWindow(): void;
20
12
  }
21
- /**
22
- * Creates and initializes an `ExtractionState` for an extraction worker.
23
- *
24
- * For non-stateless events this fetches persisted state, installs the initial
25
- * domain mapping if the snap-in version changed, then resolves the extraction
26
- * window (time-value resolution + pending boundary reuse) and validates it.
27
- */
28
13
  export declare function createExtractionState<ConnectorState>({ event, initialState, initialDomainMapping, options, }: StateInterface<ConnectorState>): Promise<ExtractionState<ConnectorState>>;
29
14
  //# sourceMappingURL=extraction-state.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"extraction-state.d.ts","sourceRoot":"","sources":["../../src/state/extraction-state.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAsB,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAExE;;;;;GAKG;AACH,qBAAa,eAAe,CAAC,cAAc,CAAE,SAAQ,SAAS,CAAC,cAAc,CAAC;gBAChE,MAAM,EAAE,cAAc,CAAC,cAAc,CAAC;IAIlD;;;;;;;OAOG;IACH,uBAAuB,IAAI,IAAI;CA+EhC;AAED;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CAAC,cAAc,EAAE,EAC1D,KAAK,EACL,YAAY,EACZ,oBAAoB,EACpB,OAAO,GACR,EAAE,cAAc,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC,CAkB3E"}
1
+ {"version":3,"file":"extraction-state.d.ts","sourceRoot":"","sources":["../../src/state/extraction-state.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAsB,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGxE,sGAAsG;AACtG,qBAAa,eAAe,CAAC,cAAc,CAAE,SAAQ,SAAS,CAAC,cAAc,CAAC;gBAChE,MAAM,EAAE,cAAc,CAAC,cAAc,CAAC;IAIlD;;;;OAIG;IACH,uBAAuB,IAAI,IAAI;CA6EhC;AAED,wBAAsB,qBAAqB,CAAC,cAAc,EAAE,EAC1D,KAAK,EACL,YAAY,EACZ,oBAAoB,EACpB,OAAO,GACR,EAAE,cAAc,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC,CAkB3E"}
@@ -4,29 +4,21 @@ exports.ExtractionState = void 0;
4
4
  exports.createExtractionState = createExtractionState;
5
5
  const node_worker_threads_1 = require("node:worker_threads");
6
6
  const constants_1 = require("../common/constants");
7
- const time_value_resolver_1 = require("./time-value-resolver");
8
7
  const logger_1 = require("../logger/logger");
9
8
  const extraction_1 = require("../types/extraction");
10
9
  const workers_1 = require("../types/workers");
11
10
  const base_state_1 = require("./base-state");
12
11
  const state_interfaces_1 = require("./state.interfaces");
13
- /**
14
- * ExtractionState is the per-mode state for extraction workers. It seeds the
15
- * extraction SDK state (extraction boundaries + attachments bookkeeping) on top
16
- * of the shared lifecycle provided by `BaseState` and adds extraction-window
17
- * resolution.
18
- */
12
+ const time_value_resolver_1 = require("./time-value-resolver");
13
+ /** State for extraction workers: seeds extraction SDK state and adds extraction-window resolution. */
19
14
  class ExtractionState extends base_state_1.BaseState {
20
15
  constructor(params) {
21
16
  super(params, state_interfaces_1.extractionSdkState);
22
17
  }
23
18
  /**
24
- * Resolves the extraction window onto the event context.
25
- *
26
- * On StartExtractingMetadata: resolve fresh from the TimeValue objects in the
27
- * event context and cache them as pending boundaries (always overwrite).
28
- * On all other events: reuse the pending boundaries cached during
29
- * StartExtractingMetadata. Finally, validate that extract_from < extract_to.
19
+ * Resolves the extraction window onto the event context. StartExtractingMetadata
20
+ * resolves fresh from the event's TimeValues and overwrites the pending boundaries;
21
+ * all other events reuse those cached boundaries. Validates extract_from < extract_to.
30
22
  */
31
23
  resolveExtractionWindow() {
32
24
  const sdkState = this.sdkState;
@@ -66,7 +58,6 @@ class ExtractionState extends base_state_1.BaseState {
66
58
  }
67
59
  }
68
60
  else {
69
- // Non-StartExtractingMetadata events: reuse pending values from state
70
61
  if (sdkState.pendingWorkersOldest) {
71
62
  eventContext.extract_from = sdkState.pendingWorkersOldest;
72
63
  console.log(`Reusing pendingWorkersOldest as extract_from: ${sdkState.pendingWorkersOldest}.`);
@@ -82,7 +73,6 @@ class ExtractionState extends base_state_1.BaseState {
82
73
  console.log('pendingWorkersNewest is not set in state. extract_to will not be populated for this invocation.');
83
74
  }
84
75
  }
85
- // Validate that extract_from is before extract_to
86
76
  if (eventContext.extract_from && eventContext.extract_to) {
87
77
  if (eventContext.extract_from >= eventContext.extract_to) {
88
78
  const errorMessage = `Invalid extraction window: extract_from (${eventContext.extract_from}) must be older than extract_to (${eventContext.extract_to}). This indicates an error in the platform.`;
@@ -97,15 +87,8 @@ class ExtractionState extends base_state_1.BaseState {
97
87
  }
98
88
  }
99
89
  exports.ExtractionState = ExtractionState;
100
- /**
101
- * Creates and initializes an `ExtractionState` for an extraction worker.
102
- *
103
- * For non-stateless events this fetches persisted state, installs the initial
104
- * domain mapping if the snap-in version changed, then resolves the extraction
105
- * window (time-value resolution + pending boundary reuse) and validates it.
106
- */
107
90
  async function createExtractionState({ event, initialState, initialDomainMapping, options, }) {
108
- // Deep clone the initial state to avoid mutating the original state
91
+ // Clone so the caller's initialState is never mutated.
109
92
  const deepCloneInitialState = structuredClone(initialState);
110
93
  const state = new ExtractionState({
111
94
  event,
@@ -1,4 +1,4 @@
1
- import { AirSyncEvent } from '../types/extraction';
2
1
  import { InitialDomainMapping } from '../types/common';
2
+ import { AirSyncEvent } from '../types/extraction';
3
3
  export declare function installInitialDomainMapping(event: AirSyncEvent, initialDomainMappingJson: InitialDomainMapping): Promise<void>;
4
4
  //# sourceMappingURL=install-initial-domain-mapping.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"install-initial-domain-mapping.d.ts","sourceRoot":"","sources":["../../src/state/install-initial-domain-mapping.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEvD,wBAAsB,2BAA2B,CAC/C,KAAK,EAAE,YAAY,EACnB,wBAAwB,EAAE,oBAAoB,GAC7C,OAAO,CAAC,IAAI,CAAC,CA0Ff"}
1
+ {"version":3,"file":"install-initial-domain-mapping.d.ts","sourceRoot":"","sources":["../../src/state/install-initial-domain-mapping.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,wBAAsB,2BAA2B,CAC/C,KAAK,EAAE,YAAY,EACnB,wBAAwB,EAAE,oBAAoB,GAC7C,OAAO,CAAC,IAAI,CAAC,CAwFf"}
@@ -12,7 +12,6 @@ async function installInitialDomainMapping(event, initialDomainMappingJson) {
12
12
  console.warn('No initial domain mapping found.');
13
13
  return;
14
14
  }
15
- // Get snap-in details
16
15
  const snapInResponse = await client_1.axiosClient.get(devrevEndpoint + '/internal/snap-ins.get', {
17
16
  headers: {
18
17
  Authorization: devrevToken,
@@ -28,7 +27,7 @@ async function installInitialDomainMapping(event, initialDomainMappingJson) {
28
27
  throw new Error(errorMessage);
29
28
  }
30
29
  const startingRecipeBlueprint = initialDomainMappingJson === null || initialDomainMappingJson === void 0 ? void 0 : initialDomainMappingJson.starting_recipe_blueprint;
31
- // Try to create a recipe blueprint
30
+ // Recipe blueprint creation is best-effort; install proceeds without it.
32
31
  let recipeBlueprintId;
33
32
  if (startingRecipeBlueprint &&
34
33
  Object.keys(startingRecipeBlueprint).length !== 0) {
@@ -45,7 +44,6 @@ async function installInitialDomainMapping(event, initialDomainMappingJson) {
45
44
  console.warn('Error while creating recipe blueprint. Continuing without it.', (0, logger_1.serializeError)(error));
46
45
  }
47
46
  }
48
- // Install the initial domain mappings
49
47
  const additionalMappings = initialDomainMappingJson.additional_mappings || {};
50
48
  const initialDomainMappingInstallResponse = await client_1.axiosClient.post(`${devrevEndpoint}/internal/airdrop.recipe.initial-domain-mappings.install`, Object.assign(Object.assign({ external_system_type: 'ADaaS', import_slug: importSlug, snap_in_slug: snapInSlug }, (recipeBlueprintId && {
51
49
  starting_recipe_blueprint: recipeBlueprintId,
@@ -1,18 +1,8 @@
1
1
  import { BaseState } from './base-state';
2
2
  import { StateInterface } from './state.interfaces';
3
- /**
4
- * LoadingState is the per-mode state for loading workers. It seeds the loading
5
- * SDK state (files-to-load bookkeeping) on top of the shared lifecycle provided
6
- * by `BaseState`. Loading has no extraction-window resolution.
7
- */
3
+ /** State for loading workers: seeds loading SDK state; no extraction-window resolution. */
8
4
  export declare class LoadingState<ConnectorState> extends BaseState<ConnectorState> {
9
5
  constructor(params: StateInterface<ConnectorState>);
10
6
  }
11
- /**
12
- * Creates and initializes a `LoadingState` for a loading worker.
13
- *
14
- * For non-stateless events this fetches persisted state and installs the
15
- * initial domain mapping if the snap-in version changed.
16
- */
17
7
  export declare function createLoadingState<ConnectorState>({ event, initialState, initialDomainMapping, options, }: StateInterface<ConnectorState>): Promise<LoadingState<ConnectorState>>;
18
8
  //# sourceMappingURL=loading-state.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"loading-state.d.ts","sourceRoot":"","sources":["../../src/state/loading-state.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAmB,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAErE;;;;GAIG;AACH,qBAAa,YAAY,CAAC,cAAc,CAAE,SAAQ,SAAS,CAAC,cAAc,CAAC;gBAC7D,MAAM,EAAE,cAAc,CAAC,cAAc,CAAC;CAGnD;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CAAC,cAAc,EAAE,EACvD,KAAK,EACL,YAAY,EACZ,oBAAoB,EACpB,OAAO,GACR,EAAE,cAAc,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC,CAiBxE"}
1
+ {"version":3,"file":"loading-state.d.ts","sourceRoot":"","sources":["../../src/state/loading-state.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAmB,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAErE,2FAA2F;AAC3F,qBAAa,YAAY,CAAC,cAAc,CAAE,SAAQ,SAAS,CAAC,cAAc,CAAC;gBAC7D,MAAM,EAAE,cAAc,CAAC,cAAc,CAAC;CAGnD;AAED,wBAAsB,kBAAkB,CAAC,cAAc,EAAE,EACvD,KAAK,EACL,YAAY,EACZ,oBAAoB,EACpB,OAAO,GACR,EAAE,cAAc,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC,CAiBxE"}
@@ -5,25 +5,15 @@ exports.createLoadingState = createLoadingState;
5
5
  const constants_1 = require("../common/constants");
6
6
  const base_state_1 = require("./base-state");
7
7
  const state_interfaces_1 = require("./state.interfaces");
8
- /**
9
- * LoadingState is the per-mode state for loading workers. It seeds the loading
10
- * SDK state (files-to-load bookkeeping) on top of the shared lifecycle provided
11
- * by `BaseState`. Loading has no extraction-window resolution.
12
- */
8
+ /** State for loading workers: seeds loading SDK state; no extraction-window resolution. */
13
9
  class LoadingState extends base_state_1.BaseState {
14
10
  constructor(params) {
15
11
  super(params, state_interfaces_1.loadingSdkState);
16
12
  }
17
13
  }
18
14
  exports.LoadingState = LoadingState;
19
- /**
20
- * Creates and initializes a `LoadingState` for a loading worker.
21
- *
22
- * For non-stateless events this fetches persisted state and installs the
23
- * initial domain mapping if the snap-in version changed.
24
- */
25
15
  async function createLoadingState({ event, initialState, initialDomainMapping, options, }) {
26
- // Deep clone the initial state to avoid mutating the original state
16
+ // Clone so the caller's initialState is never mutated.
27
17
  const deepCloneInitialState = structuredClone(initialState);
28
18
  const state = new LoadingState({
29
19
  event,
@@ -1,4 +1,4 @@
1
1
  export { BaseState } from './base-state';
2
- export { ExtractionState, createExtractionState } from './extraction-state';
3
- export { LoadingState, createLoadingState } from './loading-state';
2
+ export { createExtractionState, ExtractionState } from './extraction-state';
3
+ export { createLoadingState, LoadingState } from './loading-state';
4
4
  //# sourceMappingURL=state.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/state/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/state/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC"}
@@ -3,25 +3,15 @@ import { AirSyncEvent } from '../types/extraction';
3
3
  import { FileToLoad } from '../types/loading';
4
4
  import { WorkerAdapterOptions } from '../types/workers';
5
5
  export interface SdkState {
6
- /** The pending (not yet committed) oldest extraction boundary (ISO 8601 timestamp).
7
- * Set on StartExtractingMetadata, reused across subsequent phases, cleared on AttachmentExtractionDone. */
8
6
  pendingWorkersOldest?: string;
9
- /** The pending (not yet committed) newest extraction boundary (ISO 8601 timestamp).
10
- * Set on StartExtractingMetadata, reused across subsequent phases, cleared on AttachmentExtractionDone. */
11
7
  pendingWorkersNewest?: string;
12
- /** The oldest point of extraction (ISO 8601 timestamp). */
13
8
  workersOldest?: string;
14
- /** The newest point of extraction (ISO 8601 timestamp). */
15
9
  workersNewest?: string;
16
10
  toDevRev?: ToDevRev;
17
11
  fromDevRev?: FromDevRev;
18
12
  snapInVersionId?: string;
19
13
  }
20
- /**
21
- * AdapterStateEnvelope is the v2 on-disk state shape: connector state and SDK
22
- * bookkeeping are stored as disjoint sub-objects so SDK internals stay
23
- * encapsulated and never collide with connector keys.
24
- */
14
+ /** v2 on-disk state shape: SDK bookkeeping kept disjoint from connector keys. */
25
15
  export interface AdapterStateEnvelope<ConnectorState> {
26
16
  connectorState: ConnectorState;
27
17
  sdkState: SdkState;
@@ -33,12 +23,15 @@ export interface ToDevRev {
33
23
  lastProcessedAttachmentsIdsList?: ProcessedAttachment[];
34
24
  };
35
25
  }
36
- /**
37
- * Attachment structure, that stores both attachment id and its parent_id for deduplication on the SDK side.
38
- */
26
+ export declare enum ProcessedAttachmentStatus {
27
+ Success = "success",
28
+ Failed = "failed"
29
+ }
30
+ /** id + parent_id identify an attachment for SDK-side deduplication. */
39
31
  export interface ProcessedAttachment {
40
32
  id: string;
41
33
  parent_id: string;
34
+ status: ProcessedAttachmentStatus;
42
35
  }
43
36
  export interface FromDevRev {
44
37
  filesToLoad: FileToLoad[];
@@ -70,16 +63,9 @@ export declare const loadingSdkState: {
70
63
  };
71
64
  };
72
65
  /**
73
- * The set of top-level state keys owned by the SDK. Derived from the initial
74
- * SDK state constants so it auto-updates whenever a new SDK field is added.
75
- * Used by the migration shim to split a flat v1 state blob into the
76
- * `{ connectorState, sdkState }` envelope: keys in this set go to `sdkState`,
77
- * everything else is connector state.
78
- *
79
- * `lastSyncStarted` / `lastSuccessfulSyncStarted` are retained here even though
80
- * they are no longer fields on `SdkState`: a flat v1 blob may still carry them,
81
- * and they must be recognized as SDK-owned so they are stripped out rather than
82
- * leaking into connector state during migration.
66
+ * SDK-owned top-level state keys, used to split a flat v1 blob during migration.
67
+ * `lastSyncStarted` / `lastSuccessfulSyncStarted` are no longer on `SdkState` but
68
+ * stay listed so v1 blobs carrying them don't leak them into connector state.
83
69
  */
84
70
  export declare const V1_SDK_STATE_KEYS: ReadonlySet<string>;
85
71
  //# sourceMappingURL=state.interfaces.d.ts.map