@devrev/ts-adaas 1.13.0 → 1.13.1-beta.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/dist/common/constants.d.ts +1 -0
- package/dist/common/constants.d.ts.map +1 -1
- package/dist/common/constants.js +7 -1
- package/dist/common/install-initial-domain-mapping.test.js +1 -1
- package/dist/http/axios-client-internal.d.ts.map +1 -1
- package/dist/http/axios-client-internal.js +10 -15
- package/dist/http/axios-client-internal.test.js +126 -161
- package/dist/tests/dummy-connector/data-extraction.d.ts +2 -0
- package/dist/tests/dummy-connector/data-extraction.d.ts.map +1 -0
- package/dist/tests/dummy-connector/data-extraction.js +43 -0
- package/dist/tests/dummy-connector/data-extraction.test.d.ts +2 -0
- package/dist/tests/dummy-connector/data-extraction.test.d.ts.map +1 -0
- package/dist/tests/dummy-connector/data-extraction.test.js +24 -0
- package/dist/tests/dummy-connector/external-sync-units-extraction.d.ts +2 -0
- package/dist/tests/dummy-connector/external-sync-units-extraction.d.ts.map +1 -0
- package/dist/tests/dummy-connector/external-sync-units-extraction.js +26 -0
- package/dist/tests/dummy-connector/external-sync-units-extraction.test.d.ts +2 -0
- package/dist/tests/dummy-connector/external-sync-units-extraction.test.d.ts.map +1 -0
- package/dist/tests/dummy-connector/external-sync-units-extraction.test.js +21 -0
- package/dist/tests/dummy-connector/extraction.d.ts +4 -0
- package/dist/tests/dummy-connector/extraction.d.ts.map +1 -0
- package/dist/tests/dummy-connector/extraction.js +19 -0
- package/dist/tests/dummy-connector/metadata-extraction.d.ts +2 -0
- package/dist/tests/dummy-connector/metadata-extraction.d.ts.map +1 -0
- package/dist/tests/dummy-connector/metadata-extraction.js +23 -0
- package/dist/tests/dummy-connector/metadata-extraction.test.d.ts +2 -0
- package/dist/tests/dummy-connector/metadata-extraction.test.d.ts.map +1 -0
- package/dist/tests/dummy-connector/metadata-extraction.test.js +54 -0
- package/dist/tests/jest.setup.d.ts +3 -0
- package/dist/tests/jest.setup.d.ts.map +1 -0
- package/dist/tests/jest.setup.js +14 -0
- package/dist/tests/mock-server/mock-server.d.ts +79 -0
- package/dist/tests/mock-server/mock-server.d.ts.map +1 -0
- package/dist/tests/mock-server/mock-server.interfaces.d.ts +53 -0
- package/dist/tests/mock-server/mock-server.interfaces.d.ts.map +1 -0
- package/dist/tests/mock-server/mock-server.interfaces.js +4 -0
- package/dist/tests/mock-server/mock-server.js +237 -0
- package/dist/tests/spawn-worker/delete-event-type.test.d.ts +2 -0
- package/dist/tests/spawn-worker/delete-event-type.test.d.ts.map +1 -0
- package/dist/tests/spawn-worker/delete-event-type.test.js +31 -0
- package/dist/tests/spawn-worker/extraction.d.ts +4 -0
- package/dist/tests/spawn-worker/extraction.d.ts.map +1 -0
- package/dist/tests/spawn-worker/extraction.js +19 -0
- package/dist/tests/spawn-worker/some-cleanup-worker.d.ts +2 -0
- package/dist/tests/spawn-worker/some-cleanup-worker.d.ts.map +1 -0
- package/dist/tests/spawn-worker/some-cleanup-worker.js +16 -0
- package/dist/tests/spawn-worker/unknown-event-type.d.ts +2 -0
- package/dist/tests/spawn-worker/unknown-event-type.d.ts.map +1 -0
- package/dist/tests/spawn-worker/unknown-event-type.js +19 -0
- package/dist/tests/spawn-worker/unknown-event-type.test.d.ts +2 -0
- package/dist/tests/spawn-worker/unknown-event-type.test.d.ts.map +1 -0
- package/dist/tests/spawn-worker/unknown-event-type.test.js +21 -0
- package/dist/tests/test-helpers.d.ts.map +1 -1
- package/dist/tests/test-helpers.js +4 -3
- package/dist/tests/timeout-handling/extraction.d.ts.map +1 -1
- package/dist/tests/timeout-handling/no-timeout.d.ts +2 -0
- package/dist/tests/timeout-handling/no-timeout.d.ts.map +1 -0
- package/dist/tests/timeout-handling/{timeout-1.js → no-timeout.js} +1 -1
- package/dist/tests/timeout-handling/no-timeout.test.d.ts +2 -0
- package/dist/tests/timeout-handling/no-timeout.test.d.ts.map +1 -0
- package/dist/tests/timeout-handling/no-timeout.test.js +24 -0
- package/dist/tests/timeout-handling/timeout-blocked.d.ts +2 -0
- package/dist/tests/timeout-handling/timeout-blocked.d.ts.map +1 -0
- package/dist/tests/timeout-handling/timeout-blocked.js +23 -0
- package/dist/tests/timeout-handling/timeout-blocked.test.d.ts +2 -0
- package/dist/tests/timeout-handling/timeout-blocked.test.d.ts.map +1 -0
- package/dist/tests/timeout-handling/timeout-blocked.test.js +25 -0
- package/dist/tests/timeout-handling/timeout-graceful.d.ts +2 -0
- package/dist/tests/timeout-handling/timeout-graceful.d.ts.map +1 -0
- package/dist/tests/timeout-handling/timeout-graceful.js +17 -0
- package/dist/tests/timeout-handling/timeout-graceful.test.d.ts +2 -0
- package/dist/tests/timeout-handling/timeout-graceful.test.d.ts.map +1 -0
- package/dist/tests/timeout-handling/timeout-graceful.test.js +25 -0
- package/dist/tests/timeout-handling/timeout-unblocked.d.ts +2 -0
- package/dist/tests/timeout-handling/timeout-unblocked.d.ts.map +1 -0
- package/dist/tests/timeout-handling/timeout-unblocked.js +26 -0
- package/dist/tests/timeout-handling/timeout-unblocked.test.d.ts +2 -0
- package/dist/tests/timeout-handling/timeout-unblocked.test.d.ts.map +1 -0
- package/dist/tests/timeout-handling/timeout-unblocked.test.js +25 -0
- package/dist/uploader/uploader.d.ts +72 -8
- package/dist/uploader/uploader.d.ts.map +1 -1
- package/dist/uploader/uploader.js +73 -8
- package/dist/workers/spawn.d.ts.map +1 -1
- package/dist/workers/spawn.js +57 -32
- package/dist/workers/worker-adapter.d.ts.map +1 -1
- package/dist/workers/worker-adapter.js +9 -4
- package/package.json +3 -8
- package/dist/tests/mock-server.d.ts +0 -21
- package/dist/tests/mock-server.d.ts.map +0 -1
- package/dist/tests/mock-server.js +0 -280
- package/dist/tests/timeout-handling/timeout-1.d.ts +0 -2
- package/dist/tests/timeout-handling/timeout-1.d.ts.map +0 -1
- package/dist/tests/timeout-handling/timeout-1.test.d.ts +0 -2
- package/dist/tests/timeout-handling/timeout-1.test.d.ts.map +0 -1
- package/dist/tests/timeout-handling/timeout-1.test.js +0 -45
- package/dist/tests/timeout-handling/timeout-2.d.ts +0 -2
- package/dist/tests/timeout-handling/timeout-2.d.ts.map +0 -1
- package/dist/tests/timeout-handling/timeout-2.js +0 -44
- package/dist/tests/timeout-handling/timeout-2.test.d.ts +0 -2
- package/dist/tests/timeout-handling/timeout-2.test.d.ts.map +0 -1
- package/dist/tests/timeout-handling/timeout-2.test.js +0 -46
- package/dist/tests/timeout-handling/timeout-3a.d.ts +0 -2
- package/dist/tests/timeout-handling/timeout-3a.d.ts.map +0 -1
- package/dist/tests/timeout-handling/timeout-3a.js +0 -37
- package/dist/tests/timeout-handling/timeout-3a.test.d.ts +0 -2
- package/dist/tests/timeout-handling/timeout-3a.test.d.ts.map +0 -1
- package/dist/tests/timeout-handling/timeout-3a.test.js +0 -46
- package/dist/tests/timeout-handling/timeout-3b.d.ts +0 -2
- package/dist/tests/timeout-handling/timeout-3b.d.ts.map +0 -1
- package/dist/tests/timeout-handling/timeout-3b.js +0 -38
- package/dist/tests/timeout-handling/timeout-3b.test.d.ts +0 -2
- package/dist/tests/timeout-handling/timeout-3b.test.d.ts.map +0 -1
- package/dist/tests/timeout-handling/timeout-3b.test.js +0 -46
|
@@ -8,6 +8,7 @@ export declare const STATELESS_EVENT_TYPES: EventType[];
|
|
|
8
8
|
export declare const STATEFUL_EXTRACTION_EVENT_TYPES: EventType[];
|
|
9
9
|
export declare const STATEFUL_LOADING_EVENT_TYPES: EventType[];
|
|
10
10
|
export declare const STATEFUL_EVENT_TYPES: EventType[];
|
|
11
|
+
export declare const DELETE_EVENT_TYPES: EventType[];
|
|
11
12
|
export declare const ARTIFACT_BATCH_SIZE = 2000;
|
|
12
13
|
export declare const MAX_DEVREV_ARTIFACT_SIZE: number;
|
|
13
14
|
export declare const MAX_DEVREV_FILENAME_LENGTH = 256;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/common/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGhD,eAAO,MAAM,8BAA8B,aAS1C,CAAC;AAEF,eAAO,MAAM,2BAA2B,aAKvC,CAAC;AAEF,eAAO,MAAM,mBAAmB,aAG/B,CAAC;AAEF,eAAO,MAAM,gCAAgC,aAI5C,CAAC;AAEF,eAAO,MAAM,6BAA6B,aAGzC,CAAC;AAEF,eAAO,MAAM,qBAAqB,aAGjC,CAAC;AAEF,eAAO,MAAM,+BAA+B,aAGzC,CAAC;AAEJ,eAAO,MAAM,4BAA4B,aAExC,CAAC;AAEF,eAAO,MAAM,oBAAoB,aAGhC,CAAC;AAEF,eAAO,MAAM,mBAAmB,OAAO,CAAC;AACxC,eAAO,MAAM,wBAAwB,QAAyB,CAAC;AAC/D,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAC9C,eAAO,MAAM,oCAAoC,KAAK,CAAC;AAEvD,eAAO,MAAM,0BAA0B;;;;CAItC,CAAC;AAEF,eAAO,MAAM,eAAe,KAAsB,CAAC;AAEnD,eAAO,MAAM,sBAAsB,QAAiB,CAAC;AACrD,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAC3C,eAAO,MAAM,mBAAmB,QAAY,CAAC;AAE7C,eAAO,MAAM,sBAAsB,QAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/common/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGhD,eAAO,MAAM,8BAA8B,aAS1C,CAAC;AAEF,eAAO,MAAM,2BAA2B,aAKvC,CAAC;AAEF,eAAO,MAAM,mBAAmB,aAG/B,CAAC;AAEF,eAAO,MAAM,gCAAgC,aAI5C,CAAC;AAEF,eAAO,MAAM,6BAA6B,aAGzC,CAAC;AAEF,eAAO,MAAM,qBAAqB,aAGjC,CAAC;AAEF,eAAO,MAAM,+BAA+B,aAGzC,CAAC;AAEJ,eAAO,MAAM,4BAA4B,aAExC,CAAC;AAEF,eAAO,MAAM,oBAAoB,aAGhC,CAAC;AAEF,eAAO,MAAM,kBAAkB,aAK9B,CAAC;AAEF,eAAO,MAAM,mBAAmB,OAAO,CAAC;AACxC,eAAO,MAAM,wBAAwB,QAAyB,CAAC;AAC/D,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAC9C,eAAO,MAAM,oCAAoC,KAAK,CAAC;AAEvD,eAAO,MAAM,0BAA0B;;;;CAItC,CAAC;AAEF,eAAO,MAAM,eAAe,KAAsB,CAAC;AAEnD,eAAO,MAAM,sBAAsB,QAAiB,CAAC;AACrD,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAC3C,eAAO,MAAM,mBAAmB,QAAY,CAAC;AAE7C,eAAO,MAAM,sBAAsB,QAAgB,CAAC"}
|
package/dist/common/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_SLEEP_DELAY_MS = exports.MEMORY_LOG_INTERVAL = exports.HARD_TIMEOUT_MULTIPLIER = exports.DEFAULT_LAMBDA_TIMEOUT = exports.LIBRARY_VERSION = exports.AIRDROP_DEFAULT_ITEM_TYPES = exports.MAX_DEVREV_FILENAME_EXTENSION_LENGTH = exports.MAX_DEVREV_FILENAME_LENGTH = exports.MAX_DEVREV_ARTIFACT_SIZE = exports.ARTIFACT_BATCH_SIZE = exports.STATEFUL_EVENT_TYPES = exports.STATEFUL_LOADING_EVENT_TYPES = exports.STATEFUL_EXTRACTION_EVENT_TYPES = exports.STATELESS_EVENT_TYPES = exports.STATELESS_LOADING_EVENT_TYPES = exports.STATELESS_EXTRACTION_EVENT_TYPES = exports.ALLOWED_EVENT_TYPES = exports.ALLOWED_LOADING_EVENT_TYPES = exports.ALLOWED_EXTRACTION_EVENT_TYPES = void 0;
|
|
3
|
+
exports.DEFAULT_SLEEP_DELAY_MS = exports.MEMORY_LOG_INTERVAL = exports.HARD_TIMEOUT_MULTIPLIER = exports.DEFAULT_LAMBDA_TIMEOUT = exports.LIBRARY_VERSION = exports.AIRDROP_DEFAULT_ITEM_TYPES = exports.MAX_DEVREV_FILENAME_EXTENSION_LENGTH = exports.MAX_DEVREV_FILENAME_LENGTH = exports.MAX_DEVREV_ARTIFACT_SIZE = exports.ARTIFACT_BATCH_SIZE = exports.DELETE_EVENT_TYPES = exports.STATEFUL_EVENT_TYPES = exports.STATEFUL_LOADING_EVENT_TYPES = exports.STATEFUL_EXTRACTION_EVENT_TYPES = exports.STATELESS_EVENT_TYPES = exports.STATELESS_LOADING_EVENT_TYPES = exports.STATELESS_EXTRACTION_EVENT_TYPES = exports.ALLOWED_EVENT_TYPES = exports.ALLOWED_LOADING_EVENT_TYPES = exports.ALLOWED_EXTRACTION_EVENT_TYPES = void 0;
|
|
4
4
|
const extraction_1 = require("../types/extraction");
|
|
5
5
|
const helpers_1 = require("./helpers");
|
|
6
6
|
exports.ALLOWED_EXTRACTION_EVENT_TYPES = [
|
|
@@ -42,6 +42,12 @@ exports.STATEFUL_EVENT_TYPES = [
|
|
|
42
42
|
...exports.STATEFUL_EXTRACTION_EVENT_TYPES,
|
|
43
43
|
...exports.STATEFUL_LOADING_EVENT_TYPES,
|
|
44
44
|
];
|
|
45
|
+
exports.DELETE_EVENT_TYPES = [
|
|
46
|
+
extraction_1.EventType.StartDeletingExtractorState,
|
|
47
|
+
extraction_1.EventType.StartDeletingExtractorAttachmentsState,
|
|
48
|
+
extraction_1.EventType.StartDeletingLoaderState,
|
|
49
|
+
extraction_1.EventType.StartDeletingLoaderAttachmentState,
|
|
50
|
+
];
|
|
45
51
|
exports.ARTIFACT_BATCH_SIZE = 2000;
|
|
46
52
|
exports.MAX_DEVREV_ARTIFACT_SIZE = 2 * 1024 * 1024 * 1024; // 2GB
|
|
47
53
|
exports.MAX_DEVREV_FILENAME_LENGTH = 256;
|
|
@@ -40,7 +40,7 @@ describe(install_initial_domain_mapping_1.installInitialDomainMapping.name, () =
|
|
|
40
40
|
},
|
|
41
41
|
},
|
|
42
42
|
};
|
|
43
|
-
const mockEndpoint = '
|
|
43
|
+
const mockEndpoint = 'http://localhost:3001';
|
|
44
44
|
const mockToken = 'test_token';
|
|
45
45
|
// After each test, clear all mocks to prevent state from leaking.
|
|
46
46
|
afterEach(() => {
|
|
@@ -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;
|
|
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;AAiFH,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -12,27 +12,22 @@ const axiosClient = axios_1.default.create({
|
|
|
12
12
|
exports.axiosClient = axiosClient;
|
|
13
13
|
(0, axios_retry_1.default)(axiosClient, {
|
|
14
14
|
retries: 5,
|
|
15
|
+
shouldResetTimeout: true,
|
|
15
16
|
retryDelay: (retryCount, error) => {
|
|
16
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
17
|
-
|
|
17
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
18
|
+
let delay;
|
|
18
19
|
if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 429) {
|
|
19
20
|
const retryAfter = ((_c = (_b = error.response) === null || _b === void 0 ? void 0 : _b.headers) === null || _c === void 0 ? void 0 : _c['retry-after']) ||
|
|
20
21
|
((_e = (_d = error.response) === null || _d === void 0 ? void 0 : _d.headers) === null || _e === void 0 ? void 0 : _e['Retry-After']);
|
|
21
|
-
|
|
22
|
-
const delay = parseInt(retryAfter, 10) * 1000;
|
|
23
|
-
const delayInSeconds = Math.round(delay / 1000);
|
|
24
|
-
console.warn(`Retrying ${(_f = error.config) === null || _f === void 0 ? void 0 : _f.method} request to ${(_g = error.config) === null || _g === void 0 ? void 0 : _g.url} in ${delayInSeconds}s due to 429 Too Many Requests.`);
|
|
25
|
-
return delay;
|
|
22
|
+
delay = parseInt(retryAfter, 10) * 1000;
|
|
26
23
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
else {
|
|
25
|
+
delay = axios_retry_1.default.exponentialDelay(retryCount, error, 1000);
|
|
26
|
+
}
|
|
27
|
+
const requestId = ((_g = (_f = error.config) === null || _f === void 0 ? void 0 : _f.headers) === null || _g === void 0 ? void 0 : _g['x-request-id']) ||
|
|
28
|
+
((_j = (_h = error.config) === null || _h === void 0 ? void 0 : _h.headers) === null || _j === void 0 ? void 0 : _j['X-Request-ID']);
|
|
30
29
|
const delayInSeconds = Math.round(delay / 1000);
|
|
31
|
-
|
|
32
|
-
const errorDescription = ((_h = error.response) === null || _h === void 0 ? void 0 : _h.status)
|
|
33
|
-
? `${error.response.status} error`
|
|
34
|
-
: 'network (no response) error';
|
|
35
|
-
console.warn(`Retrying ${(_j = error.config) === null || _j === void 0 ? void 0 : _j.method} request to ${(_k = error.config) === null || _k === void 0 ? void 0 : _k.url} in ${delayInSeconds}s due to ${errorDescription}.`);
|
|
30
|
+
console.warn(`Retrying request to ${(_k = error.config) === null || _k === void 0 ? void 0 : _k.url} in ${delayInSeconds}s due to ${(_m = (_l = error.response) === null || _l === void 0 ? void 0 : _l.status) !== null && _m !== void 0 ? _m : 'unknown'} error.`, Object.assign(Object.assign({ method: (_o = error.config) === null || _o === void 0 ? void 0 : _o.method }, (retryCount && { retryCount })), (requestId && { requestId })));
|
|
36
31
|
return delay;
|
|
37
32
|
},
|
|
38
33
|
retryCondition: (error) => {
|
|
@@ -1,189 +1,154 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
3
|
+
const jest_setup_1 = require("../tests/jest.setup");
|
|
7
4
|
const axios_client_internal_1 = require("./axios-client-internal");
|
|
5
|
+
jest.setTimeout(60000);
|
|
8
6
|
describe('Internal Axios Client', () => {
|
|
9
|
-
let mockAdapter;
|
|
10
|
-
beforeEach(() => {
|
|
11
|
-
jest.clearAllMocks();
|
|
12
|
-
jest.spyOn(console, 'warn').mockImplementation(() => { });
|
|
13
|
-
mockAdapter = new axios_mock_adapter_1.default(axios_client_internal_1.axiosClient);
|
|
14
|
-
});
|
|
15
|
-
afterEach(() => {
|
|
16
|
-
jest.restoreAllMocks();
|
|
17
|
-
mockAdapter.restore();
|
|
18
|
-
});
|
|
19
7
|
it('should not retry on 200 response', async () => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const responseData = { id: 1, title: 'test title' };
|
|
23
|
-
mockAdapter.onGet(testUrl).reply(200, responseData);
|
|
24
|
-
// Act
|
|
25
|
-
await axios_client_internal_1.axiosClient.get(testUrl);
|
|
26
|
-
// Assert
|
|
27
|
-
expect(mockAdapter.history.get).toHaveLength(1);
|
|
8
|
+
await axios_client_internal_1.axiosClient.get(jest_setup_1.mockServer.baseUrl + '/test-endpoint');
|
|
9
|
+
expect(jest_setup_1.mockServer.getRequestCount('GET', '/test-endpoint')).toBe(1);
|
|
28
10
|
});
|
|
29
|
-
it('should not retry
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
// Act
|
|
35
|
-
await expect(axios_client_internal_1.axiosClient.get(testUrl)).rejects.toMatchObject({
|
|
36
|
-
response: { status: 400 },
|
|
11
|
+
it('should not retry on 400 response', async () => {
|
|
12
|
+
jest_setup_1.mockServer.setRoute({
|
|
13
|
+
path: '/test-endpoint',
|
|
14
|
+
method: 'GET',
|
|
15
|
+
status: 400,
|
|
37
16
|
});
|
|
38
|
-
|
|
39
|
-
expect(
|
|
17
|
+
await expect(axios_client_internal_1.axiosClient.get(jest_setup_1.mockServer.baseUrl + '/test-endpoint')).rejects.toThrow();
|
|
18
|
+
expect(jest_setup_1.mockServer.getRequestCount('GET', '/test-endpoint')).toBe(1);
|
|
40
19
|
});
|
|
41
20
|
// TODO: This test is working as expected, but it takes too long to run. Not
|
|
42
21
|
// sure if it is good idea to have it.
|
|
43
|
-
//
|
|
44
|
-
//
|
|
45
|
-
//
|
|
46
|
-
//
|
|
47
|
-
//
|
|
48
|
-
//
|
|
49
|
-
//
|
|
22
|
+
// it('should retry on 500 response', async () => {
|
|
23
|
+
// mockServer.setRoute({
|
|
24
|
+
// path: '/test-endpoint',
|
|
25
|
+
// method: 'GET',
|
|
26
|
+
// status: 200,
|
|
27
|
+
// retry: {
|
|
28
|
+
// failureCount: 4,
|
|
29
|
+
// errorStatus: 500,
|
|
30
|
+
// errorBody: { error: 'Internal Server Error' },
|
|
31
|
+
// },
|
|
32
|
+
// });
|
|
33
|
+
// await axiosClient.get(mockServer.baseUrl + '/test-endpoint');
|
|
34
|
+
// expect(mockServer.getRequestCount('GET', '/test-endpoint')).toBe(5);
|
|
50
35
|
// });
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
'Retry-After': '2',
|
|
81
|
-
})
|
|
82
|
-
.onGet(testUrl)
|
|
83
|
-
.reply(200, successData);
|
|
84
|
-
// Act
|
|
85
|
-
const response = await axios_client_internal_1.axiosClient.get(testUrl);
|
|
86
|
-
// Assert
|
|
87
|
-
expect(response.status).toBe(200);
|
|
88
|
-
expect(response.data).toEqual(successData);
|
|
89
|
-
expect(mockAdapter.history.get).toHaveLength(2); // 1 initial + 1 retry
|
|
36
|
+
it('should retry 2 times on 500 response and then succeed third time when response is 200', async () => {
|
|
37
|
+
jest_setup_1.mockServer.setRoute({
|
|
38
|
+
path: '/test-endpoint',
|
|
39
|
+
method: 'GET',
|
|
40
|
+
status: 200,
|
|
41
|
+
retry: {
|
|
42
|
+
failureCount: 2,
|
|
43
|
+
errorStatus: 500,
|
|
44
|
+
errorBody: { error: 'Internal Server Error' },
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
await axios_client_internal_1.axiosClient.get(jest_setup_1.mockServer.baseUrl + '/test-endpoint');
|
|
48
|
+
expect(jest_setup_1.mockServer.getRequestCount('GET', '/test-endpoint')).toBe(3);
|
|
49
|
+
});
|
|
50
|
+
it('should retry once after 3 seconds when response is 429 and Retry-After header is valid value', async () => {
|
|
51
|
+
jest_setup_1.mockServer.setRoute({
|
|
52
|
+
path: '/test-endpoint',
|
|
53
|
+
method: 'GET',
|
|
54
|
+
status: 200,
|
|
55
|
+
retry: {
|
|
56
|
+
failureCount: 1,
|
|
57
|
+
errorStatus: 429,
|
|
58
|
+
headers: {
|
|
59
|
+
'Retry-After': '3',
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
await axios_client_internal_1.axiosClient.get(jest_setup_1.mockServer.baseUrl + '/test-endpoint');
|
|
64
|
+
expect(jest_setup_1.mockServer.getRequestCount('GET', '/test-endpoint')).toBe(2);
|
|
90
65
|
});
|
|
91
|
-
it('should retry once after
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
})
|
|
102
|
-
.onGet(testUrl)
|
|
103
|
-
.reply(200, successData);
|
|
104
|
-
// Act
|
|
66
|
+
it('should retry once after 3 seconds and measure time between retries when response is 429 and Retry-After header is valid value', async () => {
|
|
67
|
+
jest_setup_1.mockServer.setRoute({
|
|
68
|
+
path: '/test-endpoint',
|
|
69
|
+
method: 'GET',
|
|
70
|
+
status: 200,
|
|
71
|
+
retry: {
|
|
72
|
+
failureCount: 1,
|
|
73
|
+
errorStatus: 429,
|
|
74
|
+
headers: { 'Retry-After': '3' },
|
|
75
|
+
},
|
|
76
|
+
});
|
|
105
77
|
const startTime = Date.now();
|
|
106
|
-
|
|
78
|
+
await axios_client_internal_1.axiosClient.get(jest_setup_1.mockServer.baseUrl + '/test-endpoint');
|
|
107
79
|
const endTime = Date.now();
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
expect(
|
|
111
|
-
expect(
|
|
112
|
-
expect(mockAdapter.history.get).toHaveLength(2); // 1 initial + 1 retry
|
|
113
|
-
const expectedWaitTime = retryAfterSeconds * 1000;
|
|
114
|
-
expect(actualWaitTime).toBeGreaterThanOrEqual(expectedWaitTime - 100);
|
|
115
|
-
expect(actualWaitTime).toBeLessThan(expectedWaitTime + 1000); // Allow up to 1s extra for processing
|
|
80
|
+
const duration = endTime - startTime;
|
|
81
|
+
const expectedDuration = 3 * 1000;
|
|
82
|
+
expect(duration).toBeGreaterThanOrEqual(expectedDuration);
|
|
83
|
+
expect(duration).toBeLessThan(expectedDuration + 1000);
|
|
116
84
|
});
|
|
117
85
|
it('should retry when response is 429 and Retry-After header is lowercase', async () => {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
expect(response.status).toBe(200);
|
|
131
|
-
expect(response.data).toEqual(successData);
|
|
132
|
-
expect(mockAdapter.history.get).toHaveLength(2); // 1 initial + 1 retry
|
|
86
|
+
jest_setup_1.mockServer.setRoute({
|
|
87
|
+
path: '/test-endpoint',
|
|
88
|
+
method: 'GET',
|
|
89
|
+
status: 200,
|
|
90
|
+
retry: {
|
|
91
|
+
failureCount: 1,
|
|
92
|
+
errorStatus: 429,
|
|
93
|
+
headers: { 'retry-after': '3' },
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
await axios_client_internal_1.axiosClient.get(jest_setup_1.mockServer.baseUrl + '/test-endpoint');
|
|
97
|
+
expect(jest_setup_1.mockServer.getRequestCount('GET', '/test-endpoint')).toBe(2);
|
|
133
98
|
});
|
|
134
99
|
it('[edge] should not retry when response is 429 and there is no Retry-After header', async () => {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
100
|
+
jest_setup_1.mockServer.setRoute({
|
|
101
|
+
path: '/test-endpoint',
|
|
102
|
+
method: 'GET',
|
|
103
|
+
status: 200,
|
|
104
|
+
retry: {
|
|
105
|
+
failureCount: 1,
|
|
106
|
+
errorStatus: 429,
|
|
107
|
+
},
|
|
142
108
|
});
|
|
143
|
-
|
|
144
|
-
expect(
|
|
109
|
+
await expect(axios_client_internal_1.axiosClient.get(jest_setup_1.mockServer.baseUrl + '/test-endpoint')).rejects.toThrow();
|
|
110
|
+
expect(jest_setup_1.mockServer.getRequestCount('GET', '/test-endpoint')).toBe(1);
|
|
145
111
|
});
|
|
146
112
|
it('[edge] should retry when response is 429 and Retry-After header is 0', async () => {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
expect(response.status).toBe(200);
|
|
160
|
-
expect(response.data).toEqual(successData);
|
|
161
|
-
expect(mockAdapter.history.get).toHaveLength(2); // 1 initial + 1 retry
|
|
113
|
+
jest_setup_1.mockServer.setRoute({
|
|
114
|
+
path: '/test-endpoint',
|
|
115
|
+
method: 'GET',
|
|
116
|
+
status: 200,
|
|
117
|
+
retry: {
|
|
118
|
+
failureCount: 1,
|
|
119
|
+
errorStatus: 429,
|
|
120
|
+
headers: { 'Retry-After': '0' },
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
await axios_client_internal_1.axiosClient.get(jest_setup_1.mockServer.baseUrl + '/test-endpoint');
|
|
124
|
+
expect(jest_setup_1.mockServer.getRequestCount('GET', '/test-endpoint')).toBe(2);
|
|
162
125
|
});
|
|
163
|
-
it('[edge] should not retry when response is 429 and Retry-After header is negative', async () => {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
126
|
+
it('[edge] should not retry when response is 429 and Retry-After header is negative value', async () => {
|
|
127
|
+
jest_setup_1.mockServer.setRoute({
|
|
128
|
+
path: '/test-endpoint',
|
|
129
|
+
method: 'GET',
|
|
130
|
+
status: 200,
|
|
131
|
+
retry: {
|
|
132
|
+
failureCount: 1,
|
|
133
|
+
errorStatus: 429,
|
|
134
|
+
headers: { 'Retry-After': '-1' },
|
|
135
|
+
},
|
|
171
136
|
});
|
|
172
|
-
|
|
173
|
-
expect(
|
|
137
|
+
await expect(axios_client_internal_1.axiosClient.get(jest_setup_1.mockServer.baseUrl + '/test-endpoint')).rejects.toThrow();
|
|
138
|
+
expect(jest_setup_1.mockServer.getRequestCount('GET', '/test-endpoint')).toBe(1);
|
|
174
139
|
});
|
|
175
140
|
it('[edge] should not retry when response is 429 and Retry-After header is invalid value', async () => {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
141
|
+
jest_setup_1.mockServer.setRoute({
|
|
142
|
+
path: '/test-endpoint',
|
|
143
|
+
method: 'GET',
|
|
144
|
+
status: 200,
|
|
145
|
+
retry: {
|
|
146
|
+
failureCount: 1,
|
|
147
|
+
errorStatus: 429,
|
|
148
|
+
headers: { 'Retry-After': 'invalid' },
|
|
149
|
+
},
|
|
185
150
|
});
|
|
186
|
-
|
|
187
|
-
expect(
|
|
151
|
+
await expect(axios_client_internal_1.axiosClient.get(jest_setup_1.mockServer.baseUrl + '/test-endpoint')).rejects.toThrow();
|
|
152
|
+
expect(jest_setup_1.mockServer.getRequestCount('GET', '/test-endpoint')).toBe(1);
|
|
188
153
|
});
|
|
189
154
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-extraction.d.ts","sourceRoot":"","sources":["../../../src/tests/dummy-connector/data-extraction.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const index_1 = require("../../index");
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
|
+
const normalizeTask = (task) => {
|
|
6
|
+
return {
|
|
7
|
+
id: task.id,
|
|
8
|
+
created_date: task.created_at,
|
|
9
|
+
modified_date: task.updated_at,
|
|
10
|
+
data: {
|
|
11
|
+
name: task.name,
|
|
12
|
+
description: task.description,
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
const repos = [
|
|
17
|
+
{
|
|
18
|
+
itemType: 'tasks',
|
|
19
|
+
normalize: normalizeTask,
|
|
20
|
+
},
|
|
21
|
+
];
|
|
22
|
+
(0, index_1.processTask)({
|
|
23
|
+
task: async ({ adapter }) => {
|
|
24
|
+
var _a;
|
|
25
|
+
adapter.initializeRepos(repos);
|
|
26
|
+
const tasks = [];
|
|
27
|
+
for (let i = 0; i < 10; i++) {
|
|
28
|
+
const task = {
|
|
29
|
+
id: `task_${i}`,
|
|
30
|
+
name: `Task ${i}`,
|
|
31
|
+
description: `Description ${i}`,
|
|
32
|
+
created_at: new Date().toISOString(),
|
|
33
|
+
updated_at: new Date().toISOString(),
|
|
34
|
+
};
|
|
35
|
+
tasks.push(task);
|
|
36
|
+
}
|
|
37
|
+
await ((_a = adapter.getRepo('tasks')) === null || _a === void 0 ? void 0 : _a.push(tasks));
|
|
38
|
+
await adapter.emit(index_1.ExtractorEventType.DataExtractionDone);
|
|
39
|
+
},
|
|
40
|
+
onTimeout: async ({ adapter }) => {
|
|
41
|
+
await adapter.emit(index_1.ExtractorEventType.DataExtractionProgress);
|
|
42
|
+
},
|
|
43
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-extraction.test.d.ts","sourceRoot":"","sources":["../../../src/tests/dummy-connector/data-extraction.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
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('Dummy Connector - Data Extraction', () => {
|
|
11
|
+
let event;
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
event = (0, test_helpers_1.createEvent)({
|
|
14
|
+
eventType: extraction_1.EventType.StartExtractingData,
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
it('should successfully emit data done event when all endpoints return 200', async () => {
|
|
18
|
+
await (0, extraction_2.default)([event], __dirname + '/data-extraction');
|
|
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
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"external-sync-units-extraction.d.ts","sourceRoot":"","sources":["../../../src/tests/dummy-connector/external-sync-units-extraction.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
const dummyExternalSyncUnits = [
|
|
7
|
+
{
|
|
8
|
+
id: '1',
|
|
9
|
+
name: 'Dummy External Sync Unit',
|
|
10
|
+
description: 'This is a dummy external sync unit',
|
|
11
|
+
item_count: 10,
|
|
12
|
+
item_type: 'dummy',
|
|
13
|
+
},
|
|
14
|
+
];
|
|
15
|
+
await adapter.emit(index_1.ExtractorEventType.ExternalSyncUnitExtractionDone, {
|
|
16
|
+
external_sync_units: dummyExternalSyncUnits,
|
|
17
|
+
});
|
|
18
|
+
},
|
|
19
|
+
onTimeout: async ({ adapter }) => {
|
|
20
|
+
await adapter.emit(index_1.ExtractorEventType.ExternalSyncUnitExtractionError, {
|
|
21
|
+
error: {
|
|
22
|
+
message: 'Failed to extract external sync units. Lambda timeout.',
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"external-sync-units-extraction.test.d.ts","sourceRoot":"","sources":["../../../src/tests/dummy-connector/external-sync-units-extraction.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,21 @@
|
|
|
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('Dummy Connector - External Sync Units Extraction', () => {
|
|
11
|
+
it('should successfully emit external sync units done event when all endpoints return 200', async () => {
|
|
12
|
+
const event = (0, test_helpers_1.createEvent)({
|
|
13
|
+
eventType: extraction_1.EventType.StartExtractingExternalSyncUnits,
|
|
14
|
+
});
|
|
15
|
+
await (0, extraction_2.default)([event], __dirname + '/external-sync-units-extraction');
|
|
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.ExternalSyncUnitExtractionDone);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extraction.d.ts","sourceRoot":"","sources":["../../../src/tests/dummy-connector/extraction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAS,MAAM,aAAa,CAAC;AASlD,QAAA,MAAM,GAAG,GAAU,QAAQ,YAAY,EAAE,EAAE,YAAY,MAAM,kBAY5D,CAAC;AAEF,eAAe,GAAG,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata-extraction.d.ts","sourceRoot":"","sources":["../../../src/tests/dummy-connector/metadata-extraction.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const index_1 = require("../../index");
|
|
4
|
+
const repos = [
|
|
5
|
+
{
|
|
6
|
+
itemType: 'external_domain_metadata',
|
|
7
|
+
},
|
|
8
|
+
];
|
|
9
|
+
(0, index_1.processTask)({
|
|
10
|
+
task: async ({ adapter }) => {
|
|
11
|
+
var _a;
|
|
12
|
+
adapter.initializeRepos(repos);
|
|
13
|
+
const externalDomainMetadata = {};
|
|
14
|
+
await ((_a = adapter
|
|
15
|
+
.getRepo('external_domain_metadata')) === null || _a === void 0 ? void 0 : _a.push([externalDomainMetadata]));
|
|
16
|
+
await adapter.emit(index_1.ExtractorEventType.MetadataExtractionDone);
|
|
17
|
+
},
|
|
18
|
+
onTimeout: async ({ adapter }) => {
|
|
19
|
+
await adapter.emit(index_1.ExtractorEventType.MetadataExtractionError, {
|
|
20
|
+
error: { message: 'Failed to extract metadata. Lambda timeout.' },
|
|
21
|
+
});
|
|
22
|
+
},
|
|
23
|
+
});
|