@devrev/airsync-sdk 2.0.0-beta.3 → 2.0.0-beta.5
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/MIGRATION.md +1028 -0
- package/README.md +5 -11
- package/dist/attachments-streaming/attachments-streaming-pool.d.ts +7 -9
- package/dist/attachments-streaming/attachments-streaming-pool.d.ts.map +1 -1
- package/dist/attachments-streaming/attachments-streaming-pool.interfaces.d.ts +2 -7
- package/dist/attachments-streaming/attachments-streaming-pool.interfaces.d.ts.map +1 -1
- package/dist/attachments-streaming/attachments-streaming-pool.js +54 -56
- package/dist/common/constants.d.ts +4 -5
- package/dist/common/constants.d.ts.map +1 -1
- package/dist/common/constants.js +6 -7
- package/dist/common/helpers.d.ts +3 -35
- package/dist/common/helpers.d.ts.map +1 -1
- package/dist/common/helpers.js +5 -50
- 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} +4 -8
- package/dist/index.d.ts +24 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +43 -32
- package/dist/logger/logger.d.ts +12 -53
- package/dist/logger/logger.d.ts.map +1 -1
- package/dist/logger/logger.interfaces.d.ts +0 -1
- package/dist/logger/logger.interfaces.d.ts.map +1 -1
- package/dist/logger/logger.js +36 -68
- package/dist/mappers/mappers.d.ts +7 -46
- package/dist/mappers/mappers.d.ts.map +1 -1
- package/dist/mappers/mappers.interfaces.d.ts +175 -0
- package/dist/mappers/mappers.interfaces.d.ts.map +1 -0
- package/dist/mappers/{mappers.interface.js → mappers.interfaces.js} +4 -13
- package/dist/mappers/mappers.js +11 -45
- package/dist/multithreading/adapters/base-adapter.d.ts +30 -32
- package/dist/multithreading/adapters/base-adapter.d.ts.map +1 -1
- package/dist/multithreading/adapters/base-adapter.js +97 -62
- package/dist/multithreading/adapters/extraction-adapter.d.ts +16 -29
- package/dist/multithreading/adapters/extraction-adapter.d.ts.map +1 -1
- package/dist/multithreading/adapters/extraction-adapter.js +203 -206
- package/dist/multithreading/adapters/loading-adapter.d.ts +8 -13
- package/dist/multithreading/adapters/loading-adapter.d.ts.map +1 -1
- package/dist/multithreading/adapters/loading-adapter.helpers.d.ts +2 -12
- package/dist/multithreading/adapters/loading-adapter.helpers.d.ts.map +1 -1
- package/dist/multithreading/adapters/loading-adapter.helpers.js +2 -12
- package/dist/multithreading/adapters/loading-adapter.js +294 -346
- package/dist/multithreading/emit.d.ts +11 -0
- package/dist/multithreading/emit.d.ts.map +1 -0
- package/dist/{common/control-protocol.js → multithreading/emit.js} +5 -7
- package/dist/multithreading/process-task.d.ts +2 -12
- package/dist/multithreading/process-task.d.ts.map +1 -1
- package/dist/multithreading/process-task.js +46 -43
- package/dist/multithreading/spawn/spawn.d.ts +3 -9
- 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 +128 -20
- package/dist/multithreading/spawn/spawn.js +24 -39
- package/dist/multithreading/worker.js +1 -4
- package/dist/repo/repo.d.ts +10 -0
- 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 +4 -16
- package/dist/repo/repo.interfaces.d.ts.map +1 -1
- package/dist/repo/repo.js +23 -8
- package/dist/state/base-state.d.ts +16 -38
- package/dist/state/base-state.d.ts.map +1 -1
- package/dist/state/base-state.js +19 -41
- package/dist/state/extraction-state.d.ts +6 -21
- package/dist/state/extraction-state.d.ts.map +1 -1
- package/dist/state/extraction-state.js +8 -25
- package/dist/{common → state}/install-initial-domain-mapping.d.ts +1 -1
- 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 +3 -14
- package/dist/state/loading-state.d.ts.map +1 -1
- package/dist/state/loading-state.js +3 -14
- package/dist/state/state.d.ts +4 -0
- package/dist/state/state.d.ts.map +1 -0
- package/dist/state/state.interfaces.d.ts +33 -37
- package/dist/state/state.interfaces.d.ts.map +1 -1
- package/dist/state/state.interfaces.js +16 -11
- package/dist/state/state.js +11 -0
- package/dist/state/time-value-resolver.d.ts +17 -0
- package/dist/state/time-value-resolver.d.ts.map +1 -0
- package/dist/{common → state}/time-value-resolver.js +9 -41
- package/dist/testing/mock-event.d.ts +10 -0
- package/dist/testing/mock-event.d.ts.map +1 -0
- package/dist/{common/test-utils.js → testing/mock-event.js} +17 -14
- package/dist/testing/mock-server.d.ts +29 -0
- package/dist/testing/mock-server.d.ts.map +1 -0
- package/dist/testing/mock-server.interfaces.d.ts +48 -0
- package/dist/testing/mock-server.interfaces.d.ts.map +1 -0
- package/dist/{mock-server → testing}/mock-server.js +21 -33
- package/dist/types/common.d.ts +1 -12
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/common.js +1 -6
- package/dist/types/errors.d.ts +9 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/external-domain-metadata.d.ts +30 -171
- package/dist/types/external-domain-metadata.d.ts.map +1 -1
- package/dist/types/extraction.d.ts +64 -94
- package/dist/types/extraction.d.ts.map +1 -1
- package/dist/types/extraction.js +6 -34
- package/dist/types/loading.d.ts +1 -2
- package/dist/types/loading.d.ts.map +1 -1
- package/dist/types/loading.js +0 -1
- package/dist/types/workers.d.ts +39 -94
- package/dist/types/workers.d.ts.map +1 -1
- package/dist/types/workers.js +0 -6
- package/dist/uploader/uploader.d.ts +8 -59
- package/dist/uploader/uploader.d.ts.map +1 -1
- package/dist/uploader/uploader.helpers.d.ts +4 -27
- package/dist/uploader/uploader.helpers.d.ts.map +1 -1
- package/dist/uploader/uploader.helpers.js +64 -30
- package/dist/uploader/uploader.interfaces.d.ts +15 -25
- package/dist/uploader/uploader.interfaces.d.ts.map +1 -1
- package/dist/uploader/uploader.interfaces.js +8 -0
- package/dist/uploader/uploader.js +23 -89
- package/package.json +8 -6
- package/dist/airsync-sdk.d.ts +0 -2059
- 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 -540
- package/dist/common/control-protocol.d.ts +0 -10
- package/dist/common/control-protocol.d.ts.map +0 -1
- package/dist/common/errors.d.ts +0 -6
- package/dist/common/errors.d.ts.map +0 -1
- 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 -211
- package/dist/common/test-utils.d.ts +0 -19
- package/dist/common/test-utils.d.ts.map +0 -1
- package/dist/common/time-value-resolver.d.ts +0 -47
- package/dist/common/time-value-resolver.d.ts.map +0 -1
- package/dist/common/time-value-resolver.test.d.ts +0 -2
- package/dist/common/time-value-resolver.test.d.ts.map +0 -1
- package/dist/common/time-value-resolver.test.js +0 -268
- 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 -175
- 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 -60
- 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 -2
- package/dist/http/index.d.ts.map +0 -1
- package/dist/http/index.js +0 -17
- 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 -537
- 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 -105
- package/dist/mock-server/mock-server.d.ts +0 -47
- package/dist/mock-server/mock-server.d.ts.map +0 -1
- package/dist/mock-server/mock-server.interfaces.d.ts +0 -73
- package/dist/mock-server/mock-server.interfaces.d.ts.map +0 -1
- package/dist/multithreading/adapters/base-adapter.emit.test.d.ts +0 -2
- package/dist/multithreading/adapters/base-adapter.emit.test.d.ts.map +0 -1
- package/dist/multithreading/adapters/base-adapter.emit.test.js +0 -403
- package/dist/multithreading/adapters/extraction-adapter.artifacts.test.d.ts +0 -2
- package/dist/multithreading/adapters/extraction-adapter.artifacts.test.d.ts.map +0 -1
- package/dist/multithreading/adapters/extraction-adapter.artifacts.test.js +0 -175
- package/dist/multithreading/adapters/extraction-adapter.test.d.ts +0 -2
- package/dist/multithreading/adapters/extraction-adapter.test.d.ts.map +0 -1
- package/dist/multithreading/adapters/extraction-adapter.test.js +0 -789
- package/dist/multithreading/adapters/loading-adapter.helpers.test.d.ts +0 -2
- package/dist/multithreading/adapters/loading-adapter.helpers.test.d.ts.map +0 -1
- package/dist/multithreading/adapters/loading-adapter.helpers.test.js +0 -514
- package/dist/multithreading/adapters/loading-adapter.test.d.ts +0 -2
- package/dist/multithreading/adapters/loading-adapter.test.d.ts.map +0 -1
- package/dist/multithreading/adapters/loading-adapter.test.js +0 -589
- package/dist/multithreading/adapters/serialization.test.d.ts +0 -2
- package/dist/multithreading/adapters/serialization.test.d.ts.map +0 -1
- package/dist/multithreading/adapters/serialization.test.js +0 -71
- 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 -108
- package/dist/multithreading/process-task.test.d.ts +0 -2
- package/dist/multithreading/process-task.test.d.ts.map +0 -1
- package/dist/multithreading/process-task.test.js +0 -146
- 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/spawn/spawn.test.d.ts +0 -2
- package/dist/multithreading/spawn/spawn.test.d.ts.map +0 -1
- package/dist/multithreading/spawn/spawn.test.js +0 -232
- 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 -184
- package/dist/state/state.extract-window.test.d.ts +0 -2
- package/dist/state/state.extract-window.test.d.ts.map +0 -1
- package/dist/state/state.extract-window.test.js +0 -163
- package/dist/state/state.pending-boundaries.test.d.ts +0 -2
- package/dist/state/state.pending-boundaries.test.d.ts.map +0 -1
- package/dist/state/state.pending-boundaries.test.js +0 -189
- package/dist/state/state.post-state.test.d.ts +0 -2
- package/dist/state/state.post-state.test.d.ts.map +0 -1
- package/dist/state/state.post-state.test.js +0 -78
- 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 -271
- package/dist/state/state.time-value-resolution.test.d.ts +0 -2
- package/dist/state/state.time-value-resolution.test.d.ts.map +0 -1
- package/dist/state/state.time-value-resolution.test.js +0 -175
- package/dist/tsdoc-metadata.json +0 -11
- 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 -96
- package/dist/types/index.d.ts +0 -10
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -21
- 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 -256
- 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 -601
- /package/dist/{mock-server → testing}/mock-server.interfaces.js +0 -0
- /package/dist/{common → types}/errors.js +0 -0
|
@@ -4,17 +4,10 @@ exports.ExtractionAdapter = void 0;
|
|
|
4
4
|
const attachments_streaming_pool_1 = require("../../attachments-streaming/attachments-streaming-pool");
|
|
5
5
|
const constants_1 = require("../../common/constants");
|
|
6
6
|
const logger_1 = require("../../logger/logger");
|
|
7
|
-
const logger_context_1 = require("../../logger/logger.context");
|
|
8
7
|
const repo_1 = require("../../repo/repo");
|
|
9
8
|
const extraction_1 = require("../../types/extraction");
|
|
10
9
|
const base_adapter_1 = require("./base-adapter");
|
|
11
|
-
/**
|
|
12
|
-
* ExtractionAdapter is the adapter passed to extraction tasks. It exposes the
|
|
13
|
-
* extraction surface (repos, artifacts, attachment streaming) and updates the
|
|
14
|
-
* extraction boundaries before emitting.
|
|
15
|
-
*
|
|
16
|
-
* @public
|
|
17
|
-
*/
|
|
10
|
+
/** Adapter passed to extraction tasks (repos, artifacts, attachment streaming). @public */
|
|
18
11
|
class ExtractionAdapter extends base_adapter_1.BaseAdapter {
|
|
19
12
|
constructor(params) {
|
|
20
13
|
super(params);
|
|
@@ -22,13 +15,7 @@ class ExtractionAdapter extends base_adapter_1.BaseAdapter {
|
|
|
22
15
|
this.currentEventDataLength = 0;
|
|
23
16
|
this._artifacts = [];
|
|
24
17
|
}
|
|
25
|
-
|
|
26
|
-
return this.adapterState.extractionScope;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Returns whether the given item type should be extracted.
|
|
30
|
-
* Defaults to true if the scope is empty or the item type is not listed.
|
|
31
|
-
*/
|
|
18
|
+
/** Defaults to true if the scope is empty or the item type is not listed. */
|
|
32
19
|
shouldExtract(itemType) {
|
|
33
20
|
const scope = this.extractionScope;
|
|
34
21
|
if (Object.keys(scope).length === 0)
|
|
@@ -43,11 +30,13 @@ class ExtractionAdapter extends base_adapter_1.BaseAdapter {
|
|
|
43
30
|
repo.itemType !== constants_1.SSOR_ATTACHMENT;
|
|
44
31
|
return new repo_1.Repo(Object.assign(Object.assign({ event: this.event, itemType: repo.itemType }, (shouldNormalize && { normalize: repo.normalize })), { onUpload: (artifact) => {
|
|
45
32
|
var _a;
|
|
46
|
-
|
|
33
|
+
this.lastExtractedItemType = repo.itemType;
|
|
34
|
+
// Artifact ids are kept in state for later attachment streaming
|
|
47
35
|
if (repo.itemType === constants_1.AirSyncDefaultItemTypes.ATTACHMENTS) {
|
|
48
|
-
(_a = this.
|
|
36
|
+
(_a = this.sdkState.toDevRev) === null || _a === void 0 ? void 0 : _a.attachmentsMetadata.artifactIds.push(artifact.id);
|
|
49
37
|
}
|
|
50
|
-
//
|
|
38
|
+
// Track size of artifact objects that go in the SQS message; flip
|
|
39
|
+
// isTimeout once the threshold is exceeded to force an early emit.
|
|
51
40
|
this.currentEventDataLength += Buffer.byteLength(JSON.stringify(artifact), 'utf8');
|
|
52
41
|
if (this.currentEventDataLength > constants_1.EVENT_SIZE_THRESHOLD_BYTES &&
|
|
53
42
|
!this.isTimeout) {
|
|
@@ -57,14 +46,12 @@ class ExtractionAdapter extends base_adapter_1.BaseAdapter {
|
|
|
57
46
|
});
|
|
58
47
|
}
|
|
59
48
|
getRepo(itemType) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return repo;
|
|
67
|
-
});
|
|
49
|
+
const repo = this.repos.find((repo) => repo.itemType === itemType);
|
|
50
|
+
if (!repo) {
|
|
51
|
+
console.error(`Repo for item type ${itemType} not found.`);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
return repo;
|
|
68
55
|
}
|
|
69
56
|
get artifacts() {
|
|
70
57
|
return this._artifacts;
|
|
@@ -75,16 +62,16 @@ class ExtractionAdapter extends base_adapter_1.BaseAdapter {
|
|
|
75
62
|
.filter((value, index, self) => self.indexOf(value) === index);
|
|
76
63
|
}
|
|
77
64
|
async beforeEmit(newEventType) {
|
|
78
|
-
// Upload all repos before emitting the event
|
|
79
65
|
console.log(`Uploading all repos before emitting event with event type: ${newEventType}.`);
|
|
80
66
|
await this.uploadAllRepos();
|
|
67
|
+
// When the full extraction cycle completes, commit the extraction window
|
|
68
|
+
// boundaries so subsequent incremental syncs can resume from them.
|
|
81
69
|
if (newEventType === extraction_1.ExtractorEventType.AttachmentExtractionDone) {
|
|
82
|
-
const sdkState = this.
|
|
83
|
-
// Clear pending extraction boundaries now that the cycle is complete
|
|
70
|
+
const sdkState = this.sdkState;
|
|
84
71
|
sdkState.pendingWorkersOldest = '';
|
|
85
72
|
sdkState.pendingWorkersNewest = '';
|
|
86
|
-
//
|
|
87
|
-
//
|
|
73
|
+
// Expand boundaries: workersOldest keeps the earliest timestamp seen,
|
|
74
|
+
// workersNewest the latest.
|
|
88
75
|
const extractionStart = this.event.payload.event_context.extract_from;
|
|
89
76
|
const extractionEnd = this.event.payload.event_context.extract_to;
|
|
90
77
|
if (extractionStart &&
|
|
@@ -103,6 +90,37 @@ class ExtractionAdapter extends base_adapter_1.BaseAdapter {
|
|
|
103
90
|
const isExtractionEvent = Object.values(extraction_1.ExtractorEventType).includes(newEventType);
|
|
104
91
|
return isExtractionEvent ? { artifacts: this.artifacts } : {};
|
|
105
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* Attaches the last-extracted item type and its created/modified date ranges
|
|
95
|
+
* to data/attachment done/progress events, mirroring the metadata v1 sent.
|
|
96
|
+
*/
|
|
97
|
+
buildWorkerMetadata(newEventType) {
|
|
98
|
+
if (newEventType !== extraction_1.ExtractorEventType.DataExtractionDone &&
|
|
99
|
+
newEventType !== extraction_1.ExtractorEventType.DataExtractionProgress &&
|
|
100
|
+
newEventType !== extraction_1.ExtractorEventType.AttachmentExtractionDone &&
|
|
101
|
+
newEventType !== extraction_1.ExtractorEventType.AttachmentExtractionProgress) {
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
const repo = this.lastExtractedItemType
|
|
105
|
+
? this.repos.find((r) => r.itemType === this.lastExtractedItemType)
|
|
106
|
+
: undefined;
|
|
107
|
+
if (!repo) {
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
item_type: repo.itemType,
|
|
112
|
+
newest_created_date: this.toRfc3339Timestamp(repo.dateRanges.creationDate.newest),
|
|
113
|
+
oldest_created_date: this.toRfc3339Timestamp(repo.dateRanges.creationDate.oldest),
|
|
114
|
+
newest_modified_date: this.toRfc3339Timestamp(repo.dateRanges.modifiedDate.newest),
|
|
115
|
+
oldest_modified_date: this.toRfc3339Timestamp(repo.dateRanges.modifiedDate.oldest),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
toRfc3339Timestamp(ms) {
|
|
119
|
+
if (ms === undefined || !Number.isFinite(ms)) {
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
return new Date(ms).toISOString();
|
|
123
|
+
}
|
|
106
124
|
afterEmit() {
|
|
107
125
|
this.artifacts = [];
|
|
108
126
|
}
|
|
@@ -116,94 +134,89 @@ class ExtractionAdapter extends base_adapter_1.BaseAdapter {
|
|
|
116
134
|
}
|
|
117
135
|
}
|
|
118
136
|
async processAttachment(attachment, stream) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
137
|
+
var _a, _b, _c;
|
|
138
|
+
const { httpStream, delay, error } = await stream({
|
|
139
|
+
item: attachment,
|
|
140
|
+
event: this.event,
|
|
141
|
+
});
|
|
142
|
+
if (error) {
|
|
143
|
+
return { error };
|
|
144
|
+
}
|
|
145
|
+
else if (delay) {
|
|
146
|
+
return { delay };
|
|
147
|
+
}
|
|
148
|
+
if (httpStream) {
|
|
149
|
+
const fileType = attachment.content_type ||
|
|
150
|
+
((_a = httpStream.headers['content-type']) === null || _a === void 0 ? void 0 : _a.toString()) ||
|
|
151
|
+
'application/octet-stream';
|
|
152
|
+
const contentLength = (_b = httpStream.headers['content-length']) === null || _b === void 0 ? void 0 : _b.toString();
|
|
153
|
+
const fileSize = contentLength ? parseInt(contentLength) : undefined;
|
|
154
|
+
const { error: artifactUrlError, response: artifactUrlResponse } = await this.uploader.getArtifactUploadUrl(attachment.file_name, fileType, fileSize);
|
|
155
|
+
if (artifactUrlError) {
|
|
156
|
+
this.destroyHttpStream(httpStream);
|
|
157
|
+
return {
|
|
158
|
+
error: {
|
|
159
|
+
message: `Error while preparing artifact for attachment ID ${attachment.id}. Skipping attachment. ${(0, logger_1.serializeError)(artifactUrlError)}`,
|
|
160
|
+
fileSize: fileSize,
|
|
161
|
+
},
|
|
162
|
+
};
|
|
130
163
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
if (artifactUrlError) {
|
|
140
|
-
this.destroyHttpStream(httpStream);
|
|
141
|
-
return {
|
|
142
|
-
error: {
|
|
143
|
-
message: `Error while preparing artifact for attachment ID ${attachment.id}. Skipping attachment. ${(0, logger_1.serializeError)(artifactUrlError)}`,
|
|
144
|
-
fileSize: fileSize,
|
|
145
|
-
},
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
// Stream attachment
|
|
149
|
-
const { error: uploadedArtifactError } = await this.uploader.streamArtifact(artifactUrlResponse, httpStream);
|
|
150
|
-
if (uploadedArtifactError) {
|
|
151
|
-
this.destroyHttpStream(httpStream);
|
|
152
|
-
return {
|
|
153
|
-
error: {
|
|
154
|
-
message: `Error while streaming to artifact for attachment ID ${attachment.id}. Skipping attachment. ` +
|
|
155
|
-
(0, logger_1.serializeError)(uploadedArtifactError),
|
|
156
|
-
fileSize: fileSize,
|
|
157
|
-
},
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
// Confirm attachment upload
|
|
161
|
-
const { error: confirmArtifactUploadError } = await this.uploader.confirmArtifactUpload(artifactUrlResponse.artifact_id);
|
|
162
|
-
if (confirmArtifactUploadError) {
|
|
163
|
-
return {
|
|
164
|
-
error: {
|
|
165
|
-
message: `Error while confirming upload for attachment ID ${attachment.id}. ` +
|
|
166
|
-
(0, logger_1.serializeError)(confirmArtifactUploadError),
|
|
167
|
-
fileSize: fileSize,
|
|
168
|
-
},
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
const ssorAttachment = {
|
|
172
|
-
id: {
|
|
173
|
-
devrev: artifactUrlResponse.artifact_id,
|
|
174
|
-
external: attachment.id,
|
|
164
|
+
const { error: uploadedArtifactError } = await this.uploader.streamArtifact(artifactUrlResponse, httpStream);
|
|
165
|
+
if (uploadedArtifactError) {
|
|
166
|
+
this.destroyHttpStream(httpStream);
|
|
167
|
+
return {
|
|
168
|
+
error: {
|
|
169
|
+
message: `Error while streaming to artifact for attachment ID ${attachment.id}. Skipping attachment. ` +
|
|
170
|
+
(0, logger_1.serializeError)(uploadedArtifactError),
|
|
171
|
+
fileSize: fileSize,
|
|
175
172
|
},
|
|
176
|
-
|
|
177
|
-
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
const { error: confirmArtifactUploadError } = await this.uploader.confirmArtifactUpload(artifactUrlResponse.artifact_id);
|
|
176
|
+
if (confirmArtifactUploadError) {
|
|
177
|
+
return {
|
|
178
|
+
error: {
|
|
179
|
+
message: `Error while confirming upload for attachment ID ${attachment.id}. ` +
|
|
180
|
+
(0, logger_1.serializeError)(confirmArtifactUploadError),
|
|
181
|
+
fileSize: fileSize,
|
|
178
182
|
},
|
|
179
183
|
};
|
|
180
|
-
if (attachment.author_id) {
|
|
181
|
-
ssorAttachment.actor_id = {
|
|
182
|
-
external: attachment.author_id,
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
// This will set inline flag in ssor_attachment only if it is explicity
|
|
186
|
-
// set in the attachment object.
|
|
187
|
-
if (attachment.inline === true) {
|
|
188
|
-
ssorAttachment.inline = true;
|
|
189
|
-
}
|
|
190
|
-
else if (attachment.inline === false) {
|
|
191
|
-
ssorAttachment.inline = false;
|
|
192
|
-
}
|
|
193
|
-
await ((_c = this.getRepo('ssor_attachment')) === null || _c === void 0 ? void 0 : _c.push([ssorAttachment]));
|
|
194
|
-
return;
|
|
195
184
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
185
|
+
const ssorAttachment = {
|
|
186
|
+
id: {
|
|
187
|
+
devrev: artifactUrlResponse.artifact_id,
|
|
188
|
+
external: attachment.id,
|
|
189
|
+
},
|
|
190
|
+
parent_id: {
|
|
191
|
+
external: attachment.parent_id,
|
|
199
192
|
},
|
|
200
193
|
};
|
|
201
|
-
|
|
194
|
+
if (attachment.author_id) {
|
|
195
|
+
ssorAttachment.actor_id = {
|
|
196
|
+
external: attachment.author_id,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
// Set inline flag only if it is explicitly set on the attachment.
|
|
200
|
+
if (attachment.inline === true) {
|
|
201
|
+
ssorAttachment.inline = true;
|
|
202
|
+
}
|
|
203
|
+
else if (attachment.inline === false) {
|
|
204
|
+
ssorAttachment.inline = false;
|
|
205
|
+
}
|
|
206
|
+
if (this.isTimeout) {
|
|
207
|
+
this.destroyHttpStream(httpStream);
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
await ((_c = this.getRepo('ssor_attachment')) === null || _c === void 0 ? void 0 : _c.push([ssorAttachment]));
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
return {
|
|
214
|
+
error: {
|
|
215
|
+
message: `Error while opening attachment stream. Skipping attachment.`,
|
|
216
|
+
},
|
|
217
|
+
};
|
|
202
218
|
}
|
|
203
|
-
/**
|
|
204
|
-
* Destroys a stream to prevent memory leaks.
|
|
205
|
-
* @param httpStream - The axios response stream to destroy
|
|
206
|
-
*/
|
|
219
|
+
/** Destroys a stream to prevent memory leaks. */
|
|
207
220
|
destroyHttpStream(httpStream) {
|
|
208
221
|
try {
|
|
209
222
|
if (httpStream && httpStream.data) {
|
|
@@ -219,107 +232,91 @@ class ExtractionAdapter extends base_adapter_1.BaseAdapter {
|
|
|
219
232
|
console.warn('Error while destroying HTTP stream:', error);
|
|
220
233
|
}
|
|
221
234
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
235
|
+
async streamAttachments({ stream, processors, batchSize = 1, }) {
|
|
236
|
+
var _a, _b;
|
|
237
|
+
if (batchSize <= 0) {
|
|
238
|
+
console.warn(`The specified batch size (${batchSize}) is invalid. Using 1 instead.`);
|
|
239
|
+
batchSize = 1;
|
|
240
|
+
}
|
|
241
|
+
if (batchSize > 50) {
|
|
242
|
+
console.warn(`The specified batch size (${batchSize}) is too large. Using 50 instead.`);
|
|
243
|
+
batchSize = 50;
|
|
244
|
+
}
|
|
245
|
+
const repos = [
|
|
246
|
+
{
|
|
247
|
+
itemType: 'ssor_attachment',
|
|
248
|
+
},
|
|
249
|
+
];
|
|
250
|
+
this.initializeRepos(repos);
|
|
251
|
+
const attachmentsMetadata = (_a = this.sdkState.toDevRev) === null || _a === void 0 ? void 0 : _a.attachmentsMetadata;
|
|
252
|
+
if (!((_b = attachmentsMetadata === null || attachmentsMetadata === void 0 ? void 0 : attachmentsMetadata.artifactIds) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
253
|
+
console.log(`No attachments metadata artifact IDs found in state.`);
|
|
254
|
+
return { status: 'success' };
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
console.log(`Found ${attachmentsMetadata.artifactIds.length} attachments metadata artifact IDs in state.`);
|
|
258
|
+
}
|
|
259
|
+
while (attachmentsMetadata.artifactIds.length > 0) {
|
|
260
|
+
const attachmentsMetadataArtifactId = attachmentsMetadata.artifactIds[0];
|
|
261
|
+
console.log(`Started processing attachments for attachments metadata artifact ID: ${attachmentsMetadataArtifactId}.`);
|
|
262
|
+
const { attachments, error } = await this.uploader.getAttachmentsFromArtifactId({
|
|
263
|
+
artifact: attachmentsMetadataArtifactId,
|
|
264
|
+
});
|
|
265
|
+
if (error) {
|
|
266
|
+
console.error(`Failed to get attachments for artifact ID: ${attachmentsMetadataArtifactId}.`);
|
|
267
|
+
return { status: 'error', error };
|
|
236
268
|
}
|
|
237
|
-
if (
|
|
238
|
-
console.warn(`
|
|
239
|
-
|
|
269
|
+
if (!attachments || attachments.length === 0) {
|
|
270
|
+
console.warn(`No attachments found for artifact ID: ${attachmentsMetadataArtifactId}.`);
|
|
271
|
+
attachmentsMetadata.artifactIds.shift();
|
|
272
|
+
attachmentsMetadata.lastProcessed = 0;
|
|
273
|
+
continue;
|
|
240
274
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
275
|
+
console.log(`Found ${attachments.length} attachments for artifact ID: ${attachmentsMetadataArtifactId}.`);
|
|
276
|
+
let response;
|
|
277
|
+
if (processors) {
|
|
278
|
+
console.log(`Using custom processors for attachments.`);
|
|
279
|
+
const reducer = processors.reducer;
|
|
280
|
+
const iterator = processors.iterator;
|
|
281
|
+
const reducedAttachments = reducer({
|
|
282
|
+
attachments,
|
|
283
|
+
adapter: this,
|
|
284
|
+
batchSize,
|
|
285
|
+
});
|
|
286
|
+
response = await iterator({
|
|
287
|
+
reducedAttachments,
|
|
288
|
+
adapter: this,
|
|
289
|
+
stream,
|
|
290
|
+
});
|
|
252
291
|
}
|
|
253
292
|
else {
|
|
254
|
-
console.log(`
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
const { attachments, error } = await this.uploader.getAttachmentsFromArtifactId({
|
|
261
|
-
artifact: attachmentsMetadataArtifactId,
|
|
293
|
+
console.log(`Using attachments streaming pool for attachments streaming.`);
|
|
294
|
+
const attachmentsPool = new attachments_streaming_pool_1.AttachmentsStreamingPool({
|
|
295
|
+
adapter: this,
|
|
296
|
+
attachments,
|
|
297
|
+
batchSize,
|
|
298
|
+
stream,
|
|
262
299
|
});
|
|
263
|
-
|
|
264
|
-
console.error(`Failed to get attachments for artifact ID: ${attachmentsMetadataArtifactId}.`);
|
|
265
|
-
return { error };
|
|
266
|
-
}
|
|
267
|
-
if (!attachments || attachments.length === 0) {
|
|
268
|
-
console.warn(`No attachments found for artifact ID: ${attachmentsMetadataArtifactId}.`);
|
|
269
|
-
// Remove empty artifact and reset lastProcessed
|
|
270
|
-
attachmentsMetadata.artifactIds.shift();
|
|
271
|
-
attachmentsMetadata.lastProcessed = 0;
|
|
272
|
-
continue;
|
|
273
|
-
}
|
|
274
|
-
console.log(`Found ${attachments.length} attachments for artifact ID: ${attachmentsMetadataArtifactId}.`);
|
|
275
|
-
let response;
|
|
276
|
-
if (processors) {
|
|
277
|
-
console.log(`Using custom processors for attachments.`);
|
|
278
|
-
const reducer = processors.reducer;
|
|
279
|
-
const iterator = processors.iterator;
|
|
280
|
-
const reducedAttachments = (0, logger_context_1.runWithUserLogContext)(() => reducer({
|
|
281
|
-
attachments,
|
|
282
|
-
adapter: this,
|
|
283
|
-
batchSize,
|
|
284
|
-
}));
|
|
285
|
-
response = await (0, logger_context_1.runWithUserLogContext)(async () => {
|
|
286
|
-
return await iterator({
|
|
287
|
-
reducedAttachments,
|
|
288
|
-
adapter: this,
|
|
289
|
-
stream,
|
|
290
|
-
});
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
else {
|
|
294
|
-
console.log(`Using attachments streaming pool for attachments streaming.`);
|
|
295
|
-
const attachmentsPool = new attachments_streaming_pool_1.AttachmentsStreamingPool({
|
|
296
|
-
adapter: this,
|
|
297
|
-
attachments,
|
|
298
|
-
attachmentsMetadata,
|
|
299
|
-
batchSize,
|
|
300
|
-
stream,
|
|
301
|
-
});
|
|
302
|
-
response = await attachmentsPool.streamAll();
|
|
303
|
-
}
|
|
304
|
-
if ((response === null || response === void 0 ? void 0 : response.delay) || (response === null || response === void 0 ? void 0 : response.error)) {
|
|
305
|
-
return response;
|
|
306
|
-
}
|
|
307
|
-
// On timeout, emit progress and exit to allow continuation.
|
|
308
|
-
if (this.isTimeout) {
|
|
309
|
-
console.log(`Timeout detected after processing attachments for artifact ID: ${attachmentsMetadataArtifactId}. Emitting progress to allow continuation.`);
|
|
310
|
-
await this.emit(extraction_1.ExtractorEventType.AttachmentExtractionProgress);
|
|
311
|
-
process.exit(0);
|
|
312
|
-
return;
|
|
313
|
-
}
|
|
314
|
-
console.log(`Finished processing all attachments for artifact ID: ${attachmentsMetadataArtifactId}.`);
|
|
315
|
-
attachmentsMetadata.artifactIds.shift();
|
|
316
|
-
attachmentsMetadata.lastProcessed = 0;
|
|
317
|
-
if (attachmentsMetadata.lastProcessedAttachmentsIdsList) {
|
|
318
|
-
attachmentsMetadata.lastProcessedAttachmentsIdsList.length = 0;
|
|
319
|
-
}
|
|
300
|
+
response = await attachmentsPool.streamAll();
|
|
320
301
|
}
|
|
321
|
-
|
|
322
|
-
|
|
302
|
+
if (response === null || response === void 0 ? void 0 : response.error) {
|
|
303
|
+
return { status: 'error', error: response.error };
|
|
304
|
+
}
|
|
305
|
+
if (response === null || response === void 0 ? void 0 : response.delay) {
|
|
306
|
+
return { status: 'delay', delaySeconds: response.delay };
|
|
307
|
+
}
|
|
308
|
+
if (this.isTimeout) {
|
|
309
|
+
console.log(`Timeout detected after processing attachments for artifact ID: ${attachmentsMetadataArtifactId}. Returning progress to allow continuation.`);
|
|
310
|
+
return { status: 'progress' };
|
|
311
|
+
}
|
|
312
|
+
console.log(`Finished processing all attachments for artifact ID: ${attachmentsMetadataArtifactId}.`);
|
|
313
|
+
attachmentsMetadata.artifactIds.shift();
|
|
314
|
+
attachmentsMetadata.lastProcessed = 0;
|
|
315
|
+
if (attachmentsMetadata.lastProcessedAttachmentsIdsList) {
|
|
316
|
+
attachmentsMetadata.lastProcessedAttachmentsIdsList.length = 0;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
return { status: 'success' };
|
|
323
320
|
}
|
|
324
321
|
}
|
|
325
322
|
exports.ExtractionAdapter = ExtractionAdapter;
|
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
import { Mappers } from '../../mappers/mappers';
|
|
2
|
-
import {
|
|
2
|
+
import { BaseState } from '../../state/state';
|
|
3
3
|
import { AirSyncEvent, EventData, ExtractorEventType } from '../../types/extraction';
|
|
4
|
-
import { ExternalSystemAttachment, ExternalSystemItem, ExternalSystemLoadingFunction, FileToLoad, ItemTypesToLoadParams, ItemTypeToLoad, LoaderEventType, LoaderReport, LoadItemResponse
|
|
5
|
-
import { WorkerAdapterOptions } from '../../types/workers';
|
|
4
|
+
import { ExternalSystemAttachment, ExternalSystemItem, ExternalSystemLoadingFunction, FileToLoad, ItemTypesToLoadParams, ItemTypeToLoad, LoaderEventType, LoaderReport, LoadItemResponse } from '../../types/loading';
|
|
5
|
+
import { TaskResult, WorkerAdapterOptions } from '../../types/workers';
|
|
6
6
|
import { BaseAdapter } from './base-adapter';
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
* surface (item/attachment loading, mappers, loader reports).
|
|
10
|
-
*
|
|
11
|
-
* @public
|
|
12
|
-
*/
|
|
13
|
-
export declare class LoadingAdapter<ConnectorState> extends BaseAdapter<ConnectorState, LoadingState<ConnectorState>> {
|
|
7
|
+
/** Adapter passed to loading tasks (item/attachment loading, mappers, loader reports). @public */
|
|
8
|
+
export declare class LoadingAdapter<ConnectorState> extends BaseAdapter<ConnectorState> {
|
|
14
9
|
private loaderReports;
|
|
15
10
|
private _processedFiles;
|
|
16
11
|
private _mappers;
|
|
17
12
|
constructor(params: {
|
|
18
13
|
event: AirSyncEvent;
|
|
19
|
-
adapterState:
|
|
14
|
+
adapterState: BaseState<ConnectorState>;
|
|
20
15
|
options?: WorkerAdapterOptions;
|
|
21
16
|
});
|
|
22
17
|
get reports(): LoaderReport[];
|
|
@@ -25,13 +20,13 @@ export declare class LoadingAdapter<ConnectorState> extends BaseAdapter<Connecto
|
|
|
25
20
|
protected beforeEmit(): Promise<void>;
|
|
26
21
|
protected buildEmitPayload(newEventType: ExtractorEventType | LoaderEventType): EventData;
|
|
27
22
|
protected afterEmit(): void;
|
|
28
|
-
loadItemTypes({ itemTypesToLoad, }: ItemTypesToLoadParams): Promise<
|
|
23
|
+
loadItemTypes({ itemTypesToLoad, }: ItemTypesToLoadParams): Promise<TaskResult>;
|
|
29
24
|
getLoaderBatches({ supportedItemTypes, }: {
|
|
30
25
|
supportedItemTypes: string[];
|
|
31
26
|
}): Promise<FileToLoad[]>;
|
|
32
27
|
loadAttachments({ create, }: {
|
|
33
28
|
create: ExternalSystemLoadingFunction<ExternalSystemAttachment>;
|
|
34
|
-
}): Promise<
|
|
29
|
+
}): Promise<TaskResult>;
|
|
35
30
|
loadItem({ item, itemTypeToLoad, }: {
|
|
36
31
|
item: ExternalSystemItem;
|
|
37
32
|
itemTypeToLoad: ItemTypeToLoad;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loading-adapter.d.ts","sourceRoot":"","sources":["../../../src/multithreading/adapters/loading-adapter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"loading-adapter.d.ts","sourceRoot":"","sources":["../../../src/multithreading/adapters/loading-adapter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EACL,YAAY,EACZ,SAAS,EAET,kBAAkB,EACnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAEL,wBAAwB,EACxB,kBAAkB,EAClB,6BAA6B,EAC7B,UAAU,EACV,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,YAAY,EACZ,gBAAgB,EAEjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAEvE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAM7C,kGAAkG;AAClG,qBAAa,cAAc,CACzB,cAAc,CACd,SAAQ,WAAW,CAAC,cAAc,CAAC;IACnC,OAAO,CAAC,aAAa,CAAiB;IACtC,OAAO,CAAC,eAAe,CAAW;IAClC,OAAO,CAAC,QAAQ,CAAU;gBAEd,MAAM,EAAE;QAClB,KAAK,EAAE,YAAY,CAAC;QACpB,YAAY,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC;QACxC,OAAO,CAAC,EAAE,oBAAoB,CAAC;KAChC;IAUD,IAAI,OAAO,IAAI,YAAY,EAAE,CAE5B;IAED,IAAI,cAAc,IAAI,MAAM,EAAE,CAE7B;IAED,IAAI,OAAO,IAAI,OAAO,CAErB;cAEe,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3C,SAAS,CAAC,gBAAgB,CACxB,YAAY,EAAE,kBAAkB,GAAG,eAAe,GACjD,SAAS;IAYZ,SAAS,CAAC,SAAS,IAAI,IAAI;IAIrB,aAAa,CAAC,EAClB,eAAe,GAChB,EAAE,qBAAqB,GAAG,OAAO,CAAC,UAAU,CAAC;IAoHxC,gBAAgB,CAAC,EACrB,kBAAkB,GACnB,EAAE;QACD,kBAAkB,EAAE,MAAM,EAAE,CAAC;KAC9B;IA0BK,eAAe,CAAC,EACpB,MAAM,GACP,EAAE;QACD,MAAM,EAAE,6BAA6B,CAAC,wBAAwB,CAAC,CAAC;KACjE,GAAG,OAAO,CAAC,UAAU,CAAC;IAqFjB,QAAQ,CAAC,EACb,IAAI,EACJ,cAAc,GACf,EAAE;QACD,IAAI,EAAE,kBAAkB,CAAC;QACzB,cAAc,EAAE,cAAc,CAAC;KAChC,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAwLvB,cAAc,CAAC,EACnB,IAAI,EACJ,MAAM,GACP,EAAE;QACD,IAAI,EAAE,wBAAwB,CAAC;QAC/B,MAAM,EAAE,6BAA6B,CAAC,wBAAwB,CAAC,CAAC;KACjE,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAiD9B"}
|
|
@@ -1,20 +1,10 @@
|
|
|
1
1
|
import { FileToLoad, LoaderReport, StatsFileObject } from '../../types/loading';
|
|
2
|
-
/**
|
|
3
|
-
* Gets the files to load for the loader.
|
|
4
|
-
* @param {string[]} supportedItemTypes - The supported item types
|
|
5
|
-
* @param {StatsFileObject[]} statsFile - The stats file
|
|
6
|
-
* @returns {FileToLoad[]} The files to load
|
|
7
|
-
*/
|
|
2
|
+
/** Filters the stats file to supported item types, ordered by their position in supportedItemTypes. */
|
|
8
3
|
export declare function getFilesToLoad({ supportedItemTypes, statsFile, }: {
|
|
9
4
|
supportedItemTypes: string[];
|
|
10
5
|
statsFile: StatsFileObject[];
|
|
11
6
|
}): FileToLoad[];
|
|
12
|
-
/**
|
|
13
|
-
* Adds a report to the loader report.
|
|
14
|
-
* @param {LoaderReport[]} loaderReports - The loader reports
|
|
15
|
-
* @param {LoaderReport} report - The report to add
|
|
16
|
-
* @returns {LoaderReport[]} The updated loader reports
|
|
17
|
-
*/
|
|
7
|
+
/** Merges a report into the loader reports, summing counts per item type. */
|
|
18
8
|
export declare function addReportToLoaderReport({ loaderReports, report, }: {
|
|
19
9
|
loaderReports: LoaderReport[];
|
|
20
10
|
report: LoaderReport;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loading-adapter.helpers.d.ts","sourceRoot":"","sources":["../../../src/multithreading/adapters/loading-adapter.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EACV,YAAY,EACZ,eAAe,EAChB,MAAM,qBAAqB,CAAC;AAE7B
|
|
1
|
+
{"version":3,"file":"loading-adapter.helpers.d.ts","sourceRoot":"","sources":["../../../src/multithreading/adapters/loading-adapter.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EACV,YAAY,EACZ,eAAe,EAChB,MAAM,qBAAqB,CAAC;AAE7B,uGAAuG;AACvG,wBAAgB,cAAc,CAAC,EAC7B,kBAAkB,EAClB,SAAS,GACV,EAAE;IACD,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAC7B,SAAS,EAAE,eAAe,EAAE,CAAC;CAC9B,GAAG,UAAU,EAAE,CA8Bf;AAED,6EAA6E;AAC7E,wBAAgB,uBAAuB,CAAC,EACtC,aAAa,EACb,MAAM,GACP,EAAE;IACD,aAAa,EAAE,YAAY,EAAE,CAAC;IAC9B,MAAM,EAAE,YAAY,CAAC;CACtB,GAAG,YAAY,EAAE,CA4BjB"}
|
|
@@ -3,12 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getFilesToLoad = getFilesToLoad;
|
|
4
4
|
exports.addReportToLoaderReport = addReportToLoaderReport;
|
|
5
5
|
const loading_1 = require("../../types/loading");
|
|
6
|
-
/**
|
|
7
|
-
* Gets the files to load for the loader.
|
|
8
|
-
* @param {string[]} supportedItemTypes - The supported item types
|
|
9
|
-
* @param {StatsFileObject[]} statsFile - The stats file
|
|
10
|
-
* @returns {FileToLoad[]} The files to load
|
|
11
|
-
*/
|
|
6
|
+
/** Filters the stats file to supported item types, ordered by their position in supportedItemTypes. */
|
|
12
7
|
function getFilesToLoad({ supportedItemTypes, statsFile, }) {
|
|
13
8
|
const filesToLoad = [];
|
|
14
9
|
if (supportedItemTypes.length === 0 || statsFile.length === 0) {
|
|
@@ -32,12 +27,7 @@ function getFilesToLoad({ supportedItemTypes, statsFile, }) {
|
|
|
32
27
|
}
|
|
33
28
|
return filesToLoad;
|
|
34
29
|
}
|
|
35
|
-
/**
|
|
36
|
-
* Adds a report to the loader report.
|
|
37
|
-
* @param {LoaderReport[]} loaderReports - The loader reports
|
|
38
|
-
* @param {LoaderReport} report - The report to add
|
|
39
|
-
* @returns {LoaderReport[]} The updated loader reports
|
|
40
|
-
*/
|
|
30
|
+
/** Merges a report into the loader reports, summing counts per item type. */
|
|
41
31
|
function addReportToLoaderReport({ loaderReports, report, }) {
|
|
42
32
|
const existingReport = loaderReports.find((loaderReport) => loaderReport.item_type === report.item_type);
|
|
43
33
|
if (existingReport) {
|