@devrev/ts-adaas 0.0.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +186 -116
- package/dist/common/constants.d.ts +10 -0
- package/dist/common/constants.js +27 -0
- package/dist/common/control-protocol.d.ts +7 -0
- package/dist/common/control-protocol.js +41 -0
- package/dist/common/helpers.d.ts +4 -0
- package/dist/common/helpers.js +38 -0
- package/dist/common/install-initial-domain-mapping.d.ts +3 -0
- package/dist/common/install-initial-domain-mapping.js +87 -0
- package/dist/{src → deprecated}/adapter/index.d.ts +10 -7
- package/dist/{src → deprecated}/adapter/index.js +13 -10
- package/dist/{src → deprecated}/common/helpers.d.ts +1 -2
- package/dist/deprecated/common/helpers.js +47 -0
- package/dist/deprecated/demo-extractor/external_domain_metadata.json +38 -0
- package/dist/deprecated/demo-extractor/index.d.ts +17 -0
- package/dist/deprecated/demo-extractor/index.js +161 -0
- package/dist/{src → deprecated}/uploader/index.d.ts +1 -1
- package/dist/{src → deprecated}/uploader/index.js +3 -1
- package/dist/{src/http → http}/client.d.ts +2 -1
- package/dist/index.d.ts +10 -0
- package/dist/index.js +30 -0
- package/dist/logger/logger.d.ts +14 -0
- package/dist/logger/logger.interfaces.d.ts +14 -0
- package/dist/logger/logger.interfaces.js +9 -0
- package/dist/logger/logger.js +91 -0
- package/dist/logger/logger.test.js +49 -0
- package/dist/repo/repo.d.ts +14 -0
- package/dist/repo/repo.interfaces.d.ts +43 -0
- package/dist/repo/repo.interfaces.js +2 -0
- package/dist/repo/repo.js +68 -0
- package/dist/repo/repo.test.js +74 -0
- package/dist/state/state.d.ts +24 -0
- package/dist/state/state.interfaces.d.ts +24 -0
- package/dist/state/state.interfaces.js +2 -0
- package/dist/state/state.js +115 -0
- package/dist/tests/test-helpers.d.ts +9 -0
- package/dist/tests/test-helpers.interfaces.d.ts +11 -0
- package/dist/tests/test-helpers.interfaces.js +2 -0
- package/dist/tests/test-helpers.js +88 -0
- package/dist/tests/test-worker.js +16 -0
- package/dist/types/common.d.ts +39 -0
- package/dist/{src/types → types}/common.js +4 -0
- package/dist/{src/types → types}/extraction.d.ts +57 -12
- package/dist/{src/types → types}/extraction.js +12 -29
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.js +11 -0
- package/dist/types/workers.d.ts +142 -0
- package/dist/types/workers.js +23 -0
- package/dist/uploader/uploader.d.ts +38 -0
- package/dist/uploader/uploader.interfaces.d.ts +63 -0
- package/dist/uploader/uploader.interfaces.js +2 -0
- package/dist/uploader/uploader.js +351 -0
- package/dist/{tests → uploader}/uploader.test.js +7 -5
- package/dist/workers/create-worker.d.ts +4 -0
- package/dist/workers/create-worker.js +30 -0
- package/dist/workers/create-worker.test.js +25 -0
- package/dist/workers/default-workers/attachments-deletion.d.ts +1 -0
- package/dist/workers/default-workers/attachments-deletion.js +13 -0
- package/dist/workers/default-workers/attachments-extraction.d.ts +1 -0
- package/dist/workers/default-workers/attachments-extraction.js +49 -0
- package/dist/workers/default-workers/data-deletion.d.ts +1 -0
- package/dist/workers/default-workers/data-deletion.js +15 -0
- package/dist/workers/default-workers/data-extraction.d.ts +1 -0
- package/dist/workers/default-workers/data-extraction.js +101 -0
- package/dist/workers/default-workers/external-sync-units-extraction.d.ts +1 -0
- package/dist/workers/default-workers/external-sync-units-extraction.js +27 -0
- package/dist/workers/default-workers/metadata-extraction.d.ts +1 -0
- package/dist/workers/default-workers/metadata-extraction.js +26 -0
- package/dist/workers/dummy-extractor/data-normalization.d.ts +4 -0
- package/dist/workers/dummy-extractor/data-normalization.js +41 -0
- package/dist/workers/dummy-extractor/external_domain_metadata.json +58 -0
- package/dist/workers/process-task.d.ts +2 -0
- package/dist/workers/process-task.js +44 -0
- package/dist/workers/spawn.d.ts +25 -0
- package/dist/workers/spawn.js +163 -0
- package/dist/workers/worker-adapter.d.ts +48 -0
- package/dist/workers/worker-adapter.js +138 -0
- package/dist/workers/worker.d.ts +1 -0
- package/dist/workers/worker.js +6 -0
- package/package.json +9 -5
- package/dist/src/common/constants.d.ts +0 -2
- package/dist/src/common/constants.js +0 -10
- package/dist/src/common/helpers.js +0 -59
- package/dist/src/demo-extractor/index.d.ts +0 -11
- package/dist/src/demo-extractor/index.js +0 -157
- package/dist/src/demo-extractor/initial_domain_mapping.json +0 -107
- package/dist/src/index.d.ts +0 -5
- package/dist/src/index.js +0 -21
- package/dist/src/logging/index.d.ts +0 -18
- package/dist/src/logging/index.js +0 -39
- package/dist/src/state/index.d.ts +0 -23
- package/dist/src/state/index.js +0 -111
- package/dist/src/types/common.d.ts +0 -33
- package/dist/src/types/index.d.ts +0 -2
- package/dist/src/types/index.js +0 -18
- package/dist/tests/adapter.helpers.test.js +0 -60
- package/dist/tests/adapter.test.js +0 -122
- package/dist/tests/demo-extractor.test.js +0 -60
- package/dist/tests/state.test.js +0 -100
- /package/dist/{src/http → http}/client.js +0 -0
- /package/dist/{src/http → http}/constants.d.ts +0 -0
- /package/dist/{src/http → http}/constants.js +0 -0
- /package/dist/{src/http → http}/index.d.ts +0 -0
- /package/dist/{src/http → http}/index.js +0 -0
- /package/dist/{src/http → http}/types.d.ts +0 -0
- /package/dist/{src/http → http}/types.js +0 -0
- /package/dist/{tests/adapter.helpers.test.d.ts → logger/logger.test.d.ts} +0 -0
- /package/dist/{tests/adapter.test.d.ts → repo/repo.test.d.ts} +0 -0
- /package/dist/tests/{demo-extractor.test.d.ts → test-worker.d.ts} +0 -0
- /package/dist/{tests → uploader}/uploader.test.d.ts +0 -0
- /package/dist/{tests/state.test.d.ts → workers/create-worker.test.d.ts} +0 -0
|
@@ -1,65 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ExtractionMode = exports.ExtractorEventType = exports.EventType = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* EventType is an enum that defines the different types of events that can be sent to the external extractor from ADaaS.
|
|
6
|
+
* The external extractor can use these events to know what to do next in the extraction process.
|
|
7
|
+
*/
|
|
4
8
|
var EventType;
|
|
5
9
|
(function (EventType) {
|
|
6
|
-
// Get the list of sync units (repos, projects, ...) that can be extracted
|
|
7
10
|
EventType["ExtractionExternalSyncUnitsStart"] = "EXTRACTION_EXTERNAL_SYNC_UNITS_START";
|
|
8
|
-
// Start the extraction of external sync unit's metadata (repos, projects, ...)
|
|
9
11
|
EventType["ExtractionMetadataStart"] = "EXTRACTION_METADATA_START";
|
|
10
|
-
// Start the extraction of a specific external sync unit
|
|
11
12
|
EventType["ExtractionDataStart"] = "EXTRACTION_DATA_START";
|
|
12
|
-
// Continue the extraction of a specific external sync unit
|
|
13
13
|
EventType["ExtractionDataContinue"] = "EXTRACTION_DATA_CONTINUE";
|
|
14
|
-
// Give the external extractor an opportunity to clean up after itself
|
|
15
14
|
EventType["ExtractionDataDelete"] = "EXTRACTION_DATA_DELETE";
|
|
16
|
-
// Extract all the attachments for a specific external sync unit
|
|
17
15
|
EventType["ExtractionAttachmentsStart"] = "EXTRACTION_ATTACHMENTS_START";
|
|
18
|
-
// Continue the extraction of attachments for a specific external sync unit
|
|
19
16
|
EventType["ExtractionAttachmentsContinue"] = "EXTRACTION_ATTACHMENTS_CONTINUE";
|
|
20
|
-
// Give the external extractor an opportunity to clean up after extractions of external sync units
|
|
21
17
|
EventType["ExtractionAttachmentsDelete"] = "EXTRACTION_ATTACHMENTS_DELETE";
|
|
22
18
|
})(EventType || (exports.EventType = EventType = {}));
|
|
19
|
+
/**
|
|
20
|
+
* ExtractorEventType is an enum that defines the different types of events that can be sent from the external extractor to ADaaS.
|
|
21
|
+
* The external extractor can use these events to inform ADaaS about the progress of the extraction process.
|
|
22
|
+
*/
|
|
23
23
|
var ExtractorEventType;
|
|
24
24
|
(function (ExtractorEventType) {
|
|
25
|
-
/* Sync Units */
|
|
26
|
-
// Sent when the extraction of external sync units finished
|
|
27
25
|
ExtractorEventType["ExtractionExternalSyncUnitsDone"] = "EXTRACTION_EXTERNAL_SYNC_UNITS_DONE";
|
|
28
|
-
// Sent when there was an unrecoverable error for extraction of external sync units.
|
|
29
|
-
// Must contain a list of error records.
|
|
30
26
|
ExtractorEventType["ExtractionExternalSyncUnitsError"] = "EXTRACTION_EXTERNAL_SYNC_UNITS_ERROR";
|
|
31
|
-
/* Metadata */
|
|
32
|
-
// Sent when the extraction of metadata finished
|
|
33
27
|
ExtractorEventType["ExtractionMetadataDone"] = "EXTRACTION_METADATA_DONE";
|
|
34
|
-
// Sent when there was an unrecoverable error for extraction of metadata.
|
|
35
28
|
ExtractorEventType["ExtractionMetadataError"] = "EXTRACTION_METADATA_ERROR";
|
|
36
|
-
/* Data */
|
|
37
|
-
// Sent after a batch was extracted, contains artifact IDs of the uploaded files
|
|
38
29
|
ExtractorEventType["ExtractionDataProgress"] = "EXTRACTION_DATA_PROGRESS";
|
|
39
|
-
// Sent when there is a rate limit of more than ~1m, adapter will restart the extraction after the delay
|
|
40
30
|
ExtractorEventType["ExtractionDataDelay"] = "EXTRACTION_DATA_DELAY";
|
|
41
|
-
// Sent when the extraction of data finished
|
|
42
31
|
ExtractorEventType["ExtractionDataDone"] = "EXTRACTION_DATA_DONE";
|
|
43
|
-
// Sent when there was an unrecoverable error for extraction of data
|
|
44
32
|
ExtractorEventType["ExtractionDataError"] = "EXTRACTION_DATA_ERROR";
|
|
45
|
-
// Sent when the external extractor has finished cleaning up after itself
|
|
46
33
|
ExtractorEventType["ExtractionDataDeleteDone"] = "EXTRACTION_DATA_DELETE_DONE";
|
|
47
|
-
// Sent when there was an unrecoverable error for extraction of data
|
|
48
34
|
ExtractorEventType["ExtractionDataDeleteError"] = "EXTRACTION_DATA_DELETE_ERROR";
|
|
49
|
-
/* Attachments */
|
|
50
|
-
// Sent after a batch was extracted, contains artifact IDs of the uploaded files
|
|
51
35
|
ExtractorEventType["ExtractionAttachmentsProgress"] = "EXTRACTION_ATTACHMENTS_PROGRESS";
|
|
52
|
-
// Sent when there is a rate limit of more than ~30s, adapter will restart the extraction after the delay
|
|
53
36
|
ExtractorEventType["ExtractionAttachmentsDelay"] = "EXTRACTION_ATTACHMENTS_DELAY";
|
|
54
|
-
// Sent when the extraction of attachements is finished
|
|
55
37
|
ExtractorEventType["ExtractionAttachmentsDone"] = "EXTRACTION_ATTACHMENTS_DONE";
|
|
56
|
-
// Sent when there was an unrecoverable error for extraction of attachments
|
|
57
38
|
ExtractorEventType["ExtractionAttachmentsError"] = "EXTRACTION_ATTACHMENTS_ERROR";
|
|
58
|
-
// Sent when the external extractor has finished cleaning up after itself
|
|
59
39
|
ExtractorEventType["ExtractionAttachmentsDeleteDone"] = "EXTRACTION_ATTACHMENTS_DELETE_DONE";
|
|
60
|
-
// Sent when there was an unrecoverable error for extraction of attachments
|
|
61
40
|
ExtractorEventType["ExtractionAttachmentsDeleteError"] = "EXTRACTION_ATTACHMENTS_DELETE_ERROR";
|
|
62
41
|
})(ExtractorEventType || (exports.ExtractorEventType = ExtractorEventType = {}));
|
|
42
|
+
/**
|
|
43
|
+
* ExtractionMode is an enum that defines the different modes of extraction that can be used by the external extractor.
|
|
44
|
+
* It can be either INITIAL or INCREMENTAL. INITIAL mode is used for the first/initial import, while INCREMENTAL mode is used for doing syncs.
|
|
45
|
+
*/
|
|
63
46
|
var ExtractionMode;
|
|
64
47
|
(function (ExtractionMode) {
|
|
65
48
|
ExtractionMode["INITIAL"] = "INITIAL";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { ErrorLevel, ErrorRecord, LogRecord, AdapterUpdateParams, InitialDomainMapping, } from './common';
|
|
2
|
+
export { EventType, ExtractorEventType, ExtractionMode, ExternalSyncUnit, EventContextIn, EventContextOut, ConnectionData, EventData, DomainObjectState, AirdropEvent, AirdropMessage, ExtractorEvent, } from './extraction';
|
|
3
|
+
export { NormalizedItem, NormalizedAttachment } from '../repo/repo.interfaces';
|
|
4
|
+
export { AdapterState } from '../state/state.interfaces';
|
|
5
|
+
export { Artifact, ArtifactsPrepareResponse, UploadResponse, StreamResponse, StreamAttachmentsResponse, SsorAttachment, } from '../uploader/uploader.interfaces';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExtractionMode = exports.ExtractorEventType = exports.EventType = exports.ErrorLevel = void 0;
|
|
4
|
+
// Common
|
|
5
|
+
var common_1 = require("./common");
|
|
6
|
+
Object.defineProperty(exports, "ErrorLevel", { enumerable: true, get: function () { return common_1.ErrorLevel; } });
|
|
7
|
+
// Extraction
|
|
8
|
+
var extraction_1 = require("./extraction");
|
|
9
|
+
Object.defineProperty(exports, "EventType", { enumerable: true, get: function () { return extraction_1.EventType; } });
|
|
10
|
+
Object.defineProperty(exports, "ExtractorEventType", { enumerable: true, get: function () { return extraction_1.ExtractorEventType; } });
|
|
11
|
+
Object.defineProperty(exports, "ExtractionMode", { enumerable: true, get: function () { return extraction_1.ExtractionMode; } });
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { Worker } from 'worker_threads';
|
|
2
|
+
import { MessagePort } from 'node:worker_threads';
|
|
3
|
+
import { State } from '../state/state';
|
|
4
|
+
import { WorkerAdapter } from '../workers/worker-adapter';
|
|
5
|
+
import { ExtractorEventType, AirdropEvent } from './extraction';
|
|
6
|
+
/**
|
|
7
|
+
* WorkerAdapterInterface is an interface for WorkerAdapter class.
|
|
8
|
+
* @interface WorkerAdapterInterface
|
|
9
|
+
* @constructor
|
|
10
|
+
* @param {AirdropEvent} event - The event object received from the platform
|
|
11
|
+
* @param {object=} initialState - The initial state of the adapter
|
|
12
|
+
* @param {MessagePort} parentPort - The parent port of the worker thread
|
|
13
|
+
* @param {WorkerAdapterInterface} options - The options to create a new instance of WorkerAdapter class
|
|
14
|
+
*/
|
|
15
|
+
export interface WorkerAdapterInterface<ConnectorState> {
|
|
16
|
+
event: AirdropEvent;
|
|
17
|
+
adapterState: State<ConnectorState>;
|
|
18
|
+
parentPort: MessagePort;
|
|
19
|
+
options: WorkerAdapterOptions;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* WorkerAdapterOptions represents the options for WorkerAdapter class.
|
|
23
|
+
* @interface WorkerAdapterOptions
|
|
24
|
+
* @constructor
|
|
25
|
+
* @param {boolean=} isLocalDevelopment - A flag to indicate if the adapter is being used in local development
|
|
26
|
+
* @param {number=} timeout - The timeout for the worker thread
|
|
27
|
+
*/
|
|
28
|
+
export interface WorkerAdapterOptions {
|
|
29
|
+
isLocalDevelopment?: boolean;
|
|
30
|
+
timeout?: number;
|
|
31
|
+
}
|
|
32
|
+
export type SpawnResolve = (value: boolean | PromiseLike<boolean>) => void;
|
|
33
|
+
/**
|
|
34
|
+
* SpawnInterface is an interface for Spawn class.
|
|
35
|
+
* @interface SpawnInterface
|
|
36
|
+
* @constructor
|
|
37
|
+
* @param {AirdropEvent} event - The event object received from the platform
|
|
38
|
+
* @param {Worker} worker - The worker thread
|
|
39
|
+
*/
|
|
40
|
+
export interface SpawnInterface {
|
|
41
|
+
event: AirdropEvent;
|
|
42
|
+
worker: Worker;
|
|
43
|
+
options: WorkerAdapterOptions | null;
|
|
44
|
+
resolve: SpawnResolve;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* SpawnFactoryInterface is an interface for Spawn class factory.
|
|
48
|
+
* Spawn class is responsible for spawning a new worker thread and managing the lifecycle of the worker.
|
|
49
|
+
* The class provides utilities to emit control events to the platform and exit the worker gracefully.
|
|
50
|
+
* In case of lambda timeout, the class emits a lambda timeout event to the platform.
|
|
51
|
+
* @interface SpawnFactoryInterface
|
|
52
|
+
* @constructor
|
|
53
|
+
* @param {AirdropEvent} event - The event object received from the platform
|
|
54
|
+
* @param {object=} initialState - The initial state of the adapter
|
|
55
|
+
* @param {string} workerPath - The path to the worker file
|
|
56
|
+
* @param {WorkerAdapterOptions} options - The options to create a new instance of Spawn class
|
|
57
|
+
*/
|
|
58
|
+
export interface SpawnFactoryInterface<ConnectorState> {
|
|
59
|
+
event: AirdropEvent;
|
|
60
|
+
initialState: ConnectorState;
|
|
61
|
+
workerPath?: string;
|
|
62
|
+
options?: WorkerAdapterOptions;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* TaskAdapterInterface is an interface for TaskAdapter class.
|
|
66
|
+
* @interface TaskAdapterInterface
|
|
67
|
+
* @constructor
|
|
68
|
+
* @param {WorkerAdapter} adapter - The adapter object
|
|
69
|
+
*/
|
|
70
|
+
export interface TaskAdapterInterface<ConnectorState> {
|
|
71
|
+
adapter: WorkerAdapter<ConnectorState>;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* ProcessTaskInterface is an interface for ProcessTask class.
|
|
75
|
+
* @interface ProcessTaskInterface
|
|
76
|
+
* @constructor
|
|
77
|
+
* @param {function} task - The task to be executed, returns exit code
|
|
78
|
+
* @param {function} onTimeout - The task to be executed on timeout, returns exit code
|
|
79
|
+
*/
|
|
80
|
+
export interface ProcessTaskInterface<ConnectorState> {
|
|
81
|
+
task: (params: TaskAdapterInterface<ConnectorState>) => void;
|
|
82
|
+
onTimeout: (params: TaskAdapterInterface<ConnectorState>) => void;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* WorkerEvent represents the standard worker events.
|
|
86
|
+
*/
|
|
87
|
+
export declare enum WorkerEvent {
|
|
88
|
+
WorkerMessage = "message",
|
|
89
|
+
WorkerOnline = "online",
|
|
90
|
+
WorkerError = "error",
|
|
91
|
+
WorkerExit = "exit"
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* WorkerMessageSubject represents the handled worker message subjects.
|
|
95
|
+
*/
|
|
96
|
+
export declare enum WorkerMessageSubject {
|
|
97
|
+
WorkerMessageEmitted = "emit",
|
|
98
|
+
WorkerMessageDone = "done",
|
|
99
|
+
WorkerMessageExit = "exit",
|
|
100
|
+
WorkerMessageLog = "log"
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* WorkerMessageEmitted interface represents the structure of the emitted worker message.
|
|
104
|
+
*/
|
|
105
|
+
export interface WorkerMessageEmitted {
|
|
106
|
+
subject: WorkerMessageSubject.WorkerMessageEmitted;
|
|
107
|
+
payload: {
|
|
108
|
+
eventType: ExtractorEventType;
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* WorkerMessageDone interface represents the structure of the done worker message.
|
|
113
|
+
*/
|
|
114
|
+
export interface WorkerMessageDone {
|
|
115
|
+
subject: WorkerMessageSubject.WorkerMessageDone;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* WorkerMessageExit interface represents the structure of the exit worker message.
|
|
119
|
+
*/
|
|
120
|
+
export interface WorkerMessageExit {
|
|
121
|
+
subject: WorkerMessageSubject.WorkerMessageExit;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* WorkerMessage represents the structure of the worker message.
|
|
125
|
+
*/
|
|
126
|
+
export type WorkerMessage = WorkerMessageDone | WorkerMessageEmitted | WorkerMessageExit;
|
|
127
|
+
/**
|
|
128
|
+
* WorkerData represents the structure of the worker data object.
|
|
129
|
+
*/
|
|
130
|
+
export interface WorkerData<ConnectorState> {
|
|
131
|
+
event: AirdropEvent;
|
|
132
|
+
initialState: ConnectorState;
|
|
133
|
+
workerPath: string;
|
|
134
|
+
options?: WorkerAdapterOptions;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* GetWorkerPathInterface is an interface for getting the worker path.
|
|
138
|
+
*/
|
|
139
|
+
export interface GetWorkerPathInterface {
|
|
140
|
+
event: AirdropEvent;
|
|
141
|
+
connectorWorkerPath?: string | null;
|
|
142
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WorkerMessageSubject = exports.WorkerEvent = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* WorkerEvent represents the standard worker events.
|
|
6
|
+
*/
|
|
7
|
+
var WorkerEvent;
|
|
8
|
+
(function (WorkerEvent) {
|
|
9
|
+
WorkerEvent["WorkerMessage"] = "message";
|
|
10
|
+
WorkerEvent["WorkerOnline"] = "online";
|
|
11
|
+
WorkerEvent["WorkerError"] = "error";
|
|
12
|
+
WorkerEvent["WorkerExit"] = "exit";
|
|
13
|
+
})(WorkerEvent || (exports.WorkerEvent = WorkerEvent = {}));
|
|
14
|
+
/**
|
|
15
|
+
* WorkerMessageSubject represents the handled worker message subjects.
|
|
16
|
+
*/
|
|
17
|
+
var WorkerMessageSubject;
|
|
18
|
+
(function (WorkerMessageSubject) {
|
|
19
|
+
WorkerMessageSubject["WorkerMessageEmitted"] = "emit";
|
|
20
|
+
WorkerMessageSubject["WorkerMessageDone"] = "done";
|
|
21
|
+
WorkerMessageSubject["WorkerMessageExit"] = "exit";
|
|
22
|
+
WorkerMessageSubject["WorkerMessageLog"] = "log";
|
|
23
|
+
})(WorkerMessageSubject || (exports.WorkerMessageSubject = WorkerMessageSubject = {}));
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { UploadResponse, StreamAttachmentsResponse, UploaderFactoryInterface } from './uploader.interfaces';
|
|
2
|
+
export declare class Uploader {
|
|
3
|
+
private event;
|
|
4
|
+
private betaDevrevSdk;
|
|
5
|
+
private isLocalDevelopment?;
|
|
6
|
+
constructor({ event, options }: UploaderFactoryInterface);
|
|
7
|
+
/**
|
|
8
|
+
* Uploads the fetched objects to the DevRev platform.
|
|
9
|
+
* The fetched objects are uploaded to the platform and the artifact information is returned.
|
|
10
|
+
* @param {string} filename - The name of the file to be uploaded
|
|
11
|
+
* @param {string} itemType - The type of the item to be uploaded
|
|
12
|
+
* @param {object[] | object} fetchedObjects - The fetched objects to be uploaded
|
|
13
|
+
* @returns {Promise<UploadResponse>} - The response object containing the artifact information
|
|
14
|
+
* or error information if there was an error
|
|
15
|
+
*/
|
|
16
|
+
upload(itemType: string, fetchedObjects: object[] | object): Promise<UploadResponse>;
|
|
17
|
+
private prepareArtifact;
|
|
18
|
+
private uploadToArtifact;
|
|
19
|
+
private streamToArtifact;
|
|
20
|
+
/**
|
|
21
|
+
* Streams the attachments to the DevRev platform.
|
|
22
|
+
* The attachments are streamed to the platform and the artifact information is returned.
|
|
23
|
+
* @param {string} attachmentsMetadataArtifactId - The artifact ID of the attachments metadata
|
|
24
|
+
* @returns {Promise<UploadResponse>} - The response object containing the ssoAttachment artifact information
|
|
25
|
+
* or error information if there was an error
|
|
26
|
+
*/
|
|
27
|
+
streamAttachments({ attachmentsMetadataArtifactId, }: {
|
|
28
|
+
attachmentsMetadataArtifactId: string;
|
|
29
|
+
}): Promise<StreamAttachmentsResponse>;
|
|
30
|
+
private getArtifactDownloadUrl;
|
|
31
|
+
private downloadArtifact;
|
|
32
|
+
private compressGzip;
|
|
33
|
+
private decompressGzip;
|
|
34
|
+
private parseJsonl;
|
|
35
|
+
private stream;
|
|
36
|
+
private getFileStreamResponse;
|
|
37
|
+
private downloadToLocal;
|
|
38
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { AirdropEvent } from '../types/extraction';
|
|
2
|
+
import { WorkerAdapterOptions } from '../types/workers';
|
|
3
|
+
import { ErrorRecord } from '../types/common';
|
|
4
|
+
export interface UploaderFactoryInterface {
|
|
5
|
+
event: AirdropEvent;
|
|
6
|
+
options?: WorkerAdapterOptions;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Artifact is an interface that defines the structure of an artifact. Artifact is a file that is generated by the extractor and uploaded to ADaaS.
|
|
10
|
+
*/
|
|
11
|
+
export interface Artifact {
|
|
12
|
+
id: string;
|
|
13
|
+
item_type: string;
|
|
14
|
+
item_count: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* ArtifactsPrepareResponse is an interface that defines the structure of the response from the prepare artifacts endpoint.
|
|
18
|
+
* @deprecated
|
|
19
|
+
*/
|
|
20
|
+
export interface ArtifactsPrepareResponse {
|
|
21
|
+
url: string;
|
|
22
|
+
id: string;
|
|
23
|
+
form_data: {
|
|
24
|
+
key: string;
|
|
25
|
+
value: string;
|
|
26
|
+
}[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* UploadResponse is an interface that defines the structure of the response from upload through Uploader.
|
|
30
|
+
*/
|
|
31
|
+
export interface UploadResponse {
|
|
32
|
+
artifact?: Artifact;
|
|
33
|
+
error?: ErrorRecord;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* StreamAttachmentsResponse is an interface that defines the structure of the response from the stream attachments through Uploader.
|
|
37
|
+
*/
|
|
38
|
+
export interface StreamAttachmentsResponse {
|
|
39
|
+
ssorAttachments?: SsorAttachment[];
|
|
40
|
+
error?: ErrorRecord;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* StreamResponse is an interface that defines the structure of the response from the stream of single attachment through Uploader.
|
|
44
|
+
*/
|
|
45
|
+
export interface StreamResponse {
|
|
46
|
+
ssorAttachment?: SsorAttachment;
|
|
47
|
+
error?: ErrorRecord;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* SsorAttachment is an interface that defines the structure of the SSOR attachment.
|
|
51
|
+
*/
|
|
52
|
+
export interface SsorAttachment {
|
|
53
|
+
id: {
|
|
54
|
+
devrev: string;
|
|
55
|
+
external: string;
|
|
56
|
+
};
|
|
57
|
+
parent_id: {
|
|
58
|
+
external: string;
|
|
59
|
+
};
|
|
60
|
+
actor_id: {
|
|
61
|
+
external: string;
|
|
62
|
+
};
|
|
63
|
+
}
|