@devrev/ts-adaas 1.20.2-beta.1 → 1.20.2-beta.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/state/state.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,YAAY,EAIZ,cAAc,EACf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,wBAAsB,kBAAkB,CAAC,cAAc,EAAE,EACvD,KAAK,EACL,YAAY,EACZ,oBAAoB,EACpB,OAAO,GACR,EAAE,cAAc,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAsJjE;AAED,qBAAa,KAAK,CAAC,cAAc;IAC/B,OAAO,CAAC,MAAM,CAA+B;IAC7C,OAAO,CAAC,gBAAgB,CAAuB;IAC/C,OAAO,CAAC,eAAe,CAAW;IAClC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,SAAS,CAAS;gBAEd,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,cAAc,CAAC,cAAc,CAAC;IAenE,IAAI,KAAK,IAAI,YAAY,CAAC,cAAc,CAAC,CAExC;IAED,IAAI,KAAK,CAAC,KAAK,EAAE,YAAY,CAAC,cAAc,CAAC,EAE5C;IAED,IAAI,eAAe,IAAI,eAAe,CAErC;IAED;;;;OAIG;IACG,IAAI,CAAC,YAAY,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAiDvD;;;OAGG;IACG,SAAS,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC,cAAc,CAAC;IAqDpD;;;OAGG;IACG,UAAU,IAAI,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAqBjE"}
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/state/state.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,YAAY,EAIZ,cAAc,EACf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,wBAAsB,kBAAkB,CAAC,cAAc,EAAE,EACvD,KAAK,EACL,YAAY,EACZ,oBAAoB,EACpB,OAAO,GACR,EAAE,cAAc,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAoKjE;AAED,qBAAa,KAAK,CAAC,cAAc;IAC/B,OAAO,CAAC,MAAM,CAA+B;IAC7C,OAAO,CAAC,gBAAgB,CAAuB;IAC/C,OAAO,CAAC,eAAe,CAAW;IAClC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,SAAS,CAAS;gBAEd,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,cAAc,CAAC,cAAc,CAAC;IAenE,IAAI,KAAK,IAAI,YAAY,CAAC,cAAc,CAAC,CAExC;IAED,IAAI,KAAK,CAAC,KAAK,EAAE,YAAY,CAAC,cAAc,CAAC,EAE5C;IAED,IAAI,eAAe,IAAI,eAAe,CAErC;IAED;;;;OAIG;IACG,IAAI,CAAC,YAAY,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAiDvD;;;OAGG;IACG,SAAS,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC,cAAc,CAAC;IAqDpD;;;OAGG;IACG,UAAU,IAAI,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAqBjE"}
@@ -98,16 +98,25 @@ async function createAdapterState({ event, initialState, initialDomainMapping, o
98
98
  }
99
99
  }
100
100
  else if (target === 'extract_from' &&
101
+ eventContext.extract_from === undefined &&
101
102
  as.state.lastSuccessfulSyncStarted) {
102
103
  eventContext.extract_from = as.state.lastSuccessfulSyncStarted;
103
104
  as.state.pendingWorkersOldest = as.state.lastSuccessfulSyncStarted;
104
105
  console.log(`Using lastSuccessfulSyncStarted as extract_from: ${as.state.lastSuccessfulSyncStarted}.`);
105
106
  }
107
+ else if (target === 'extract_from' &&
108
+ eventContext.extract_from !== undefined) {
109
+ // CPv1.1 supplies the resolved boundary directly. Keep it pending so
110
+ // later extraction phases expose the same event_context value.
111
+ as.state.pendingWorkersOldest = eventContext.extract_from;
112
+ console.log(`Using platform-provided extract_from: ${eventContext.extract_from}. Stored in pendingWorkersOldest.`);
113
+ }
106
114
  }
107
115
  }
108
116
  else {
109
117
  // Non-StartExtractingMetadata events: reuse pending values from state
110
- if (as.state.pendingWorkersOldest) {
118
+ if (eventContext.extract_from === undefined &&
119
+ as.state.pendingWorkersOldest) {
111
120
  eventContext.extract_from = as.state.pendingWorkersOldest;
112
121
  console.log(`Reusing pendingWorkersOldest as extract_from: ${as.state.pendingWorkersOldest}.`);
113
122
  }
@@ -73,6 +73,36 @@ describe('State — TimeValue resolution', () => {
73
73
  });
74
74
  });
75
75
  describe('Backwards compatibility - missing TimeValue type', () => {
76
+ it('should preserve the platform extract_from when no CPv2 start time is provided', async () => {
77
+ // Arrange: CPv1.1 sends a concrete extract_from instead of a TimeValue.
78
+ const platformExtractFrom = '2025-04-01T00:00:00.000Z';
79
+ const event = (0, test_utils_1.createMockEvent)(jest_setup_1.mockServer.baseUrl, {
80
+ context: {
81
+ snap_in_version_id: 'test_snap_in_version_id',
82
+ },
83
+ payload: {
84
+ event_type: extraction_1.EventType.StartExtractingMetadata,
85
+ event_context: {
86
+ extract_from: platformExtractFrom,
87
+ },
88
+ },
89
+ });
90
+ fetchStateSpy.mockResolvedValue({
91
+ state: JSON.stringify({
92
+ snapInVersionId: 'test_snap_in_version_id',
93
+ lastSuccessfulSyncStarted: '2025-05-01T00:00:00.000Z',
94
+ }),
95
+ });
96
+ // Act
97
+ const state = await (0, state_1.createAdapterState)({
98
+ event,
99
+ initialState: {},
100
+ initialDomainMapping: {},
101
+ });
102
+ // Assert: the platform value is forwarded and retained for later phases.
103
+ expect(event.payload.event_context.extract_from).toBe(platformExtractFrom);
104
+ expect(state.state.pendingWorkersOldest).toBe(platformExtractFrom);
105
+ });
76
106
  it('should skip resolution when extraction_start_time has no type', async () => {
77
107
  // Arrange: platform sends extraction_start_time without a type field (old platform version)
78
108
  const event = (0, test_utils_1.createMockEvent)(jest_setup_1.mockServer.baseUrl, {
@@ -294,8 +294,8 @@ export interface EventContext {
294
294
  external_system_name: string;
295
295
  external_system_type: string;
296
296
  /**
297
- * Resolved start timestamp of extraction (ISO 8601 format).
298
- * Automatically computed by the SDK from extraction_start_time and worker state.
297
+ * Extraction start timestamp (ISO 8601 format), supplied directly by CPv1.1
298
+ * or resolved by the SDK from extraction_start_time and worker state for CPv2.
299
299
  * This is the field developers should read to know when to start extracting from.
300
300
  */
301
301
  extract_from?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devrev/ts-adaas",
3
- "version": "1.20.2-beta.1",
3
+ "version": "1.20.2-beta.2",
4
4
  "description": "Typescript library containing the ADaaS(AirDrop as a Service) control protocol.",
5
5
  "type": "commonjs",
6
6
  "main": "./dist/index.js",