@devrev/airsync-sdk 2.0.0-beta.1 → 2.0.0-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -21
- package/dist/attachments-streaming/attachments-streaming-pool.d.ts +6 -7
- package/dist/attachments-streaming/attachments-streaming-pool.d.ts.map +1 -1
- package/dist/attachments-streaming/attachments-streaming-pool.interfaces.d.ts +4 -3
- package/dist/attachments-streaming/attachments-streaming-pool.interfaces.d.ts.map +1 -1
- package/dist/attachments-streaming/attachments-streaming-pool.js +69 -61
- package/dist/common/constants.d.ts +15 -12
- package/dist/common/constants.d.ts.map +1 -1
- package/dist/common/constants.js +20 -34
- package/dist/common/helpers.d.ts +3 -27
- package/dist/common/helpers.d.ts.map +1 -1
- package/dist/common/helpers.js +6 -36
- package/dist/http/client.d.ts +4 -0
- package/dist/http/client.d.ts.map +1 -0
- package/dist/http/client.js +80 -0
- package/dist/http/errors.d.ts +8 -0
- package/dist/http/errors.d.ts.map +1 -0
- package/dist/http/errors.js +31 -0
- package/dist/index.d.ts +30 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +47 -28
- package/dist/logger/logger.d.ts +13 -70
- package/dist/logger/logger.d.ts.map +1 -1
- package/dist/logger/logger.interfaces.d.ts +4 -7
- package/dist/logger/logger.interfaces.d.ts.map +1 -1
- package/dist/logger/logger.js +67 -92
- package/dist/mappers/mappers.d.ts +10 -43
- package/dist/mappers/mappers.d.ts.map +1 -1
- package/dist/mappers/mappers.interfaces.d.ts +173 -0
- package/dist/mappers/mappers.interfaces.d.ts.map +1 -0
- package/dist/mappers/{mappers.interface.js → mappers.interfaces.js} +1 -10
- package/dist/mappers/mappers.js +32 -46
- package/dist/multithreading/adapters/base-adapter.d.ts +39 -0
- package/dist/multithreading/adapters/base-adapter.d.ts.map +1 -0
- package/dist/multithreading/adapters/base-adapter.js +212 -0
- package/dist/multithreading/adapters/extraction-adapter.d.ts +49 -0
- package/dist/multithreading/adapters/extraction-adapter.d.ts.map +1 -0
- package/dist/multithreading/adapters/extraction-adapter.js +375 -0
- package/dist/multithreading/adapters/loading-adapter.d.ts +26 -0
- package/dist/multithreading/adapters/loading-adapter.d.ts.map +1 -0
- package/dist/multithreading/adapters/loading-adapter.helpers.d.ts +12 -0
- package/dist/multithreading/adapters/loading-adapter.helpers.d.ts.map +1 -0
- package/dist/multithreading/{worker-adapter/worker-adapter.helpers.js → adapters/loading-adapter.helpers.js} +2 -12
- package/dist/multithreading/adapters/loading-adapter.js +279 -0
- package/dist/multithreading/emit.d.ts +11 -0
- package/dist/multithreading/emit.d.ts.map +1 -0
- package/dist/multithreading/emit.js +25 -0
- package/dist/multithreading/process-task.d.ts +6 -1
- package/dist/multithreading/process-task.d.ts.map +1 -1
- package/dist/multithreading/process-task.js +120 -82
- package/dist/multithreading/spawn/spawn.d.ts +10 -11
- package/dist/multithreading/spawn/spawn.d.ts.map +1 -1
- package/dist/multithreading/spawn/spawn.helpers.d.ts +12 -11
- package/dist/multithreading/spawn/spawn.helpers.d.ts.map +1 -1
- package/dist/multithreading/spawn/spawn.helpers.js +142 -77
- package/dist/multithreading/spawn/spawn.js +59 -75
- package/dist/multithreading/worker.js +16 -5
- package/dist/repo/repo.d.ts +14 -5
- package/dist/repo/repo.d.ts.map +1 -1
- package/dist/repo/repo.helpers.d.ts +6 -0
- package/dist/repo/repo.helpers.d.ts.map +1 -0
- package/dist/repo/repo.helpers.js +16 -0
- package/dist/repo/repo.interfaces.d.ts +11 -20
- package/dist/repo/repo.interfaces.d.ts.map +1 -1
- package/dist/repo/repo.js +36 -22
- package/dist/state/base-state.d.ts +58 -0
- package/dist/state/base-state.d.ts.map +1 -0
- package/dist/state/base-state.js +242 -0
- package/dist/state/extraction-state.d.ts +14 -0
- package/dist/state/extraction-state.d.ts.map +1 -0
- package/dist/state/extraction-state.js +146 -0
- package/dist/state/install-initial-domain-mapping.d.ts +4 -0
- package/dist/state/install-initial-domain-mapping.d.ts.map +1 -0
- package/dist/{common → state}/install-initial-domain-mapping.js +5 -7
- package/dist/state/loading-state.d.ts +8 -0
- package/dist/state/loading-state.d.ts.map +1 -0
- package/dist/state/loading-state.js +29 -0
- package/dist/state/state.d.ts +3 -29
- package/dist/state/state.d.ts.map +1 -1
- package/dist/state/state.interfaces.d.ts +31 -12
- package/dist/state/state.interfaces.d.ts.map +1 -1
- package/dist/state/state.interfaces.js +17 -1
- package/dist/state/state.js +9 -164
- package/dist/state/time-value-resolver.d.ts +17 -0
- package/dist/state/time-value-resolver.d.ts.map +1 -0
- package/dist/state/time-value-resolver.js +110 -0
- package/dist/testing/mock-event.d.ts +10 -0
- package/dist/testing/mock-event.d.ts.map +1 -0
- package/dist/testing/mock-event.js +96 -0
- package/dist/testing/mock-server.d.ts +31 -0
- package/dist/testing/mock-server.d.ts.map +1 -0
- package/dist/testing/mock-server.interfaces.d.ts +54 -0
- package/dist/testing/mock-server.interfaces.d.ts.map +1 -0
- package/dist/testing/mock-server.interfaces.js +4 -0
- package/dist/testing/mock-server.js +297 -0
- package/dist/testing/test-adapters.d.ts +22 -0
- package/dist/testing/test-adapters.d.ts.map +1 -0
- package/dist/testing/test-adapters.js +32 -0
- package/dist/types/common.d.ts +4 -37
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/common.js +2 -17
- package/dist/types/errors.d.ts +15 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/errors.js +28 -0
- package/dist/types/external-domain-metadata.d.ts +40 -162
- package/dist/types/external-domain-metadata.d.ts.map +1 -1
- package/dist/types/extraction.d.ts +135 -278
- package/dist/types/extraction.d.ts.map +1 -1
- package/dist/types/extraction.js +46 -133
- package/dist/types/loading.d.ts +15 -55
- package/dist/types/loading.d.ts.map +1 -1
- package/dist/types/loading.js +1 -23
- package/dist/types/workers.d.ts +70 -103
- package/dist/types/workers.d.ts.map +1 -1
- package/dist/types/workers.js +1 -6
- package/dist/uploader/uploader.d.ts +10 -61
- package/dist/uploader/uploader.d.ts.map +1 -1
- package/dist/uploader/uploader.helpers.d.ts +7 -27
- package/dist/uploader/uploader.helpers.d.ts.map +1 -1
- package/dist/uploader/uploader.helpers.js +80 -30
- package/dist/uploader/uploader.interfaces.d.ts +19 -54
- package/dist/uploader/uploader.interfaces.d.ts.map +1 -1
- package/dist/uploader/uploader.interfaces.js +8 -0
- package/dist/uploader/uploader.js +72 -124
- package/docs/MIGRATION.md +751 -0
- package/package.json +35 -22
- package/dist/attachments-streaming/attachments-streaming-pool.test.d.ts +0 -2
- package/dist/attachments-streaming/attachments-streaming-pool.test.d.ts.map +0 -1
- package/dist/attachments-streaming/attachments-streaming-pool.test.js +0 -321
- package/dist/common/control-protocol.d.ts +0 -10
- package/dist/common/control-protocol.d.ts.map +0 -1
- package/dist/common/control-protocol.js +0 -31
- package/dist/common/errors.d.ts +0 -6
- package/dist/common/errors.d.ts.map +0 -1
- package/dist/common/errors.js +0 -4
- package/dist/common/event-type-translation.d.ts +0 -24
- package/dist/common/event-type-translation.d.ts.map +0 -1
- package/dist/common/event-type-translation.js +0 -117
- package/dist/common/install-initial-domain-mapping.d.ts +0 -4
- package/dist/common/install-initial-domain-mapping.d.ts.map +0 -1
- package/dist/common/install-initial-domain-mapping.test.d.ts +0 -2
- package/dist/common/install-initial-domain-mapping.test.d.ts.map +0 -1
- package/dist/common/install-initial-domain-mapping.test.js +0 -208
- package/dist/deprecated/adapter/index.d.ts +0 -62
- package/dist/deprecated/adapter/index.d.ts.map +0 -1
- package/dist/deprecated/adapter/index.js +0 -151
- package/dist/deprecated/common/helpers.d.ts +0 -7
- package/dist/deprecated/common/helpers.d.ts.map +0 -1
- package/dist/deprecated/common/helpers.js +0 -47
- package/dist/deprecated/demo-extractor/external_domain_metadata.json +0 -38
- package/dist/deprecated/demo-extractor/index.d.ts +0 -18
- package/dist/deprecated/demo-extractor/index.d.ts.map +0 -1
- package/dist/deprecated/demo-extractor/index.js +0 -161
- package/dist/deprecated/http/client.d.ts +0 -22
- package/dist/deprecated/http/client.d.ts.map +0 -1
- package/dist/deprecated/http/client.js +0 -161
- package/dist/deprecated/uploader/index.d.ts +0 -35
- package/dist/deprecated/uploader/index.d.ts.map +0 -1
- package/dist/deprecated/uploader/index.js +0 -161
- package/dist/http/axios-client-internal.d.ts +0 -3
- package/dist/http/axios-client-internal.d.ts.map +0 -1
- package/dist/http/axios-client-internal.js +0 -66
- package/dist/http/axios-client-internal.test.d.ts +0 -2
- package/dist/http/axios-client-internal.test.d.ts.map +0 -1
- package/dist/http/axios-client-internal.test.js +0 -154
- package/dist/http/axios-client.d.ts +0 -27
- package/dist/http/axios-client.d.ts.map +0 -1
- package/dist/http/axios-client.js +0 -57
- package/dist/http/constants.d.ts +0 -4
- package/dist/http/constants.d.ts.map +0 -1
- package/dist/http/constants.js +0 -6
- package/dist/http/index.d.ts +0 -3
- package/dist/http/index.d.ts.map +0 -1
- package/dist/http/index.js +0 -18
- package/dist/http/types.d.ts +0 -17
- package/dist/http/types.d.ts.map +0 -1
- package/dist/http/types.js +0 -2
- package/dist/logger/logger.constants.d.ts +0 -6
- package/dist/logger/logger.constants.d.ts.map +0 -1
- package/dist/logger/logger.constants.js +0 -13
- package/dist/logger/logger.context.d.ts +0 -58
- package/dist/logger/logger.context.d.ts.map +0 -1
- package/dist/logger/logger.context.js +0 -86
- package/dist/logger/logger.test.d.ts +0 -2
- package/dist/logger/logger.test.d.ts.map +0 -1
- package/dist/logger/logger.test.js +0 -490
- package/dist/mappers/mappers.interface.d.ts +0 -294
- package/dist/mappers/mappers.interface.d.ts.map +0 -1
- package/dist/mappers/mappers.test.d.ts +0 -2
- package/dist/mappers/mappers.test.d.ts.map +0 -1
- package/dist/mappers/mappers.test.js +0 -107
- package/dist/multithreading/create-worker.test.d.ts +0 -2
- package/dist/multithreading/create-worker.test.d.ts.map +0 -1
- package/dist/multithreading/create-worker.test.js +0 -89
- package/dist/multithreading/spawn/spawn.helpers.test.d.ts +0 -2
- package/dist/multithreading/spawn/spawn.helpers.test.d.ts.map +0 -1
- package/dist/multithreading/spawn/spawn.helpers.test.js +0 -293
- package/dist/multithreading/worker-adapter/worker-adapter.artifacts.test.d.ts +0 -2
- package/dist/multithreading/worker-adapter/worker-adapter.artifacts.test.d.ts.map +0 -1
- package/dist/multithreading/worker-adapter/worker-adapter.artifacts.test.js +0 -127
- package/dist/multithreading/worker-adapter/worker-adapter.d.ts +0 -91
- package/dist/multithreading/worker-adapter/worker-adapter.d.ts.map +0 -1
- package/dist/multithreading/worker-adapter/worker-adapter.helpers.d.ts +0 -22
- package/dist/multithreading/worker-adapter/worker-adapter.helpers.d.ts.map +0 -1
- package/dist/multithreading/worker-adapter/worker-adapter.helpers.test.d.ts +0 -2
- package/dist/multithreading/worker-adapter/worker-adapter.helpers.test.d.ts.map +0 -1
- package/dist/multithreading/worker-adapter/worker-adapter.helpers.test.js +0 -514
- package/dist/multithreading/worker-adapter/worker-adapter.js +0 -745
- package/dist/multithreading/worker-adapter/worker-adapter.test.d.ts +0 -2
- package/dist/multithreading/worker-adapter/worker-adapter.test.d.ts.map +0 -1
- package/dist/multithreading/worker-adapter/worker-adapter.test.js +0 -483
- package/dist/repo/repo.test.d.ts +0 -2
- package/dist/repo/repo.test.d.ts.map +0 -1
- package/dist/repo/repo.test.js +0 -131
- package/dist/state/state.test.d.ts +0 -2
- package/dist/state/state.test.d.ts.map +0 -1
- package/dist/state/state.test.js +0 -224
- package/dist/types/extraction.test.d.ts +0 -2
- package/dist/types/extraction.test.d.ts.map +0 -1
- package/dist/types/extraction.test.js +0 -70
- package/dist/types/index.d.ts +0 -10
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -18
- package/dist/uploader/uploader.helpers.test.d.ts +0 -2
- package/dist/uploader/uploader.helpers.test.d.ts.map +0 -1
- package/dist/uploader/uploader.helpers.test.js +0 -267
- package/dist/uploader/uploader.test.d.ts +0 -2
- package/dist/uploader/uploader.test.d.ts.map +0 -1
- package/dist/uploader/uploader.test.js +0 -589
package/dist/logger/logger.js
CHANGED
|
@@ -1,94 +1,72 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Logger = void 0;
|
|
3
|
+
exports.Logger = exports.INSPECT_OPTIONS = exports.MAX_LOG_STRING_LENGTH = void 0;
|
|
4
|
+
exports.truncateMessage = truncateMessage;
|
|
4
5
|
exports.getPrintableState = getPrintableState;
|
|
5
6
|
exports.serializeError = serializeError;
|
|
6
7
|
exports.serializeAxiosError = serializeAxiosError;
|
|
7
|
-
exports.formatAxiosError = formatAxiosError;
|
|
8
|
-
const axios_1 = require("axios");
|
|
9
8
|
const node_console_1 = require("node:console");
|
|
10
9
|
const node_util_1 = require("node:util");
|
|
11
10
|
const node_worker_threads_1 = require("node:worker_threads");
|
|
11
|
+
const axios_1 = require("axios");
|
|
12
12
|
const constants_1 = require("../common/constants");
|
|
13
13
|
const workers_1 = require("../types/workers");
|
|
14
|
-
const logger_constants_1 = require("./logger.constants");
|
|
15
|
-
const logger_context_1 = require("./logger.context");
|
|
16
14
|
const logger_interfaces_1 = require("./logger.interfaces");
|
|
15
|
+
// ── Log formatting ──
|
|
16
|
+
exports.MAX_LOG_STRING_LENGTH = 10000;
|
|
17
|
+
const MAX_LOG_DEPTH = 10;
|
|
18
|
+
const MAX_LOG_ARRAY_LENGTH = 100;
|
|
19
|
+
exports.INSPECT_OPTIONS = {
|
|
20
|
+
compact: false,
|
|
21
|
+
breakLength: Infinity,
|
|
22
|
+
depth: MAX_LOG_DEPTH,
|
|
23
|
+
maxArrayLength: MAX_LOG_ARRAY_LENGTH,
|
|
24
|
+
maxStringLength: exports.MAX_LOG_STRING_LENGTH,
|
|
25
|
+
};
|
|
26
|
+
function truncateMessage(message) {
|
|
27
|
+
if (message.length > exports.MAX_LOG_STRING_LENGTH) {
|
|
28
|
+
return `${message.substring(0, exports.MAX_LOG_STRING_LENGTH)}... ${message.length - exports.MAX_LOG_STRING_LENGTH} more characters`;
|
|
29
|
+
}
|
|
30
|
+
return message;
|
|
31
|
+
}
|
|
17
32
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
33
|
+
* Console replacement that tags every log line with the event context. Worker
|
|
34
|
+
* threads forward log lines to the main thread, because the snap-in platform
|
|
35
|
+
* only captures logs written through the main thread's console.
|
|
20
36
|
*/
|
|
21
37
|
class Logger extends node_console_1.Console {
|
|
22
38
|
constructor({ event, options }) {
|
|
23
39
|
super(process.stdout, process.stderr);
|
|
24
40
|
this.originalConsole = console;
|
|
25
41
|
this.options = options;
|
|
26
|
-
this.tags = Object.assign(Object.assign({}, event.payload.event_context), { sdk_version: constants_1.LIBRARY_VERSION
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Converts any value to a string using `util.inspect()` for complex types.
|
|
30
|
-
*
|
|
31
|
-
* @param value - The value to convert
|
|
32
|
-
* @returns String representation of the value
|
|
33
|
-
*/
|
|
42
|
+
this.tags = Object.assign(Object.assign({}, event.payload.event_context), { sdk_version: constants_1.LIBRARY_VERSION });
|
|
43
|
+
}
|
|
34
44
|
valueToString(value) {
|
|
35
45
|
if (typeof value === 'string') {
|
|
36
46
|
return value;
|
|
37
47
|
}
|
|
38
|
-
return (0, node_util_1.inspect)(value,
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
|
|
42
|
-
* Adds a suffix indicating how many characters were omitted.
|
|
43
|
-
*
|
|
44
|
-
* @param message - The message to truncate
|
|
45
|
-
* @returns Truncated message or original if within limits
|
|
46
|
-
*/
|
|
47
|
-
truncateMessage(message) {
|
|
48
|
-
if (message.length > logger_constants_1.MAX_LOG_STRING_LENGTH) {
|
|
49
|
-
return `${message.substring(0, logger_constants_1.MAX_LOG_STRING_LENGTH)}... ${message.length - logger_constants_1.MAX_LOG_STRING_LENGTH} more characters`;
|
|
50
|
-
}
|
|
51
|
-
return message;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Logs a pre-formatted message string to the console.
|
|
55
|
-
* In production mode, wraps the message with JSON formatting and event context tags.
|
|
56
|
-
* In local development mode, logs the message directly without JSON wrapping.
|
|
57
|
-
* This is useful when you need to log already-stringified content.
|
|
58
|
-
*
|
|
59
|
-
* @param message - The pre-formatted message string to log
|
|
60
|
-
* @param level - Log level (info, warn, error)
|
|
61
|
-
* @param isSdkLog - Flag indicating if the log originated from the SDK
|
|
62
|
-
*/
|
|
63
|
-
logFn(message, level, isSdkLog = (0, logger_context_1.getSdkLogContextValue)(true)) {
|
|
48
|
+
return (0, node_util_1.inspect)(value, exports.INSPECT_OPTIONS);
|
|
49
|
+
}
|
|
50
|
+
/** In production wraps the message in JSON with event context tags; in local development logs as-is. */
|
|
51
|
+
logFn(message, level) {
|
|
64
52
|
var _a;
|
|
65
53
|
if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.isLocalDevelopment) {
|
|
66
54
|
this.originalConsole[level](message);
|
|
67
55
|
return;
|
|
68
56
|
}
|
|
69
|
-
const logObject = Object.assign(
|
|
57
|
+
const logObject = Object.assign({ message }, this.tags);
|
|
70
58
|
this.originalConsole[level](JSON.stringify(logObject));
|
|
71
59
|
}
|
|
72
|
-
/**
|
|
73
|
-
* Stringifies and logs arguments to the appropriate destination.
|
|
74
|
-
* On main thread, converts arguments to strings and calls logFn.
|
|
75
|
-
* In worker threads, forwards stringified arguments to the main thread for processing.
|
|
76
|
-
* All arguments are converted to strings using util.inspect and joined with spaces.
|
|
77
|
-
*
|
|
78
|
-
* @param args - Values to log (will be stringified and truncated if needed)
|
|
79
|
-
* @param level - Log level (info, warn, error)
|
|
80
|
-
*/
|
|
81
60
|
stringifyAndLog(args, level) {
|
|
82
61
|
let stringifiedArgs = args.map((arg) => this.valueToString(arg)).join(' ');
|
|
83
|
-
stringifiedArgs =
|
|
84
|
-
const isSdkLog = (0, logger_context_1.getSdkLogContextValue)(true);
|
|
62
|
+
stringifiedArgs = truncateMessage(stringifiedArgs);
|
|
85
63
|
if (node_worker_threads_1.isMainThread) {
|
|
86
|
-
this.logFn(stringifiedArgs, level
|
|
64
|
+
this.logFn(stringifiedArgs, level);
|
|
87
65
|
}
|
|
88
66
|
else {
|
|
89
67
|
node_worker_threads_1.parentPort === null || node_worker_threads_1.parentPort === void 0 ? void 0 : node_worker_threads_1.parentPort.postMessage({
|
|
90
68
|
subject: workers_1.WorkerMessageSubject.WorkerMessageLog,
|
|
91
|
-
payload: { stringifiedArgs, level
|
|
69
|
+
payload: { stringifiedArgs, level },
|
|
92
70
|
});
|
|
93
71
|
}
|
|
94
72
|
}
|
|
@@ -106,14 +84,7 @@ class Logger extends node_console_1.Console {
|
|
|
106
84
|
}
|
|
107
85
|
}
|
|
108
86
|
exports.Logger = Logger;
|
|
109
|
-
/**
|
|
110
|
-
* Converts a state object into a printable format where arrays are summarized.
|
|
111
|
-
* Arrays show their length, first item, and last item instead of all elements.
|
|
112
|
-
* Objects are recursively processed and primitives are returned as-is.
|
|
113
|
-
*
|
|
114
|
-
* @param state - State object to convert
|
|
115
|
-
* @returns Printable representation with summarized arrays
|
|
116
|
-
*/
|
|
87
|
+
/** Summarizes arrays as `{ length, firstItem, lastItem }` instead of listing all elements. */
|
|
117
88
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
118
89
|
function getPrintableState(state) {
|
|
119
90
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -137,28 +108,43 @@ function getPrintableState(state) {
|
|
|
137
108
|
}
|
|
138
109
|
return processValue(state);
|
|
139
110
|
}
|
|
140
|
-
/**
|
|
141
|
-
* Serializes an error into a structured format.
|
|
142
|
-
* Automatically detects and formats Axios errors with HTTP details.
|
|
143
|
-
* Returns other error types as-is.
|
|
144
|
-
*
|
|
145
|
-
* @param error - Error to serialize
|
|
146
|
-
* @returns Serialized error or original if not an Axios error
|
|
147
|
-
*/
|
|
111
|
+
/** Serializes any error into a loggable string; Axios errors get HTTP details. */
|
|
148
112
|
function serializeError(error) {
|
|
149
113
|
if ((0, axios_1.isAxiosError)(error)) {
|
|
150
|
-
return serializeAxiosError(error);
|
|
114
|
+
return JSON.stringify(serializeAxiosError(error));
|
|
115
|
+
}
|
|
116
|
+
if (error instanceof Error) {
|
|
117
|
+
// Include non-default error name (e.g. TypeError) for easier debugging
|
|
118
|
+
return error.name !== 'Error'
|
|
119
|
+
? `${error.name}: ${error.message}`
|
|
120
|
+
: error.message;
|
|
151
121
|
}
|
|
152
|
-
|
|
122
|
+
if (typeof error === 'string') {
|
|
123
|
+
return error;
|
|
124
|
+
}
|
|
125
|
+
// JSON.stringify returns '{}' for objects with only non-enumerable properties
|
|
126
|
+
// Fall back to extracting own property names or String() coercion.
|
|
127
|
+
const stringified = JSON.stringify(error);
|
|
128
|
+
if (!stringified || stringified === '{}') {
|
|
129
|
+
if (error !== null && typeof error === 'object') {
|
|
130
|
+
const props = {};
|
|
131
|
+
for (const key of Object.getOwnPropertyNames(error)) {
|
|
132
|
+
props[key] = error[key];
|
|
133
|
+
}
|
|
134
|
+
const extracted = JSON.stringify(props);
|
|
135
|
+
if (extracted && extracted !== '{}') {
|
|
136
|
+
return extracted;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
try {
|
|
140
|
+
return String(error);
|
|
141
|
+
}
|
|
142
|
+
catch (_a) {
|
|
143
|
+
return '[Unserializable error]';
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return stringified;
|
|
153
147
|
}
|
|
154
|
-
/**
|
|
155
|
-
* Serializes an Axios error into a structured format with HTTP request/response details.
|
|
156
|
-
* Extracts method, URL, parameters, status code, headers, and data.
|
|
157
|
-
* Includes CORS/network failure indicator when no response is available.
|
|
158
|
-
*
|
|
159
|
-
* @param error - Axios error to serialize
|
|
160
|
-
* @returns Structured object with error details
|
|
161
|
-
*/
|
|
162
148
|
function serializeAxiosError(error) {
|
|
163
149
|
var _a, _b, _c;
|
|
164
150
|
const serializedAxiosError = {
|
|
@@ -173,7 +159,6 @@ function serializeAxiosError(error) {
|
|
|
173
159
|
if (error.response) {
|
|
174
160
|
serializedAxiosError.response = {
|
|
175
161
|
data: error.response.data,
|
|
176
|
-
headers: error.response.headers,
|
|
177
162
|
status: error.response.status,
|
|
178
163
|
statusText: error.response.statusText,
|
|
179
164
|
};
|
|
@@ -184,13 +169,3 @@ function serializeAxiosError(error) {
|
|
|
184
169
|
}
|
|
185
170
|
return serializedAxiosError;
|
|
186
171
|
}
|
|
187
|
-
/**
|
|
188
|
-
* Formats an Axios error to a printable format.
|
|
189
|
-
*
|
|
190
|
-
* @param error - Axios error to format
|
|
191
|
-
* @returns Formatted error object
|
|
192
|
-
* @deprecated Use {@link serializeAxiosError} instead
|
|
193
|
-
*/
|
|
194
|
-
function formatAxiosError(error) {
|
|
195
|
-
return serializeAxiosError(error);
|
|
196
|
-
}
|
|
@@ -1,52 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { MappersCreateParams, MappersCreateResponse, MappersFactoryInterface, MappersGetByExternalIdParams, MappersGetByExternalIdResponse, MappersGetByTargetIdParams, MappersGetByTargetIdResponse, MappersUpdateParams, MappersUpdateResponse } from './mappers.interface';
|
|
1
|
+
import { MappersCreateParams, MappersCreateResponse, MappersFactoryInterface, MappersGetByExternalIdParams, MappersGetByExternalIdResponse, MappersGetByTargetIdParams, MappersGetByTargetIdResponse, MappersUpdateParams, MappersUpdateResponse } from './mappers.interfaces';
|
|
3
2
|
/**
|
|
4
3
|
* Manages sync mapper records that link external system items to DevRev items.
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Lookups resolve to `null` when no record exists; every other failure rejects
|
|
5
|
+
* with an {@link AirSyncHttpError}.
|
|
7
6
|
*/
|
|
8
7
|
export declare class Mappers {
|
|
9
8
|
private devrevApiEndpoint;
|
|
10
9
|
private devrevApiToken;
|
|
11
10
|
constructor({ event }: MappersFactoryInterface);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
*/
|
|
20
|
-
getByTargetId(params: MappersGetByTargetIdParams): Promise<AxiosResponse<MappersGetByTargetIdResponse>>;
|
|
21
|
-
/**
|
|
22
|
-
* Retrieves a sync mapper record by external system ID.
|
|
23
|
-
*
|
|
24
|
-
* Used to find the mapping when you know the external system ID and want to find the DevRev ID.
|
|
25
|
-
*
|
|
26
|
-
* @param params - Query parameters of type MappersGetByExternalIdParams
|
|
27
|
-
* @returns Promise with response data containing the sync mapper record
|
|
28
|
-
*/
|
|
29
|
-
getByExternalId(params: MappersGetByExternalIdParams): Promise<AxiosResponse<MappersGetByExternalIdResponse>>;
|
|
30
|
-
/**
|
|
31
|
-
* Creates a new sync mapper record to establish a relationship between external system
|
|
32
|
-
* entities and DevRev entities.
|
|
33
|
-
*
|
|
34
|
-
* This is called after importing an item from external system to DevRev to record
|
|
35
|
-
* the mapping for future synchronization operations.
|
|
36
|
-
*
|
|
37
|
-
* @param params - Creation parameters of type MappersCreateParams
|
|
38
|
-
* @returns Promise with response data containing the created sync mapper record
|
|
39
|
-
*/
|
|
40
|
-
create(params: MappersCreateParams): Promise<AxiosResponse<MappersCreateResponse>>;
|
|
41
|
-
/**
|
|
42
|
-
* Updates an existing sync mapper record.
|
|
43
|
-
*
|
|
44
|
-
* Used to modify existing mappings when external system entities change or when
|
|
45
|
-
* additional DevRev entities need to be associated.
|
|
46
|
-
*
|
|
47
|
-
* @param params - Update parameters of type MappersUpdateParams
|
|
48
|
-
* @returns Promise with response data containing the updated sync mapper record
|
|
49
|
-
*/
|
|
50
|
-
update(params: MappersUpdateParams): Promise<AxiosResponse<MappersUpdateResponse>>;
|
|
11
|
+
getByTargetId(params: MappersGetByTargetIdParams): Promise<MappersGetByTargetIdResponse | null>;
|
|
12
|
+
getByExternalId(params: MappersGetByExternalIdParams): Promise<MappersGetByExternalIdResponse | null>;
|
|
13
|
+
/** Called after importing an item to DevRev to record the mapping for future syncs. */
|
|
14
|
+
create(params: MappersCreateParams): Promise<MappersCreateResponse>;
|
|
15
|
+
update(params: MappersUpdateParams): Promise<MappersUpdateResponse>;
|
|
16
|
+
private call;
|
|
17
|
+
private lookup;
|
|
51
18
|
}
|
|
52
19
|
//# sourceMappingURL=mappers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mappers.d.ts","sourceRoot":"","sources":["../../src/mappers/mappers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mappers.d.ts","sourceRoot":"","sources":["../../src/mappers/mappers.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,uBAAuB,EACvB,4BAA4B,EAC5B,8BAA8B,EAC9B,0BAA0B,EAC1B,4BAA4B,EAC5B,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,sBAAsB,CAAC;AAE9B;;;;GAIG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,iBAAiB,CAAS;IAClC,OAAO,CAAC,cAAc,CAAS;gBAEnB,EAAE,KAAK,EAAE,EAAE,uBAAuB;IAKxC,aAAa,CACjB,MAAM,EAAE,0BAA0B,GACjC,OAAO,CAAC,4BAA4B,GAAG,IAAI,CAAC;IAezC,eAAe,CACnB,MAAM,EAAE,4BAA4B,GACnC,OAAO,CAAC,8BAA8B,GAAG,IAAI,CAAC;IAejD,uFAAuF;IACjF,MAAM,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAcnE,MAAM,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,qBAAqB,CAAC;YAc3D,IAAI;YAQJ,MAAM;CAYrB"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { AirSyncEvent } from '../types/extraction';
|
|
2
|
+
import { DonV2 } from '../types/loading';
|
|
3
|
+
export interface MappersFactoryInterface {
|
|
4
|
+
event: AirSyncEvent;
|
|
5
|
+
}
|
|
6
|
+
export interface UpdateSyncMapperRecordParams {
|
|
7
|
+
external_ids: {
|
|
8
|
+
add: string[];
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Labels values in `external_ids` with their usage context (e.g. a UUID for
|
|
12
|
+
* one API call, a login username for another). Not indexed: to look up by a
|
|
13
|
+
* secondary value it must also be present in `external_ids`.
|
|
14
|
+
*/
|
|
15
|
+
secondary_ids?: Record<string, string>;
|
|
16
|
+
targets: {
|
|
17
|
+
add: DonV2[];
|
|
18
|
+
};
|
|
19
|
+
status: SyncMapperRecordStatus;
|
|
20
|
+
/** Input file name(s) containing the object data; helps later debugging. */
|
|
21
|
+
input_files?: {
|
|
22
|
+
add: string[];
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Prevents update loops: after writing the object to the external system,
|
|
26
|
+
* add its modified_date here. The Loader skips extracted updates whose
|
|
27
|
+
* modified_date is listed (the change originated in DevRev).
|
|
28
|
+
*/
|
|
29
|
+
external_versions?: {
|
|
30
|
+
add: SyncMapperRecordExternalVersion[];
|
|
31
|
+
};
|
|
32
|
+
/** Free-form storage; opaque to the platform. */
|
|
33
|
+
extra_data?: string;
|
|
34
|
+
}
|
|
35
|
+
/** Links external system entities to DevRev entities. */
|
|
36
|
+
export interface SyncMapperRecord {
|
|
37
|
+
id: DonV2;
|
|
38
|
+
external_ids: string[];
|
|
39
|
+
/**
|
|
40
|
+
* Labels values in `external_ids` with their usage context (e.g. a UUID for
|
|
41
|
+
* one API call, a login username for another). Not indexed: to look up by a
|
|
42
|
+
* secondary value it must also be present in `external_ids`.
|
|
43
|
+
*/
|
|
44
|
+
secondary_ids?: Record<string, string>;
|
|
45
|
+
targets: DonV2[];
|
|
46
|
+
status: SyncMapperRecordStatus;
|
|
47
|
+
/** Input file name(s) containing the object data; helps later debugging. */
|
|
48
|
+
input_files?: string[];
|
|
49
|
+
/**
|
|
50
|
+
* Prevents update loops: after writing the object to the external system,
|
|
51
|
+
* its modified_date is stored here. The Loader skips extracted updates whose
|
|
52
|
+
* modified_date is listed (the change originated in DevRev).
|
|
53
|
+
*/
|
|
54
|
+
external_versions?: SyncMapperRecordExternalVersion[];
|
|
55
|
+
/** Free-form storage; opaque to the platform. */
|
|
56
|
+
extra_data?: string;
|
|
57
|
+
}
|
|
58
|
+
export interface MappersGetByTargetIdParams {
|
|
59
|
+
sync_unit: DonV2;
|
|
60
|
+
target: DonV2;
|
|
61
|
+
}
|
|
62
|
+
export interface MappersGetByTargetIdResponse {
|
|
63
|
+
sync_mapper_record: SyncMapperRecord;
|
|
64
|
+
}
|
|
65
|
+
export interface MappersCreateParams {
|
|
66
|
+
sync_unit: DonV2;
|
|
67
|
+
external_ids: string[];
|
|
68
|
+
/**
|
|
69
|
+
* Labels values in `external_ids` with their usage context (e.g. a UUID for
|
|
70
|
+
* one API call, a login username for another). Not indexed: to look up by a
|
|
71
|
+
* secondary value it must also be present in `external_ids`.
|
|
72
|
+
*/
|
|
73
|
+
secondary_ids?: Record<string, string>;
|
|
74
|
+
targets: DonV2[];
|
|
75
|
+
status: SyncMapperRecordStatus;
|
|
76
|
+
/** Input file name(s) containing the object data; helps later debugging. */
|
|
77
|
+
input_files?: string[];
|
|
78
|
+
/**
|
|
79
|
+
* Prevents update loops: after writing the object to the external system,
|
|
80
|
+
* add its modified_date here. The Loader skips extracted updates whose
|
|
81
|
+
* modified_date is listed (the change originated in DevRev).
|
|
82
|
+
*/
|
|
83
|
+
external_versions?: SyncMapperRecordExternalVersion[];
|
|
84
|
+
/** Free-form storage; opaque to the platform. */
|
|
85
|
+
extra_data?: string;
|
|
86
|
+
}
|
|
87
|
+
export interface MappersCreateResponse {
|
|
88
|
+
sync_mapper_record: SyncMapperRecord;
|
|
89
|
+
}
|
|
90
|
+
export interface MappersUpdateParams {
|
|
91
|
+
id: DonV2;
|
|
92
|
+
sync_unit: DonV2;
|
|
93
|
+
external_ids: {
|
|
94
|
+
add: string[];
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Labels values in `external_ids` with their usage context (e.g. a UUID for
|
|
98
|
+
* one API call, a login username for another). Not indexed: to look up by a
|
|
99
|
+
* secondary value it must also be present in `external_ids`.
|
|
100
|
+
*/
|
|
101
|
+
secondary_ids?: Record<string, string>;
|
|
102
|
+
targets: {
|
|
103
|
+
add: DonV2[];
|
|
104
|
+
};
|
|
105
|
+
status: SyncMapperRecordStatus;
|
|
106
|
+
/** Input file name(s) containing the object data; helps later debugging. */
|
|
107
|
+
input_files?: {
|
|
108
|
+
add: string[];
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Prevents update loops: after writing the object to the external system,
|
|
112
|
+
* add its modified_date here. The Loader skips extracted updates whose
|
|
113
|
+
* modified_date is listed (the change originated in DevRev).
|
|
114
|
+
*/
|
|
115
|
+
external_versions?: {
|
|
116
|
+
add: SyncMapperRecordExternalVersion[];
|
|
117
|
+
};
|
|
118
|
+
/** Free-form storage; opaque to the platform. */
|
|
119
|
+
extra_data?: string;
|
|
120
|
+
}
|
|
121
|
+
export interface MappersUpdateResponse {
|
|
122
|
+
sync_mapper_record: SyncMapperRecord;
|
|
123
|
+
}
|
|
124
|
+
export declare enum SyncMapperRecordStatus {
|
|
125
|
+
/** The mapping is active and operational (default) */
|
|
126
|
+
OPERATIONAL = "operational",
|
|
127
|
+
/** The mapping was filtered out by user filter settings */
|
|
128
|
+
FILTERED = "filtered",
|
|
129
|
+
/** Ignore the external object in sync; prevents create/update in DevRev. */
|
|
130
|
+
IGNORED = "ignored"
|
|
131
|
+
}
|
|
132
|
+
/** Marks external changes as DevRev-originated to prevent update loops. */
|
|
133
|
+
export interface SyncMapperRecordExternalVersion {
|
|
134
|
+
/** Sync recipe version at the time the external change was written */
|
|
135
|
+
recipe_version: number;
|
|
136
|
+
/** External system modified timestamp (ISO 8601 string) used for loop detection */
|
|
137
|
+
modified_date: string;
|
|
138
|
+
}
|
|
139
|
+
export interface MappersGetByExternalIdParams {
|
|
140
|
+
sync_unit: DonV2;
|
|
141
|
+
external_id: string;
|
|
142
|
+
target_type: SyncMapperRecordTargetType;
|
|
143
|
+
}
|
|
144
|
+
export declare enum SyncMapperRecordTargetType {
|
|
145
|
+
ACCESS_CONTROL_ENTRY = "access_control_entry",
|
|
146
|
+
ACCOUNT = "account",
|
|
147
|
+
AIRDROP_AUTHORIZATION_POLICY = "airdrop_authorization_policy",
|
|
148
|
+
AIRDROP_FIELD_AUTHORIZATION_POLICY = "airdrop_field_authorization_policy",
|
|
149
|
+
AIRDROP_PLATFORM_GROUP = "airdrop_platform_group",
|
|
150
|
+
ARTICLE = "article",
|
|
151
|
+
ARTIFACT = "artifact",
|
|
152
|
+
CHAT = "chat",
|
|
153
|
+
CONVERSATION = "conversation",
|
|
154
|
+
CUSTOM_OBJECT = "custom_object",
|
|
155
|
+
DIRECTORY = "directory",
|
|
156
|
+
GROUP = "group",
|
|
157
|
+
INCIDENT = "incident",
|
|
158
|
+
LINK = "link",
|
|
159
|
+
MEETING = "meeting",
|
|
160
|
+
OBJECT_MEMBER = "object_member",
|
|
161
|
+
PART = "part",
|
|
162
|
+
REV_ORG = "rev_org",
|
|
163
|
+
ROLE = "role",
|
|
164
|
+
ROLE_SET = "role_set",
|
|
165
|
+
TAG = "tag",
|
|
166
|
+
TIMELINE_COMMENT = "timeline_comment",
|
|
167
|
+
USER = "user",
|
|
168
|
+
WORK = "work"
|
|
169
|
+
}
|
|
170
|
+
export interface MappersGetByExternalIdResponse {
|
|
171
|
+
sync_mapper_record: SyncMapperRecord;
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=mappers.interfaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mappers.interfaces.d.ts","sourceRoot":"","sources":["../../src/mappers/mappers.interfaces.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,24 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SyncMapperRecordTargetType = exports.SyncMapperRecordStatus = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Status of a sync mapper record indicating its operational state.
|
|
6
|
-
*/
|
|
7
4
|
var SyncMapperRecordStatus;
|
|
8
5
|
(function (SyncMapperRecordStatus) {
|
|
9
6
|
/** The mapping is active and operational (default) */
|
|
10
7
|
SyncMapperRecordStatus["OPERATIONAL"] = "operational";
|
|
11
8
|
/** The mapping was filtered out by user filter settings */
|
|
12
9
|
SyncMapperRecordStatus["FILTERED"] = "filtered";
|
|
13
|
-
/**
|
|
14
|
-
* The external object should be ignored in sync operations.
|
|
15
|
-
* Use to prevent objects from being created or updated in DevRev.
|
|
16
|
-
*/
|
|
10
|
+
/** Ignore the external object in sync; prevents create/update in DevRev. */
|
|
17
11
|
SyncMapperRecordStatus["IGNORED"] = "ignored";
|
|
18
12
|
})(SyncMapperRecordStatus || (exports.SyncMapperRecordStatus = SyncMapperRecordStatus = {}));
|
|
19
|
-
/**
|
|
20
|
-
* Types of DevRev entities that can be targets in sync mapper records.
|
|
21
|
-
*/
|
|
22
13
|
var SyncMapperRecordTargetType;
|
|
23
14
|
(function (SyncMapperRecordTargetType) {
|
|
24
15
|
SyncMapperRecordTargetType["ACCESS_CONTROL_ENTRY"] = "access_control_entry";
|
package/dist/mappers/mappers.js
CHANGED
|
@@ -1,83 +1,69 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Mappers = void 0;
|
|
4
|
-
const
|
|
4
|
+
const client_1 = require("../http/client");
|
|
5
|
+
const errors_1 = require("../http/errors");
|
|
5
6
|
/**
|
|
6
7
|
* Manages sync mapper records that link external system items to DevRev items.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
8
|
+
* Lookups resolve to `null` when no record exists; every other failure rejects
|
|
9
|
+
* with an {@link AirSyncHttpError}.
|
|
9
10
|
*/
|
|
10
11
|
class Mappers {
|
|
11
12
|
constructor({ event }) {
|
|
12
13
|
this.devrevApiEndpoint = event.execution_metadata.devrev_endpoint;
|
|
13
14
|
this.devrevApiToken = event.context.secrets.service_account_token;
|
|
14
15
|
}
|
|
15
|
-
/**
|
|
16
|
-
* Retrieves a sync mapper record by DevRev ID.
|
|
17
|
-
*
|
|
18
|
-
* Used to find the mapping when you know the DevRev ID and want to find the external system ID.
|
|
19
|
-
*
|
|
20
|
-
* @param params - Query parameters of type MappersGetByTargetIdParams
|
|
21
|
-
* @returns Promise with response data containing the sync mapper record
|
|
22
|
-
*/
|
|
23
16
|
async getByTargetId(params) {
|
|
24
17
|
const { sync_unit, target } = params;
|
|
25
|
-
return
|
|
18
|
+
return this.lookup(async () => client_1.axiosClient.get(`${this.devrevApiEndpoint}/internal/airdrop.sync-mapper-record.get-by-target`, {
|
|
26
19
|
headers: {
|
|
27
20
|
Authorization: this.devrevApiToken,
|
|
28
21
|
},
|
|
29
22
|
params: { sync_unit, target },
|
|
30
|
-
});
|
|
23
|
+
}));
|
|
31
24
|
}
|
|
32
|
-
/**
|
|
33
|
-
* Retrieves a sync mapper record by external system ID.
|
|
34
|
-
*
|
|
35
|
-
* Used to find the mapping when you know the external system ID and want to find the DevRev ID.
|
|
36
|
-
*
|
|
37
|
-
* @param params - Query parameters of type MappersGetByExternalIdParams
|
|
38
|
-
* @returns Promise with response data containing the sync mapper record
|
|
39
|
-
*/
|
|
40
25
|
async getByExternalId(params) {
|
|
41
26
|
const { sync_unit, external_id, target_type } = params;
|
|
42
|
-
return
|
|
27
|
+
return this.lookup(async () => client_1.axiosClient.get(`${this.devrevApiEndpoint}/internal/airdrop.sync-mapper-record.get-by-external-id`, {
|
|
43
28
|
headers: {
|
|
44
29
|
Authorization: this.devrevApiToken,
|
|
45
30
|
},
|
|
46
31
|
params: { sync_unit, external_id, target_type },
|
|
47
|
-
});
|
|
32
|
+
}));
|
|
48
33
|
}
|
|
49
|
-
/**
|
|
50
|
-
* Creates a new sync mapper record to establish a relationship between external system
|
|
51
|
-
* entities and DevRev entities.
|
|
52
|
-
*
|
|
53
|
-
* This is called after importing an item from external system to DevRev to record
|
|
54
|
-
* the mapping for future synchronization operations.
|
|
55
|
-
*
|
|
56
|
-
* @param params - Creation parameters of type MappersCreateParams
|
|
57
|
-
* @returns Promise with response data containing the created sync mapper record
|
|
58
|
-
*/
|
|
34
|
+
/** Called after importing an item to DevRev to record the mapping for future syncs. */
|
|
59
35
|
async create(params) {
|
|
60
|
-
return
|
|
36
|
+
return this.call(async () => client_1.axiosClient.post(`${this.devrevApiEndpoint}/internal/airdrop.sync-mapper-record.create`, params, {
|
|
61
37
|
headers: {
|
|
62
38
|
Authorization: this.devrevApiToken,
|
|
63
39
|
},
|
|
64
|
-
});
|
|
40
|
+
}));
|
|
65
41
|
}
|
|
66
|
-
/**
|
|
67
|
-
* Updates an existing sync mapper record.
|
|
68
|
-
*
|
|
69
|
-
* Used to modify existing mappings when external system entities change or when
|
|
70
|
-
* additional DevRev entities need to be associated.
|
|
71
|
-
*
|
|
72
|
-
* @param params - Update parameters of type MappersUpdateParams
|
|
73
|
-
* @returns Promise with response data containing the updated sync mapper record
|
|
74
|
-
*/
|
|
75
42
|
async update(params) {
|
|
76
|
-
return
|
|
43
|
+
return this.call(async () => client_1.axiosClient.post(`${this.devrevApiEndpoint}/internal/airdrop.sync-mapper-record.update`, params, {
|
|
77
44
|
headers: {
|
|
78
45
|
Authorization: this.devrevApiToken,
|
|
79
46
|
},
|
|
80
|
-
});
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
async call(request) {
|
|
50
|
+
try {
|
|
51
|
+
return (await request()).data;
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
throw (0, errors_1.toAirSyncHttpError)(error);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async lookup(request) {
|
|
58
|
+
try {
|
|
59
|
+
return (await request()).data;
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
if ((0, errors_1.isNotFound)(error)) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
throw (0, errors_1.toAirSyncHttpError)(error);
|
|
66
|
+
}
|
|
81
67
|
}
|
|
82
68
|
}
|
|
83
69
|
exports.Mappers = Mappers;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Mappers } from '../../mappers/mappers';
|
|
2
|
+
import { AirSyncEvent } from '../../types/extraction';
|
|
3
|
+
/**
|
|
4
|
+
* Shared state/behavior for both sync modes; owns the `emit` control-protocol
|
|
5
|
+
* flow as a template method with mode-specific hooks.
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class BaseAdapter<ConnectorState> {
|
|
8
|
+
readonly event: AirSyncEvent;
|
|
9
|
+
private _hasWorkerEmitted;
|
|
10
|
+
private _isTimeout;
|
|
11
|
+
private resolveTimeoutSignal;
|
|
12
|
+
private _mappers;
|
|
13
|
+
/** Sync mapper records for this event's sync unit, in both extraction and loading. */
|
|
14
|
+
get mappers(): Mappers;
|
|
15
|
+
/** Set once the soft timeout fires; the task should wrap up and return. */
|
|
16
|
+
get isTimeout(): boolean;
|
|
17
|
+
/** Connector-owned state exposed to snap-in code. */
|
|
18
|
+
get state(): ConnectorState;
|
|
19
|
+
set state(value: ConnectorState);
|
|
20
|
+
get extractionScope(): import("../../types/workers").ExtractionScope;
|
|
21
|
+
/**
|
|
22
|
+
* Persists connector and SDK state right now. State is saved on every emit
|
|
23
|
+
* anyway; call this only to record intent before an external write that
|
|
24
|
+
* must not be repeated. Throws if the save fails.
|
|
25
|
+
*/
|
|
26
|
+
postState(): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Uploads connector-owned data (e.g. state too large to keep inline) as a
|
|
29
|
+
* gzipped JSONL artifact. Unlike repo uploads it is not reported in the
|
|
30
|
+
* emitted event. Throws on failure.
|
|
31
|
+
*/
|
|
32
|
+
uploadArtifact(itemType: string, data: object[]): Promise<{
|
|
33
|
+
id: string;
|
|
34
|
+
}>;
|
|
35
|
+
/** Downloads an artifact written by {@link uploadArtifact}. Throws on failure. */
|
|
36
|
+
downloadArtifact<T = unknown>(artifactId: string): Promise<T[]>;
|
|
37
|
+
private send;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=base-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-adapter.d.ts","sourceRoot":"","sources":["../../../src/multithreading/adapters/base-adapter.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAKhD,OAAO,EACL,YAAY,EAIb,MAAM,wBAAwB,CAAC;AAYhC;;;GAGG;AACH,8BAAsB,WAAW,CAAC,cAAc;IAC9C,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAI7B,OAAO,CAAC,iBAAiB,CAAkB;IAC3C,OAAO,CAAC,UAAU,CAAkB;IACpC,OAAO,CAAC,oBAAoB,CAAc;IAU1C,OAAO,CAAC,QAAQ,CAAU;IAsB1B,sFAAsF;IACtF,IAAI,OAAO,IAAI,OAAO,CAErB;IAOD,2EAA2E;IAC3E,IAAI,SAAS,IAAI,OAAO,CAEvB;IAUD,qDAAqD;IACrD,IAAI,KAAK,IAAI,cAAc,CAE1B;IAED,IAAI,KAAK,CAAC,KAAK,EAAE,cAAc,EAE9B;IAOD,IAAI,eAAe,kDAElB;IAED;;;;OAIG;IACG,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAIhC;;;;OAIG;IACG,cAAc,CAClB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EAAE,GACb,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IAY1B,kFAAkF;IAC5E,gBAAgB,CAAC,CAAC,GAAG,OAAO,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC;YAmIvD,IAAI;CAmCnB"}
|