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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (198) hide show
  1. package/README.md +5 -11
  2. package/dist/attachments-streaming/attachments-streaming-pool.d.ts +2 -10
  3. package/dist/attachments-streaming/attachments-streaming-pool.d.ts.map +1 -1
  4. package/dist/attachments-streaming/attachments-streaming-pool.interfaces.d.ts +2 -7
  5. package/dist/attachments-streaming/attachments-streaming-pool.interfaces.d.ts.map +1 -1
  6. package/dist/attachments-streaming/attachments-streaming-pool.js +15 -43
  7. package/dist/common/constants.d.ts +1 -0
  8. package/dist/common/constants.d.ts.map +1 -1
  9. package/dist/common/constants.js +2 -1
  10. package/dist/common/helpers.d.ts +0 -14
  11. package/dist/common/helpers.d.ts.map +1 -1
  12. package/dist/common/helpers.js +0 -36
  13. package/dist/http/{axios-client-internal.d.ts → client.d.ts} +1 -1
  14. package/dist/http/client.d.ts.map +1 -0
  15. package/dist/index.d.ts +22 -11
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +46 -28
  18. package/dist/logger/logger.d.ts +14 -0
  19. package/dist/logger/logger.d.ts.map +1 -1
  20. package/dist/logger/logger.js +55 -8
  21. package/dist/mappers/mappers.d.ts +9 -10
  22. package/dist/mappers/mappers.d.ts.map +1 -1
  23. package/dist/mappers/{mappers.interface.d.ts → mappers.interfaces.d.ts} +5 -5
  24. package/dist/mappers/mappers.interfaces.d.ts.map +1 -0
  25. package/dist/mappers/{mappers.interface.js → mappers.interfaces.js} +3 -3
  26. package/dist/mappers/mappers.js +13 -9
  27. package/dist/multithreading/adapters/base-adapter.d.ts +23 -8
  28. package/dist/multithreading/adapters/base-adapter.d.ts.map +1 -1
  29. package/dist/multithreading/adapters/base-adapter.js +41 -8
  30. package/dist/multithreading/adapters/extraction-adapter.d.ts +8 -9
  31. package/dist/multithreading/adapters/extraction-adapter.d.ts.map +1 -1
  32. package/dist/multithreading/adapters/extraction-adapter.js +24 -26
  33. package/dist/multithreading/adapters/loading-adapter.d.ts +7 -7
  34. package/dist/multithreading/adapters/loading-adapter.d.ts.map +1 -1
  35. package/dist/multithreading/adapters/loading-adapter.js +53 -83
  36. package/dist/{common/control-protocol.d.ts → multithreading/emit.d.ts} +1 -1
  37. package/dist/multithreading/emit.d.ts.map +1 -0
  38. package/dist/{common/control-protocol.js → multithreading/emit.js} +3 -3
  39. package/dist/multithreading/process-task.d.ts.map +1 -1
  40. package/dist/multithreading/process-task.js +26 -9
  41. package/dist/multithreading/spawn/spawn.helpers.d.ts +23 -3
  42. package/dist/multithreading/spawn/spawn.helpers.d.ts.map +1 -1
  43. package/dist/multithreading/spawn/spawn.helpers.js +152 -2
  44. package/dist/multithreading/spawn/spawn.js +7 -7
  45. package/dist/multithreading/worker.js +1 -2
  46. package/dist/repo/repo.js +2 -2
  47. package/dist/state/base-state.d.ts +5 -5
  48. package/dist/state/base-state.d.ts.map +1 -1
  49. package/dist/state/base-state.js +7 -7
  50. package/dist/state/extraction-state.d.ts +9 -9
  51. package/dist/state/extraction-state.d.ts.map +1 -1
  52. package/dist/state/extraction-state.js +10 -10
  53. package/dist/state/install-initial-domain-mapping.d.ts.map +1 -0
  54. package/dist/{common → state}/install-initial-domain-mapping.js +4 -4
  55. package/dist/state/loading-state.d.ts +7 -8
  56. package/dist/state/loading-state.d.ts.map +1 -1
  57. package/dist/state/loading-state.js +6 -7
  58. package/dist/state/state.d.ts +4 -0
  59. package/dist/state/state.d.ts.map +1 -0
  60. package/dist/state/state.interfaces.d.ts +28 -18
  61. package/dist/state/state.interfaces.d.ts.map +1 -1
  62. package/dist/state/state.interfaces.js +13 -6
  63. package/dist/state/state.js +11 -0
  64. package/dist/{common → state}/time-value-resolver.d.ts +6 -7
  65. package/dist/state/time-value-resolver.d.ts.map +1 -0
  66. package/dist/{common → state}/time-value-resolver.js +9 -8
  67. package/dist/{common/test-utils.d.ts → testing/mock-event.d.ts} +1 -2
  68. package/dist/testing/mock-event.d.ts.map +1 -0
  69. package/dist/{common/test-utils.js → testing/mock-event.js} +14 -3
  70. package/dist/{mock-server → testing}/mock-server.d.ts +5 -0
  71. package/dist/testing/mock-server.d.ts.map +1 -0
  72. package/dist/testing/mock-server.interfaces.d.ts.map +1 -0
  73. package/dist/{mock-server → testing}/mock-server.js +6 -1
  74. package/dist/types/errors.d.ts +9 -0
  75. package/dist/types/errors.d.ts.map +1 -0
  76. package/dist/types/extraction.d.ts +70 -15
  77. package/dist/types/extraction.d.ts.map +1 -1
  78. package/dist/types/extraction.js +4 -6
  79. package/dist/types/loading.d.ts +1 -2
  80. package/dist/types/loading.d.ts.map +1 -1
  81. package/dist/types/loading.js +0 -1
  82. package/dist/types/workers.d.ts +66 -23
  83. package/dist/types/workers.d.ts.map +1 -1
  84. package/dist/uploader/uploader.d.ts +5 -4
  85. package/dist/uploader/uploader.d.ts.map +1 -1
  86. package/dist/uploader/uploader.interfaces.d.ts +1 -1
  87. package/dist/uploader/uploader.js +10 -10
  88. package/package.json +3 -3
  89. package/dist/airsync-sdk.d.ts +0 -2059
  90. package/dist/attachments-streaming/attachments-streaming-pool.test.d.ts +0 -2
  91. package/dist/attachments-streaming/attachments-streaming-pool.test.d.ts.map +0 -1
  92. package/dist/attachments-streaming/attachments-streaming-pool.test.js +0 -540
  93. package/dist/common/control-protocol.d.ts.map +0 -1
  94. package/dist/common/errors.d.ts +0 -6
  95. package/dist/common/errors.d.ts.map +0 -1
  96. package/dist/common/install-initial-domain-mapping.d.ts.map +0 -1
  97. package/dist/common/install-initial-domain-mapping.test.d.ts +0 -2
  98. package/dist/common/install-initial-domain-mapping.test.d.ts.map +0 -1
  99. package/dist/common/install-initial-domain-mapping.test.js +0 -211
  100. package/dist/common/test-utils.d.ts.map +0 -1
  101. package/dist/common/time-value-resolver.d.ts.map +0 -1
  102. package/dist/common/time-value-resolver.test.d.ts +0 -2
  103. package/dist/common/time-value-resolver.test.d.ts.map +0 -1
  104. package/dist/common/time-value-resolver.test.js +0 -268
  105. package/dist/http/axios-client-internal.d.ts.map +0 -1
  106. package/dist/http/axios-client-internal.test.d.ts +0 -2
  107. package/dist/http/axios-client-internal.test.d.ts.map +0 -1
  108. package/dist/http/axios-client-internal.test.js +0 -175
  109. package/dist/http/axios-client.d.ts +0 -27
  110. package/dist/http/axios-client.d.ts.map +0 -1
  111. package/dist/http/axios-client.js +0 -60
  112. package/dist/http/constants.d.ts +0 -4
  113. package/dist/http/constants.d.ts.map +0 -1
  114. package/dist/http/constants.js +0 -6
  115. package/dist/http/index.d.ts +0 -2
  116. package/dist/http/index.d.ts.map +0 -1
  117. package/dist/http/index.js +0 -17
  118. package/dist/logger/logger.constants.d.ts +0 -6
  119. package/dist/logger/logger.constants.d.ts.map +0 -1
  120. package/dist/logger/logger.constants.js +0 -13
  121. package/dist/logger/logger.context.d.ts +0 -58
  122. package/dist/logger/logger.context.d.ts.map +0 -1
  123. package/dist/logger/logger.context.js +0 -86
  124. package/dist/logger/logger.test.d.ts +0 -2
  125. package/dist/logger/logger.test.d.ts.map +0 -1
  126. package/dist/logger/logger.test.js +0 -537
  127. package/dist/mappers/mappers.interface.d.ts.map +0 -1
  128. package/dist/mappers/mappers.test.d.ts +0 -2
  129. package/dist/mappers/mappers.test.d.ts.map +0 -1
  130. package/dist/mappers/mappers.test.js +0 -105
  131. package/dist/mock-server/mock-server.d.ts.map +0 -1
  132. package/dist/mock-server/mock-server.interfaces.d.ts.map +0 -1
  133. package/dist/multithreading/adapters/base-adapter.emit.test.d.ts +0 -2
  134. package/dist/multithreading/adapters/base-adapter.emit.test.d.ts.map +0 -1
  135. package/dist/multithreading/adapters/base-adapter.emit.test.js +0 -403
  136. package/dist/multithreading/adapters/extraction-adapter.artifacts.test.d.ts +0 -2
  137. package/dist/multithreading/adapters/extraction-adapter.artifacts.test.d.ts.map +0 -1
  138. package/dist/multithreading/adapters/extraction-adapter.artifacts.test.js +0 -175
  139. package/dist/multithreading/adapters/extraction-adapter.test.d.ts +0 -2
  140. package/dist/multithreading/adapters/extraction-adapter.test.d.ts.map +0 -1
  141. package/dist/multithreading/adapters/extraction-adapter.test.js +0 -789
  142. package/dist/multithreading/adapters/loading-adapter.helpers.test.d.ts +0 -2
  143. package/dist/multithreading/adapters/loading-adapter.helpers.test.d.ts.map +0 -1
  144. package/dist/multithreading/adapters/loading-adapter.helpers.test.js +0 -514
  145. package/dist/multithreading/adapters/loading-adapter.test.d.ts +0 -2
  146. package/dist/multithreading/adapters/loading-adapter.test.d.ts.map +0 -1
  147. package/dist/multithreading/adapters/loading-adapter.test.js +0 -589
  148. package/dist/multithreading/adapters/serialization.test.d.ts +0 -2
  149. package/dist/multithreading/adapters/serialization.test.d.ts.map +0 -1
  150. package/dist/multithreading/adapters/serialization.test.js +0 -71
  151. package/dist/multithreading/create-worker.test.d.ts +0 -2
  152. package/dist/multithreading/create-worker.test.d.ts.map +0 -1
  153. package/dist/multithreading/create-worker.test.js +0 -108
  154. package/dist/multithreading/process-task.test.d.ts +0 -2
  155. package/dist/multithreading/process-task.test.d.ts.map +0 -1
  156. package/dist/multithreading/process-task.test.js +0 -146
  157. package/dist/multithreading/spawn/spawn.helpers.test.d.ts +0 -2
  158. package/dist/multithreading/spawn/spawn.helpers.test.d.ts.map +0 -1
  159. package/dist/multithreading/spawn/spawn.helpers.test.js +0 -293
  160. package/dist/multithreading/spawn/spawn.test.d.ts +0 -2
  161. package/dist/multithreading/spawn/spawn.test.d.ts.map +0 -1
  162. package/dist/multithreading/spawn/spawn.test.js +0 -232
  163. package/dist/repo/repo.test.d.ts +0 -2
  164. package/dist/repo/repo.test.d.ts.map +0 -1
  165. package/dist/repo/repo.test.js +0 -184
  166. package/dist/state/state.extract-window.test.d.ts +0 -2
  167. package/dist/state/state.extract-window.test.d.ts.map +0 -1
  168. package/dist/state/state.extract-window.test.js +0 -163
  169. package/dist/state/state.pending-boundaries.test.d.ts +0 -2
  170. package/dist/state/state.pending-boundaries.test.d.ts.map +0 -1
  171. package/dist/state/state.pending-boundaries.test.js +0 -189
  172. package/dist/state/state.post-state.test.d.ts +0 -2
  173. package/dist/state/state.post-state.test.d.ts.map +0 -1
  174. package/dist/state/state.post-state.test.js +0 -78
  175. package/dist/state/state.test.d.ts +0 -2
  176. package/dist/state/state.test.d.ts.map +0 -1
  177. package/dist/state/state.test.js +0 -271
  178. package/dist/state/state.time-value-resolution.test.d.ts +0 -2
  179. package/dist/state/state.time-value-resolution.test.d.ts.map +0 -1
  180. package/dist/state/state.time-value-resolution.test.js +0 -175
  181. package/dist/tsdoc-metadata.json +0 -11
  182. package/dist/types/extraction.test.d.ts +0 -2
  183. package/dist/types/extraction.test.d.ts.map +0 -1
  184. package/dist/types/extraction.test.js +0 -96
  185. package/dist/types/index.d.ts +0 -10
  186. package/dist/types/index.d.ts.map +0 -1
  187. package/dist/types/index.js +0 -21
  188. package/dist/uploader/uploader.helpers.test.d.ts +0 -2
  189. package/dist/uploader/uploader.helpers.test.d.ts.map +0 -1
  190. package/dist/uploader/uploader.helpers.test.js +0 -256
  191. package/dist/uploader/uploader.test.d.ts +0 -2
  192. package/dist/uploader/uploader.test.d.ts.map +0 -1
  193. package/dist/uploader/uploader.test.js +0 -601
  194. /package/dist/http/{axios-client-internal.js → client.js} +0 -0
  195. /package/dist/{common → state}/install-initial-domain-mapping.d.ts +0 -0
  196. /package/dist/{mock-server → testing}/mock-server.interfaces.d.ts +0 -0
  197. /package/dist/{mock-server → testing}/mock-server.interfaces.js +0 -0
  198. /package/dist/{common → types}/errors.js +0 -0
@@ -1,2059 +0,0 @@
1
- import axios from 'axios';
2
- import { AxiosError } from 'axios';
3
- import { AxiosInstance } from 'axios';
4
- import { AxiosResponse } from 'axios';
5
- import { InputData } from '@devrev/typescript-sdk/dist/snap-ins';
6
- import type { RawAxiosResponseHeaders } from 'axios';
7
- import { Worker as Worker_2 } from 'worker_threads';
8
-
9
- declare enum ActionType {
10
- CREATED = "created",
11
- UPDATED = "updated",
12
- SKIPPED = "skipped",
13
- DELETED = "deleted",
14
- FAILED = "failed"
15
- }
16
-
17
- export declare enum AirSyncDefaultItemTypes {
18
- EXTERNAL_DOMAIN_METADATA = "external_domain_metadata",
19
- ATTACHMENTS = "attachments",
20
- EXTERNAL_SYNC_UNITS = "external_sync_units"
21
- }
22
-
23
- /**
24
- * AirSyncEvent is an interface that defines the structure of the event that is sent to the external extractor from the AirSync platform.
25
- * It contains the context, payload, execution metadata, and input data as common snap-ins.
26
- */
27
- export declare interface AirSyncEvent {
28
- context: {
29
- secrets: {
30
- service_account_token: string;
31
- };
32
- snap_in_version_id: string;
33
- snap_in_id: string;
34
- };
35
- payload: AirSyncMessage;
36
- execution_metadata: {
37
- devrev_endpoint: string;
38
- };
39
- input_data: InputData;
40
- }
41
-
42
- /**
43
- * AirSyncMessage is an interface that defines the structure of the payload/message that is sent to the external extractor from the AirSync platform.
44
- */
45
- export declare interface AirSyncMessage {
46
- connection_data: ConnectionData;
47
- event_context: EventContext;
48
- event_type: EventType;
49
- event_data?: EventData;
50
- }
51
-
52
- /**
53
- * Artifact is an interface that defines the structure of an artifact. Artifact is a file that is generated by the extractor and uploaded to the AirSync platform.
54
- */
55
- export declare interface Artifact {
56
- id: string;
57
- item_type: string;
58
- item_count: number;
59
- }
60
-
61
- /**
62
- * ArtifactsPrepareResponse is an interface that defines the structure of the response from the prepare artifacts endpoint.
63
- */
64
- export declare interface ArtifactsPrepareResponse {
65
- url: string;
66
- id: string;
67
- form_data: {
68
- key: string;
69
- value: string;
70
- }[];
71
- }
72
-
73
- /**
74
- * ArtifactToUpload is an interface that defines the structure of the response from the get upload url endpoint.
75
- */
76
- declare interface ArtifactToUpload {
77
- upload_url: string;
78
- artifact_id: string;
79
- form_data: {
80
- key: string;
81
- value: string;
82
- }[];
83
- }
84
-
85
- /**
86
- * Attachments configuration for a record type.
87
- */
88
- declare interface Attachments {
89
- /** Whether attachments can be extracted */
90
- is_extractable?: boolean;
91
- /** Whether attachments can be loaded: that is, whether the connector supports creating it in the system */
92
- is_loadable?: boolean;
93
- }
94
-
95
- export { axios }
96
-
97
- export declare const axiosClient: AxiosInstance;
98
-
99
- declare interface AxiosErrorResponse {
100
- config: {
101
- method: string | undefined;
102
- params: any;
103
- url: string | undefined;
104
- };
105
- isAxiosError: boolean;
106
- isCorsOrNoNetworkError: boolean;
107
- response?: {
108
- data: unknown;
109
- headers: RawAxiosResponseHeaders;
110
- status: number;
111
- statusText: string;
112
- };
113
- code?: string;
114
- message?: string;
115
- }
116
-
117
- /**
118
- * BaseAdapter holds the state and behavior shared by both sync modes and owns
119
- * the `emit` control-protocol flow as a template method. Mode-specific adapters
120
- * (`ExtractionAdapter`, `LoadingAdapter`) implement the abstract hooks to inject
121
- * their own pre-emit work and event payload shaping.
122
- *
123
- * @typeParam ConnectorState - the connector-owned state shape
124
- * @typeParam StateClass - the mode's `BaseState` subclass
125
- */
126
- declare abstract class BaseAdapter<ConnectorState, StateClass extends BaseState<ConnectorState, BaseSdkState>> {
127
- readonly event: AirSyncEvent;
128
- readonly options?: WorkerAdapterOptions;
129
- isTimeout: boolean;
130
- hasWorkerEmitted: boolean;
131
- protected adapterState: StateClass;
132
- protected uploader: Uploader;
133
- constructor({ event, adapterState, options, }: {
134
- event: AirSyncEvent;
135
- adapterState: StateClass;
136
- options?: WorkerAdapterOptions;
137
- });
138
- get state(): ConnectorState;
139
- set state(value: ConnectorState);
140
- postState(): Promise<void>;
141
- /**
142
- * Pre-emit hook run before any state is persisted or the event is sent.
143
- * Extraction uploads pending repos and updates extraction boundaries here;
144
- * loading has nothing to do. Throwing aborts the emit (the caller signals
145
- * worker exit).
146
- */
147
- protected abstract beforeEmit(newEventType: ExtractorEventType | LoaderEventType): Promise<void>;
148
- /**
149
- * Builds the mode-specific extras merged into the emitted event payload
150
- * (extraction: artifacts; loading: reports + processed files).
151
- */
152
- protected abstract buildEmitPayload(newEventType: ExtractorEventType | LoaderEventType): EventData;
153
- /**
154
- * Post-emit hook run after the event has been sent successfully. Extraction
155
- * clears its accumulated artifacts here; loading has nothing to do.
156
- */
157
- protected abstract afterEmit(newEventType: ExtractorEventType | LoaderEventType): void;
158
- /**
159
- * Emits an event to the platform.
160
- *
161
- * @param newEventType - The event type to be emitted
162
- * @param data - The data to be sent with the event
163
- */
164
- emit(newEventType: ExtractorEventType | LoaderEventType, data?: EventData): Promise<void>;
165
- }
166
-
167
- /**
168
- * BaseSdkState holds SDK bookkeeping common to every sync mode.
169
- */
170
- declare interface BaseSdkState {
171
- snapInVersionId?: string;
172
- }
173
-
174
- /**
175
- * BaseState owns the state lifecycle shared by every sync mode: connector vs.
176
- * SDK state separation, fetch/init/post against the platform, the v1->v2
177
- * migration shim, and the snap-in-version-gated initial domain mapping install.
178
- *
179
- * Mode-specific subclasses (`ExtractionState`, `LoadingState`) narrow `sdkState`
180
- * to their own SDK state shape and add mode-specific setup in their factories.
181
- *
182
- * @typeParam ConnectorState - the connector-owned state shape
183
- * @typeParam SdkState - the SDK bookkeeping shape for this mode
184
- */
185
- declare abstract class BaseState<ConnectorState, SdkState extends BaseSdkState> {
186
- protected _connectorState: ConnectorState;
187
- protected _sdkState: SdkState;
188
- protected _extractionScope: ExtractionScope;
189
- protected readonly initialSdkState: SdkState;
190
- protected readonly event: AirSyncEvent;
191
- private workerUrl;
192
- private devrevToken;
193
- private syncUnitId;
194
- private requestId;
195
- constructor({ event, initialState }: StateInterface<ConnectorState>, initialSdkState: SdkState);
196
- /** Connector-owned state. This is what `adapter.state` exposes to snap-in code. */
197
- get state(): ConnectorState;
198
- set state(value: ConnectorState);
199
- /** SDK-internal bookkeeping state. Never exposed to connector code. */
200
- get sdkState(): SdkState;
201
- set sdkState(value: SdkState);
202
- get extractionScope(): ExtractionScope;
203
- /**
204
- * Installs the initial domain mapping when the snap-in version in state does
205
- * not match the version in the event context. Shared by all modes so that a
206
- * loading run still installs the mapping if extraction has not done so.
207
- */
208
- installInitialDomainMappingIfNeeded(initialDomainMapping?: InitialDomainMapping): Promise<void>;
209
- /**
210
- * Initializes the state for this adapter instance by fetching from API
211
- * or creating an initial state if none exists (404).
212
- *
213
- * Reads both the v2 `{ connectorState, sdkState }` envelope and a legacy flat
214
- * v1 blob (connector keys merged with SDK keys), migrating the latter on read.
215
- * Always persists the v2 envelope going forward.
216
- * @param initialState The initial connector state provided by the spawn function
217
- */
218
- init(initialState: ConnectorState): Promise<void>;
219
- /**
220
- * Normalizes a parsed on-disk state into the `{ connectorState, sdkState }`
221
- * envelope, migrating a legacy flat v1 blob if needed.
222
- *
223
- * - v2 envelope (`{ connectorState, sdkState }`): used as-is.
224
- * - v1 flat blob: SDK-owned keys (`V1_SDK_STATE_KEYS`) split into `sdkState`,
225
- * everything else becomes connector state.
226
- * - Malformed envelope (one side present, the other missing) fails loud.
227
- */
228
- private normalizeFetchedState;
229
- /**
230
- * Updates the state of the adapter by posting to API.
231
- * Persists the v2 `{ connectorState, sdkState }` envelope.
232
- * @param {object} state - The connector state to be updated
233
- */
234
- postState(state?: ConnectorState): Promise<void>;
235
- /**
236
- * Fetches the state of the adapter from API.
237
- * @return The raw state data from API
238
- */
239
- fetchState(): Promise<{
240
- state: string;
241
- objects?: string;
242
- }>;
243
- }
244
-
245
- /**
246
- * Collection constraints for fields that are collections of values.
247
- */
248
- export declare interface CollectionData {
249
- min_length?: number;
250
- max_length?: number;
251
- }
252
-
253
- /**
254
- * Conditional privilege data for authorization.
255
- */
256
- export declare interface ConditionalPrivilegeData {
257
- /** The possible record types or record type categories that can be targeted in conditional privilege. */
258
- type_keys: RecordTypeKey[];
259
- }
260
-
261
- /**
262
- * ConnectionData is an interface that defines the structure of the connection data that is sent to the external extractor from the AirSync platform.
263
- * It contains the organization ID, organization name, key, and key type.
264
- */
265
- export declare interface ConnectionData {
266
- org_id: string;
267
- org_name: string;
268
- key: string;
269
- key_type: string;
270
- }
271
-
272
- /**
273
- * Creates a mock AirSyncEvent for testing.
274
- *
275
- * @param mockServerUrl - Base URL for the mock server. Defaults to {@link MOCK_SERVER_DEFAULT_URL}.
276
- * The `callback_url`, `worker_data_url`, and `devrev_endpoint` fields are
277
- * derived from this value unless explicitly overridden.
278
- * @param overrides - Deep partial of AirSyncEvent. Any provided fields are
279
- * deep-merged on top of the defaults.
280
- */
281
- export declare function createMockEvent(mockServerUrl?: string, overrides?: DeepPartial<AirSyncEvent>): AirSyncEvent;
282
-
283
- /**
284
- * Custom link data for defining link types.
285
- */
286
- export declare interface CustomLinkData {
287
- /** The field that defines the link types in the system. */
288
- link_type_field: FieldKey;
289
- link_direction_names: Record<string, CustomLinkNames> | null;
290
- }
291
-
292
- /**
293
- * Custom link names for forward and backward directions.
294
- */
295
- export declare interface CustomLinkNames {
296
- /** The forward name of the link */
297
- forward_name: string;
298
- /** The backward name of the link */
299
- backward_name: string;
300
- }
301
-
302
- /**
303
- * Custom stage definition in a stage diagram.
304
- */
305
- export declare interface CustomStage {
306
- /** The state this stage belongs to. Must match the ones defined in the diagram 'states' field or be one of the default options: 'open', 'in_progress', 'closed'. */
307
- state?: StateKey;
308
- /** A list of stage names that this stage can transition to. */
309
- transitions_to?: StageKey[];
310
- }
311
-
312
- /**
313
- * Custom state definition in a stage diagram.
314
- */
315
- export declare interface CustomState {
316
- /** The human readable name of the custom state. */
317
- name: string;
318
- /** Denotes that this state is an end state. */
319
- is_end_state?: boolean;
320
- /** The sort order of the state. */
321
- ordinal?: number;
322
- }
323
-
324
- /**
325
- * Recursively makes all properties of T optional.
326
- */
327
- export declare type DeepPartial<T> = {
328
- [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
329
- };
330
-
331
- declare type DonV2 = string;
332
-
333
- /**
334
- * Enum field data containing possible values.
335
- */
336
- export declare interface EnumData {
337
- values: EnumValue[];
338
- }
339
-
340
- /**
341
- * Enum value definition.
342
- */
343
- export declare interface EnumValue {
344
- /** The enum value that actually occurs in the json data */
345
- key: EnumValueKey;
346
- /** The human readable name of the enum value */
347
- name?: string;
348
- description?: string;
349
- /** Deprecated enum values may still occur in the data, but should not be used in new data */
350
- is_deprecated?: boolean;
351
- }
352
-
353
- /** Key identifying an enum value in EnumValue.key or stage diagram stages map keys. */
354
- export declare type EnumValueKey = string;
355
-
356
- /**
357
- * ErrorRecord is an interface that defines the structure of an error record.
358
- */
359
- export declare interface ErrorRecord {
360
- message: string;
361
- }
362
-
363
- /**
364
- * EventContext is an interface that defines the structure of the event context that is sent to the external connector from AirSync.
365
- */
366
- export declare interface EventContext {
367
- callback_url: string;
368
- dev_oid: string;
369
- dev_org_id: string;
370
- dev_uid: string;
371
- event_type_adaas: string;
372
- external_sync_unit_id: string;
373
- external_sync_unit_name: string;
374
- external_system_id: string;
375
- external_system_name: string;
376
- external_system_type: string;
377
- /**
378
- * Resolved start timestamp of extraction (ISO 8601 format).
379
- * Automatically computed by the SDK from extraction_start_time and worker state.
380
- * This is the field developers should read to know when to start extracting from.
381
- */
382
- extract_from?: string;
383
- import_slug: string;
384
- initial_sync_scope?: InitialSyncScope;
385
- mode: string;
386
- request_id: string;
387
- request_id_adaas: string;
388
- run_id: string;
389
- sequence_version: string;
390
- snap_in_slug: string;
391
- snap_in_version_id: string;
392
- sync_tier: string;
393
- sync_unit: DonV2;
394
- sync_unit_id: string;
395
- worker_data_url: string;
396
- /**
397
- * Start time value for extraction, as sent by the platform.
398
- * The SDK resolves this into a concrete ISO 8601 timestamp on extract_from.
399
- */
400
- extraction_start_time?: TimeValue;
401
- /**
402
- * End time value for extraction, as sent by the platform.
403
- * The SDK resolves this into a concrete ISO 8601 timestamp on extract_to.
404
- */
405
- extraction_end_time?: TimeValue;
406
- /**
407
- * Resolved end timestamp of extraction (ISO 8601 format).
408
- * Automatically computed by the SDK from extraction_end_time and worker state.
409
- * This is the field developers should read to know when to stop extracting at.
410
- */
411
- extract_to?: string;
412
- }
413
-
414
- /**
415
- * EventData is an interface that defines the structure of the event data that is sent from the external extractor to the AirSync platform.
416
- */
417
- export declare interface EventData {
418
- error?: ErrorRecord;
419
- delay?: number;
420
- artifacts?: Artifact[];
421
- reports?: LoaderReport[];
422
- processed_files?: string[];
423
- stats_file?: string;
424
- }
425
-
426
- /**
427
- * EventType is an enum that defines the different types of events that can be sent to the external extractor from the AirSync platform.
428
- * The external extractor can use these events to know what to do next in the extraction process.
429
- */
430
- export declare enum EventType {
431
- StartExtractingExternalSyncUnits = "START_EXTRACTING_EXTERNAL_SYNC_UNITS",
432
- StartExtractingMetadata = "START_EXTRACTING_METADATA",
433
- StartExtractingData = "START_EXTRACTING_DATA",
434
- ContinueExtractingData = "CONTINUE_EXTRACTING_DATA",
435
- StartDeletingExtractorState = "START_DELETING_EXTRACTOR_STATE",
436
- StartExtractingAttachments = "START_EXTRACTING_ATTACHMENTS",
437
- ContinueExtractingAttachments = "CONTINUE_EXTRACTING_ATTACHMENTS",
438
- StartDeletingExtractorAttachmentsState = "START_DELETING_EXTRACTOR_ATTACHMENTS_STATE",
439
- StartLoadingData = "START_LOADING_DATA",
440
- ContinueLoadingData = "CONTINUE_LOADING_DATA",
441
- StartLoadingAttachments = "START_LOADING_ATTACHMENTS",
442
- ContinueLoadingAttachments = "CONTINUE_LOADING_ATTACHMENTS",
443
- StartDeletingLoaderState = "START_DELETING_LOADER_STATE",
444
- StartDeletingLoaderAttachmentState = "START_DELETING_LOADER_ATTACHMENT_STATE",
445
- UnknownEventType = "UNKNOWN_EVENT_TYPE"
446
- }
447
-
448
- /**
449
- * External domain metadata describing the logical structure of an external system.
450
- */
451
- export declare interface ExternalDomainMetadata {
452
- /** The record types in the domain */
453
- record_types: Record<RecordTypeKey, RecordType>;
454
- /** Record type categories */
455
- record_type_categories?: Record<RecordTypeCategoryKey, RecordTypeCategory>;
456
- /** Struct types for reusable field structures */
457
- struct_types?: Record<StructTypeKey, StructType>;
458
- /** The schema version of the metadata format itself. */
459
- schema_version?: SchemaVersion;
460
- }
461
-
462
- export declare type ExternalProcessAttachmentFunction = ({ attachment, stream, }: {
463
- attachment: NormalizedAttachment;
464
- stream: ExternalSystemAttachmentStreamingFunction;
465
- }) => Promise<ProcessAttachmentReturnType>;
466
-
467
- /**
468
- * ExternalSyncUnit is an interface that defines the structure of an external sync unit (repos, projects, ...) that can be extracted.
469
- * It must contain an ID, a name, and a description. It can also contain the number of items in the external sync unit.
470
- */
471
- export declare interface ExternalSyncUnit {
472
- id: string;
473
- name: string;
474
- description: string;
475
- item_count?: number;
476
- item_type?: string;
477
- }
478
-
479
- export declare interface ExternalSystemAttachment {
480
- reference_id: DonV2;
481
- parent_type: string;
482
- parent_reference_id: DonV2;
483
- file_name: string;
484
- file_type: string;
485
- file_size: number;
486
- url: string;
487
- valid_until: string;
488
- created_by_id: string;
489
- created_date: string;
490
- modified_by_id: string;
491
- modified_date: string;
492
- parent_id?: string;
493
- grand_parent_id?: string;
494
- }
495
-
496
- export declare type ExternalSystemAttachmentIteratorFunction<NewBatch, ConnectorState> = ({ reducedAttachments, adapter, stream, }: {
497
- reducedAttachments: NewBatch;
498
- adapter: ExtractionAdapter<ConnectorState>;
499
- stream: ExternalSystemAttachmentStreamingFunction;
500
- }) => Promise<ProcessAttachmentReturnType>;
501
-
502
- declare interface ExternalSystemAttachmentProcessors<ConnectorState, Batch, NewBatch> {
503
- reducer: ExternalSystemAttachmentReducerFunction<Batch, NewBatch, ConnectorState>;
504
- iterator: ExternalSystemAttachmentIteratorFunction<NewBatch, ConnectorState>;
505
- }
506
-
507
- export declare type ExternalSystemAttachmentReducerFunction<Batch, NewBatch, ConnectorState> = ({ attachments, adapter, batchSize, }: {
508
- attachments: Batch;
509
- adapter: ExtractionAdapter<ConnectorState>;
510
- batchSize?: number;
511
- }) => NewBatch;
512
-
513
- export declare type ExternalSystemAttachmentStreamingFunction = ({ item, event, }: ExternalSystemAttachmentStreamingParams) => Promise<ExternalSystemAttachmentStreamingResponse>;
514
-
515
- export declare interface ExternalSystemAttachmentStreamingParams {
516
- item: NormalizedAttachment;
517
- event: AirSyncEvent;
518
- }
519
-
520
- export declare interface ExternalSystemAttachmentStreamingResponse {
521
- httpStream?: AxiosResponse;
522
- error?: ErrorRecord;
523
- delay?: number;
524
- }
525
-
526
- export declare interface ExternalSystemItem {
527
- id: {
528
- devrev: DonV2;
529
- external?: string;
530
- };
531
- created_date: string;
532
- modified_date: string;
533
- data: any;
534
- }
535
-
536
- export declare interface ExternalSystemItem {
537
- id: {
538
- devrev: DonV2;
539
- external?: string;
540
- };
541
- created_date: string;
542
- modified_date: string;
543
- data: any;
544
- }
545
-
546
- export declare interface ExternalSystemItemLoadingParams<Type> {
547
- item: Type;
548
- mappers: Mappers;
549
- event: AirSyncEvent;
550
- }
551
-
552
- export declare interface ExternalSystemItemLoadingResponse {
553
- id?: string;
554
- error?: string;
555
- modifiedDate?: string;
556
- delay?: number;
557
- }
558
-
559
- declare type ExternalSystemLoadingFunction<Item> = ({ item, mappers, event, }: ExternalSystemItemLoadingParams<Item>) => Promise<ExternalSystemItemLoadingResponse>;
560
-
561
- /**
562
- * ExtractionAdapter is the adapter passed to extraction tasks. It exposes the
563
- * extraction surface (repos, artifacts, attachment streaming) and updates the
564
- * extraction boundaries before emitting.
565
- *
566
- * @public
567
- */
568
- export declare class ExtractionAdapter<ConnectorState> extends BaseAdapter<ConnectorState, ExtractionState<ConnectorState>> {
569
- private _artifacts;
570
- private repos;
571
- private currentEventDataLength;
572
- constructor(params: {
573
- event: AirSyncEvent;
574
- adapterState: ExtractionState<ConnectorState>;
575
- options?: WorkerAdapterOptions;
576
- });
577
- get extractionScope(): ExtractionScope;
578
- /**
579
- * Returns whether the given item type should be extracted.
580
- * Defaults to true if the scope is empty or the item type is not listed.
581
- */
582
- shouldExtract(itemType: string): boolean;
583
- initializeRepos(repos: RepoInterface[]): void;
584
- getRepo(itemType: string): Repo | undefined;
585
- get artifacts(): Artifact[];
586
- set artifacts(artifacts: Artifact[]);
587
- protected beforeEmit(newEventType: ExtractorEventType | LoaderEventType): Promise<void>;
588
- protected buildEmitPayload(newEventType: ExtractorEventType | LoaderEventType): EventData;
589
- protected afterEmit(): void;
590
- uploadAllRepos(): Promise<void>;
591
- processAttachment(attachment: NormalizedAttachment, stream: ExternalSystemAttachmentStreamingFunction): Promise<ProcessAttachmentReturnType>;
592
- /**
593
- * Destroys a stream to prevent memory leaks.
594
- * @param httpStream - The axios response stream to destroy
595
- */
596
- private destroyHttpStream;
597
- /**
598
- * Streams the attachments to the DevRev platform.
599
- * The attachments are streamed to the platform and the artifact information is returned.
600
- * @param params - The parameters to stream the attachments
601
- * @returns The response object containing the ssorAttachment artifact information
602
- * or error information if there was an error
603
- */
604
- streamAttachments<NewBatch>({ stream, processors, batchSize, }: {
605
- stream: ExternalSystemAttachmentStreamingFunction;
606
- processors?: ExternalSystemAttachmentProcessors<ConnectorState, NormalizedAttachment[], NewBatch>;
607
- batchSize?: number;
608
- }): Promise<StreamAttachmentsReturnType>;
609
- }
610
-
611
- export declare const enum ExtractionCommonError {
612
- EXTERNAL_SYNC_UNIT_DELETED = "ERROR_CODE=EXTERNAL_SYNC_UNIT_DELETED",
613
- EXTERNAL_SYNC_UNIT_DEACTIVATED = "ERROR_CODE=EXTERNAL_SYNC_UNIT_DEACTIVATED",
614
- USER_DELETED = "ERROR_CODE=USER_DELETED"
615
- }
616
-
617
- /**
618
- * ExtractionScope represents the parsed extraction scope from the platform.
619
- * Each key is an item type name, and the value indicates whether it should be extracted.
620
- */
621
- export declare type ExtractionScope = Record<string, {
622
- extract: boolean;
623
- }>;
624
-
625
- /**
626
- * ExtractionSdkState holds SDK bookkeeping owned by the extraction modes.
627
- */
628
- declare interface ExtractionSdkState extends BaseSdkState {
629
- /** The pending (not yet committed) oldest extraction boundary (ISO 8601 timestamp).
630
- * Set on StartExtractingMetadata, reused across subsequent phases, cleared on AttachmentExtractionDone. */
631
- pendingWorkersOldest?: string;
632
- /** The pending (not yet committed) newest extraction boundary (ISO 8601 timestamp).
633
- * Set on StartExtractingMetadata, reused across subsequent phases, cleared on AttachmentExtractionDone. */
634
- pendingWorkersNewest?: string;
635
- /** The oldest point of extraction (ISO 8601 timestamp). */
636
- workersOldest?: string;
637
- /** The newest point of extraction (ISO 8601 timestamp). */
638
- workersNewest?: string;
639
- toDevRev?: ToDevRev;
640
- }
641
-
642
- /**
643
- * ExtractionState is the per-mode state for extraction workers. It narrows
644
- * `sdkState` to `ExtractionSdkState` (extraction boundaries + attachments
645
- * bookkeeping) on top of the shared lifecycle provided by `BaseState`.
646
- */
647
- declare class ExtractionState<ConnectorState> extends BaseState<ConnectorState, ExtractionSdkState> {
648
- constructor(params: StateInterface<ConnectorState>);
649
- /**
650
- * Resolves the extraction window onto the event context.
651
- *
652
- * On StartExtractingMetadata: resolve fresh from the TimeValue objects in the
653
- * event context and cache them as pending boundaries (always overwrite).
654
- * On all other events: reuse the pending boundaries cached during
655
- * StartExtractingMetadata. Finally, validate that extract_from < extract_to.
656
- */
657
- resolveExtractionWindow(): void;
658
- }
659
-
660
- /**
661
- * ExtractorEvent is an interface that defines the structure of the event that is sent from the external extractor to the AirSync platform.
662
- * It contains the event type, event context, extractor state, and event data.
663
- */
664
- export declare interface ExtractorEvent {
665
- event_type: string;
666
- event_context: EventContext;
667
- event_data?: EventData;
668
- worker_metadata?: WorkerMetadata;
669
- }
670
-
671
- /**
672
- * ExtractorEventType is an enum that defines the different types of events that can be sent from the external extractor to the AirSync platform.
673
- * The external extractor can use these events to inform the AirSync platform about the progress of the extraction process.
674
- */
675
- export declare enum ExtractorEventType {
676
- ExternalSyncUnitExtractionDone = "EXTERNAL_SYNC_UNIT_EXTRACTION_DONE",
677
- ExternalSyncUnitExtractionError = "EXTERNAL_SYNC_UNIT_EXTRACTION_ERROR",
678
- MetadataExtractionDone = "METADATA_EXTRACTION_DONE",
679
- MetadataExtractionError = "METADATA_EXTRACTION_ERROR",
680
- DataExtractionProgress = "DATA_EXTRACTION_PROGRESS",
681
- DataExtractionDelayed = "DATA_EXTRACTION_DELAYED",
682
- DataExtractionDone = "DATA_EXTRACTION_DONE",
683
- DataExtractionError = "DATA_EXTRACTION_ERROR",
684
- ExtractorStateDeletionDone = "EXTRACTOR_STATE_DELETION_DONE",
685
- ExtractorStateDeletionError = "EXTRACTOR_STATE_DELETION_ERROR",
686
- AttachmentExtractionProgress = "ATTACHMENT_EXTRACTION_PROGRESS",
687
- AttachmentExtractionDelayed = "ATTACHMENT_EXTRACTION_DELAYED",
688
- AttachmentExtractionDone = "ATTACHMENT_EXTRACTION_DONE",
689
- AttachmentExtractionError = "ATTACHMENT_EXTRACTION_ERROR",
690
- ExtractorAttachmentsStateDeletionDone = "EXTRACTOR_ATTACHMENTS_STATE_DELETION_DONE",
691
- ExtractorAttachmentsStateDeletionError = "EXTRACTOR_ATTACHMENTS_STATE_DELETION_ERROR",
692
- UnknownEventType = "UNKNOWN_EVENT_TYPE"
693
- }
694
-
695
- /**
696
- * Field definition with type discriminator and type-specific data.
697
- */
698
- export declare interface Field {
699
- /** The type of the field */
700
- type: FieldType;
701
- /** The human readable name of the field */
702
- name?: string;
703
- description?: string;
704
- /** Required fields are required in the domain model of the external system. */
705
- is_required?: boolean;
706
- /** Read only fields can't be set (when creating or updating a record), but are filled in by some process in the system. */
707
- is_read_only?: boolean | null;
708
- /** Fields that are write only should only be written to. */
709
- is_write_only?: boolean | null;
710
- /** Indexed fields can be used for searching, sorting or filtering. */
711
- is_indexed?: boolean | null;
712
- /** Indicates that the field can be used to uniquely lookup a record. */
713
- is_identifier?: boolean | null;
714
- /** Default value for the field */
715
- default_value?: boolean | number | string;
716
- /** If collection is set, the field is a 'collection' of the given type. */
717
- collection?: CollectionData;
718
- int?: IntData;
719
- float?: FloatData;
720
- text?: TextData;
721
- enum?: EnumData | null;
722
- reference?: ReferenceData;
723
- typed_reference?: TypedReferenceData;
724
- struct?: StructData;
725
- permission?: PermissionData;
726
- type_key?: TargetTypeKeyData;
727
- field_reference?: FieldReferenceData;
728
- record_type_privilege?: RecordTypePrivilegeData;
729
- field_privilege?: FieldPrivilegeData;
730
- conditional_privilege?: ConditionalPrivilegeData;
731
- participation?: ParticipationData;
732
- }
733
-
734
- /**
735
- * Field condition definition.
736
- */
737
- export declare interface FieldCondition {
738
- /** The value of the controlling field that will be compared against to see if the condition is met. */
739
- value: unknown;
740
- /** The comparator that will be used to compare the controlling field's value against the Value. */
741
- comparator: FieldConditionComparator;
742
- /** The fields that will be affected by the condition being met. */
743
- affected_fields: FieldKey[];
744
- /** The effect that will be applied to the affected fields if the condition is met. */
745
- effect: FieldConditionEffect;
746
- }
747
-
748
- /**
749
- * Comparator for field conditions.
750
- */
751
- export declare type FieldConditionComparator = 'eq' | 'ne';
752
-
753
- /**
754
- * Effect applied when a field condition is met.
755
- */
756
- export declare type FieldConditionEffect = 'require' | 'show';
757
-
758
- /**
759
- * Array of field conditions.
760
- */
761
- export declare type FieldConditions = FieldCondition[];
762
-
763
- /** Key identifying a field within a record type or struct type fields map. */
764
- export declare type FieldKey = string;
765
-
766
- /**
767
- * Field privilege data for authorization.
768
- */
769
- export declare interface FieldPrivilegeData {
770
- /** The possible record types or record type categories that can be targeted in field privilege. */
771
- type_keys: RecordTypeKey[];
772
- }
773
-
774
- /**
775
- * Field reference data (currently empty, reserved for future use).
776
- */
777
- export declare interface FieldReferenceData {
778
- [key: string]: never;
779
- }
780
-
781
- /**
782
- * Field type discriminator.
783
- */
784
- export declare type FieldType = 'bool' | 'int' | 'float' | 'text' | 'rich_text' | 'reference' | 'typed_reference' | 'enum' | 'date' | 'timestamp' | 'struct' | 'permission' | 'record_type_privilege' | 'field_privilege' | 'conditional_privilege' | 'participation';
785
-
786
- declare interface FileToLoad {
787
- id: string;
788
- file_name: string;
789
- itemType: string;
790
- count: number;
791
- lineToProcess: number;
792
- completed: boolean;
793
- }
794
-
795
- /**
796
- * Float field constraints.
797
- */
798
- export declare interface FloatData {
799
- min?: number;
800
- max?: number;
801
- }
802
-
803
- declare interface FromDevRev {
804
- filesToLoad: FileToLoad[];
805
- }
806
-
807
- /**
808
- * GetWorkerPathInterface is an interface for getting the worker path.
809
- */
810
- export declare interface GetWorkerPathInterface {
811
- event: AirSyncEvent;
812
- workerBasePath?: string | null;
813
- }
814
-
815
- /**
816
- * InitialDomainMapping is an interface that defines the structure of the initial domain mapping.
817
- */
818
- export declare interface InitialDomainMapping {
819
- starting_recipe_blueprint?: object;
820
- additional_mappings?: object;
821
- }
822
-
823
- /**
824
- * InitialSyncScope is an enum that defines the different scopes of initial sync that can be used by the external extractor.
825
- */
826
- export declare enum InitialSyncScope {
827
- FULL_HISTORY = "full-history",
828
- TIME_SCOPED = "time-scoped"
829
- }
830
-
831
- export declare function installInitialDomainMapping(event: AirSyncEvent, initialDomainMappingJson: InitialDomainMapping): Promise<void>;
832
-
833
- /**
834
- * Integer field constraints.
835
- */
836
- export declare interface IntData {
837
- min?: number;
838
- max?: number;
839
- }
840
-
841
- /**
842
- * Item is an interface that defines the structure of an item.
843
- */
844
- declare type Item = Record<string, any>;
845
-
846
- declare interface ItemTypesToLoadParams {
847
- itemTypesToLoad: ItemTypeToLoad[];
848
- }
849
-
850
- declare interface ItemTypeToLoad {
851
- itemType: string;
852
- create: ExternalSystemLoadingFunction<ExternalSystemItem>;
853
- update: ExternalSystemLoadingFunction<ExternalSystemItem>;
854
- }
855
-
856
- export declare enum LoaderEventType {
857
- DataLoadingProgress = "DATA_LOADING_PROGRESS",
858
- DataLoadingDelayed = "DATA_LOADING_DELAYED",
859
- DataLoadingDone = "DATA_LOADING_DONE",
860
- DataLoadingError = "DATA_LOADING_ERROR",
861
- AttachmentLoadingProgress = "ATTACHMENT_LOADING_PROGRESS",
862
- AttachmentLoadingDelayed = "ATTACHMENT_LOADING_DELAYED",
863
- AttachmentLoadingDone = "ATTACHMENT_LOADING_DONE",
864
- AttachmentLoadingError = "ATTACHMENT_LOADING_ERROR",
865
- LoaderStateDeletionDone = "LOADER_STATE_DELETION_DONE",
866
- LoaderStateDeletionError = "LOADER_STATE_DELETION_ERROR",
867
- LoaderAttachmentStateDeletionDone = "LOADER_ATTACHMENT_STATE_DELETION_DONE",
868
- LoaderAttachmentStateDeletionError = "LOADER_ATTACHMENT_STATE_DELETION_ERROR",
869
- UnknownEventType = "UNKNOWN_EVENT_TYPE"
870
- }
871
-
872
- declare interface LoaderReport {
873
- item_type: string;
874
- [ActionType.CREATED]?: number;
875
- [ActionType.UPDATED]?: number;
876
- [ActionType.SKIPPED]?: number;
877
- [ActionType.DELETED]?: number;
878
- [ActionType.FAILED]?: number;
879
- }
880
-
881
- /**
882
- * LoadingAdapter is the adapter passed to loading tasks. It exposes the loading
883
- * surface (item/attachment loading, mappers, loader reports).
884
- *
885
- * @public
886
- */
887
- export declare class LoadingAdapter<ConnectorState> extends BaseAdapter<ConnectorState, LoadingState<ConnectorState>> {
888
- private loaderReports;
889
- private _processedFiles;
890
- private _mappers;
891
- constructor(params: {
892
- event: AirSyncEvent;
893
- adapterState: LoadingState<ConnectorState>;
894
- options?: WorkerAdapterOptions;
895
- });
896
- get reports(): LoaderReport[];
897
- get processedFiles(): string[];
898
- get mappers(): Mappers;
899
- protected beforeEmit(): Promise<void>;
900
- protected buildEmitPayload(newEventType: ExtractorEventType | LoaderEventType): EventData;
901
- protected afterEmit(): void;
902
- loadItemTypes({ itemTypesToLoad, }: ItemTypesToLoadParams): Promise<LoadItemTypesResponse>;
903
- getLoaderBatches({ supportedItemTypes, }: {
904
- supportedItemTypes: string[];
905
- }): Promise<FileToLoad[]>;
906
- loadAttachments({ create, }: {
907
- create: ExternalSystemLoadingFunction<ExternalSystemAttachment>;
908
- }): Promise<LoadItemTypesResponse>;
909
- loadItem({ item, itemTypeToLoad, }: {
910
- item: ExternalSystemItem;
911
- itemTypeToLoad: ItemTypeToLoad;
912
- }): Promise<LoadItemResponse>;
913
- loadAttachment({ item, create, }: {
914
- item: ExternalSystemAttachment;
915
- create: ExternalSystemLoadingFunction<ExternalSystemAttachment>;
916
- }): Promise<LoadItemResponse>;
917
- }
918
-
919
- /**
920
- * LoadingSdkState holds SDK bookkeeping owned by the loading modes.
921
- */
922
- declare interface LoadingSdkState extends BaseSdkState {
923
- fromDevRev?: FromDevRev;
924
- }
925
-
926
- /**
927
- * LoadingState is the per-mode state for loading workers. It narrows `sdkState`
928
- * to `LoadingSdkState` (files-to-load bookkeeping) on top of the shared
929
- * lifecycle provided by `BaseState`.
930
- */
931
- declare class LoadingState<ConnectorState> extends BaseState<ConnectorState, LoadingSdkState> {
932
- constructor(params: StateInterface<ConnectorState>);
933
- }
934
-
935
- declare interface LoadItemResponse {
936
- error?: ErrorRecord;
937
- report?: LoaderReport;
938
- rateLimit?: RateLimited;
939
- }
940
-
941
- declare interface LoadItemTypesResponse {
942
- reports: LoaderReport[];
943
- processed_files: string[];
944
- }
945
-
946
- declare enum LogLevel {
947
- INFO = "info",
948
- WARN = "warn",
949
- ERROR = "error"
950
- }
951
-
952
- /**
953
- * Manages sync mapper records that link external system items to DevRev items.
954
- *
955
- * Used for tracking relationships between external and DevRev entities during sync operations.
956
- */
957
- declare class Mappers {
958
- private devrevApiEndpoint;
959
- private devrevApiToken;
960
- constructor({ event }: MappersFactoryInterface);
961
- /**
962
- * Retrieves a sync mapper record by DevRev ID.
963
- *
964
- * Used to find the mapping when you know the DevRev ID and want to find the external system ID.
965
- *
966
- * @param params - Query parameters of type MappersGetByTargetIdParams
967
- * @returns Promise with response data containing the sync mapper record
968
- */
969
- getByTargetId(params: MappersGetByTargetIdParams): Promise<AxiosResponse<MappersGetByTargetIdResponse>>;
970
- /**
971
- * Retrieves a sync mapper record by external system ID.
972
- *
973
- * Used to find the mapping when you know the external system ID and want to find the DevRev ID.
974
- *
975
- * @param params - Query parameters of type MappersGetByExternalIdParams
976
- * @returns Promise with response data containing the sync mapper record
977
- */
978
- getByExternalId(params: MappersGetByExternalIdParams): Promise<AxiosResponse<MappersGetByExternalIdResponse>>;
979
- /**
980
- * Creates a new sync mapper record to establish a relationship between external system
981
- * entities and DevRev entities.
982
- *
983
- * This is called after importing an item from external system to DevRev to record
984
- * the mapping for future synchronization operations.
985
- *
986
- * @param params - Creation parameters of type MappersCreateParams
987
- * @returns Promise with response data containing the created sync mapper record
988
- */
989
- create(params: MappersCreateParams): Promise<AxiosResponse<MappersCreateResponse>>;
990
- /**
991
- * Updates an existing sync mapper record.
992
- *
993
- * Used to modify existing mappings when external system entities change or when
994
- * additional DevRev entities need to be associated.
995
- *
996
- * @param params - Update parameters of type MappersUpdateParams
997
- * @returns Promise with response data containing the updated sync mapper record
998
- */
999
- update(params: MappersUpdateParams): Promise<AxiosResponse<MappersUpdateResponse>>;
1000
- }
1001
-
1002
- /**
1003
- * Parameters for creating a new sync mapper record.
1004
- */
1005
- export declare interface MappersCreateParams {
1006
- /** The sync unit ID that scopes the synchronization context */
1007
- sync_unit: DonV2;
1008
- /** Array of external system identifiers */
1009
- external_ids: string[];
1010
- /**
1011
- * Optional map that labels values in `external_ids` with their usage context.
1012
- * Use when an external system requires different identifiers for different API calls
1013
- * (for example, a UUID for one endpoint and a login username for another).
1014
- *
1015
- * Example:
1016
- * external_ids: ["2a1c...-uuid", "john_doe"]
1017
- * secondary_ids: { "username": "john_doe" }
1018
- *
1019
- * Note: Values in `secondary_ids` are not indexed. If you need to look up by a
1020
- * secondary value (e.g., username), you must also include that value in `external_ids`.
1021
- */
1022
- secondary_ids?: Record<string, string>;
1023
- /** Array of DevRev entity IDs this mapping points to */
1024
- targets: DonV2[];
1025
- status: SyncMapperRecordStatus;
1026
- /**
1027
- * Input file names where the object was encountered.
1028
- * Used for observability and tracking.
1029
- */
1030
- input_files?: string[];
1031
- /**
1032
- * External version markers used to avoid update loops.
1033
- * After creating or updating the object in the external system, add its
1034
- * modified_date here. On subsequent extraction, the Loader skips applying the
1035
- * update if the modified_date is present (change originated in DevRev).
1036
- */
1037
- external_versions?: SyncMapperRecordExternalVersion[];
1038
- /**
1039
- * Opaque data for storing additional client-specific information.
1040
- * Fully managed by snapin authors.
1041
- */
1042
- extra_data?: string;
1043
- }
1044
-
1045
- /**
1046
- * Response containing the newly created sync mapper record.
1047
- */
1048
- declare interface MappersCreateResponse {
1049
- sync_mapper_record: SyncMapperRecord;
1050
- }
1051
-
1052
- /**
1053
- * Configuration interface for creating a Mappers instance.
1054
- */
1055
- declare interface MappersFactoryInterface {
1056
- event: AirSyncEvent;
1057
- options?: WorkerAdapterOptions;
1058
- }
1059
-
1060
- /**
1061
- * Parameters for retrieving a sync mapper record by external system ID.
1062
- */
1063
- export declare interface MappersGetByExternalIdParams {
1064
- /** The sync unit ID that scopes the synchronization context */
1065
- sync_unit: DonV2;
1066
- /** The identifier from the external system */
1067
- external_id: string;
1068
- /** The type of DevRev entity to look for */
1069
- target_type: SyncMapperRecordTargetType;
1070
- }
1071
-
1072
- /**
1073
- * Response containing a sync mapper record retrieved by external ID.
1074
- */
1075
- declare interface MappersGetByExternalIdResponse {
1076
- sync_mapper_record: SyncMapperRecord;
1077
- }
1078
-
1079
- /**
1080
- * Parameters for retrieving a sync mapper record by DevRev target ID.
1081
- */
1082
- export declare interface MappersGetByTargetIdParams {
1083
- /** The sync unit ID that scopes the synchronization context */
1084
- sync_unit: DonV2;
1085
- /** The DevRev entity ID to look up */
1086
- target: DonV2;
1087
- }
1088
-
1089
- /**
1090
- * Response containing a sync mapper record retrieved by target ID.
1091
- */
1092
- declare interface MappersGetByTargetIdResponse {
1093
- sync_mapper_record: SyncMapperRecord;
1094
- }
1095
-
1096
- /**
1097
- * Parameters for updating an existing sync mapper record.
1098
- */
1099
- export declare interface MappersUpdateParams {
1100
- /** The ID of the existing sync mapper record to update */
1101
- id: DonV2;
1102
- /** The sync unit ID that scopes the synchronization context */
1103
- sync_unit: DonV2;
1104
- /** External system IDs to add to the existing mapping */
1105
- external_ids: {
1106
- add: string[];
1107
- };
1108
- /**
1109
- * Optional map that labels values in `external_ids` with their usage context.
1110
- * Use when an external system requires different identifiers for different API calls
1111
- * (for example, a UUID for one endpoint and a login username for another).
1112
- *
1113
- * Example:
1114
- * external_ids: ["2a1c...-uuid", "john_doe"]
1115
- * secondary_ids: { "username": "john_doe" }
1116
- *
1117
- * Note: Values in `secondary_ids` are not indexed. If you need to look up by a
1118
- * secondary value (e.g., username), you must also include that value in `external_ids`.
1119
- */
1120
- secondary_ids?: Record<string, string>;
1121
- /** DevRev entity IDs to add to the existing mapping */
1122
- targets: {
1123
- add: DonV2[];
1124
- };
1125
- status: SyncMapperRecordStatus;
1126
- /**
1127
- * Input file names where the object was encountered.
1128
- * Used for observability and tracking.
1129
- */
1130
- input_files?: {
1131
- add: string[];
1132
- };
1133
- /**
1134
- * External version markers used to avoid update loops.
1135
- * After creating or updating the object in the external system, add its
1136
- * modified_date here. On subsequent extraction, the Loader skips applying the
1137
- * update if the modified_date is present (change originated in DevRev).
1138
- */
1139
- external_versions?: {
1140
- add: SyncMapperRecordExternalVersion[];
1141
- };
1142
- /**
1143
- * Opaque data for storing additional client-specific information.
1144
- * Fully managed by snapin authors.
1145
- */
1146
- extra_data?: string;
1147
- }
1148
-
1149
- /**
1150
- * Response containing the updated sync mapper record.
1151
- */
1152
- declare interface MappersUpdateResponse {
1153
- sync_mapper_record: SyncMapperRecord;
1154
- }
1155
-
1156
- export declare const MOCK_SERVER_DEFAULT_URL = "http://localhost:0";
1157
-
1158
- /**
1159
- * MockServer used in tests to mock internal AirSync endpoints.
1160
- * This is a simple mock server that listens on a port and responds to requests.
1161
- * Supports per-test route configuration to simulate different response scenarios.
1162
- */
1163
- export declare class MockServer {
1164
- private server;
1165
- private internalPort;
1166
- port: number;
1167
- baseUrl: string;
1168
- private routeHandlers;
1169
- private requests;
1170
- private requestCounts;
1171
- constructor(port?: number);
1172
- start(): Promise<void>;
1173
- stop(): Promise<void>;
1174
- private handleRequest;
1175
- /**
1176
- * Default route handler for the mock server. Returns { success: true } for
1177
- * routes that are not explicitly set.
1178
- */
1179
- private defaultRouteHandler;
1180
- private getRouteKey;
1181
- /**
1182
- * Configures a route to return a specific status code and optional response body.
1183
- */
1184
- setRoute(config: RouteConfig): void;
1185
- /**
1186
- * Resets all custom route handlers, restoring all default handlers.
1187
- * Also clears request tracking data.
1188
- */
1189
- resetRoutes(): void;
1190
- /**
1191
- * Returns the most recent request or undefined if no requests exist.
1192
- */
1193
- getLastRequest(): RequestInfo_2 | undefined;
1194
- /**
1195
- * Gets the number of requests made to a specific endpoint.
1196
- */
1197
- getRequestCount(method: string, path: string): number;
1198
- /**
1199
- * Gets all requests made to a specific endpoint.
1200
- */
1201
- getRequests(method: string, path: string): RequestInfo_2[];
1202
- }
1203
-
1204
- /**
1205
- * NormalizedAttachment is an interface of attachment after normalization.
1206
- */
1207
- export declare interface NormalizedAttachment {
1208
- url: string;
1209
- id: string;
1210
- file_name: string;
1211
- parent_id: string;
1212
- author_id?: string;
1213
- inline?: boolean;
1214
- content_type?: string;
1215
- grand_parent_id?: number | string;
1216
- }
1217
-
1218
- /**
1219
- * NormalizedItem is an interface of item after normalization.
1220
- */
1221
- export declare interface NormalizedItem {
1222
- id: string;
1223
- created_date: string;
1224
- modified_date: string;
1225
- data: object;
1226
- }
1227
-
1228
- /**
1229
- * Participation field data specifying target record types.
1230
- */
1231
- declare interface ParticipationData {
1232
- /** The record types that this participation reference can refer to */
1233
- refers_to: Record<RecordTypeKey, ReferenceDetail>;
1234
- }
1235
-
1236
- /**
1237
- * Permission data associating a reference with a role.
1238
- */
1239
- export declare interface PermissionData {
1240
- member_id?: ReferenceData;
1241
- role?: EnumData;
1242
- }
1243
-
1244
- export declare type ProcessAttachmentReturnType = {
1245
- delay?: number;
1246
- error?: {
1247
- message: string;
1248
- fileSize?: number;
1249
- };
1250
- } | undefined;
1251
-
1252
- /**
1253
- * Attachment structure, that stores both attachment id and its parent_id for deduplication on the SDK side.
1254
- */
1255
- declare interface ProcessedAttachment {
1256
- id: string;
1257
- parent_id: string;
1258
- }
1259
-
1260
- /**
1261
- * Entry point for an extraction worker. Builds an {@link ExtractionAdapter} and
1262
- * runs the provided task against it.
1263
- *
1264
- * @public
1265
- */
1266
- export declare function processExtractionTask<ConnectorState>({ task, onTimeout, }: ProcessTaskInterface<ExtractionAdapter<ConnectorState>>): void;
1267
-
1268
- /**
1269
- * Entry point for a loading worker. Builds a {@link LoadingAdapter} and runs the
1270
- * provided task against it.
1271
- *
1272
- * @public
1273
- */
1274
- export declare function processLoadingTask<ConnectorState>({ task, onTimeout, }: ProcessTaskInterface<LoadingAdapter<ConnectorState>>): void;
1275
-
1276
- /**
1277
- * ProcessTaskInterface is the parameter shape for the process-task entry points.
1278
- * @interface ProcessTaskInterface
1279
- * @constructor
1280
- * @param {function} task - The task to be executed, returns exit code
1281
- * @param {function} onTimeout - The task to be executed on timeout, returns exit code
1282
- */
1283
- export declare interface ProcessTaskInterface<Adapter extends BaseAdapter<unknown, BaseState<unknown, BaseSdkState>>> {
1284
- task: (params: TaskAdapterInterface<Adapter>) => Promise<void>;
1285
- onTimeout: (params: TaskAdapterInterface<Adapter>) => Promise<void>;
1286
- }
1287
-
1288
- declare interface RateLimited {
1289
- delay: number;
1290
- }
1291
-
1292
- /**
1293
- * Record type definition.
1294
- */
1295
- export declare interface RecordType {
1296
- /** The fields of the record type */
1297
- fields: Record<FieldKey, Field>;
1298
- /** The human readable name of the record type */
1299
- name?: string;
1300
- description?: string;
1301
- category?: RecordTypeCategoryKey;
1302
- /** Whether the record type can be loaded (connector supports creating it in the system) */
1303
- is_loadable?: boolean;
1304
- /** Whether the record type sends the complete system state in every sync */
1305
- is_snapshot?: boolean;
1306
- /** Denotes that the record type has no ID field, primarily used for authorization policies */
1307
- no_identifier?: boolean;
1308
- /** Indicates the scope of this record type */
1309
- scope?: RecordTypeScope;
1310
- /** Field conditions for this record type */
1311
- conditions?: Record<FieldKey, FieldConditions>;
1312
- /** Stage diagram for workflow */
1313
- stage_diagram?: StageDiagram;
1314
- /** Link naming data for custom links */
1315
- link_naming_data?: CustomLinkData;
1316
- /** Attachments configuration */
1317
- attachments?: Attachments;
1318
- }
1319
-
1320
- /**
1321
- * Record type category definition.
1322
- */
1323
- export declare interface RecordTypeCategory {
1324
- /** The human readable name of the record type category */
1325
- name?: string;
1326
- /** Indicates whether a record can move between the record types of this category while preserving its identity */
1327
- are_record_type_conversions_possible?: boolean;
1328
- }
1329
-
1330
- /** Key identifying a record type category in the record_type_categories map. */
1331
- export declare type RecordTypeCategoryKey = string;
1332
-
1333
- /** Key identifying a record type in the record_types map, refers_to maps, or type_keys arrays. */
1334
- export declare type RecordTypeKey = string;
1335
-
1336
- /**
1337
- * Record type privilege data for authorization.
1338
- */
1339
- export declare interface RecordTypePrivilegeData {
1340
- /** The possible record types or record type categories that can be targeted in record type privilege. */
1341
- type_keys: RecordTypeKey[];
1342
- }
1343
-
1344
- /**
1345
- * Scope of a record type.
1346
- */
1347
- export declare type RecordTypeScope = 'metadata_is_system_scoped' | 'data_is_system_scoped';
1348
-
1349
- /**
1350
- * Reference field data specifying target record types.
1351
- */
1352
- export declare interface ReferenceData {
1353
- /** The record types that this reference can refer to */
1354
- refers_to: Record<RecordTypeKey, ReferenceDetail>;
1355
- /** The parent reference refers to a record that has special ownership over the child */
1356
- reference_type?: ReferenceType;
1357
- }
1358
-
1359
- /**
1360
- * Details about how a reference targets another record type.
1361
- */
1362
- export declare interface ReferenceDetail {
1363
- /** The field in the target record type by which it is referenced. Assumed to be the primary key if not set. */
1364
- by_field?: FieldKey;
1365
- }
1366
-
1367
- /**
1368
- * Reference type indicating parent-child relationship.
1369
- */
1370
- export declare type ReferenceType = 'child' | 'parent';
1371
-
1372
- declare class Repo {
1373
- readonly itemType: string;
1374
- private items;
1375
- private normalize?;
1376
- private uploader;
1377
- private onUpload;
1378
- private options?;
1379
- uploadedArtifacts: Artifact[];
1380
- constructor({ event, itemType, normalize, onUpload, options, }: RepoFactoryInterface);
1381
- getItems(): (NormalizedItem | NormalizedAttachment | Item)[];
1382
- upload(batch?: (NormalizedItem | NormalizedAttachment | Item)[]): Promise<void | ErrorRecord>;
1383
- push(items: Item[]): Promise<boolean>;
1384
- }
1385
-
1386
- /**
1387
- * RepoFactoryInterface is an interface that defines the structure of a repo factory which is used to create a repo.
1388
- */
1389
- declare interface RepoFactoryInterface {
1390
- event: AirSyncEvent;
1391
- itemType: string;
1392
- normalize?: (record: object) => NormalizedItem | NormalizedAttachment;
1393
- onUpload: (artifact: Artifact) => void;
1394
- options?: WorkerAdapterOptions;
1395
- }
1396
-
1397
- /**
1398
- * RepoInterface is an interface that defines the structure of a repo which is used to store and upload extracted data.
1399
- */
1400
- export declare interface RepoInterface {
1401
- itemType: string;
1402
- normalize?: (record: object) => NormalizedItem | NormalizedAttachment;
1403
- overridenOptions?: WorkerAdapterOptions;
1404
- }
1405
-
1406
- /**
1407
- * Information about a request received by the mock server.
1408
- */
1409
- declare interface RequestInfo_2 {
1410
- /** The HTTP method (e.g., 'GET', 'POST') */
1411
- method: string;
1412
- /** The full URL path of the request */
1413
- url: string;
1414
- /** Optional request body (for POST/PUT requests) */
1415
- body?: unknown;
1416
- }
1417
- export { RequestInfo_2 as RequestInfo }
1418
-
1419
- /**
1420
- * Configuration for retry simulation behavior.
1421
- */
1422
- export declare interface RetryConfig {
1423
- /** Number of times to return error before succeeding (default: 4) */
1424
- failureCount?: number;
1425
- /** 5xx status code to return during failures (default: 500) */
1426
- errorStatus?: number;
1427
- /** Optional error response body to send as JSON during failures */
1428
- errorBody?: unknown;
1429
- /** Optional headers to send with the error response */
1430
- headers?: Record<string, string>;
1431
- /** Optional delay in milliseconds before sending each failure response */
1432
- delay?: number;
1433
- }
1434
-
1435
- /**
1436
- * Configuration object for setting up a route response.
1437
- */
1438
- export declare interface RouteConfig {
1439
- /** The path of the route (e.g., '/callback_url', '/worker_data_url.get') */
1440
- path: string;
1441
- /** The HTTP method (e.g., 'GET', 'POST', 'PUT', 'DELETE') */
1442
- method: string;
1443
- /** The HTTP status code to return (e.g., 200, 401, 500) */
1444
- status: number;
1445
- /** Optional response body to send as JSON */
1446
- body?: unknown;
1447
- /** Optional headers to send with the response */
1448
- headers?: Record<string, string>;
1449
- /** Optional retry configuration for simulating failures before success */
1450
- retry?: RetryConfig;
1451
- /** Optional delay in milliseconds before sending the response */
1452
- delay?: number;
1453
- }
1454
-
1455
- /**
1456
- * Schema version for the external domain metadata format.
1457
- */
1458
- export declare type SchemaVersion = 'v0.2.0';
1459
-
1460
- /**
1461
- * Serializes an Axios error into a structured format with HTTP request/response details.
1462
- * Extracts method, URL, parameters, status code, headers, and data.
1463
- * Includes CORS/network failure indicator when no response is available.
1464
- *
1465
- * @param error - Axios error to serialize
1466
- * @returns Structured object with error details
1467
- */
1468
- export declare function serializeAxiosError(error: AxiosError): AxiosErrorResponse;
1469
-
1470
- /**
1471
- * Creates a new instance of Spawn class.
1472
- * Spawn class is responsible for spawning a new worker thread and managing the lifecycle of the worker.
1473
- * The class provides utilities to emit control events to the platform and exit the worker gracefully.
1474
- * In case of lambda timeout, the class emits a lambda timeout event to the platform.
1475
- * @param {SpawnFactoryInterface} options - The options to create a new instance of Spawn class
1476
- * @param {AirSyncEvent} options.event - The event object received from the platform
1477
- * @param {object} options.initialState - The initial state of the adapter
1478
- * @param {string} [options.baseWorkerPath] - The base path for the worker files, usually `__dirname`
1479
- * @returns {Promise<Spawn>} - A new instance of Spawn class
1480
- */
1481
- export declare function spawn<ConnectorState>({ event, initialState, initialDomainMapping, options, baseWorkerPath, }: SpawnFactoryInterface<ConnectorState>): Promise<void>;
1482
-
1483
- /**
1484
- * SpawnFactoryInterface is an interface for Spawn class factory.
1485
- * Spawn class is responsible for spawning a new worker thread and managing the lifecycle of the worker.
1486
- * The class provides utilities to emit control events to the platform and exit the worker gracefully.
1487
- * In case of lambda timeout, the class emits a lambda timeout event to the platform.
1488
- * @interface SpawnFactoryInterface
1489
- * @constructor
1490
- * @param {AirSyncEvent} event - The event object received from the platform
1491
- * @param {object=} initialState - The initial state of the adapter
1492
- * @param {string} initialDomainMapping - The initial domain mapping
1493
- * @param {WorkerAdapterOptions} options - The options to create a new instance of Spawn class
1494
- * @param {string=} baseWorkerPath - The base path for the worker files, usually `__dirname`
1495
- */
1496
- export declare interface SpawnFactoryInterface<ConnectorState> {
1497
- event: AirSyncEvent;
1498
- initialState: ConnectorState;
1499
- options?: WorkerAdapterOptions;
1500
- initialDomainMapping?: InitialDomainMapping;
1501
- baseWorkerPath?: string;
1502
- }
1503
-
1504
- /**
1505
- * SpawnInterface is an interface for Spawn class.
1506
- * @interface SpawnInterface
1507
- * @constructor
1508
- * @param {AirSyncEvent} event - The event object received from the platform
1509
- * @param {Worker} worker - The worker thread
1510
- */
1511
- export declare interface SpawnInterface {
1512
- event: AirSyncEvent;
1513
- worker: Worker_2;
1514
- options?: WorkerAdapterOptions;
1515
- resolve: (value: void | PromiseLike<void>) => void;
1516
- originalConsole?: Console;
1517
- }
1518
-
1519
- /**
1520
- * SsorAttachment is an interface that defines the structure of the SSOR attachment.
1521
- */
1522
- export declare interface SsorAttachment {
1523
- id: {
1524
- devrev: string;
1525
- external: string;
1526
- };
1527
- parent_id: {
1528
- external: string;
1529
- };
1530
- actor_id?: {
1531
- external: string;
1532
- };
1533
- inline?: boolean;
1534
- }
1535
-
1536
- /**
1537
- * Stage diagram definition for record type workflow.
1538
- */
1539
- export declare interface StageDiagram {
1540
- /** The field that represents the stage in the external system. */
1541
- controlling_field: FieldKey;
1542
- /** A map of the stages that should be created. Keys must match the enum values in the controlling field. */
1543
- stages: Record<StageKey, CustomStage>;
1544
- /** The stage that the parent record type starts in when it is created. */
1545
- starting_stage?: StageKey;
1546
- /** A map of the states/status categories that should be created. */
1547
- states?: Record<StateKey, CustomState>;
1548
- /** Denotes that this diagram has no explicit transitions and should be created as an 'all-to-all' diagram. */
1549
- all_transitions_allowed?: boolean;
1550
- }
1551
-
1552
- /** Key identifying a stage in the stage diagram stages map. */
1553
- export declare type StageKey = string;
1554
-
1555
- declare interface StateInterface<ConnectorState> {
1556
- event: AirSyncEvent;
1557
- initialState: ConnectorState;
1558
- initialDomainMapping?: InitialDomainMapping;
1559
- options?: WorkerAdapterOptions;
1560
- }
1561
-
1562
- /** Key identifying a state in the stage diagram states map. */
1563
- export declare type StateKey = string;
1564
-
1565
- /**
1566
- * StreamAttachmentsResponse is an interface that defines the structure of the response from the stream attachments through Uploader.
1567
- */
1568
- export declare interface StreamAttachmentsResponse {
1569
- ssorAttachments?: SsorAttachment[];
1570
- error?: ErrorRecord;
1571
- }
1572
-
1573
- declare type StreamAttachmentsReturnType = {
1574
- delay?: number;
1575
- error?: ErrorRecord;
1576
- } | undefined;
1577
-
1578
- /**
1579
- * StreamResponse is an interface that defines the structure of the response from the stream of single attachment through Uploader.
1580
- */
1581
- export declare interface StreamResponse {
1582
- ssorAttachment?: SsorAttachment;
1583
- error?: ErrorRecord;
1584
- }
1585
-
1586
- /**
1587
- * Struct field data referencing a struct type.
1588
- */
1589
- export declare interface StructData {
1590
- key?: StructTypeKey;
1591
- }
1592
-
1593
- /**
1594
- * Struct type definition for reusable field structures.
1595
- */
1596
- export declare interface StructType {
1597
- /** The fields of the struct type */
1598
- fields: Record<FieldKey, Field>;
1599
- /** The human readable name of the struct type */
1600
- name?: string;
1601
- }
1602
-
1603
- /** Key identifying a struct type in the struct_types map. */
1604
- export declare type StructTypeKey = string;
1605
-
1606
- /**
1607
- * Represents a sync mapper record that links external system entities to DevRev entities.
1608
- */
1609
- declare interface SyncMapperRecord {
1610
- id: DonV2;
1611
- /** Array of external system IDs that map to the same DevRev object */
1612
- external_ids: string[];
1613
- /**
1614
- * Optional map that labels values in `external_ids` with their usage context.
1615
- * Use when an external system requires different identifiers for different API calls
1616
- * (for example, a UUID for one endpoint and a login username for another).
1617
- *
1618
- * Example:
1619
- * external_ids: ["2a1c...-uuid", "john_doe"]
1620
- * secondary_ids: { "username": "john_doe" }
1621
- *
1622
- * Note: Values in `secondary_ids` are not indexed. If you need to look up by a
1623
- * secondary value (e.g., username), you must also include that value in `external_ids`.
1624
- */
1625
- secondary_ids?: Record<string, string>;
1626
- /** Array of DevRev entity IDs this mapping points to */
1627
- targets: DonV2[];
1628
- status: SyncMapperRecordStatus;
1629
- /**
1630
- * Optional file name where the object data was found.
1631
- * Useful for debugging - helps locate the source of object data later.
1632
- */
1633
- input_files?: string[];
1634
- /**
1635
- * Records external-system changes to prevent update loops.
1636
- * When the Loader writes to the external system, store the object's
1637
- * modified_date here. During the next sync back to DevRev, if the extracted
1638
- * object's modified_date exists in this list the update is skipped (avoids
1639
- * re-applying a DevRev-originated change).
1640
- */
1641
- external_versions?: SyncMapperRecordExternalVersion[];
1642
- /**
1643
- * Free-form data storage for your use. Store any additional information here.
1644
- * Completely opaque to the platform - use however you need.
1645
- */
1646
- extra_data?: string;
1647
- }
1648
-
1649
- /**
1650
- * External version tracking to prevent update loops.
1651
- * Used to identify changes that originated from your system.
1652
- */
1653
- declare interface SyncMapperRecordExternalVersion {
1654
- /** Sync recipe version at the time the external change was written */
1655
- recipe_version: number;
1656
- /** External system modified timestamp (ISO 8601 string) used for loop detection */
1657
- modified_date: string;
1658
- }
1659
-
1660
- /**
1661
- * Status of a sync mapper record indicating its operational state.
1662
- */
1663
- export declare enum SyncMapperRecordStatus {
1664
- /** The mapping is active and operational (default) */
1665
- OPERATIONAL = "operational",
1666
- /** The mapping was filtered out by user filter settings */
1667
- FILTERED = "filtered",
1668
- /**
1669
- * The external object should be ignored in sync operations.
1670
- * Use to prevent objects from being created or updated in DevRev.
1671
- */
1672
- IGNORED = "ignored"
1673
- }
1674
-
1675
- /**
1676
- * Types of DevRev entities that can be targets in sync mapper records.
1677
- */
1678
- export declare enum SyncMapperRecordTargetType {
1679
- ACCESS_CONTROL_ENTRY = "access_control_entry",
1680
- ACCOUNT = "account",
1681
- AIRSYNC_AUTHORIZATION_POLICY = "airdrop_authorization_policy",
1682
- AIRSYNC_FIELD_AUTHORIZATION_POLICY = "airdrop_field_authorization_policy",
1683
- AIRSYNC_PLATFORM_GROUP = "airdrop_platform_group",
1684
- ARTICLE = "article",
1685
- ARTIFACT = "artifact",
1686
- CHAT = "chat",
1687
- CONVERSATION = "conversation",
1688
- CUSTOM_OBJECT = "custom_object",
1689
- DIRECTORY = "directory",
1690
- GROUP = "group",
1691
- INCIDENT = "incident",
1692
- LINK = "link",
1693
- MEETING = "meeting",
1694
- OBJECT_MEMBER = "object_member",
1695
- PART = "part",
1696
- REV_ORG = "rev_org",
1697
- ROLE = "role",
1698
- ROLE_SET = "role_set",
1699
- TAG = "tag",
1700
- TIMELINE_COMMENT = "timeline_comment",
1701
- USER = "user",
1702
- WORK = "work"
1703
- }
1704
-
1705
- /**
1706
- * SyncMode is an enum that defines the different modes of sync that can be used by the external extractor.
1707
- * It can be either INITIAL, INCREMENTAL or LOADING. INITIAL mode is used for
1708
- * the first/initial import, while INCREMENTAL mode is used for doing syncs. LOADING mode is used for
1709
- * loading data from DevRev to the external system.
1710
- */
1711
- export declare enum SyncMode {
1712
- INITIAL = "INITIAL",
1713
- INCREMENTAL = "INCREMENTAL",
1714
- LOADING = "LOADING"
1715
- }
1716
-
1717
- /**
1718
- * Target type key data for authorization policy.
1719
- */
1720
- export declare interface TargetTypeKeyData {
1721
- /** The possible record types or record type categories that can be targeted in authorization policy. */
1722
- type_keys: RecordTypeKey[];
1723
- }
1724
-
1725
- /**
1726
- * TaskAdapterInterface is the parameter shape passed to a task callback.
1727
- * @interface TaskAdapterInterface
1728
- * @constructor
1729
- * @param {BaseAdapter} adapter - The adapter object
1730
- */
1731
- export declare interface TaskAdapterInterface<Adapter extends BaseAdapter<unknown, BaseState<unknown, BaseSdkState>>> {
1732
- adapter: Adapter;
1733
- }
1734
-
1735
- /**
1736
- * Text field constraints.
1737
- */
1738
- export declare interface TextData {
1739
- min_length?: number;
1740
- max_length?: number;
1741
- }
1742
-
1743
- /**
1744
- * TimeUnit is an enum that defines the supported Go duration units for time window calculations.
1745
- * These correspond directly to Go's time.ParseDuration units.
1746
- */
1747
- export declare enum TimeUnit {
1748
- /** Nanoseconds */
1749
- NANOSECONDS = "ns",
1750
- /** Microseconds (ASCII alias) */
1751
- MICROSECONDS = "us",
1752
- /** Microseconds (Unicode alias) */
1753
- MICROSECONDS_MU = "\u00B5s",
1754
- /** Milliseconds */
1755
- MILLISECONDS = "ms",
1756
- /** Seconds */
1757
- SECONDS = "s",
1758
- /** Minutes */
1759
- MINUTES = "m",
1760
- /** Hours */
1761
- HOURS = "h"
1762
- }
1763
-
1764
- /**
1765
- * TimeValue is an interface that represents a time value used in extraction start/end times.
1766
- * It contains a type (which denotes how the value should be resolved) and an optional value.
1767
- * - For ABSOLUTE: value is an ISO 8601 timestamp
1768
- * - For *_WINDOW types: value is a Go duration string (e.g. '500ms', '30s', '5m', '2h')
1769
- * - For other types: value is not used
1770
- */
1771
- export declare interface TimeValue {
1772
- type: TimeValueType;
1773
- value?: string;
1774
- }
1775
-
1776
- /**
1777
- * TimeValueType is an enum that defines the type of a time value used in extraction start/end times.
1778
- * The platform sends these types to indicate how the extraction time should be resolved by the SDK.
1779
- */
1780
- export declare enum TimeValueType {
1781
- /** Oldest timestamp from worker state */
1782
- WORKERS_OLDEST = "workers_oldest",
1783
- /** Oldest timestamp from worker state minus a duration window */
1784
- WORKERS_OLDEST_MINUS_WINDOW = "workers_oldest_minus_window",
1785
- /** Newest timestamp from worker state */
1786
- WORKERS_NEWEST = "workers_newest",
1787
- /** Newest timestamp from worker state plus a duration window */
1788
- WORKERS_NEWEST_PLUS_WINDOW = "workers_newest_plus_window",
1789
- /** Current time */
1790
- CURRENT_TIME = "current_time",
1791
- /** User-specified absolute timestamp */
1792
- ABSOLUTE_TIME = "absolute_time",
1793
- /** No bound - extract all available data */
1794
- UNBOUNDED = "unbounded"
1795
- }
1796
-
1797
- declare interface ToDevRev {
1798
- attachmentsMetadata: {
1799
- artifactIds: string[];
1800
- lastProcessed: number;
1801
- lastProcessedAttachmentsIdsList?: ProcessedAttachment[];
1802
- };
1803
- }
1804
-
1805
- /**
1806
- * Typed reference field data specifying target record types.
1807
- */
1808
- export declare interface TypedReferenceData {
1809
- /** The record types that this reference can refer to */
1810
- refers_to: Record<RecordTypeKey, ReferenceDetail>;
1811
- /** The parent reference refers to a record that has special ownership over the child */
1812
- reference_type?: ReferenceType;
1813
- }
1814
-
1815
- /**
1816
- * Sentinel value representing an unbounded (no limit) extraction timestamp.
1817
- * Used as the resolved value for TimeValueType.UNBOUNDED, stored as workersOldest
1818
- * when the initial import has no lower time bound. The Unix epoch ensures that
1819
- * no real extraction timestamp can be earlier, preventing accidental overwrites
1820
- * of the boundary by subsequent syncs (e.g. reconciliation with absolute dates).
1821
- */
1822
- export declare const UNBOUNDED_DATE_TIME_VALUE = "1970-01-01T00:00:00.000Z";
1823
-
1824
- declare class Uploader {
1825
- private isLocalDevelopment?;
1826
- private devrevApiEndpoint;
1827
- private devrevApiToken;
1828
- private requestId;
1829
- private defaultHeaders;
1830
- private skipConfirmation;
1831
- constructor({ event, options }: UploaderFactoryInterface);
1832
- /**
1833
- * Uploads the fetched objects to the DevRev platform. Fetched objects are compressed to a gzipped jsonl object and uploaded to the platform.
1834
- * @param {string} itemType - The type of the item to be uploaded
1835
- * @param {object[] | object} fetchedObjects - The objects to be uploaded
1836
- * @returns {Promise<UploadResponse>} - The response object containing the artifact information or error information if there was an error
1837
- */
1838
- upload(itemType: string, fetchedObjects: object[] | object): Promise<UploadResponse>;
1839
- /**
1840
- * Gets the upload URL for an artifact from the DevRev API.
1841
- * @param {string} filename - The name of the file to upload
1842
- * @param {string} fileType - The MIME type of the file
1843
- * @param {number} [fileSize] - Optional file size in bytes
1844
- * @returns {Promise<ArtifactToUpload | void>} The artifact upload information or undefined on error
1845
- */
1846
- getArtifactUploadUrl(filename: string, fileType: string, fileSize?: number): Promise<UploaderResult<ArtifactToUpload>>;
1847
- /**
1848
- * Uploads an artifact file to the provided upload URL using multipart form data.
1849
- * @param {ArtifactToUpload} artifact - The artifact upload information containing upload URL and form data
1850
- * @param {Buffer} file - The file buffer to upload
1851
- * @returns {Promise<AxiosResponse | void>} The axios response or undefined on error
1852
- */
1853
- uploadArtifact(artifact: ArtifactToUpload, file: Buffer): Promise<UploaderResult<AxiosResponse>>;
1854
- /**
1855
- * Streams an artifact file from an axios response to the upload URL.
1856
- * @param {ArtifactToUpload} artifact - The artifact upload information containing upload URL and form data
1857
- * @param {AxiosResponse} fileStream - The axios response stream containing the file data
1858
- * @returns {Promise<AxiosResponse | void>} The axios response or undefined on error
1859
- */
1860
- streamArtifact(artifact: ArtifactToUpload, fileStream: AxiosResponse): Promise<UploaderResult<AxiosResponse>>;
1861
- /**
1862
- * Confirms that an artifact upload has been completed successfully.
1863
- * @param {string} artifactId - The ID of the artifact to confirm
1864
- * @returns {Promise<AxiosResponse | void>} The axios response or undefined on error
1865
- */
1866
- confirmArtifactUpload(artifactId: string): Promise<{
1867
- response?: AxiosResponse;
1868
- error?: unknown;
1869
- }>;
1870
- /**
1871
- * Destroys a stream to prevent resource leaks.
1872
- * @param {any} fileStream - The axios response stream to destroy
1873
- */
1874
- private destroyStream;
1875
- /**
1876
- * Retrieves attachment metadata from an artifact by downloading and parsing it.
1877
- * @param {object} param0 - Configuration object
1878
- * @param {string} param0.artifact - The artifact ID to download attachments from
1879
- * @returns {Promise<{attachments?: NormalizedAttachment[], error?: {message: string}}>} The attachments array or error object
1880
- */
1881
- getAttachmentsFromArtifactId({ artifact, }: {
1882
- artifact: string;
1883
- }): Promise<{
1884
- attachments?: NormalizedAttachment[];
1885
- error?: {
1886
- message: string;
1887
- };
1888
- }>;
1889
- /**
1890
- * Gets the download URL for an artifact from the DevRev API.
1891
- * @param {string} artifactId - The ID of the artifact to download
1892
- * @returns {Promise<string | void>} The download URL or undefined on error
1893
- */
1894
- private getArtifactDownloadUrl;
1895
- /**
1896
- * Downloads an artifact file from the given URL.
1897
- * @param {string} artifactUrl - The URL to download the artifact from
1898
- * @returns {Promise<Buffer | void>} The artifact file buffer or undefined on error
1899
- */
1900
- private downloadArtifact;
1901
- /**
1902
- * Retrieves and parses JSON objects from an artifact by artifact ID.
1903
- * @param {object} param0 - Configuration object
1904
- * @param {string} param0.artifactId - The artifact ID to download and parse
1905
- * @param {boolean} [param0.isGzipped=false] - Whether the artifact is gzipped
1906
- * @returns {Promise<object[] | object | void>} The parsed JSON objects or undefined on error
1907
- */
1908
- getJsonObjectByArtifactId({ artifactId, isGzipped, }: {
1909
- artifactId: string;
1910
- isGzipped?: boolean;
1911
- }): Promise<UploaderResult<object[] | object>>;
1912
- }
1913
-
1914
- declare interface UploaderFactoryInterface {
1915
- event: AirSyncEvent;
1916
- options?: WorkerAdapterOptions;
1917
- }
1918
-
1919
- /**
1920
- * Generic result type for uploader operations that can either succeed with a response or fail with an error.
1921
- * @template T The type of the successful response data
1922
- */
1923
- declare type UploaderResult<T> = {
1924
- response: T;
1925
- error?: never;
1926
- } | {
1927
- response?: never;
1928
- error: unknown;
1929
- };
1930
-
1931
- /**
1932
- * UploadResponse is an interface that defines the structure of the response from upload through Uploader.
1933
- */
1934
- export declare interface UploadResponse {
1935
- artifact?: Artifact;
1936
- error?: ErrorRecord;
1937
- }
1938
-
1939
- /**
1940
- * WorkerAdapterInterface is the constructor parameter shape for an adapter.
1941
- * @interface WorkerAdapterInterface
1942
- * @constructor
1943
- * @param {AirSyncEvent} event - The event object received from the platform
1944
- * @param {BaseState} adapterState - The state instance for the adapter
1945
- * @param {WorkerAdapterOptions} options - The options to create a new adapter
1946
- */
1947
- export declare interface WorkerAdapterInterface<ConnectorState, StateClass extends BaseState<ConnectorState, BaseSdkState>> {
1948
- event: AirSyncEvent;
1949
- adapterState: StateClass;
1950
- options?: WorkerAdapterOptions;
1951
- }
1952
-
1953
- /**
1954
- * WorkerAdapterOptions represents the options for WorkerAdapter class.
1955
- * @interface WorkerAdapterOptions
1956
- * @constructor
1957
- * @param {boolean=} isLocalDevelopment - A flag to indicate if the adapter is being used in local development
1958
- * @param {number=} timeout - The timeout for the worker thread
1959
- * @param {number=} batchSize - Maximum number of extracted items in a batch
1960
- * @param {Record<EventType, string>=} workerPathOverrides - A map of event types to custom worker paths to override default worker paths
1961
- */
1962
- export declare interface WorkerAdapterOptions {
1963
- isLocalDevelopment?: boolean;
1964
- timeout?: number;
1965
- batchSize?: number;
1966
- workerPathOverrides?: WorkerPathOverrides;
1967
- skipConfirmation?: boolean;
1968
- }
1969
-
1970
- /**
1971
- * WorkerData represents the structure of the worker data object.
1972
- */
1973
- export declare interface WorkerData<ConnectorState> {
1974
- event: AirSyncEvent;
1975
- initialState: ConnectorState;
1976
- workerPath: string;
1977
- initialDomainMapping?: InitialDomainMapping;
1978
- options?: WorkerAdapterOptions;
1979
- }
1980
-
1981
- /**
1982
- * WorkerEvent represents the standard worker events.
1983
- */
1984
- export declare enum WorkerEvent {
1985
- WorkerMessage = "message",
1986
- WorkerOnline = "online",
1987
- WorkerError = "error",
1988
- WorkerExit = "exit"
1989
- }
1990
-
1991
- /**
1992
- * WorkerMessage represents the structure of the worker message.
1993
- */
1994
- export declare type WorkerMessage = WorkerMessageEmitted | WorkerMessageExit | WorkerMessageLog | WorkerMessageFailed;
1995
-
1996
- /**
1997
- * WorkerMessageEmitted interface represents the structure of the emitted worker message.
1998
- */
1999
- export declare interface WorkerMessageEmitted {
2000
- subject: WorkerMessageSubject.WorkerMessageEmitted;
2001
- payload: {
2002
- eventType: ExtractorEventType | LoaderEventType;
2003
- };
2004
- }
2005
-
2006
- /**
2007
- * WorkerMessageExit interface represents the structure of the exit worker message.
2008
- */
2009
- export declare interface WorkerMessageExit {
2010
- subject: WorkerMessageSubject.WorkerMessageExit;
2011
- }
2012
-
2013
- /**
2014
- * WorkerMessageFailed interface represents the structure of the worker failed message.
2015
- * Sent from the worker thread before calling process.exit(1) to convey the specific
2016
- * error reason to the main thread.
2017
- */
2018
- export declare interface WorkerMessageFailed {
2019
- subject: WorkerMessageSubject.WorkerMessageFailed;
2020
- payload: {
2021
- message: string;
2022
- };
2023
- }
2024
-
2025
- /**
2026
- * WorkerMessageLog interface represents the structure of the worker log message.
2027
- */
2028
- export declare interface WorkerMessageLog {
2029
- subject: WorkerMessageSubject.WorkerMessageLog;
2030
- payload: {
2031
- stringifiedArgs: string;
2032
- level: LogLevel;
2033
- isSdkLog?: boolean;
2034
- };
2035
- }
2036
-
2037
- /**
2038
- * WorkerMessageSubject represents the handled worker message subjects.
2039
- */
2040
- export declare enum WorkerMessageSubject {
2041
- WorkerMessageEmitted = "emit",
2042
- WorkerMessageExit = "exit",
2043
- WorkerMessageLog = "log",
2044
- WorkerMessageFailed = "failed"
2045
- }
2046
-
2047
- /**
2048
- * WorkerMetadata is an interface that defines the structure of the worker metadata that is sent from the external extractor to the AirSync platform.
2049
- */
2050
- declare interface WorkerMetadata {
2051
- adaas_library_version: string;
2052
- }
2053
-
2054
- /**
2055
- * WorkerPathOverrides represents a mapping of event types to custom worker paths.
2056
- */
2057
- export declare type WorkerPathOverrides = Partial<Record<EventType, string>>;
2058
-
2059
- export { }