@devrev/airsync-sdk 2.0.0-beta.1 → 2.0.0-beta.3
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 +0 -4
- package/dist/airsync-sdk.d.ts +2059 -0
- package/dist/attachments-streaming/attachments-streaming-pool.d.ts +2 -1
- package/dist/attachments-streaming/attachments-streaming-pool.d.ts.map +1 -1
- package/dist/attachments-streaming/attachments-streaming-pool.interfaces.d.ts +8 -2
- package/dist/attachments-streaming/attachments-streaming-pool.interfaces.d.ts.map +1 -1
- package/dist/attachments-streaming/attachments-streaming-pool.js +27 -16
- package/dist/attachments-streaming/attachments-streaming-pool.test.js +246 -27
- package/dist/common/constants.d.ts +16 -5
- package/dist/common/constants.d.ts.map +1 -1
- package/dist/common/constants.js +20 -6
- package/dist/common/control-protocol.d.ts +2 -2
- package/dist/common/control-protocol.d.ts.map +1 -1
- package/dist/common/control-protocol.js +1 -5
- package/dist/common/helpers.d.ts +8 -0
- package/dist/common/helpers.d.ts.map +1 -1
- package/dist/common/helpers.js +15 -0
- package/dist/common/install-initial-domain-mapping.d.ts +2 -2
- package/dist/common/install-initial-domain-mapping.test.js +5 -2
- package/dist/common/test-utils.d.ts +19 -0
- package/dist/common/test-utils.d.ts.map +1 -0
- package/dist/common/test-utils.js +101 -0
- package/dist/common/time-value-resolver.d.ts +47 -0
- package/dist/common/time-value-resolver.d.ts.map +1 -0
- package/dist/common/time-value-resolver.js +141 -0
- package/dist/common/time-value-resolver.test.d.ts +2 -0
- package/dist/common/time-value-resolver.test.d.ts.map +1 -0
- package/dist/common/time-value-resolver.test.js +268 -0
- package/dist/http/axios-client-internal.d.ts.map +1 -1
- package/dist/http/axios-client-internal.js +7 -0
- package/dist/http/axios-client-internal.test.js +21 -0
- package/dist/http/axios-client.d.ts.map +1 -1
- package/dist/http/axios-client.js +6 -3
- package/dist/http/index.d.ts +0 -1
- package/dist/http/index.d.ts.map +1 -1
- package/dist/http/index.js +0 -1
- package/dist/index.d.ts +12 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -13
- package/dist/logger/logger.d.ts +1 -17
- package/dist/logger/logger.d.ts.map +1 -1
- package/dist/logger/logger.interfaces.d.ts +2 -2
- package/dist/logger/logger.js +35 -27
- package/dist/logger/logger.test.js +66 -19
- package/dist/mappers/mappers.interface.d.ts +5 -5
- package/dist/mappers/mappers.interface.js +3 -3
- package/dist/mappers/mappers.test.js +8 -10
- package/dist/mock-server/mock-server.d.ts +47 -0
- package/dist/mock-server/mock-server.d.ts.map +1 -0
- package/dist/mock-server/mock-server.interfaces.d.ts +73 -0
- package/dist/mock-server/mock-server.interfaces.d.ts.map +1 -0
- package/dist/mock-server/mock-server.interfaces.js +4 -0
- package/dist/mock-server/mock-server.js +278 -0
- package/dist/multithreading/adapters/base-adapter.d.ts +56 -0
- package/dist/multithreading/adapters/base-adapter.d.ts.map +1 -0
- package/dist/multithreading/adapters/base-adapter.emit.test.d.ts +2 -0
- package/dist/multithreading/adapters/base-adapter.emit.test.d.ts.map +1 -0
- package/dist/multithreading/adapters/base-adapter.emit.test.js +403 -0
- package/dist/multithreading/adapters/base-adapter.js +105 -0
- package/dist/multithreading/adapters/extraction-adapter.artifacts.test.d.ts +2 -0
- package/dist/multithreading/adapters/extraction-adapter.artifacts.test.d.ts.map +1 -0
- package/dist/multithreading/{worker-adapter/worker-adapter.artifacts.test.js → adapters/extraction-adapter.artifacts.test.js} +53 -5
- package/dist/multithreading/adapters/extraction-adapter.d.ts +58 -0
- package/dist/multithreading/adapters/extraction-adapter.d.ts.map +1 -0
- package/dist/multithreading/adapters/extraction-adapter.js +325 -0
- package/dist/multithreading/adapters/extraction-adapter.test.d.ts +2 -0
- package/dist/multithreading/adapters/extraction-adapter.test.d.ts.map +1 -0
- package/dist/multithreading/adapters/extraction-adapter.test.js +789 -0
- package/dist/multithreading/adapters/loading-adapter.d.ts +44 -0
- package/dist/multithreading/adapters/loading-adapter.d.ts.map +1 -0
- package/dist/multithreading/{worker-adapter/worker-adapter.helpers.d.ts → adapters/loading-adapter.helpers.d.ts} +1 -1
- package/dist/multithreading/adapters/loading-adapter.helpers.d.ts.map +1 -0
- package/dist/multithreading/adapters/loading-adapter.helpers.test.d.ts +2 -0
- package/dist/multithreading/adapters/loading-adapter.helpers.test.d.ts.map +1 -0
- package/dist/multithreading/{worker-adapter/worker-adapter.helpers.test.js → adapters/loading-adapter.helpers.test.js} +26 -26
- package/dist/multithreading/adapters/loading-adapter.js +461 -0
- package/dist/multithreading/adapters/loading-adapter.test.d.ts +2 -0
- package/dist/multithreading/adapters/loading-adapter.test.d.ts.map +1 -0
- package/dist/multithreading/adapters/loading-adapter.test.js +589 -0
- package/dist/multithreading/adapters/serialization.test.d.ts +2 -0
- package/dist/multithreading/adapters/serialization.test.d.ts.map +1 -0
- package/dist/multithreading/adapters/serialization.test.js +71 -0
- package/dist/multithreading/create-worker.test.js +36 -17
- package/dist/multithreading/process-task.d.ts +16 -1
- package/dist/multithreading/process-task.d.ts.map +1 -1
- package/dist/multithreading/process-task.js +97 -82
- package/dist/multithreading/process-task.test.d.ts +2 -0
- package/dist/multithreading/process-task.test.d.ts.map +1 -0
- package/dist/multithreading/process-task.test.js +146 -0
- package/dist/multithreading/spawn/spawn.d.ts +3 -3
- package/dist/multithreading/spawn/spawn.d.ts.map +1 -1
- package/dist/multithreading/spawn/spawn.helpers.d.ts.map +1 -1
- package/dist/multithreading/spawn/spawn.helpers.js +6 -14
- package/dist/multithreading/spawn/spawn.helpers.test.js +8 -8
- package/dist/multithreading/spawn/spawn.js +20 -25
- package/dist/multithreading/spawn/spawn.test.d.ts +2 -0
- package/dist/multithreading/spawn/spawn.test.d.ts.map +1 -0
- package/dist/multithreading/spawn/spawn.test.js +232 -0
- package/dist/repo/repo.d.ts.map +1 -1
- package/dist/repo/repo.interfaces.d.ts +4 -2
- package/dist/repo/repo.interfaces.d.ts.map +1 -1
- package/dist/repo/repo.js +4 -3
- package/dist/repo/repo.test.js +60 -7
- package/dist/state/base-state.d.ts +75 -0
- package/dist/state/base-state.d.ts.map +1 -0
- package/dist/state/base-state.js +261 -0
- package/dist/state/extraction-state.d.ts +29 -0
- package/dist/state/extraction-state.d.ts.map +1 -0
- package/dist/state/extraction-state.js +122 -0
- package/dist/state/loading-state.d.ts +19 -0
- package/dist/state/loading-state.d.ts.map +1 -0
- package/dist/state/loading-state.js +40 -0
- package/dist/state/state.extract-window.test.d.ts +2 -0
- package/dist/state/state.extract-window.test.d.ts.map +1 -0
- package/dist/state/state.extract-window.test.js +163 -0
- package/dist/state/state.interfaces.d.ts +44 -27
- package/dist/state/state.interfaces.d.ts.map +1 -1
- package/dist/state/state.interfaces.js +18 -5
- package/dist/state/state.pending-boundaries.test.d.ts +2 -0
- package/dist/state/state.pending-boundaries.test.d.ts.map +1 -0
- package/dist/state/state.pending-boundaries.test.js +189 -0
- package/dist/state/state.post-state.test.d.ts +2 -0
- package/dist/state/state.post-state.test.d.ts.map +1 -0
- package/dist/state/state.post-state.test.js +78 -0
- package/dist/state/state.test.js +135 -88
- package/dist/state/state.time-value-resolution.test.d.ts +2 -0
- package/dist/state/state.time-value-resolution.test.d.ts.map +1 -0
- package/dist/state/state.time-value-resolution.test.js +175 -0
- package/dist/tsdoc-metadata.json +11 -0
- package/dist/types/common.d.ts +0 -25
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/common.js +1 -11
- package/dist/types/external-domain-metadata.d.ts +20 -1
- package/dist/types/external-domain-metadata.d.ts.map +1 -1
- package/dist/types/extraction.d.ts +92 -221
- package/dist/types/extraction.d.ts.map +1 -1
- package/dist/types/extraction.js +56 -124
- package/dist/types/extraction.test.js +69 -43
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +6 -3
- package/dist/types/loading.d.ts +4 -24
- package/dist/types/loading.d.ts.map +1 -1
- package/dist/types/loading.js +1 -22
- package/dist/types/workers.d.ts +47 -29
- package/dist/types/workers.d.ts.map +1 -1
- package/dist/types/workers.js +1 -0
- package/dist/uploader/uploader.d.ts +1 -0
- package/dist/uploader/uploader.d.ts.map +1 -1
- package/dist/uploader/uploader.helpers.test.js +0 -11
- package/dist/uploader/uploader.interfaces.d.ts +3 -3
- package/dist/uploader/uploader.js +53 -20
- package/dist/uploader/uploader.test.js +22 -10
- package/package.json +10 -13
- 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/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/types.d.ts +0 -17
- package/dist/http/types.d.ts.map +0 -1
- package/dist/http/types.js +0 -2
- 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.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.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.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/state/state.d.ts +0 -30
- package/dist/state/state.d.ts.map +0 -1
- package/dist/state/state.js +0 -166
- /package/dist/multithreading/{worker-adapter/worker-adapter.helpers.js → adapters/loading-adapter.helpers.js} +0 -0
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.translateIncomingEventType = translateIncomingEventType;
|
|
4
|
-
exports.translateExtractorEventType = translateExtractorEventType;
|
|
5
|
-
exports.translateLoaderEventType = translateLoaderEventType;
|
|
6
|
-
exports.translateOutgoingEventType = translateOutgoingEventType;
|
|
7
|
-
const extraction_1 = require("../types/extraction");
|
|
8
|
-
const loading_1 = require("../types/loading");
|
|
9
|
-
/**
|
|
10
|
-
* Maps old incoming event type strings to new EventType enum values.
|
|
11
|
-
* This ensures backwards compatibility when the platform sends old event types.
|
|
12
|
-
* @param eventTypeString The raw event type string from the platform
|
|
13
|
-
* @returns The translated EventType enum value
|
|
14
|
-
*/
|
|
15
|
-
function translateIncomingEventType(eventTypeString) {
|
|
16
|
-
// Create a reverse mapping from OLD string values to NEW enum member names
|
|
17
|
-
const eventTypeMap = {
|
|
18
|
-
// Old extraction event types from platform -> New enum members
|
|
19
|
-
[extraction_1.EventType.ExtractionExternalSyncUnitsStart]: extraction_1.EventType.StartExtractingExternalSyncUnits,
|
|
20
|
-
[extraction_1.EventType.ExtractionMetadataStart]: extraction_1.EventType.StartExtractingMetadata,
|
|
21
|
-
[extraction_1.EventType.ExtractionDataStart]: extraction_1.EventType.StartExtractingData,
|
|
22
|
-
[extraction_1.EventType.ExtractionDataContinue]: extraction_1.EventType.ContinueExtractingData,
|
|
23
|
-
[extraction_1.EventType.ExtractionDataDelete]: extraction_1.EventType.StartDeletingExtractorState,
|
|
24
|
-
[extraction_1.EventType.ExtractionAttachmentsStart]: extraction_1.EventType.StartExtractingAttachments,
|
|
25
|
-
[extraction_1.EventType.ExtractionAttachmentsContinue]: extraction_1.EventType.ContinueExtractingAttachments,
|
|
26
|
-
[extraction_1.EventType.ExtractionAttachmentsDelete]: extraction_1.EventType.StartDeletingExtractorAttachmentsState,
|
|
27
|
-
// New extraction event types (already correct, map to new enum members)
|
|
28
|
-
[extraction_1.EventType.StartExtractingExternalSyncUnits]: extraction_1.EventType.StartExtractingExternalSyncUnits,
|
|
29
|
-
[extraction_1.EventType.StartExtractingMetadata]: extraction_1.EventType.StartExtractingMetadata,
|
|
30
|
-
[extraction_1.EventType.StartExtractingData]: extraction_1.EventType.StartExtractingData,
|
|
31
|
-
[extraction_1.EventType.ContinueExtractingData]: extraction_1.EventType.ContinueExtractingData,
|
|
32
|
-
[extraction_1.EventType.StartDeletingExtractorState]: extraction_1.EventType.StartDeletingExtractorState,
|
|
33
|
-
[extraction_1.EventType.StartExtractingAttachments]: extraction_1.EventType.StartExtractingAttachments,
|
|
34
|
-
[extraction_1.EventType.ContinueExtractingAttachments]: extraction_1.EventType.ContinueExtractingAttachments,
|
|
35
|
-
[extraction_1.EventType.StartDeletingExtractorAttachmentsState]: extraction_1.EventType.StartDeletingExtractorAttachmentsState,
|
|
36
|
-
// Loading events
|
|
37
|
-
[extraction_1.EventType.StartLoadingData]: extraction_1.EventType.StartLoadingData,
|
|
38
|
-
[extraction_1.EventType.ContinueLoadingData]: extraction_1.EventType.ContinueLoadingData,
|
|
39
|
-
[extraction_1.EventType.StartLoadingAttachments]: extraction_1.EventType.StartLoadingAttachments,
|
|
40
|
-
[extraction_1.EventType.ContinueLoadingAttachments]: extraction_1.EventType.ContinueLoadingAttachments,
|
|
41
|
-
[extraction_1.EventType.StartDeletingLoaderState]: extraction_1.EventType.StartDeletingLoaderState,
|
|
42
|
-
[extraction_1.EventType.StartDeletingLoaderAttachmentState]: extraction_1.EventType.StartDeletingLoaderAttachmentState,
|
|
43
|
-
// Unknown
|
|
44
|
-
[extraction_1.EventType.UnknownEventType]: extraction_1.EventType.UnknownEventType,
|
|
45
|
-
};
|
|
46
|
-
const translated = eventTypeMap[eventTypeString];
|
|
47
|
-
if (!translated) {
|
|
48
|
-
console.warn(`Unknown event type received: ${eventTypeString}. This may indicate a new event type or a typo.`);
|
|
49
|
-
// Return the original string cast as EventType as a fallback
|
|
50
|
-
return eventTypeString;
|
|
51
|
-
}
|
|
52
|
-
return translated;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Translates ExtractorEventType enum values by converting old enum members to new ones.
|
|
56
|
-
* Old enum members are deprecated and should be replaced with new ones.
|
|
57
|
-
*/
|
|
58
|
-
function translateExtractorEventType(eventType) {
|
|
59
|
-
var _a;
|
|
60
|
-
// Map old enum members to new enum members
|
|
61
|
-
const stringValue = eventType;
|
|
62
|
-
const mapping = {
|
|
63
|
-
// Old string values -> New enum members
|
|
64
|
-
[extraction_1.ExtractorEventType.ExtractionExternalSyncUnitsDone]: extraction_1.ExtractorEventType.ExternalSyncUnitExtractionDone,
|
|
65
|
-
[extraction_1.ExtractorEventType.ExtractionExternalSyncUnitsError]: extraction_1.ExtractorEventType.ExternalSyncUnitExtractionError,
|
|
66
|
-
[extraction_1.ExtractorEventType.ExtractionMetadataDone]: extraction_1.ExtractorEventType.MetadataExtractionDone,
|
|
67
|
-
[extraction_1.ExtractorEventType.ExtractionMetadataError]: extraction_1.ExtractorEventType.MetadataExtractionError,
|
|
68
|
-
[extraction_1.ExtractorEventType.ExtractionDataProgress]: extraction_1.ExtractorEventType.DataExtractionProgress,
|
|
69
|
-
[extraction_1.ExtractorEventType.ExtractionDataDelay]: extraction_1.ExtractorEventType.DataExtractionDelayed,
|
|
70
|
-
[extraction_1.ExtractorEventType.ExtractionDataDone]: extraction_1.ExtractorEventType.DataExtractionDone,
|
|
71
|
-
[extraction_1.ExtractorEventType.ExtractionDataError]: extraction_1.ExtractorEventType.DataExtractionError,
|
|
72
|
-
[extraction_1.ExtractorEventType.ExtractionDataDeleteDone]: extraction_1.ExtractorEventType.ExtractorStateDeletionDone,
|
|
73
|
-
[extraction_1.ExtractorEventType.ExtractionDataDeleteError]: extraction_1.ExtractorEventType.ExtractorStateDeletionError,
|
|
74
|
-
[extraction_1.ExtractorEventType.ExtractionAttachmentsProgress]: extraction_1.ExtractorEventType.AttachmentExtractionProgress,
|
|
75
|
-
[extraction_1.ExtractorEventType.ExtractionAttachmentsDelay]: extraction_1.ExtractorEventType.AttachmentExtractionDelayed,
|
|
76
|
-
[extraction_1.ExtractorEventType.ExtractionAttachmentsDone]: extraction_1.ExtractorEventType.AttachmentExtractionDone,
|
|
77
|
-
[extraction_1.ExtractorEventType.ExtractionAttachmentsError]: extraction_1.ExtractorEventType.AttachmentExtractionError,
|
|
78
|
-
[extraction_1.ExtractorEventType.ExtractionAttachmentsDeleteDone]: extraction_1.ExtractorEventType.ExtractorAttachmentsStateDeletionDone,
|
|
79
|
-
[extraction_1.ExtractorEventType.ExtractionAttachmentsDeleteError]: extraction_1.ExtractorEventType.ExtractorAttachmentsStateDeletionError,
|
|
80
|
-
};
|
|
81
|
-
// If there's a mapping, use it; otherwise return original (already new)
|
|
82
|
-
return (_a = mapping[stringValue]) !== null && _a !== void 0 ? _a : eventType;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Translates LoaderEventType enum values by converting old enum members to new ones.
|
|
86
|
-
* Old enum members are deprecated and should be replaced with new ones.
|
|
87
|
-
*/
|
|
88
|
-
function translateLoaderEventType(eventType) {
|
|
89
|
-
var _a;
|
|
90
|
-
// Map old enum members to new enum members
|
|
91
|
-
const stringValue = eventType;
|
|
92
|
-
const mapping = {
|
|
93
|
-
// Old string values -> New enum members
|
|
94
|
-
[loading_1.LoaderEventType.DataLoadingDelay]: loading_1.LoaderEventType.DataLoadingDelayed,
|
|
95
|
-
[loading_1.LoaderEventType.AttachmentsLoadingProgress]: loading_1.LoaderEventType.AttachmentLoadingProgress,
|
|
96
|
-
[loading_1.LoaderEventType.AttachmentsLoadingDelayed]: loading_1.LoaderEventType.AttachmentLoadingDelayed,
|
|
97
|
-
[loading_1.LoaderEventType.AttachmentsLoadingDone]: loading_1.LoaderEventType.AttachmentLoadingDone,
|
|
98
|
-
[loading_1.LoaderEventType.AttachmentsLoadingError]: loading_1.LoaderEventType.AttachmentLoadingError,
|
|
99
|
-
};
|
|
100
|
-
// If there's a mapping, use it; otherwise return original (already new)
|
|
101
|
-
return (_a = mapping[stringValue]) !== null && _a !== void 0 ? _a : eventType;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Translates any outgoing event type (Extractor or Loader) to ensure new event types are used.
|
|
105
|
-
*/
|
|
106
|
-
function translateOutgoingEventType(eventType) {
|
|
107
|
-
// Check if it's an ExtractorEventType by checking if the value exists in ExtractorEventType
|
|
108
|
-
if (Object.values(extraction_1.ExtractorEventType).includes(eventType)) {
|
|
109
|
-
return translateExtractorEventType(eventType);
|
|
110
|
-
}
|
|
111
|
-
// Otherwise treat as LoaderEventType
|
|
112
|
-
if (Object.values(loading_1.LoaderEventType).includes(eventType)) {
|
|
113
|
-
return translateLoaderEventType(eventType);
|
|
114
|
-
}
|
|
115
|
-
// If neither, return as-is
|
|
116
|
-
return eventType;
|
|
117
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { AirdropEvent, EventData, ExtractorEventType } from '../../types/extraction';
|
|
2
|
-
import { Artifact } from '../../uploader/uploader.interfaces';
|
|
3
|
-
import { AdapterState } from '../../state/state.interfaces';
|
|
4
|
-
import { State } from '../../state/state';
|
|
5
|
-
/**
|
|
6
|
-
* Adapter class is used to interact with Airdrop platform. The class provides
|
|
7
|
-
* utilities to
|
|
8
|
-
* - emit control events to the platform
|
|
9
|
-
* - update the state of the extractor
|
|
10
|
-
* - set the last saved state in case of a timeout
|
|
11
|
-
*
|
|
12
|
-
* @class Adapter
|
|
13
|
-
* @constructor
|
|
14
|
-
* @deprecated
|
|
15
|
-
* @param {AirdropEvent} event - The event object received from the platform
|
|
16
|
-
* @param {object=} initialState - The initial state of the adapter
|
|
17
|
-
* @param {boolean=} isLocalDevelopment - A flag to indicate if the adapter is being used in local development
|
|
18
|
-
*/
|
|
19
|
-
/**
|
|
20
|
-
* Creates an adapter instance.
|
|
21
|
-
*
|
|
22
|
-
* @param {AirdropEvent} event - The event object received from the platform
|
|
23
|
-
* @param initialState
|
|
24
|
-
* @param {boolean=} isLocalDevelopment - A flag to indicate if the adapter is being used in local development
|
|
25
|
-
* @return The adapter instance
|
|
26
|
-
*/
|
|
27
|
-
export declare function createAdapter<ConnectorState>(event: AirdropEvent, initialState: ConnectorState, isLocalDevelopment?: boolean): Promise<Adapter<ConnectorState>>;
|
|
28
|
-
export declare class Adapter<ConnectorState> {
|
|
29
|
-
private adapterState;
|
|
30
|
-
private _artifacts;
|
|
31
|
-
private event;
|
|
32
|
-
private callbackUrl;
|
|
33
|
-
private devrevToken;
|
|
34
|
-
private startTime;
|
|
35
|
-
private heartBeatFn;
|
|
36
|
-
private exit;
|
|
37
|
-
private lambdaTimeout;
|
|
38
|
-
private heartBeatInterval;
|
|
39
|
-
constructor(event: AirdropEvent, adapterState: State<ConnectorState>, isLocalDevelopment?: boolean);
|
|
40
|
-
get state(): AdapterState<ConnectorState>;
|
|
41
|
-
set state(value: AdapterState<ConnectorState>);
|
|
42
|
-
get artifacts(): Artifact[];
|
|
43
|
-
set artifacts(value: Artifact[]);
|
|
44
|
-
/**
|
|
45
|
-
* Emits an event to the platform.
|
|
46
|
-
*
|
|
47
|
-
* @param {ExtractorEventType} newEventType - The event type to be emitted
|
|
48
|
-
* @param {EventData=} data - The data to be sent with the event
|
|
49
|
-
*/
|
|
50
|
-
emit(newEventType: ExtractorEventType, data?: EventData): Promise<void>;
|
|
51
|
-
/**
|
|
52
|
-
* Exit the adapter. This will stop the heartbeat and no
|
|
53
|
-
* further events will be emitted.
|
|
54
|
-
*/
|
|
55
|
-
private exitAdapter;
|
|
56
|
-
/**
|
|
57
|
-
* Heartbeat function to check if the lambda is about to timeout.
|
|
58
|
-
* @returns true if 10 minutes have passed since the start of the lambda.
|
|
59
|
-
*/
|
|
60
|
-
private heartbeat;
|
|
61
|
-
}
|
|
62
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/deprecated/adapter/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,YAAY,EACZ,SAAS,EAET,kBAAkB,EACnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAE9D,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAK5D,OAAO,EAAE,KAAK,EAAsB,MAAM,mBAAmB,CAAC;AAI9D;;;;;;;;;;;;;GAaG;AAEH;;;;;;;GAOG;AAEH,wBAAsB,aAAa,CAAC,cAAc,EAChD,KAAK,EAAE,YAAY,EACnB,YAAY,EAAE,cAAc,EAC5B,kBAAkB,GAAE,OAAe,oCAiBpC;AAED,qBAAa,OAAO,CAAC,cAAc;IACjC,OAAO,CAAC,YAAY,CAAwB;IAC5C,OAAO,CAAC,UAAU,CAAa;IAE/B,OAAO,CAAC,KAAK,CAAe;IAC5B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,WAAW,CAA4C;IAC/D,OAAO,CAAC,IAAI,CAAkB;IAC9B,OAAO,CAAC,aAAa,CAA0B;IAC/C,OAAO,CAAC,iBAAiB,CAAqB;gBAG5C,KAAK,EAAE,YAAY,EACnB,YAAY,EAAE,KAAK,CAAC,cAAc,CAAC,EACnC,kBAAkB,GAAE,OAAe;IAwBrC,IAAI,KAAK,IAAI,YAAY,CAAC,cAAc,CAAC,CAExC;IAED,IAAI,KAAK,CAAC,KAAK,EAAE,YAAY,CAAC,cAAc,CAAC,EAE5C;IAED,IAAI,SAAS,IAAI,QAAQ,EAAE,CAE1B;IAED,IAAI,SAAS,CAAC,KAAK,EAAE,QAAQ,EAAE,EAE9B;IAED;;;;;OAKG;IACG,IAAI,CAAC,YAAY,EAAE,kBAAkB,EAAE,IAAI,CAAC,EAAE,SAAS;IAoD7D;;;OAGG;IACH,OAAO,CAAC,WAAW;IAInB;;;OAGG;YACW,SAAS;CAiBxB"}
|
|
@@ -1,151 +0,0 @@
|
|
|
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.Adapter = void 0;
|
|
7
|
-
exports.createAdapter = createAdapter;
|
|
8
|
-
const axios_1 = __importDefault(require("axios"));
|
|
9
|
-
const constants_1 = require("../../common/constants");
|
|
10
|
-
const helpers_1 = require("../common/helpers");
|
|
11
|
-
// import { Logger } from '../../logger/logger';
|
|
12
|
-
const state_1 = require("../../state/state");
|
|
13
|
-
const event_type_translation_1 = require("../../common/event-type-translation");
|
|
14
|
-
const logger_context_1 = require("../../logger/logger.context");
|
|
15
|
-
/**
|
|
16
|
-
* Adapter class is used to interact with Airdrop platform. The class provides
|
|
17
|
-
* utilities to
|
|
18
|
-
* - emit control events to the platform
|
|
19
|
-
* - update the state of the extractor
|
|
20
|
-
* - set the last saved state in case of a timeout
|
|
21
|
-
*
|
|
22
|
-
* @class Adapter
|
|
23
|
-
* @constructor
|
|
24
|
-
* @deprecated
|
|
25
|
-
* @param {AirdropEvent} event - The event object received from the platform
|
|
26
|
-
* @param {object=} initialState - The initial state of the adapter
|
|
27
|
-
* @param {boolean=} isLocalDevelopment - A flag to indicate if the adapter is being used in local development
|
|
28
|
-
*/
|
|
29
|
-
/**
|
|
30
|
-
* Creates an adapter instance.
|
|
31
|
-
*
|
|
32
|
-
* @param {AirdropEvent} event - The event object received from the platform
|
|
33
|
-
* @param initialState
|
|
34
|
-
* @param {boolean=} isLocalDevelopment - A flag to indicate if the adapter is being used in local development
|
|
35
|
-
* @return The adapter instance
|
|
36
|
-
*/
|
|
37
|
-
async function createAdapter(event, initialState, isLocalDevelopment = false) {
|
|
38
|
-
event.payload.event_type = (0, event_type_translation_1.translateIncomingEventType)(event.payload.event_type);
|
|
39
|
-
const newInitialState = structuredClone(initialState);
|
|
40
|
-
const adapterState = await (0, state_1.createAdapterState)({
|
|
41
|
-
event,
|
|
42
|
-
initialState: newInitialState,
|
|
43
|
-
});
|
|
44
|
-
const a = new Adapter(event, adapterState, isLocalDevelopment);
|
|
45
|
-
return a;
|
|
46
|
-
}
|
|
47
|
-
class Adapter {
|
|
48
|
-
constructor(event, adapterState, isLocalDevelopment = false) {
|
|
49
|
-
this.exit = false;
|
|
50
|
-
this.lambdaTimeout = 10 * 60 * 1000; // 10 minutes in milliseconds
|
|
51
|
-
this.heartBeatInterval = 30 * 1000; // 30 seconds in milliseconds
|
|
52
|
-
if (!isLocalDevelopment) {
|
|
53
|
-
// Logger.init(event);
|
|
54
|
-
}
|
|
55
|
-
this.adapterState = adapterState;
|
|
56
|
-
this._artifacts = [];
|
|
57
|
-
this.event = event;
|
|
58
|
-
this.callbackUrl = event.payload.event_context.callback_url;
|
|
59
|
-
this.devrevToken = event.context.secrets.service_account_token;
|
|
60
|
-
this.startTime = Date.now();
|
|
61
|
-
// Run heartbeat every 30 seconds
|
|
62
|
-
this.heartBeatFn = setInterval(async () => {
|
|
63
|
-
const b = await this.heartbeat();
|
|
64
|
-
if (b) {
|
|
65
|
-
this.exitAdapter();
|
|
66
|
-
}
|
|
67
|
-
}, this.heartBeatInterval);
|
|
68
|
-
}
|
|
69
|
-
get state() {
|
|
70
|
-
return this.adapterState.state;
|
|
71
|
-
}
|
|
72
|
-
set state(value) {
|
|
73
|
-
this.adapterState.state = value;
|
|
74
|
-
}
|
|
75
|
-
get artifacts() {
|
|
76
|
-
return this._artifacts;
|
|
77
|
-
}
|
|
78
|
-
set artifacts(value) {
|
|
79
|
-
this._artifacts = value;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Emits an event to the platform.
|
|
83
|
-
*
|
|
84
|
-
* @param {ExtractorEventType} newEventType - The event type to be emitted
|
|
85
|
-
* @param {EventData=} data - The data to be sent with the event
|
|
86
|
-
*/
|
|
87
|
-
async emit(newEventType, data) {
|
|
88
|
-
if (this.exit) {
|
|
89
|
-
console.warn('Adapter is already in exit state. No more events can be emitted.');
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
// We want to save the state every time we emit an event, except for the start and delete events
|
|
93
|
-
if (!constants_1.STATELESS_EVENT_TYPES.includes(this.event.payload.event_type)) {
|
|
94
|
-
(0, logger_context_1.runWithSdkLogContext)(() => console.log(`Saving state before emitting event`));
|
|
95
|
-
await this.adapterState.postState(this.state);
|
|
96
|
-
}
|
|
97
|
-
const newEvent = {
|
|
98
|
-
event_type: newEventType,
|
|
99
|
-
event_context: this.event.payload.event_context,
|
|
100
|
-
event_data: Object.assign({}, data),
|
|
101
|
-
};
|
|
102
|
-
try {
|
|
103
|
-
await axios_1.default.post(this.callbackUrl, Object.assign({}, newEvent), {
|
|
104
|
-
headers: {
|
|
105
|
-
Accept: 'application/json, text/plain, */*',
|
|
106
|
-
Authorization: this.devrevToken,
|
|
107
|
-
'Content-Type': 'application/json',
|
|
108
|
-
},
|
|
109
|
-
});
|
|
110
|
-
console.log('Successfully emitted event: ' + JSON.stringify(newEvent));
|
|
111
|
-
}
|
|
112
|
-
catch (error) {
|
|
113
|
-
// If this request fails the extraction will be stuck in loop and
|
|
114
|
-
// we need to stop it through UI or think about retrying this request
|
|
115
|
-
console.log('Failed to emit event: ' +
|
|
116
|
-
JSON.stringify(newEvent) +
|
|
117
|
-
', error: ' +
|
|
118
|
-
error);
|
|
119
|
-
}
|
|
120
|
-
finally {
|
|
121
|
-
this.exitAdapter();
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Exit the adapter. This will stop the heartbeat and no
|
|
126
|
-
* further events will be emitted.
|
|
127
|
-
*/
|
|
128
|
-
exitAdapter() {
|
|
129
|
-
this.exit = true;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Heartbeat function to check if the lambda is about to timeout.
|
|
133
|
-
* @returns true if 10 minutes have passed since the start of the lambda.
|
|
134
|
-
*/
|
|
135
|
-
async heartbeat() {
|
|
136
|
-
if (this.exit) {
|
|
137
|
-
return true;
|
|
138
|
-
}
|
|
139
|
-
if (Date.now() - this.startTime > this.lambdaTimeout) {
|
|
140
|
-
const timeoutEventType = (0, helpers_1.getTimeoutExtractorEventType)(this.event.payload.event_type);
|
|
141
|
-
if (timeoutEventType !== null) {
|
|
142
|
-
const { eventType, isError } = timeoutEventType;
|
|
143
|
-
const err = isError ? { message: 'Lambda Timeout' } : undefined;
|
|
144
|
-
await this.emit(eventType, { error: err, artifacts: this._artifacts });
|
|
145
|
-
return true;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
return false;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
exports.Adapter = Adapter;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { EventType, ExtractorEventType } from '../../types/extraction';
|
|
2
|
-
export declare function createFormData(preparedArtifact: any, fetchedObjects: object[] | object): FormData;
|
|
3
|
-
export declare function getTimeoutExtractorEventType(eventType: EventType): {
|
|
4
|
-
eventType: ExtractorEventType;
|
|
5
|
-
isError: boolean;
|
|
6
|
-
} | null;
|
|
7
|
-
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/deprecated/common/helpers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEvE,wBAAgB,cAAc,CAE5B,gBAAgB,EAAE,GAAG,EACrB,cAAc,EAAE,MAAM,EAAE,GAAG,MAAM,GAChC,QAAQ,CAUV;AAED,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,SAAS,GAAG;IAClE,SAAS,EAAE,kBAAkB,CAAC;IAC9B,OAAO,EAAE,OAAO,CAAC;CAClB,GAAG,IAAI,CA+BP"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createFormData = createFormData;
|
|
4
|
-
exports.getTimeoutExtractorEventType = getTimeoutExtractorEventType;
|
|
5
|
-
const js_jsonl_1 = require("js-jsonl");
|
|
6
|
-
const extraction_1 = require("../../types/extraction");
|
|
7
|
-
function createFormData(
|
|
8
|
-
//eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
-
preparedArtifact, fetchedObjects) {
|
|
10
|
-
const formData = new FormData();
|
|
11
|
-
for (const item of preparedArtifact.form_data) {
|
|
12
|
-
formData.append(item.key, item.value);
|
|
13
|
-
}
|
|
14
|
-
const output = js_jsonl_1.jsonl.stringify(fetchedObjects);
|
|
15
|
-
formData.append('file', output);
|
|
16
|
-
return formData;
|
|
17
|
-
}
|
|
18
|
-
function getTimeoutExtractorEventType(eventType) {
|
|
19
|
-
switch (eventType) {
|
|
20
|
-
case extraction_1.EventType.ExtractionMetadataStart:
|
|
21
|
-
return {
|
|
22
|
-
eventType: extraction_1.ExtractorEventType.ExtractionMetadataError,
|
|
23
|
-
isError: true,
|
|
24
|
-
};
|
|
25
|
-
case extraction_1.EventType.ExtractionDataStart:
|
|
26
|
-
case extraction_1.EventType.ExtractionDataContinue:
|
|
27
|
-
return {
|
|
28
|
-
eventType: extraction_1.ExtractorEventType.ExtractionDataProgress,
|
|
29
|
-
isError: false,
|
|
30
|
-
};
|
|
31
|
-
case extraction_1.EventType.ExtractionAttachmentsStart:
|
|
32
|
-
case extraction_1.EventType.ExtractionAttachmentsContinue:
|
|
33
|
-
return {
|
|
34
|
-
eventType: extraction_1.ExtractorEventType.ExtractionAttachmentsProgress,
|
|
35
|
-
isError: false,
|
|
36
|
-
};
|
|
37
|
-
case extraction_1.EventType.ExtractionExternalSyncUnitsStart:
|
|
38
|
-
return {
|
|
39
|
-
eventType: extraction_1.ExtractorEventType.ExtractionExternalSyncUnitsError,
|
|
40
|
-
isError: true,
|
|
41
|
-
};
|
|
42
|
-
default:
|
|
43
|
-
console.log('Event type not recognized in getTimeoutExtractorEventType function: ' +
|
|
44
|
-
eventType);
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"record_types": {
|
|
3
|
-
"users": {
|
|
4
|
-
"fields": {
|
|
5
|
-
"name": {
|
|
6
|
-
"is_required": true,
|
|
7
|
-
"type": "text",
|
|
8
|
-
"name": "Name",
|
|
9
|
-
"text": {
|
|
10
|
-
"min_length": 1
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
"email": {
|
|
14
|
-
"type": "text",
|
|
15
|
-
"name": "Email",
|
|
16
|
-
"is_required": true
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
"contacts": {
|
|
21
|
-
"fields": {
|
|
22
|
-
"name": {
|
|
23
|
-
"is_required": true,
|
|
24
|
-
"type": "text",
|
|
25
|
-
"name": "Name",
|
|
26
|
-
"text": {
|
|
27
|
-
"min_length": 1
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
"email": {
|
|
31
|
-
"type": "text",
|
|
32
|
-
"name": "Email",
|
|
33
|
-
"is_required": true
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { AirdropEvent } from '../../types/extraction';
|
|
2
|
-
import { Adapter } from '../adapter';
|
|
3
|
-
type ConnectorState = object;
|
|
4
|
-
/**
|
|
5
|
-
* Demo extractor is a reference implementation of an ADaaS connector to facilitate rapid immersion into ADaaS.
|
|
6
|
-
*
|
|
7
|
-
* @class DemoExtractor
|
|
8
|
-
* @deprecated
|
|
9
|
-
**/
|
|
10
|
-
export declare class DemoExtractor {
|
|
11
|
-
private event;
|
|
12
|
-
private adapter;
|
|
13
|
-
private uploader;
|
|
14
|
-
constructor(event: AirdropEvent, adapter: Adapter<ConnectorState>);
|
|
15
|
-
run(): Promise<void>;
|
|
16
|
-
}
|
|
17
|
-
export {};
|
|
18
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/deprecated/demo-extractor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAIb,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAIrC,KAAK,cAAc,GAAG,MAAM,CAAC;AAE7B;;;;;IAKI;AACJ,qBAAa,aAAa;IACxB,OAAO,CAAC,KAAK,CAAe;IAC5B,OAAO,CAAC,OAAO,CAA0B;IACzC,OAAO,CAAC,QAAQ,CAAW;gBAEf,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,CAAC,cAAc,CAAC;IAS3D,GAAG;CA0MV"}
|
|
@@ -1,161 +0,0 @@
|
|
|
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.DemoExtractor = void 0;
|
|
7
|
-
const extraction_1 = require("../../types/extraction");
|
|
8
|
-
const uploader_1 = require("../uploader");
|
|
9
|
-
const external_domain_metadata_json_1 = __importDefault(require("./external_domain_metadata.json"));
|
|
10
|
-
/**
|
|
11
|
-
* Demo extractor is a reference implementation of an ADaaS connector to facilitate rapid immersion into ADaaS.
|
|
12
|
-
*
|
|
13
|
-
* @class DemoExtractor
|
|
14
|
-
* @deprecated
|
|
15
|
-
**/
|
|
16
|
-
class DemoExtractor {
|
|
17
|
-
constructor(event, adapter) {
|
|
18
|
-
this.event = event;
|
|
19
|
-
this.adapter = adapter;
|
|
20
|
-
this.uploader = new uploader_1.Uploader(this.event.execution_metadata.devrev_endpoint, this.event.context.secrets.service_account_token);
|
|
21
|
-
}
|
|
22
|
-
async run() {
|
|
23
|
-
switch (this.event.payload.event_type) {
|
|
24
|
-
case extraction_1.EventType.ExtractionExternalSyncUnitsStart: {
|
|
25
|
-
const externalSyncUnits = [
|
|
26
|
-
{
|
|
27
|
-
id: 'devrev',
|
|
28
|
-
name: 'devrev',
|
|
29
|
-
description: 'Demo external sync unit',
|
|
30
|
-
},
|
|
31
|
-
];
|
|
32
|
-
await this.adapter.emit(extraction_1.ExtractorEventType.ExtractionExternalSyncUnitsDone, {
|
|
33
|
-
external_sync_units: externalSyncUnits,
|
|
34
|
-
});
|
|
35
|
-
break;
|
|
36
|
-
}
|
|
37
|
-
case extraction_1.EventType.ExtractionMetadataStart: {
|
|
38
|
-
const { artifact, error } = await this.uploader.upload('metadata_1.jsonl', 'external_domain_metadata', external_domain_metadata_json_1.default);
|
|
39
|
-
if (error || !artifact) {
|
|
40
|
-
await this.adapter.emit(extraction_1.ExtractorEventType.ExtractionMetadataError, {
|
|
41
|
-
error,
|
|
42
|
-
});
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
await this.adapter.emit(extraction_1.ExtractorEventType.ExtractionMetadataDone, {
|
|
46
|
-
artifacts: [artifact],
|
|
47
|
-
});
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
case extraction_1.EventType.ExtractionDataStart: {
|
|
51
|
-
const contacts = [
|
|
52
|
-
{
|
|
53
|
-
id: 'contact-1',
|
|
54
|
-
created_date: '1999-12-25T01:00:03+01:00',
|
|
55
|
-
modified_date: '1999-12-25T01:00:03+01:00',
|
|
56
|
-
data: {
|
|
57
|
-
email: 'johnsmith@test.com',
|
|
58
|
-
name: 'John Smith',
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
id: 'contact-2',
|
|
63
|
-
created_date: '1999-12-27T15:31:34+01:00',
|
|
64
|
-
modified_date: '2002-04-09T01:55:31+02:00',
|
|
65
|
-
data: {
|
|
66
|
-
email: 'janesmith@test.com',
|
|
67
|
-
name: 'Jane Smith',
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
];
|
|
71
|
-
const { artifact, error } = await this.uploader.upload('contacts_1.json', 'contacts', contacts);
|
|
72
|
-
if (error || !artifact) {
|
|
73
|
-
await this.adapter.emit(extraction_1.ExtractorEventType.ExtractionDataError, {
|
|
74
|
-
error,
|
|
75
|
-
});
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
await this.adapter.emit(extraction_1.ExtractorEventType.ExtractionDataProgress, {
|
|
79
|
-
progress: 50,
|
|
80
|
-
artifacts: [artifact],
|
|
81
|
-
});
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
case extraction_1.EventType.ExtractionDataContinue: {
|
|
85
|
-
const users = [
|
|
86
|
-
{
|
|
87
|
-
id: 'user-1',
|
|
88
|
-
created_date: '1999-12-25T01:00:03+01:00',
|
|
89
|
-
modified_date: '1999-12-25T01:00:03+01:00',
|
|
90
|
-
data: {
|
|
91
|
-
email: 'johndoe@test.com',
|
|
92
|
-
name: 'John Doe',
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
id: 'user-2',
|
|
97
|
-
created_date: '1999-12-27T15:31:34+01:00',
|
|
98
|
-
modified_date: '2002-04-09T01:55:31+02:00',
|
|
99
|
-
data: {
|
|
100
|
-
email: 'janedoe@test.com',
|
|
101
|
-
name: 'Jane Doe',
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
];
|
|
105
|
-
const { artifact, error } = await this.uploader.upload('users_1.json', 'users', users);
|
|
106
|
-
if (error || !artifact) {
|
|
107
|
-
await this.adapter.emit(extraction_1.ExtractorEventType.ExtractionDataError, {
|
|
108
|
-
error,
|
|
109
|
-
});
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
await this.adapter.emit(extraction_1.ExtractorEventType.ExtractionDataDone, {
|
|
113
|
-
progress: 100,
|
|
114
|
-
artifacts: [artifact],
|
|
115
|
-
});
|
|
116
|
-
break;
|
|
117
|
-
}
|
|
118
|
-
case extraction_1.EventType.ExtractionDataDelete: {
|
|
119
|
-
await this.adapter.emit(extraction_1.ExtractorEventType.ExtractionDataDeleteDone);
|
|
120
|
-
break;
|
|
121
|
-
}
|
|
122
|
-
case extraction_1.EventType.ExtractionAttachmentsStart: {
|
|
123
|
-
const attachment1 = ['This is attachment1.txt content'];
|
|
124
|
-
const { artifact, error } = await this.uploader.upload('attachment1.txt', 'attachment', attachment1);
|
|
125
|
-
if (error || !artifact) {
|
|
126
|
-
await this.adapter.emit(extraction_1.ExtractorEventType.ExtractionAttachmentsError, {
|
|
127
|
-
error,
|
|
128
|
-
});
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
await this.adapter.emit(extraction_1.ExtractorEventType.ExtractionAttachmentsProgress, {
|
|
132
|
-
artifacts: [artifact],
|
|
133
|
-
});
|
|
134
|
-
break;
|
|
135
|
-
}
|
|
136
|
-
case extraction_1.EventType.ExtractionAttachmentsContinue: {
|
|
137
|
-
const attachment2 = ['This is attachment2.txt content'];
|
|
138
|
-
const { artifact, error } = await this.uploader.upload('attachment2.txt', 'attachment', attachment2);
|
|
139
|
-
if (error || !artifact) {
|
|
140
|
-
await this.adapter.emit(extraction_1.ExtractorEventType.ExtractionAttachmentsError, {
|
|
141
|
-
error,
|
|
142
|
-
});
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
await this.adapter.emit(extraction_1.ExtractorEventType.ExtractionAttachmentsDone, {
|
|
146
|
-
artifacts: [artifact],
|
|
147
|
-
});
|
|
148
|
-
break;
|
|
149
|
-
}
|
|
150
|
-
case extraction_1.EventType.ExtractionAttachmentsDelete: {
|
|
151
|
-
await this.adapter.emit(extraction_1.ExtractorEventType.ExtractionAttachmentsDeleteDone);
|
|
152
|
-
break;
|
|
153
|
-
}
|
|
154
|
-
default: {
|
|
155
|
-
console.error('Event in DemoExtractor run not recognized: ' +
|
|
156
|
-
JSON.stringify(this.event.payload.event_type));
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
exports.DemoExtractor = DemoExtractor;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { RawAxiosRequestHeaders } from 'axios';
|
|
2
|
-
import { HTTPResponse } from '../../http/types';
|
|
3
|
-
export declare const defaultResponse: HTTPResponse;
|
|
4
|
-
/**
|
|
5
|
-
* HTTPClient class to make HTTP requests
|
|
6
|
-
* @deprecated
|
|
7
|
-
*/
|
|
8
|
-
export declare class HTTPClient {
|
|
9
|
-
private retryAfter;
|
|
10
|
-
private retryAt;
|
|
11
|
-
private axiosInstance;
|
|
12
|
-
constructor();
|
|
13
|
-
/**
|
|
14
|
-
*
|
|
15
|
-
* Function to make a GET call to the endpoint.
|
|
16
|
-
* There is special handling for rate limit exceeded error.
|
|
17
|
-
* In case of rate limit exceeded, the function returns success as true and the delay time in seconds
|
|
18
|
-
* In case of any other error, the function returns success as false and the error message
|
|
19
|
-
*/
|
|
20
|
-
getCall(endpoint: string, headers: RawAxiosRequestHeaders, params?: any): Promise<HTTPResponse>;
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/deprecated/http/client.ts"],"names":[],"mappings":"AAAA,OAAc,EAGZ,sBAAsB,EACvB,MAAM,OAAO,CAAC;AAKf,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,eAAO,MAAM,eAAe,EAAE,YAQ7B,CAAC;AAEF;;;GAGG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,aAAa,CAAkB;;IA8BvC;;;;;;OAMG;IACG,OAAO,CACX,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,sBAAsB,EAE/B,MAAM,CAAC,EAAE,GAAG,GACX,OAAO,CAAC,YAAY,CAAC;CA8EzB"}
|