@devrev/airsync-sdk 2.0.0-beta.3 → 2.0.0-beta.5
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/MIGRATION.md +1028 -0
- package/README.md +5 -11
- package/dist/attachments-streaming/attachments-streaming-pool.d.ts +7 -9
- package/dist/attachments-streaming/attachments-streaming-pool.d.ts.map +1 -1
- package/dist/attachments-streaming/attachments-streaming-pool.interfaces.d.ts +2 -7
- package/dist/attachments-streaming/attachments-streaming-pool.interfaces.d.ts.map +1 -1
- package/dist/attachments-streaming/attachments-streaming-pool.js +54 -56
- package/dist/common/constants.d.ts +4 -5
- package/dist/common/constants.d.ts.map +1 -1
- package/dist/common/constants.js +6 -7
- package/dist/common/helpers.d.ts +3 -35
- package/dist/common/helpers.d.ts.map +1 -1
- package/dist/common/helpers.js +5 -50
- package/dist/http/{axios-client-internal.d.ts → client.d.ts} +1 -1
- package/dist/http/client.d.ts.map +1 -0
- package/dist/http/{axios-client-internal.js → client.js} +4 -8
- package/dist/index.d.ts +24 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +43 -32
- package/dist/logger/logger.d.ts +12 -53
- package/dist/logger/logger.d.ts.map +1 -1
- package/dist/logger/logger.interfaces.d.ts +0 -1
- package/dist/logger/logger.interfaces.d.ts.map +1 -1
- package/dist/logger/logger.js +36 -68
- package/dist/mappers/mappers.d.ts +7 -46
- package/dist/mappers/mappers.d.ts.map +1 -1
- package/dist/mappers/mappers.interfaces.d.ts +175 -0
- package/dist/mappers/mappers.interfaces.d.ts.map +1 -0
- package/dist/mappers/{mappers.interface.js → mappers.interfaces.js} +4 -13
- package/dist/mappers/mappers.js +11 -45
- package/dist/multithreading/adapters/base-adapter.d.ts +30 -32
- package/dist/multithreading/adapters/base-adapter.d.ts.map +1 -1
- package/dist/multithreading/adapters/base-adapter.js +97 -62
- package/dist/multithreading/adapters/extraction-adapter.d.ts +16 -29
- package/dist/multithreading/adapters/extraction-adapter.d.ts.map +1 -1
- package/dist/multithreading/adapters/extraction-adapter.js +203 -206
- package/dist/multithreading/adapters/loading-adapter.d.ts +8 -13
- package/dist/multithreading/adapters/loading-adapter.d.ts.map +1 -1
- package/dist/multithreading/adapters/loading-adapter.helpers.d.ts +2 -12
- package/dist/multithreading/adapters/loading-adapter.helpers.d.ts.map +1 -1
- package/dist/multithreading/adapters/loading-adapter.helpers.js +2 -12
- package/dist/multithreading/adapters/loading-adapter.js +294 -346
- package/dist/multithreading/emit.d.ts +11 -0
- package/dist/multithreading/emit.d.ts.map +1 -0
- package/dist/{common/control-protocol.js → multithreading/emit.js} +5 -7
- package/dist/multithreading/process-task.d.ts +2 -12
- package/dist/multithreading/process-task.d.ts.map +1 -1
- package/dist/multithreading/process-task.js +46 -43
- package/dist/multithreading/spawn/spawn.d.ts +3 -9
- package/dist/multithreading/spawn/spawn.d.ts.map +1 -1
- package/dist/multithreading/spawn/spawn.helpers.d.ts +12 -11
- package/dist/multithreading/spawn/spawn.helpers.d.ts.map +1 -1
- package/dist/multithreading/spawn/spawn.helpers.js +128 -20
- package/dist/multithreading/spawn/spawn.js +24 -39
- package/dist/multithreading/worker.js +1 -4
- package/dist/repo/repo.d.ts +10 -0
- package/dist/repo/repo.d.ts.map +1 -1
- package/dist/repo/repo.helpers.d.ts +6 -0
- package/dist/repo/repo.helpers.d.ts.map +1 -0
- package/dist/repo/repo.helpers.js +16 -0
- package/dist/repo/repo.interfaces.d.ts +4 -16
- package/dist/repo/repo.interfaces.d.ts.map +1 -1
- package/dist/repo/repo.js +23 -8
- package/dist/state/base-state.d.ts +16 -38
- package/dist/state/base-state.d.ts.map +1 -1
- package/dist/state/base-state.js +19 -41
- package/dist/state/extraction-state.d.ts +6 -21
- package/dist/state/extraction-state.d.ts.map +1 -1
- package/dist/state/extraction-state.js +8 -25
- package/dist/{common → state}/install-initial-domain-mapping.d.ts +1 -1
- package/dist/state/install-initial-domain-mapping.d.ts.map +1 -0
- package/dist/{common → state}/install-initial-domain-mapping.js +5 -7
- package/dist/state/loading-state.d.ts +3 -14
- package/dist/state/loading-state.d.ts.map +1 -1
- package/dist/state/loading-state.js +3 -14
- package/dist/state/state.d.ts +4 -0
- package/dist/state/state.d.ts.map +1 -0
- package/dist/state/state.interfaces.d.ts +33 -37
- package/dist/state/state.interfaces.d.ts.map +1 -1
- package/dist/state/state.interfaces.js +16 -11
- package/dist/state/state.js +11 -0
- package/dist/state/time-value-resolver.d.ts +17 -0
- package/dist/state/time-value-resolver.d.ts.map +1 -0
- package/dist/{common → state}/time-value-resolver.js +9 -41
- package/dist/testing/mock-event.d.ts +10 -0
- package/dist/testing/mock-event.d.ts.map +1 -0
- package/dist/{common/test-utils.js → testing/mock-event.js} +17 -14
- package/dist/testing/mock-server.d.ts +29 -0
- package/dist/testing/mock-server.d.ts.map +1 -0
- package/dist/testing/mock-server.interfaces.d.ts +48 -0
- package/dist/testing/mock-server.interfaces.d.ts.map +1 -0
- package/dist/{mock-server → testing}/mock-server.js +21 -33
- package/dist/types/common.d.ts +1 -12
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/common.js +1 -6
- package/dist/types/errors.d.ts +9 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/external-domain-metadata.d.ts +30 -171
- package/dist/types/external-domain-metadata.d.ts.map +1 -1
- package/dist/types/extraction.d.ts +64 -94
- package/dist/types/extraction.d.ts.map +1 -1
- package/dist/types/extraction.js +6 -34
- package/dist/types/loading.d.ts +1 -2
- package/dist/types/loading.d.ts.map +1 -1
- package/dist/types/loading.js +0 -1
- package/dist/types/workers.d.ts +39 -94
- package/dist/types/workers.d.ts.map +1 -1
- package/dist/types/workers.js +0 -6
- package/dist/uploader/uploader.d.ts +8 -59
- package/dist/uploader/uploader.d.ts.map +1 -1
- package/dist/uploader/uploader.helpers.d.ts +4 -27
- package/dist/uploader/uploader.helpers.d.ts.map +1 -1
- package/dist/uploader/uploader.helpers.js +64 -30
- package/dist/uploader/uploader.interfaces.d.ts +15 -25
- package/dist/uploader/uploader.interfaces.d.ts.map +1 -1
- package/dist/uploader/uploader.interfaces.js +8 -0
- package/dist/uploader/uploader.js +23 -89
- package/package.json +8 -6
- package/dist/airsync-sdk.d.ts +0 -2059
- package/dist/attachments-streaming/attachments-streaming-pool.test.d.ts +0 -2
- package/dist/attachments-streaming/attachments-streaming-pool.test.d.ts.map +0 -1
- package/dist/attachments-streaming/attachments-streaming-pool.test.js +0 -540
- package/dist/common/control-protocol.d.ts +0 -10
- package/dist/common/control-protocol.d.ts.map +0 -1
- package/dist/common/errors.d.ts +0 -6
- package/dist/common/errors.d.ts.map +0 -1
- package/dist/common/install-initial-domain-mapping.d.ts.map +0 -1
- package/dist/common/install-initial-domain-mapping.test.d.ts +0 -2
- package/dist/common/install-initial-domain-mapping.test.d.ts.map +0 -1
- package/dist/common/install-initial-domain-mapping.test.js +0 -211
- package/dist/common/test-utils.d.ts +0 -19
- package/dist/common/test-utils.d.ts.map +0 -1
- package/dist/common/time-value-resolver.d.ts +0 -47
- package/dist/common/time-value-resolver.d.ts.map +0 -1
- package/dist/common/time-value-resolver.test.d.ts +0 -2
- package/dist/common/time-value-resolver.test.d.ts.map +0 -1
- package/dist/common/time-value-resolver.test.js +0 -268
- package/dist/http/axios-client-internal.d.ts.map +0 -1
- package/dist/http/axios-client-internal.test.d.ts +0 -2
- package/dist/http/axios-client-internal.test.d.ts.map +0 -1
- package/dist/http/axios-client-internal.test.js +0 -175
- package/dist/http/axios-client.d.ts +0 -27
- package/dist/http/axios-client.d.ts.map +0 -1
- package/dist/http/axios-client.js +0 -60
- package/dist/http/constants.d.ts +0 -4
- package/dist/http/constants.d.ts.map +0 -1
- package/dist/http/constants.js +0 -6
- package/dist/http/index.d.ts +0 -2
- package/dist/http/index.d.ts.map +0 -1
- package/dist/http/index.js +0 -17
- package/dist/logger/logger.constants.d.ts +0 -6
- package/dist/logger/logger.constants.d.ts.map +0 -1
- package/dist/logger/logger.constants.js +0 -13
- package/dist/logger/logger.context.d.ts +0 -58
- package/dist/logger/logger.context.d.ts.map +0 -1
- package/dist/logger/logger.context.js +0 -86
- package/dist/logger/logger.test.d.ts +0 -2
- package/dist/logger/logger.test.d.ts.map +0 -1
- package/dist/logger/logger.test.js +0 -537
- package/dist/mappers/mappers.interface.d.ts +0 -294
- package/dist/mappers/mappers.interface.d.ts.map +0 -1
- package/dist/mappers/mappers.test.d.ts +0 -2
- package/dist/mappers/mappers.test.d.ts.map +0 -1
- package/dist/mappers/mappers.test.js +0 -105
- package/dist/mock-server/mock-server.d.ts +0 -47
- package/dist/mock-server/mock-server.d.ts.map +0 -1
- package/dist/mock-server/mock-server.interfaces.d.ts +0 -73
- package/dist/mock-server/mock-server.interfaces.d.ts.map +0 -1
- package/dist/multithreading/adapters/base-adapter.emit.test.d.ts +0 -2
- package/dist/multithreading/adapters/base-adapter.emit.test.d.ts.map +0 -1
- package/dist/multithreading/adapters/base-adapter.emit.test.js +0 -403
- package/dist/multithreading/adapters/extraction-adapter.artifacts.test.d.ts +0 -2
- package/dist/multithreading/adapters/extraction-adapter.artifacts.test.d.ts.map +0 -1
- package/dist/multithreading/adapters/extraction-adapter.artifacts.test.js +0 -175
- package/dist/multithreading/adapters/extraction-adapter.test.d.ts +0 -2
- package/dist/multithreading/adapters/extraction-adapter.test.d.ts.map +0 -1
- package/dist/multithreading/adapters/extraction-adapter.test.js +0 -789
- package/dist/multithreading/adapters/loading-adapter.helpers.test.d.ts +0 -2
- package/dist/multithreading/adapters/loading-adapter.helpers.test.d.ts.map +0 -1
- package/dist/multithreading/adapters/loading-adapter.helpers.test.js +0 -514
- package/dist/multithreading/adapters/loading-adapter.test.d.ts +0 -2
- package/dist/multithreading/adapters/loading-adapter.test.d.ts.map +0 -1
- package/dist/multithreading/adapters/loading-adapter.test.js +0 -589
- package/dist/multithreading/adapters/serialization.test.d.ts +0 -2
- package/dist/multithreading/adapters/serialization.test.d.ts.map +0 -1
- package/dist/multithreading/adapters/serialization.test.js +0 -71
- package/dist/multithreading/create-worker.test.d.ts +0 -2
- package/dist/multithreading/create-worker.test.d.ts.map +0 -1
- package/dist/multithreading/create-worker.test.js +0 -108
- package/dist/multithreading/process-task.test.d.ts +0 -2
- package/dist/multithreading/process-task.test.d.ts.map +0 -1
- package/dist/multithreading/process-task.test.js +0 -146
- package/dist/multithreading/spawn/spawn.helpers.test.d.ts +0 -2
- package/dist/multithreading/spawn/spawn.helpers.test.d.ts.map +0 -1
- package/dist/multithreading/spawn/spawn.helpers.test.js +0 -293
- package/dist/multithreading/spawn/spawn.test.d.ts +0 -2
- package/dist/multithreading/spawn/spawn.test.d.ts.map +0 -1
- package/dist/multithreading/spawn/spawn.test.js +0 -232
- package/dist/repo/repo.test.d.ts +0 -2
- package/dist/repo/repo.test.d.ts.map +0 -1
- package/dist/repo/repo.test.js +0 -184
- package/dist/state/state.extract-window.test.d.ts +0 -2
- package/dist/state/state.extract-window.test.d.ts.map +0 -1
- package/dist/state/state.extract-window.test.js +0 -163
- package/dist/state/state.pending-boundaries.test.d.ts +0 -2
- package/dist/state/state.pending-boundaries.test.d.ts.map +0 -1
- package/dist/state/state.pending-boundaries.test.js +0 -189
- package/dist/state/state.post-state.test.d.ts +0 -2
- package/dist/state/state.post-state.test.d.ts.map +0 -1
- package/dist/state/state.post-state.test.js +0 -78
- package/dist/state/state.test.d.ts +0 -2
- package/dist/state/state.test.d.ts.map +0 -1
- package/dist/state/state.test.js +0 -271
- package/dist/state/state.time-value-resolution.test.d.ts +0 -2
- package/dist/state/state.time-value-resolution.test.d.ts.map +0 -1
- package/dist/state/state.time-value-resolution.test.js +0 -175
- package/dist/tsdoc-metadata.json +0 -11
- package/dist/types/extraction.test.d.ts +0 -2
- package/dist/types/extraction.test.d.ts.map +0 -1
- package/dist/types/extraction.test.js +0 -96
- package/dist/types/index.d.ts +0 -10
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -21
- package/dist/uploader/uploader.helpers.test.d.ts +0 -2
- package/dist/uploader/uploader.helpers.test.d.ts.map +0 -1
- package/dist/uploader/uploader.helpers.test.js +0 -256
- package/dist/uploader/uploader.test.d.ts +0 -2
- package/dist/uploader/uploader.test.d.ts.map +0 -1
- package/dist/uploader/uploader.test.js +0 -601
- /package/dist/{mock-server → testing}/mock-server.interfaces.js +0 -0
- /package/dist/{common → types}/errors.js +0 -0
|
@@ -1,211 +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 axios_1 = __importDefault(require("axios"));
|
|
7
|
-
const axios_client_internal_1 = require("../http/axios-client-internal");
|
|
8
|
-
const jest_setup_1 = require("../tests/jest.setup");
|
|
9
|
-
const test_utils_1 = require("./test-utils");
|
|
10
|
-
const extraction_1 = require("../types/extraction");
|
|
11
|
-
const install_initial_domain_mapping_1 = require("./install-initial-domain-mapping");
|
|
12
|
-
// Mock dependencies
|
|
13
|
-
jest.mock('axios', () => (Object.assign(Object.assign({}, jest.requireActual('axios')), { isAxiosError: jest.fn() })));
|
|
14
|
-
jest.mock('../http/axios-client-internal', () => {
|
|
15
|
-
const originalModule = jest.requireActual('../http/axios-client-internal');
|
|
16
|
-
return Object.assign(Object.assign({}, originalModule), { axiosClient: {
|
|
17
|
-
get: jest.fn(),
|
|
18
|
-
post: jest.fn(),
|
|
19
|
-
} });
|
|
20
|
-
});
|
|
21
|
-
jest.mock('../logger/logger');
|
|
22
|
-
const mockAxiosClient = axios_client_internal_1.axiosClient;
|
|
23
|
-
const mockIsAxiosError = axios_1.default.isAxiosError;
|
|
24
|
-
describe(install_initial_domain_mapping_1.installInitialDomainMapping.name, () => {
|
|
25
|
-
// Create mock objects
|
|
26
|
-
const mockEvent = (0, test_utils_1.createMockEvent)(jest_setup_1.mockServer.baseUrl, {
|
|
27
|
-
payload: { event_type: extraction_1.EventType.StartExtractingData },
|
|
28
|
-
});
|
|
29
|
-
const mockInitialDomainMapping = {
|
|
30
|
-
starting_recipe_blueprint: {
|
|
31
|
-
name: 'Test Recipe Blueprint',
|
|
32
|
-
description: 'Test description',
|
|
33
|
-
},
|
|
34
|
-
additional_mappings: {
|
|
35
|
-
custom_field: 'custom_value',
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
const mockSnapInResponse = {
|
|
39
|
-
data: {
|
|
40
|
-
snap_in: {
|
|
41
|
-
imports: [{ name: 'import-slug-123' }],
|
|
42
|
-
snap_in_version: { slug: 'snap-in-slug-123' },
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
// Use the endpoint from the event to support dynamic ports in parallel tests
|
|
47
|
-
const mockEndpoint = mockEvent.execution_metadata.devrev_endpoint;
|
|
48
|
-
const mockToken = 'test_token';
|
|
49
|
-
// After each test, clear all mocks to prevent state from leaking.
|
|
50
|
-
afterEach(() => {
|
|
51
|
-
jest.clearAllMocks();
|
|
52
|
-
});
|
|
53
|
-
it('should successfully install initial domain mapping with recipe blueprint', async () => {
|
|
54
|
-
// Mock successful snap-in response
|
|
55
|
-
mockAxiosClient.get.mockResolvedValueOnce(mockSnapInResponse);
|
|
56
|
-
// Mock successful recipe blueprint creation
|
|
57
|
-
const mockRecipeBlueprintResponse = {
|
|
58
|
-
data: {
|
|
59
|
-
recipe_blueprint: {
|
|
60
|
-
id: 'recipe-blueprint-123',
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
};
|
|
64
|
-
mockAxiosClient.post.mockResolvedValueOnce(mockRecipeBlueprintResponse);
|
|
65
|
-
// Mock successful domain mapping installation
|
|
66
|
-
const mockDomainMappingResponse = {
|
|
67
|
-
data: {
|
|
68
|
-
success: true,
|
|
69
|
-
mapping_id: 'mapping-123',
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
mockAxiosClient.post.mockResolvedValueOnce(mockDomainMappingResponse);
|
|
73
|
-
await (0, install_initial_domain_mapping_1.installInitialDomainMapping)(mockEvent, mockInitialDomainMapping);
|
|
74
|
-
// Verify snap-in details request
|
|
75
|
-
expect(mockAxiosClient.get).toHaveBeenCalledWith(`${mockEndpoint}/internal/snap-ins.get`, {
|
|
76
|
-
headers: {
|
|
77
|
-
Authorization: mockToken,
|
|
78
|
-
},
|
|
79
|
-
params: {
|
|
80
|
-
id: 'test_snap_in_id',
|
|
81
|
-
},
|
|
82
|
-
});
|
|
83
|
-
// Verify recipe blueprint creation
|
|
84
|
-
expect(mockAxiosClient.post).toHaveBeenCalledWith(`${mockEndpoint}/internal/airdrop.recipe.blueprints.create`, {
|
|
85
|
-
name: 'Test Recipe Blueprint',
|
|
86
|
-
description: 'Test description',
|
|
87
|
-
}, {
|
|
88
|
-
headers: {
|
|
89
|
-
Authorization: mockToken,
|
|
90
|
-
},
|
|
91
|
-
});
|
|
92
|
-
// Verify domain mapping installation
|
|
93
|
-
expect(mockAxiosClient.post).toHaveBeenCalledWith(`${mockEndpoint}/internal/airdrop.recipe.initial-domain-mappings.install`, {
|
|
94
|
-
external_system_type: 'ADaaS',
|
|
95
|
-
import_slug: 'import-slug-123',
|
|
96
|
-
snap_in_slug: 'snap-in-slug-123',
|
|
97
|
-
starting_recipe_blueprint: 'recipe-blueprint-123',
|
|
98
|
-
custom_field: 'custom_value',
|
|
99
|
-
}, {
|
|
100
|
-
headers: {
|
|
101
|
-
Authorization: mockToken,
|
|
102
|
-
},
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
it('should successfully install without recipe blueprint when not provided', async () => {
|
|
106
|
-
const mappingWithoutBlueprint = {
|
|
107
|
-
additional_mappings: {
|
|
108
|
-
custom_field: 'custom_value',
|
|
109
|
-
},
|
|
110
|
-
};
|
|
111
|
-
mockAxiosClient.get.mockResolvedValueOnce(mockSnapInResponse);
|
|
112
|
-
const mockDomainMappingResponse = {
|
|
113
|
-
data: { success: true },
|
|
114
|
-
};
|
|
115
|
-
mockAxiosClient.post.mockResolvedValueOnce(mockDomainMappingResponse);
|
|
116
|
-
await (0, install_initial_domain_mapping_1.installInitialDomainMapping)(mockEvent, mappingWithoutBlueprint);
|
|
117
|
-
// Should only make one POST request (no recipe blueprint creation)
|
|
118
|
-
expect(mockAxiosClient.post).toHaveBeenCalledTimes(1);
|
|
119
|
-
expect(mockAxiosClient.post).toHaveBeenCalledWith(`${mockEndpoint}/internal/airdrop.recipe.initial-domain-mappings.install`, {
|
|
120
|
-
external_system_type: 'ADaaS',
|
|
121
|
-
import_slug: 'import-slug-123',
|
|
122
|
-
snap_in_slug: 'snap-in-slug-123',
|
|
123
|
-
custom_field: 'custom_value',
|
|
124
|
-
}, {
|
|
125
|
-
headers: {
|
|
126
|
-
Authorization: mockToken,
|
|
127
|
-
},
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
it('should handle empty starting_recipe_blueprint object', async () => {
|
|
131
|
-
const mappingWithEmptyBlueprint = {
|
|
132
|
-
starting_recipe_blueprint: {},
|
|
133
|
-
additional_mappings: {
|
|
134
|
-
custom_field: 'custom_value',
|
|
135
|
-
},
|
|
136
|
-
};
|
|
137
|
-
mockAxiosClient.get.mockResolvedValueOnce(mockSnapInResponse);
|
|
138
|
-
const mockDomainMappingResponse = {
|
|
139
|
-
data: { success: true },
|
|
140
|
-
};
|
|
141
|
-
mockAxiosClient.post.mockResolvedValueOnce(mockDomainMappingResponse);
|
|
142
|
-
await (0, install_initial_domain_mapping_1.installInitialDomainMapping)(mockEvent, mappingWithEmptyBlueprint);
|
|
143
|
-
// Should only make one POST request (no recipe blueprint creation for empty object)
|
|
144
|
-
expect(mockAxiosClient.post).toHaveBeenCalledTimes(1);
|
|
145
|
-
});
|
|
146
|
-
it('[edge] should return early with warning when initial domain mapping is null', async () => {
|
|
147
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
148
|
-
await (0, install_initial_domain_mapping_1.installInitialDomainMapping)(mockEvent, null);
|
|
149
|
-
expect(mockAxiosClient.get).not.toHaveBeenCalled();
|
|
150
|
-
expect(mockAxiosClient.post).not.toHaveBeenCalled();
|
|
151
|
-
});
|
|
152
|
-
it('[edge] should return early with warning when initial domain mapping is undefined', async () => {
|
|
153
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
154
|
-
await (0, install_initial_domain_mapping_1.installInitialDomainMapping)(mockEvent, undefined);
|
|
155
|
-
expect(mockAxiosClient.get).not.toHaveBeenCalled();
|
|
156
|
-
expect(mockAxiosClient.post).not.toHaveBeenCalled();
|
|
157
|
-
});
|
|
158
|
-
it('[edge] should throw error when import slug is missing', async () => {
|
|
159
|
-
const snapInResponseWithoutImport = {
|
|
160
|
-
data: {
|
|
161
|
-
snap_in: {
|
|
162
|
-
imports: [],
|
|
163
|
-
snap_in_version: { slug: 'snap-in-slug-123' },
|
|
164
|
-
},
|
|
165
|
-
},
|
|
166
|
-
};
|
|
167
|
-
mockAxiosClient.get.mockResolvedValueOnce(snapInResponseWithoutImport);
|
|
168
|
-
await expect((0, install_initial_domain_mapping_1.installInitialDomainMapping)(mockEvent, mockInitialDomainMapping)).rejects.toThrow();
|
|
169
|
-
});
|
|
170
|
-
it('[edge] should throw error when snap-in slug is missing', async () => {
|
|
171
|
-
const snapInResponseWithoutSlug = {
|
|
172
|
-
data: {
|
|
173
|
-
snap_in: {
|
|
174
|
-
imports: [{ name: 'import-slug-123' }],
|
|
175
|
-
snap_in_version: {},
|
|
176
|
-
},
|
|
177
|
-
},
|
|
178
|
-
};
|
|
179
|
-
mockAxiosClient.get.mockResolvedValueOnce(snapInResponseWithoutSlug);
|
|
180
|
-
await expect((0, install_initial_domain_mapping_1.installInitialDomainMapping)(mockEvent, mockInitialDomainMapping)).rejects.toThrow();
|
|
181
|
-
});
|
|
182
|
-
it('should handle the error during recipe blueprint creation', async () => {
|
|
183
|
-
mockAxiosClient.get.mockResolvedValueOnce(mockSnapInResponse);
|
|
184
|
-
const genericError = new Error('Generic error during blueprint creation');
|
|
185
|
-
// Mock axios.isAxiosError to return false
|
|
186
|
-
mockIsAxiosError.mockReturnValue(false);
|
|
187
|
-
mockAxiosClient.post.mockRejectedValueOnce(genericError);
|
|
188
|
-
const mockDomainMappingResponse = {
|
|
189
|
-
data: { success: true },
|
|
190
|
-
};
|
|
191
|
-
mockAxiosClient.post.mockResolvedValueOnce(mockDomainMappingResponse);
|
|
192
|
-
await (0, install_initial_domain_mapping_1.installInitialDomainMapping)(mockEvent, mockInitialDomainMapping);
|
|
193
|
-
// Should still proceed with domain mapping installation
|
|
194
|
-
expect(mockAxiosClient.post).toHaveBeenCalledTimes(2);
|
|
195
|
-
});
|
|
196
|
-
it('should propagate error from domain mapping installation', async () => {
|
|
197
|
-
mockAxiosClient.get.mockResolvedValueOnce(mockSnapInResponse);
|
|
198
|
-
// Mock successful recipe blueprint creation
|
|
199
|
-
const mockRecipeBlueprintResponse = {
|
|
200
|
-
data: {
|
|
201
|
-
recipe_blueprint: {
|
|
202
|
-
id: 'recipe-blueprint-123',
|
|
203
|
-
},
|
|
204
|
-
},
|
|
205
|
-
};
|
|
206
|
-
mockAxiosClient.post.mockResolvedValueOnce(mockRecipeBlueprintResponse);
|
|
207
|
-
const domainMappingError = new Error('Domain mapping installation failed');
|
|
208
|
-
mockAxiosClient.post.mockRejectedValueOnce(domainMappingError);
|
|
209
|
-
await expect((0, install_initial_domain_mapping_1.installInitialDomainMapping)(mockEvent, mockInitialDomainMapping)).rejects.toThrow();
|
|
210
|
-
});
|
|
211
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { AirSyncEvent } from '../types/extraction';
|
|
2
|
-
export declare const MOCK_SERVER_DEFAULT_URL = "http://localhost:0";
|
|
3
|
-
/**
|
|
4
|
-
* Recursively makes all properties of T optional.
|
|
5
|
-
*/
|
|
6
|
-
export type DeepPartial<T> = {
|
|
7
|
-
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* Creates a mock AirSyncEvent for testing.
|
|
11
|
-
*
|
|
12
|
-
* @param mockServerUrl - Base URL for the mock server. Defaults to {@link MOCK_SERVER_DEFAULT_URL}.
|
|
13
|
-
* The `callback_url`, `worker_data_url`, and `devrev_endpoint` fields are
|
|
14
|
-
* derived from this value unless explicitly overridden.
|
|
15
|
-
* @param overrides - Deep partial of AirSyncEvent. Any provided fields are
|
|
16
|
-
* deep-merged on top of the defaults.
|
|
17
|
-
*/
|
|
18
|
-
export declare function createMockEvent(mockServerUrl?: string, overrides?: DeepPartial<AirSyncEvent>): AirSyncEvent;
|
|
19
|
-
//# sourceMappingURL=test-utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../../src/common/test-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAa,MAAM,qBAAqB,CAAC;AAE9D,eAAO,MAAM,uBAAuB,uBAAuB,CAAC;AAE5D;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;KAC1B,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAChE,CAAC;AAoCF;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,aAAa,GAAE,MAAgC,EAC/C,SAAS,GAAE,WAAW,CAAC,YAAY,CAAM,GACxC,YAAY,CAmEd"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { TimeUnit, TimeValue } from '../types/extraction';
|
|
2
|
-
import { ExtractionSdkState } from '../state/state.interfaces';
|
|
3
|
-
/**
|
|
4
|
-
* Parses a shorthand duration string into its numeric value and unit.
|
|
5
|
-
* Supported units:
|
|
6
|
-
* - 'ns' for nanoseconds
|
|
7
|
-
* - 'us' or 'µs' for microseconds
|
|
8
|
-
* - 'ms' for milliseconds
|
|
9
|
-
* - 's' for seconds
|
|
10
|
-
* - 'm' for minutes
|
|
11
|
-
* - 'h' for hours
|
|
12
|
-
*
|
|
13
|
-
* @throws Error if the format is invalid
|
|
14
|
-
*/
|
|
15
|
-
export declare function parseDuration(shorthand: string): {
|
|
16
|
-
value: number;
|
|
17
|
-
unit: TimeUnit;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Applies a shorthand duration to a base ISO 8601 timestamp.
|
|
21
|
-
*
|
|
22
|
-
* @param baseTimestamp - ISO 8601 timestamp to apply duration to
|
|
23
|
-
* @param duration - Shorthand duration string (e.g. '100ns', '500ms', '30s', '5m', '2h')
|
|
24
|
-
* @param operation - Whether to 'add' or 'subtract' the duration
|
|
25
|
-
* @returns ISO 8601 timestamp with the duration applied
|
|
26
|
-
*/
|
|
27
|
-
export declare function applyDuration(baseTimestamp: string, duration: string, operation: 'add' | 'subtract'): string;
|
|
28
|
-
/**
|
|
29
|
-
* Resolves a TimeValue into a concrete ISO 8601 timestamp string.
|
|
30
|
-
*
|
|
31
|
-
* Resolution rules:
|
|
32
|
-
* - ABSOLUTE: Returns the value directly (must be an ISO 8601 timestamp)
|
|
33
|
-
* - NOW: Returns the current time as ISO 8601
|
|
34
|
-
* - UNBOUNDED: Returns UNBOUNDED_DATE_TIME_VALUE ('1970-01-01T00:00:00.000Z')
|
|
35
|
-
* - WORKERS_OLDEST: Returns workersOldest from state, or throws if not set
|
|
36
|
-
* - WORKERS_NEWEST: Returns workersNewest from state, or throws if not set
|
|
37
|
-
* - WORKERS_OLDEST_MINUS_WINDOW: Subtracts duration from workersOldest, or throws if not set
|
|
38
|
-
* - WORKERS_NEWEST_PLUS_WINDOW: Adds duration to workersNewest, or throws if not set
|
|
39
|
-
*
|
|
40
|
-
* @param timeValue - The TimeValue to resolve
|
|
41
|
-
* @param state - The current SDK state containing workersOldest and workersNewest
|
|
42
|
-
* @returns Resolved ISO 8601 timestamp string
|
|
43
|
-
* @throws Error if required TimeValue.value is missing for ABSOLUTE or *_WINDOW types
|
|
44
|
-
* @throws Error if workersOldest/workersNewest is not set in state for WORKERS_* types
|
|
45
|
-
*/
|
|
46
|
-
export declare function resolveTimeValue(timeValue: TimeValue, state: ExtractionSdkState): string;
|
|
47
|
-
//# sourceMappingURL=time-value-resolver.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"time-value-resolver.d.ts","sourceRoot":"","sources":["../../src/common/time-value-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAiB,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAG/D;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG;IAChD,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,QAAQ,CAAC;CAChB,CAcA;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,KAAK,GAAG,UAAU,GAC5B,MAAM,CA6BR;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,kBAAkB,GACxB,MAAM,CA2ER"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"time-value-resolver.test.d.ts","sourceRoot":"","sources":["../../src/common/time-value-resolver.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const extraction_1 = require("../types/extraction");
|
|
4
|
-
const constants_1 = require("./constants");
|
|
5
|
-
const time_value_resolver_1 = require("./time-value-resolver");
|
|
6
|
-
describe('time-value-resolver', () => {
|
|
7
|
-
describe('parseDuration', () => {
|
|
8
|
-
it('should parse nanoseconds', () => {
|
|
9
|
-
expect((0, time_value_resolver_1.parseDuration)('100ns')).toEqual({ value: 100, unit: 'ns' });
|
|
10
|
-
expect((0, time_value_resolver_1.parseDuration)('1ns')).toEqual({ value: 1, unit: 'ns' });
|
|
11
|
-
});
|
|
12
|
-
it('should parse microseconds', () => {
|
|
13
|
-
expect((0, time_value_resolver_1.parseDuration)('500us')).toEqual({ value: 500, unit: 'us' });
|
|
14
|
-
expect((0, time_value_resolver_1.parseDuration)('500µs')).toEqual({ value: 500, unit: 'µs' });
|
|
15
|
-
});
|
|
16
|
-
it('should parse milliseconds', () => {
|
|
17
|
-
expect((0, time_value_resolver_1.parseDuration)('250ms')).toEqual({ value: 250, unit: 'ms' });
|
|
18
|
-
expect((0, time_value_resolver_1.parseDuration)('1ms')).toEqual({ value: 1, unit: 'ms' });
|
|
19
|
-
});
|
|
20
|
-
it('should parse seconds', () => {
|
|
21
|
-
expect((0, time_value_resolver_1.parseDuration)('30s')).toEqual({ value: 30, unit: 's' });
|
|
22
|
-
expect((0, time_value_resolver_1.parseDuration)('1s')).toEqual({ value: 1, unit: 's' });
|
|
23
|
-
expect((0, time_value_resolver_1.parseDuration)('3600s')).toEqual({ value: 3600, unit: 's' });
|
|
24
|
-
});
|
|
25
|
-
it('should parse minutes', () => {
|
|
26
|
-
expect((0, time_value_resolver_1.parseDuration)('5m')).toEqual({ value: 5, unit: 'm' });
|
|
27
|
-
expect((0, time_value_resolver_1.parseDuration)('1m')).toEqual({ value: 1, unit: 'm' });
|
|
28
|
-
expect((0, time_value_resolver_1.parseDuration)('60m')).toEqual({ value: 60, unit: 'm' });
|
|
29
|
-
});
|
|
30
|
-
it('should parse hours', () => {
|
|
31
|
-
expect((0, time_value_resolver_1.parseDuration)('2h')).toEqual({ value: 2, unit: 'h' });
|
|
32
|
-
expect((0, time_value_resolver_1.parseDuration)('24h')).toEqual({ value: 24, unit: 'h' });
|
|
33
|
-
expect((0, time_value_resolver_1.parseDuration)('168h')).toEqual({ value: 168, unit: 'h' });
|
|
34
|
-
});
|
|
35
|
-
it('should parse fractional values', () => {
|
|
36
|
-
expect((0, time_value_resolver_1.parseDuration)('1.5h')).toEqual({ value: 1.5, unit: 'h' });
|
|
37
|
-
expect((0, time_value_resolver_1.parseDuration)('0.5s')).toEqual({ value: 0.5, unit: 's' });
|
|
38
|
-
expect((0, time_value_resolver_1.parseDuration)('2.5m')).toEqual({ value: 2.5, unit: 'm' });
|
|
39
|
-
});
|
|
40
|
-
it('should throw on invalid format', () => {
|
|
41
|
-
expect(() => (0, time_value_resolver_1.parseDuration)('')).toThrow('Invalid duration format');
|
|
42
|
-
expect(() => (0, time_value_resolver_1.parseDuration)('7')).toThrow('Invalid duration format');
|
|
43
|
-
expect(() => (0, time_value_resolver_1.parseDuration)('s')).toThrow('Invalid duration format');
|
|
44
|
-
expect(() => (0, time_value_resolver_1.parseDuration)('7d')).toThrow('Invalid duration format');
|
|
45
|
-
expect(() => (0, time_value_resolver_1.parseDuration)('7y')).toThrow('Invalid duration format');
|
|
46
|
-
expect(() => (0, time_value_resolver_1.parseDuration)('abc')).toThrow('Invalid duration format');
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
describe('applyDuration', () => {
|
|
50
|
-
describe('subtract', () => {
|
|
51
|
-
it('should subtract seconds', () => {
|
|
52
|
-
const result = (0, time_value_resolver_1.applyDuration)('2024-01-15T00:00:30.000Z', '30s', 'subtract');
|
|
53
|
-
expect(result).toBe('2024-01-15T00:00:00.000Z');
|
|
54
|
-
});
|
|
55
|
-
it('should subtract minutes', () => {
|
|
56
|
-
const result = (0, time_value_resolver_1.applyDuration)('2024-01-15T00:05:00.000Z', '5m', 'subtract');
|
|
57
|
-
expect(result).toBe('2024-01-15T00:00:00.000Z');
|
|
58
|
-
});
|
|
59
|
-
it('should subtract hours', () => {
|
|
60
|
-
const result = (0, time_value_resolver_1.applyDuration)('2024-01-15T02:00:00.000Z', '2h', 'subtract');
|
|
61
|
-
expect(result).toBe('2024-01-15T00:00:00.000Z');
|
|
62
|
-
});
|
|
63
|
-
it('should subtract milliseconds', () => {
|
|
64
|
-
const result = (0, time_value_resolver_1.applyDuration)('2024-01-15T00:00:00.500Z', '500ms', 'subtract');
|
|
65
|
-
expect(result).toBe('2024-01-15T00:00:00.000Z');
|
|
66
|
-
});
|
|
67
|
-
it('should handle crossing day boundary', () => {
|
|
68
|
-
const result = (0, time_value_resolver_1.applyDuration)('2024-01-15T01:00:00.000Z', '2h', 'subtract');
|
|
69
|
-
expect(result).toBe('2024-01-14T23:00:00.000Z');
|
|
70
|
-
});
|
|
71
|
-
it('should subtract 168 hours (7 days equivalent)', () => {
|
|
72
|
-
const result = (0, time_value_resolver_1.applyDuration)('2024-01-15T00:00:00.000Z', '168h', 'subtract');
|
|
73
|
-
expect(result).toBe('2024-01-08T00:00:00.000Z');
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
describe('add', () => {
|
|
77
|
-
it('should add seconds', () => {
|
|
78
|
-
const result = (0, time_value_resolver_1.applyDuration)('2024-01-15T00:00:00.000Z', '30s', 'add');
|
|
79
|
-
expect(result).toBe('2024-01-15T00:00:30.000Z');
|
|
80
|
-
});
|
|
81
|
-
it('should add minutes', () => {
|
|
82
|
-
const result = (0, time_value_resolver_1.applyDuration)('2024-01-15T00:00:00.000Z', '5m', 'add');
|
|
83
|
-
expect(result).toBe('2024-01-15T00:05:00.000Z');
|
|
84
|
-
});
|
|
85
|
-
it('should add hours', () => {
|
|
86
|
-
const result = (0, time_value_resolver_1.applyDuration)('2024-01-15T00:00:00.000Z', '2h', 'add');
|
|
87
|
-
expect(result).toBe('2024-01-15T02:00:00.000Z');
|
|
88
|
-
});
|
|
89
|
-
it('should add milliseconds', () => {
|
|
90
|
-
const result = (0, time_value_resolver_1.applyDuration)('2024-01-15T00:00:00.000Z', '500ms', 'add');
|
|
91
|
-
expect(result).toBe('2024-01-15T00:00:00.500Z');
|
|
92
|
-
});
|
|
93
|
-
it('should handle crossing day boundary', () => {
|
|
94
|
-
const result = (0, time_value_resolver_1.applyDuration)('2024-01-15T23:00:00.000Z', '2h', 'add');
|
|
95
|
-
expect(result).toBe('2024-01-16T01:00:00.000Z');
|
|
96
|
-
});
|
|
97
|
-
it('should add 168 hours (7 days equivalent)', () => {
|
|
98
|
-
const result = (0, time_value_resolver_1.applyDuration)('2024-01-15T00:00:00.000Z', '168h', 'add');
|
|
99
|
-
expect(result).toBe('2024-01-22T00:00:00.000Z');
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
describe('resolveTimeValue', () => {
|
|
104
|
-
const baseState = {
|
|
105
|
-
workersOldest: '2024-01-01T00:00:00.000Z',
|
|
106
|
-
workersNewest: '2024-06-01T00:00:00.000Z',
|
|
107
|
-
};
|
|
108
|
-
describe('ABSOLUTE_TIME type', () => {
|
|
109
|
-
it('should return the value normalized to ISO 8601', () => {
|
|
110
|
-
const result = (0, time_value_resolver_1.resolveTimeValue)({ type: extraction_1.TimeValueType.ABSOLUTE_TIME, value: '2024-03-15T12:00:00Z' }, baseState);
|
|
111
|
-
expect(result).toBe('2024-03-15T12:00:00.000Z');
|
|
112
|
-
});
|
|
113
|
-
it('should normalize timestamps without milliseconds', () => {
|
|
114
|
-
const result = (0, time_value_resolver_1.resolveTimeValue)({ type: extraction_1.TimeValueType.ABSOLUTE_TIME, value: '2024-01-01T00:00:00Z' }, baseState);
|
|
115
|
-
expect(result).toBe('2024-01-01T00:00:00.000Z');
|
|
116
|
-
});
|
|
117
|
-
it('should preserve timestamps already in normalized format', () => {
|
|
118
|
-
const result = (0, time_value_resolver_1.resolveTimeValue)({
|
|
119
|
-
type: extraction_1.TimeValueType.ABSOLUTE_TIME,
|
|
120
|
-
value: '2024-06-15T10:30:00.000Z',
|
|
121
|
-
}, baseState);
|
|
122
|
-
expect(result).toBe('2024-06-15T10:30:00.000Z');
|
|
123
|
-
});
|
|
124
|
-
it('should throw if value is missing', () => {
|
|
125
|
-
expect(() => (0, time_value_resolver_1.resolveTimeValue)({ type: extraction_1.TimeValueType.ABSOLUTE_TIME }, baseState)).toThrow('must have a value');
|
|
126
|
-
});
|
|
127
|
-
it('should throw a descriptive error if value is an invalid timestamp', () => {
|
|
128
|
-
expect(() => (0, time_value_resolver_1.resolveTimeValue)({ type: extraction_1.TimeValueType.ABSOLUTE_TIME, value: 'not-a-date' }, baseState)).toThrow("invalid ISO 8601 timestamp: 'not-a-date'");
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
describe('CURRENT_TIME type', () => {
|
|
132
|
-
it('should return current time as ISO string', () => {
|
|
133
|
-
const before = new Date().toISOString();
|
|
134
|
-
const result = (0, time_value_resolver_1.resolveTimeValue)({ type: extraction_1.TimeValueType.CURRENT_TIME }, baseState);
|
|
135
|
-
const after = new Date().toISOString();
|
|
136
|
-
expect(result >= before).toBe(true);
|
|
137
|
-
expect(result <= after).toBe(true);
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
describe('UNBOUNDED type', () => {
|
|
141
|
-
it('should return UNBOUNDED_DATE_TIME_VALUE', () => {
|
|
142
|
-
const result = (0, time_value_resolver_1.resolveTimeValue)({ type: extraction_1.TimeValueType.UNBOUNDED }, baseState);
|
|
143
|
-
expect(result).toBe(constants_1.UNBOUNDED_DATE_TIME_VALUE);
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
describe('WORKERS_OLDEST type', () => {
|
|
147
|
-
it('should return workersOldest from state', () => {
|
|
148
|
-
const result = (0, time_value_resolver_1.resolveTimeValue)({ type: extraction_1.TimeValueType.WORKERS_OLDEST }, baseState);
|
|
149
|
-
expect(result).toBe('2024-01-01T00:00:00.000Z');
|
|
150
|
-
});
|
|
151
|
-
it('should return UNBOUNDED_DATE_TIME_VALUE if workersOldest is not set', () => {
|
|
152
|
-
const result = (0, time_value_resolver_1.resolveTimeValue)({ type: extraction_1.TimeValueType.WORKERS_OLDEST }, { workersOldest: '' });
|
|
153
|
-
expect(result).toBe(constants_1.UNBOUNDED_DATE_TIME_VALUE);
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
describe('WORKERS_NEWEST type', () => {
|
|
157
|
-
it('should return workersNewest from state', () => {
|
|
158
|
-
const result = (0, time_value_resolver_1.resolveTimeValue)({ type: extraction_1.TimeValueType.WORKERS_NEWEST }, baseState);
|
|
159
|
-
expect(result).toBe('2024-06-01T00:00:00.000Z');
|
|
160
|
-
});
|
|
161
|
-
it('should throw if workersNewest is not set', () => {
|
|
162
|
-
expect(() => (0, time_value_resolver_1.resolveTimeValue)({ type: extraction_1.TimeValueType.WORKERS_NEWEST }, { workersNewest: '' })).toThrow('workersNewest is not set in state');
|
|
163
|
-
});
|
|
164
|
-
});
|
|
165
|
-
describe('WORKERS_OLDEST_MINUS_WINDOW type', () => {
|
|
166
|
-
it('should subtract duration from workersOldest', () => {
|
|
167
|
-
const result = (0, time_value_resolver_1.resolveTimeValue)({
|
|
168
|
-
type: extraction_1.TimeValueType.WORKERS_OLDEST_MINUS_WINDOW,
|
|
169
|
-
value: '168h',
|
|
170
|
-
}, baseState);
|
|
171
|
-
expect(result).toBe('2023-12-25T00:00:00.000Z');
|
|
172
|
-
});
|
|
173
|
-
it('should subtract minutes from workersOldest', () => {
|
|
174
|
-
const result = (0, time_value_resolver_1.resolveTimeValue)({
|
|
175
|
-
type: extraction_1.TimeValueType.WORKERS_OLDEST_MINUS_WINDOW,
|
|
176
|
-
value: '30m',
|
|
177
|
-
}, baseState);
|
|
178
|
-
expect(result).toBe('2023-12-31T23:30:00.000Z');
|
|
179
|
-
});
|
|
180
|
-
it('should return UNBOUNDED_DATE_TIME_VALUE if workersOldest is not set', () => {
|
|
181
|
-
const result = (0, time_value_resolver_1.resolveTimeValue)({
|
|
182
|
-
type: extraction_1.TimeValueType.WORKERS_OLDEST_MINUS_WINDOW,
|
|
183
|
-
value: '2h',
|
|
184
|
-
}, { workersOldest: '' });
|
|
185
|
-
expect(result).toBe(constants_1.UNBOUNDED_DATE_TIME_VALUE);
|
|
186
|
-
});
|
|
187
|
-
it('should throw if value (duration) is missing', () => {
|
|
188
|
-
expect(() => (0, time_value_resolver_1.resolveTimeValue)({ type: extraction_1.TimeValueType.WORKERS_OLDEST_MINUS_WINDOW }, baseState)).toThrow('must have a value');
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
describe('WORKERS_NEWEST_PLUS_WINDOW type', () => {
|
|
192
|
-
it('should add duration to workersNewest', () => {
|
|
193
|
-
const result = (0, time_value_resolver_1.resolveTimeValue)({
|
|
194
|
-
type: extraction_1.TimeValueType.WORKERS_NEWEST_PLUS_WINDOW,
|
|
195
|
-
value: '168h',
|
|
196
|
-
}, baseState);
|
|
197
|
-
expect(result).toBe('2024-06-08T00:00:00.000Z');
|
|
198
|
-
});
|
|
199
|
-
it('should add minutes to workersNewest', () => {
|
|
200
|
-
const result = (0, time_value_resolver_1.resolveTimeValue)({
|
|
201
|
-
type: extraction_1.TimeValueType.WORKERS_NEWEST_PLUS_WINDOW,
|
|
202
|
-
value: '30m',
|
|
203
|
-
}, baseState);
|
|
204
|
-
expect(result).toBe('2024-06-01T00:30:00.000Z');
|
|
205
|
-
});
|
|
206
|
-
it('should throw if workersNewest is not set', () => {
|
|
207
|
-
expect(() => (0, time_value_resolver_1.resolveTimeValue)({
|
|
208
|
-
type: extraction_1.TimeValueType.WORKERS_NEWEST_PLUS_WINDOW,
|
|
209
|
-
value: '2h',
|
|
210
|
-
}, { workersNewest: '' })).toThrow('workersNewest is not set in state');
|
|
211
|
-
});
|
|
212
|
-
it('should throw if value (duration) is missing', () => {
|
|
213
|
-
expect(() => (0, time_value_resolver_1.resolveTimeValue)({ type: extraction_1.TimeValueType.WORKERS_NEWEST_PLUS_WINDOW }, baseState)).toThrow('must have a value');
|
|
214
|
-
});
|
|
215
|
-
});
|
|
216
|
-
describe('Unknown type', () => {
|
|
217
|
-
it('should throw for unknown type', () => {
|
|
218
|
-
expect(() =>
|
|
219
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
220
|
-
(0, time_value_resolver_1.resolveTimeValue)({ type: 'unknown' }, baseState)).toThrow('Unknown TimeValueType');
|
|
221
|
-
});
|
|
222
|
-
});
|
|
223
|
-
describe('Real-world scenarios', () => {
|
|
224
|
-
const FIXED_NOW = '2026-02-26T15:30:00.000Z';
|
|
225
|
-
const scenarioState = {
|
|
226
|
-
workersOldest: '2024-01-01T00:00:00.000Z',
|
|
227
|
-
workersNewest: '2024-06-01T00:00:00.000Z',
|
|
228
|
-
};
|
|
229
|
-
beforeEach(() => {
|
|
230
|
-
jest.useFakeTimers();
|
|
231
|
-
jest.setSystemTime(new Date(FIXED_NOW));
|
|
232
|
-
});
|
|
233
|
-
afterEach(() => {
|
|
234
|
-
jest.useRealTimers();
|
|
235
|
-
});
|
|
236
|
-
it('Initial Import: UNBOUNDED start, CURRENT_TIME end', () => {
|
|
237
|
-
const start = (0, time_value_resolver_1.resolveTimeValue)({ type: extraction_1.TimeValueType.UNBOUNDED }, scenarioState);
|
|
238
|
-
const end = (0, time_value_resolver_1.resolveTimeValue)({ type: extraction_1.TimeValueType.CURRENT_TIME }, scenarioState);
|
|
239
|
-
expect(start).toBe(constants_1.UNBOUNDED_DATE_TIME_VALUE);
|
|
240
|
-
expect(end).toBe(FIXED_NOW);
|
|
241
|
-
});
|
|
242
|
-
it('Normal Import: WORKERS_NEWEST start, CURRENT_TIME end', () => {
|
|
243
|
-
const start = (0, time_value_resolver_1.resolveTimeValue)({ type: extraction_1.TimeValueType.WORKERS_NEWEST }, scenarioState);
|
|
244
|
-
const end = (0, time_value_resolver_1.resolveTimeValue)({ type: extraction_1.TimeValueType.CURRENT_TIME }, scenarioState);
|
|
245
|
-
expect(start).toBe('2024-06-01T00:00:00.000Z');
|
|
246
|
-
expect(end).toBe(FIXED_NOW);
|
|
247
|
-
});
|
|
248
|
-
it('POC Import: ABSOLUTE_TIME start, CURRENT_TIME end', () => {
|
|
249
|
-
const start = (0, time_value_resolver_1.resolveTimeValue)({ type: extraction_1.TimeValueType.ABSOLUTE_TIME, value: '2024-01-01T00:00:00Z' }, scenarioState);
|
|
250
|
-
const end = (0, time_value_resolver_1.resolveTimeValue)({ type: extraction_1.TimeValueType.CURRENT_TIME }, scenarioState);
|
|
251
|
-
expect(start).toBe('2024-01-01T00:00:00.000Z');
|
|
252
|
-
expect(end).toBe(FIXED_NOW);
|
|
253
|
-
});
|
|
254
|
-
it('Computer Import: WORKERS_OLDEST_MINUS_WINDOW start, WORKERS_OLDEST end', () => {
|
|
255
|
-
const start = (0, time_value_resolver_1.resolveTimeValue)({ type: extraction_1.TimeValueType.WORKERS_OLDEST_MINUS_WINDOW, value: '168h' }, scenarioState);
|
|
256
|
-
const end = (0, time_value_resolver_1.resolveTimeValue)({ type: extraction_1.TimeValueType.WORKERS_OLDEST }, scenarioState);
|
|
257
|
-
expect(start).toBe('2023-12-25T00:00:00.000Z');
|
|
258
|
-
expect(end).toBe('2024-01-01T00:00:00.000Z');
|
|
259
|
-
});
|
|
260
|
-
it('Reconciliation: ABSOLUTE_TIME start, ABSOLUTE_TIME end', () => {
|
|
261
|
-
const start = (0, time_value_resolver_1.resolveTimeValue)({ type: extraction_1.TimeValueType.ABSOLUTE_TIME, value: '2026-01-01T00:00:00Z' }, scenarioState);
|
|
262
|
-
const end = (0, time_value_resolver_1.resolveTimeValue)({ type: extraction_1.TimeValueType.ABSOLUTE_TIME, value: '2026-03-31T23:59:59Z' }, scenarioState);
|
|
263
|
-
expect(start).toBe('2026-01-01T00:00:00.000Z');
|
|
264
|
-
expect(end).toBe('2026-03-31T23:59:59.000Z');
|
|
265
|
-
});
|
|
266
|
-
});
|
|
267
|
-
});
|
|
268
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"axios-client-internal.d.ts","sourceRoot":"","sources":["../../src/http/axios-client-internal.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,WAAW,+BAEf,CAAC;AAyFH,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"axios-client-internal.test.d.ts","sourceRoot":"","sources":["../../src/http/axios-client-internal.test.ts"],"names":[],"mappings":""}
|