@devrev/ts-adaas 1.20.2-beta.0 → 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,
|
|
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"}
|
package/dist/state/state.js
CHANGED
|
@@ -97,11 +97,26 @@ async function createAdapterState({ event, initialState, initialDomainMapping, o
|
|
|
97
97
|
process.exit(1);
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
+
else if (target === 'extract_from' &&
|
|
101
|
+
eventContext.extract_from === undefined &&
|
|
102
|
+
as.state.lastSuccessfulSyncStarted) {
|
|
103
|
+
eventContext.extract_from = as.state.lastSuccessfulSyncStarted;
|
|
104
|
+
as.state.pendingWorkersOldest = as.state.lastSuccessfulSyncStarted;
|
|
105
|
+
console.log(`Using lastSuccessfulSyncStarted as extract_from: ${as.state.lastSuccessfulSyncStarted}.`);
|
|
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
|
+
}
|
|
100
114
|
}
|
|
101
115
|
}
|
|
102
116
|
else {
|
|
103
117
|
// Non-StartExtractingMetadata events: reuse pending values from state
|
|
104
|
-
if (
|
|
118
|
+
if (eventContext.extract_from === undefined &&
|
|
119
|
+
as.state.pendingWorkersOldest) {
|
|
105
120
|
eventContext.extract_from = as.state.pendingWorkersOldest;
|
|
106
121
|
console.log(`Reusing pendingWorkersOldest as extract_from: ${as.state.pendingWorkersOldest}.`);
|
|
107
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, {
|
|
@@ -106,6 +136,36 @@ describe('State — TimeValue resolution', () => {
|
|
|
106
136
|
expect(event.payload.event_context.extract_to).toBe('2025-06-01T00:00:00.000Z');
|
|
107
137
|
expect(state.state.pendingWorkersNewest).toBe('2025-06-01T00:00:00.000Z');
|
|
108
138
|
});
|
|
139
|
+
it('should use lastSuccessfulSyncStarted for extract_from when extraction_start_time has no type', async () => {
|
|
140
|
+
// Arrange: platform sends an empty extraction_start_time on a subsequent sync
|
|
141
|
+
const lastSuccessfulSyncStarted = '2025-05-01T00:00:00.000Z';
|
|
142
|
+
const event = (0, test_utils_1.createMockEvent)(jest_setup_1.mockServer.baseUrl, {
|
|
143
|
+
context: {
|
|
144
|
+
snap_in_version_id: 'test_snap_in_version_id',
|
|
145
|
+
},
|
|
146
|
+
payload: {
|
|
147
|
+
event_type: extraction_1.EventType.StartExtractingMetadata,
|
|
148
|
+
event_context: {
|
|
149
|
+
extraction_start_time: {},
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
fetchStateSpy.mockResolvedValue({
|
|
154
|
+
state: JSON.stringify({
|
|
155
|
+
snapInVersionId: 'test_snap_in_version_id',
|
|
156
|
+
lastSuccessfulSyncStarted,
|
|
157
|
+
}),
|
|
158
|
+
});
|
|
159
|
+
// Act
|
|
160
|
+
const state = await (0, state_1.createAdapterState)({
|
|
161
|
+
event,
|
|
162
|
+
initialState: {},
|
|
163
|
+
initialDomainMapping: {},
|
|
164
|
+
});
|
|
165
|
+
// Assert: the fallback is also stored for the following data phase
|
|
166
|
+
expect(event.payload.event_context.extract_from).toBe(lastSuccessfulSyncStarted);
|
|
167
|
+
expect(state.state.pendingWorkersOldest).toBe(lastSuccessfulSyncStarted);
|
|
168
|
+
});
|
|
109
169
|
it('should skip resolution when extraction_end_time has no type', async () => {
|
|
110
170
|
// Arrange: platform sends extraction_end_time without a type field
|
|
111
171
|
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
|
-
*
|
|
298
|
-
*
|
|
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