@devrev/airsync-sdk 2.0.0-beta.1 → 2.0.0-beta.3
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/README.md +0 -4
- package/dist/airsync-sdk.d.ts +2059 -0
- package/dist/attachments-streaming/attachments-streaming-pool.d.ts +2 -1
- package/dist/attachments-streaming/attachments-streaming-pool.d.ts.map +1 -1
- package/dist/attachments-streaming/attachments-streaming-pool.interfaces.d.ts +8 -2
- package/dist/attachments-streaming/attachments-streaming-pool.interfaces.d.ts.map +1 -1
- package/dist/attachments-streaming/attachments-streaming-pool.js +27 -16
- package/dist/attachments-streaming/attachments-streaming-pool.test.js +246 -27
- package/dist/common/constants.d.ts +16 -5
- package/dist/common/constants.d.ts.map +1 -1
- package/dist/common/constants.js +20 -6
- package/dist/common/control-protocol.d.ts +2 -2
- package/dist/common/control-protocol.d.ts.map +1 -1
- package/dist/common/control-protocol.js +1 -5
- package/dist/common/helpers.d.ts +8 -0
- package/dist/common/helpers.d.ts.map +1 -1
- package/dist/common/helpers.js +15 -0
- package/dist/common/install-initial-domain-mapping.d.ts +2 -2
- package/dist/common/install-initial-domain-mapping.test.js +5 -2
- package/dist/common/test-utils.d.ts +19 -0
- package/dist/common/test-utils.d.ts.map +1 -0
- package/dist/common/test-utils.js +101 -0
- package/dist/common/time-value-resolver.d.ts +47 -0
- package/dist/common/time-value-resolver.d.ts.map +1 -0
- package/dist/common/time-value-resolver.js +141 -0
- package/dist/common/time-value-resolver.test.d.ts +2 -0
- package/dist/common/time-value-resolver.test.d.ts.map +1 -0
- package/dist/common/time-value-resolver.test.js +268 -0
- package/dist/http/axios-client-internal.d.ts.map +1 -1
- package/dist/http/axios-client-internal.js +7 -0
- package/dist/http/axios-client-internal.test.js +21 -0
- package/dist/http/axios-client.d.ts.map +1 -1
- package/dist/http/axios-client.js +6 -3
- package/dist/http/index.d.ts +0 -1
- package/dist/http/index.d.ts.map +1 -1
- package/dist/http/index.js +0 -1
- package/dist/index.d.ts +12 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -13
- package/dist/logger/logger.d.ts +1 -17
- package/dist/logger/logger.d.ts.map +1 -1
- package/dist/logger/logger.interfaces.d.ts +2 -2
- package/dist/logger/logger.js +35 -27
- package/dist/logger/logger.test.js +66 -19
- package/dist/mappers/mappers.interface.d.ts +5 -5
- package/dist/mappers/mappers.interface.js +3 -3
- package/dist/mappers/mappers.test.js +8 -10
- package/dist/mock-server/mock-server.d.ts +47 -0
- package/dist/mock-server/mock-server.d.ts.map +1 -0
- package/dist/mock-server/mock-server.interfaces.d.ts +73 -0
- package/dist/mock-server/mock-server.interfaces.d.ts.map +1 -0
- package/dist/mock-server/mock-server.interfaces.js +4 -0
- package/dist/mock-server/mock-server.js +278 -0
- package/dist/multithreading/adapters/base-adapter.d.ts +56 -0
- package/dist/multithreading/adapters/base-adapter.d.ts.map +1 -0
- package/dist/multithreading/adapters/base-adapter.emit.test.d.ts +2 -0
- package/dist/multithreading/adapters/base-adapter.emit.test.d.ts.map +1 -0
- package/dist/multithreading/adapters/base-adapter.emit.test.js +403 -0
- package/dist/multithreading/adapters/base-adapter.js +105 -0
- package/dist/multithreading/adapters/extraction-adapter.artifacts.test.d.ts +2 -0
- package/dist/multithreading/adapters/extraction-adapter.artifacts.test.d.ts.map +1 -0
- package/dist/multithreading/{worker-adapter/worker-adapter.artifacts.test.js → adapters/extraction-adapter.artifacts.test.js} +53 -5
- package/dist/multithreading/adapters/extraction-adapter.d.ts +58 -0
- package/dist/multithreading/adapters/extraction-adapter.d.ts.map +1 -0
- package/dist/multithreading/adapters/extraction-adapter.js +325 -0
- package/dist/multithreading/adapters/extraction-adapter.test.d.ts +2 -0
- package/dist/multithreading/adapters/extraction-adapter.test.d.ts.map +1 -0
- package/dist/multithreading/adapters/extraction-adapter.test.js +789 -0
- package/dist/multithreading/adapters/loading-adapter.d.ts +44 -0
- package/dist/multithreading/adapters/loading-adapter.d.ts.map +1 -0
- package/dist/multithreading/{worker-adapter/worker-adapter.helpers.d.ts → adapters/loading-adapter.helpers.d.ts} +1 -1
- package/dist/multithreading/adapters/loading-adapter.helpers.d.ts.map +1 -0
- package/dist/multithreading/adapters/loading-adapter.helpers.test.d.ts +2 -0
- package/dist/multithreading/adapters/loading-adapter.helpers.test.d.ts.map +1 -0
- package/dist/multithreading/{worker-adapter/worker-adapter.helpers.test.js → adapters/loading-adapter.helpers.test.js} +26 -26
- package/dist/multithreading/adapters/loading-adapter.js +461 -0
- package/dist/multithreading/adapters/loading-adapter.test.d.ts +2 -0
- package/dist/multithreading/adapters/loading-adapter.test.d.ts.map +1 -0
- package/dist/multithreading/adapters/loading-adapter.test.js +589 -0
- package/dist/multithreading/adapters/serialization.test.d.ts +2 -0
- package/dist/multithreading/adapters/serialization.test.d.ts.map +1 -0
- package/dist/multithreading/adapters/serialization.test.js +71 -0
- package/dist/multithreading/create-worker.test.js +36 -17
- package/dist/multithreading/process-task.d.ts +16 -1
- package/dist/multithreading/process-task.d.ts.map +1 -1
- package/dist/multithreading/process-task.js +97 -82
- package/dist/multithreading/process-task.test.d.ts +2 -0
- package/dist/multithreading/process-task.test.d.ts.map +1 -0
- package/dist/multithreading/process-task.test.js +146 -0
- package/dist/multithreading/spawn/spawn.d.ts +3 -3
- package/dist/multithreading/spawn/spawn.d.ts.map +1 -1
- package/dist/multithreading/spawn/spawn.helpers.d.ts.map +1 -1
- package/dist/multithreading/spawn/spawn.helpers.js +6 -14
- package/dist/multithreading/spawn/spawn.helpers.test.js +8 -8
- package/dist/multithreading/spawn/spawn.js +20 -25
- package/dist/multithreading/spawn/spawn.test.d.ts +2 -0
- package/dist/multithreading/spawn/spawn.test.d.ts.map +1 -0
- package/dist/multithreading/spawn/spawn.test.js +232 -0
- package/dist/repo/repo.d.ts.map +1 -1
- package/dist/repo/repo.interfaces.d.ts +4 -2
- package/dist/repo/repo.interfaces.d.ts.map +1 -1
- package/dist/repo/repo.js +4 -3
- package/dist/repo/repo.test.js +60 -7
- package/dist/state/base-state.d.ts +75 -0
- package/dist/state/base-state.d.ts.map +1 -0
- package/dist/state/base-state.js +261 -0
- package/dist/state/extraction-state.d.ts +29 -0
- package/dist/state/extraction-state.d.ts.map +1 -0
- package/dist/state/extraction-state.js +122 -0
- package/dist/state/loading-state.d.ts +19 -0
- package/dist/state/loading-state.d.ts.map +1 -0
- package/dist/state/loading-state.js +40 -0
- package/dist/state/state.extract-window.test.d.ts +2 -0
- package/dist/state/state.extract-window.test.d.ts.map +1 -0
- package/dist/state/state.extract-window.test.js +163 -0
- package/dist/state/state.interfaces.d.ts +44 -27
- package/dist/state/state.interfaces.d.ts.map +1 -1
- package/dist/state/state.interfaces.js +18 -5
- package/dist/state/state.pending-boundaries.test.d.ts +2 -0
- package/dist/state/state.pending-boundaries.test.d.ts.map +1 -0
- package/dist/state/state.pending-boundaries.test.js +189 -0
- package/dist/state/state.post-state.test.d.ts +2 -0
- package/dist/state/state.post-state.test.d.ts.map +1 -0
- package/dist/state/state.post-state.test.js +78 -0
- package/dist/state/state.test.js +135 -88
- package/dist/state/state.time-value-resolution.test.d.ts +2 -0
- package/dist/state/state.time-value-resolution.test.d.ts.map +1 -0
- package/dist/state/state.time-value-resolution.test.js +175 -0
- package/dist/tsdoc-metadata.json +11 -0
- package/dist/types/common.d.ts +0 -25
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/common.js +1 -11
- package/dist/types/external-domain-metadata.d.ts +20 -1
- package/dist/types/external-domain-metadata.d.ts.map +1 -1
- package/dist/types/extraction.d.ts +92 -221
- package/dist/types/extraction.d.ts.map +1 -1
- package/dist/types/extraction.js +56 -124
- package/dist/types/extraction.test.js +69 -43
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +6 -3
- package/dist/types/loading.d.ts +4 -24
- package/dist/types/loading.d.ts.map +1 -1
- package/dist/types/loading.js +1 -22
- package/dist/types/workers.d.ts +47 -29
- package/dist/types/workers.d.ts.map +1 -1
- package/dist/types/workers.js +1 -0
- package/dist/uploader/uploader.d.ts +1 -0
- package/dist/uploader/uploader.d.ts.map +1 -1
- package/dist/uploader/uploader.helpers.test.js +0 -11
- package/dist/uploader/uploader.interfaces.d.ts +3 -3
- package/dist/uploader/uploader.js +53 -20
- package/dist/uploader/uploader.test.js +22 -10
- package/package.json +10 -13
- package/dist/common/event-type-translation.d.ts +0 -24
- package/dist/common/event-type-translation.d.ts.map +0 -1
- package/dist/common/event-type-translation.js +0 -117
- package/dist/deprecated/adapter/index.d.ts +0 -62
- package/dist/deprecated/adapter/index.d.ts.map +0 -1
- package/dist/deprecated/adapter/index.js +0 -151
- package/dist/deprecated/common/helpers.d.ts +0 -7
- package/dist/deprecated/common/helpers.d.ts.map +0 -1
- package/dist/deprecated/common/helpers.js +0 -47
- package/dist/deprecated/demo-extractor/external_domain_metadata.json +0 -38
- package/dist/deprecated/demo-extractor/index.d.ts +0 -18
- package/dist/deprecated/demo-extractor/index.d.ts.map +0 -1
- package/dist/deprecated/demo-extractor/index.js +0 -161
- package/dist/deprecated/http/client.d.ts +0 -22
- package/dist/deprecated/http/client.d.ts.map +0 -1
- package/dist/deprecated/http/client.js +0 -161
- package/dist/deprecated/uploader/index.d.ts +0 -35
- package/dist/deprecated/uploader/index.d.ts.map +0 -1
- package/dist/deprecated/uploader/index.js +0 -161
- package/dist/http/types.d.ts +0 -17
- package/dist/http/types.d.ts.map +0 -1
- package/dist/http/types.js +0 -2
- package/dist/multithreading/worker-adapter/worker-adapter.artifacts.test.d.ts +0 -2
- package/dist/multithreading/worker-adapter/worker-adapter.artifacts.test.d.ts.map +0 -1
- package/dist/multithreading/worker-adapter/worker-adapter.d.ts +0 -91
- package/dist/multithreading/worker-adapter/worker-adapter.d.ts.map +0 -1
- package/dist/multithreading/worker-adapter/worker-adapter.helpers.d.ts.map +0 -1
- package/dist/multithreading/worker-adapter/worker-adapter.helpers.test.d.ts +0 -2
- package/dist/multithreading/worker-adapter/worker-adapter.helpers.test.d.ts.map +0 -1
- package/dist/multithreading/worker-adapter/worker-adapter.js +0 -745
- package/dist/multithreading/worker-adapter/worker-adapter.test.d.ts +0 -2
- package/dist/multithreading/worker-adapter/worker-adapter.test.d.ts.map +0 -1
- package/dist/multithreading/worker-adapter/worker-adapter.test.js +0 -483
- package/dist/state/state.d.ts +0 -30
- package/dist/state/state.d.ts.map +0 -1
- package/dist/state/state.js +0 -166
- /package/dist/multithreading/{worker-adapter/worker-adapter.helpers.js → adapters/loading-adapter.helpers.js} +0 -0
|
@@ -0,0 +1,268 @@
|
|
|
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 +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;AAyFH,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -51,6 +51,13 @@ exports.axiosClient = axiosClient;
|
|
|
51
51
|
((_g = error.response) === null || _g === void 0 ? void 0 : _g.status) !== 429) {
|
|
52
52
|
return true;
|
|
53
53
|
}
|
|
54
|
+
// Request timeout errors (ECONNABORTED) — axios-retry explicitly excludes
|
|
55
|
+
// ECONNABORTED from isNetworkError, so we handle it here separately.
|
|
56
|
+
// Axios only produces ECONNABORTED on client-side timeouts and browser
|
|
57
|
+
// cancellations, never on server responses, so no response guard is needed.
|
|
58
|
+
else if (error.code === 'ECONNABORTED') {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
54
61
|
// all other errors
|
|
55
62
|
else {
|
|
56
63
|
return false;
|
|
@@ -151,4 +151,25 @@ describe('Internal Axios Client', () => {
|
|
|
151
151
|
await expect(axios_client_internal_1.axiosClient.get(jest_setup_1.mockServer.baseUrl + '/test-endpoint')).rejects.toThrow();
|
|
152
152
|
expect(jest_setup_1.mockServer.getRequestCount('GET', '/test-endpoint')).toBe(1);
|
|
153
153
|
});
|
|
154
|
+
it('should retry on request timeout (ECONNABORTED)', async () => {
|
|
155
|
+
// The mock server delays the first response by 500ms, but we set a per-request
|
|
156
|
+
// timeout of 150ms so the first request times out with ECONNABORTED.
|
|
157
|
+
// After the 1 timed-out failure, the server responds immediately (no delay),
|
|
158
|
+
// so the retry succeeds quickly without waiting for full exponential backoff.
|
|
159
|
+
jest_setup_1.mockServer.setRoute({
|
|
160
|
+
path: '/test-endpoint',
|
|
161
|
+
method: 'GET',
|
|
162
|
+
status: 200,
|
|
163
|
+
retry: {
|
|
164
|
+
failureCount: 1,
|
|
165
|
+
errorStatus: 200,
|
|
166
|
+
delay: 500,
|
|
167
|
+
},
|
|
168
|
+
});
|
|
169
|
+
await axios_client_internal_1.axiosClient.get(jest_setup_1.mockServer.baseUrl + '/test-endpoint', {
|
|
170
|
+
timeout: 150,
|
|
171
|
+
});
|
|
172
|
+
// Should have made 2 requests: 1 that timed out + 1 successful retry
|
|
173
|
+
expect(jest_setup_1.mockServer.getRequestCount('GET', '/test-endpoint')).toBe(2);
|
|
174
|
+
});
|
|
154
175
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"axios-client.d.ts","sourceRoot":"","sources":["../../src/http/axios-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAqB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"axios-client.d.ts","sourceRoot":"","sources":["../../src/http/axios-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAqB,MAAM,OAAO,CAAC;AAI1C,QAAA,MAAM,WAAW,+BAAiB,CAAC;AAuCnC,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -30,15 +30,18 @@ exports.axiosClient = exports.axios = void 0;
|
|
|
30
30
|
const axios_1 = __importDefault(require("axios"));
|
|
31
31
|
exports.axios = axios_1.default;
|
|
32
32
|
const axios_retry_1 = __importDefault(require("axios-retry"));
|
|
33
|
+
const logger_context_1 = require("../logger/logger.context");
|
|
33
34
|
const axiosClient = axios_1.default.create();
|
|
34
35
|
exports.axiosClient = axiosClient;
|
|
35
36
|
(0, axios_retry_1.default)(axiosClient, {
|
|
36
37
|
retries: 5,
|
|
37
38
|
retryDelay: (retryCount, error) => {
|
|
38
|
-
var _a, _b, _c;
|
|
39
39
|
// exponential backoff algorithm: 1 * 2 ^ retryCount * 1000ms
|
|
40
40
|
const delay = axios_retry_1.default.exponentialDelay(retryCount, error, 1000);
|
|
41
|
-
|
|
41
|
+
(0, logger_context_1.runWithUserLogContext)(() => {
|
|
42
|
+
var _a, _b, _c;
|
|
43
|
+
return console.warn(`Request to ${(_a = error.config) === null || _a === void 0 ? void 0 : _a.url} failed with response status code ${(_b = error.response) === null || _b === void 0 ? void 0 : _b.status}. Method ${(_c = error.config) === null || _c === void 0 ? void 0 : _c.method}. Retry count: ${retryCount}. Retrying in ${Math.round(delay / 1000)}s.`);
|
|
44
|
+
});
|
|
42
45
|
return delay;
|
|
43
46
|
},
|
|
44
47
|
retryCondition: (error) => {
|
|
@@ -52,6 +55,6 @@ exports.axiosClient = axiosClient;
|
|
|
52
55
|
(_b = (_a = error.config) === null || _a === void 0 ? void 0 : _a.headers) === null || _b === void 0 ? true : delete _b.authorization;
|
|
53
56
|
(_d = (_c = error.config) === null || _c === void 0 ? void 0 : _c.headers) === null || _d === void 0 ? true : delete _d.Authorization;
|
|
54
57
|
delete error.request._header;
|
|
55
|
-
console.warn('Max retry times exceeded. Error', error);
|
|
58
|
+
(0, logger_context_1.runWithUserLogContext)(() => console.warn('Max retry times exceeded. Error', error));
|
|
56
59
|
},
|
|
57
60
|
});
|
package/dist/http/index.d.ts
CHANGED
package/dist/http/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/http/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/http/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
|
package/dist/http/index.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from './deprecated/demo-extractor';
|
|
3
|
-
export * from './deprecated/http/client';
|
|
4
|
-
export * from './deprecated/uploader';
|
|
5
|
-
export * from './http';
|
|
6
|
-
export * from './types';
|
|
7
|
-
export * from './common/install-initial-domain-mapping';
|
|
1
|
+
export { AirSyncDefaultItemTypes } from './common/constants';
|
|
8
2
|
export { ExtractionCommonError } from './common/errors';
|
|
9
|
-
export
|
|
3
|
+
export * from './common/install-initial-domain-mapping';
|
|
4
|
+
export * from './http';
|
|
5
|
+
export { serializeAxiosError } from './logger/logger';
|
|
6
|
+
export { MockServer } from './mock-server/mock-server';
|
|
7
|
+
export type { RequestInfo, RetryConfig, RouteConfig, } from './mock-server/mock-server.interfaces';
|
|
8
|
+
export { processExtractionTask, processLoadingTask, } from './multithreading/process-task';
|
|
10
9
|
export { spawn } from './multithreading/spawn/spawn';
|
|
11
|
-
export {
|
|
10
|
+
export { ExtractionAdapter } from './multithreading/adapters/extraction-adapter';
|
|
11
|
+
export { LoadingAdapter } from './multithreading/adapters/loading-adapter';
|
|
12
|
+
export { createMockEvent, MOCK_SERVER_DEFAULT_URL } from './common/test-utils';
|
|
13
|
+
export type { DeepPartial } from './common/test-utils';
|
|
14
|
+
export * from './types';
|
|
12
15
|
export * from './types/workers';
|
|
13
|
-
export { formatAxiosError, serializeAxiosError } from './logger/logger';
|
|
14
16
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,cAAc,yCAAyC,CAAC;AACxD,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,YAAY,EACV,WAAW,EACX,WAAW,EACX,WAAW,GACZ,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8CAA8C,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -14,21 +14,26 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
__exportStar(require("./deprecated/http/client"), exports);
|
|
21
|
-
__exportStar(require("./deprecated/uploader"), exports);
|
|
22
|
-
__exportStar(require("./http"), exports);
|
|
23
|
-
__exportStar(require("./types"), exports);
|
|
17
|
+
exports.MOCK_SERVER_DEFAULT_URL = exports.createMockEvent = exports.LoadingAdapter = exports.ExtractionAdapter = exports.spawn = exports.processLoadingTask = exports.processExtractionTask = exports.MockServer = exports.serializeAxiosError = exports.AirSyncDefaultItemTypes = void 0;
|
|
18
|
+
var constants_1 = require("./common/constants");
|
|
19
|
+
Object.defineProperty(exports, "AirSyncDefaultItemTypes", { enumerable: true, get: function () { return constants_1.AirSyncDefaultItemTypes; } });
|
|
24
20
|
__exportStar(require("./common/install-initial-domain-mapping"), exports);
|
|
21
|
+
__exportStar(require("./http"), exports);
|
|
22
|
+
var logger_1 = require("./logger/logger");
|
|
23
|
+
Object.defineProperty(exports, "serializeAxiosError", { enumerable: true, get: function () { return logger_1.serializeAxiosError; } });
|
|
24
|
+
var mock_server_1 = require("./mock-server/mock-server");
|
|
25
|
+
Object.defineProperty(exports, "MockServer", { enumerable: true, get: function () { return mock_server_1.MockServer; } });
|
|
25
26
|
var process_task_1 = require("./multithreading/process-task");
|
|
26
|
-
Object.defineProperty(exports, "
|
|
27
|
+
Object.defineProperty(exports, "processExtractionTask", { enumerable: true, get: function () { return process_task_1.processExtractionTask; } });
|
|
28
|
+
Object.defineProperty(exports, "processLoadingTask", { enumerable: true, get: function () { return process_task_1.processLoadingTask; } });
|
|
27
29
|
var spawn_1 = require("./multithreading/spawn/spawn");
|
|
28
30
|
Object.defineProperty(exports, "spawn", { enumerable: true, get: function () { return spawn_1.spawn; } });
|
|
29
|
-
var
|
|
30
|
-
Object.defineProperty(exports, "
|
|
31
|
+
var extraction_adapter_1 = require("./multithreading/adapters/extraction-adapter");
|
|
32
|
+
Object.defineProperty(exports, "ExtractionAdapter", { enumerable: true, get: function () { return extraction_adapter_1.ExtractionAdapter; } });
|
|
33
|
+
var loading_adapter_1 = require("./multithreading/adapters/loading-adapter");
|
|
34
|
+
Object.defineProperty(exports, "LoadingAdapter", { enumerable: true, get: function () { return loading_adapter_1.LoadingAdapter; } });
|
|
35
|
+
var test_utils_1 = require("./common/test-utils");
|
|
36
|
+
Object.defineProperty(exports, "createMockEvent", { enumerable: true, get: function () { return test_utils_1.createMockEvent; } });
|
|
37
|
+
Object.defineProperty(exports, "MOCK_SERVER_DEFAULT_URL", { enumerable: true, get: function () { return test_utils_1.MOCK_SERVER_DEFAULT_URL; } });
|
|
38
|
+
__exportStar(require("./types"), exports);
|
|
31
39
|
__exportStar(require("./types/workers"), exports);
|
|
32
|
-
var logger_1 = require("./logger/logger");
|
|
33
|
-
Object.defineProperty(exports, "formatAxiosError", { enumerable: true, get: function () { return logger_1.formatAxiosError; } });
|
|
34
|
-
Object.defineProperty(exports, "serializeAxiosError", { enumerable: true, get: function () { return logger_1.serializeAxiosError; } });
|
package/dist/logger/logger.d.ts
CHANGED
|
@@ -17,14 +17,6 @@ export declare class Logger extends Console {
|
|
|
17
17
|
* @returns String representation of the value
|
|
18
18
|
*/
|
|
19
19
|
private valueToString;
|
|
20
|
-
/**
|
|
21
|
-
* Truncates a message if it exceeds the maximum allowed length.
|
|
22
|
-
* Adds a suffix indicating how many characters were omitted.
|
|
23
|
-
*
|
|
24
|
-
* @param message - The message to truncate
|
|
25
|
-
* @returns Truncated message or original if within limits
|
|
26
|
-
*/
|
|
27
|
-
private truncateMessage;
|
|
28
20
|
/**
|
|
29
21
|
* Logs a pre-formatted message string to the console.
|
|
30
22
|
* In production mode, wraps the message with JSON formatting and event context tags.
|
|
@@ -68,7 +60,7 @@ export declare function getPrintableState(state: Record<string, any>): Printable
|
|
|
68
60
|
* @param error - Error to serialize
|
|
69
61
|
* @returns Serialized error or original if not an Axios error
|
|
70
62
|
*/
|
|
71
|
-
export declare function serializeError(error: unknown):
|
|
63
|
+
export declare function serializeError(error: unknown): string;
|
|
72
64
|
/**
|
|
73
65
|
* Serializes an Axios error into a structured format with HTTP request/response details.
|
|
74
66
|
* Extracts method, URL, parameters, status code, headers, and data.
|
|
@@ -78,12 +70,4 @@ export declare function serializeError(error: unknown): unknown;
|
|
|
78
70
|
* @returns Structured object with error details
|
|
79
71
|
*/
|
|
80
72
|
export declare function serializeAxiosError(error: AxiosError): AxiosErrorResponse;
|
|
81
|
-
/**
|
|
82
|
-
* Formats an Axios error to a printable format.
|
|
83
|
-
*
|
|
84
|
-
* @param error - Axios error to format
|
|
85
|
-
* @returns Formatted error object
|
|
86
|
-
* @deprecated Use {@link serializeAxiosError} instead
|
|
87
|
-
*/
|
|
88
|
-
export declare function formatAxiosError(error: AxiosError): object;
|
|
89
73
|
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAyC,MAAM,OAAO,CAAC;AAE1E,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AASvC,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EAEtB,QAAQ,EAER,cAAc,EACf,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAyC,MAAM,OAAO,CAAC;AAE1E,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AASvC,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EAEtB,QAAQ,EAER,cAAc,EACf,MAAM,qBAAqB,CAAC;AAG7B;;;GAGG;AACH,qBAAa,MAAO,SAAQ,OAAO;IACjC,OAAO,CAAC,eAAe,CAAU;IACjC,OAAO,CAAC,OAAO,CAAC,CAAuB;IACvC,OAAO,CAAC,IAAI,CAAa;gBAEb,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,sBAAsB;IAWtD;;;;;OAKG;IACH,OAAO,CAAC,aAAa;IAOrB;;;;;;;;;OASG;IACH,KAAK,CACH,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,QAAQ,EACf,QAAQ,GAAE,OAAqC,GAC9C,IAAI;IAcP;;;;;;;;OAQG;IACH,OAAO,CAAC,eAAe;IAgBd,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAI7B,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAI9B,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAI9B,KAAK,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;CAGzC;AACD;;;;;;;GAOG;AAEH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,cAAc,CAqB5E;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAoCrD;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,UAAU,GAAG,kBAAkB,CAwBzE"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { RawAxiosResponseHeaders } from 'axios';
|
|
2
|
-
import type {
|
|
2
|
+
import type { AirSyncEvent, EventContext } from '../types/extraction';
|
|
3
3
|
import type { WorkerAdapterOptions } from '../types/workers';
|
|
4
4
|
export interface LoggerFactoryInterface {
|
|
5
|
-
event:
|
|
5
|
+
event: AirSyncEvent;
|
|
6
6
|
options?: WorkerAdapterOptions;
|
|
7
7
|
}
|
|
8
8
|
export declare enum LogLevel {
|
package/dist/logger/logger.js
CHANGED
|
@@ -4,7 +4,6 @@ exports.Logger = void 0;
|
|
|
4
4
|
exports.getPrintableState = getPrintableState;
|
|
5
5
|
exports.serializeError = serializeError;
|
|
6
6
|
exports.serializeAxiosError = serializeAxiosError;
|
|
7
|
-
exports.formatAxiosError = formatAxiosError;
|
|
8
7
|
const axios_1 = require("axios");
|
|
9
8
|
const node_console_1 = require("node:console");
|
|
10
9
|
const node_util_1 = require("node:util");
|
|
@@ -14,6 +13,7 @@ const workers_1 = require("../types/workers");
|
|
|
14
13
|
const logger_constants_1 = require("./logger.constants");
|
|
15
14
|
const logger_context_1 = require("./logger.context");
|
|
16
15
|
const logger_interfaces_1 = require("./logger.interfaces");
|
|
16
|
+
const helpers_1 = require("../common/helpers");
|
|
17
17
|
/**
|
|
18
18
|
* Custom logger that extends Node.js Console with context-aware logging.
|
|
19
19
|
* Handles local development, main thread, and worker thread logging differently.
|
|
@@ -37,19 +37,6 @@ class Logger extends node_console_1.Console {
|
|
|
37
37
|
}
|
|
38
38
|
return (0, node_util_1.inspect)(value, logger_constants_1.INSPECT_OPTIONS);
|
|
39
39
|
}
|
|
40
|
-
/**
|
|
41
|
-
* Truncates a message if it exceeds the maximum allowed length.
|
|
42
|
-
* Adds a suffix indicating how many characters were omitted.
|
|
43
|
-
*
|
|
44
|
-
* @param message - The message to truncate
|
|
45
|
-
* @returns Truncated message or original if within limits
|
|
46
|
-
*/
|
|
47
|
-
truncateMessage(message) {
|
|
48
|
-
if (message.length > logger_constants_1.MAX_LOG_STRING_LENGTH) {
|
|
49
|
-
return `${message.substring(0, logger_constants_1.MAX_LOG_STRING_LENGTH)}... ${message.length - logger_constants_1.MAX_LOG_STRING_LENGTH} more characters`;
|
|
50
|
-
}
|
|
51
|
-
return message;
|
|
52
|
-
}
|
|
53
40
|
/**
|
|
54
41
|
* Logs a pre-formatted message string to the console.
|
|
55
42
|
* In production mode, wraps the message with JSON formatting and event context tags.
|
|
@@ -80,7 +67,7 @@ class Logger extends node_console_1.Console {
|
|
|
80
67
|
*/
|
|
81
68
|
stringifyAndLog(args, level) {
|
|
82
69
|
let stringifiedArgs = args.map((arg) => this.valueToString(arg)).join(' ');
|
|
83
|
-
stringifiedArgs =
|
|
70
|
+
stringifiedArgs = (0, helpers_1.truncateMessage)(stringifiedArgs);
|
|
84
71
|
const isSdkLog = (0, logger_context_1.getSdkLogContextValue)(true);
|
|
85
72
|
if (node_worker_threads_1.isMainThread) {
|
|
86
73
|
this.logFn(stringifiedArgs, level, isSdkLog);
|
|
@@ -147,9 +134,40 @@ function getPrintableState(state) {
|
|
|
147
134
|
*/
|
|
148
135
|
function serializeError(error) {
|
|
149
136
|
if ((0, axios_1.isAxiosError)(error)) {
|
|
150
|
-
return serializeAxiosError(error);
|
|
137
|
+
return JSON.stringify(serializeAxiosError(error));
|
|
151
138
|
}
|
|
152
|
-
|
|
139
|
+
if (error instanceof Error) {
|
|
140
|
+
// Include error name (e.g. TypeError, RangeError) alongside message
|
|
141
|
+
// for easier debugging
|
|
142
|
+
return error.name !== 'Error'
|
|
143
|
+
? `${error.name}: ${error.message}`
|
|
144
|
+
: error.message;
|
|
145
|
+
}
|
|
146
|
+
if (typeof error === 'string') {
|
|
147
|
+
return error;
|
|
148
|
+
}
|
|
149
|
+
// JSON.stringify returns '{}' for objects with only non-enumerable properties
|
|
150
|
+
// Fall back to extracting own property names or String() coercion.
|
|
151
|
+
const stringified = JSON.stringify(error);
|
|
152
|
+
if (!stringified || stringified === '{}') {
|
|
153
|
+
if (error !== null && typeof error === 'object') {
|
|
154
|
+
const props = {};
|
|
155
|
+
for (const key of Object.getOwnPropertyNames(error)) {
|
|
156
|
+
props[key] = error[key];
|
|
157
|
+
}
|
|
158
|
+
const extracted = JSON.stringify(props);
|
|
159
|
+
if (extracted && extracted !== '{}') {
|
|
160
|
+
return extracted;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
try {
|
|
164
|
+
return String(error);
|
|
165
|
+
}
|
|
166
|
+
catch (_a) {
|
|
167
|
+
return '[Unserializable error]';
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return stringified;
|
|
153
171
|
}
|
|
154
172
|
/**
|
|
155
173
|
* Serializes an Axios error into a structured format with HTTP request/response details.
|
|
@@ -184,13 +202,3 @@ function serializeAxiosError(error) {
|
|
|
184
202
|
}
|
|
185
203
|
return serializedAxiosError;
|
|
186
204
|
}
|
|
187
|
-
/**
|
|
188
|
-
* Formats an Axios error to a printable format.
|
|
189
|
-
*
|
|
190
|
-
* @param error - Axios error to format
|
|
191
|
-
* @returns Formatted error object
|
|
192
|
-
* @deprecated Use {@link serializeAxiosError} instead
|
|
193
|
-
*/
|
|
194
|
-
function formatAxiosError(error) {
|
|
195
|
-
return serializeAxiosError(error);
|
|
196
|
-
}
|