@devrev/airsync-sdk 2.0.0-beta.5 → 2.0.0-beta.7
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 +8 -12
- package/dist/attachments-streaming/attachments-streaming-pool.d.ts.map +1 -1
- package/dist/attachments-streaming/attachments-streaming-pool.js +8 -9
- package/dist/common/constants.d.ts +0 -7
- package/dist/common/constants.d.ts.map +1 -1
- package/dist/common/constants.js +1 -28
- package/dist/common/helpers.d.ts.map +1 -1
- package/dist/common/helpers.js +1 -1
- package/dist/http/errors.d.ts +8 -0
- package/dist/http/errors.d.ts.map +1 -0
- package/dist/http/errors.js +31 -0
- package/dist/index.d.ts +18 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -11
- package/dist/logger/logger.d.ts.map +1 -1
- package/dist/logger/logger.interfaces.d.ts +2 -2
- package/dist/logger/logger.interfaces.d.ts.map +1 -1
- package/dist/mappers/mappers.d.ts +9 -3
- package/dist/mappers/mappers.d.ts.map +1 -1
- package/dist/mappers/mappers.interfaces.d.ts +0 -2
- package/dist/mappers/mappers.interfaces.d.ts.map +1 -1
- package/dist/mappers/mappers.js +33 -13
- package/dist/multithreading/adapters/base-adapter.d.ts +16 -35
- package/dist/multithreading/adapters/base-adapter.d.ts.map +1 -1
- package/dist/multithreading/adapters/base-adapter.js +89 -23
- package/dist/multithreading/adapters/extraction-adapter.d.ts +24 -20
- package/dist/multithreading/adapters/extraction-adapter.d.ts.map +1 -1
- package/dist/multithreading/adapters/extraction-adapter.js +175 -122
- package/dist/multithreading/adapters/loading-adapter.d.ts +13 -23
- package/dist/multithreading/adapters/loading-adapter.d.ts.map +1 -1
- package/dist/multithreading/adapters/loading-adapter.js +176 -301
- package/dist/multithreading/emit.d.ts.map +1 -1
- package/dist/multithreading/process-task.d.ts.map +1 -1
- package/dist/multithreading/process-task.js +24 -6
- package/dist/multithreading/spawn/spawn.d.ts +6 -1
- 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 +17 -52
- package/dist/multithreading/spawn/spawn.js +30 -26
- package/dist/multithreading/worker.js +15 -1
- package/dist/repo/repo.d.ts +4 -5
- package/dist/repo/repo.d.ts.map +1 -1
- package/dist/repo/repo.interfaces.d.ts +5 -4
- package/dist/repo/repo.interfaces.d.ts.map +1 -1
- package/dist/repo/repo.js +13 -15
- package/dist/state/base-state.d.ts +10 -5
- package/dist/state/base-state.d.ts.map +1 -1
- package/dist/state/base-state.js +39 -36
- package/dist/state/extraction-state.d.ts.map +1 -1
- package/dist/state/extraction-state.js +39 -4
- package/dist/state/state.interfaces.d.ts +13 -7
- package/dist/state/state.interfaces.d.ts.map +1 -1
- package/dist/state/state.interfaces.js +6 -8
- package/dist/state/time-value-resolver.d.ts.map +1 -1
- package/dist/state/time-value-resolver.js +3 -2
- package/dist/testing/mock-event.d.ts.map +1 -1
- package/dist/testing/mock-event.js +0 -8
- package/dist/testing/mock-server.d.ts +2 -0
- package/dist/testing/mock-server.d.ts.map +1 -1
- package/dist/testing/mock-server.interfaces.d.ts +6 -0
- package/dist/testing/mock-server.interfaces.d.ts.map +1 -1
- package/dist/testing/mock-server.js +37 -6
- package/dist/testing/test-adapters.d.ts +22 -0
- package/dist/testing/test-adapters.d.ts.map +1 -0
- package/dist/testing/test-adapters.js +32 -0
- package/dist/types/common.d.ts +4 -1
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/common.js +1 -1
- package/dist/types/errors.d.ts +13 -7
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +24 -0
- package/dist/types/extraction.d.ts +60 -44
- package/dist/types/extraction.d.ts.map +1 -1
- package/dist/types/extraction.js +10 -1
- package/dist/types/loading.d.ts +11 -30
- package/dist/types/loading.d.ts.map +1 -1
- package/dist/types/workers.d.ts +27 -23
- package/dist/types/workers.d.ts.map +1 -1
- package/dist/uploader/uploader.d.ts +1 -2
- package/dist/uploader/uploader.d.ts.map +1 -1
- package/dist/uploader/uploader.helpers.d.ts +3 -0
- package/dist/uploader/uploader.helpers.d.ts.map +1 -1
- package/dist/uploader/uploader.helpers.js +16 -0
- package/dist/uploader/uploader.interfaces.d.ts +4 -29
- package/dist/uploader/uploader.interfaces.d.ts.map +1 -1
- package/dist/uploader/uploader.js +4 -23
- package/docs/MIGRATION.md +651 -0
- package/package.json +24 -10
- package/MIGRATION.md +0 -1028
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { InitialDomainMapping } from '../types/common';
|
|
2
2
|
import { AirSyncEvent } from '../types/extraction';
|
|
3
3
|
import { FileToLoad } from '../types/loading';
|
|
4
|
-
import {
|
|
4
|
+
import { RuntimeOptions } from '../types/workers';
|
|
5
|
+
import { Artifact } from '../uploader/uploader.interfaces';
|
|
5
6
|
export interface SdkState {
|
|
7
|
+
lastSyncStarted?: string;
|
|
8
|
+
lastSuccessfulSyncStarted?: string;
|
|
6
9
|
pendingWorkersOldest?: string;
|
|
7
10
|
pendingWorkersNewest?: string;
|
|
8
11
|
workersOldest?: string;
|
|
@@ -11,12 +14,16 @@ export interface SdkState {
|
|
|
11
14
|
fromDevRev?: FromDevRev;
|
|
12
15
|
snapInVersionId?: string;
|
|
13
16
|
}
|
|
17
|
+
export declare const STATE_VERSION = 2;
|
|
14
18
|
/** v2 on-disk state shape: SDK bookkeeping kept disjoint from connector keys. */
|
|
15
19
|
export interface AdapterStateEnvelope<ConnectorState> {
|
|
20
|
+
stateVersion: typeof STATE_VERSION;
|
|
16
21
|
connectorState: ConnectorState;
|
|
17
22
|
sdkState: SdkState;
|
|
18
23
|
}
|
|
19
24
|
export interface ToDevRev {
|
|
25
|
+
/** SSOR artifacts from earlier phases, reported with ATTACHMENT_EXTRACTION_DONE. */
|
|
26
|
+
deferredSsorArtifacts?: Artifact[];
|
|
20
27
|
attachmentsMetadata: {
|
|
21
28
|
artifactIds: string[];
|
|
22
29
|
lastProcessed: number;
|
|
@@ -40,15 +47,18 @@ export interface StateInterface<ConnectorState> {
|
|
|
40
47
|
event: AirSyncEvent;
|
|
41
48
|
initialState: ConnectorState;
|
|
42
49
|
initialDomainMapping?: InitialDomainMapping;
|
|
43
|
-
options?:
|
|
50
|
+
options?: RuntimeOptions;
|
|
44
51
|
}
|
|
45
52
|
export declare const extractionSdkState: {
|
|
53
|
+
lastSyncStarted: string;
|
|
54
|
+
lastSuccessfulSyncStarted: string;
|
|
46
55
|
pendingWorkersOldest: string;
|
|
47
56
|
pendingWorkersNewest: string;
|
|
48
57
|
workersOldest: string;
|
|
49
58
|
workersNewest: string;
|
|
50
59
|
snapInVersionId: string;
|
|
51
60
|
toDevRev: {
|
|
61
|
+
deferredSsorArtifacts: never[];
|
|
52
62
|
attachmentsMetadata: {
|
|
53
63
|
artifactIds: never[];
|
|
54
64
|
lastProcessed: number;
|
|
@@ -62,10 +72,6 @@ export declare const loadingSdkState: {
|
|
|
62
72
|
filesToLoad: never[];
|
|
63
73
|
};
|
|
64
74
|
};
|
|
65
|
-
/**
|
|
66
|
-
* SDK-owned top-level state keys, used to split a flat v1 blob during migration.
|
|
67
|
-
* `lastSyncStarted` / `lastSuccessfulSyncStarted` are no longer on `SdkState` but
|
|
68
|
-
* stay listed so v1 blobs carrying them don't leak them into connector state.
|
|
69
|
-
*/
|
|
75
|
+
/** SDK-owned top-level state keys, used to split a flat v1 blob during migration. */
|
|
70
76
|
export declare const V1_SDK_STATE_KEYS: ReadonlySet<string>;
|
|
71
77
|
//# sourceMappingURL=state.interfaces.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.interfaces.d.ts","sourceRoot":"","sources":["../../src/state/state.interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAA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;AAED,wEAAwE;AACxE,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,yBAAyB,CAAC;CACnC;AAED,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,cAAc,CAAC,cAAc;IAC5C,KAAK,EAAE,YAAY,CAAC;IACpB,YAAY,EAAE,cAAc,CAAC;IAC7B,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C,OAAO,CAAC,EAAE,cAAc,CAAC;CAC1B;AAED,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;CAgB9B,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;CAK3B,CAAC;AAEF,qFAAqF;AACrF,eAAO,MAAM,iBAAiB,EAAE,WAAW,CAAC,MAAM,CAGhD,CAAC"}
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.V1_SDK_STATE_KEYS = exports.loadingSdkState = exports.extractionSdkState = exports.ProcessedAttachmentStatus = void 0;
|
|
3
|
+
exports.V1_SDK_STATE_KEYS = exports.loadingSdkState = exports.extractionSdkState = exports.ProcessedAttachmentStatus = exports.STATE_VERSION = void 0;
|
|
4
|
+
exports.STATE_VERSION = 2;
|
|
4
5
|
var ProcessedAttachmentStatus;
|
|
5
6
|
(function (ProcessedAttachmentStatus) {
|
|
6
7
|
ProcessedAttachmentStatus["Success"] = "success";
|
|
7
8
|
ProcessedAttachmentStatus["Failed"] = "failed";
|
|
8
9
|
})(ProcessedAttachmentStatus || (exports.ProcessedAttachmentStatus = ProcessedAttachmentStatus = {}));
|
|
9
10
|
exports.extractionSdkState = {
|
|
11
|
+
lastSyncStarted: '',
|
|
12
|
+
lastSuccessfulSyncStarted: '',
|
|
10
13
|
pendingWorkersOldest: '',
|
|
11
14
|
pendingWorkersNewest: '',
|
|
12
15
|
workersOldest: '',
|
|
13
16
|
workersNewest: '',
|
|
14
17
|
snapInVersionId: '',
|
|
15
18
|
toDevRev: {
|
|
19
|
+
deferredSsorArtifacts: [],
|
|
16
20
|
attachmentsMetadata: {
|
|
17
21
|
artifactIds: [],
|
|
18
22
|
lastProcessed: 0,
|
|
@@ -26,14 +30,8 @@ exports.loadingSdkState = {
|
|
|
26
30
|
filesToLoad: [],
|
|
27
31
|
},
|
|
28
32
|
};
|
|
29
|
-
/**
|
|
30
|
-
* SDK-owned top-level state keys, used to split a flat v1 blob during migration.
|
|
31
|
-
* `lastSyncStarted` / `lastSuccessfulSyncStarted` are no longer on `SdkState` but
|
|
32
|
-
* stay listed so v1 blobs carrying them don't leak them into connector state.
|
|
33
|
-
*/
|
|
33
|
+
/** SDK-owned top-level state keys, used to split a flat v1 blob during migration. */
|
|
34
34
|
exports.V1_SDK_STATE_KEYS = new Set([
|
|
35
35
|
...Object.keys(exports.extractionSdkState),
|
|
36
36
|
...Object.keys(exports.loadingSdkState),
|
|
37
|
-
'lastSyncStarted',
|
|
38
|
-
'lastSuccessfulSyncStarted',
|
|
39
37
|
]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time-value-resolver.d.ts","sourceRoot":"","sources":["../../src/state/time-value-resolver.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAiB,MAAM,qBAAqB,CAAC;AAEzE,wGAAwG;AACxG,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG;IAChD,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,QAAQ,CAAC;CAChB,CAcA;AAED,yEAAyE;AACzE,wBAAgB,aAAa,CAC3B,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,KAAK,GAAG,UAAU,GAC5B,MAAM,CA6BR;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,QAAQ,GACd,MAAM,
|
|
1
|
+
{"version":3,"file":"time-value-resolver.d.ts","sourceRoot":"","sources":["../../src/state/time-value-resolver.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAiB,MAAM,qBAAqB,CAAC;AAEzE,wGAAwG;AACxG,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG;IAChD,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,QAAQ,CAAC;CAChB,CAcA;AAED,yEAAyE;AACzE,wBAAgB,aAAa,CAC3B,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,KAAK,GAAG,UAAU,GAC5B,MAAM,CA6BR;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,QAAQ,GACd,MAAM,CAsER"}
|
|
@@ -80,7 +80,8 @@ function resolveTimeValue(timeValue, state) {
|
|
|
80
80
|
}
|
|
81
81
|
case extraction_1.TimeValueType.WORKERS_NEWEST: {
|
|
82
82
|
if (!state.workersNewest) {
|
|
83
|
-
|
|
83
|
+
// State from before workers boundaries existed only has the sync start.
|
|
84
|
+
return state.lastSuccessfulSyncStarted || constants_1.UNBOUNDED_DATE_TIME_VALUE;
|
|
84
85
|
}
|
|
85
86
|
return state.workersNewest;
|
|
86
87
|
}
|
|
@@ -98,7 +99,7 @@ function resolveTimeValue(timeValue, state) {
|
|
|
98
99
|
throw new Error("TimeValue of type WORKERS_NEWEST_PLUS_WINDOW must have a value (duration, e.g. '30s', '5m', '2h').");
|
|
99
100
|
}
|
|
100
101
|
if (!state.workersNewest) {
|
|
101
|
-
return constants_1.UNBOUNDED_DATE_TIME_VALUE;
|
|
102
|
+
return state.lastSuccessfulSyncStarted || constants_1.UNBOUNDED_DATE_TIME_VALUE;
|
|
102
103
|
}
|
|
103
104
|
return applyDuration(state.workersNewest, timeValue.value, 'add');
|
|
104
105
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock-event.d.ts","sourceRoot":"","sources":["../../src/testing/mock-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAa,MAAM,qBAAqB,CAAC;AAI9D,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;AAiCF;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,aAAa,GAAE,MAAgC,EAC/C,SAAS,GAAE,WAAW,CAAC,YAAY,CAAM,GACxC,YAAY,
|
|
1
|
+
{"version":3,"file":"mock-event.d.ts","sourceRoot":"","sources":["../../src/testing/mock-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAa,MAAM,qBAAqB,CAAC;AAI9D,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;AAiCF;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,aAAa,GAAE,MAAgC,EAC/C,SAAS,GAAE,WAAW,CAAC,YAAY,CAAM,GACxC,YAAY,CAuEd"}
|
|
@@ -50,17 +50,12 @@ function createMockEvent(mockServerUrl = mock_server_1.MOCK_SERVER_DEFAULT_URL,
|
|
|
50
50
|
},
|
|
51
51
|
event_context: {
|
|
52
52
|
callback_url: `${mockServerUrl}/callback_url`,
|
|
53
|
-
dev_org: 'test_dev_org',
|
|
54
53
|
dev_oid: 'test_dev_oid',
|
|
55
54
|
dev_org_id: 'test_dev_org_id',
|
|
56
|
-
dev_user: 'test_dev_user',
|
|
57
|
-
dev_user_id: 'test_dev_user_id',
|
|
58
55
|
dev_uid: 'test_dev_uid',
|
|
59
56
|
event_type_adaas: 'test_event_type_adaas',
|
|
60
|
-
external_sync_unit: 'test_external_sync_unit',
|
|
61
57
|
external_sync_unit_id: 'test_external_sync_unit_id',
|
|
62
58
|
external_sync_unit_name: 'test_external_sync_unit_name',
|
|
63
|
-
external_system: 'test_external_system',
|
|
64
59
|
external_system_id: 'test_external_system_id',
|
|
65
60
|
external_system_name: 'test_external_system_name',
|
|
66
61
|
external_system_type: 'test_external_system_type',
|
|
@@ -72,12 +67,9 @@ function createMockEvent(mockServerUrl = mock_server_1.MOCK_SERVER_DEFAULT_URL,
|
|
|
72
67
|
sequence_version: 'test_sequence_version',
|
|
73
68
|
snap_in_slug: 'test_snap_in_slug',
|
|
74
69
|
snap_in_version_id: 'test_snap_in_version_id',
|
|
75
|
-
sync_run: 'test_sync_run',
|
|
76
|
-
sync_run_id: 'test_sync_run_id',
|
|
77
70
|
sync_tier: 'test_sync_tier',
|
|
78
71
|
sync_unit: 'test_sync_unit',
|
|
79
72
|
sync_unit_id: 'test_sync_unit_id',
|
|
80
|
-
uuid: 'test_uuid',
|
|
81
73
|
worker_data_url: `${mockServerUrl}/worker_data_url`,
|
|
82
74
|
},
|
|
83
75
|
event_type: extraction_1.EventType.StartExtractingData,
|
|
@@ -23,6 +23,8 @@ export declare class MockServer {
|
|
|
23
23
|
/** Restores default handlers and clears request tracking data. */
|
|
24
24
|
resetRoutes(): void;
|
|
25
25
|
getLastRequest(): RequestInfo | undefined;
|
|
26
|
+
/** POST requests to the platform callback URL, i.e. emitted events. */
|
|
27
|
+
getCallbackRequests(): RequestInfo[];
|
|
26
28
|
getRequestCount(method: string, path: string): number;
|
|
27
29
|
getRequests(method: string, path: string): RequestInfo[];
|
|
28
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock-server.d.ts","sourceRoot":"","sources":["../../src/testing/mock-server.ts"],"names":[],"mappings":"AAEA,OAAO,EAKL,WAAW,EACX,WAAW,EAEZ,MAAM,0BAA0B,CAAC;AAIlC,eAAO,MAAM,uBAAuB,uBAAuB,CAAC;AAsE5D;;;GAGG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,YAAY,CAAS;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,aAAa,CAA4B;IACjD,OAAO,CAAC,QAAQ,CAAqB;IACrC,OAAO,CAAC,aAAa,CAA4B;gBAErC,IAAI,GAAE,MAAiC;IAMtC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAsBtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;YAkBpB,aAAa;IA+B3B,qEAAqE;IACrE,OAAO,CAAC,mBAAmB;IA6B3B,OAAO,CAAC,WAAW;IAIZ,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"mock-server.d.ts","sourceRoot":"","sources":["../../src/testing/mock-server.ts"],"names":[],"mappings":"AAEA,OAAO,EAKL,WAAW,EACX,WAAW,EAEZ,MAAM,0BAA0B,CAAC;AAIlC,eAAO,MAAM,uBAAuB,uBAAuB,CAAC;AAsE5D;;;GAGG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,YAAY,CAAS;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,aAAa,CAA4B;IACjD,OAAO,CAAC,QAAQ,CAAqB;IACrC,OAAO,CAAC,aAAa,CAA4B;gBAErC,IAAI,GAAE,MAAiC;IAMtC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAsBtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;YAkBpB,aAAa;IA+B3B,qEAAqE;IACrE,OAAO,CAAC,mBAAmB;IA6B3B,OAAO,CAAC,WAAW;IAIZ,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;IA+G1C,kEAAkE;IAC3D,WAAW,IAAI,IAAI;IAMnB,cAAc,IAAI,WAAW,GAAG,SAAS;IAOhD,uEAAuE;IAChE,mBAAmB,IAAI,WAAW,EAAE;IAOpC,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM;IAIrD,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,WAAW,EAAE;CAQhE"}
|
|
@@ -33,6 +33,12 @@ export interface RouteConfig {
|
|
|
33
33
|
bodyBuffer?: Buffer;
|
|
34
34
|
headers?: Record<string, string>;
|
|
35
35
|
retry?: RetryConfig;
|
|
36
|
+
/** Succeed for the first `successCount` requests, then fail (partial-upload scenarios). */
|
|
37
|
+
succeedThenFail?: {
|
|
38
|
+
successCount: number;
|
|
39
|
+
errorStatus?: number;
|
|
40
|
+
errorBody?: unknown;
|
|
41
|
+
};
|
|
36
42
|
/** Delay in ms before sending the response */
|
|
37
43
|
delay?: number;
|
|
38
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock-server.interfaces.d.ts","sourceRoot":"","sources":["../../src/testing/mock-server.interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAEvD,eAAO,MAAM,wBAAwB,OAAO,CAAC;AAE7C,MAAM,WAAW,aAAc,SAAQ,eAAe;IACpD,oCAAoC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,gCAAgC;IAChC,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW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ACzE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,2FAA2F;IAC3F,eAAe,CAAC,EAAE;QAChB,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,SAAS,CAAC,EAAE,OAAO,CAAC;KACrB,CAAC;IACF,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,YAAY,KAAK,OAAO,CAAC;AAE9E,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AAEtD,gCAAgC;AAChC,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC"}
|
|
@@ -168,19 +168,46 @@ class MockServer {
|
|
|
168
168
|
return `${method.toUpperCase()}:${path}`;
|
|
169
169
|
}
|
|
170
170
|
setRoute(config) {
|
|
171
|
-
const { path, method, status, body, bodyBuffer, retry, headers, delay } = config;
|
|
171
|
+
const { path, method, status, body, bodyBuffer, retry, succeedThenFail, headers, delay, } = config;
|
|
172
172
|
const key = this.getRouteKey(method, path);
|
|
173
|
-
if (retry) {
|
|
173
|
+
if (retry || succeedThenFail) {
|
|
174
174
|
this.requestCounts.set(key, 0);
|
|
175
175
|
}
|
|
176
176
|
this.routeHandlers.set(key, (req, res) => {
|
|
177
177
|
const sendResponse = (responseDelay) => {
|
|
178
178
|
const send = () => {
|
|
179
|
-
var _a, _b;
|
|
180
|
-
if (
|
|
179
|
+
var _a, _b, _c;
|
|
180
|
+
if (succeedThenFail) {
|
|
181
181
|
const currentCount = this.requestCounts.get(key) || 0;
|
|
182
|
-
|
|
183
|
-
|
|
182
|
+
this.requestCounts.set(key, currentCount + 1);
|
|
183
|
+
if (currentCount < succeedThenFail.successCount) {
|
|
184
|
+
if (headers) {
|
|
185
|
+
res.set(headers);
|
|
186
|
+
}
|
|
187
|
+
if (bodyBuffer !== undefined) {
|
|
188
|
+
res.status(status).buffer(bodyBuffer);
|
|
189
|
+
}
|
|
190
|
+
else if (body !== undefined) {
|
|
191
|
+
res.status(status).json(body);
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
this.defaultRouteHandler(req, res);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
const errorStatus = (_a = succeedThenFail.errorStatus) !== null && _a !== void 0 ? _a : 400;
|
|
199
|
+
if (succeedThenFail.errorBody !== undefined) {
|
|
200
|
+
res.status(errorStatus).json(succeedThenFail.errorBody);
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
res.status(errorStatus).send();
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
else if (retry) {
|
|
208
|
+
const currentCount = this.requestCounts.get(key) || 0;
|
|
209
|
+
const failureCount = (_b = retry.failureCount) !== null && _b !== void 0 ? _b : 4;
|
|
210
|
+
const errorStatus = (_c = retry.errorStatus) !== null && _c !== void 0 ? _c : 500;
|
|
184
211
|
if (currentCount < failureCount) {
|
|
185
212
|
this.requestCounts.set(key, currentCount + 1);
|
|
186
213
|
const sendFailure = () => {
|
|
@@ -254,6 +281,10 @@ class MockServer {
|
|
|
254
281
|
}
|
|
255
282
|
return this.requests[this.requests.length - 1];
|
|
256
283
|
}
|
|
284
|
+
/** POST requests to the platform callback URL, i.e. emitted events. */
|
|
285
|
+
getCallbackRequests() {
|
|
286
|
+
return this.requests.filter((req) => req.method.toUpperCase() === 'POST' && req.url.includes('callback_url'));
|
|
287
|
+
}
|
|
257
288
|
getRequestCount(method, path) {
|
|
258
289
|
return this.getRequests(method, path).length;
|
|
259
290
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ExtractionAdapter } from '../multithreading/adapters/extraction-adapter';
|
|
2
|
+
import { LoadingAdapter } from '../multithreading/adapters/loading-adapter';
|
|
3
|
+
import { AirSyncEvent } from '../types/extraction';
|
|
4
|
+
import { FileToLoad } from '../types/loading';
|
|
5
|
+
import { SpawnOptions } from '../types/workers';
|
|
6
|
+
export interface TestAdapterParams<ConnectorState> {
|
|
7
|
+
event: AirSyncEvent;
|
|
8
|
+
initialState: ConnectorState;
|
|
9
|
+
options?: SpawnOptions;
|
|
10
|
+
}
|
|
11
|
+
export interface TestLoadingAdapterParams<ConnectorState> extends TestAdapterParams<ConnectorState> {
|
|
12
|
+
/** Transformer files to resume from, as if a START_* event had set them. */
|
|
13
|
+
filesToLoad?: FileToLoad[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Builds an extraction adapter for connector tests without fetching state.
|
|
17
|
+
* Platform calls still go to the event's URLs; point them at a MockServer.
|
|
18
|
+
*/
|
|
19
|
+
export declare function createTestExtractionAdapter<ConnectorState>({ event, initialState, options, }: TestAdapterParams<ConnectorState>): ExtractionAdapter<ConnectorState>;
|
|
20
|
+
/** Loading counterpart of {@link createTestExtractionAdapter}. */
|
|
21
|
+
export declare function createTestLoadingAdapter<ConnectorState>({ event, initialState, filesToLoad, options, }: TestLoadingAdapterParams<ConnectorState>): LoadingAdapter<ConnectorState>;
|
|
22
|
+
//# sourceMappingURL=test-adapters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-adapters.d.ts","sourceRoot":"","sources":["../../src/testing/test-adapters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAG5E,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,MAAM,WAAW,iBAAiB,CAAC,cAAc;IAC/C,KAAK,EAAE,YAAY,CAAC;IACpB,YAAY,EAAE,cAAc,CAAC;IAC7B,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB;AAED,MAAM,WAAW,wBAAwB,CAAC,cAAc,CACtD,SAAQ,iBAAiB,CAAC,cAAc,CAAC;IACzC,4EAA4E;IAC5E,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;CAC5B;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,cAAc,EAAE,EAC1D,KAAK,EACL,YAAY,EACZ,OAAO,GACR,EAAE,iBAAiB,CAAC,cAAc,CAAC,GAAG,iBAAiB,CAAC,cAAc,CAAC,CAOvE;AAED,kEAAkE;AAClE,wBAAgB,wBAAwB,CAAC,cAAc,EAAE,EACvD,KAAK,EACL,YAAY,EACZ,WAAW,EACX,OAAO,GACR,EAAE,wBAAwB,CAAC,cAAc,CAAC,GAAG,cAAc,CAAC,cAAc,CAAC,CAU3E"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createTestExtractionAdapter = createTestExtractionAdapter;
|
|
4
|
+
exports.createTestLoadingAdapter = createTestLoadingAdapter;
|
|
5
|
+
const extraction_adapter_1 = require("../multithreading/adapters/extraction-adapter");
|
|
6
|
+
const loading_adapter_1 = require("../multithreading/adapters/loading-adapter");
|
|
7
|
+
const extraction_state_1 = require("../state/extraction-state");
|
|
8
|
+
const loading_state_1 = require("../state/loading-state");
|
|
9
|
+
/**
|
|
10
|
+
* Builds an extraction adapter for connector tests without fetching state.
|
|
11
|
+
* Platform calls still go to the event's URLs; point them at a MockServer.
|
|
12
|
+
*/
|
|
13
|
+
function createTestExtractionAdapter({ event, initialState, options, }) {
|
|
14
|
+
const adapterState = new extraction_state_1.ExtractionState({
|
|
15
|
+
event,
|
|
16
|
+
initialState,
|
|
17
|
+
options,
|
|
18
|
+
});
|
|
19
|
+
return new extraction_adapter_1.ExtractionAdapter({ event, adapterState, options });
|
|
20
|
+
}
|
|
21
|
+
/** Loading counterpart of {@link createTestExtractionAdapter}. */
|
|
22
|
+
function createTestLoadingAdapter({ event, initialState, filesToLoad, options, }) {
|
|
23
|
+
const adapterState = new loading_state_1.LoadingState({
|
|
24
|
+
event,
|
|
25
|
+
initialState,
|
|
26
|
+
options,
|
|
27
|
+
});
|
|
28
|
+
if (filesToLoad) {
|
|
29
|
+
adapterState.sdkState.fromDevRev = { filesToLoad };
|
|
30
|
+
}
|
|
31
|
+
return new loading_adapter_1.LoadingAdapter({ event, adapterState, options });
|
|
32
|
+
}
|
package/dist/types/common.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
import { AirSyncErrorCode } from './errors';
|
|
1
2
|
export interface ErrorRecord {
|
|
2
3
|
message: string;
|
|
4
|
+
/** Platform-recognized condition; when set, it replaces the wire message. */
|
|
5
|
+
code?: AirSyncErrorCode;
|
|
3
6
|
}
|
|
4
7
|
export interface InitialDomainMapping {
|
|
5
8
|
starting_recipe_blueprint?: object;
|
|
6
9
|
additional_mappings?: object;
|
|
7
10
|
}
|
|
8
|
-
/** INITIAL = first import, INCREMENTAL = subsequent syncs, LOADING = DevRev
|
|
11
|
+
/** INITIAL = first import, INCREMENTAL = subsequent syncs, LOADING = DevRev to external system. */
|
|
9
12
|
export declare enum SyncMode {
|
|
10
13
|
INITIAL = "INITIAL",
|
|
11
14
|
INCREMENTAL = "INCREMENTAL",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/types/common.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/types/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,6EAA6E;IAC7E,IAAI,CAAC,EAAE,gBAAgB,CAAC;CACzB;AAED,MAAM,WAAW,oBAAoB;IACnC,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,mGAAmG;AACnG,oBAAY,QAAQ;IAClB,OAAO,YAAY;IACnB,WAAW,gBAAgB;IAC3B,OAAO,YAAY;CACpB"}
|
package/dist/types/common.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SyncMode = void 0;
|
|
4
|
-
/** INITIAL = first import, INCREMENTAL = subsequent syncs, LOADING = DevRev
|
|
4
|
+
/** INITIAL = first import, INCREMENTAL = subsequent syncs, LOADING = DevRev to external system. */
|
|
5
5
|
var SyncMode;
|
|
6
6
|
(function (SyncMode) {
|
|
7
7
|
SyncMode["INITIAL"] = "INITIAL";
|
package/dist/types/errors.d.ts
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Error codes the platform reacts to (e.g. stopping periodic syncs). Set them
|
|
3
|
+
* on `ErrorRecord.code`; the platform matches the code exactly, so the SDK
|
|
4
|
+
* sends it as the whole wire message.
|
|
5
|
+
*/
|
|
6
|
+
export declare enum AirSyncErrorCode {
|
|
7
|
+
EXTERNAL_SYNC_UNIT_DELETED = "EXTERNAL_SYNC_UNIT_DELETED",
|
|
8
|
+
EXTERNAL_SYNC_UNIT_DEACTIVATED = "EXTERNAL_SYNC_UNIT_DEACTIVATED",
|
|
9
|
+
USER_DELETED = "USER_DELETED",
|
|
10
|
+
EXTERNAL_SYSTEM_NO_ACCESS = "EXTERNAL_SYSTEM_NO_ACCESS",
|
|
11
|
+
EXTERNAL_SYSTEM_NO_PERMISSION = "EXTERNAL_SYSTEM_NO_PERMISSION",
|
|
12
|
+
HISTORICAL_DATA_EXTRACTION_DONE = "HISTORICAL_DATA_EXTRACTION_DONE"
|
|
8
13
|
}
|
|
14
|
+
export declare function formatErrorCode(code: AirSyncErrorCode): string;
|
|
9
15
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/types/errors.ts"],"names":[],"mappings":"AAGA,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/types/errors.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,oBAAY,gBAAgB;IAG1B,0BAA0B,+BAA+B;IACzD,8BAA8B,mCAAmC;IACjE,YAAY,iBAAiB;IAG7B,yBAAyB,8BAA8B;IAEvD,6BAA6B,kCAAkC;IAE/D,+BAA+B,oCAAoC;CACpE;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,gBAAgB,GAAG,MAAM,CAE9D"}
|
package/dist/types/errors.js
CHANGED
|
@@ -1,4 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AirSyncErrorCode = void 0;
|
|
4
|
+
exports.formatErrorCode = formatErrorCode;
|
|
3
5
|
const ERROR_PREFIX = 'ERROR_CODE';
|
|
4
6
|
const ERROR_DELIMITER = '=';
|
|
7
|
+
/**
|
|
8
|
+
* Error codes the platform reacts to (e.g. stopping periodic syncs). Set them
|
|
9
|
+
* on `ErrorRecord.code`; the platform matches the code exactly, so the SDK
|
|
10
|
+
* sends it as the whole wire message.
|
|
11
|
+
*/
|
|
12
|
+
var AirSyncErrorCode;
|
|
13
|
+
(function (AirSyncErrorCode) {
|
|
14
|
+
// Persistent conditions (system deleted, deactivated, access permanently
|
|
15
|
+
// revoked) that require stopping periodic syncs, not transient failures.
|
|
16
|
+
AirSyncErrorCode["EXTERNAL_SYNC_UNIT_DELETED"] = "EXTERNAL_SYNC_UNIT_DELETED";
|
|
17
|
+
AirSyncErrorCode["EXTERNAL_SYNC_UNIT_DEACTIVATED"] = "EXTERNAL_SYNC_UNIT_DEACTIVATED";
|
|
18
|
+
AirSyncErrorCode["USER_DELETED"] = "USER_DELETED";
|
|
19
|
+
// Could not find an accessible resource in the source system.
|
|
20
|
+
AirSyncErrorCode["EXTERNAL_SYSTEM_NO_ACCESS"] = "EXTERNAL_SYSTEM_NO_ACCESS";
|
|
21
|
+
// The user is missing a required permission.
|
|
22
|
+
AirSyncErrorCode["EXTERNAL_SYSTEM_NO_PERMISSION"] = "EXTERNAL_SYSTEM_NO_PERMISSION";
|
|
23
|
+
// The historical periodic sync reached the end; nothing left to extract.
|
|
24
|
+
AirSyncErrorCode["HISTORICAL_DATA_EXTRACTION_DONE"] = "HISTORICAL_DATA_EXTRACTION_DONE";
|
|
25
|
+
})(AirSyncErrorCode || (exports.AirSyncErrorCode = AirSyncErrorCode = {}));
|
|
26
|
+
function formatErrorCode(code) {
|
|
27
|
+
return `${ERROR_PREFIX}${ERROR_DELIMITER}${code}`;
|
|
28
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { InputData } from '@devrev/typescript-sdk/dist/snap-ins';
|
|
2
1
|
import { ExtractionAdapter } from '../multithreading/adapters/extraction-adapter';
|
|
3
2
|
import { NormalizedAttachment } from '../repo/repo.interfaces';
|
|
4
3
|
import { Artifact } from '../uploader/uploader.interfaces';
|
|
5
4
|
import { ErrorRecord } from './common';
|
|
6
|
-
import { DonV2, LoaderReport
|
|
5
|
+
import { DonV2, LoaderReport } from './loading';
|
|
7
6
|
/** Events sent from AirSync to the connector. */
|
|
8
7
|
export declare enum EventType {
|
|
9
8
|
StartExtractingExternalSyncUnits = "START_EXTRACTING_EXTERNAL_SYNC_UNITS",
|
|
10
9
|
StartExtractingMetadata = "START_EXTRACTING_METADATA",
|
|
10
|
+
ContinueExtractingMetadata = "CONTINUE_EXTRACTING_METADATA",
|
|
11
11
|
StartExtractingData = "START_EXTRACTING_DATA",
|
|
12
12
|
ContinueExtractingData = "CONTINUE_EXTRACTING_DATA",
|
|
13
13
|
StartDeletingExtractorState = "START_DELETING_EXTRACTOR_STATE",
|
|
@@ -25,6 +25,8 @@ export declare enum EventType {
|
|
|
25
25
|
export declare enum ExtractorEventType {
|
|
26
26
|
ExternalSyncUnitExtractionDone = "EXTERNAL_SYNC_UNIT_EXTRACTION_DONE",
|
|
27
27
|
ExternalSyncUnitExtractionError = "EXTERNAL_SYNC_UNIT_EXTRACTION_ERROR",
|
|
28
|
+
MetadataExtractionProgress = "METADATA_EXTRACTION_PROGRESS",
|
|
29
|
+
MetadataExtractionDelayed = "METADATA_EXTRACTION_DELAYED",
|
|
28
30
|
MetadataExtractionDone = "METADATA_EXTRACTION_DONE",
|
|
29
31
|
MetadataExtractionError = "METADATA_EXTRACTION_ERROR",
|
|
30
32
|
DataExtractionProgress = "DATA_EXTRACTION_PROGRESS",
|
|
@@ -85,33 +87,29 @@ export interface TimeValue {
|
|
|
85
87
|
}
|
|
86
88
|
export interface EventContext {
|
|
87
89
|
callback_url: string;
|
|
88
|
-
/** @deprecated Use dev_oid instead. */
|
|
89
|
-
dev_org: string;
|
|
90
90
|
dev_oid: string;
|
|
91
91
|
dev_org_id: string;
|
|
92
|
-
/** @deprecated Use dev_uid instead. */
|
|
93
|
-
dev_user: string;
|
|
94
|
-
/** @deprecated Use dev_uid instead. */
|
|
95
|
-
dev_user_id: string;
|
|
96
92
|
dev_uid: string;
|
|
97
93
|
event_type_adaas: string;
|
|
98
|
-
/** @deprecated Use external_sync_unit_id instead. */
|
|
99
|
-
external_sync_unit: string;
|
|
100
94
|
external_sync_unit_id: string;
|
|
101
95
|
external_sync_unit_name: string;
|
|
102
|
-
/** @deprecated Use external_system_id instead. */
|
|
103
|
-
external_system: string;
|
|
104
96
|
external_system_id: string;
|
|
105
97
|
external_system_name: string;
|
|
106
98
|
external_system_type: string;
|
|
107
|
-
/**
|
|
99
|
+
/**
|
|
100
|
+
* Start of extraction (ISO 8601): resolved by the SDK from
|
|
101
|
+
* extraction_start_time and worker state, or on platforms that don't send it,
|
|
102
|
+
* the last successful sync start / the platform-supplied value.
|
|
103
|
+
*/
|
|
108
104
|
extract_from?: string;
|
|
105
|
+
/** The platform-supplied extract_from, kept when the SDK overrides it. */
|
|
106
|
+
original_extract_from?: string;
|
|
109
107
|
import_slug: string;
|
|
110
108
|
initial_sync_scope?: InitialSyncScope;
|
|
111
109
|
mode: string;
|
|
112
110
|
request_id: string;
|
|
113
111
|
request_id_adaas: string;
|
|
114
|
-
/** @deprecated */
|
|
112
|
+
/** @deprecated Never read by the SDK; kept because connectors still branch on it. */
|
|
115
113
|
reset_extraction?: boolean;
|
|
116
114
|
/** @deprecated Use extraction_start_time/extraction_end_time (resolved into extract_from/extract_to). */
|
|
117
115
|
reset_extract_from?: boolean;
|
|
@@ -119,15 +117,9 @@ export interface EventContext {
|
|
|
119
117
|
sequence_version: string;
|
|
120
118
|
snap_in_slug: string;
|
|
121
119
|
snap_in_version_id: string;
|
|
122
|
-
/** @deprecated Use run_id instead. */
|
|
123
|
-
sync_run: string;
|
|
124
|
-
/** @deprecated Use run_id instead. */
|
|
125
|
-
sync_run_id: string;
|
|
126
120
|
sync_tier: string;
|
|
127
121
|
sync_unit: DonV2;
|
|
128
122
|
sync_unit_id: string;
|
|
129
|
-
/** @deprecated Use request_id_adaas instead. */
|
|
130
|
-
uuid: string;
|
|
131
123
|
worker_data_url: string;
|
|
132
124
|
/** Platform-sent start time; the SDK resolves it into extract_from. */
|
|
133
125
|
extraction_start_time?: TimeValue;
|
|
@@ -142,6 +134,17 @@ export interface ConnectionData {
|
|
|
142
134
|
key: string;
|
|
143
135
|
key_type: string;
|
|
144
136
|
}
|
|
137
|
+
/** Sync-duration-estimation model input that a counted record type feeds into. */
|
|
138
|
+
export declare enum ItemInputType {
|
|
139
|
+
MAIN = "main",
|
|
140
|
+
USERS = "users"
|
|
141
|
+
}
|
|
142
|
+
/** Per-record-type count reported during the metadata phase, used for sync-duration estimation. */
|
|
143
|
+
export interface ItemTypeCount {
|
|
144
|
+
record_type: string;
|
|
145
|
+
count: number;
|
|
146
|
+
model_input_type: ItemInputType;
|
|
147
|
+
}
|
|
145
148
|
export interface EventData {
|
|
146
149
|
error?: ErrorRecord;
|
|
147
150
|
delay?: number;
|
|
@@ -154,6 +157,11 @@ export interface EventData {
|
|
|
154
157
|
reports?: LoaderReport[];
|
|
155
158
|
processed_files?: string[];
|
|
156
159
|
stats_file?: string;
|
|
160
|
+
/**
|
|
161
|
+
* Per-record-type counts attached to the metadata-done event by the SDK when
|
|
162
|
+
* the connector sets ExtractionAdapter.preExtractionItemCounts.
|
|
163
|
+
*/
|
|
164
|
+
pre_extraction_item_counts?: ItemTypeCount[];
|
|
157
165
|
}
|
|
158
166
|
export interface WorkerMetadata {
|
|
159
167
|
adaas_library_version?: string;
|
|
@@ -188,6 +196,14 @@ export interface AirSyncEvent {
|
|
|
188
196
|
};
|
|
189
197
|
input_data: InputData;
|
|
190
198
|
}
|
|
199
|
+
/** Snap-in inputs passed with every event. */
|
|
200
|
+
export interface InputData {
|
|
201
|
+
/** Snap-in globals; values arrive as strings. */
|
|
202
|
+
global_values: Record<string, string>;
|
|
203
|
+
event_sources: Record<string, string>;
|
|
204
|
+
/** Keyrings, tags and other manifest resources, keyed by resource name. */
|
|
205
|
+
resources?: Record<string, any>;
|
|
206
|
+
}
|
|
191
207
|
export interface AirSyncMessage {
|
|
192
208
|
connection_data: ConnectionData;
|
|
193
209
|
event_context: EventContext;
|
|
@@ -201,12 +217,6 @@ export interface ExtractorEvent {
|
|
|
201
217
|
event_data?: EventData;
|
|
202
218
|
worker_metadata?: WorkerMetadata;
|
|
203
219
|
}
|
|
204
|
-
export interface LoaderEvent {
|
|
205
|
-
event_type: string;
|
|
206
|
-
event_context: EventContext;
|
|
207
|
-
event_data?: EventData;
|
|
208
|
-
worker_metadata?: WorkerMetadata;
|
|
209
|
-
}
|
|
210
220
|
export type ExternalSystemAttachmentStreamingFunction = ({ item, event, }: ExternalSystemAttachmentStreamingParams) => Promise<ExternalSystemAttachmentStreamingResponse>;
|
|
211
221
|
export interface ExternalSystemAttachmentStreamingParams {
|
|
212
222
|
item: NormalizedAttachment;
|
|
@@ -216,27 +226,33 @@ export interface HttpStreamResponse {
|
|
|
216
226
|
data: any;
|
|
217
227
|
headers: Record<string, any>;
|
|
218
228
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
+
/** Returned by the connector's attachment `stream` function. */
|
|
230
|
+
export type ExternalSystemAttachmentStreamingResponse = {
|
|
231
|
+
status: 'success';
|
|
232
|
+
httpStream: HttpStreamResponse;
|
|
233
|
+
} | {
|
|
234
|
+
status: 'delay';
|
|
235
|
+
delaySeconds: number;
|
|
236
|
+
} | {
|
|
237
|
+
status: 'error';
|
|
238
|
+
error: ErrorRecord;
|
|
239
|
+
};
|
|
240
|
+
/**
|
|
241
|
+
* Outcome of streaming one attachment. `success` is also returned when the
|
|
242
|
+
* soft timeout cut the upload short; the attachment is then retried in the
|
|
243
|
+
* next invocation, so check `adapter.isTimeout` before recording it as done.
|
|
244
|
+
*/
|
|
229
245
|
export type ProcessAttachmentReturnType = {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
246
|
+
status: 'success';
|
|
247
|
+
} | {
|
|
248
|
+
status: 'delay';
|
|
249
|
+
delaySeconds: number;
|
|
250
|
+
} | {
|
|
251
|
+
status: 'error';
|
|
252
|
+
error: ErrorRecord & {
|
|
233
253
|
fileSize?: number;
|
|
234
254
|
};
|
|
235
|
-
}
|
|
236
|
-
export type StreamAttachmentsReturnType = {
|
|
237
|
-
delay?: number;
|
|
238
|
-
error?: ErrorRecord;
|
|
239
|
-
} | undefined;
|
|
255
|
+
};
|
|
240
256
|
export type ExternalSystemAttachmentReducerFunction<Batch, NewBatch, ConnectorState> = ({ attachments, adapter, batchSize, }: {
|
|
241
257
|
attachments: Batch;
|
|
242
258
|
adapter: ExtractionAdapter<ConnectorState>;
|