@devrev/airsync-sdk 2.0.0-beta.3 → 2.0.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (198) hide show
  1. package/README.md +5 -11
  2. package/dist/attachments-streaming/attachments-streaming-pool.d.ts +2 -10
  3. package/dist/attachments-streaming/attachments-streaming-pool.d.ts.map +1 -1
  4. package/dist/attachments-streaming/attachments-streaming-pool.interfaces.d.ts +2 -7
  5. package/dist/attachments-streaming/attachments-streaming-pool.interfaces.d.ts.map +1 -1
  6. package/dist/attachments-streaming/attachments-streaming-pool.js +15 -43
  7. package/dist/common/constants.d.ts +1 -0
  8. package/dist/common/constants.d.ts.map +1 -1
  9. package/dist/common/constants.js +2 -1
  10. package/dist/common/helpers.d.ts +0 -14
  11. package/dist/common/helpers.d.ts.map +1 -1
  12. package/dist/common/helpers.js +0 -36
  13. package/dist/http/{axios-client-internal.d.ts → client.d.ts} +1 -1
  14. package/dist/http/client.d.ts.map +1 -0
  15. package/dist/index.d.ts +22 -11
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +46 -28
  18. package/dist/logger/logger.d.ts +14 -0
  19. package/dist/logger/logger.d.ts.map +1 -1
  20. package/dist/logger/logger.js +55 -8
  21. package/dist/mappers/mappers.d.ts +9 -10
  22. package/dist/mappers/mappers.d.ts.map +1 -1
  23. package/dist/mappers/{mappers.interface.d.ts → mappers.interfaces.d.ts} +5 -5
  24. package/dist/mappers/mappers.interfaces.d.ts.map +1 -0
  25. package/dist/mappers/{mappers.interface.js → mappers.interfaces.js} +3 -3
  26. package/dist/mappers/mappers.js +13 -9
  27. package/dist/multithreading/adapters/base-adapter.d.ts +23 -8
  28. package/dist/multithreading/adapters/base-adapter.d.ts.map +1 -1
  29. package/dist/multithreading/adapters/base-adapter.js +41 -8
  30. package/dist/multithreading/adapters/extraction-adapter.d.ts +8 -9
  31. package/dist/multithreading/adapters/extraction-adapter.d.ts.map +1 -1
  32. package/dist/multithreading/adapters/extraction-adapter.js +24 -26
  33. package/dist/multithreading/adapters/loading-adapter.d.ts +7 -7
  34. package/dist/multithreading/adapters/loading-adapter.d.ts.map +1 -1
  35. package/dist/multithreading/adapters/loading-adapter.js +53 -83
  36. package/dist/{common/control-protocol.d.ts → multithreading/emit.d.ts} +1 -1
  37. package/dist/multithreading/emit.d.ts.map +1 -0
  38. package/dist/{common/control-protocol.js → multithreading/emit.js} +3 -3
  39. package/dist/multithreading/process-task.d.ts.map +1 -1
  40. package/dist/multithreading/process-task.js +26 -9
  41. package/dist/multithreading/spawn/spawn.helpers.d.ts +23 -3
  42. package/dist/multithreading/spawn/spawn.helpers.d.ts.map +1 -1
  43. package/dist/multithreading/spawn/spawn.helpers.js +152 -2
  44. package/dist/multithreading/spawn/spawn.js +7 -7
  45. package/dist/multithreading/worker.js +1 -2
  46. package/dist/repo/repo.js +2 -2
  47. package/dist/state/base-state.d.ts +5 -5
  48. package/dist/state/base-state.d.ts.map +1 -1
  49. package/dist/state/base-state.js +7 -7
  50. package/dist/state/extraction-state.d.ts +9 -9
  51. package/dist/state/extraction-state.d.ts.map +1 -1
  52. package/dist/state/extraction-state.js +10 -10
  53. package/dist/state/install-initial-domain-mapping.d.ts.map +1 -0
  54. package/dist/{common → state}/install-initial-domain-mapping.js +4 -4
  55. package/dist/state/loading-state.d.ts +7 -8
  56. package/dist/state/loading-state.d.ts.map +1 -1
  57. package/dist/state/loading-state.js +6 -7
  58. package/dist/state/state.d.ts +4 -0
  59. package/dist/state/state.d.ts.map +1 -0
  60. package/dist/state/state.interfaces.d.ts +28 -18
  61. package/dist/state/state.interfaces.d.ts.map +1 -1
  62. package/dist/state/state.interfaces.js +13 -6
  63. package/dist/state/state.js +11 -0
  64. package/dist/{common → state}/time-value-resolver.d.ts +6 -7
  65. package/dist/state/time-value-resolver.d.ts.map +1 -0
  66. package/dist/{common → state}/time-value-resolver.js +9 -8
  67. package/dist/{common/test-utils.d.ts → testing/mock-event.d.ts} +1 -2
  68. package/dist/testing/mock-event.d.ts.map +1 -0
  69. package/dist/{common/test-utils.js → testing/mock-event.js} +14 -3
  70. package/dist/{mock-server → testing}/mock-server.d.ts +5 -0
  71. package/dist/testing/mock-server.d.ts.map +1 -0
  72. package/dist/testing/mock-server.interfaces.d.ts.map +1 -0
  73. package/dist/{mock-server → testing}/mock-server.js +6 -1
  74. package/dist/types/errors.d.ts +9 -0
  75. package/dist/types/errors.d.ts.map +1 -0
  76. package/dist/types/extraction.d.ts +70 -15
  77. package/dist/types/extraction.d.ts.map +1 -1
  78. package/dist/types/extraction.js +4 -6
  79. package/dist/types/loading.d.ts +1 -2
  80. package/dist/types/loading.d.ts.map +1 -1
  81. package/dist/types/loading.js +0 -1
  82. package/dist/types/workers.d.ts +66 -23
  83. package/dist/types/workers.d.ts.map +1 -1
  84. package/dist/uploader/uploader.d.ts +5 -4
  85. package/dist/uploader/uploader.d.ts.map +1 -1
  86. package/dist/uploader/uploader.interfaces.d.ts +1 -1
  87. package/dist/uploader/uploader.js +10 -10
  88. package/package.json +3 -3
  89. package/dist/airsync-sdk.d.ts +0 -2059
  90. package/dist/attachments-streaming/attachments-streaming-pool.test.d.ts +0 -2
  91. package/dist/attachments-streaming/attachments-streaming-pool.test.d.ts.map +0 -1
  92. package/dist/attachments-streaming/attachments-streaming-pool.test.js +0 -540
  93. package/dist/common/control-protocol.d.ts.map +0 -1
  94. package/dist/common/errors.d.ts +0 -6
  95. package/dist/common/errors.d.ts.map +0 -1
  96. package/dist/common/install-initial-domain-mapping.d.ts.map +0 -1
  97. package/dist/common/install-initial-domain-mapping.test.d.ts +0 -2
  98. package/dist/common/install-initial-domain-mapping.test.d.ts.map +0 -1
  99. package/dist/common/install-initial-domain-mapping.test.js +0 -211
  100. package/dist/common/test-utils.d.ts.map +0 -1
  101. package/dist/common/time-value-resolver.d.ts.map +0 -1
  102. package/dist/common/time-value-resolver.test.d.ts +0 -2
  103. package/dist/common/time-value-resolver.test.d.ts.map +0 -1
  104. package/dist/common/time-value-resolver.test.js +0 -268
  105. package/dist/http/axios-client-internal.d.ts.map +0 -1
  106. package/dist/http/axios-client-internal.test.d.ts +0 -2
  107. package/dist/http/axios-client-internal.test.d.ts.map +0 -1
  108. package/dist/http/axios-client-internal.test.js +0 -175
  109. package/dist/http/axios-client.d.ts +0 -27
  110. package/dist/http/axios-client.d.ts.map +0 -1
  111. package/dist/http/axios-client.js +0 -60
  112. package/dist/http/constants.d.ts +0 -4
  113. package/dist/http/constants.d.ts.map +0 -1
  114. package/dist/http/constants.js +0 -6
  115. package/dist/http/index.d.ts +0 -2
  116. package/dist/http/index.d.ts.map +0 -1
  117. package/dist/http/index.js +0 -17
  118. package/dist/logger/logger.constants.d.ts +0 -6
  119. package/dist/logger/logger.constants.d.ts.map +0 -1
  120. package/dist/logger/logger.constants.js +0 -13
  121. package/dist/logger/logger.context.d.ts +0 -58
  122. package/dist/logger/logger.context.d.ts.map +0 -1
  123. package/dist/logger/logger.context.js +0 -86
  124. package/dist/logger/logger.test.d.ts +0 -2
  125. package/dist/logger/logger.test.d.ts.map +0 -1
  126. package/dist/logger/logger.test.js +0 -537
  127. package/dist/mappers/mappers.interface.d.ts.map +0 -1
  128. package/dist/mappers/mappers.test.d.ts +0 -2
  129. package/dist/mappers/mappers.test.d.ts.map +0 -1
  130. package/dist/mappers/mappers.test.js +0 -105
  131. package/dist/mock-server/mock-server.d.ts.map +0 -1
  132. package/dist/mock-server/mock-server.interfaces.d.ts.map +0 -1
  133. package/dist/multithreading/adapters/base-adapter.emit.test.d.ts +0 -2
  134. package/dist/multithreading/adapters/base-adapter.emit.test.d.ts.map +0 -1
  135. package/dist/multithreading/adapters/base-adapter.emit.test.js +0 -403
  136. package/dist/multithreading/adapters/extraction-adapter.artifacts.test.d.ts +0 -2
  137. package/dist/multithreading/adapters/extraction-adapter.artifacts.test.d.ts.map +0 -1
  138. package/dist/multithreading/adapters/extraction-adapter.artifacts.test.js +0 -175
  139. package/dist/multithreading/adapters/extraction-adapter.test.d.ts +0 -2
  140. package/dist/multithreading/adapters/extraction-adapter.test.d.ts.map +0 -1
  141. package/dist/multithreading/adapters/extraction-adapter.test.js +0 -789
  142. package/dist/multithreading/adapters/loading-adapter.helpers.test.d.ts +0 -2
  143. package/dist/multithreading/adapters/loading-adapter.helpers.test.d.ts.map +0 -1
  144. package/dist/multithreading/adapters/loading-adapter.helpers.test.js +0 -514
  145. package/dist/multithreading/adapters/loading-adapter.test.d.ts +0 -2
  146. package/dist/multithreading/adapters/loading-adapter.test.d.ts.map +0 -1
  147. package/dist/multithreading/adapters/loading-adapter.test.js +0 -589
  148. package/dist/multithreading/adapters/serialization.test.d.ts +0 -2
  149. package/dist/multithreading/adapters/serialization.test.d.ts.map +0 -1
  150. package/dist/multithreading/adapters/serialization.test.js +0 -71
  151. package/dist/multithreading/create-worker.test.d.ts +0 -2
  152. package/dist/multithreading/create-worker.test.d.ts.map +0 -1
  153. package/dist/multithreading/create-worker.test.js +0 -108
  154. package/dist/multithreading/process-task.test.d.ts +0 -2
  155. package/dist/multithreading/process-task.test.d.ts.map +0 -1
  156. package/dist/multithreading/process-task.test.js +0 -146
  157. package/dist/multithreading/spawn/spawn.helpers.test.d.ts +0 -2
  158. package/dist/multithreading/spawn/spawn.helpers.test.d.ts.map +0 -1
  159. package/dist/multithreading/spawn/spawn.helpers.test.js +0 -293
  160. package/dist/multithreading/spawn/spawn.test.d.ts +0 -2
  161. package/dist/multithreading/spawn/spawn.test.d.ts.map +0 -1
  162. package/dist/multithreading/spawn/spawn.test.js +0 -232
  163. package/dist/repo/repo.test.d.ts +0 -2
  164. package/dist/repo/repo.test.d.ts.map +0 -1
  165. package/dist/repo/repo.test.js +0 -184
  166. package/dist/state/state.extract-window.test.d.ts +0 -2
  167. package/dist/state/state.extract-window.test.d.ts.map +0 -1
  168. package/dist/state/state.extract-window.test.js +0 -163
  169. package/dist/state/state.pending-boundaries.test.d.ts +0 -2
  170. package/dist/state/state.pending-boundaries.test.d.ts.map +0 -1
  171. package/dist/state/state.pending-boundaries.test.js +0 -189
  172. package/dist/state/state.post-state.test.d.ts +0 -2
  173. package/dist/state/state.post-state.test.d.ts.map +0 -1
  174. package/dist/state/state.post-state.test.js +0 -78
  175. package/dist/state/state.test.d.ts +0 -2
  176. package/dist/state/state.test.d.ts.map +0 -1
  177. package/dist/state/state.test.js +0 -271
  178. package/dist/state/state.time-value-resolution.test.d.ts +0 -2
  179. package/dist/state/state.time-value-resolution.test.d.ts.map +0 -1
  180. package/dist/state/state.time-value-resolution.test.js +0 -175
  181. package/dist/tsdoc-metadata.json +0 -11
  182. package/dist/types/extraction.test.d.ts +0 -2
  183. package/dist/types/extraction.test.d.ts.map +0 -1
  184. package/dist/types/extraction.test.js +0 -96
  185. package/dist/types/index.d.ts +0 -10
  186. package/dist/types/index.d.ts.map +0 -1
  187. package/dist/types/index.js +0 -21
  188. package/dist/uploader/uploader.helpers.test.d.ts +0 -2
  189. package/dist/uploader/uploader.helpers.test.d.ts.map +0 -1
  190. package/dist/uploader/uploader.helpers.test.js +0 -256
  191. package/dist/uploader/uploader.test.d.ts +0 -2
  192. package/dist/uploader/uploader.test.d.ts.map +0 -1
  193. package/dist/uploader/uploader.test.js +0 -601
  194. /package/dist/http/{axios-client-internal.js → client.js} +0 -0
  195. /package/dist/{common → state}/install-initial-domain-mapping.d.ts +0 -0
  196. /package/dist/{mock-server → testing}/mock-server.interfaces.d.ts +0 -0
  197. /package/dist/{mock-server → testing}/mock-server.interfaces.js +0 -0
  198. /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 +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 +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,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=time-value-resolver.test.d.ts.map
@@ -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,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=axios-client-internal.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"axios-client-internal.test.d.ts","sourceRoot":"","sources":["../../src/http/axios-client-internal.test.ts"],"names":[],"mappings":""}