@devrev/ts-adaas 1.17.1-beta.7 → 1.17.1-beta.8

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.
@@ -80,7 +80,7 @@ async function createAdapterState({ event, initialState, initialDomainMapping, o
80
80
  ];
81
81
  for (const { source, target, pending } of timeFields) {
82
82
  const timeValue = eventContext[source];
83
- if (timeValue) {
83
+ if (timeValue && timeValue.type) {
84
84
  try {
85
85
  const resolved = (0, time_value_resolver_1.resolveTimeValue)(timeValue, as.state);
86
86
  eventContext[target] = resolved;
@@ -280,6 +280,99 @@ describe(state_1.State.name, () => {
280
280
  expect(processExitSpy).toHaveBeenCalledWith(1);
281
281
  });
282
282
  });
283
+ describe('Backwards compatibility - missing TimeValue type', () => {
284
+ it('should skip resolution when extraction_start_time has no type', async () => {
285
+ // Arrange: platform sends extraction_start_time without a type field (old platform version)
286
+ const event = (0, test_helpers_1.createEvent)({
287
+ eventType: extraction_1.EventType.StartExtractingData,
288
+ eventContextOverrides: {
289
+ extraction_start_time: {},
290
+ extraction_end_time: {
291
+ type: extraction_1.TimeValueType.ABSOLUTE_TIME,
292
+ value: '2025-06-01T00:00:00Z',
293
+ },
294
+ },
295
+ contextOverrides: {
296
+ snap_in_version_id: 'test_snap_in_version_id',
297
+ },
298
+ });
299
+ const stringifiedState = JSON.stringify({
300
+ snapInVersionId: 'test_snap_in_version_id',
301
+ });
302
+ fetchStateSpy.mockResolvedValue({ state: stringifiedState });
303
+ jest.spyOn(console, 'log').mockImplementation(() => { });
304
+ // Act
305
+ const state = await (0, state_1.createAdapterState)({
306
+ event,
307
+ initialState: {},
308
+ initialDomainMapping: {},
309
+ });
310
+ // Assert: should not crash, extract_from is not set, extract_to is resolved
311
+ expect(processExitSpy).not.toHaveBeenCalled();
312
+ expect(event.payload.event_context.extract_from).toBeUndefined();
313
+ expect(event.payload.event_context.extract_to).toBe('2025-06-01T00:00:00.000Z');
314
+ expect(state.state.pendingWorkersNewest).toBe('2025-06-01T00:00:00.000Z');
315
+ });
316
+ it('should skip resolution when extraction_end_time has no type', async () => {
317
+ // Arrange: platform sends extraction_end_time without a type field
318
+ const event = (0, test_helpers_1.createEvent)({
319
+ eventType: extraction_1.EventType.StartExtractingData,
320
+ eventContextOverrides: {
321
+ extraction_start_time: {
322
+ type: extraction_1.TimeValueType.ABSOLUTE_TIME,
323
+ value: '2024-01-01T00:00:00Z',
324
+ },
325
+ extraction_end_time: {},
326
+ },
327
+ contextOverrides: {
328
+ snap_in_version_id: 'test_snap_in_version_id',
329
+ },
330
+ });
331
+ const stringifiedState = JSON.stringify({
332
+ snapInVersionId: 'test_snap_in_version_id',
333
+ });
334
+ fetchStateSpy.mockResolvedValue({ state: stringifiedState });
335
+ jest.spyOn(console, 'log').mockImplementation(() => { });
336
+ // Act
337
+ await (0, state_1.createAdapterState)({
338
+ event,
339
+ initialState: {},
340
+ initialDomainMapping: {},
341
+ });
342
+ // Assert: should not crash, extract_to is not set, extract_from is resolved
343
+ expect(processExitSpy).not.toHaveBeenCalled();
344
+ expect(event.payload.event_context.extract_from).toBe('2024-01-01T00:00:00.000Z');
345
+ expect(event.payload.event_context.extract_to).toBeUndefined();
346
+ });
347
+ it('should skip resolution when both extraction times have no type', async () => {
348
+ // Arrange: platform sends both time values without type fields
349
+ const event = (0, test_helpers_1.createEvent)({
350
+ eventType: extraction_1.EventType.StartExtractingData,
351
+ eventContextOverrides: {
352
+ extraction_start_time: { value: 'some-value' },
353
+ extraction_end_time: { value: 'some-value' },
354
+ },
355
+ contextOverrides: {
356
+ snap_in_version_id: 'test_snap_in_version_id',
357
+ },
358
+ });
359
+ const stringifiedState = JSON.stringify({
360
+ snapInVersionId: 'test_snap_in_version_id',
361
+ });
362
+ fetchStateSpy.mockResolvedValue({ state: stringifiedState });
363
+ jest.spyOn(console, 'log').mockImplementation(() => { });
364
+ // Act
365
+ await (0, state_1.createAdapterState)({
366
+ event,
367
+ initialState: {},
368
+ initialDomainMapping: {},
369
+ });
370
+ // Assert: should not crash, neither extraction time is resolved
371
+ expect(processExitSpy).not.toHaveBeenCalled();
372
+ expect(event.payload.event_context.extract_from).toBeUndefined();
373
+ expect(event.payload.event_context.extract_to).toBeUndefined();
374
+ });
375
+ });
283
376
  describe('Enhanced Control Protocol - extraction window validation', () => {
284
377
  it('should exit the process if extract_from >= extract_to', async () => {
285
378
  // Arrange: start is after end (inverted window)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devrev/ts-adaas",
3
- "version": "1.17.1-beta.7",
3
+ "version": "1.17.1-beta.8",
4
4
  "description": "Typescript library containing the ADaaS(AirDrop as a Service) control protocol.",
5
5
  "type": "commonjs",
6
6
  "main": "./dist/index.js",