@devrev/ts-adaas 1.13.1-beta.2 → 1.13.1
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.
- package/package.json +3 -2
- package/dist/tests/backwards-compatibility/backwards-compatibility.test.d.ts +0 -3
- package/dist/tests/backwards-compatibility/backwards-compatibility.test.d.ts.map +0 -1
- package/dist/tests/backwards-compatibility/backwards-compatibility.test.js +0 -441
- package/dist/tests/backwards-compatibility/helpers.d.ts +0 -21
- package/dist/tests/backwards-compatibility/helpers.d.ts.map +0 -1
- package/dist/tests/backwards-compatibility/helpers.js +0 -151
- package/dist/tests/backwards-compatibility/jest.setup.d.ts +0 -2
- package/dist/tests/backwards-compatibility/jest.setup.d.ts.map +0 -1
- package/dist/tests/backwards-compatibility/jest.setup.js +0 -5
- package/dist/tests/dummy-connector/data-extraction.d.ts +0 -2
- package/dist/tests/dummy-connector/data-extraction.d.ts.map +0 -1
- package/dist/tests/dummy-connector/data-extraction.js +0 -43
- package/dist/tests/dummy-connector/data-extraction.test.d.ts +0 -2
- package/dist/tests/dummy-connector/data-extraction.test.d.ts.map +0 -1
- package/dist/tests/dummy-connector/data-extraction.test.js +0 -24
- package/dist/tests/dummy-connector/external-sync-units-extraction.d.ts +0 -2
- package/dist/tests/dummy-connector/external-sync-units-extraction.d.ts.map +0 -1
- package/dist/tests/dummy-connector/external-sync-units-extraction.js +0 -26
- package/dist/tests/dummy-connector/external-sync-units-extraction.test.d.ts +0 -2
- package/dist/tests/dummy-connector/external-sync-units-extraction.test.d.ts.map +0 -1
- package/dist/tests/dummy-connector/external-sync-units-extraction.test.js +0 -21
- package/dist/tests/dummy-connector/extraction.d.ts +0 -4
- package/dist/tests/dummy-connector/extraction.d.ts.map +0 -1
- package/dist/tests/dummy-connector/extraction.js +0 -19
- package/dist/tests/dummy-connector/metadata-extraction.d.ts +0 -2
- package/dist/tests/dummy-connector/metadata-extraction.d.ts.map +0 -1
- package/dist/tests/dummy-connector/metadata-extraction.js +0 -23
- package/dist/tests/dummy-connector/metadata-extraction.test.d.ts +0 -2
- package/dist/tests/dummy-connector/metadata-extraction.test.d.ts.map +0 -1
- package/dist/tests/dummy-connector/metadata-extraction.test.js +0 -54
- package/dist/tests/jest.setup.d.ts +0 -3
- package/dist/tests/jest.setup.d.ts.map +0 -1
- package/dist/tests/jest.setup.js +0 -14
- package/dist/tests/mock-server/mock-server.d.ts +0 -79
- package/dist/tests/mock-server/mock-server.d.ts.map +0 -1
- package/dist/tests/mock-server/mock-server.interfaces.d.ts +0 -53
- package/dist/tests/mock-server/mock-server.interfaces.d.ts.map +0 -1
- package/dist/tests/mock-server/mock-server.interfaces.js +0 -4
- package/dist/tests/mock-server/mock-server.js +0 -237
- package/dist/tests/spawn-worker/delete-event-type.test.d.ts +0 -2
- package/dist/tests/spawn-worker/delete-event-type.test.d.ts.map +0 -1
- package/dist/tests/spawn-worker/delete-event-type.test.js +0 -31
- package/dist/tests/spawn-worker/extraction.d.ts +0 -4
- package/dist/tests/spawn-worker/extraction.d.ts.map +0 -1
- package/dist/tests/spawn-worker/extraction.js +0 -19
- package/dist/tests/spawn-worker/some-cleanup-worker.d.ts +0 -2
- package/dist/tests/spawn-worker/some-cleanup-worker.d.ts.map +0 -1
- package/dist/tests/spawn-worker/some-cleanup-worker.js +0 -16
- package/dist/tests/spawn-worker/unknown-event-type.d.ts +0 -2
- package/dist/tests/spawn-worker/unknown-event-type.d.ts.map +0 -1
- package/dist/tests/spawn-worker/unknown-event-type.js +0 -19
- package/dist/tests/spawn-worker/unknown-event-type.test.d.ts +0 -2
- package/dist/tests/spawn-worker/unknown-event-type.test.d.ts.map +0 -1
- package/dist/tests/spawn-worker/unknown-event-type.test.js +0 -21
- package/dist/tests/test-helpers.d.ts +0 -10
- package/dist/tests/test-helpers.d.ts.map +0 -1
- package/dist/tests/test-helpers.interfaces.d.ts +0 -14
- package/dist/tests/test-helpers.interfaces.d.ts.map +0 -1
- package/dist/tests/test-helpers.interfaces.js +0 -2
- package/dist/tests/test-helpers.js +0 -101
- package/dist/tests/timeout-handling/extraction.d.ts +0 -4
- package/dist/tests/timeout-handling/extraction.d.ts.map +0 -1
- package/dist/tests/timeout-handling/extraction.js +0 -21
- package/dist/tests/timeout-handling/no-timeout.d.ts +0 -2
- package/dist/tests/timeout-handling/no-timeout.d.ts.map +0 -1
- package/dist/tests/timeout-handling/no-timeout.js +0 -14
- package/dist/tests/timeout-handling/no-timeout.test.d.ts +0 -2
- package/dist/tests/timeout-handling/no-timeout.test.d.ts.map +0 -1
- package/dist/tests/timeout-handling/no-timeout.test.js +0 -24
- package/dist/tests/timeout-handling/timeout-blocked.d.ts +0 -2
- package/dist/tests/timeout-handling/timeout-blocked.d.ts.map +0 -1
- package/dist/tests/timeout-handling/timeout-blocked.js +0 -23
- package/dist/tests/timeout-handling/timeout-blocked.test.d.ts +0 -2
- package/dist/tests/timeout-handling/timeout-blocked.test.d.ts.map +0 -1
- package/dist/tests/timeout-handling/timeout-blocked.test.js +0 -25
- package/dist/tests/timeout-handling/timeout-graceful.d.ts +0 -2
- package/dist/tests/timeout-handling/timeout-graceful.d.ts.map +0 -1
- package/dist/tests/timeout-handling/timeout-graceful.js +0 -17
- package/dist/tests/timeout-handling/timeout-graceful.test.d.ts +0 -2
- package/dist/tests/timeout-handling/timeout-graceful.test.d.ts.map +0 -1
- package/dist/tests/timeout-handling/timeout-graceful.test.js +0 -25
- package/dist/tests/timeout-handling/timeout-unblocked.d.ts +0 -2
- package/dist/tests/timeout-handling/timeout-unblocked.d.ts.map +0 -1
- package/dist/tests/timeout-handling/timeout-unblocked.js +0 -26
- package/dist/tests/timeout-handling/timeout-unblocked.test.d.ts +0 -2
- package/dist/tests/timeout-handling/timeout-unblocked.test.d.ts.map +0 -1
- package/dist/tests/timeout-handling/timeout-unblocked.test.js +0 -25
|
@@ -1,237 +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
|
-
exports.MockServer = void 0;
|
|
7
|
-
const express_1 = __importDefault(require("express"));
|
|
8
|
-
const mock_server_interfaces_1 = require("./mock-server.interfaces");
|
|
9
|
-
/**
|
|
10
|
-
* MockServer used in tests to mock internal AirSync endpoints.
|
|
11
|
-
* This is a simple mock server that listens on a port and responds to requests.
|
|
12
|
-
* Supports per-test route configuration to simulate different response scenarios.
|
|
13
|
-
*/
|
|
14
|
-
class MockServer {
|
|
15
|
-
constructor(port = mock_server_interfaces_1.DEFAULT_MOCK_SERVER_PORT) {
|
|
16
|
-
this.server = null;
|
|
17
|
-
this.routeHandlers = new Map();
|
|
18
|
-
this.requests = [];
|
|
19
|
-
this.requestCounts = new Map();
|
|
20
|
-
this.port = port;
|
|
21
|
-
this.baseUrl = `http://localhost:${this.port}`;
|
|
22
|
-
this.app = (0, express_1.default)();
|
|
23
|
-
this.app.use(express_1.default.json());
|
|
24
|
-
this.setupRoutes();
|
|
25
|
-
}
|
|
26
|
-
async start() {
|
|
27
|
-
return new Promise((resolve) => {
|
|
28
|
-
this.server = this.app.listen(this.port, () => {
|
|
29
|
-
console.log(`Mock server running on http://localhost:${this.port}.`);
|
|
30
|
-
resolve();
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
async stop() {
|
|
35
|
-
if (!this.server) {
|
|
36
|
-
return Promise.resolve();
|
|
37
|
-
}
|
|
38
|
-
return new Promise((resolve, reject) => {
|
|
39
|
-
this.server.close((err) => {
|
|
40
|
-
if (err) {
|
|
41
|
-
reject(err);
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
console.log('Mock server stopped.');
|
|
45
|
-
this.server = null;
|
|
46
|
-
resolve();
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Sets up routes for the mock server.
|
|
53
|
-
*/
|
|
54
|
-
setupRoutes() {
|
|
55
|
-
// TEST ENDPOINT
|
|
56
|
-
this.app.get('/test-endpoint', this.routeHandler('GET', '/test-endpoint'));
|
|
57
|
-
// CALLBACK URL
|
|
58
|
-
this.app.post('/callback_url', this.routeHandler('POST', '/callback_url'));
|
|
59
|
-
// WORKER DATA URL
|
|
60
|
-
this.app.post('/worker_data_url', this.routeHandler('POST', '/worker_data_url'));
|
|
61
|
-
this.app.get('/worker_data_url.get', this.routeHandler('GET', '/worker_data_url.get'));
|
|
62
|
-
this.app.post('/worker_data_url.update', this.routeHandler('POST', '/worker_data_url.update'));
|
|
63
|
-
// SNAP-INS URL
|
|
64
|
-
this.app.get('/internal/snap-ins.get', this.routeHandler('GET', '/internal/snap-ins.get'));
|
|
65
|
-
// AIRDROP RECIPE INITIAL DOMAIN MAPPINGS INSTALL URL
|
|
66
|
-
this.app.post('/internal/airdrop.recipe.initial-domain-mappings.install', this.routeHandler('POST', '/internal/airdrop.recipe.initial-domain-mappings.install'));
|
|
67
|
-
// ARTIFACTS URL
|
|
68
|
-
this.app.get('/internal/airdrop.artifacts.upload-url', this.routeHandler('GET', '/internal/airdrop.artifacts.upload-url'));
|
|
69
|
-
this.app.post('/internal/airdrop.artifacts.confirm-upload', this.routeHandler('POST', '/internal/airdrop.artifacts.confirm-upload'));
|
|
70
|
-
// FILE UPLOAD URL
|
|
71
|
-
this.app.post('/file-upload-url', this.routeHandler('POST', '/file-upload-url'));
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Creates a route handler that checks for custom handlers before using the default.
|
|
75
|
-
* @param method - The HTTP method
|
|
76
|
-
* @param path - The route path
|
|
77
|
-
* @returns A route handler function
|
|
78
|
-
*/
|
|
79
|
-
routeHandler(method, path) {
|
|
80
|
-
return (req, res) => {
|
|
81
|
-
const requestInfo = Object.assign({ method: req.method, url: req.url || req.path }, (req.body !== undefined && req.body !== null
|
|
82
|
-
? { body: req.body }
|
|
83
|
-
: {}));
|
|
84
|
-
this.requests.push(requestInfo);
|
|
85
|
-
const key = `${method}:${path}`;
|
|
86
|
-
const customHandler = this.routeHandlers.get(key);
|
|
87
|
-
if (customHandler) {
|
|
88
|
-
customHandler(req, res);
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
this.defaultRouteHandler(req, res);
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Default route handler for the mock server. Returns { success: true } for
|
|
97
|
-
* routes that are not explicitly set.
|
|
98
|
-
* @param req - The request object
|
|
99
|
-
* @param res - The response object
|
|
100
|
-
* @returns void
|
|
101
|
-
*/
|
|
102
|
-
defaultRouteHandler(req, res) {
|
|
103
|
-
if (req.method === 'GET' && req.path === '/worker_data_url.get') {
|
|
104
|
-
res.status(200).json({
|
|
105
|
-
state: JSON.stringify({}),
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
else if (req.method === 'GET' && req.path === '/internal/snap-ins.get') {
|
|
109
|
-
res.status(200).json({
|
|
110
|
-
snap_in: {
|
|
111
|
-
imports: [{ name: 'test_import_slug' }],
|
|
112
|
-
snap_in_version: { slug: 'test_snap_in_slug' },
|
|
113
|
-
},
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
else if (req.method === 'GET' &&
|
|
117
|
-
req.path === '/internal/airdrop.artifacts.upload-url') {
|
|
118
|
-
res.status(200).json({
|
|
119
|
-
upload_url: `${this.baseUrl}/file-upload-url`,
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
res.status(200).json({ success: true });
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Gets the route key for a given method and path.
|
|
128
|
-
* @param method - The HTTP method
|
|
129
|
-
* @param path - The route path
|
|
130
|
-
* @returns The route key in the format 'METHOD:path'
|
|
131
|
-
*/
|
|
132
|
-
getRouteKey(method, path) {
|
|
133
|
-
return `${method.toUpperCase()}:${path}`;
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Configures a route to return a specific status code and optional response body.
|
|
137
|
-
* @param config - The route configuration object
|
|
138
|
-
* @param config.path - The path of the route (e.g., '/callback_url')
|
|
139
|
-
* @param config.method - The HTTP method (e.g., 'GET', 'POST')
|
|
140
|
-
* @param config.status - The HTTP status code to return (e.g., 200, 401, 500)
|
|
141
|
-
* @param config.body - Optional response body to send as JSON
|
|
142
|
-
* @param config.retry - Optional retry configuration for simulating failures before success
|
|
143
|
-
*/
|
|
144
|
-
setRoute(config) {
|
|
145
|
-
const { path, method, status, body, retry, headers } = config;
|
|
146
|
-
const key = this.getRouteKey(method, path);
|
|
147
|
-
// Reset request count for this route if retry is configured
|
|
148
|
-
// This ensures a clean state each time setRoute is called
|
|
149
|
-
if (retry) {
|
|
150
|
-
this.requestCounts.set(key, 0);
|
|
151
|
-
}
|
|
152
|
-
this.routeHandlers.set(key, (req, res) => {
|
|
153
|
-
var _a, _b;
|
|
154
|
-
if (retry) {
|
|
155
|
-
const currentCount = this.requestCounts.get(key) || 0;
|
|
156
|
-
const failureCount = (_a = retry.failureCount) !== null && _a !== void 0 ? _a : 4;
|
|
157
|
-
const errorStatus = (_b = retry.errorStatus) !== null && _b !== void 0 ? _b : 500;
|
|
158
|
-
if (currentCount < failureCount) {
|
|
159
|
-
this.requestCounts.set(key, currentCount + 1);
|
|
160
|
-
if (retry.headers) {
|
|
161
|
-
res.set(retry.headers);
|
|
162
|
-
}
|
|
163
|
-
if (retry.errorBody !== undefined) {
|
|
164
|
-
res.status(errorStatus).json(retry.errorBody);
|
|
165
|
-
}
|
|
166
|
-
else {
|
|
167
|
-
res.status(errorStatus).send();
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
this.requestCounts.set(key, currentCount + 1);
|
|
172
|
-
if (headers) {
|
|
173
|
-
res.set(headers);
|
|
174
|
-
}
|
|
175
|
-
if (body !== undefined) {
|
|
176
|
-
res.status(status).json(body);
|
|
177
|
-
}
|
|
178
|
-
else {
|
|
179
|
-
this.defaultRouteHandler(req, res);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
else {
|
|
184
|
-
if (headers) {
|
|
185
|
-
res.set(headers);
|
|
186
|
-
}
|
|
187
|
-
if (body !== undefined) {
|
|
188
|
-
res.status(status).json(body);
|
|
189
|
-
}
|
|
190
|
-
else {
|
|
191
|
-
res.status(status).send();
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Resets all custom route handlers, restoring all default handlers.
|
|
198
|
-
* Also clears request tracking data.
|
|
199
|
-
*/
|
|
200
|
-
resetRoutes() {
|
|
201
|
-
this.routeHandlers.clear();
|
|
202
|
-
this.requestCounts.clear();
|
|
203
|
-
this.requests = [];
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* Returns the most recent request or undefined if no requests exist.
|
|
207
|
-
* @returns The last RequestInfo object or undefined
|
|
208
|
-
*/
|
|
209
|
-
getLastRequest() {
|
|
210
|
-
if (this.requests.length === 0) {
|
|
211
|
-
return undefined;
|
|
212
|
-
}
|
|
213
|
-
return this.requests[this.requests.length - 1];
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Gets the number of requests made to a specific endpoint.
|
|
217
|
-
* @param method - The HTTP method (e.g., 'GET', 'POST')
|
|
218
|
-
* @param path - The route path (e.g., '/test-endpoint', '/callback_url')
|
|
219
|
-
* @returns The number of requests made to the endpoint
|
|
220
|
-
*/
|
|
221
|
-
getRequestCount(method, path) {
|
|
222
|
-
return this.getRequests(method, path).length;
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* Gets all requests made to a specific endpoint.
|
|
226
|
-
* @param method - The HTTP method (e.g., 'GET', 'POST')
|
|
227
|
-
* @param path - The route path (e.g., '/test-endpoint', '/callback_url')
|
|
228
|
-
* @returns An array of RequestInfo objects for the endpoint
|
|
229
|
-
*/
|
|
230
|
-
getRequests(method, path) {
|
|
231
|
-
// Remove query parameters for comparison
|
|
232
|
-
const pathWithoutQuery = path.split('?')[0];
|
|
233
|
-
return this.requests.filter((req) => req.method.toUpperCase() === method.toUpperCase() &&
|
|
234
|
-
req.url.split('?')[0] === pathWithoutQuery);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
exports.MockServer = MockServer;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"delete-event-type.test.d.ts","sourceRoot":"","sources":["../../../src/tests/spawn-worker/delete-event-type.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,31 +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 jest_setup_1 = require("../jest.setup");
|
|
8
|
-
const test_helpers_1 = require("../test-helpers");
|
|
9
|
-
const extraction_2 = __importDefault(require("./extraction"));
|
|
10
|
-
describe('Delete event type', () => {
|
|
11
|
-
it('should successfully emit delete done event when the incoming event is start delete and there is no script passed', async () => {
|
|
12
|
-
const event = (0, test_helpers_1.createEvent)({
|
|
13
|
-
eventType: extraction_1.EventType.StartDeletingExtractorState,
|
|
14
|
-
});
|
|
15
|
-
await (0, extraction_2.default)([event]);
|
|
16
|
-
const lastRequest = jest_setup_1.mockServer.getLastRequest();
|
|
17
|
-
expect(lastRequest === null || lastRequest === void 0 ? void 0 : lastRequest.url).toContain('/callback_url');
|
|
18
|
-
expect(lastRequest === null || lastRequest === void 0 ? void 0 : lastRequest.method).toBe('POST');
|
|
19
|
-
expect((lastRequest === null || lastRequest === void 0 ? void 0 : lastRequest.body).event_type).toBe(extraction_1.ExtractorEventType.ExtractorStateDeletionDone);
|
|
20
|
-
});
|
|
21
|
-
it('should successfully emit delete done event when the incoming event is start delete and there is a script passed', async () => {
|
|
22
|
-
const event = (0, test_helpers_1.createEvent)({
|
|
23
|
-
eventType: extraction_1.EventType.StartDeletingExtractorState,
|
|
24
|
-
});
|
|
25
|
-
await (0, extraction_2.default)([event], __dirname + '/some-cleanup-worker');
|
|
26
|
-
const lastRequest = jest_setup_1.mockServer.getLastRequest();
|
|
27
|
-
expect(lastRequest === null || lastRequest === void 0 ? void 0 : lastRequest.url).toContain('/callback_url');
|
|
28
|
-
expect(lastRequest === null || lastRequest === void 0 ? void 0 : lastRequest.method).toBe('POST');
|
|
29
|
-
expect((lastRequest === null || lastRequest === void 0 ? void 0 : lastRequest.body).event_type).toBe(extraction_1.ExtractorEventType.ExtractorStateDeletionDone);
|
|
30
|
-
});
|
|
31
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extraction.d.ts","sourceRoot":"","sources":["../../../src/tests/spawn-worker/extraction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAS,MAAM,aAAa,CAAC;AASlD,QAAA,MAAM,GAAG,GAAU,QAAQ,YAAY,EAAE,EAAE,aAAa,MAAM,kBAY7D,CAAC;AAEF,eAAe,GAAG,CAAC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const index_1 = require("../../index");
|
|
4
|
-
const initialState = {};
|
|
5
|
-
const initialDomainMapping = {};
|
|
6
|
-
const run = async (events, workerPath) => {
|
|
7
|
-
for (const event of events) {
|
|
8
|
-
await (0, index_1.spawn)({
|
|
9
|
-
event,
|
|
10
|
-
initialState,
|
|
11
|
-
workerPath,
|
|
12
|
-
initialDomainMapping,
|
|
13
|
-
options: {
|
|
14
|
-
isLocalDevelopment: true,
|
|
15
|
-
},
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
exports.default = run;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"some-cleanup-worker.d.ts","sourceRoot":"","sources":["../../../src/tests/spawn-worker/some-cleanup-worker.ts"],"names":[],"mappings":""}
|
|
@@ -1,16 +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('Some cleanup logic executed.');
|
|
7
|
-
await adapter.emit(index_1.ExtractorEventType.ExtractorStateDeletionDone);
|
|
8
|
-
},
|
|
9
|
-
onTimeout: async ({ adapter }) => {
|
|
10
|
-
await adapter.emit(index_1.ExtractorEventType.ExtractorStateDeletionError, {
|
|
11
|
-
error: {
|
|
12
|
-
message: 'Failed to execute cleanup logic. Lambda timeout.',
|
|
13
|
-
},
|
|
14
|
-
});
|
|
15
|
-
},
|
|
16
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unknown-event-type.d.ts","sourceRoot":"","sources":["../../../src/tests/spawn-worker/unknown-event-type.ts"],"names":[],"mappings":""}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const index_1 = require("../../index");
|
|
4
|
-
(0, index_1.processTask)({
|
|
5
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
6
|
-
task: async ({ adapter }) => {
|
|
7
|
-
await new Promise((resolve) => setTimeout(() => {
|
|
8
|
-
console.log('task should not be called.');
|
|
9
|
-
resolve(true);
|
|
10
|
-
}, 1000));
|
|
11
|
-
},
|
|
12
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
13
|
-
onTimeout: async ({ adapter }) => {
|
|
14
|
-
await new Promise((resolve) => setTimeout(() => {
|
|
15
|
-
console.log('onTimeout should not be called.');
|
|
16
|
-
resolve(true);
|
|
17
|
-
}, 1000));
|
|
18
|
-
},
|
|
19
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unknown-event-type.test.d.ts","sourceRoot":"","sources":["../../../src/tests/spawn-worker/unknown-event-type.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,21 +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 jest_setup_1 = require("../jest.setup");
|
|
8
|
-
const test_helpers_1 = require("../test-helpers");
|
|
9
|
-
const extraction_2 = __importDefault(require("./extraction"));
|
|
10
|
-
describe('Unknown event type', () => {
|
|
11
|
-
it('should successfully emit unknown event type when the event type is not found', async () => {
|
|
12
|
-
const event = (0, test_helpers_1.createEvent)({
|
|
13
|
-
eventType: 'INVALID_EVENT_TYPE',
|
|
14
|
-
});
|
|
15
|
-
await (0, extraction_2.default)([event], __dirname + '/unknown-event-type');
|
|
16
|
-
const lastRequest = jest_setup_1.mockServer.getLastRequest();
|
|
17
|
-
expect(lastRequest === null || lastRequest === void 0 ? void 0 : lastRequest.url).toContain('/callback_url');
|
|
18
|
-
expect(lastRequest === null || lastRequest === void 0 ? void 0 : lastRequest.method).toBe('POST');
|
|
19
|
-
expect((lastRequest === null || lastRequest === void 0 ? void 0 : lastRequest.body).event_type).toBe(extraction_1.ExtractorEventType.UnknownEventType);
|
|
20
|
-
});
|
|
21
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Item, NormalizedAttachment, NormalizedItem } from '../repo/repo.interfaces';
|
|
2
|
-
import { AirdropEvent } from '../types/extraction';
|
|
3
|
-
import { CreateEventInterface } from './test-helpers.interfaces';
|
|
4
|
-
export declare function createEvent({ eventType, externalSyncUnits, progress, error, delay, contextOverrides, payloadOverrides, eventContextOverrides, executionMetadataOverrides, }: CreateEventInterface): AirdropEvent;
|
|
5
|
-
export declare function createItem(id: number): Item;
|
|
6
|
-
export declare function createItems(count: number): Item[];
|
|
7
|
-
export declare function normalizeItem(item: Item): NormalizedItem;
|
|
8
|
-
export declare function createAttachment(id: number): NormalizedAttachment;
|
|
9
|
-
export declare function createAttachments(count: number): NormalizedAttachment[];
|
|
10
|
-
//# sourceMappingURL=test-helpers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test-helpers.d.ts","sourceRoot":"","sources":["../../src/tests/test-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,oBAAoB,EACpB,cAAc,EACf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,wBAAgB,WAAW,CAAC,EAC1B,SAAS,EACT,iBAAsB,EACtB,QAAQ,EACR,KAAK,EACL,KAAK,EACL,gBAAqB,EACrB,gBAAqB,EACrB,qBAA0B,EAC1B,0BAA+B,GAChC,EAAE,oBAAoB,GAAG,YAAY,CA4ErC;AAED,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAO3C;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE,CAEjD;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,cAAc,CASxD;AAED,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,oBAAoB,CAQjE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,oBAAoB,EAAE,CAEvE"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ErrorRecord } from '../types/common';
|
|
2
|
-
import { AirdropEvent, EventContext, EventType, ExternalSyncUnit } from '../types/extraction';
|
|
3
|
-
export interface CreateEventInterface {
|
|
4
|
-
eventType: EventType;
|
|
5
|
-
externalSyncUnits?: ExternalSyncUnit[];
|
|
6
|
-
progress?: number;
|
|
7
|
-
error?: ErrorRecord;
|
|
8
|
-
delay?: number;
|
|
9
|
-
contextOverrides?: Partial<AirdropEvent['context']>;
|
|
10
|
-
payloadOverrides?: Partial<AirdropEvent['payload']>;
|
|
11
|
-
eventContextOverrides?: Partial<EventContext>;
|
|
12
|
-
executionMetadataOverrides?: Partial<AirdropEvent['execution_metadata']>;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=test-helpers.interfaces.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test-helpers.interfaces.d.ts","sourceRoot":"","sources":["../../src/tests/test-helpers.interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,gBAAgB,EACjB,MAAM,qBAAqB,CAAC;AAE7B,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,SAAS,CAAC;IACrB,iBAAiB,CAAC,EAAE,gBAAgB,EAAE,CAAC;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC;IACpD,gBAAgB,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC;IACpD,qBAAqB,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IAC9C,0BAA0B,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,oBAAoB,CAAC,CAAC,CAAC;CAC1E"}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createEvent = createEvent;
|
|
4
|
-
exports.createItem = createItem;
|
|
5
|
-
exports.createItems = createItems;
|
|
6
|
-
exports.normalizeItem = normalizeItem;
|
|
7
|
-
exports.createAttachment = createAttachment;
|
|
8
|
-
exports.createAttachments = createAttachments;
|
|
9
|
-
const jest_setup_1 = require("./jest.setup");
|
|
10
|
-
function createEvent({ eventType, externalSyncUnits = [], progress, error, delay, contextOverrides = {}, payloadOverrides = {}, eventContextOverrides = {}, executionMetadataOverrides = {}, }) {
|
|
11
|
-
const defaultEventContext = {
|
|
12
|
-
callback_url: `${jest_setup_1.mockServer.baseUrl}/callback_url`,
|
|
13
|
-
dev_org: 'test_dev_org',
|
|
14
|
-
dev_oid: 'test_dev_oid',
|
|
15
|
-
dev_org_id: 'test_dev_org_id',
|
|
16
|
-
dev_user: 'test_dev_user',
|
|
17
|
-
dev_user_id: 'test_dev_user_id',
|
|
18
|
-
dev_uid: 'test_dev_uid',
|
|
19
|
-
event_type_adaas: 'test_event_type_adaas',
|
|
20
|
-
external_sync_unit: 'test_external_sync_unit',
|
|
21
|
-
external_sync_unit_id: 'test_external_sync_unit_id',
|
|
22
|
-
external_sync_unit_name: 'test_external_sync_unit_name',
|
|
23
|
-
external_system: 'test_external_system',
|
|
24
|
-
external_system_id: 'test_external_system_id',
|
|
25
|
-
external_system_name: 'test_external_system_name',
|
|
26
|
-
external_system_type: 'test_external_system_type',
|
|
27
|
-
import_slug: 'test_import_slug',
|
|
28
|
-
mode: 'test_mode',
|
|
29
|
-
request_id: 'test_request_id',
|
|
30
|
-
request_id_adaas: 'test_request_id_adaas',
|
|
31
|
-
run_id: 'test_run_id',
|
|
32
|
-
sequence_version: 'test_sequence_version',
|
|
33
|
-
snap_in_slug: 'test_snap_in_slug',
|
|
34
|
-
snap_in_version_id: 'test_snap_in_version_id',
|
|
35
|
-
sync_run: 'test_sync_run',
|
|
36
|
-
sync_run_id: 'test_sync_run_id',
|
|
37
|
-
sync_tier: 'test_sync_tier',
|
|
38
|
-
sync_unit: 'test_sync_unit',
|
|
39
|
-
sync_unit_id: 'test_sync_unit_id',
|
|
40
|
-
uuid: 'test_uuid',
|
|
41
|
-
worker_data_url: `${jest_setup_1.mockServer.baseUrl}/worker_data_url`,
|
|
42
|
-
};
|
|
43
|
-
return {
|
|
44
|
-
context: Object.assign({ secrets: {
|
|
45
|
-
service_account_token: 'test_token',
|
|
46
|
-
}, snap_in_version_id: 'test_snap_in_version_id', snap_in_id: 'test_snap_in_id' }, contextOverrides),
|
|
47
|
-
payload: Object.assign({ connection_data: {
|
|
48
|
-
org_id: 'test_org_id',
|
|
49
|
-
org_name: 'test_org_name',
|
|
50
|
-
key: 'test_key',
|
|
51
|
-
key_type: 'test_key_type',
|
|
52
|
-
}, event_context: Object.assign(Object.assign({}, defaultEventContext), eventContextOverrides), event_type: eventType, event_data: {
|
|
53
|
-
external_sync_units: externalSyncUnits,
|
|
54
|
-
progress,
|
|
55
|
-
error,
|
|
56
|
-
delay,
|
|
57
|
-
} }, payloadOverrides),
|
|
58
|
-
execution_metadata: Object.assign({ devrev_endpoint: jest_setup_1.mockServer.baseUrl }, executionMetadataOverrides),
|
|
59
|
-
input_data: {
|
|
60
|
-
global_values: {
|
|
61
|
-
test_global_key: 'test_global_value',
|
|
62
|
-
},
|
|
63
|
-
event_sources: {
|
|
64
|
-
test_event_source_key: 'test_event_source_id',
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
function createItem(id) {
|
|
70
|
-
return {
|
|
71
|
-
id,
|
|
72
|
-
created_at: '2021-01-01',
|
|
73
|
-
updated_at: '2021-01-01',
|
|
74
|
-
name: 'item' + id,
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
function createItems(count) {
|
|
78
|
-
return Array.from({ length: count }, (_, index) => createItem(index));
|
|
79
|
-
}
|
|
80
|
-
function normalizeItem(item) {
|
|
81
|
-
return {
|
|
82
|
-
id: item.id,
|
|
83
|
-
created_date: item.created_at,
|
|
84
|
-
modified_date: item.updated_at,
|
|
85
|
-
data: {
|
|
86
|
-
name: item.name,
|
|
87
|
-
},
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
function createAttachment(id) {
|
|
91
|
-
return {
|
|
92
|
-
id: id.toString(),
|
|
93
|
-
url: 'https://test.com/' + id,
|
|
94
|
-
author_id: 'author' + id,
|
|
95
|
-
file_name: 'file' + id,
|
|
96
|
-
parent_id: 'parent' + id,
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
function createAttachments(count) {
|
|
100
|
-
return Array.from({ length: count }, (_, index) => createAttachment(index));
|
|
101
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extraction.d.ts","sourceRoot":"","sources":["../../../src/tests/timeout-handling/extraction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAS,MAAM,aAAa,CAAC;AASlD,QAAA,MAAM,GAAG,GAAU,QAAQ,YAAY,EAAE,EAAE,YAAY,MAAM,kBAc5D,CAAC;AAEF,eAAe,GAAG,CAAC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const index_1 = require("../../index");
|
|
4
|
-
const initialState = {};
|
|
5
|
-
const initialDomainMapping = {};
|
|
6
|
-
const run = async (events, workerPath) => {
|
|
7
|
-
for (const event of events) {
|
|
8
|
-
await (0, index_1.spawn)({
|
|
9
|
-
event,
|
|
10
|
-
initialState,
|
|
11
|
-
workerPath,
|
|
12
|
-
initialDomainMapping,
|
|
13
|
-
options: {
|
|
14
|
-
batchSize: 1000,
|
|
15
|
-
timeout: 5 * 1000, // 5 seconds
|
|
16
|
-
isLocalDevelopment: true,
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
exports.default = run;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"no-timeout.d.ts","sourceRoot":"","sources":["../../../src/tests/timeout-handling/no-timeout.ts"],"names":[],"mappings":""}
|
|
@@ -1,14 +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
|
-
for (let i = 0; i < 10; i++) {
|
|
7
|
-
console.log('no-timeout iteration', i);
|
|
8
|
-
}
|
|
9
|
-
await adapter.emit(index_1.ExtractorEventType.DataExtractionDone);
|
|
10
|
-
},
|
|
11
|
-
onTimeout: async ({ adapter }) => {
|
|
12
|
-
await adapter.emit(index_1.ExtractorEventType.DataExtractionProgress);
|
|
13
|
-
},
|
|
14
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"no-timeout.test.d.ts","sourceRoot":"","sources":["../../../src/tests/timeout-handling/no-timeout.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,24 +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 jest_setup_1 = require("../jest.setup");
|
|
8
|
-
const test_helpers_1 = require("../test-helpers");
|
|
9
|
-
const extraction_2 = __importDefault(require("./extraction"));
|
|
10
|
-
describe('No timeout', () => {
|
|
11
|
-
let event;
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
event = (0, test_helpers_1.createEvent)({
|
|
14
|
-
eventType: extraction_1.EventType.StartExtractingData,
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
it('should emit done event when no timeout is reached', async () => {
|
|
18
|
-
await (0, extraction_2.default)([event], __dirname + '/no-timeout');
|
|
19
|
-
const lastRequest = jest_setup_1.mockServer.getLastRequest();
|
|
20
|
-
expect(lastRequest === null || lastRequest === void 0 ? void 0 : lastRequest.url).toContain('/callback_url');
|
|
21
|
-
expect(lastRequest === null || lastRequest === void 0 ? void 0 : lastRequest.method).toBe('POST');
|
|
22
|
-
expect((lastRequest === null || lastRequest === void 0 ? void 0 : lastRequest.body).event_type).toBe(extraction_1.ExtractorEventType.DataExtractionDone);
|
|
23
|
-
});
|
|
24
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"timeout-blocked.d.ts","sourceRoot":"","sources":["../../../src/tests/timeout-handling/timeout-blocked.ts"],"names":[],"mappings":""}
|
|
@@ -1,23 +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
|
-
// Simple CPU-intensive nested loops that block the event loop
|
|
7
|
-
let result = 0;
|
|
8
|
-
for (let i = 0; i < 100000; i++) {
|
|
9
|
-
for (let j = 0; j < 10000; j++) {
|
|
10
|
-
result += Math.sqrt(i * j) * Math.sin(i + j);
|
|
11
|
-
result = Math.abs(result) % 1000000;
|
|
12
|
-
}
|
|
13
|
-
// Log every 10000 iterations to show progress
|
|
14
|
-
if (i % 10000 === 0) {
|
|
15
|
-
console.log(`timeout-blocked iteration ${i}`);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
await adapter.emit(index_1.ExtractorEventType.DataExtractionDone);
|
|
19
|
-
},
|
|
20
|
-
onTimeout: async ({ adapter }) => {
|
|
21
|
-
await adapter.emit(index_1.ExtractorEventType.DataExtractionProgress);
|
|
22
|
-
},
|
|
23
|
-
});
|