@devrev/airsync-sdk 2.0.0-beta.1 → 2.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -21
- package/dist/attachments-streaming/attachments-streaming-pool.d.ts +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/{axios-client-internal.d.ts → client.d.ts} +1 -1
- package/dist/http/client.d.ts.map +1 -0
- package/dist/http/{axios-client-internal.js → client.js} +7 -4
- package/dist/http/errors.d.ts +8 -0
- package/dist/http/errors.d.ts.map +1 -0
- package/dist/http/errors.js +31 -0
- package/dist/index.d.ts +30 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +47 -28
- package/dist/logger/logger.d.ts +13 -70
- package/dist/logger/logger.d.ts.map +1 -1
- package/dist/logger/logger.interfaces.d.ts +4 -7
- package/dist/logger/logger.interfaces.d.ts.map +1 -1
- package/dist/logger/logger.js +67 -92
- package/dist/mappers/mappers.d.ts +10 -43
- package/dist/mappers/mappers.d.ts.map +1 -1
- package/dist/mappers/mappers.interfaces.d.ts +173 -0
- package/dist/mappers/mappers.interfaces.d.ts.map +1 -0
- package/dist/mappers/{mappers.interface.js → mappers.interfaces.js} +1 -10
- package/dist/mappers/mappers.js +32 -46
- package/dist/multithreading/adapters/base-adapter.d.ts +39 -0
- package/dist/multithreading/adapters/base-adapter.d.ts.map +1 -0
- package/dist/multithreading/adapters/base-adapter.js +212 -0
- package/dist/multithreading/adapters/extraction-adapter.d.ts +49 -0
- package/dist/multithreading/adapters/extraction-adapter.d.ts.map +1 -0
- package/dist/multithreading/adapters/extraction-adapter.js +375 -0
- package/dist/multithreading/adapters/loading-adapter.d.ts +26 -0
- package/dist/multithreading/adapters/loading-adapter.d.ts.map +1 -0
- package/dist/multithreading/adapters/loading-adapter.helpers.d.ts +12 -0
- package/dist/multithreading/adapters/loading-adapter.helpers.d.ts.map +1 -0
- package/dist/multithreading/{worker-adapter/worker-adapter.helpers.js → adapters/loading-adapter.helpers.js} +2 -12
- package/dist/multithreading/adapters/loading-adapter.js +279 -0
- package/dist/multithreading/emit.d.ts +11 -0
- package/dist/multithreading/emit.d.ts.map +1 -0
- package/dist/multithreading/emit.js +25 -0
- package/dist/multithreading/process-task.d.ts +6 -1
- package/dist/multithreading/process-task.d.ts.map +1 -1
- package/dist/multithreading/process-task.js +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 +140 -0
- package/dist/state/install-initial-domain-mapping.d.ts +4 -0
- package/dist/state/install-initial-domain-mapping.d.ts.map +1 -0
- package/dist/{common → state}/install-initial-domain-mapping.js +5 -7
- package/dist/state/loading-state.d.ts +8 -0
- package/dist/state/loading-state.d.ts.map +1 -0
- package/dist/state/loading-state.js +29 -0
- package/dist/state/state.d.ts +3 -29
- package/dist/state/state.d.ts.map +1 -1
- package/dist/state/state.interfaces.d.ts +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 +696 -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.map +0 -1
- package/dist/http/axios-client-internal.test.d.ts +0 -2
- package/dist/http/axios-client-internal.test.d.ts.map +0 -1
- package/dist/http/axios-client-internal.test.js +0 -154
- package/dist/http/axios-client.d.ts +0 -27
- package/dist/http/axios-client.d.ts.map +0 -1
- package/dist/http/axios-client.js +0 -57
- package/dist/http/constants.d.ts +0 -4
- package/dist/http/constants.d.ts.map +0 -1
- package/dist/http/constants.js +0 -6
- package/dist/http/index.d.ts +0 -3
- package/dist/http/index.d.ts.map +0 -1
- package/dist/http/index.js +0 -18
- package/dist/http/types.d.ts +0 -17
- package/dist/http/types.d.ts.map +0 -1
- package/dist/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
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AirSyncHttpError = void 0;
|
|
7
|
+
exports.toAirSyncHttpError = toAirSyncHttpError;
|
|
8
|
+
exports.isNotFound = isNotFound;
|
|
9
|
+
const axios_1 = __importDefault(require("axios"));
|
|
10
|
+
/** Rejection for failed SDK calls to the DevRev platform. */
|
|
11
|
+
class AirSyncHttpError extends Error {
|
|
12
|
+
constructor(message, status) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.name = 'AirSyncHttpError';
|
|
15
|
+
this.status = status;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.AirSyncHttpError = AirSyncHttpError;
|
|
19
|
+
function toAirSyncHttpError(error) {
|
|
20
|
+
var _a, _b, _c, _d, _e, _f;
|
|
21
|
+
if (axios_1.default.isAxiosError(error)) {
|
|
22
|
+
const status = (_a = error.response) === null || _a === void 0 ? void 0 : _a.status;
|
|
23
|
+
const target = `${(_d = (_c = (_b = error.config) === null || _b === void 0 ? void 0 : _b.method) === null || _c === void 0 ? void 0 : _c.toUpperCase()) !== null && _d !== void 0 ? _d : 'REQUEST'} ${(_f = (_e = error.config) === null || _e === void 0 ? void 0 : _e.url) !== null && _f !== void 0 ? _f : ''}`.trim();
|
|
24
|
+
return new AirSyncHttpError(`${target} failed${status ? ` with status ${status}` : ''}: ${error.message}`, status);
|
|
25
|
+
}
|
|
26
|
+
return new AirSyncHttpError(error instanceof Error ? error.message : String(error));
|
|
27
|
+
}
|
|
28
|
+
function isNotFound(error) {
|
|
29
|
+
var _a;
|
|
30
|
+
return axios_1.default.isAxiosError(error) && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 404;
|
|
31
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,32 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export * from './http';
|
|
6
|
-
export * from './types';
|
|
7
|
-
export * from './common/install-initial-domain-mapping';
|
|
8
|
-
export { ExtractionCommonError } from './common/errors';
|
|
9
|
-
export { processTask } from './multithreading/process-task';
|
|
1
|
+
export type { BaseAdapter } from './multithreading/adapters/base-adapter';
|
|
2
|
+
export type { ExtractionAdapter } from './multithreading/adapters/extraction-adapter';
|
|
3
|
+
export type { LoadingAdapter } from './multithreading/adapters/loading-adapter';
|
|
4
|
+
export { processExtractionTask, processLoadingTask, } from './multithreading/process-task';
|
|
10
5
|
export { spawn } from './multithreading/spawn/spawn';
|
|
11
|
-
export {
|
|
12
|
-
export
|
|
13
|
-
export {
|
|
6
|
+
export type { Repo } from './repo/repo';
|
|
7
|
+
export type { ExtractionScope, ProcessTaskInterface, RepoOptions, SpawnFactoryInterface, SpawnOptions, TaskAdapterInterface, TaskResult, TaskStatus, WorkerPathOverrides, } from './types/workers';
|
|
8
|
+
export { AirSyncDefaultItemTypes, UNBOUNDED_DATE_TIME_VALUE, } from './common/constants';
|
|
9
|
+
export { AirSyncErrorCode } from './types/errors';
|
|
10
|
+
export { installInitialDomainMapping } from './state/install-initial-domain-mapping';
|
|
11
|
+
export { AirSyncHttpError } from './http/errors';
|
|
12
|
+
export { serializeError } from './logger/logger';
|
|
13
|
+
export type { ErrorRecord, InitialDomainMapping } from './types/common';
|
|
14
|
+
export { SyncMode } from './types/common';
|
|
15
|
+
export type { AirSyncEvent, AirSyncMessage, ConnectionData, EventContext, EventData, ExternalProcessAttachmentFunction, ExternalSyncUnit, ExternalSystemAttachmentIteratorFunction, ExternalSystemAttachmentProcessors, ExternalSystemAttachmentReducerFunction, ExternalSystemAttachmentStreamingFunction, ExternalSystemAttachmentStreamingParams, ExternalSystemAttachmentStreamingResponse, ExtractorEvent, HttpStreamResponse, InputData, ItemTypeCount, ProcessAttachmentReturnType, TimeValue, WorkerMetadata, } from './types/extraction';
|
|
16
|
+
export { EventType, InitialSyncScope, ItemInputType, TimeUnit, TimeValueType, } from './types/extraction';
|
|
17
|
+
export type { ExternalSystemAttachment, ExternalSystemItem, ExternalSystemItemLoadingParams, ExternalSystemItemLoadingResponse, ExternalSystemLoadingFunction, FileToLoad, ItemTypesToLoadParams, ItemTypeToLoad, LoaderReport, } from './types/loading';
|
|
18
|
+
export { ActionType } from './types/loading';
|
|
19
|
+
export type { Item, NormalizedAttachment, NormalizedItem, RepoInterface, } from './repo/repo.interfaces';
|
|
20
|
+
export { Mappers } from './mappers/mappers';
|
|
21
|
+
export type { MappersCreateParams, MappersCreateResponse, MappersFactoryInterface, MappersGetByExternalIdParams, MappersGetByExternalIdResponse, MappersGetByTargetIdParams, MappersGetByTargetIdResponse, MappersUpdateParams, MappersUpdateResponse, SyncMapperRecord, SyncMapperRecordExternalVersion, UpdateSyncMapperRecordParams, } from './mappers/mappers.interfaces';
|
|
22
|
+
export { SyncMapperRecordStatus, SyncMapperRecordTargetType, } from './mappers/mappers.interfaces';
|
|
23
|
+
export type { Artifact, SsorAttachment, UploadResponse, } from './uploader/uploader.interfaces';
|
|
24
|
+
export { ArtifactDateField } from './uploader/uploader.interfaces';
|
|
25
|
+
export type { Attachments, CollectionData, ConditionalPrivilegeData, CustomLinkData, CustomLinkNames, CustomStage, CustomState, EnumData, EnumValue, EnumValueKey, ExternalDomainMetadata, Field, FieldCondition, FieldConditionComparator, FieldConditionEffect, FieldConditions, FieldKey, FieldPrivilegeData, FieldReferenceData, FieldType, FloatData, IntData, ParticipationData, PermissionData, RecordType, RecordTypeCategory, RecordTypeCategoryKey, RecordTypeKey, RecordTypePrivilegeData, RecordTypeScope, ReferenceData, ReferenceDetail, ReferenceType, SchemaVersion, StageDiagram, StageKey, StateKey, StructData, StructType, StructTypeKey, TargetTypeKeyData, TextData, TypedReferenceData, } from './types/external-domain-metadata';
|
|
26
|
+
export type { DeepPartial } from './testing/mock-event';
|
|
27
|
+
export { createMockEvent } from './testing/mock-event';
|
|
28
|
+
export { MOCK_SERVER_DEFAULT_URL, MockServer } from './testing/mock-server';
|
|
29
|
+
export type { RequestInfo, RetryConfig, RouteConfig, } from './testing/mock-server.interfaces';
|
|
30
|
+
export type { TestAdapterParams, TestLoadingAdapterParams, } from './testing/test-adapters';
|
|
31
|
+
export { createTestExtractionAdapter, createTestLoadingAdapter, } from './testing/test-adapters';
|
|
14
32
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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"}
|
package/dist/index.js
CHANGED
|
@@ -1,34 +1,53 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
2
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
3
|
+
// Public API barrel for @devrev/airsync-sdk. Single source of the public
|
|
4
|
+
// surface: every export is named explicitly (no `export *`), so any public API
|
|
5
|
+
// change shows up as a diff here.
|
|
6
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
16
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
18
|
-
__exportStar(require("./deprecated/adapter"), exports);
|
|
19
|
-
__exportStar(require("./deprecated/demo-extractor"), exports);
|
|
20
|
-
__exportStar(require("./deprecated/http/client"), exports);
|
|
21
|
-
__exportStar(require("./deprecated/uploader"), exports);
|
|
22
|
-
__exportStar(require("./http"), exports);
|
|
23
|
-
__exportStar(require("./types"), exports);
|
|
24
|
-
__exportStar(require("./common/install-initial-domain-mapping"), exports);
|
|
8
|
+
exports.createTestLoadingAdapter = exports.createTestExtractionAdapter = exports.MockServer = exports.MOCK_SERVER_DEFAULT_URL = exports.createMockEvent = exports.ArtifactDateField = exports.SyncMapperRecordTargetType = exports.SyncMapperRecordStatus = exports.Mappers = exports.ActionType = exports.TimeValueType = exports.TimeUnit = exports.ItemInputType = exports.InitialSyncScope = exports.EventType = exports.SyncMode = exports.serializeError = exports.AirSyncHttpError = exports.installInitialDomainMapping = exports.AirSyncErrorCode = exports.UNBOUNDED_DATE_TIME_VALUE = exports.AirSyncDefaultItemTypes = exports.spawn = exports.processLoadingTask = exports.processExtractionTask = void 0;
|
|
25
9
|
var process_task_1 = require("./multithreading/process-task");
|
|
26
|
-
Object.defineProperty(exports, "
|
|
10
|
+
Object.defineProperty(exports, "processExtractionTask", { enumerable: true, get: function () { return process_task_1.processExtractionTask; } });
|
|
11
|
+
Object.defineProperty(exports, "processLoadingTask", { enumerable: true, get: function () { return process_task_1.processLoadingTask; } });
|
|
27
12
|
var spawn_1 = require("./multithreading/spawn/spawn");
|
|
28
13
|
Object.defineProperty(exports, "spawn", { enumerable: true, get: function () { return spawn_1.spawn; } });
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
14
|
+
// ── Constants & enums ──
|
|
15
|
+
var constants_1 = require("./common/constants");
|
|
16
|
+
Object.defineProperty(exports, "AirSyncDefaultItemTypes", { enumerable: true, get: function () { return constants_1.AirSyncDefaultItemTypes; } });
|
|
17
|
+
Object.defineProperty(exports, "UNBOUNDED_DATE_TIME_VALUE", { enumerable: true, get: function () { return constants_1.UNBOUNDED_DATE_TIME_VALUE; } });
|
|
18
|
+
var errors_1 = require("./types/errors");
|
|
19
|
+
Object.defineProperty(exports, "AirSyncErrorCode", { enumerable: true, get: function () { return errors_1.AirSyncErrorCode; } });
|
|
20
|
+
// ── Domain mapping install ──
|
|
21
|
+
var install_initial_domain_mapping_1 = require("./state/install-initial-domain-mapping");
|
|
22
|
+
Object.defineProperty(exports, "installInitialDomainMapping", { enumerable: true, get: function () { return install_initial_domain_mapping_1.installInitialDomainMapping; } });
|
|
23
|
+
// ── Errors ──
|
|
24
|
+
var errors_2 = require("./http/errors");
|
|
25
|
+
Object.defineProperty(exports, "AirSyncHttpError", { enumerable: true, get: function () { return errors_2.AirSyncHttpError; } });
|
|
32
26
|
var logger_1 = require("./logger/logger");
|
|
33
|
-
Object.defineProperty(exports, "
|
|
34
|
-
|
|
27
|
+
Object.defineProperty(exports, "serializeError", { enumerable: true, get: function () { return logger_1.serializeError; } });
|
|
28
|
+
var common_1 = require("./types/common");
|
|
29
|
+
Object.defineProperty(exports, "SyncMode", { enumerable: true, get: function () { return common_1.SyncMode; } });
|
|
30
|
+
var extraction_1 = require("./types/extraction");
|
|
31
|
+
Object.defineProperty(exports, "EventType", { enumerable: true, get: function () { return extraction_1.EventType; } });
|
|
32
|
+
Object.defineProperty(exports, "InitialSyncScope", { enumerable: true, get: function () { return extraction_1.InitialSyncScope; } });
|
|
33
|
+
Object.defineProperty(exports, "ItemInputType", { enumerable: true, get: function () { return extraction_1.ItemInputType; } });
|
|
34
|
+
Object.defineProperty(exports, "TimeUnit", { enumerable: true, get: function () { return extraction_1.TimeUnit; } });
|
|
35
|
+
Object.defineProperty(exports, "TimeValueType", { enumerable: true, get: function () { return extraction_1.TimeValueType; } });
|
|
36
|
+
var loading_1 = require("./types/loading");
|
|
37
|
+
Object.defineProperty(exports, "ActionType", { enumerable: true, get: function () { return loading_1.ActionType; } });
|
|
38
|
+
// ── Mappers ──
|
|
39
|
+
var mappers_1 = require("./mappers/mappers");
|
|
40
|
+
Object.defineProperty(exports, "Mappers", { enumerable: true, get: function () { return mappers_1.Mappers; } });
|
|
41
|
+
var mappers_interfaces_1 = require("./mappers/mappers.interfaces");
|
|
42
|
+
Object.defineProperty(exports, "SyncMapperRecordStatus", { enumerable: true, get: function () { return mappers_interfaces_1.SyncMapperRecordStatus; } });
|
|
43
|
+
Object.defineProperty(exports, "SyncMapperRecordTargetType", { enumerable: true, get: function () { return mappers_interfaces_1.SyncMapperRecordTargetType; } });
|
|
44
|
+
var uploader_interfaces_1 = require("./uploader/uploader.interfaces");
|
|
45
|
+
Object.defineProperty(exports, "ArtifactDateField", { enumerable: true, get: function () { return uploader_interfaces_1.ArtifactDateField; } });
|
|
46
|
+
var mock_event_1 = require("./testing/mock-event");
|
|
47
|
+
Object.defineProperty(exports, "createMockEvent", { enumerable: true, get: function () { return mock_event_1.createMockEvent; } });
|
|
48
|
+
var mock_server_1 = require("./testing/mock-server");
|
|
49
|
+
Object.defineProperty(exports, "MOCK_SERVER_DEFAULT_URL", { enumerable: true, get: function () { return mock_server_1.MOCK_SERVER_DEFAULT_URL; } });
|
|
50
|
+
Object.defineProperty(exports, "MockServer", { enumerable: true, get: function () { return mock_server_1.MockServer; } });
|
|
51
|
+
var test_adapters_1 = require("./testing/test-adapters");
|
|
52
|
+
Object.defineProperty(exports, "createTestExtractionAdapter", { enumerable: true, get: function () { return test_adapters_1.createTestExtractionAdapter; } });
|
|
53
|
+
Object.defineProperty(exports, "createTestLoadingAdapter", { enumerable: true, get: function () { return test_adapters_1.createTestLoadingAdapter; } });
|
package/dist/logger/logger.d.ts
CHANGED
|
@@ -1,89 +1,32 @@
|
|
|
1
|
-
import { AxiosError } from 'axios';
|
|
2
1
|
import { Console } from 'node:console';
|
|
2
|
+
import { InspectOptions } from 'node:util';
|
|
3
|
+
import { AxiosError } from 'axios';
|
|
3
4
|
import { AxiosErrorResponse, LoggerFactoryInterface, LogLevel, PrintableState } from './logger.interfaces';
|
|
5
|
+
export declare const MAX_LOG_STRING_LENGTH = 10000;
|
|
6
|
+
export declare const INSPECT_OPTIONS: InspectOptions;
|
|
7
|
+
export declare function truncateMessage(message: string): string;
|
|
4
8
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
9
|
+
* Console replacement that tags every log line with the event context. Worker
|
|
10
|
+
* threads forward log lines to the main thread, because the snap-in platform
|
|
11
|
+
* only captures logs written through the main thread's console.
|
|
7
12
|
*/
|
|
8
13
|
export declare class Logger extends Console {
|
|
9
14
|
private originalConsole;
|
|
10
15
|
private options?;
|
|
11
16
|
private tags;
|
|
12
17
|
constructor({ event, options }: LoggerFactoryInterface);
|
|
13
|
-
/**
|
|
14
|
-
* Converts any value to a string using `util.inspect()` for complex types.
|
|
15
|
-
*
|
|
16
|
-
* @param value - The value to convert
|
|
17
|
-
* @returns String representation of the value
|
|
18
|
-
*/
|
|
19
18
|
private valueToString;
|
|
20
|
-
/**
|
|
21
|
-
|
|
22
|
-
* Adds a suffix indicating how many characters were omitted.
|
|
23
|
-
*
|
|
24
|
-
* @param message - The message to truncate
|
|
25
|
-
* @returns Truncated message or original if within limits
|
|
26
|
-
*/
|
|
27
|
-
private truncateMessage;
|
|
28
|
-
/**
|
|
29
|
-
* Logs a pre-formatted message string to the console.
|
|
30
|
-
* In production mode, wraps the message with JSON formatting and event context tags.
|
|
31
|
-
* In local development mode, logs the message directly without JSON wrapping.
|
|
32
|
-
* This is useful when you need to log already-stringified content.
|
|
33
|
-
*
|
|
34
|
-
* @param message - The pre-formatted message string to log
|
|
35
|
-
* @param level - Log level (info, warn, error)
|
|
36
|
-
* @param isSdkLog - Flag indicating if the log originated from the SDK
|
|
37
|
-
*/
|
|
38
|
-
logFn(message: string, level: LogLevel, isSdkLog?: boolean): void;
|
|
39
|
-
/**
|
|
40
|
-
* Stringifies and logs arguments to the appropriate destination.
|
|
41
|
-
* On main thread, converts arguments to strings and calls logFn.
|
|
42
|
-
* In worker threads, forwards stringified arguments to the main thread for processing.
|
|
43
|
-
* All arguments are converted to strings using util.inspect and joined with spaces.
|
|
44
|
-
*
|
|
45
|
-
* @param args - Values to log (will be stringified and truncated if needed)
|
|
46
|
-
* @param level - Log level (info, warn, error)
|
|
47
|
-
*/
|
|
19
|
+
/** In production wraps the message in JSON with event context tags; in local development logs as-is. */
|
|
20
|
+
logFn(message: string, level: LogLevel): void;
|
|
48
21
|
private stringifyAndLog;
|
|
49
22
|
log(...args: unknown[]): void;
|
|
50
23
|
info(...args: unknown[]): void;
|
|
51
24
|
warn(...args: unknown[]): void;
|
|
52
25
|
error(...args: unknown[]): void;
|
|
53
26
|
}
|
|
54
|
-
/**
|
|
55
|
-
* Converts a state object into a printable format where arrays are summarized.
|
|
56
|
-
* Arrays show their length, first item, and last item instead of all elements.
|
|
57
|
-
* Objects are recursively processed and primitives are returned as-is.
|
|
58
|
-
*
|
|
59
|
-
* @param state - State object to convert
|
|
60
|
-
* @returns Printable representation with summarized arrays
|
|
61
|
-
*/
|
|
27
|
+
/** Summarizes arrays as `{ length, firstItem, lastItem }` instead of listing all elements. */
|
|
62
28
|
export declare function getPrintableState(state: Record<string, any>): PrintableState;
|
|
63
|
-
/**
|
|
64
|
-
|
|
65
|
-
* Automatically detects and formats Axios errors with HTTP details.
|
|
66
|
-
* Returns other error types as-is.
|
|
67
|
-
*
|
|
68
|
-
* @param error - Error to serialize
|
|
69
|
-
* @returns Serialized error or original if not an Axios error
|
|
70
|
-
*/
|
|
71
|
-
export declare function serializeError(error: unknown): unknown;
|
|
72
|
-
/**
|
|
73
|
-
* Serializes an Axios error into a structured format with HTTP request/response details.
|
|
74
|
-
* Extracts method, URL, parameters, status code, headers, and data.
|
|
75
|
-
* Includes CORS/network failure indicator when no response is available.
|
|
76
|
-
*
|
|
77
|
-
* @param error - Axios error to serialize
|
|
78
|
-
* @returns Structured object with error details
|
|
79
|
-
*/
|
|
29
|
+
/** Serializes any error into a loggable string; Axios errors get HTTP details. */
|
|
30
|
+
export declare function serializeError(error: unknown): string;
|
|
80
31
|
export declare function serializeAxiosError(error: AxiosError): AxiosErrorResponse;
|
|
81
|
-
/**
|
|
82
|
-
* Formats an Axios error to a printable format.
|
|
83
|
-
*
|
|
84
|
-
* @param error - Axios error to format
|
|
85
|
-
* @returns Formatted error object
|
|
86
|
-
* @deprecated Use {@link serializeAxiosError} instead
|
|
87
|
-
*/
|
|
88
|
-
export declare function formatAxiosError(error: AxiosError): object;
|
|
89
32
|
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAW,cAAc,EAAE,MAAM,WAAW,CAAC;AAGpD,OAAO,EAAE,UAAU,EAAgB,MAAM,OAAO,CAAC;AAKjD,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EAEtB,QAAQ,EAER,cAAc,EACf,MAAM,qBAAqB,CAAC;AAI7B,eAAO,MAAM,qBAAqB,QAAQ,CAAC;AAI3C,eAAO,MAAM,eAAe,EAAE,cAM7B,CAAC;AAEF,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAOvD;AAED;;;;GAIG;AACH,qBAAa,MAAO,SAAQ,OAAO;IACjC,OAAO,CAAC,eAAe,CAAU;IACjC,OAAO,CAAC,OAAO,CAAC,CAAiB;IACjC,OAAO,CAAC,IAAI,CAAa;gBAEb,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,sBAAsB;IAUtD,OAAO,CAAC,aAAa;IAOrB,wGAAwG;IACxG,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,GAAG,IAAI;IAa7C,OAAO,CAAC,eAAe;IAcd,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAI7B,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAI9B,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAI9B,KAAK,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;CAGzC;AAED,8FAA8F;AAE9F,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,cAAc,CAqB5E;AAED,kFAAkF;AAClF,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAmCrD;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,UAAU,GAAG,kBAAkB,CAuBzE"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type { WorkerAdapterOptions } from '../types/workers';
|
|
1
|
+
import type { AirSyncEvent, EventContext } from '../types/extraction';
|
|
2
|
+
import type { RuntimeOptions } from '../types/workers';
|
|
4
3
|
export interface LoggerFactoryInterface {
|
|
5
|
-
event:
|
|
6
|
-
options?:
|
|
4
|
+
event: AirSyncEvent;
|
|
5
|
+
options?: RuntimeOptions;
|
|
7
6
|
}
|
|
8
7
|
export declare enum LogLevel {
|
|
9
8
|
INFO = "info",
|
|
@@ -29,7 +28,6 @@ export interface AxiosErrorResponse {
|
|
|
29
28
|
isCorsOrNoNetworkError: boolean;
|
|
30
29
|
response?: {
|
|
31
30
|
data: unknown;
|
|
32
|
-
headers: RawAxiosResponseHeaders;
|
|
33
31
|
status: number;
|
|
34
32
|
statusText: string;
|
|
35
33
|
};
|
|
@@ -38,6 +36,5 @@ export interface AxiosErrorResponse {
|
|
|
38
36
|
}
|
|
39
37
|
export interface LoggerTags extends EventContext {
|
|
40
38
|
sdk_version: string;
|
|
41
|
-
is_sdk_log: boolean;
|
|
42
39
|
}
|
|
43
40
|
//# sourceMappingURL=logger.interfaces.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.interfaces.d.ts","sourceRoot":"","sources":["../../src/logger/logger.interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"logger.interfaces.d.ts","sourceRoot":"","sources":["../../src/logger/logger.interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,YAAY,CAAC;IACpB,OAAO,CAAC,EAAE,cAAc,CAAC;CAC1B;AAED,oBAAY,QAAQ;IAClB,IAAI,SAAS;IACb,IAAI,SAAS;IACb,KAAK,UAAU;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IAEf,SAAS,CAAC,EAAE,GAAG,CAAC;IAEhB,QAAQ,CAAC,EAAE,GAAG,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAE7B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,GAAG,cAAc,GAAG,cAAc,CAAC;CACtD;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE;QACN,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;QAE3B,MAAM,EAAE,GAAG,CAAC;QACZ,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;KACzB,CAAC;IACF,YAAY,EAAE,OAAO,CAAC;IACtB,sBAAsB,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,EAAE;QACT,IAAI,EAAE,OAAO,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,UAAW,SAAQ,YAAY;IAC9C,WAAW,EAAE,MAAM,CAAC;CACrB"}
|
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"}
|