@devrev/ts-adaas 1.19.8 → 1.19.9-beta.0

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 (50) hide show
  1. package/dist/attachments-streaming/attachments-streaming-pool.d.ts.map +1 -1
  2. package/dist/attachments-streaming/attachments-streaming-pool.js +4 -6
  3. package/dist/attachments-streaming/attachments-streaming-pool.test.js +0 -65
  4. package/dist/common/control-protocol.d.ts +3 -2
  5. package/dist/common/control-protocol.d.ts.map +1 -1
  6. package/dist/common/control-protocol.js +2 -4
  7. package/dist/common/control-protocol.test.d.ts +2 -0
  8. package/dist/common/control-protocol.test.d.ts.map +1 -0
  9. package/dist/common/control-protocol.test.js +126 -0
  10. package/dist/http/axios-client-internal.d.ts.map +1 -1
  11. package/dist/http/axios-client-internal.js +19 -1
  12. package/dist/mock-server/mock-server.d.ts +4 -0
  13. package/dist/mock-server/mock-server.d.ts.map +1 -1
  14. package/dist/mock-server/mock-server.interfaces.d.ts +9 -4
  15. package/dist/mock-server/mock-server.interfaces.d.ts.map +1 -1
  16. package/dist/mock-server/mock-server.js +30 -18
  17. package/dist/multithreading/spawn/spawn.d.ts +1 -1
  18. package/dist/multithreading/spawn/spawn.d.ts.map +1 -1
  19. package/dist/multithreading/spawn/spawn.js +11 -6
  20. package/dist/multithreading/spawn/spawn.test.js +1 -0
  21. package/dist/multithreading/worker-adapter/worker-adapter.artifacts.test.js +1 -1
  22. package/dist/multithreading/worker-adapter/worker-adapter.d.ts +11 -5
  23. package/dist/multithreading/worker-adapter/worker-adapter.d.ts.map +1 -1
  24. package/dist/multithreading/worker-adapter/worker-adapter.emit.test.js +90 -9
  25. package/dist/multithreading/worker-adapter/worker-adapter.extraction.test.js +1 -1
  26. package/dist/multithreading/worker-adapter/worker-adapter.js +93 -64
  27. package/dist/multithreading/worker-adapter/worker-adapter.upload-failure.test.d.ts +2 -0
  28. package/dist/multithreading/worker-adapter/worker-adapter.upload-failure.test.d.ts.map +1 -0
  29. package/dist/multithreading/worker-adapter/worker-adapter.upload-failure.test.js +135 -0
  30. package/dist/repo/repo.d.ts +11 -2
  31. package/dist/repo/repo.d.ts.map +1 -1
  32. package/dist/repo/repo.interfaces.d.ts +2 -0
  33. package/dist/repo/repo.interfaces.d.ts.map +1 -1
  34. package/dist/repo/repo.js +37 -11
  35. package/dist/repo/repo.test.js +184 -0
  36. package/dist/types/extraction.d.ts +8 -1
  37. package/dist/types/extraction.d.ts.map +1 -1
  38. package/dist/types/workers.d.ts +4 -0
  39. package/dist/types/workers.d.ts.map +1 -1
  40. package/dist/uploader/uploader.d.ts.map +1 -1
  41. package/dist/uploader/uploader.helpers.d.ts +6 -1
  42. package/dist/uploader/uploader.helpers.d.ts.map +1 -1
  43. package/dist/uploader/uploader.helpers.js +65 -0
  44. package/dist/uploader/uploader.helpers.test.js +148 -7
  45. package/dist/uploader/uploader.interfaces.d.ts +11 -0
  46. package/dist/uploader/uploader.interfaces.d.ts.map +1 -1
  47. package/dist/uploader/uploader.interfaces.js +11 -0
  48. package/dist/uploader/uploader.js +2 -5
  49. package/dist/uploader/uploader.test.js +54 -3
  50. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"attachments-streaming-pool.d.ts","sourceRoot":"","sources":["../../src/attachments-streaming/attachments-streaming-pool.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,2BAA2B,EAC5B,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC;AAEzF,qBAAa,wBAAwB,CAAC,cAAc;IAClD,OAAO,CAAC,OAAO,CAAgC;IAC/C,OAAO,CAAC,WAAW,CAAyB;IAC5C,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,KAAK,CAAqB;IAClC,OAAO,CAAC,MAAM,CAA4C;IAE1D,OAAO,CAAC,mBAAmB,CAAa;IACxC,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAM;gBAEnC,EACV,OAAO,EACP,WAAW,EACX,SAAc,EACd,MAAM,GACP,EAAE,8BAA8B,CAAC,cAAc,CAAC;YAQnC,cAAc;IAS5B;;;;;OAKG;IAEH,OAAO,CAAC,2BAA2B;IAsB7B,SAAS,IAAI,OAAO,CAAC,2BAA2B,CAAC;IAgDjD,kBAAkB;CA0FzB"}
1
+ {"version":3,"file":"attachments-streaming-pool.d.ts","sourceRoot":"","sources":["../../src/attachments-streaming/attachments-streaming-pool.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,2BAA2B,EAC5B,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC;AAEzF,qBAAa,wBAAwB,CAAC,cAAc;IAClD,OAAO,CAAC,OAAO,CAAgC;IAC/C,OAAO,CAAC,WAAW,CAAyB;IAC5C,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,KAAK,CAAqB;IAClC,OAAO,CAAC,MAAM,CAA4C;IAE1D,OAAO,CAAC,mBAAmB,CAAa;IACxC,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAM;gBAEnC,EACV,OAAO,EACP,WAAW,EACX,SAAc,EACd,MAAM,GACP,EAAE,8BAA8B,CAAC,cAAc,CAAC;YAQnC,cAAc;IAS5B;;;;;OAKG;IAEH,OAAO,CAAC,2BAA2B;IAsB7B,SAAS,IAAI,OAAO,CAAC,2BAA2B,CAAC;IA8CjD,kBAAkB;CA0FzB"}
@@ -69,10 +69,8 @@ class AttachmentsStreamingPool {
69
69
  for (let i = 0; i < initialBatchSize; i++) {
70
70
  initialPromises.push(this.startPoolStreaming());
71
71
  }
72
- await Promise.race([
73
- Promise.all(initialPromises),
74
- this.adapter.timeoutSignal,
75
- ]);
72
+ // Wait for all promises to complete
73
+ await Promise.all(initialPromises);
76
74
  if (this.delay) {
77
75
  return { delay: this.delay };
78
76
  }
@@ -119,8 +117,8 @@ class AttachmentsStreamingPool {
119
117
  await this.updateProgress();
120
118
  continue;
121
119
  }
122
- if (!this.adapter.isTimeout &&
123
- ((_c = (_b = this.adapter.state.toDevRev) === null || _b === void 0 ? void 0 : _b.attachmentsMetadata) === null || _c === void 0 ? void 0 : _c.lastProcessedAttachmentsIdsList)) {
120
+ // No rate limiting, process normally
121
+ if ((_c = (_b = this.adapter.state.toDevRev) === null || _b === void 0 ? void 0 : _b.attachmentsMetadata) === null || _c === void 0 ? void 0 : _c.lastProcessedAttachmentsIdsList) {
124
122
  (_d = this.adapter.state.toDevRev) === null || _d === void 0 ? void 0 : _d.attachmentsMetadata.lastProcessedAttachmentsIdsList.push({ id: attachment.id, parent_id: attachment.parent_id });
125
123
  }
126
124
  await this.updateProgress();
@@ -17,10 +17,6 @@ describe(attachments_streaming_pool_1.AttachmentsStreamingPool.name, () => {
17
17
  },
18
18
  },
19
19
  },
20
- isTimeout: false,
21
- // Never resolves: streamAll's race is decided by the workers completing,
22
- // unless a test overrides this / flips isTimeout.
23
- timeoutSignal: new Promise(() => { }),
24
20
  processAttachment: jest
25
21
  .fn()
26
22
  .mockResolvedValue({}),
@@ -517,65 +513,4 @@ describe(attachments_streaming_pool_1.AttachmentsStreamingPool.name, () => {
517
513
  expect(mockStreamFn).toHaveBeenCalled();
518
514
  });
519
515
  });
520
- describe('soft timeout handling', () => {
521
- it('should resolve streamAll when the timeout signal fires even if a worker is stuck in flight', async () => {
522
- // A worker stuck in a never-resolving request: only the timeout race can
523
- // unblock streamAll.
524
- mockAdapter.processAttachment.mockImplementation(async () => new Promise(() => { }));
525
- let fireTimeout;
526
- mockAdapter.timeoutSignal = new Promise((resolve) => {
527
- fireTimeout = resolve;
528
- });
529
- const pool = new attachments_streaming_pool_1.AttachmentsStreamingPool({
530
- adapter: mockAdapter,
531
- attachments: mockAttachments,
532
- batchSize: 10,
533
- stream: mockStream,
534
- });
535
- const streamAllPromise = pool.streamAll();
536
- mockAdapter.isTimeout = true;
537
- fireTimeout();
538
- const result = await streamAllPromise;
539
- expect(result).toEqual({});
540
- });
541
- it('should not record an attachment as processed when a timeout fires while it is in flight', async () => {
542
- mockAdapter.processAttachment.mockImplementation(async () => {
543
- await Promise.resolve();
544
- mockAdapter.isTimeout = true;
545
- return {};
546
- });
547
- const pool = new attachments_streaming_pool_1.AttachmentsStreamingPool({
548
- adapter: mockAdapter,
549
- attachments: mockAttachments,
550
- batchSize: 1,
551
- stream: mockStream,
552
- });
553
- await pool.streamAll();
554
- expect(mockAdapter.state.toDevRev.attachmentsMetadata
555
- .lastProcessedAttachmentsIdsList).toEqual([]);
556
- expect(mockAdapter.processAttachment).toHaveBeenCalledTimes(1);
557
- });
558
- it('should record attachments completed before the timeout and stop after', async () => {
559
- let calls = 0;
560
- mockAdapter.processAttachment.mockImplementation(async () => {
561
- await Promise.resolve();
562
- calls++;
563
- if (calls === 2) {
564
- mockAdapter.isTimeout = true;
565
- }
566
- return {};
567
- });
568
- const pool = new attachments_streaming_pool_1.AttachmentsStreamingPool({
569
- adapter: mockAdapter,
570
- attachments: mockAttachments,
571
- batchSize: 1,
572
- stream: mockStream,
573
- });
574
- await pool.streamAll();
575
- expect(mockAdapter.state.toDevRev.attachmentsMetadata
576
- .lastProcessedAttachmentsIdsList).toEqual([{ id: 'attachment-1', parent_id: 'parent-1' }]);
577
- // 2nd was started then abandoned; 3rd never started.
578
- expect(mockAdapter.processAttachment).toHaveBeenCalledTimes(2);
579
- });
580
- });
581
516
  });
@@ -1,10 +1,11 @@
1
1
  import { AxiosResponse } from 'axios';
2
- import { AirdropEvent, EventData, ExtractorEventType } from '../types/extraction';
2
+ import { AirdropEvent, EventData, ExtractorEventType, WorkerMetadata } from '../types/extraction';
3
3
  import { LoaderEventType } from '../types/loading';
4
4
  export interface EmitInterface {
5
5
  event: AirdropEvent;
6
6
  eventType: ExtractorEventType | LoaderEventType;
7
7
  data?: EventData;
8
+ worker_metadata?: WorkerMetadata;
8
9
  }
9
- export declare const emit: ({ event, eventType, data, }: EmitInterface) => Promise<AxiosResponse>;
10
+ export declare const emit: ({ event, eventType, data, worker_metadata, }: EmitInterface) => Promise<AxiosResponse>;
10
11
  //# sourceMappingURL=control-protocol.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"control-protocol.d.ts","sourceRoot":"","sources":["../../src/common/control-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,EACL,YAAY,EACZ,SAAS,EAET,kBAAkB,EAEnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAInD,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,YAAY,CAAC;IACpB,SAAS,EAAE,kBAAkB,GAAG,eAAe,CAAC;IAChD,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB;AAED,eAAO,MAAM,IAAI,GAAU,6BAIxB,aAAa,KAAG,OAAO,CAAC,aAAa,CAgCvC,CAAC"}
1
+ {"version":3,"file":"control-protocol.d.ts","sourceRoot":"","sources":["../../src/common/control-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,EACL,YAAY,EACZ,SAAS,EAET,kBAAkB,EAElB,cAAc,EACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAInD,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,YAAY,CAAC;IACpB,SAAS,EAAE,kBAAkB,GAAG,eAAe,CAAC;IAChD,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,eAAe,CAAC,EAAE,cAAc,CAAC;CAClC;AAED,eAAO,MAAM,IAAI,GAAU,8CAKxB,aAAa,KAAG,OAAO,CAAC,aAAa,CAmCvC,CAAC"}
@@ -4,7 +4,7 @@ exports.emit = void 0;
4
4
  const axios_client_internal_1 = require("../http/axios-client-internal");
5
5
  const constants_1 = require("./constants");
6
6
  const event_type_translation_1 = require("./event-type-translation");
7
- const emit = async ({ event, eventType, data, }) => {
7
+ const emit = async ({ event, eventType, data, worker_metadata, }) => {
8
8
  // Translate outgoing event type to ensure we always send new event types
9
9
  // TODO: Remove when the old types are completely phased out
10
10
  const translatedEventType = (0, event_type_translation_1.translateOutgoingEventType)(eventType);
@@ -12,9 +12,7 @@ const emit = async ({ event, eventType, data, }) => {
12
12
  event_type: translatedEventType,
13
13
  event_context: event.payload.event_context,
14
14
  event_data: Object.assign({}, data),
15
- worker_metadata: {
16
- adaas_library_version: constants_1.LIBRARY_VERSION,
17
- },
15
+ worker_metadata: Object.assign(Object.assign({}, worker_metadata), { newest_state_date: event.payload.event_context.extract_to, oldest_state_date: event.payload.event_context.extract_from, adaas_library_version: constants_1.LIBRARY_VERSION }),
18
16
  };
19
17
  console.info('Emitting event', newEvent);
20
18
  return axios_client_internal_1.axiosClient.post(event.payload.event_context.callback_url, Object.assign({}, newEvent), {
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=control-protocol.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"control-protocol.test.d.ts","sourceRoot":"","sources":["../../src/common/control-protocol.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const axios_client_internal_1 = require("../http/axios-client-internal");
4
+ const test_helpers_1 = require("../tests/test-helpers");
5
+ const test_utils_1 = require("./test-utils");
6
+ const control_protocol_1 = require("./control-protocol");
7
+ const extraction_1 = require("../types/extraction");
8
+ const loading_1 = require("../types/loading");
9
+ jest.mock('../http/axios-client-internal');
10
+ const mockedAxiosClient = jest.mocked(axios_client_internal_1.axiosClient);
11
+ describe('control-protocol.emit', () => {
12
+ beforeEach(() => {
13
+ jest.clearAllMocks();
14
+ mockedAxiosClient.post.mockResolvedValue((0, test_helpers_1.createAxiosResponse)());
15
+ });
16
+ it.each([
17
+ {
18
+ title: 'extractor events',
19
+ inputEventType: extraction_1.EventType.StartExtractingData,
20
+ outputEventType: extraction_1.ExtractorEventType.DataExtractionProgress,
21
+ },
22
+ {
23
+ title: 'loader events',
24
+ inputEventType: extraction_1.EventType.StartLoadingData,
25
+ outputEventType: loading_1.LoaderEventType.DataLoadingProgress,
26
+ },
27
+ {
28
+ title: 'unknown events',
29
+ inputEventType: extraction_1.EventType.StartExtractingData,
30
+ outputEventType: 'SOME_UNKNOWN_EVENT',
31
+ },
32
+ ])('sets state dates from event context for $title', async ({ inputEventType, outputEventType }) => {
33
+ const event = (0, test_utils_1.createMockEvent)(undefined, {
34
+ payload: {
35
+ event_type: inputEventType,
36
+ event_context: {
37
+ extract_from: '2024-01-01T00:00:00.000Z',
38
+ extract_to: '2024-06-01T00:00:00.000Z',
39
+ },
40
+ },
41
+ });
42
+ await (0, control_protocol_1.emit)({
43
+ event,
44
+ eventType: outputEventType,
45
+ });
46
+ expect(mockedAxiosClient.post).toHaveBeenCalledTimes(1);
47
+ const [, body, config] = mockedAxiosClient.post.mock.calls[0];
48
+ expect(body).toMatchObject({
49
+ event_type: outputEventType,
50
+ event_context: expect.objectContaining({
51
+ extract_from: '2024-01-01T00:00:00.000Z',
52
+ extract_to: '2024-06-01T00:00:00.000Z',
53
+ }),
54
+ worker_metadata: expect.objectContaining({
55
+ oldest_state_date: '2024-01-01T00:00:00.000Z',
56
+ newest_state_date: '2024-06-01T00:00:00.000Z',
57
+ }),
58
+ });
59
+ expect(config).toEqual(expect.objectContaining({
60
+ headers: expect.objectContaining({
61
+ 'X-DevRev-Client-Version': expect.any(String),
62
+ }),
63
+ }));
64
+ });
65
+ it.each([
66
+ {
67
+ title: 'only extract_from is set',
68
+ extractFrom: '2024-01-01T00:00:00.000Z',
69
+ extractTo: undefined,
70
+ },
71
+ {
72
+ title: 'only extract_to is set',
73
+ extractFrom: undefined,
74
+ extractTo: '2024-06-01T00:00:00.000Z',
75
+ },
76
+ {
77
+ title: 'neither extract_from nor extract_to is set',
78
+ extractFrom: undefined,
79
+ extractTo: undefined,
80
+ },
81
+ ])('handles state-date absence when $title', async ({ extractFrom, extractTo }) => {
82
+ const event = (0, test_utils_1.createMockEvent)(undefined, {
83
+ payload: {
84
+ event_type: extraction_1.EventType.StartExtractingData,
85
+ event_context: {
86
+ extract_from: extractFrom,
87
+ extract_to: extractTo,
88
+ },
89
+ },
90
+ });
91
+ await (0, control_protocol_1.emit)({
92
+ event,
93
+ eventType: extraction_1.ExtractorEventType.DataExtractionProgress,
94
+ });
95
+ const [, body] = mockedAxiosClient.post.mock.calls[0];
96
+ const workerMetadata = body.worker_metadata;
97
+ expect(workerMetadata.oldest_state_date).toBe(extractFrom);
98
+ expect(workerMetadata.newest_state_date).toBe(extractTo);
99
+ });
100
+ it('overrides caller-provided worker_metadata state dates', async () => {
101
+ const event = (0, test_utils_1.createMockEvent)(undefined, {
102
+ payload: {
103
+ event_type: extraction_1.EventType.StartExtractingData,
104
+ event_context: {
105
+ extract_from: '2024-01-01T00:00:00.000Z',
106
+ extract_to: '2024-06-01T00:00:00.000Z',
107
+ },
108
+ },
109
+ });
110
+ await (0, control_protocol_1.emit)({
111
+ event,
112
+ eventType: extraction_1.ExtractorEventType.DataExtractionProgress,
113
+ worker_metadata: {
114
+ item_type: 'tasks',
115
+ oldest_state_date: 'should-be-overwritten',
116
+ newest_state_date: 'should-be-overwritten',
117
+ },
118
+ });
119
+ const [, body] = mockedAxiosClient.post.mock.calls[0];
120
+ expect(body.worker_metadata).toEqual(expect.objectContaining({
121
+ item_type: 'tasks',
122
+ oldest_state_date: '2024-01-01T00:00:00.000Z',
123
+ newest_state_date: '2024-06-01T00:00:00.000Z',
124
+ }));
125
+ });
126
+ });
@@ -1 +1 @@
1
- {"version":3,"file":"axios-client-internal.d.ts","sourceRoot":"","sources":["../../src/http/axios-client-internal.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,WAAW,+BAEf,CAAC;AAyFH,OAAO,EAAE,WAAW,EAAE,CAAC"}
1
+ {"version":3,"file":"axios-client-internal.d.ts","sourceRoot":"","sources":["../../src/http/axios-client-internal.ts"],"names":[],"mappings":"AAwBA,QAAA,MAAM,WAAW,+BAEf,CAAC;AAyFH,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -6,12 +6,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.axiosClient = void 0;
7
7
  const axios_1 = __importDefault(require("axios"));
8
8
  const axios_retry_1 = __importDefault(require("axios-retry"));
9
+ const node_worker_threads_1 = require("node:worker_threads");
10
+ /** Production default; tests may lower via workerData.options.httpRetries or ADAAS_TEST_HTTP_RETRIES. */
11
+ function getHttpRetryCount() {
12
+ var _a;
13
+ if (!node_worker_threads_1.isMainThread &&
14
+ ((_a = node_worker_threads_1.workerData === null || node_worker_threads_1.workerData === void 0 ? void 0 : node_worker_threads_1.workerData.options) === null || _a === void 0 ? void 0 : _a.httpRetries) !== undefined &&
15
+ node_worker_threads_1.workerData.options.httpRetries >= 0) {
16
+ return node_worker_threads_1.workerData.options.httpRetries;
17
+ }
18
+ const fromEnv = process.env.ADAAS_TEST_HTTP_RETRIES;
19
+ if (fromEnv !== undefined) {
20
+ const parsed = parseInt(fromEnv, 10);
21
+ if (!isNaN(parsed) && parsed >= 0) {
22
+ return parsed;
23
+ }
24
+ }
25
+ return 5;
26
+ }
9
27
  const axiosClient = axios_1.default.create({
10
28
  timeout: 30 * 1000,
11
29
  });
12
30
  exports.axiosClient = axiosClient;
13
31
  (0, axios_retry_1.default)(axiosClient, {
14
- retries: 5,
32
+ retries: getHttpRetryCount(),
15
33
  shouldResetTimeout: true,
16
34
  retryDelay: (retryCount, error) => {
17
35
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
@@ -31,6 +31,10 @@ export declare class MockServer {
31
31
  * Also clears request tracking data.
32
32
  */
33
33
  resetRoutes(): void;
34
+ /**
35
+ * Returns all POST requests to the platform callback URL.
36
+ */
37
+ getCallbackRequests(): RequestInfo[];
34
38
  /**
35
39
  * Returns the most recent request or undefined if no requests exist.
36
40
  */
@@ -1 +1 @@
1
- {"version":3,"file":"mock-server.d.ts","sourceRoot":"","sources":["../../src/mock-server/mock-server.ts"],"names":[],"mappings":"AAEA,OAAO,EAKL,WAAW,EACX,WAAW,EAEZ,MAAM,0BAA0B,CAAC;AA4ElC;;;;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;IA8E1C;;;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/mock-server/mock-server.ts"],"names":[],"mappings":"AAEA,OAAO,EAKL,WAAW,EACX,WAAW,EAEZ,MAAM,0BAA0B,CAAC;AAuElC;;;;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;IAwF1C;;;OAGG;IACI,WAAW,IAAI,IAAI;IAM1B;;OAEG;IACI,mBAAmB,IAAI,WAAW,EAAE;IAO3C;;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"}
@@ -13,8 +13,6 @@ export interface MockResponse extends ServerResponse {
13
13
  status(code: number): MockResponse;
14
14
  /** Send a JSON response */
15
15
  json(data: unknown): void;
16
- /** Send a raw binary (Buffer) response */
17
- buffer(data: Buffer): void;
18
16
  /** Send an empty response */
19
17
  send(): void;
20
18
  }
@@ -45,12 +43,19 @@ export interface RouteConfig {
45
43
  status: number;
46
44
  /** Optional response body to send as JSON */
47
45
  body?: unknown;
48
- /** Optional raw binary response body, e.g. gzipped JSONL (takes precedence over `body`) */
49
- bodyBuffer?: Buffer;
50
46
  /** Optional headers to send with the response */
51
47
  headers?: Record<string, string>;
52
48
  /** Optional retry configuration for simulating failures before success */
53
49
  retry?: RetryConfig;
50
+ /**
51
+ * Respond successfully for the first N requests, then return an error.
52
+ * Useful for partial-upload scenarios (first batch succeeds, second fails).
53
+ */
54
+ succeedThenFail?: {
55
+ successCount: number;
56
+ errorStatus?: number;
57
+ errorBody?: unknown;
58
+ };
54
59
  /** Optional delay in milliseconds before sending the response */
55
60
  delay?: number;
56
61
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mock-server.interfaces.d.ts","sourceRoot":"","sources":["../../src/mock-server/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,0CAA0C;IAC1C,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,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,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,0EAA0E;IAC1E,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,4EAA4E;IAC5E,IAAI,EAAE,MAAM,CAAC;IACb,6DAA6D;IAC7D,MAAM,EAAE,MAAM,CAAC;IACf,2DAA2D;IAC3D,MAAM,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,2FAA2F;IAC3F,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iDAAiD;IACjD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,0EAA0E;IAC1E,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,iEAAiE;IACjE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,YAAY,KAAK,OAAO,CAAC;AAE9E;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,4CAA4C;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,oDAAoD;IACpD,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AAEtD;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC"}
1
+ {"version":3,"file":"mock-server.interfaces.d.ts","sourceRoot":"","sources":["../../src/mock-server/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,OA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AAK,OAAO,CAAC;AAE9E;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,4CAA4C;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,oDAAoD;IACpD,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AAEtD;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC"}
@@ -56,10 +56,6 @@ function wrapResponse(res) {
56
56
  res.writeHead(statusCode, { 'Content-Type': 'application/json' });
57
57
  res.end(JSON.stringify(data));
58
58
  };
59
- mock.buffer = (data) => {
60
- res.writeHead(statusCode, { 'Content-Type': 'application/octet-stream' });
61
- res.end(data);
62
- };
63
59
  mock.send = () => {
64
60
  res.writeHead(statusCode);
65
61
  res.end();
@@ -178,19 +174,35 @@ class MockServer {
178
174
  * Configures a route to return a specific status code and optional response body.
179
175
  */
180
176
  setRoute(config) {
181
- const { path, method, status, body, bodyBuffer, retry, headers, delay } = config;
177
+ const { path, method, status, body, retry, succeedThenFail, headers, delay } = config;
182
178
  const key = this.getRouteKey(method, path);
183
- if (retry) {
179
+ if (retry || succeedThenFail) {
184
180
  this.requestCounts.set(key, 0);
185
181
  }
186
182
  this.routeHandlers.set(key, (req, res) => {
187
183
  const sendResponse = (responseDelay) => {
188
184
  const send = () => {
189
- var _a, _b;
190
- if (retry) {
185
+ var _a, _b, _c;
186
+ if (succeedThenFail) {
187
+ const currentCount = this.requestCounts.get(key) || 0;
188
+ this.requestCounts.set(key, currentCount + 1);
189
+ if (currentCount < succeedThenFail.successCount) {
190
+ this.defaultRouteHandler(req, res);
191
+ }
192
+ else {
193
+ const errorStatus = (_a = succeedThenFail.errorStatus) !== null && _a !== void 0 ? _a : 400;
194
+ if (succeedThenFail.errorBody !== undefined) {
195
+ res.status(errorStatus).json(succeedThenFail.errorBody);
196
+ }
197
+ else {
198
+ res.status(errorStatus).send();
199
+ }
200
+ }
201
+ }
202
+ else if (retry) {
191
203
  const currentCount = this.requestCounts.get(key) || 0;
192
- const failureCount = (_a = retry.failureCount) !== null && _a !== void 0 ? _a : 4;
193
- const errorStatus = (_b = retry.errorStatus) !== null && _b !== void 0 ? _b : 500;
204
+ const failureCount = (_b = retry.failureCount) !== null && _b !== void 0 ? _b : 4;
205
+ const errorStatus = (_c = retry.errorStatus) !== null && _c !== void 0 ? _c : 500;
194
206
  if (currentCount < failureCount) {
195
207
  this.requestCounts.set(key, currentCount + 1);
196
208
  const sendFailure = () => {
@@ -216,10 +228,7 @@ class MockServer {
216
228
  if (headers) {
217
229
  res.set(headers);
218
230
  }
219
- if (bodyBuffer !== undefined) {
220
- res.status(status).buffer(bodyBuffer);
221
- }
222
- else if (body !== undefined) {
231
+ if (body !== undefined) {
223
232
  res.status(status).json(body);
224
233
  }
225
234
  else {
@@ -231,10 +240,7 @@ class MockServer {
231
240
  if (headers) {
232
241
  res.set(headers);
233
242
  }
234
- if (bodyBuffer !== undefined) {
235
- res.status(status).buffer(bodyBuffer);
236
- }
237
- else if (body !== undefined) {
243
+ if (body !== undefined) {
238
244
  res.status(status).json(body);
239
245
  }
240
246
  else {
@@ -261,6 +267,12 @@ class MockServer {
261
267
  this.requestCounts.clear();
262
268
  this.requests = [];
263
269
  }
270
+ /**
271
+ * Returns all POST requests to the platform callback URL.
272
+ */
273
+ getCallbackRequests() {
274
+ return this.requests.filter((req) => req.method.toUpperCase() === 'POST' && req.url.includes('callback_url'));
275
+ }
264
276
  /**
265
277
  * Returns the most recent request or undefined if no requests exist.
266
278
  */
@@ -25,7 +25,7 @@ export declare class Spawn {
25
25
  private originalConsole;
26
26
  private logger;
27
27
  private workerFailedMessage;
28
- constructor({ event, worker, options, resolve, originalConsole, }: SpawnInterface);
28
+ constructor({ event, worker, options, resolve, originalConsole, logger, }: SpawnInterface);
29
29
  private clearTimeouts;
30
30
  private exitFromMainThread;
31
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"spawn.d.ts","sourceRoot":"","sources":["../../../src/multithreading/spawn/spawn.ts"],"names":[],"mappings":"AAQA,OAAO,EAEL,qBAAqB,EACrB,cAAc,EAGf,MAAM,qBAAqB,CAAC;AA+C7B;;;;;;;;;;;GAWG;AACH,wBAAsB,KAAK,CAAC,cAAc,EAAE,EAC1C,KAAK,EACL,YAAY,EACZ,UAAU,EACV,oBAAoB,EACpB,OAAO,EACP,cAAc,GACf,EAAE,qBAAqB,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAwFvD;AAED,qBAAa,KAAK;IAChB,OAAO,CAAC,KAAK,CAAe;IAC5B,OAAO,CAAC,cAAc,CAAU;IAChC,OAAO,CAAC,eAAe,CAAU;IACjC,OAAO,CAAC,oBAAoB,CAAkC;IAC9D,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,gBAAgB,CAA4C;IACpE,OAAO,CAAC,gBAAgB,CAA4C;IACpE,OAAO,CAAC,wBAAwB,CAA6C;IAC7E,OAAO,CAAC,OAAO,CAA4C;IAC3D,OAAO,CAAC,eAAe,CAAU;IACjC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,mBAAmB,CAAqB;gBACpC,EACV,KAAK,EACL,MAAM,EACN,OAAO,EACP,OAAO,EACP,eAAe,GAChB,EAAE,cAAc;IAiHjB,OAAO,CAAC,aAAa;YAYP,kBAAkB;CAoCjC"}
1
+ {"version":3,"file":"spawn.d.ts","sourceRoot":"","sources":["../../../src/multithreading/spawn/spawn.ts"],"names":[],"mappings":"AASA,OAAO,EAEL,qBAAqB,EACrB,cAAc,EAGf,MAAM,qBAAqB,CAAC;AA+C7B;;;;;;;;;;;GAWG;AACH,wBAAsB,KAAK,CAAC,cAAc,EAAE,EAC1C,KAAK,EACL,YAAY,EACZ,UAAU,EACV,oBAAoB,EACpB,OAAO,EACP,cAAc,GACf,EAAE,qBAAqB,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CA0FvD;AAED,qBAAa,KAAK;IAChB,OAAO,CAAC,KAAK,CAAe;IAC5B,OAAO,CAAC,cAAc,CAAU;IAChC,OAAO,CAAC,eAAe,CAAU;IACjC,OAAO,CAAC,oBAAoB,CAAkC;IAC9D,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,gBAAgB,CAA4C;IACpE,OAAO,CAAC,gBAAgB,CAA4C;IACpE,OAAO,CAAC,wBAAwB,CAA6C;IAC7E,OAAO,CAAC,OAAO,CAA4C;IAC3D,OAAO,CAAC,eAAe,CAAU;IACjC,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,mBAAmB,CAAqB;gBACpC,EACV,KAAK,EACL,MAAM,EACN,OAAO,EACP,OAAO,EACP,eAAe,EACf,MAAM,GACP,EAAE,cAAc;IAoHjB,OAAO,CAAC,aAAa;YAYP,kBAAkB;CAoCjC"}
@@ -68,8 +68,9 @@ async function spawn({ event, initialState, workerPath, initialDomainMapping, op
68
68
  options = Object.assign(Object.assign({}, (options || {})), { isLocalDevelopment: true });
69
69
  }
70
70
  const originalConsole = console;
71
+ const logger = new logger_1.Logger({ event, options });
71
72
  // eslint-disable-next-line no-global-assign
72
- console = new logger_1.Logger({ event, options });
73
+ console = logger;
73
74
  if (translatedEventType !== originalEventType) {
74
75
  console.log(`Event type translated from ${originalEventType} to ${translatedEventType}.`);
75
76
  }
@@ -110,6 +111,7 @@ async function spawn({ event, initialState, workerPath, initialDomainMapping, op
110
111
  options,
111
112
  resolve,
112
113
  originalConsole,
114
+ logger,
113
115
  });
114
116
  });
115
117
  }
@@ -132,10 +134,11 @@ async function spawn({ event, initialState, workerPath, initialDomainMapping, op
132
134
  }
133
135
  }
134
136
  class Spawn {
135
- constructor({ event, worker, options, resolve, originalConsole, }) {
137
+ constructor({ event, worker, options, resolve, originalConsole, logger, }) {
136
138
  this.defaultLambdaTimeout = constants_1.DEFAULT_LAMBDA_TIMEOUT;
137
139
  this.originalConsole = originalConsole || console;
138
- this.logger = console;
140
+ this.logger =
141
+ logger !== null && logger !== void 0 ? logger : console;
139
142
  this.alreadyEmitted = false;
140
143
  this.softTimeoutSent = false;
141
144
  this.event = event;
@@ -189,7 +192,7 @@ class Spawn {
189
192
  }
190
193
  });
191
194
  worker.on(workers_1.WorkerEvent.WorkerMessage, (message) => {
192
- var _a, _b, _c, _d, _e;
195
+ var _a, _b, _c, _d, _e, _f;
193
196
  // Since logs from the worker thread are handled differently in snap-in
194
197
  // platform, we need to catch the log messages from worker thread and log
195
198
  // them in main thread.
@@ -197,7 +200,9 @@ class Spawn {
197
200
  const stringifiedArgs = (_a = message.payload) === null || _a === void 0 ? void 0 : _a.stringifiedArgs;
198
201
  const level = (_b = message.payload) === null || _b === void 0 ? void 0 : _b.level;
199
202
  const isSdkLog = (_d = (_c = message.payload) === null || _c === void 0 ? void 0 : _c.isSdkLog) !== null && _d !== void 0 ? _d : true;
200
- this.logger.logFn(stringifiedArgs, level, isSdkLog);
203
+ if (typeof ((_e = this.logger) === null || _e === void 0 ? void 0 : _e.logFn) === 'function') {
204
+ this.logger.logFn(stringifiedArgs, level, isSdkLog);
205
+ }
201
206
  }
202
207
  // If worker sends a message that it has emitted an event, then set alreadyEmitted to true.
203
208
  if ((message === null || message === void 0 ? void 0 : message.subject) === workers_1.WorkerMessageSubject.WorkerMessageEmitted) {
@@ -206,7 +211,7 @@ class Spawn {
206
211
  }
207
212
  // If worker sends a failure message before exiting, capture it for use in the error event.
208
213
  if ((message === null || message === void 0 ? void 0 : message.subject) === workers_1.WorkerMessageSubject.WorkerMessageFailed) {
209
- this.workerFailedMessage = (_e = message.payload) === null || _e === void 0 ? void 0 : _e.message;
214
+ this.workerFailedMessage = (_f = message.payload) === null || _f === void 0 ? void 0 : _f.message;
210
215
  }
211
216
  });
212
217
  // Log memory usage every 30 seconds
@@ -78,6 +78,7 @@ function buildSpawn(overrides) {
78
78
  options: overrides.options,
79
79
  resolve: (_a = overrides.resolve) !== null && _a !== void 0 ? _a : jest.fn(),
80
80
  originalConsole: originalConsole,
81
+ logger: mockLogger,
81
82
  });
82
83
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
83
84
  global.console = originalConsole;
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const constants_1 = require("../../common/constants");
4
+ const test_utils_1 = require("../../common/test-utils");
4
5
  const state_1 = require("../../state/state");
5
6
  const jest_setup_1 = require("../../tests/jest.setup");
6
7
  const test_helpers_1 = require("../../tests/test-helpers");
7
- const test_utils_1 = require("../../common/test-utils");
8
8
  const types_1 = require("../../types");
9
9
  const worker_adapter_1 = require("./worker-adapter");
10
10
  // 1. Create a mock function for the method you want to override.
@@ -25,21 +25,18 @@ export declare function createWorkerAdapter<ConnectorState>({ event, adapterStat
25
25
  export declare class WorkerAdapter<ConnectorState> {
26
26
  readonly event: AirdropEvent;
27
27
  readonly options?: WorkerAdapterOptions;
28
+ isTimeout: boolean;
28
29
  hasWorkerEmitted: boolean;
29
- private _isTimeout;
30
- private resolveTimeoutSignal;
31
- readonly timeoutSignal: Promise<void>;
32
30
  private adapterState;
33
31
  private _artifacts;
34
32
  private repos;
33
+ private lastExtractedItemType?;
35
34
  private currentEventDataLength;
36
35
  private loaderReports;
37
36
  private _processedFiles;
38
37
  private _mappers;
39
38
  private uploader;
40
39
  constructor({ event, adapterState, options, }: WorkerAdapterInterface<ConnectorState>);
41
- get isTimeout(): boolean;
42
- set isTimeout(value: boolean);
43
40
  get state(): AdapterState<ConnectorState>;
44
41
  set state(value: AdapterState<ConnectorState>);
45
42
  get reports(): LoaderReport[];
@@ -64,6 +61,15 @@ export declare class WorkerAdapter<ConnectorState> {
64
61
  */
65
62
  emit(newEventType: ExtractorEventType | LoaderEventType, data?: EventData): Promise<void>;
66
63
  uploadAllRepos(): Promise<void>;
64
+ /**
65
+ * Persists adapter state before emitting, except for stateless worker phases.
66
+ */
67
+ private postStateBeforeEmit;
68
+ /**
69
+ * Posts state (when required), emits to the platform, and notifies the parent
70
+ * worker that an event was emitted.
71
+ */
72
+ private emitToPlatform;
67
73
  loadItemTypes({ itemTypesToLoad, }: ItemTypesToLoadParams): Promise<LoadItemTypesResponse>;
68
74
  getLoaderBatches({ supportedItemTypes, }: {
69
75
  supportedItemTypes: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"worker-adapter.d.ts","sourceRoot":"","sources":["../../../src/multithreading/worker-adapter/worker-adapter.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EACL,oBAAoB,EACpB,aAAa,EACd,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EACL,YAAY,EACZ,SAAS,EAET,kCAAkC,EAClC,yCAAyC,EACzC,kBAAkB,EAClB,2BAA2B,EAC3B,2BAA2B,EAC5B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAEL,wBAAwB,EACxB,kBAAkB,EAClB,6BAA6B,EAC7B,UAAU,EACV,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,qBAAqB,EAEtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EAGrB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,QAAQ,EAAkB,MAAM,oCAAoC,CAAC;AAI9E,wBAAgB,mBAAmB,CAAC,cAAc,EAAE,EAClD,KAAK,EACL,YAAY,EACZ,OAAO,GACR,EAAE,sBAAsB,CAAC,cAAc,CAAC,GAAG,aAAa,CAAC,cAAc,CAAC,CAMxE;AAED;;;;;;;;;;;;;;GAcG;AACH,qBAAa,aAAa,CAAC,cAAc;IACvC,QAAQ,CAAC,KAA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