@devrev/ts-adaas 1.9.0-beta.0 → 1.9.0

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 (41) hide show
  1. package/dist/attachments-streaming/attachments-streaming-pool.test.js +33 -40
  2. package/dist/common/constants.d.ts +6 -1
  3. package/dist/common/constants.js +20 -9
  4. package/dist/common/control-protocol.js +2 -2
  5. package/dist/common/helpers.test.js +29 -29
  6. package/dist/common/install-initial-domain-mapping.js +4 -4
  7. package/dist/common/install-initial-domain-mapping.test.js +17 -27
  8. package/dist/deprecated/uploader/index.js +2 -2
  9. package/dist/http/axios-client-internal.d.ts +2 -0
  10. package/dist/http/axios-client-internal.js +60 -0
  11. package/dist/http/axios-client-internal.test.d.ts +1 -0
  12. package/dist/http/axios-client-internal.test.js +189 -0
  13. package/dist/logger/logger.js +1 -1
  14. package/dist/logger/logger.test.js +12 -12
  15. package/dist/mappers/mappers.js +4 -4
  16. package/dist/repo/repo.test.js +51 -37
  17. package/dist/state/state.d.ts +12 -8
  18. package/dist/state/state.interfaces.d.ts +18 -0
  19. package/dist/state/state.interfaces.js +19 -0
  20. package/dist/state/state.js +85 -67
  21. package/dist/state/state.test.d.ts +1 -0
  22. package/dist/state/state.test.js +223 -0
  23. package/dist/tests/test-helpers.js +8 -0
  24. package/dist/tests/timeout-handling/timeout-1.test.js +1 -1
  25. package/dist/tests/timeout-handling/timeout-2.test.js +1 -1
  26. package/dist/tests/timeout-handling/timeout-3a.test.js +1 -1
  27. package/dist/tests/timeout-handling/timeout-3b.test.js +1 -1
  28. package/dist/types/common.d.ts +11 -0
  29. package/dist/types/common.js +13 -1
  30. package/dist/types/extraction.d.ts +32 -9
  31. package/dist/types/extraction.js +1 -11
  32. package/dist/types/extraction.test.js +51 -5
  33. package/dist/types/index.d.ts +2 -2
  34. package/dist/types/index.js +2 -2
  35. package/dist/uploader/uploader.js +7 -7
  36. package/dist/uploader/uploader.test.js +18 -21
  37. package/dist/workers/create-worker.test.js +64 -2
  38. package/dist/workers/default-workers/attachments-extraction.js +7 -3
  39. package/dist/workers/worker-adapter.js +10 -3
  40. package/dist/workers/worker-adapter.test.js +140 -71
  41. package/package.json +3 -2
@@ -1,42 +1,51 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.State = void 0;
4
7
  exports.createAdapterState = createAdapterState;
5
- const axios_client_1 = require("../http/axios-client");
8
+ const axios_1 = __importDefault(require("axios"));
9
+ const axios_client_internal_1 = require("../http/axios-client-internal");
6
10
  const extraction_1 = require("../types/extraction");
11
+ const common_1 = require("../types/common");
7
12
  const constants_1 = require("../common/constants");
8
13
  const logger_1 = require("../logger/logger");
9
14
  const install_initial_domain_mapping_1 = require("../common/install-initial-domain-mapping");
10
15
  const helpers_1 = require("../common/helpers");
16
+ const state_interfaces_1 = require("./state.interfaces");
11
17
  async function createAdapterState({ event, initialState, initialDomainMapping, options, }) {
12
- const newInitialState = structuredClone(initialState);
18
+ // Deep clone the initial state to avoid mutating the original state
19
+ const deepCloneInitialState = structuredClone(initialState);
13
20
  const as = new State({
14
21
  event,
15
- initialState: newInitialState,
22
+ initialState: deepCloneInitialState,
16
23
  initialDomainMapping,
17
24
  options,
18
25
  });
19
26
  if (!constants_1.STATELESS_EVENT_TYPES.includes(event.payload.event_type)) {
20
- await as.fetchState(newInitialState);
27
+ await as.init(deepCloneInitialState);
21
28
  // Check if IDM needs to be updated
22
29
  const snapInVersionId = event.context.snap_in_version_id;
23
30
  const hasSnapInVersionInState = 'snapInVersionId' in as.state;
24
31
  const shouldUpdateIDM = !hasSnapInVersionInState || as.state.snapInVersionId !== snapInVersionId;
25
32
  if (!shouldUpdateIDM) {
26
- console.log(`Snap-in version in state matches the version in event context (${snapInVersionId}). Skipping initial domain mapping installation.`);
33
+ console.log(`Snap-in version in state matches the version in event context "${snapInVersionId}". Skipping initial domain mapping installation.`);
27
34
  }
28
35
  else {
29
36
  try {
37
+ console.log(`Snap-in version in state "${as.state.snapInVersionId}" does not match the version in event context "${snapInVersionId}". Installing initial domain mapping.`);
30
38
  if (initialDomainMapping) {
31
39
  await (0, install_initial_domain_mapping_1.installInitialDomainMapping)(event, initialDomainMapping);
32
40
  as.state.snapInVersionId = snapInVersionId;
33
41
  }
34
42
  else {
35
- console.warn('No initial domain mapping was passed to spawn function. Skipping initial domain mapping installation.');
43
+ throw new Error('No initial domain mapping was passed to spawn function. Skipping initial domain mapping installation.');
36
44
  }
37
45
  }
38
46
  catch (error) {
39
47
  console.error('Error while installing initial domain mapping.', (0, logger_1.serializeError)(error));
48
+ process.exit(1);
40
49
  }
41
50
  }
42
51
  // Set lastSyncStarted if the event type is ExtractionDataStart
@@ -51,29 +60,14 @@ async function createAdapterState({ event, initialState, initialDomainMapping, o
51
60
  class State {
52
61
  constructor({ event, initialState }) {
53
62
  this.initialSdkState =
54
- (0, helpers_1.getSyncDirection)({ event }) === extraction_1.SyncMode.LOADING
55
- ? {
56
- snapInVersionId: '',
57
- fromDevRev: {
58
- filesToLoad: [],
59
- },
60
- }
61
- : {
62
- lastSyncStarted: '',
63
- lastSuccessfulSyncStarted: '',
64
- snapInVersionId: '',
65
- toDevRev: {
66
- attachmentsMetadata: {
67
- artifactIds: [],
68
- lastProcessed: 0,
69
- lastProcessedAttachmentsIdsList: [],
70
- },
71
- },
72
- };
63
+ (0, helpers_1.getSyncDirection)({ event }) === common_1.SyncMode.LOADING
64
+ ? state_interfaces_1.loadingSdkState
65
+ : state_interfaces_1.extractionSdkState;
73
66
  this._state = Object.assign(Object.assign({}, initialState), this.initialSdkState);
74
- this.event = event;
75
67
  this.workerUrl = event.payload.event_context.worker_data_url;
76
68
  this.devrevToken = event.context.secrets.service_account_token;
69
+ this.syncUnitId = event.payload.event_context.sync_unit_id;
70
+ this.requestId = event.payload.event_context.request_id_adaas;
77
71
  }
78
72
  get state() {
79
73
  return this._state;
@@ -82,24 +76,67 @@ class State {
82
76
  this._state = value;
83
77
  }
84
78
  /**
85
- * Updates the state of the adapter.
86
- *
79
+ * Initializes the state for this adapter instance by fetching from API
80
+ * or creating an initial state if none exists (404).
81
+ * @param initialState The initial connector state provided by the spawn function
82
+ */
83
+ async init(initialState) {
84
+ var _a;
85
+ try {
86
+ const stringifiedState = await this.fetchState();
87
+ if (!stringifiedState) {
88
+ throw new Error('No state found in response.');
89
+ }
90
+ let parsedState;
91
+ try {
92
+ parsedState = JSON.parse(stringifiedState);
93
+ }
94
+ catch (error) {
95
+ throw new Error('Failed to parse state.');
96
+ }
97
+ this.state = parsedState;
98
+ console.log('State fetched successfully. Current state', (0, logger_1.getPrintableState)(this.state));
99
+ }
100
+ catch (error) {
101
+ if (axios_1.default.isAxiosError(error) && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 404) {
102
+ console.log('State not found. Initializing state with initial state.');
103
+ const initialAdapterState = Object.assign(Object.assign({}, initialState), this.initialSdkState);
104
+ this.state = initialAdapterState;
105
+ await this.postState(initialAdapterState);
106
+ }
107
+ else {
108
+ console.error('Failed to init state.', (0, logger_1.serializeError)(error));
109
+ process.exit(1);
110
+ }
111
+ }
112
+ }
113
+ /**
114
+ * Updates the state of the adapter by posting to API.
87
115
  * @param {object} state - The state to be updated
88
116
  */
89
117
  async postState(state) {
118
+ const url = this.workerUrl + '.update';
119
+ this.state = state || this.state;
120
+ let stringifiedState;
90
121
  try {
91
- await axios_client_1.axiosClient.post(this.workerUrl + '.update', {
92
- state: JSON.stringify(state || this.state),
122
+ stringifiedState = JSON.stringify(this.state);
123
+ }
124
+ catch (error) {
125
+ console.error('Failed to stringify state.', (0, logger_1.serializeError)(error));
126
+ process.exit(1);
127
+ }
128
+ try {
129
+ await axios_client_internal_1.axiosClient.post(url, {
130
+ state: stringifiedState,
93
131
  }, {
94
132
  headers: {
95
133
  Authorization: this.devrevToken,
96
134
  },
97
135
  params: {
98
- sync_unit: this.event.payload.event_context.sync_unit_id,
99
- request_id: this.event.payload.event_context.uuid,
136
+ sync_unit: this.syncUnitId,
137
+ request_id: this.requestId,
100
138
  },
101
139
  });
102
- this.state = state || this.state;
103
140
  console.log('State updated successfully to', (0, logger_1.getPrintableState)(this.state));
104
141
  }
105
142
  catch (error) {
@@ -108,42 +145,23 @@ class State {
108
145
  }
109
146
  }
110
147
  /**
111
- * Fetches the state of the adapter.
112
- *
113
- * @return The state of the adapter
148
+ * Fetches the state of the adapter from API.
149
+ * @return The raw state data from API
114
150
  */
115
- async fetchState(initialState) {
151
+ async fetchState() {
116
152
  var _a;
117
- console.log('Fetching state with sync unit id: ' +
118
- this.event.payload.event_context.sync_unit_id +
119
- '.');
120
- try {
121
- const response = await axios_client_1.axiosClient.get(this.workerUrl + '.get', {
122
- headers: {
123
- Authorization: this.devrevToken,
124
- },
125
- params: {
126
- sync_unit: this.event.payload.event_context.sync_unit_id,
127
- request_id: this.event.payload.event_context.uuid,
128
- },
129
- });
130
- this.state = JSON.parse(response.data.state);
131
- console.log('State fetched successfully. Current state', (0, logger_1.getPrintableState)(this.state));
132
- return this.state;
133
- }
134
- catch (error) {
135
- if (axios_client_1.axios.isAxiosError(error) && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 404) {
136
- const state = Object.assign(Object.assign({}, initialState), this.initialSdkState);
137
- this.state = state;
138
- console.log('State not found, returning initial state. Current state', (0, logger_1.getPrintableState)(this.state));
139
- await this.postState(this.state);
140
- return this.state;
141
- }
142
- else {
143
- console.error('Failed to fetch state.', error);
144
- process.exit(1);
145
- }
146
- }
153
+ console.log(`Fetching state with sync unit id ${this.syncUnitId} and request id ${this.requestId}.`);
154
+ const url = this.workerUrl + '.get';
155
+ const response = await axios_client_internal_1.axiosClient.get(url, {
156
+ headers: {
157
+ Authorization: this.devrevToken,
158
+ },
159
+ params: {
160
+ sync_unit: this.syncUnitId,
161
+ request_id: this.requestId,
162
+ },
163
+ });
164
+ return (_a = response.data) === null || _a === void 0 ? void 0 : _a.state;
147
165
  }
148
166
  }
149
167
  exports.State = State;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,223 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const state_1 = require("./state");
4
+ const extraction_1 = require("../types/extraction");
5
+ const test_helpers_1 = require("../tests/test-helpers");
6
+ const constants_1 = require("../common/constants");
7
+ const state_interfaces_1 = require("./state.interfaces");
8
+ describe(state_1.State.name, () => {
9
+ let initSpy;
10
+ let postStateSpy;
11
+ let fetchStateSpy;
12
+ let installInitialDomainMappingSpy;
13
+ let processExitSpy;
14
+ beforeEach(() => {
15
+ jest.clearAllMocks();
16
+ jest.restoreAllMocks();
17
+ initSpy = jest.spyOn(state_1.State.prototype, 'init');
18
+ postStateSpy = jest.spyOn(state_1.State.prototype, 'postState');
19
+ fetchStateSpy = jest.spyOn(state_1.State.prototype, 'fetchState');
20
+ installInitialDomainMappingSpy = jest.spyOn(require('../common/install-initial-domain-mapping'), 'installInitialDomainMapping');
21
+ processExitSpy = jest.spyOn(process, 'exit').mockImplementation(() => {
22
+ throw new Error('process.exit called');
23
+ });
24
+ });
25
+ it.each(constants_1.STATELESS_EVENT_TYPES)('should not init, fetch, post or install IDM for stateless event type %s', async (eventType) => {
26
+ // Arrange
27
+ const event = (0, test_helpers_1.createEvent)({
28
+ eventType: eventType,
29
+ });
30
+ // Act
31
+ await (0, state_1.createAdapterState)({
32
+ event,
33
+ initialState: {},
34
+ initialDomainMapping: {},
35
+ });
36
+ // Assert
37
+ expect(initSpy).not.toHaveBeenCalled();
38
+ expect(fetchStateSpy).not.toHaveBeenCalled();
39
+ expect(postStateSpy).not.toHaveBeenCalled();
40
+ expect(installInitialDomainMappingSpy).not.toHaveBeenCalled();
41
+ });
42
+ it.each(constants_1.STATEFUL_EVENT_TYPES)('should exit the process if fetching the state fails', async (eventType) => {
43
+ // Arrange
44
+ const event = (0, test_helpers_1.createEvent)({
45
+ eventType: eventType,
46
+ });
47
+ fetchStateSpy.mockRejectedValue({
48
+ isAxiosError: true,
49
+ response: { status: 500 },
50
+ });
51
+ jest.spyOn(console, 'error').mockImplementation(() => { });
52
+ // Act & Assert
53
+ await expect((0, state_1.createAdapterState)({
54
+ event,
55
+ initialState: {},
56
+ initialDomainMapping: {},
57
+ })).rejects.toThrow('process.exit called');
58
+ expect(processExitSpy).toHaveBeenCalledWith(1);
59
+ });
60
+ it.each(constants_1.STATEFUL_EVENT_TYPES)('should exit the process if parsing the state fails', async (eventType) => {
61
+ // Arrange
62
+ const event = (0, test_helpers_1.createEvent)({
63
+ eventType: eventType,
64
+ });
65
+ fetchStateSpy.mockResolvedValue('invalid-json');
66
+ jest.spyOn(console, 'error').mockImplementation(() => { });
67
+ // Act & Assert
68
+ await expect((0, state_1.createAdapterState)({
69
+ event,
70
+ initialState: {},
71
+ initialDomainMapping: {},
72
+ })).rejects.toThrow('process.exit called');
73
+ expect(processExitSpy).toHaveBeenCalledWith(1);
74
+ });
75
+ it.each(constants_1.STATEFUL_EVENT_TYPES)('should exit the process if fetching is successful but there is no state in the response', async (eventType) => {
76
+ // Arrange
77
+ const event = (0, test_helpers_1.createEvent)({
78
+ eventType: eventType,
79
+ });
80
+ fetchStateSpy.mockResolvedValue(null);
81
+ jest.spyOn(console, 'error').mockImplementation(() => { });
82
+ // Act & Assert
83
+ await expect((0, state_1.createAdapterState)({
84
+ event,
85
+ initialState: {},
86
+ initialDomainMapping: {},
87
+ })).rejects.toThrow('process.exit called');
88
+ expect(processExitSpy).toHaveBeenCalledWith(1);
89
+ });
90
+ it.each(constants_1.STATEFUL_EVENT_TYPES.filter((eventType) => eventType !== extraction_1.EventType.ExtractionDataStart))('should call post state with full adapter state if fetching returns 404 for event type %s', async (eventType) => {
91
+ // Arrange
92
+ const initialState = {
93
+ test: 'test',
94
+ };
95
+ const event = (0, test_helpers_1.createEvent)({
96
+ eventType: eventType,
97
+ contextOverrides: {
98
+ snap_in_version_id: '',
99
+ },
100
+ });
101
+ fetchStateSpy.mockRejectedValue({
102
+ isAxiosError: true,
103
+ response: { status: 404 },
104
+ });
105
+ installInitialDomainMappingSpy.mockResolvedValue({
106
+ success: true,
107
+ });
108
+ postStateSpy.mockResolvedValue({
109
+ success: true,
110
+ });
111
+ jest.spyOn(console, 'log').mockImplementation(() => { });
112
+ // Act
113
+ await (0, state_1.createAdapterState)({
114
+ event,
115
+ initialState,
116
+ initialDomainMapping: {},
117
+ });
118
+ const expectedState = Object.assign(Object.assign({}, initialState), state_interfaces_1.extractionSdkState);
119
+ expect(postStateSpy).toHaveBeenCalledWith(expectedState);
120
+ });
121
+ it(extraction_1.EventType.ExtractionDataStart, async () => {
122
+ // Arrange
123
+ const initialState = {
124
+ test: 'test',
125
+ };
126
+ const event = (0, test_helpers_1.createEvent)({
127
+ eventType: extraction_1.EventType.ExtractionDataStart,
128
+ contextOverrides: {
129
+ snap_in_version_id: '',
130
+ },
131
+ });
132
+ fetchStateSpy.mockRejectedValue({
133
+ isAxiosError: true,
134
+ response: { status: 404 },
135
+ });
136
+ installInitialDomainMappingSpy.mockResolvedValue({
137
+ success: true,
138
+ });
139
+ postStateSpy.mockResolvedValue({
140
+ success: true,
141
+ });
142
+ jest.spyOn(console, 'log').mockImplementation(() => { });
143
+ // Act
144
+ await (0, state_1.createAdapterState)({
145
+ event,
146
+ initialState,
147
+ initialDomainMapping: {},
148
+ });
149
+ // Assert
150
+ // Verify that post state is called with object that contains
151
+ // lastSyncStarted which is not empty string
152
+ expect(postStateSpy).toHaveBeenCalledWith(expect.objectContaining({
153
+ lastSyncStarted: expect.not.stringMatching(/^$/),
154
+ }));
155
+ });
156
+ it.each(constants_1.STATEFUL_EVENT_TYPES)('should exit the process if initialDomainMapping is not provided for event type %s', async (eventType) => {
157
+ // Arrange
158
+ const event = (0, test_helpers_1.createEvent)({
159
+ eventType: eventType,
160
+ });
161
+ fetchStateSpy.mockResolvedValue(JSON.stringify({
162
+ test: 'test',
163
+ }));
164
+ jest.spyOn(console, 'log').mockImplementation(() => { });
165
+ jest.spyOn(console, 'error').mockImplementation(() => { });
166
+ // Act & Assert
167
+ await expect((0, state_1.createAdapterState)({
168
+ event,
169
+ initialState: {},
170
+ initialDomainMapping: undefined,
171
+ })).rejects.toThrow('process.exit called');
172
+ expect(processExitSpy).toHaveBeenCalledWith(1);
173
+ });
174
+ it.each(constants_1.STATEFUL_EVENT_TYPES)('should not install IDM if version matches for event type %s', async (eventType) => {
175
+ // Arrange
176
+ const event = (0, test_helpers_1.createEvent)({
177
+ eventType: eventType,
178
+ contextOverrides: {
179
+ snap_in_version_id: '1.0.0',
180
+ },
181
+ });
182
+ const stringifiedState = JSON.stringify({
183
+ test: 'test',
184
+ snapInVersionId: '1.0.0',
185
+ });
186
+ fetchStateSpy.mockResolvedValue(stringifiedState);
187
+ jest.spyOn(console, 'log').mockImplementation(() => { });
188
+ // Act & Assert
189
+ await (0, state_1.createAdapterState)({
190
+ event,
191
+ initialState: {},
192
+ initialDomainMapping: {},
193
+ });
194
+ // Assert
195
+ expect(installInitialDomainMappingSpy).not.toHaveBeenCalled();
196
+ });
197
+ it.each(constants_1.STATEFUL_EVENT_TYPES)('should install IDM if version does not match for event type %s', async (eventType) => {
198
+ // Arrange
199
+ const event = (0, test_helpers_1.createEvent)({
200
+ eventType: eventType,
201
+ contextOverrides: {
202
+ snap_in_version_id: '2.0.0',
203
+ },
204
+ });
205
+ const stringifiedState = JSON.stringify({
206
+ test: 'test',
207
+ snapInVersionId: '1.0.0',
208
+ });
209
+ fetchStateSpy.mockResolvedValue(stringifiedState);
210
+ installInitialDomainMappingSpy.mockResolvedValue({
211
+ success: true,
212
+ });
213
+ jest.spyOn(console, 'log').mockImplementation(() => { });
214
+ // Act
215
+ await (0, state_1.createAdapterState)({
216
+ event,
217
+ initialState: {},
218
+ initialDomainMapping: {},
219
+ });
220
+ // Assert
221
+ expect(installInitialDomainMappingSpy).toHaveBeenCalled();
222
+ });
223
+ });
@@ -10,17 +10,25 @@ function createEvent({ eventType, externalSyncUnits = [], progress, error, delay
10
10
  const defaultEventContext = {
11
11
  callback_url: 'test_callback_url',
12
12
  dev_org: 'test_dev_org',
13
+ dev_oid: 'test_dev_oid',
13
14
  dev_org_id: 'test_dev_org_id',
14
15
  dev_user: 'test_dev_user',
15
16
  dev_user_id: 'test_dev_user_id',
17
+ dev_uid: 'test_dev_uid',
18
+ event_type_adaas: 'test_event_type_adaas',
16
19
  external_sync_unit: 'test_external_sync_unit',
17
20
  external_sync_unit_id: 'test_external_sync_unit_id',
18
21
  external_sync_unit_name: 'test_external_sync_unit_name',
19
22
  external_system: 'test_external_system',
23
+ external_system_id: 'test_external_system_id',
24
+ external_system_name: 'test_external_system_name',
20
25
  external_system_type: 'test_external_system_type',
21
26
  import_slug: 'test_import_slug',
22
27
  mode: 'test_mode',
23
28
  request_id: 'test_request_id',
29
+ request_id_adaas: 'test_request_id_adaas',
30
+ run_id: 'test_run_id',
31
+ sequence_version: 'test_sequence_version',
24
32
  snap_in_slug: 'test_snap_in_slug',
25
33
  snap_in_version_id: 'test_snap_in_version_id',
26
34
  sync_run: 'test_sync_run',
@@ -7,7 +7,7 @@ const extraction_1 = require("../../types/extraction");
7
7
  const test_helpers_1 = require("../test-helpers");
8
8
  const extraction_2 = __importDefault(require("./extraction"));
9
9
  const mock_server_1 = require("../mock-server");
10
- describe('timeout-1', () => {
10
+ describe('timeout-1 extraction', () => {
11
11
  let mockServer;
12
12
  beforeAll(async () => {
13
13
  mockServer = new mock_server_1.MockServer(3001);
@@ -8,7 +8,7 @@ const test_helpers_1 = require("../test-helpers");
8
8
  const extraction_2 = __importDefault(require("./extraction"));
9
9
  const mock_server_1 = require("../mock-server");
10
10
  jest.setTimeout(15000);
11
- describe('timeout-2', () => {
11
+ describe('timeout-2 extraction', () => {
12
12
  let mockServer;
13
13
  beforeAll(async () => {
14
14
  mockServer = new mock_server_1.MockServer(3001);
@@ -8,7 +8,7 @@ const test_helpers_1 = require("../test-helpers");
8
8
  const extraction_2 = __importDefault(require("./extraction"));
9
9
  const mock_server_1 = require("../mock-server");
10
10
  jest.setTimeout(15000);
11
- describe('timeout-3a', () => {
11
+ describe('timeout-3a extraction', () => {
12
12
  let mockServer;
13
13
  beforeAll(async () => {
14
14
  mockServer = new mock_server_1.MockServer(3001);
@@ -8,7 +8,7 @@ const test_helpers_1 = require("../test-helpers");
8
8
  const extraction_2 = __importDefault(require("./extraction"));
9
9
  const mock_server_1 = require("../mock-server");
10
10
  jest.setTimeout(15000);
11
- describe('timeout-3b', () => {
11
+ describe('timeout-3b extraction', () => {
12
12
  let mockServer;
13
13
  beforeAll(async () => {
14
14
  mockServer = new mock_server_1.MockServer(3001);
@@ -36,3 +36,14 @@ export interface InitialDomainMapping {
36
36
  starting_recipe_blueprint?: object;
37
37
  additional_mappings?: object;
38
38
  }
39
+ /**
40
+ * SyncMode is an enum that defines the different modes of sync that can be used by the external extractor.
41
+ * It can be either INITIAL, INCREMENTAL or LOADING. INITIAL mode is used for
42
+ * the first/initial import, while INCREMENTAL mode is used for doing syncs. LOADING mode is used for
43
+ * loading data from DevRev to the external system.
44
+ */
45
+ export declare enum SyncMode {
46
+ INITIAL = "INITIAL",
47
+ INCREMENTAL = "INCREMENTAL",
48
+ LOADING = "LOADING"
49
+ }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ErrorLevel = void 0;
3
+ exports.SyncMode = exports.ErrorLevel = void 0;
4
4
  /**
5
5
  * ErrorLevel is an enum that represents the level of an error.
6
6
  * @deprecated
@@ -11,3 +11,15 @@ var ErrorLevel;
11
11
  ErrorLevel["Error"] = "ERROR";
12
12
  ErrorLevel["Info"] = "INFO";
13
13
  })(ErrorLevel || (exports.ErrorLevel = ErrorLevel = {}));
14
+ /**
15
+ * SyncMode is an enum that defines the different modes of sync that can be used by the external extractor.
16
+ * It can be either INITIAL, INCREMENTAL or LOADING. INITIAL mode is used for
17
+ * the first/initial import, while INCREMENTAL mode is used for doing syncs. LOADING mode is used for
18
+ * loading data from DevRev to the external system.
19
+ */
20
+ var SyncMode;
21
+ (function (SyncMode) {
22
+ SyncMode["INITIAL"] = "INITIAL";
23
+ SyncMode["INCREMENTAL"] = "INCREMENTAL";
24
+ SyncMode["LOADING"] = "LOADING";
25
+ })(SyncMode || (exports.SyncMode = SyncMode = {}));
@@ -57,15 +57,6 @@ export declare enum ExtractionMode {
57
57
  INITIAL = "INITIAL",
58
58
  INCREMENTAL = "INCREMENTAL"
59
59
  }
60
- /**
61
- * ExtractionMode is an enum that defines the different modes of extraction that can be used by the external extractor.
62
- * It can be either INITIAL or INCREMENTAL. INITIAL mode is used for the first/initial import, while INCREMENTAL mode is used for doing syncs.
63
- */
64
- export declare enum SyncMode {
65
- INITIAL = "INITIAL",
66
- INCREMENTAL = "INCREMENTAL",
67
- LOADING = "LOADING"
68
- }
69
60
  /**
70
61
  * ExternalSyncUnit is an interface that defines the structure of an external sync unit (repos, projects, ...) that can be extracted.
71
62
  * It must contain an ID, a name, and a description. It can also contain the number of items in the external sync unit.
@@ -125,32 +116,64 @@ export interface EventContextOut {
125
116
  */
126
117
  export interface EventContext {
127
118
  callback_url: string;
119
+ /**
120
+ * @deprecated dev_org is deprecated and should not be used. Use dev_oid instead.
121
+ */
128
122
  dev_org: string;
123
+ dev_oid: string;
129
124
  dev_org_id: string;
125
+ /**
126
+ * @deprecated dev_user is deprecated and should not be used. Use dev_uid instead.
127
+ */
130
128
  dev_user: string;
129
+ /**
130
+ * @deprecated dev_user_id is deprecated and should not be used. Use dev_uid instead.
131
+ */
131
132
  dev_user_id: string;
133
+ dev_uid: string;
134
+ event_type_adaas: string;
135
+ /**
136
+ * @deprecated external_sync_unit is deprecated and should not be used. Use external_sync_unit_id instead.
137
+ */
132
138
  external_sync_unit: string;
133
139
  external_sync_unit_id: string;
134
140
  external_sync_unit_name: string;
141
+ /**
142
+ * @deprecated external_system is deprecated and should not be used. Use external_system_id instead.
143
+ */
135
144
  external_system: string;
145
+ external_system_id: string;
146
+ external_system_name: string;
136
147
  external_system_type: string;
137
148
  extract_from?: string;
138
149
  import_slug: string;
139
150
  initial_sync_scope?: InitialSyncScope;
140
151
  mode: string;
141
152
  request_id: string;
153
+ request_id_adaas: string;
142
154
  /**
143
155
  * @deprecated reset_extraction is deprecated and should not be used. Use reset_extract_from instead.
144
156
  */
145
157
  reset_extraction?: boolean;
146
158
  reset_extract_from?: boolean;
159
+ run_id: string;
160
+ sequence_version: string;
147
161
  snap_in_slug: string;
148
162
  snap_in_version_id: string;
163
+ /**
164
+ * @deprecated sync_run is deprecated and should not be used. Use run_id instead.
165
+ */
149
166
  sync_run: string;
167
+ /**
168
+ * @deprecated sync_run_id is deprecated and should not be used. Use run_id instead.
169
+ */
150
170
  sync_run_id: string;
151
171
  sync_tier: string;
152
172
  sync_unit: DonV2;
153
173
  sync_unit_id: string;
174
+ /**
175
+ * @deprecated uuid is deprecated and should not be used. Use request_id_adaas instead.
176
+ */
154
177
  uuid: string;
155
178
  worker_data_url: string;
156
179
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InitialSyncScope = exports.SyncMode = exports.ExtractionMode = exports.ExtractorEventType = exports.EventType = void 0;
3
+ exports.InitialSyncScope = exports.ExtractionMode = exports.ExtractorEventType = exports.EventType = void 0;
4
4
  /**
5
5
  * EventType is an enum that defines the different types of events that can be sent to the external extractor from ADaaS.
6
6
  * The external extractor can use these events to know what to do next in the extraction process.
@@ -60,16 +60,6 @@ var ExtractionMode;
60
60
  ExtractionMode["INITIAL"] = "INITIAL";
61
61
  ExtractionMode["INCREMENTAL"] = "INCREMENTAL";
62
62
  })(ExtractionMode || (exports.ExtractionMode = ExtractionMode = {}));
63
- /**
64
- * ExtractionMode is an enum that defines the different modes of extraction that can be used by the external extractor.
65
- * It can be either INITIAL or INCREMENTAL. INITIAL mode is used for the first/initial import, while INCREMENTAL mode is used for doing syncs.
66
- */
67
- var SyncMode;
68
- (function (SyncMode) {
69
- SyncMode["INITIAL"] = "INITIAL";
70
- SyncMode["INCREMENTAL"] = "INCREMENTAL";
71
- SyncMode["LOADING"] = "LOADING";
72
- })(SyncMode || (exports.SyncMode = SyncMode = {}));
73
63
  /**
74
64
  * InitialSyncScope is an enum that defines the different scopes of initial sync that can be used by the external extractor.
75
65
  */