@devrev/airsync-sdk 2.0.0-beta.0 → 2.0.0-beta.10
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 +7 -21
- package/dist/attachments-streaming/attachments-streaming-pool.d.ts +7 -1
- package/dist/attachments-streaming/attachments-streaming-pool.d.ts.map +1 -1
- package/dist/attachments-streaming/attachments-streaming-pool.interfaces.d.ts +4 -3
- package/dist/attachments-streaming/attachments-streaming-pool.interfaces.d.ts.map +1 -1
- package/dist/attachments-streaming/attachments-streaming-pool.js +70 -33
- package/dist/common/constants.d.ts +15 -12
- package/dist/common/constants.d.ts.map +1 -1
- package/dist/common/constants.js +20 -34
- package/dist/common/helpers.d.ts +3 -27
- package/dist/common/helpers.d.ts.map +1 -1
- package/dist/common/helpers.js +6 -36
- package/dist/http/{axios-client-internal.d.ts → client.d.ts} +1 -1
- package/dist/http/client.d.ts.map +1 -0
- package/dist/http/{axios-client-internal.js → client.js} +7 -4
- 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 +30 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +47 -28
- package/dist/logger/logger.d.ts +13 -70
- package/dist/logger/logger.d.ts.map +1 -1
- package/dist/logger/logger.interfaces.d.ts +4 -7
- package/dist/logger/logger.interfaces.d.ts.map +1 -1
- package/dist/logger/logger.js +67 -92
- package/dist/mappers/mappers.d.ts +10 -43
- package/dist/mappers/mappers.d.ts.map +1 -1
- package/dist/mappers/mappers.interfaces.d.ts +173 -0
- package/dist/mappers/mappers.interfaces.d.ts.map +1 -0
- package/dist/mappers/{mappers.interface.js → mappers.interfaces.js} +1 -10
- package/dist/mappers/mappers.js +32 -46
- package/dist/multithreading/adapters/base-adapter.d.ts +39 -0
- package/dist/multithreading/adapters/base-adapter.d.ts.map +1 -0
- package/dist/multithreading/adapters/base-adapter.js +212 -0
- package/dist/multithreading/adapters/extraction-adapter.d.ts +49 -0
- package/dist/multithreading/adapters/extraction-adapter.d.ts.map +1 -0
- package/dist/multithreading/adapters/extraction-adapter.js +375 -0
- package/dist/multithreading/adapters/loading-adapter.d.ts +26 -0
- package/dist/multithreading/adapters/loading-adapter.d.ts.map +1 -0
- package/dist/multithreading/adapters/loading-adapter.helpers.d.ts +12 -0
- package/dist/multithreading/adapters/loading-adapter.helpers.d.ts.map +1 -0
- package/dist/multithreading/{worker-adapter/worker-adapter.helpers.js → adapters/loading-adapter.helpers.js} +2 -12
- package/dist/multithreading/adapters/loading-adapter.js +279 -0
- package/dist/multithreading/emit.d.ts +11 -0
- package/dist/multithreading/emit.d.ts.map +1 -0
- package/dist/multithreading/emit.js +25 -0
- package/dist/multithreading/process-task.d.ts +6 -1
- package/dist/multithreading/process-task.d.ts.map +1 -1
- package/dist/multithreading/process-task.js +124 -51
- package/dist/multithreading/spawn/spawn.d.ts +11 -11
- package/dist/multithreading/spawn/spawn.d.ts.map +1 -1
- package/dist/multithreading/spawn/spawn.helpers.d.ts +12 -11
- package/dist/multithreading/spawn/spawn.helpers.d.ts.map +1 -1
- package/dist/multithreading/spawn/spawn.helpers.js +142 -77
- package/dist/multithreading/spawn/spawn.js +74 -75
- package/dist/multithreading/worker.js +16 -5
- package/dist/repo/repo.d.ts +14 -5
- package/dist/repo/repo.d.ts.map +1 -1
- package/dist/repo/repo.helpers.d.ts +6 -0
- package/dist/repo/repo.helpers.d.ts.map +1 -0
- package/dist/repo/repo.helpers.js +16 -0
- package/dist/repo/repo.interfaces.d.ts +11 -20
- package/dist/repo/repo.interfaces.d.ts.map +1 -1
- package/dist/repo/repo.js +36 -22
- package/dist/state/base-state.d.ts +58 -0
- package/dist/state/base-state.d.ts.map +1 -0
- package/dist/state/base-state.js +242 -0
- package/dist/state/extraction-state.d.ts +14 -0
- package/dist/state/extraction-state.d.ts.map +1 -0
- package/dist/state/extraction-state.js +140 -0
- package/dist/state/install-initial-domain-mapping.d.ts +4 -0
- package/dist/state/install-initial-domain-mapping.d.ts.map +1 -0
- package/dist/{common → state}/install-initial-domain-mapping.js +5 -7
- package/dist/state/loading-state.d.ts +8 -0
- package/dist/state/loading-state.d.ts.map +1 -0
- package/dist/state/loading-state.js +29 -0
- package/dist/state/state.d.ts +3 -29
- package/dist/state/state.d.ts.map +1 -1
- package/dist/state/state.interfaces.d.ts +36 -10
- package/dist/state/state.interfaces.d.ts.map +1 -1
- package/dist/state/state.interfaces.js +17 -1
- package/dist/state/state.js +9 -164
- package/dist/state/time-value-resolver.d.ts +17 -0
- package/dist/state/time-value-resolver.d.ts.map +1 -0
- package/dist/state/time-value-resolver.js +110 -0
- package/dist/testing/mock-event.d.ts +10 -0
- package/dist/testing/mock-event.d.ts.map +1 -0
- package/dist/testing/mock-event.js +96 -0
- package/dist/testing/mock-server.d.ts +31 -0
- package/dist/testing/mock-server.d.ts.map +1 -0
- package/dist/testing/mock-server.interfaces.d.ts +54 -0
- package/dist/testing/mock-server.interfaces.d.ts.map +1 -0
- package/dist/testing/mock-server.interfaces.js +4 -0
- package/dist/testing/mock-server.js +297 -0
- 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 -37
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/common.js +2 -17
- package/dist/types/errors.d.ts +15 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/errors.js +28 -0
- package/dist/types/external-domain-metadata.d.ts +197 -0
- package/dist/types/external-domain-metadata.d.ts.map +1 -0
- package/dist/types/extraction.d.ts +135 -278
- package/dist/types/extraction.d.ts.map +1 -1
- package/dist/types/extraction.js +46 -133
- package/dist/types/loading.d.ts +15 -55
- package/dist/types/loading.d.ts.map +1 -1
- package/dist/types/loading.js +1 -23
- package/dist/types/workers.d.ts +70 -103
- package/dist/types/workers.d.ts.map +1 -1
- package/dist/types/workers.js +1 -6
- package/dist/uploader/uploader.d.ts +10 -61
- package/dist/uploader/uploader.d.ts.map +1 -1
- package/dist/uploader/uploader.helpers.d.ts +7 -27
- package/dist/uploader/uploader.helpers.d.ts.map +1 -1
- package/dist/uploader/uploader.helpers.js +80 -30
- package/dist/uploader/uploader.interfaces.d.ts +19 -54
- package/dist/uploader/uploader.interfaces.d.ts.map +1 -1
- package/dist/uploader/uploader.interfaces.js +8 -0
- package/dist/uploader/uploader.js +72 -124
- package/docs/MIGRATION.md +696 -0
- package/package.json +37 -20
- package/dist/attachments-streaming/attachments-streaming-pool.test.d.ts +0 -2
- package/dist/attachments-streaming/attachments-streaming-pool.test.d.ts.map +0 -1
- package/dist/attachments-streaming/attachments-streaming-pool.test.js +0 -267
- package/dist/common/control-protocol.d.ts +0 -10
- package/dist/common/control-protocol.d.ts.map +0 -1
- package/dist/common/control-protocol.js +0 -31
- package/dist/common/errors.d.ts +0 -6
- package/dist/common/errors.d.ts.map +0 -1
- package/dist/common/errors.js +0 -4
- 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/common/install-initial-domain-mapping.d.ts +0 -4
- package/dist/common/install-initial-domain-mapping.d.ts.map +0 -1
- package/dist/common/install-initial-domain-mapping.test.d.ts +0 -2
- package/dist/common/install-initial-domain-mapping.test.d.ts.map +0 -1
- package/dist/common/install-initial-domain-mapping.test.js +0 -207
- 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/axios-client-internal.d.ts.map +0 -1
- package/dist/http/axios-client-internal.test.d.ts +0 -2
- package/dist/http/axios-client-internal.test.d.ts.map +0 -1
- package/dist/http/axios-client-internal.test.js +0 -154
- package/dist/http/axios-client.d.ts +0 -27
- package/dist/http/axios-client.d.ts.map +0 -1
- package/dist/http/axios-client.js +0 -57
- package/dist/http/constants.d.ts +0 -4
- package/dist/http/constants.d.ts.map +0 -1
- package/dist/http/constants.js +0 -6
- package/dist/http/index.d.ts +0 -3
- package/dist/http/index.d.ts.map +0 -1
- package/dist/http/index.js +0 -18
- package/dist/http/types.d.ts +0 -17
- package/dist/http/types.d.ts.map +0 -1
- package/dist/logger/logger.constants.d.ts +0 -6
- package/dist/logger/logger.constants.d.ts.map +0 -1
- package/dist/logger/logger.constants.js +0 -13
- package/dist/logger/logger.context.d.ts +0 -58
- package/dist/logger/logger.context.d.ts.map +0 -1
- package/dist/logger/logger.context.js +0 -86
- package/dist/logger/logger.test.d.ts +0 -2
- package/dist/logger/logger.test.d.ts.map +0 -1
- package/dist/logger/logger.test.js +0 -490
- package/dist/mappers/mappers.interface.d.ts +0 -294
- package/dist/mappers/mappers.interface.d.ts.map +0 -1
- package/dist/mappers/mappers.test.d.ts +0 -2
- package/dist/mappers/mappers.test.d.ts.map +0 -1
- package/dist/mappers/mappers.test.js +0 -107
- package/dist/multithreading/create-worker.test.d.ts +0 -2
- package/dist/multithreading/create-worker.test.d.ts.map +0 -1
- package/dist/multithreading/create-worker.test.js +0 -89
- package/dist/multithreading/spawn/spawn.helpers.test.d.ts +0 -2
- package/dist/multithreading/spawn/spawn.helpers.test.d.ts.map +0 -1
- package/dist/multithreading/spawn/spawn.helpers.test.js +0 -293
- package/dist/multithreading/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.artifacts.test.js +0 -127
- 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 +0 -22
- 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.helpers.test.js +0 -514
- package/dist/multithreading/worker-adapter/worker-adapter.js +0 -747
- 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/repo/repo.test.d.ts +0 -2
- package/dist/repo/repo.test.d.ts.map +0 -1
- package/dist/repo/repo.test.js +0 -131
- package/dist/state/state.test.d.ts +0 -2
- package/dist/state/state.test.d.ts.map +0 -1
- package/dist/state/state.test.js +0 -224
- package/dist/types/extraction.test.d.ts +0 -2
- package/dist/types/extraction.test.d.ts.map +0 -1
- package/dist/types/extraction.test.js +0 -70
- package/dist/types/index.d.ts +0 -9
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -18
- package/dist/uploader/uploader.helpers.test.d.ts +0 -2
- package/dist/uploader/uploader.helpers.test.d.ts.map +0 -1
- package/dist/uploader/uploader.helpers.test.js +0 -267
- package/dist/uploader/uploader.test.d.ts +0 -2
- package/dist/uploader/uploader.test.d.ts.map +0 -1
- package/dist/uploader/uploader.test.js +0 -589
- /package/dist/{http/types.js → types/external-domain-metadata.js} +0 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { AirSyncEvent } from '../types/extraction';
|
|
2
|
+
import { DonV2 } from '../types/loading';
|
|
3
|
+
export interface MappersFactoryInterface {
|
|
4
|
+
event: AirSyncEvent;
|
|
5
|
+
}
|
|
6
|
+
export interface UpdateSyncMapperRecordParams {
|
|
7
|
+
external_ids: {
|
|
8
|
+
add: string[];
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Labels values in `external_ids` with their usage context (e.g. a UUID for
|
|
12
|
+
* one API call, a login username for another). Not indexed: to look up by a
|
|
13
|
+
* secondary value it must also be present in `external_ids`.
|
|
14
|
+
*/
|
|
15
|
+
secondary_ids?: Record<string, string>;
|
|
16
|
+
targets: {
|
|
17
|
+
add: DonV2[];
|
|
18
|
+
};
|
|
19
|
+
status: SyncMapperRecordStatus;
|
|
20
|
+
/** Input file name(s) containing the object data; helps later debugging. */
|
|
21
|
+
input_files?: {
|
|
22
|
+
add: string[];
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Prevents update loops: after writing the object to the external system,
|
|
26
|
+
* add its modified_date here. The Loader skips extracted updates whose
|
|
27
|
+
* modified_date is listed (the change originated in DevRev).
|
|
28
|
+
*/
|
|
29
|
+
external_versions?: {
|
|
30
|
+
add: SyncMapperRecordExternalVersion[];
|
|
31
|
+
};
|
|
32
|
+
/** Free-form storage; opaque to the platform. */
|
|
33
|
+
extra_data?: string;
|
|
34
|
+
}
|
|
35
|
+
/** Links external system entities to DevRev entities. */
|
|
36
|
+
export interface SyncMapperRecord {
|
|
37
|
+
id: DonV2;
|
|
38
|
+
external_ids: string[];
|
|
39
|
+
/**
|
|
40
|
+
* Labels values in `external_ids` with their usage context (e.g. a UUID for
|
|
41
|
+
* one API call, a login username for another). Not indexed: to look up by a
|
|
42
|
+
* secondary value it must also be present in `external_ids`.
|
|
43
|
+
*/
|
|
44
|
+
secondary_ids?: Record<string, string>;
|
|
45
|
+
targets: DonV2[];
|
|
46
|
+
status: SyncMapperRecordStatus;
|
|
47
|
+
/** Input file name(s) containing the object data; helps later debugging. */
|
|
48
|
+
input_files?: string[];
|
|
49
|
+
/**
|
|
50
|
+
* Prevents update loops: after writing the object to the external system,
|
|
51
|
+
* its modified_date is stored here. The Loader skips extracted updates whose
|
|
52
|
+
* modified_date is listed (the change originated in DevRev).
|
|
53
|
+
*/
|
|
54
|
+
external_versions?: SyncMapperRecordExternalVersion[];
|
|
55
|
+
/** Free-form storage; opaque to the platform. */
|
|
56
|
+
extra_data?: string;
|
|
57
|
+
}
|
|
58
|
+
export interface MappersGetByTargetIdParams {
|
|
59
|
+
sync_unit: DonV2;
|
|
60
|
+
target: DonV2;
|
|
61
|
+
}
|
|
62
|
+
export interface MappersGetByTargetIdResponse {
|
|
63
|
+
sync_mapper_record: SyncMapperRecord;
|
|
64
|
+
}
|
|
65
|
+
export interface MappersCreateParams {
|
|
66
|
+
sync_unit: DonV2;
|
|
67
|
+
external_ids: string[];
|
|
68
|
+
/**
|
|
69
|
+
* Labels values in `external_ids` with their usage context (e.g. a UUID for
|
|
70
|
+
* one API call, a login username for another). Not indexed: to look up by a
|
|
71
|
+
* secondary value it must also be present in `external_ids`.
|
|
72
|
+
*/
|
|
73
|
+
secondary_ids?: Record<string, string>;
|
|
74
|
+
targets: DonV2[];
|
|
75
|
+
status: SyncMapperRecordStatus;
|
|
76
|
+
/** Input file name(s) containing the object data; helps later debugging. */
|
|
77
|
+
input_files?: string[];
|
|
78
|
+
/**
|
|
79
|
+
* Prevents update loops: after writing the object to the external system,
|
|
80
|
+
* add its modified_date here. The Loader skips extracted updates whose
|
|
81
|
+
* modified_date is listed (the change originated in DevRev).
|
|
82
|
+
*/
|
|
83
|
+
external_versions?: SyncMapperRecordExternalVersion[];
|
|
84
|
+
/** Free-form storage; opaque to the platform. */
|
|
85
|
+
extra_data?: string;
|
|
86
|
+
}
|
|
87
|
+
export interface MappersCreateResponse {
|
|
88
|
+
sync_mapper_record: SyncMapperRecord;
|
|
89
|
+
}
|
|
90
|
+
export interface MappersUpdateParams {
|
|
91
|
+
id: DonV2;
|
|
92
|
+
sync_unit: DonV2;
|
|
93
|
+
external_ids: {
|
|
94
|
+
add: string[];
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Labels values in `external_ids` with their usage context (e.g. a UUID for
|
|
98
|
+
* one API call, a login username for another). Not indexed: to look up by a
|
|
99
|
+
* secondary value it must also be present in `external_ids`.
|
|
100
|
+
*/
|
|
101
|
+
secondary_ids?: Record<string, string>;
|
|
102
|
+
targets: {
|
|
103
|
+
add: DonV2[];
|
|
104
|
+
};
|
|
105
|
+
status: SyncMapperRecordStatus;
|
|
106
|
+
/** Input file name(s) containing the object data; helps later debugging. */
|
|
107
|
+
input_files?: {
|
|
108
|
+
add: string[];
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Prevents update loops: after writing the object to the external system,
|
|
112
|
+
* add its modified_date here. The Loader skips extracted updates whose
|
|
113
|
+
* modified_date is listed (the change originated in DevRev).
|
|
114
|
+
*/
|
|
115
|
+
external_versions?: {
|
|
116
|
+
add: SyncMapperRecordExternalVersion[];
|
|
117
|
+
};
|
|
118
|
+
/** Free-form storage; opaque to the platform. */
|
|
119
|
+
extra_data?: string;
|
|
120
|
+
}
|
|
121
|
+
export interface MappersUpdateResponse {
|
|
122
|
+
sync_mapper_record: SyncMapperRecord;
|
|
123
|
+
}
|
|
124
|
+
export declare enum SyncMapperRecordStatus {
|
|
125
|
+
/** The mapping is active and operational (default) */
|
|
126
|
+
OPERATIONAL = "operational",
|
|
127
|
+
/** The mapping was filtered out by user filter settings */
|
|
128
|
+
FILTERED = "filtered",
|
|
129
|
+
/** Ignore the external object in sync; prevents create/update in DevRev. */
|
|
130
|
+
IGNORED = "ignored"
|
|
131
|
+
}
|
|
132
|
+
/** Marks external changes as DevRev-originated to prevent update loops. */
|
|
133
|
+
export interface SyncMapperRecordExternalVersion {
|
|
134
|
+
/** Sync recipe version at the time the external change was written */
|
|
135
|
+
recipe_version: number;
|
|
136
|
+
/** External system modified timestamp (ISO 8601 string) used for loop detection */
|
|
137
|
+
modified_date: string;
|
|
138
|
+
}
|
|
139
|
+
export interface MappersGetByExternalIdParams {
|
|
140
|
+
sync_unit: DonV2;
|
|
141
|
+
external_id: string;
|
|
142
|
+
target_type: SyncMapperRecordTargetType;
|
|
143
|
+
}
|
|
144
|
+
export declare enum SyncMapperRecordTargetType {
|
|
145
|
+
ACCESS_CONTROL_ENTRY = "access_control_entry",
|
|
146
|
+
ACCOUNT = "account",
|
|
147
|
+
AIRDROP_AUTHORIZATION_POLICY = "airdrop_authorization_policy",
|
|
148
|
+
AIRDROP_FIELD_AUTHORIZATION_POLICY = "airdrop_field_authorization_policy",
|
|
149
|
+
AIRDROP_PLATFORM_GROUP = "airdrop_platform_group",
|
|
150
|
+
ARTICLE = "article",
|
|
151
|
+
ARTIFACT = "artifact",
|
|
152
|
+
CHAT = "chat",
|
|
153
|
+
CONVERSATION = "conversation",
|
|
154
|
+
CUSTOM_OBJECT = "custom_object",
|
|
155
|
+
DIRECTORY = "directory",
|
|
156
|
+
GROUP = "group",
|
|
157
|
+
INCIDENT = "incident",
|
|
158
|
+
LINK = "link",
|
|
159
|
+
MEETING = "meeting",
|
|
160
|
+
OBJECT_MEMBER = "object_member",
|
|
161
|
+
PART = "part",
|
|
162
|
+
REV_ORG = "rev_org",
|
|
163
|
+
ROLE = "role",
|
|
164
|
+
ROLE_SET = "role_set",
|
|
165
|
+
TAG = "tag",
|
|
166
|
+
TIMELINE_COMMENT = "timeline_comment",
|
|
167
|
+
USER = "user",
|
|
168
|
+
WORK = "work"
|
|
169
|
+
}
|
|
170
|
+
export interface MappersGetByExternalIdResponse {
|
|
171
|
+
sync_mapper_record: SyncMapperRecord;
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=mappers.interfaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mappers.interfaces.d.ts","sourceRoot":"","sources":["../../src/mappers/mappers.interfaces.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,24 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SyncMapperRecordTargetType = exports.SyncMapperRecordStatus = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Status of a sync mapper record indicating its operational state.
|
|
6
|
-
*/
|
|
7
4
|
var SyncMapperRecordStatus;
|
|
8
5
|
(function (SyncMapperRecordStatus) {
|
|
9
6
|
/** The mapping is active and operational (default) */
|
|
10
7
|
SyncMapperRecordStatus["OPERATIONAL"] = "operational";
|
|
11
8
|
/** The mapping was filtered out by user filter settings */
|
|
12
9
|
SyncMapperRecordStatus["FILTERED"] = "filtered";
|
|
13
|
-
/**
|
|
14
|
-
* The external object should be ignored in sync operations.
|
|
15
|
-
* Use to prevent objects from being created or updated in DevRev.
|
|
16
|
-
*/
|
|
10
|
+
/** Ignore the external object in sync; prevents create/update in DevRev. */
|
|
17
11
|
SyncMapperRecordStatus["IGNORED"] = "ignored";
|
|
18
12
|
})(SyncMapperRecordStatus || (exports.SyncMapperRecordStatus = SyncMapperRecordStatus = {}));
|
|
19
|
-
/**
|
|
20
|
-
* Types of DevRev entities that can be targets in sync mapper records.
|
|
21
|
-
*/
|
|
22
13
|
var SyncMapperRecordTargetType;
|
|
23
14
|
(function (SyncMapperRecordTargetType) {
|
|
24
15
|
SyncMapperRecordTargetType["ACCESS_CONTROL_ENTRY"] = "access_control_entry";
|
package/dist/mappers/mappers.js
CHANGED
|
@@ -1,83 +1,69 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Mappers = void 0;
|
|
4
|
-
const
|
|
4
|
+
const client_1 = require("../http/client");
|
|
5
|
+
const errors_1 = require("../http/errors");
|
|
5
6
|
/**
|
|
6
7
|
* Manages sync mapper records that link external system items to DevRev items.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
8
|
+
* Lookups resolve to `null` when no record exists; every other failure rejects
|
|
9
|
+
* with an {@link AirSyncHttpError}.
|
|
9
10
|
*/
|
|
10
11
|
class Mappers {
|
|
11
12
|
constructor({ event }) {
|
|
12
13
|
this.devrevApiEndpoint = event.execution_metadata.devrev_endpoint;
|
|
13
14
|
this.devrevApiToken = event.context.secrets.service_account_token;
|
|
14
15
|
}
|
|
15
|
-
/**
|
|
16
|
-
* Retrieves a sync mapper record by DevRev ID.
|
|
17
|
-
*
|
|
18
|
-
* Used to find the mapping when you know the DevRev ID and want to find the external system ID.
|
|
19
|
-
*
|
|
20
|
-
* @param params - Query parameters of type MappersGetByTargetIdParams
|
|
21
|
-
* @returns Promise with response data containing the sync mapper record
|
|
22
|
-
*/
|
|
23
16
|
async getByTargetId(params) {
|
|
24
17
|
const { sync_unit, target } = params;
|
|
25
|
-
return
|
|
18
|
+
return this.lookup(async () => client_1.axiosClient.get(`${this.devrevApiEndpoint}/internal/airdrop.sync-mapper-record.get-by-target`, {
|
|
26
19
|
headers: {
|
|
27
20
|
Authorization: this.devrevApiToken,
|
|
28
21
|
},
|
|
29
22
|
params: { sync_unit, target },
|
|
30
|
-
});
|
|
23
|
+
}));
|
|
31
24
|
}
|
|
32
|
-
/**
|
|
33
|
-
* Retrieves a sync mapper record by external system ID.
|
|
34
|
-
*
|
|
35
|
-
* Used to find the mapping when you know the external system ID and want to find the DevRev ID.
|
|
36
|
-
*
|
|
37
|
-
* @param params - Query parameters of type MappersGetByExternalIdParams
|
|
38
|
-
* @returns Promise with response data containing the sync mapper record
|
|
39
|
-
*/
|
|
40
25
|
async getByExternalId(params) {
|
|
41
26
|
const { sync_unit, external_id, target_type } = params;
|
|
42
|
-
return
|
|
27
|
+
return this.lookup(async () => client_1.axiosClient.get(`${this.devrevApiEndpoint}/internal/airdrop.sync-mapper-record.get-by-external-id`, {
|
|
43
28
|
headers: {
|
|
44
29
|
Authorization: this.devrevApiToken,
|
|
45
30
|
},
|
|
46
31
|
params: { sync_unit, external_id, target_type },
|
|
47
|
-
});
|
|
32
|
+
}));
|
|
48
33
|
}
|
|
49
|
-
/**
|
|
50
|
-
* Creates a new sync mapper record to establish a relationship between external system
|
|
51
|
-
* entities and DevRev entities.
|
|
52
|
-
*
|
|
53
|
-
* This is called after importing an item from external system to DevRev to record
|
|
54
|
-
* the mapping for future synchronization operations.
|
|
55
|
-
*
|
|
56
|
-
* @param params - Creation parameters of type MappersCreateParams
|
|
57
|
-
* @returns Promise with response data containing the created sync mapper record
|
|
58
|
-
*/
|
|
34
|
+
/** Called after importing an item to DevRev to record the mapping for future syncs. */
|
|
59
35
|
async create(params) {
|
|
60
|
-
return
|
|
36
|
+
return this.call(async () => client_1.axiosClient.post(`${this.devrevApiEndpoint}/internal/airdrop.sync-mapper-record.create`, params, {
|
|
61
37
|
headers: {
|
|
62
38
|
Authorization: this.devrevApiToken,
|
|
63
39
|
},
|
|
64
|
-
});
|
|
40
|
+
}));
|
|
65
41
|
}
|
|
66
|
-
/**
|
|
67
|
-
* Updates an existing sync mapper record.
|
|
68
|
-
*
|
|
69
|
-
* Used to modify existing mappings when external system entities change or when
|
|
70
|
-
* additional DevRev entities need to be associated.
|
|
71
|
-
*
|
|
72
|
-
* @param params - Update parameters of type MappersUpdateParams
|
|
73
|
-
* @returns Promise with response data containing the updated sync mapper record
|
|
74
|
-
*/
|
|
75
42
|
async update(params) {
|
|
76
|
-
return
|
|
43
|
+
return this.call(async () => client_1.axiosClient.post(`${this.devrevApiEndpoint}/internal/airdrop.sync-mapper-record.update`, params, {
|
|
77
44
|
headers: {
|
|
78
45
|
Authorization: this.devrevApiToken,
|
|
79
46
|
},
|
|
80
|
-
});
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
async call(request) {
|
|
50
|
+
try {
|
|
51
|
+
return (await request()).data;
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
throw (0, errors_1.toAirSyncHttpError)(error);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async lookup(request) {
|
|
58
|
+
try {
|
|
59
|
+
return (await request()).data;
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
if ((0, errors_1.isNotFound)(error)) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
throw (0, errors_1.toAirSyncHttpError)(error);
|
|
66
|
+
}
|
|
81
67
|
}
|
|
82
68
|
}
|
|
83
69
|
exports.Mappers = Mappers;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Mappers } from '../../mappers/mappers';
|
|
2
|
+
import { AirSyncEvent } from '../../types/extraction';
|
|
3
|
+
/**
|
|
4
|
+
* Shared state/behavior for both sync modes; owns the `emit` control-protocol
|
|
5
|
+
* flow as a template method with mode-specific hooks.
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class BaseAdapter<ConnectorState> {
|
|
8
|
+
readonly event: AirSyncEvent;
|
|
9
|
+
private _hasWorkerEmitted;
|
|
10
|
+
private _isTimeout;
|
|
11
|
+
private resolveTimeoutSignal;
|
|
12
|
+
private _mappers;
|
|
13
|
+
/** Sync mapper records for this event's sync unit, in both extraction and loading. */
|
|
14
|
+
get mappers(): Mappers;
|
|
15
|
+
/** Set once the soft timeout fires; the task should wrap up and return. */
|
|
16
|
+
get isTimeout(): boolean;
|
|
17
|
+
/** Connector-owned state exposed to snap-in code. */
|
|
18
|
+
get state(): ConnectorState;
|
|
19
|
+
set state(value: ConnectorState);
|
|
20
|
+
get extractionScope(): import("../../types/workers").ExtractionScope;
|
|
21
|
+
/**
|
|
22
|
+
* Persists connector and SDK state right now. State is saved on every emit
|
|
23
|
+
* anyway; call this only to record intent before an external write that
|
|
24
|
+
* must not be repeated. Throws if the save fails.
|
|
25
|
+
*/
|
|
26
|
+
postState(): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Uploads connector-owned data (e.g. state too large to keep inline) as a
|
|
29
|
+
* gzipped JSONL artifact. Unlike repo uploads it is not reported in the
|
|
30
|
+
* emitted event. Throws on failure.
|
|
31
|
+
*/
|
|
32
|
+
uploadArtifact(itemType: string, data: object[]): Promise<{
|
|
33
|
+
id: string;
|
|
34
|
+
}>;
|
|
35
|
+
/** Downloads an artifact written by {@link uploadArtifact}. Throws on failure. */
|
|
36
|
+
downloadArtifact<T = unknown>(artifactId: string): Promise<T[]>;
|
|
37
|
+
private send;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=base-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-adapter.d.ts","sourceRoot":"","sources":["../../../src/multithreading/adapters/base-adapter.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAKhD,OAAO,EACL,YAAY,EAIb,MAAM,wBAAwB,CAAC;AAYhC;;;GAGG;AACH,8BAAsB,WAAW,CAAC,cAAc;IAC9C,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAI7B,OAAO,CAAC,iBAAiB,CAAkB;IAC3C,OAAO,CAAC,UAAU,CAAkB;IACpC,OAAO,CAAC,oBAAoB,CAAc;IAU1C,OAAO,CAAC,QAAQ,CAAU;IAsB1B,sFAAsF;IACtF,IAAI,OAAO,IAAI,OAAO,CAErB;IAOD,2EAA2E;IAC3E,IAAI,SAAS,IAAI,OAAO,CAEvB;IAUD,qDAAqD;IACrD,IAAI,KAAK,IAAI,cAAc,CAE1B;IAED,IAAI,KAAK,CAAC,KAAK,EAAE,cAAc,EAE9B;IAOD,IAAI,eAAe,kDAElB;IAED;;;;OAIG;IACG,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAIhC;;;;OAIG;IACG,cAAc,CAClB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EAAE,GACb,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IAY1B,kFAAkF;IAC5E,gBAAgB,CAAC,CAAC,GAAG,OAAO,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC;YAmIvD,IAAI;CAmCnB"}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseAdapter = void 0;
|
|
4
|
+
const node_worker_threads_1 = require("node:worker_threads");
|
|
5
|
+
const constants_1 = require("../../common/constants");
|
|
6
|
+
const errors_1 = require("../../http/errors");
|
|
7
|
+
const logger_1 = require("../../logger/logger");
|
|
8
|
+
const mappers_1 = require("../../mappers/mappers");
|
|
9
|
+
const errors_2 = require("../../types/errors");
|
|
10
|
+
const workers_1 = require("../../types/workers");
|
|
11
|
+
const uploader_1 = require("../../uploader/uploader");
|
|
12
|
+
const emit_1 = require("../emit");
|
|
13
|
+
const spawn_helpers_1 = require("../spawn/spawn.helpers");
|
|
14
|
+
/**
|
|
15
|
+
* Shared state/behavior for both sync modes; owns the `emit` control-protocol
|
|
16
|
+
* flow as a template method with mode-specific hooks.
|
|
17
|
+
*/
|
|
18
|
+
class BaseAdapter {
|
|
19
|
+
/** @internal */
|
|
20
|
+
constructor({ event, adapterState, options, }) {
|
|
21
|
+
this._hasWorkerEmitted = false;
|
|
22
|
+
this._isTimeout = false;
|
|
23
|
+
/** @internal */
|
|
24
|
+
this.timeoutSignal = new Promise((resolve) => {
|
|
25
|
+
this.resolveTimeoutSignal = resolve;
|
|
26
|
+
});
|
|
27
|
+
this.event = event;
|
|
28
|
+
this.options = options;
|
|
29
|
+
this.adapterState = adapterState;
|
|
30
|
+
this.uploader = new uploader_1.Uploader({
|
|
31
|
+
event,
|
|
32
|
+
options,
|
|
33
|
+
});
|
|
34
|
+
this._mappers = new mappers_1.Mappers({ event });
|
|
35
|
+
}
|
|
36
|
+
/** Sync mapper records for this event's sync unit, in both extraction and loading. */
|
|
37
|
+
get mappers() {
|
|
38
|
+
return this._mappers;
|
|
39
|
+
}
|
|
40
|
+
/** @internal */
|
|
41
|
+
get hasWorkerEmitted() {
|
|
42
|
+
return this._hasWorkerEmitted;
|
|
43
|
+
}
|
|
44
|
+
/** Set once the soft timeout fires; the task should wrap up and return. */
|
|
45
|
+
get isTimeout() {
|
|
46
|
+
return this._isTimeout;
|
|
47
|
+
}
|
|
48
|
+
/** @internal */
|
|
49
|
+
set isTimeout(value) {
|
|
50
|
+
this._isTimeout = value;
|
|
51
|
+
if (value) {
|
|
52
|
+
this.resolveTimeoutSignal();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/** Connector-owned state exposed to snap-in code. */
|
|
56
|
+
get state() {
|
|
57
|
+
return this.adapterState.state;
|
|
58
|
+
}
|
|
59
|
+
set state(value) {
|
|
60
|
+
this.adapterState.state = value;
|
|
61
|
+
}
|
|
62
|
+
/** @internal */
|
|
63
|
+
get sdkState() {
|
|
64
|
+
return this.adapterState.sdkState;
|
|
65
|
+
}
|
|
66
|
+
get extractionScope() {
|
|
67
|
+
return this.adapterState.extractionScope;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Persists connector and SDK state right now. State is saved on every emit
|
|
71
|
+
* anyway; call this only to record intent before an external write that
|
|
72
|
+
* must not be repeated. Throws if the save fails.
|
|
73
|
+
*/
|
|
74
|
+
async postState() {
|
|
75
|
+
await this.adapterState.postState();
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Uploads connector-owned data (e.g. state too large to keep inline) as a
|
|
79
|
+
* gzipped JSONL artifact. Unlike repo uploads it is not reported in the
|
|
80
|
+
* emitted event. Throws on failure.
|
|
81
|
+
*/
|
|
82
|
+
async uploadArtifact(itemType, data) {
|
|
83
|
+
var _a;
|
|
84
|
+
const { artifact, error } = await this.uploader.upload(itemType, data);
|
|
85
|
+
if (error || !artifact) {
|
|
86
|
+
throw new errors_1.AirSyncHttpError(`Failed to upload artifact of type ${itemType}. ${(_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : 'No artifact returned.'}`);
|
|
87
|
+
}
|
|
88
|
+
return { id: artifact.id };
|
|
89
|
+
}
|
|
90
|
+
/** Downloads an artifact written by {@link uploadArtifact}. Throws on failure. */
|
|
91
|
+
async downloadArtifact(artifactId) {
|
|
92
|
+
const { response, error } = await this.uploader.getJsonObjectByArtifactId({
|
|
93
|
+
artifactId,
|
|
94
|
+
isGzipped: true,
|
|
95
|
+
});
|
|
96
|
+
if (error !== undefined || response === undefined) {
|
|
97
|
+
throw error instanceof errors_1.AirSyncHttpError
|
|
98
|
+
? error
|
|
99
|
+
: new errors_1.AirSyncHttpError(`Failed to download artifact ${artifactId}. ${(0, logger_1.serializeError)(error)}`);
|
|
100
|
+
}
|
|
101
|
+
return (Array.isArray(response) ? response : [response]);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* @internal
|
|
105
|
+
* Mode-specific worker metadata merged into the emitted event. The library
|
|
106
|
+
* version and state-date range are added centrally in `emit`, so subclasses
|
|
107
|
+
* only contribute their own statistics.
|
|
108
|
+
*/
|
|
109
|
+
buildWorkerMetadata(
|
|
110
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
111
|
+
newEventType) {
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
/** @internal Runs before a failure is reported via `emitError`. */
|
|
115
|
+
beforeErrorEmit() { }
|
|
116
|
+
/**
|
|
117
|
+
* Maps a {@link TaskResult} to the phase-appropriate platform event and emits
|
|
118
|
+
* it exactly once. Invoked by the worker driver, not by connectors —
|
|
119
|
+
* connectors signal outcomes by returning a `TaskResult`, never by emitting.
|
|
120
|
+
*
|
|
121
|
+
* @internal
|
|
122
|
+
*/
|
|
123
|
+
async emitFromResult(result) {
|
|
124
|
+
const { eventType, illegal } = (0, spawn_helpers_1.getEventTypeForResult)(this.event.payload.event_type, result.status);
|
|
125
|
+
const data = {};
|
|
126
|
+
if (result.status === 'delay') {
|
|
127
|
+
data.delay = result.delaySeconds;
|
|
128
|
+
}
|
|
129
|
+
else if (result.status === 'error') {
|
|
130
|
+
data.error = result.error;
|
|
131
|
+
}
|
|
132
|
+
else if (illegal) {
|
|
133
|
+
data.error = {
|
|
134
|
+
message: `Worker returned status '${result.status}' for a non-resumable phase (${this.event.payload.event_type}), which is not allowed. Emitting an error event instead.`,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
await this.emit(eventType, data);
|
|
138
|
+
}
|
|
139
|
+
/** @internal */
|
|
140
|
+
async emit(newEventType, data) {
|
|
141
|
+
if (this._hasWorkerEmitted) {
|
|
142
|
+
console.warn(`Trying to emit event with event type: ${newEventType}. Ignoring emit request because it has already been emitted.`);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
try {
|
|
146
|
+
await this.beforeEmit(newEventType);
|
|
147
|
+
// Save state on every emit, except for start and delete events
|
|
148
|
+
if (!constants_1.STATELESS_EVENT_TYPES.includes(this.event.payload.event_type)) {
|
|
149
|
+
console.log(`Saving state before emitting event with event type: ${newEventType}.`);
|
|
150
|
+
await this.adapterState.postState();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
console.error('Error while preparing event for emission.', (0, logger_1.serializeError)(error));
|
|
155
|
+
await this.emitError(error);
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
await this.send(newEventType, data);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Emits the phase error for a failed task or pre-emit step. Skips the
|
|
162
|
+
* pre-emit flush and state save, so a failed batch isn't retried; artifacts
|
|
163
|
+
* uploaded before the failure are still reported.
|
|
164
|
+
*
|
|
165
|
+
* @internal
|
|
166
|
+
*/
|
|
167
|
+
async emitError(error) {
|
|
168
|
+
if (this._hasWorkerEmitted) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
this.beforeErrorEmit();
|
|
172
|
+
const { eventType } = (0, spawn_helpers_1.getEventTypeForResult)(this.event.payload.event_type, 'error');
|
|
173
|
+
await this.send(eventType, { error: { message: (0, logger_1.serializeError)(error) } });
|
|
174
|
+
}
|
|
175
|
+
async send(newEventType, data) {
|
|
176
|
+
try {
|
|
177
|
+
if (data === null || data === void 0 ? void 0 : data.error) {
|
|
178
|
+
data.error = toWireError(data.error);
|
|
179
|
+
}
|
|
180
|
+
await (0, emit_1.emit)({
|
|
181
|
+
eventType: newEventType,
|
|
182
|
+
event: this.event,
|
|
183
|
+
data: Object.assign(Object.assign({}, data), this.buildEmitPayload(newEventType)),
|
|
184
|
+
worker_metadata: this.buildWorkerMetadata(newEventType),
|
|
185
|
+
});
|
|
186
|
+
const message = {
|
|
187
|
+
subject: workers_1.WorkerMessageSubject.WorkerMessageEmitted,
|
|
188
|
+
payload: { eventType: newEventType },
|
|
189
|
+
};
|
|
190
|
+
this.afterEmit(newEventType);
|
|
191
|
+
node_worker_threads_1.parentPort === null || node_worker_threads_1.parentPort === void 0 ? void 0 : node_worker_threads_1.parentPort.postMessage(message);
|
|
192
|
+
this._hasWorkerEmitted = true;
|
|
193
|
+
}
|
|
194
|
+
catch (error) {
|
|
195
|
+
console.error(`Error while emitting event with event type: ${newEventType}.`, (0, logger_1.serializeError)(error));
|
|
196
|
+
node_worker_threads_1.parentPort === null || node_worker_threads_1.parentPort === void 0 ? void 0 : node_worker_threads_1.parentPort.postMessage(workers_1.WorkerMessageSubject.WorkerMessageExit);
|
|
197
|
+
this._hasWorkerEmitted = true;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
exports.BaseAdapter = BaseAdapter;
|
|
202
|
+
/**
|
|
203
|
+
* The platform matches error codes against the whole message, so a coded
|
|
204
|
+
* error is sent as just the code and its details only go to the logs.
|
|
205
|
+
*/
|
|
206
|
+
function toWireError({ message, code }) {
|
|
207
|
+
if (!code) {
|
|
208
|
+
return { message: (0, logger_1.truncateMessage)(message) };
|
|
209
|
+
}
|
|
210
|
+
console.error(`Reporting ${code}: ${message}`);
|
|
211
|
+
return { message: (0, errors_2.formatErrorCode)(code) };
|
|
212
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Repo } from '../../repo/repo';
|
|
2
|
+
import { NormalizedAttachment, RepoInterface } from '../../repo/repo.interfaces';
|
|
3
|
+
import { ExternalSystemAttachmentProcessors, ExternalSystemAttachmentStreamingFunction, ItemTypeCount, ProcessAttachmentReturnType } from '../../types/extraction';
|
|
4
|
+
import { TaskResult } from '../../types/workers';
|
|
5
|
+
import { Artifact } from '../../uploader/uploader.interfaces';
|
|
6
|
+
import { BaseAdapter } from './base-adapter';
|
|
7
|
+
/** Adapter passed to extraction tasks (repos, artifacts, attachment streaming). @public */
|
|
8
|
+
export declare class ExtractionAdapter<ConnectorState> extends BaseAdapter<ConnectorState> {
|
|
9
|
+
private _artifacts;
|
|
10
|
+
private _preExtractionItemCounts?;
|
|
11
|
+
private repos;
|
|
12
|
+
private lastExtractedItemType?;
|
|
13
|
+
private currentEventDataLength;
|
|
14
|
+
/** Defaults to true if the scope is empty or the item type is not listed. */
|
|
15
|
+
shouldExtract(itemType: string): boolean;
|
|
16
|
+
initializeRepos(repos: RepoInterface[]): void;
|
|
17
|
+
private createRepo;
|
|
18
|
+
/**
|
|
19
|
+
* SSOR attachments created outside the attachments phase are held in state
|
|
20
|
+
* and reported with ATTACHMENT_EXTRACTION_DONE instead of the current event.
|
|
21
|
+
*/
|
|
22
|
+
private isDeferredRepo;
|
|
23
|
+
private isAttachmentsPhase;
|
|
24
|
+
private getOrCreateSsorRepo;
|
|
25
|
+
getRepo(itemType: string): Repo | undefined;
|
|
26
|
+
/** Artifacts uploaded so far that the next emit will report. */
|
|
27
|
+
get artifacts(): readonly Artifact[];
|
|
28
|
+
private addArtifacts;
|
|
29
|
+
/**
|
|
30
|
+
* Per-record-type counts for sync-duration estimation. Set during the
|
|
31
|
+
* metadata phase; the SDK attaches them to the metadata-done event.
|
|
32
|
+
*/
|
|
33
|
+
get preExtractionItemCounts(): ItemTypeCount[] | undefined;
|
|
34
|
+
set preExtractionItemCounts(counts: ItemTypeCount[] | undefined);
|
|
35
|
+
private toRfc3339Timestamp;
|
|
36
|
+
private uploadAllRepos;
|
|
37
|
+
/**
|
|
38
|
+
* Streams one attachment into DevRev. Usable in any extraction phase; SSOR
|
|
39
|
+
* records created outside the attachments phase are reported with
|
|
40
|
+
* ATTACHMENT_EXTRACTION_DONE.
|
|
41
|
+
*/
|
|
42
|
+
processAttachment(attachment: NormalizedAttachment, stream: ExternalSystemAttachmentStreamingFunction): Promise<ProcessAttachmentReturnType>;
|
|
43
|
+
streamAttachments<NewBatch>({ stream, processors, batchSize, }: {
|
|
44
|
+
stream: ExternalSystemAttachmentStreamingFunction;
|
|
45
|
+
processors?: ExternalSystemAttachmentProcessors<ConnectorState, NormalizedAttachment[], NewBatch>;
|
|
46
|
+
batchSize?: number;
|
|
47
|
+
}): Promise<TaskResult>;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=extraction-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extraction-adapter.d.ts","sourceRoot":"","sources":["../../../src/multithreading/adapters/extraction-adapter.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EACL,oBAAoB,EACpB,aAAa,EACd,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAIL,kCAAkC,EAClC,yCAAyC,EAEzC,aAAa,EACb,2BAA2B,EAE5B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAkB,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjE,OAAO,EAAE,QAAQ,EAAkB,MAAM,oCAAoC,CAAC;AAE9E,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,2FAA2F;AAC3F,qBAAa,iBAAiB,CAC5B,cAAc,CACd,SAAQ,WAAW,CAAC,cAAc,CAAC;IACnC,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,wBAAwB,CAAC,CAAkB;IACnD,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,qBAAqB,CAAC,CAAS;IACvC,OAAO,CAAC,sBAAsB,CAAa;IAY3C,6EAA6E;IAC7E,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAOxC,eAAe,CAAC,KAAK,EAAE,aAAa,EAAE;IAatC,OAAO,CAAC,UAAU;IAoDlB;;;OAGG;IACH,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,kBAAkB;IAQ1B,OAAO,CAAC,mBAAmB;IAS3B,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;IAW3C,gEAAgE;IAChE,IAAI,SAAS,IAAI,SAAS,QAAQ,EAAE,CAEnC;IAED,OAAO,CAAC,YAAY;IAMpB;;;OAGG;IACH,IAAI,uBAAuB,IAAI,aAAa,EAAE,GAAG,SAAS,CAEzD;IAED,IAAI,uBAAuB,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,SAAS,EAE9D;IA6HD,OAAO,CAAC,kBAAkB;YAaZ,cAAc;IAmB5B;;;;OAIG;IACG,iBAAiB,CACrB,UAAU,EAAE,oBAAoB,EAChC,MAAM,EAAE,yCAAyC,GAChD,OAAO,CAAC,2BAA2B,CAAC;IAwGjC,iBAAiB,CAAC,QAAQ,EAAE,EAChC,MAAM,EACN,UAAU,EACV,SAAa,GACd,EAAE;QACD,MAAM,EAAE,yCAAyC,CAAC;QAClD,UAAU,CAAC,EAAE,kCAAkC,CAC7C,cAAc,EACd,oBAAoB,EAAE,EACtB,QAAQ,CACT,CAAC;QACF,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,UAAU,CAAC;CAsHxB"}
|