@devrev/ts-adaas 1.13.0 → 1.13.1-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 (95) hide show
  1. package/dist/common/install-initial-domain-mapping.test.js +1 -1
  2. package/dist/http/axios-client-internal.d.ts.map +1 -1
  3. package/dist/http/axios-client-internal.js +10 -15
  4. package/dist/http/axios-client-internal.test.js +126 -161
  5. package/dist/tests/dummy-connector/data-extraction.d.ts +2 -0
  6. package/dist/tests/dummy-connector/data-extraction.d.ts.map +1 -0
  7. package/dist/tests/dummy-connector/data-extraction.js +43 -0
  8. package/dist/tests/dummy-connector/data-extraction.test.d.ts +2 -0
  9. package/dist/tests/dummy-connector/data-extraction.test.d.ts.map +1 -0
  10. package/dist/tests/dummy-connector/data-extraction.test.js +24 -0
  11. package/dist/tests/dummy-connector/external-sync-units-extraction.d.ts +2 -0
  12. package/dist/tests/dummy-connector/external-sync-units-extraction.d.ts.map +1 -0
  13. package/dist/tests/dummy-connector/external-sync-units-extraction.js +26 -0
  14. package/dist/tests/dummy-connector/external-sync-units-extraction.test.d.ts +2 -0
  15. package/dist/tests/dummy-connector/external-sync-units-extraction.test.d.ts.map +1 -0
  16. package/dist/tests/dummy-connector/external-sync-units-extraction.test.js +21 -0
  17. package/dist/tests/dummy-connector/extraction.d.ts +4 -0
  18. package/dist/tests/dummy-connector/extraction.d.ts.map +1 -0
  19. package/dist/tests/dummy-connector/extraction.js +19 -0
  20. package/dist/tests/dummy-connector/metadata-extraction.d.ts +2 -0
  21. package/dist/tests/dummy-connector/metadata-extraction.d.ts.map +1 -0
  22. package/dist/tests/dummy-connector/metadata-extraction.js +23 -0
  23. package/dist/tests/dummy-connector/metadata-extraction.test.d.ts +2 -0
  24. package/dist/tests/dummy-connector/metadata-extraction.test.d.ts.map +1 -0
  25. package/dist/tests/dummy-connector/metadata-extraction.test.js +54 -0
  26. package/dist/tests/jest.setup.d.ts +3 -0
  27. package/dist/tests/jest.setup.d.ts.map +1 -0
  28. package/dist/tests/jest.setup.js +14 -0
  29. package/dist/tests/mock-server/mock-server.d.ts +79 -0
  30. package/dist/tests/mock-server/mock-server.d.ts.map +1 -0
  31. package/dist/tests/mock-server/mock-server.interfaces.d.ts +53 -0
  32. package/dist/tests/mock-server/mock-server.interfaces.d.ts.map +1 -0
  33. package/dist/tests/mock-server/mock-server.interfaces.js +4 -0
  34. package/dist/tests/mock-server/mock-server.js +237 -0
  35. package/dist/tests/test-helpers.d.ts.map +1 -1
  36. package/dist/tests/test-helpers.js +4 -3
  37. package/dist/tests/timeout-handling/extraction.d.ts.map +1 -1
  38. package/dist/tests/timeout-handling/no-timeout.d.ts +2 -0
  39. package/dist/tests/timeout-handling/no-timeout.d.ts.map +1 -0
  40. package/dist/tests/timeout-handling/{timeout-1.js → no-timeout.js} +1 -1
  41. package/dist/tests/timeout-handling/no-timeout.test.d.ts +2 -0
  42. package/dist/tests/timeout-handling/no-timeout.test.d.ts.map +1 -0
  43. package/dist/tests/timeout-handling/no-timeout.test.js +24 -0
  44. package/dist/tests/timeout-handling/timeout-blocked.d.ts +2 -0
  45. package/dist/tests/timeout-handling/timeout-blocked.d.ts.map +1 -0
  46. package/dist/tests/timeout-handling/timeout-blocked.js +23 -0
  47. package/dist/tests/timeout-handling/timeout-blocked.test.d.ts +2 -0
  48. package/dist/tests/timeout-handling/timeout-blocked.test.d.ts.map +1 -0
  49. package/dist/tests/timeout-handling/timeout-blocked.test.js +25 -0
  50. package/dist/tests/timeout-handling/timeout-graceful.d.ts +2 -0
  51. package/dist/tests/timeout-handling/timeout-graceful.d.ts.map +1 -0
  52. package/dist/tests/timeout-handling/timeout-graceful.js +17 -0
  53. package/dist/tests/timeout-handling/timeout-graceful.test.d.ts +2 -0
  54. package/dist/tests/timeout-handling/timeout-graceful.test.d.ts.map +1 -0
  55. package/dist/tests/timeout-handling/timeout-graceful.test.js +25 -0
  56. package/dist/tests/timeout-handling/timeout-unblocked.d.ts +2 -0
  57. package/dist/tests/timeout-handling/timeout-unblocked.d.ts.map +1 -0
  58. package/dist/tests/timeout-handling/timeout-unblocked.js +26 -0
  59. package/dist/tests/timeout-handling/timeout-unblocked.test.d.ts +2 -0
  60. package/dist/tests/timeout-handling/timeout-unblocked.test.d.ts.map +1 -0
  61. package/dist/tests/timeout-handling/timeout-unblocked.test.js +25 -0
  62. package/dist/uploader/uploader.d.ts +72 -8
  63. package/dist/uploader/uploader.d.ts.map +1 -1
  64. package/dist/uploader/uploader.js +73 -8
  65. package/dist/workers/spawn.d.ts.map +1 -1
  66. package/dist/workers/spawn.js +28 -0
  67. package/dist/workers/worker-adapter.d.ts.map +1 -1
  68. package/dist/workers/worker-adapter.js +7 -4
  69. package/package.json +3 -8
  70. package/dist/tests/mock-server.d.ts +0 -21
  71. package/dist/tests/mock-server.d.ts.map +0 -1
  72. package/dist/tests/mock-server.js +0 -280
  73. package/dist/tests/timeout-handling/timeout-1.d.ts +0 -2
  74. package/dist/tests/timeout-handling/timeout-1.d.ts.map +0 -1
  75. package/dist/tests/timeout-handling/timeout-1.test.d.ts +0 -2
  76. package/dist/tests/timeout-handling/timeout-1.test.d.ts.map +0 -1
  77. package/dist/tests/timeout-handling/timeout-1.test.js +0 -45
  78. package/dist/tests/timeout-handling/timeout-2.d.ts +0 -2
  79. package/dist/tests/timeout-handling/timeout-2.d.ts.map +0 -1
  80. package/dist/tests/timeout-handling/timeout-2.js +0 -44
  81. package/dist/tests/timeout-handling/timeout-2.test.d.ts +0 -2
  82. package/dist/tests/timeout-handling/timeout-2.test.d.ts.map +0 -1
  83. package/dist/tests/timeout-handling/timeout-2.test.js +0 -46
  84. package/dist/tests/timeout-handling/timeout-3a.d.ts +0 -2
  85. package/dist/tests/timeout-handling/timeout-3a.d.ts.map +0 -1
  86. package/dist/tests/timeout-handling/timeout-3a.js +0 -37
  87. package/dist/tests/timeout-handling/timeout-3a.test.d.ts +0 -2
  88. package/dist/tests/timeout-handling/timeout-3a.test.d.ts.map +0 -1
  89. package/dist/tests/timeout-handling/timeout-3a.test.js +0 -46
  90. package/dist/tests/timeout-handling/timeout-3b.d.ts +0 -2
  91. package/dist/tests/timeout-handling/timeout-3b.d.ts.map +0 -1
  92. package/dist/tests/timeout-handling/timeout-3b.js +0 -38
  93. package/dist/tests/timeout-handling/timeout-3b.test.d.ts +0 -2
  94. package/dist/tests/timeout-handling/timeout-3b.test.d.ts.map +0 -1
  95. package/dist/tests/timeout-handling/timeout-3b.test.js +0 -46
@@ -1,280 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.MockServer = void 0;
37
- const http = __importStar(require("http"));
38
- const url = __importStar(require("url"));
39
- class MockServer {
40
- constructor(port) {
41
- this.server = null;
42
- this.consoleLogs = [];
43
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
44
- this.requests = [];
45
- this.port = port || 3001; // Default to standard test port
46
- }
47
- getDefaultWorkerState() {
48
- return {
49
- lastSyncStarted: '',
50
- lastSuccessfulSyncStarted: '',
51
- snapInVersionId: 'test-snap-in-version-id',
52
- toDevRev: {
53
- attachmentsMetadata: {
54
- artifactIds: [],
55
- lastProcessed: 0,
56
- lastProcessedAttachmentsIdsList: [],
57
- },
58
- },
59
- };
60
- }
61
- handleRequest(req, res) {
62
- const parsedUrl = url.parse(req.url || '', true);
63
- const pathname = parsedUrl.pathname || '';
64
- const method = req.method || 'GET';
65
- // Track this request
66
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
67
- const requestInfo = {
68
- method,
69
- url: req.url || '',
70
- };
71
- // For POST requests, capture the body
72
- if (method === 'POST') {
73
- let body = '';
74
- req.on('data', (chunk) => (body += chunk.toString()));
75
- req.on('end', () => {
76
- try {
77
- requestInfo.body = JSON.parse(body);
78
- }
79
- catch (_a) {
80
- requestInfo.body = body;
81
- }
82
- this.requests.push(requestInfo);
83
- });
84
- }
85
- else {
86
- this.requests.push(requestInfo);
87
- }
88
- // Set CORS headers for all requests
89
- res.setHeader('Access-Control-Allow-Origin', '*');
90
- res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
91
- res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization');
92
- res.setHeader('Content-Type', 'application/json');
93
- switch (method) {
94
- case 'OPTIONS':
95
- // Handle preflight CORS requests
96
- res.writeHead(200);
97
- res.end();
98
- break;
99
- case 'GET':
100
- switch (true) {
101
- case pathname.includes('airdrop.external-worker'):
102
- // Worker state GET endpoint
103
- res.writeHead(200);
104
- res.end(JSON.stringify({
105
- state: JSON.stringify(this.getDefaultWorkerState()),
106
- }));
107
- break;
108
- case pathname.includes('snap-ins.get'):
109
- // Snap-ins endpoint for install-initial-domain-mapping
110
- res.writeHead(200);
111
- res.end(JSON.stringify({
112
- snap_in: {
113
- imports: [{ name: 'test_import_slug' }],
114
- snap_in_version: { slug: 'test_snap_in_slug' },
115
- },
116
- }));
117
- break;
118
- case pathname.includes('/upload') || pathname.includes('/download'):
119
- // Generic file download endpoints for artifacts
120
- res.writeHead(200);
121
- res.setHeader('Content-Type', 'application/octet-stream');
122
- res.end(Buffer.from('mock file content'));
123
- break;
124
- default:
125
- // Unknown GET endpoint
126
- res.writeHead(404);
127
- res.end(JSON.stringify({
128
- error: 'GET endpoint not found',
129
- code: 'ENDPOINT_NOT_FOUND',
130
- }));
131
- }
132
- break;
133
- case 'POST':
134
- switch (true) {
135
- case pathname.includes('airdrop.external-worker'):
136
- // Worker state POST/UPDATE endpoint
137
- res.writeHead(200);
138
- res.end(JSON.stringify({
139
- success: true,
140
- updated_at: new Date().toISOString(),
141
- }));
142
- break;
143
- case pathname.includes('airdrop.external-extractor.message'):
144
- // Callback endpoint for event emissions
145
- res.writeHead(200);
146
- res.end(JSON.stringify({
147
- success: true,
148
- received_at: new Date().toISOString(),
149
- }));
150
- break;
151
- case pathname.includes('recipe.blueprints.create'):
152
- // Recipe blueprint creation endpoint
153
- res.writeHead(200);
154
- res.end(JSON.stringify({
155
- recipe_blueprint: { id: 'test_recipe_blueprint_id' },
156
- }));
157
- break;
158
- case pathname.includes('initial-domain-mappings.install'):
159
- // Domain mappings installation endpoint
160
- res.writeHead(200);
161
- res.end(JSON.stringify({
162
- success: true,
163
- message: 'Initial domain mappings installed successfully',
164
- }));
165
- break;
166
- case pathname.includes('artifacts.prepare'):
167
- // Artifacts prepare endpoint for uploader
168
- res.writeHead(200);
169
- res.end(JSON.stringify({
170
- id: `test_artifact_${Date.now()}`,
171
- url: `${this.getBaseUrl()}/upload`,
172
- form_data: [
173
- { key: 'key', value: 'test-key' },
174
- { key: 'x-amz-algorithm', value: 'AWS4-HMAC-SHA256' },
175
- { key: 'x-amz-credential', value: 'test-credential' },
176
- { key: 'x-amz-date', value: new Date().toISOString() },
177
- { key: 'policy', value: 'test-policy' },
178
- { key: 'x-amz-signature', value: 'test-signature' },
179
- ],
180
- }));
181
- break;
182
- case pathname.includes('artifacts.locate'):
183
- // Artifacts locate endpoint for uploader
184
- res.writeHead(200);
185
- res.end(JSON.stringify({
186
- url: `${this.getBaseUrl()}/download/artifact.jsonl.gz`,
187
- }));
188
- break;
189
- case pathname.includes('/upload'):
190
- // File upload endpoint for artifacts
191
- res.writeHead(200);
192
- res.end(JSON.stringify({
193
- success: true,
194
- message: 'File uploaded successfully',
195
- ETag: '"test-etag-12345"',
196
- }));
197
- break;
198
- default:
199
- // Unknown POST endpoint
200
- res.writeHead(404);
201
- res.end(JSON.stringify({
202
- error: 'POST endpoint not found',
203
- code: 'ENDPOINT_NOT_FOUND',
204
- }));
205
- }
206
- break;
207
- case 'PUT':
208
- switch (true) {
209
- case pathname.includes('/upload'):
210
- // PUT file upload endpoint for artifacts (alternative upload method)
211
- res.writeHead(200);
212
- res.end(JSON.stringify({
213
- success: true,
214
- message: 'File uploaded successfully via PUT',
215
- ETag: '"test-etag-put-12345"',
216
- }));
217
- break;
218
- default:
219
- // Unknown PUT endpoint
220
- res.writeHead(404);
221
- res.end(JSON.stringify({
222
- error: 'PUT endpoint not found',
223
- code: 'ENDPOINT_NOT_FOUND',
224
- }));
225
- }
226
- break;
227
- default:
228
- // Unsupported HTTP method
229
- res.writeHead(405);
230
- res.end(JSON.stringify({
231
- error: `Method ${method} not allowed`,
232
- code: 'METHOD_NOT_ALLOWED',
233
- }));
234
- }
235
- }
236
- async start() {
237
- return new Promise((resolve, reject) => {
238
- this.server = http.createServer((req, res) => {
239
- this.handleRequest(req, res);
240
- });
241
- this.server.listen(this.port, () => {
242
- console.log(`Mock server running on port ${this.port}`);
243
- resolve();
244
- });
245
- this.server.on('error', (error) => {
246
- reject(error);
247
- });
248
- });
249
- }
250
- async stop() {
251
- return new Promise((resolve) => {
252
- if (this.server) {
253
- this.server.close(() => {
254
- console.log('Mock server stopped');
255
- this.server = null;
256
- resolve();
257
- });
258
- }
259
- else {
260
- resolve();
261
- }
262
- });
263
- }
264
- getBaseUrl() {
265
- return `http://localhost:${this.port}`;
266
- }
267
- getPort() {
268
- return this.port;
269
- }
270
- getConsoleLogs() {
271
- return [...this.consoleLogs];
272
- }
273
- getRequests() {
274
- return [...this.requests];
275
- }
276
- clearRequests() {
277
- this.requests = [];
278
- }
279
- }
280
- exports.MockServer = MockServer;
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=timeout-1.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"timeout-1.d.ts","sourceRoot":"","sources":["../../../src/tests/timeout-handling/timeout-1.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=timeout-1.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"timeout-1.test.d.ts","sourceRoot":"","sources":["../../../src/tests/timeout-handling/timeout-1.test.ts"],"names":[],"mappings":""}
@@ -1,45 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const extraction_1 = require("../../types/extraction");
7
- const mock_server_1 = require("../mock-server");
8
- const test_helpers_1 = require("../test-helpers");
9
- const extraction_2 = __importDefault(require("./extraction"));
10
- describe('timeout-1 extraction', () => {
11
- let mockServer;
12
- beforeAll(async () => {
13
- mockServer = new mock_server_1.MockServer(3001);
14
- await mockServer.start();
15
- });
16
- afterAll(async () => {
17
- if (mockServer) {
18
- await mockServer.stop();
19
- }
20
- });
21
- beforeEach(() => {
22
- jest.clearAllMocks();
23
- mockServer.clearRequests();
24
- });
25
- it('should emit done event since there is no timeout', async () => {
26
- const baseUrl = mockServer.getBaseUrl();
27
- const event = (0, test_helpers_1.createEvent)({
28
- eventType: extraction_1.EventType.ExtractionDataStart,
29
- eventContextOverrides: {
30
- callback_url: `${baseUrl}/internal/airdrop.external-extractor.message`,
31
- worker_data_url: `${baseUrl}/internal/airdrop.external-worker`,
32
- },
33
- executionMetadataOverrides: {
34
- devrev_endpoint: `${baseUrl}`,
35
- },
36
- });
37
- await (0, extraction_2.default)([event], __dirname + '/timeout-1');
38
- const requests = mockServer.getRequests();
39
- const lastRequest = requests[requests.length - 1];
40
- // Expect last request to be emission of done event
41
- expect(lastRequest.url).toContain('airdrop.external-extractor.message');
42
- expect(lastRequest.method).toBe('POST');
43
- expect(lastRequest.body.event_type).toBe(extraction_1.ExtractorEventType.DataExtractionDone);
44
- });
45
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=timeout-2.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"timeout-2.d.ts","sourceRoot":"","sources":["../../../src/tests/timeout-handling/timeout-2.ts"],"names":[],"mappings":""}
@@ -1,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const index_1 = require("../../index");
4
- /* eslint-disable @typescript-eslint/no-explicit-any */
5
- // Simulate a network request with variable delays
6
- // eslint-disable @typescript-eslint/no-explicit-any
7
- const simulateNetworkRequest = async (url, delay) => {
8
- return new Promise((resolve) => {
9
- console.log(`Starting network request to ${url}...`);
10
- setTimeout(() => {
11
- console.log(`Completed network request to ${url} after ${delay}ms`);
12
- resolve({ status: 200, data: `Response from ${url}` });
13
- }, delay);
14
- });
15
- };
16
- (0, index_1.processTask)({
17
- task: async ({ adapter }) => {
18
- console.log('Starting network requests simulation...');
19
- // Define request configurations
20
- const requestConfigs = [
21
- { url: '/api/users', delay: 3000 },
22
- { url: '/api/products', delay: 4000 },
23
- { url: '/api/orders', delay: 5000 },
24
- { url: '/api/analytics', delay: 6000 },
25
- { url: '/api/reports', delay: 4000 },
26
- ];
27
- try {
28
- // Execute requests sequentially - this will take approximately 22 seconds total
29
- for (const config of requestConfigs) {
30
- const response = await simulateNetworkRequest(config.url, config.delay);
31
- console.log('Network request completed:', response.data);
32
- }
33
- console.log('All network requests completed successfully');
34
- await adapter.emit(index_1.ExtractorEventType.DataExtractionDone);
35
- }
36
- catch (error) {
37
- console.error('Network request failed:', error);
38
- await adapter.emit(index_1.ExtractorEventType.DataExtractionDone);
39
- }
40
- },
41
- onTimeout: async ({ adapter }) => {
42
- await adapter.emit(index_1.ExtractorEventType.DataExtractionProgress);
43
- },
44
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=timeout-2.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"timeout-2.test.d.ts","sourceRoot":"","sources":["../../../src/tests/timeout-handling/timeout-2.test.ts"],"names":[],"mappings":""}
@@ -1,46 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const extraction_1 = require("../../types/extraction");
7
- const mock_server_1 = require("../mock-server");
8
- const test_helpers_1 = require("../test-helpers");
9
- const extraction_2 = __importDefault(require("./extraction"));
10
- jest.setTimeout(15000);
11
- describe('timeout-2 extraction', () => {
12
- let mockServer;
13
- beforeAll(async () => {
14
- mockServer = new mock_server_1.MockServer(3001);
15
- await mockServer.start();
16
- });
17
- afterAll(async () => {
18
- if (mockServer) {
19
- await mockServer.stop();
20
- }
21
- });
22
- beforeEach(() => {
23
- jest.clearAllMocks();
24
- mockServer.clearRequests();
25
- });
26
- it('should emit progress event when soft timeout is reached', async () => {
27
- const baseUrl = mockServer.getBaseUrl();
28
- const event = (0, test_helpers_1.createEvent)({
29
- eventType: extraction_1.EventType.ExtractionDataStart,
30
- eventContextOverrides: {
31
- callback_url: `${baseUrl}/internal/airdrop.external-extractor.message`,
32
- worker_data_url: `${baseUrl}/internal/airdrop.external-worker`,
33
- },
34
- executionMetadataOverrides: {
35
- devrev_endpoint: `${baseUrl}`,
36
- },
37
- });
38
- await (0, extraction_2.default)([event], __dirname + '/timeout-2');
39
- const requests = mockServer.getRequests();
40
- const lastRequest = requests[requests.length - 1];
41
- // Expect last request to be emission of progress event
42
- expect(lastRequest.url).toContain('airdrop.external-extractor.message');
43
- expect(lastRequest.method).toBe('POST');
44
- expect(lastRequest.body.event_type).toBe(extraction_1.ExtractorEventType.DataExtractionProgress);
45
- });
46
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=timeout-3a.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"timeout-3a.d.ts","sourceRoot":"","sources":["../../../src/tests/timeout-handling/timeout-3a.ts"],"names":[],"mappings":""}
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const index_1 = require("../../index");
4
- (0, index_1.processTask)({
5
- task: async ({ adapter }) => {
6
- console.log('Starting intensive computation...');
7
- let result = 0;
8
- // Intensive loop - calibrated to exceed timeout
9
- for (let i = 1; i <= 30000; i++) {
10
- for (let num = 2; num <= 2000; num++) {
11
- let isPrime = true;
12
- for (let divisor = 2; divisor <= Math.sqrt(num); divisor++) {
13
- if (num % divisor === 0) {
14
- isPrime = false;
15
- break;
16
- }
17
- }
18
- if (isPrime) {
19
- for (let j = 0; j < 200; j++) {
20
- result +=
21
- Math.sin(num * j) * Math.cos(i * j) * Math.sqrt(num + i + j);
22
- result = Math.abs(result) % 1000000;
23
- }
24
- }
25
- }
26
- // Log every 500 iterations to see progress before timeout
27
- if (i % 500 === 0) {
28
- console.log(`timeout-3a iteration ${i}, result: ${result}`);
29
- }
30
- }
31
- console.log(`Final computation result: ${result}`);
32
- await adapter.emit(index_1.ExtractorEventType.DataExtractionDone);
33
- },
34
- onTimeout: async ({ adapter }) => {
35
- await adapter.emit(index_1.ExtractorEventType.DataExtractionProgress);
36
- },
37
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=timeout-3a.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"timeout-3a.test.d.ts","sourceRoot":"","sources":["../../../src/tests/timeout-handling/timeout-3a.test.ts"],"names":[],"mappings":""}
@@ -1,46 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const extraction_1 = require("../../types/extraction");
7
- const mock_server_1 = require("../mock-server");
8
- const test_helpers_1 = require("../test-helpers");
9
- const extraction_2 = __importDefault(require("./extraction"));
10
- jest.setTimeout(15000);
11
- describe('timeout-3a extraction', () => {
12
- let mockServer;
13
- beforeAll(async () => {
14
- mockServer = new mock_server_1.MockServer(3001);
15
- await mockServer.start();
16
- });
17
- afterAll(async () => {
18
- if (mockServer) {
19
- await mockServer.stop();
20
- }
21
- });
22
- beforeEach(() => {
23
- jest.clearAllMocks();
24
- mockServer.clearRequests();
25
- });
26
- it('should emit error event when hard timeout is reached', async () => {
27
- const baseUrl = mockServer.getBaseUrl();
28
- const event = (0, test_helpers_1.createEvent)({
29
- eventType: extraction_1.EventType.ExtractionDataStart,
30
- eventContextOverrides: {
31
- callback_url: `${baseUrl}/internal/airdrop.external-extractor.message`,
32
- worker_data_url: `${baseUrl}/internal/airdrop.external-worker`,
33
- },
34
- executionMetadataOverrides: {
35
- devrev_endpoint: `${baseUrl}`,
36
- },
37
- });
38
- await (0, extraction_2.default)([event], __dirname + '/timeout-3a');
39
- const requests = mockServer.getRequests();
40
- const lastRequest = requests[requests.length - 1];
41
- // Expect last request to be emission of error event since we force-kill the worker
42
- expect(lastRequest.url).toContain('airdrop.external-extractor.message');
43
- expect(lastRequest.method).toBe('POST');
44
- expect(lastRequest.body.event_type).toBe(extraction_1.ExtractorEventType.DataExtractionError);
45
- });
46
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=timeout-3b.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"timeout-3b.d.ts","sourceRoot":"","sources":["../../../src/tests/timeout-handling/timeout-3b.ts"],"names":[],"mappings":""}
@@ -1,38 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const index_1 = require("../../index");
4
- (0, index_1.processTask)({
5
- task: async ({ adapter }) => {
6
- console.log('Starting intensive computation...');
7
- let result = 0;
8
- // Intensive loop - calibrated to exceed 10 seconds but show progress
9
- for (let i = 1; i <= 30000; i++) {
10
- for (let num = 2; num <= 2000; num++) {
11
- let isPrime = true;
12
- for (let divisor = 2; divisor <= Math.sqrt(num); divisor++) {
13
- if (num % divisor === 0) {
14
- isPrime = false;
15
- break;
16
- }
17
- }
18
- if (isPrime) {
19
- for (let j = 0; j < 200; j++) {
20
- result +=
21
- Math.sin(num * j) * Math.cos(i * j) * Math.sqrt(num + i + j);
22
- result = Math.abs(result) % 1000000;
23
- }
24
- }
25
- }
26
- // Log every 500 iterations to see progress before timeout
27
- if (i % 500 === 0) {
28
- await new Promise((resolve) => setTimeout(resolve, 50));
29
- console.log(`timeout-3b iteration ${i}, result: ${result}`);
30
- }
31
- }
32
- console.log(`Final computation result: ${result}`);
33
- await adapter.emit(index_1.ExtractorEventType.DataExtractionDone);
34
- },
35
- onTimeout: async ({ adapter }) => {
36
- await adapter.emit(index_1.ExtractorEventType.DataExtractionProgress);
37
- },
38
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=timeout-3b.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"timeout-3b.test.d.ts","sourceRoot":"","sources":["../../../src/tests/timeout-handling/timeout-3b.test.ts"],"names":[],"mappings":""}
@@ -1,46 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const extraction_1 = require("../../types/extraction");
7
- const mock_server_1 = require("../mock-server");
8
- const test_helpers_1 = require("../test-helpers");
9
- const extraction_2 = __importDefault(require("./extraction"));
10
- jest.setTimeout(15000);
11
- describe('timeout-3b extraction', () => {
12
- let mockServer;
13
- beforeAll(async () => {
14
- mockServer = new mock_server_1.MockServer(3001);
15
- await mockServer.start();
16
- });
17
- afterAll(async () => {
18
- if (mockServer) {
19
- await mockServer.stop();
20
- }
21
- });
22
- beforeEach(() => {
23
- jest.clearAllMocks();
24
- mockServer.clearRequests();
25
- });
26
- it('should emit progress event when soft timeout is reached', async () => {
27
- const baseUrl = mockServer.getBaseUrl();
28
- const event = (0, test_helpers_1.createEvent)({
29
- eventType: extraction_1.EventType.ExtractionDataStart,
30
- eventContextOverrides: {
31
- callback_url: `${baseUrl}/internal/airdrop.external-extractor.message`,
32
- worker_data_url: `${baseUrl}/internal/airdrop.external-worker`,
33
- },
34
- executionMetadataOverrides: {
35
- devrev_endpoint: `${baseUrl}`,
36
- },
37
- });
38
- await (0, extraction_2.default)([event], __dirname + '/timeout-3b');
39
- const requests = mockServer.getRequests();
40
- const lastRequest = requests[requests.length - 1];
41
- // Expect last request to be emission of progress event
42
- expect(lastRequest.url).toContain('airdrop.external-extractor.message');
43
- expect(lastRequest.method).toBe('POST');
44
- expect(lastRequest.body.event_type).toBe(extraction_1.ExtractorEventType.DataExtractionProgress);
45
- });
46
- });