@devrev/airsync-sdk 2.0.0-beta.3 → 2.0.0-beta.4
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 +5 -11
- package/dist/attachments-streaming/attachments-streaming-pool.d.ts +2 -10
- 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 +15 -43
- package/dist/common/constants.d.ts +1 -0
- package/dist/common/constants.d.ts.map +1 -1
- package/dist/common/constants.js +2 -1
- package/dist/common/helpers.d.ts +0 -14
- package/dist/common/helpers.d.ts.map +1 -1
- package/dist/common/helpers.js +0 -36
- package/dist/http/{axios-client-internal.d.ts → client.d.ts} +1 -1
- package/dist/http/client.d.ts.map +1 -0
- package/dist/index.d.ts +22 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +46 -28
- package/dist/logger/logger.d.ts +14 -0
- package/dist/logger/logger.d.ts.map +1 -1
- package/dist/logger/logger.js +55 -8
- package/dist/mappers/mappers.d.ts +9 -10
- package/dist/mappers/mappers.d.ts.map +1 -1
- package/dist/mappers/{mappers.interface.d.ts → mappers.interfaces.d.ts} +5 -5
- package/dist/mappers/mappers.interfaces.d.ts.map +1 -0
- package/dist/mappers/{mappers.interface.js → mappers.interfaces.js} +3 -3
- package/dist/mappers/mappers.js +13 -9
- package/dist/multithreading/adapters/base-adapter.d.ts +23 -8
- package/dist/multithreading/adapters/base-adapter.d.ts.map +1 -1
- package/dist/multithreading/adapters/base-adapter.js +41 -8
- package/dist/multithreading/adapters/extraction-adapter.d.ts +8 -9
- package/dist/multithreading/adapters/extraction-adapter.d.ts.map +1 -1
- package/dist/multithreading/adapters/extraction-adapter.js +24 -26
- package/dist/multithreading/adapters/loading-adapter.d.ts +7 -7
- package/dist/multithreading/adapters/loading-adapter.d.ts.map +1 -1
- package/dist/multithreading/adapters/loading-adapter.js +53 -83
- package/dist/{common/control-protocol.d.ts → multithreading/emit.d.ts} +1 -1
- package/dist/multithreading/emit.d.ts.map +1 -0
- package/dist/{common/control-protocol.js → multithreading/emit.js} +3 -3
- package/dist/multithreading/process-task.d.ts.map +1 -1
- package/dist/multithreading/process-task.js +26 -9
- package/dist/multithreading/spawn/spawn.helpers.d.ts +23 -3
- package/dist/multithreading/spawn/spawn.helpers.d.ts.map +1 -1
- package/dist/multithreading/spawn/spawn.helpers.js +152 -2
- package/dist/multithreading/spawn/spawn.js +7 -7
- package/dist/multithreading/worker.js +1 -2
- package/dist/repo/repo.js +2 -2
- package/dist/state/base-state.d.ts +5 -5
- package/dist/state/base-state.d.ts.map +1 -1
- package/dist/state/base-state.js +7 -7
- package/dist/state/extraction-state.d.ts +9 -9
- package/dist/state/extraction-state.d.ts.map +1 -1
- package/dist/state/extraction-state.js +10 -10
- package/dist/state/install-initial-domain-mapping.d.ts.map +1 -0
- package/dist/{common → state}/install-initial-domain-mapping.js +4 -4
- package/dist/state/loading-state.d.ts +7 -8
- package/dist/state/loading-state.d.ts.map +1 -1
- package/dist/state/loading-state.js +6 -7
- package/dist/state/state.d.ts +4 -0
- package/dist/state/state.d.ts.map +1 -0
- package/dist/state/state.interfaces.d.ts +28 -18
- package/dist/state/state.interfaces.d.ts.map +1 -1
- package/dist/state/state.interfaces.js +13 -6
- package/dist/state/state.js +11 -0
- package/dist/{common → state}/time-value-resolver.d.ts +6 -7
- package/dist/state/time-value-resolver.d.ts.map +1 -0
- package/dist/{common → state}/time-value-resolver.js +9 -8
- package/dist/{common/test-utils.d.ts → testing/mock-event.d.ts} +1 -2
- package/dist/testing/mock-event.d.ts.map +1 -0
- package/dist/{common/test-utils.js → testing/mock-event.js} +14 -3
- package/dist/{mock-server → testing}/mock-server.d.ts +5 -0
- package/dist/testing/mock-server.d.ts.map +1 -0
- package/dist/testing/mock-server.interfaces.d.ts.map +1 -0
- package/dist/{mock-server → testing}/mock-server.js +6 -1
- package/dist/types/errors.d.ts +9 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/extraction.d.ts +70 -15
- package/dist/types/extraction.d.ts.map +1 -1
- package/dist/types/extraction.js +4 -6
- 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 +66 -23
- package/dist/types/workers.d.ts.map +1 -1
- package/dist/uploader/uploader.d.ts +5 -4
- package/dist/uploader/uploader.d.ts.map +1 -1
- package/dist/uploader/uploader.interfaces.d.ts +1 -1
- package/dist/uploader/uploader.js +10 -10
- package/package.json +3 -3
- 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.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.map +0 -1
- 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.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.map +0 -1
- 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/http/{axios-client-internal.js → client.js} +0 -0
- /package/dist/{common → state}/install-initial-domain-mapping.d.ts +0 -0
- /package/dist/{mock-server → testing}/mock-server.interfaces.d.ts +0 -0
- /package/dist/{mock-server → testing}/mock-server.interfaces.js +0 -0
- /package/dist/{common → types}/errors.js +0 -0
|
@@ -7,7 +7,7 @@ exports.Spawn = void 0;
|
|
|
7
7
|
exports.spawn = spawn;
|
|
8
8
|
const yargs_1 = __importDefault(require("yargs"));
|
|
9
9
|
const helpers_1 = require("yargs/helpers");
|
|
10
|
-
const
|
|
10
|
+
const emit_1 = require("../emit");
|
|
11
11
|
const helpers_2 = require("../../common/helpers");
|
|
12
12
|
const logger_1 = require("../../logger/logger");
|
|
13
13
|
const extraction_1 = require("../../types/extraction");
|
|
@@ -66,13 +66,13 @@ async function spawn({ event, initialState, initialDomainMapping, options, baseW
|
|
|
66
66
|
if (options === null || options === void 0 ? void 0 : options.isLocalDevelopment) {
|
|
67
67
|
console.log('Snap-in is running in local development mode.');
|
|
68
68
|
}
|
|
69
|
-
const eventType = event.payload.event_type;
|
|
70
69
|
let script = null;
|
|
71
70
|
if (baseWorkerPath != null &&
|
|
72
71
|
(options === null || options === void 0 ? void 0 : options.workerPathOverrides) != null &&
|
|
73
|
-
options.workerPathOverrides[
|
|
72
|
+
options.workerPathOverrides[event.payload.event_type] != null) {
|
|
74
73
|
script =
|
|
75
|
-
baseWorkerPath +
|
|
74
|
+
baseWorkerPath +
|
|
75
|
+
options.workerPathOverrides[event.payload.event_type];
|
|
76
76
|
}
|
|
77
77
|
else {
|
|
78
78
|
script = getWorkerPath({
|
|
@@ -109,7 +109,7 @@ async function spawn({ event, initialState, initialDomainMapping, options, baseW
|
|
|
109
109
|
}
|
|
110
110
|
else {
|
|
111
111
|
const { eventType } = (0, spawn_helpers_1.getNoScriptEventType)(event.payload.event_type);
|
|
112
|
-
await (0,
|
|
112
|
+
await (0, emit_1.emit)({
|
|
113
113
|
event,
|
|
114
114
|
eventType,
|
|
115
115
|
});
|
|
@@ -188,7 +188,7 @@ class Spawn {
|
|
|
188
188
|
}
|
|
189
189
|
// If worker sends a message that it has emitted an event, then set alreadyEmitted to true.
|
|
190
190
|
if ((message === null || message === void 0 ? void 0 : message.subject) === workers_1.WorkerMessageSubject.WorkerMessageEmitted) {
|
|
191
|
-
console.info('Worker has emitted message to
|
|
191
|
+
console.info('Worker has emitted message to AirSync.');
|
|
192
192
|
this.alreadyEmitted = true;
|
|
193
193
|
}
|
|
194
194
|
// If worker sends a failure message before exiting, capture it for use in the error event.
|
|
@@ -236,7 +236,7 @@ class Spawn {
|
|
|
236
236
|
this.alreadyEmitted = true;
|
|
237
237
|
const { eventType } = (0, spawn_helpers_1.getTimeoutErrorEventType)(this.event.payload.event_type);
|
|
238
238
|
try {
|
|
239
|
-
await (0,
|
|
239
|
+
await (0, emit_1.emit)({
|
|
240
240
|
eventType,
|
|
241
241
|
event: this.event,
|
|
242
242
|
data: {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const { workerData } = require('node:worker_threads');
|
|
3
3
|
require('ts-node').register();
|
|
4
|
-
const { Logger } = require('../logger/logger');
|
|
5
|
-
const { runWithUserLogContext } = require('../logger/logger.context');
|
|
4
|
+
const { Logger, runWithUserLogContext } = require('../logger/logger');
|
|
6
5
|
console = new Logger({ event: workerData.event, options: workerData.options });
|
|
7
6
|
runWithUserLogContext(() => {
|
|
8
7
|
require(workerData.workerPath);
|
package/dist/repo/repo.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Repo = void 0;
|
|
4
4
|
const constants_1 = require("../common/constants");
|
|
5
5
|
const uploader_1 = require("../uploader/uploader");
|
|
6
|
-
const
|
|
6
|
+
const logger_1 = require("../logger/logger");
|
|
7
7
|
class Repo {
|
|
8
8
|
constructor({ event, itemType, normalize, onUpload, options, }) {
|
|
9
9
|
this.items = [];
|
|
@@ -49,7 +49,7 @@ class Repo {
|
|
|
49
49
|
if (this.normalize &&
|
|
50
50
|
this.itemType != constants_1.AirSyncDefaultItemTypes.EXTERNAL_DOMAIN_METADATA &&
|
|
51
51
|
this.itemType != constants_1.SSOR_ATTACHMENT) {
|
|
52
|
-
recordsToPush = (0,
|
|
52
|
+
recordsToPush = (0, logger_1.runWithUserLogContext)(() => items.map((item) => this.normalize(item)));
|
|
53
53
|
}
|
|
54
54
|
else {
|
|
55
55
|
recordsToPush = items;
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import { InitialDomainMapping } from '../types/common';
|
|
2
2
|
import { AirSyncEvent } from '../types/extraction';
|
|
3
3
|
import { ExtractionScope } from '../types/workers';
|
|
4
|
-
import {
|
|
4
|
+
import { SdkState, StateInterface } from './state.interfaces';
|
|
5
5
|
/**
|
|
6
6
|
* BaseState owns the state lifecycle shared by every sync mode: connector vs.
|
|
7
7
|
* SDK state separation, fetch/init/post against the platform, the v1->v2
|
|
8
8
|
* migration shim, and the snap-in-version-gated initial domain mapping install.
|
|
9
9
|
*
|
|
10
|
-
* Mode-specific subclasses (`ExtractionState`, `LoadingState`)
|
|
11
|
-
*
|
|
10
|
+
* Mode-specific subclasses (`ExtractionState`, `LoadingState`) seed the
|
|
11
|
+
* SDK-owned portion of the state and add mode-specific setup in their factories.
|
|
12
12
|
*
|
|
13
13
|
* @typeParam ConnectorState - the connector-owned state shape
|
|
14
|
-
* @typeParam SdkState - the SDK bookkeeping shape for this mode
|
|
15
14
|
*/
|
|
16
|
-
export declare abstract class BaseState<ConnectorState
|
|
15
|
+
export declare abstract class BaseState<ConnectorState> {
|
|
17
16
|
protected _connectorState: ConnectorState;
|
|
18
17
|
protected _sdkState: SdkState;
|
|
19
18
|
protected _extractionScope: ExtractionScope;
|
|
@@ -35,6 +34,7 @@ export declare abstract class BaseState<ConnectorState, SdkState extends BaseSdk
|
|
|
35
34
|
* Installs the initial domain mapping when the snap-in version in state does
|
|
36
35
|
* not match the version in the event context. Shared by all modes so that a
|
|
37
36
|
* loading run still installs the mapping if extraction has not done so.
|
|
37
|
+
* @param initialDomainMapping The initial domain mapping passed to spawn
|
|
38
38
|
*/
|
|
39
39
|
installInitialDomainMappingIfNeeded(initialDomainMapping?: InitialDomainMapping): Promise<void>;
|
|
40
40
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-state.d.ts","sourceRoot":"","sources":["../../src/state/base-state.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAEL,
|
|
1
|
+
{"version":3,"file":"base-state.d.ts","sourceRoot":"","sources":["../../src/state/base-state.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAEL,QAAQ,EACR,cAAc,EAEf,MAAM,oBAAoB,CAAC;AAE5B;;;;;;;;;GASG;AACH,8BAAsB,SAAS,CAAC,cAAc;IAC5C,SAAS,CAAC,eAAe,EAAE,cAAc,CAAC;IAC1C,SAAS,CAAC,SAAS,EAAE,QAAQ,CAAC;IAC9B,SAAS,CAAC,gBAAgB,EAAE,eAAe,CAAM;IACjD,SAAS,CAAC,QAAQ,CAAC,eAAe,EAAE,QAAQ,CAAC;IAC7C,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IACvC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,SAAS,CAAS;gBAGxB,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,cAAc,CAAC,cAAc,CAAC,EACvD,eAAe,EAAE,QAAQ;IAY3B,mFAAmF;IACnF,IAAI,KAAK,IAAI,cAAc,CAE1B;IAED,IAAI,KAAK,CAAC,KAAK,EAAE,cAAc,EAE9B;IAED,uEAAuE;IACvE,IAAI,QAAQ,IAAI,QAAQ,CAEvB;IAED,IAAI,QAAQ,CAAC,KAAK,EAAE,QAAQ,EAE3B;IAED,IAAI,eAAe,IAAI,eAAe,CAErC;IAED;;;;;OAKG;IACG,mCAAmC,CACvC,oBAAoB,CAAC,EAAE,oBAAoB,GAC1C,OAAO,CAAC,IAAI,CAAC;IAwChB;;;;;;;;OAQG;IACG,IAAI,CAAC,YAAY,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAkDvD;;;;;;;;OAQG;IACH,OAAO,CAAC,qBAAqB;IAyC7B;;;;OAIG;IACG,SAAS,CAAC,KAAK,CAAC,EAAE,cAAc;IA4DtC;;;OAGG;IACG,UAAU,IAAI,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAqBjE"}
|
package/dist/state/base-state.js
CHANGED
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.BaseState = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
const node_worker_threads_1 = require("node:worker_threads");
|
|
9
|
-
const install_initial_domain_mapping_1 = require("
|
|
10
|
-
const
|
|
9
|
+
const install_initial_domain_mapping_1 = require("./install-initial-domain-mapping");
|
|
10
|
+
const client_1 = require("../http/client");
|
|
11
11
|
const logger_1 = require("../logger/logger");
|
|
12
12
|
const workers_1 = require("../types/workers");
|
|
13
13
|
const state_interfaces_1 = require("./state.interfaces");
|
|
@@ -16,11 +16,10 @@ const state_interfaces_1 = require("./state.interfaces");
|
|
|
16
16
|
* SDK state separation, fetch/init/post against the platform, the v1->v2
|
|
17
17
|
* migration shim, and the snap-in-version-gated initial domain mapping install.
|
|
18
18
|
*
|
|
19
|
-
* Mode-specific subclasses (`ExtractionState`, `LoadingState`)
|
|
20
|
-
*
|
|
19
|
+
* Mode-specific subclasses (`ExtractionState`, `LoadingState`) seed the
|
|
20
|
+
* SDK-owned portion of the state and add mode-specific setup in their factories.
|
|
21
21
|
*
|
|
22
22
|
* @typeParam ConnectorState - the connector-owned state shape
|
|
23
|
-
* @typeParam SdkState - the SDK bookkeeping shape for this mode
|
|
24
23
|
*/
|
|
25
24
|
class BaseState {
|
|
26
25
|
constructor({ event, initialState }, initialSdkState) {
|
|
@@ -55,6 +54,7 @@ class BaseState {
|
|
|
55
54
|
* Installs the initial domain mapping when the snap-in version in state does
|
|
56
55
|
* not match the version in the event context. Shared by all modes so that a
|
|
57
56
|
* loading run still installs the mapping if extraction has not done so.
|
|
57
|
+
* @param initialDomainMapping The initial domain mapping passed to spawn
|
|
58
58
|
*/
|
|
59
59
|
async installInitialDomainMappingIfNeeded(initialDomainMapping) {
|
|
60
60
|
const snapInVersionId = this.event.context.snap_in_version_id;
|
|
@@ -209,7 +209,7 @@ class BaseState {
|
|
|
209
209
|
process.exit(1);
|
|
210
210
|
}
|
|
211
211
|
try {
|
|
212
|
-
await
|
|
212
|
+
await client_1.axiosClient.post(url, {
|
|
213
213
|
state: stringifiedState,
|
|
214
214
|
}, {
|
|
215
215
|
headers: {
|
|
@@ -243,7 +243,7 @@ class BaseState {
|
|
|
243
243
|
var _a, _b;
|
|
244
244
|
console.log(`Fetching state with sync unit id ${this.syncUnitId} and request id ${this.requestId}.`);
|
|
245
245
|
const url = this.workerUrl + '.get';
|
|
246
|
-
const response = await
|
|
246
|
+
const response = await client_1.axiosClient.get(url, {
|
|
247
247
|
headers: {
|
|
248
248
|
Authorization: this.devrevToken,
|
|
249
249
|
},
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { BaseState } from './base-state';
|
|
2
|
-
import {
|
|
2
|
+
import { StateInterface } from './state.interfaces';
|
|
3
3
|
/**
|
|
4
|
-
* ExtractionState is the per-mode state for extraction workers. It
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* ExtractionState is the per-mode state for extraction workers. It seeds the
|
|
5
|
+
* extraction SDK state (extraction boundaries + attachments bookkeeping) on top
|
|
6
|
+
* of the shared lifecycle provided by `BaseState` and adds extraction-window
|
|
7
|
+
* resolution.
|
|
7
8
|
*/
|
|
8
|
-
export declare class ExtractionState<ConnectorState> extends BaseState<ConnectorState
|
|
9
|
+
export declare class ExtractionState<ConnectorState> extends BaseState<ConnectorState> {
|
|
9
10
|
constructor(params: StateInterface<ConnectorState>);
|
|
10
11
|
/**
|
|
11
12
|
* Resolves the extraction window onto the event context.
|
|
@@ -20,10 +21,9 @@ export declare class ExtractionState<ConnectorState> extends BaseState<Connector
|
|
|
20
21
|
/**
|
|
21
22
|
* Creates and initializes an `ExtractionState` for an extraction worker.
|
|
22
23
|
*
|
|
23
|
-
* For non-stateless events this fetches
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* validates it.
|
|
24
|
+
* For non-stateless events this fetches persisted state, installs the initial
|
|
25
|
+
* domain mapping if the snap-in version changed, then resolves the extraction
|
|
26
|
+
* window (time-value resolution + pending boundary reuse) and validates it.
|
|
27
27
|
*/
|
|
28
28
|
export declare function createExtractionState<ConnectorState>({ event, initialState, initialDomainMapping, options, }: StateInterface<ConnectorState>): Promise<ExtractionState<ConnectorState>>;
|
|
29
29
|
//# sourceMappingURL=extraction-state.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extraction-state.d.ts","sourceRoot":"","sources":["../../src/state/extraction-state.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,
|
|
1
|
+
{"version":3,"file":"extraction-state.d.ts","sourceRoot":"","sources":["../../src/state/extraction-state.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAsB,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAExE;;;;;GAKG;AACH,qBAAa,eAAe,CAAC,cAAc,CAAE,SAAQ,SAAS,CAAC,cAAc,CAAC;gBAChE,MAAM,EAAE,cAAc,CAAC,cAAc,CAAC;IAIlD;;;;;;;OAOG;IACH,uBAAuB,IAAI,IAAI;CA+EhC;AAED;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CAAC,cAAc,EAAE,EAC1D,KAAK,EACL,YAAY,EACZ,oBAAoB,EACpB,OAAO,GACR,EAAE,cAAc,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC,CAkB3E"}
|
|
@@ -4,20 +4,21 @@ exports.ExtractionState = void 0;
|
|
|
4
4
|
exports.createExtractionState = createExtractionState;
|
|
5
5
|
const node_worker_threads_1 = require("node:worker_threads");
|
|
6
6
|
const constants_1 = require("../common/constants");
|
|
7
|
-
const time_value_resolver_1 = require("
|
|
7
|
+
const time_value_resolver_1 = require("./time-value-resolver");
|
|
8
8
|
const logger_1 = require("../logger/logger");
|
|
9
9
|
const extraction_1 = require("../types/extraction");
|
|
10
10
|
const workers_1 = require("../types/workers");
|
|
11
11
|
const base_state_1 = require("./base-state");
|
|
12
12
|
const state_interfaces_1 = require("./state.interfaces");
|
|
13
13
|
/**
|
|
14
|
-
* ExtractionState is the per-mode state for extraction workers. It
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* ExtractionState is the per-mode state for extraction workers. It seeds the
|
|
15
|
+
* extraction SDK state (extraction boundaries + attachments bookkeeping) on top
|
|
16
|
+
* of the shared lifecycle provided by `BaseState` and adds extraction-window
|
|
17
|
+
* resolution.
|
|
17
18
|
*/
|
|
18
19
|
class ExtractionState extends base_state_1.BaseState {
|
|
19
20
|
constructor(params) {
|
|
20
|
-
super(params, state_interfaces_1.
|
|
21
|
+
super(params, state_interfaces_1.extractionSdkState);
|
|
21
22
|
}
|
|
22
23
|
/**
|
|
23
24
|
* Resolves the extraction window onto the event context.
|
|
@@ -28,8 +29,8 @@ class ExtractionState extends base_state_1.BaseState {
|
|
|
28
29
|
* StartExtractingMetadata. Finally, validate that extract_from < extract_to.
|
|
29
30
|
*/
|
|
30
31
|
resolveExtractionWindow() {
|
|
31
|
-
const eventContext = this.event.payload.event_context;
|
|
32
32
|
const sdkState = this.sdkState;
|
|
33
|
+
const eventContext = this.event.payload.event_context;
|
|
33
34
|
if (this.event.payload.event_type === extraction_1.EventType.StartExtractingMetadata) {
|
|
34
35
|
const timeFields = [
|
|
35
36
|
{
|
|
@@ -99,10 +100,9 @@ exports.ExtractionState = ExtractionState;
|
|
|
99
100
|
/**
|
|
100
101
|
* Creates and initializes an `ExtractionState` for an extraction worker.
|
|
101
102
|
*
|
|
102
|
-
* For non-stateless events this fetches
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
* validates it.
|
|
103
|
+
* For non-stateless events this fetches persisted state, installs the initial
|
|
104
|
+
* domain mapping if the snap-in version changed, then resolves the extraction
|
|
105
|
+
* window (time-value resolution + pending boundary reuse) and validates it.
|
|
106
106
|
*/
|
|
107
107
|
async function createExtractionState({ event, initialState, initialDomainMapping, options, }) {
|
|
108
108
|
// Deep clone the initial state to avoid mutating the original state
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install-initial-domain-mapping.d.ts","sourceRoot":"","sources":["../../src/state/install-initial-domain-mapping.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEvD,wBAAsB,2BAA2B,CAC/C,KAAK,EAAE,YAAY,EACnB,wBAAwB,EAAE,oBAAoB,GAC7C,OAAO,CAAC,IAAI,CAAC,CA0Ff"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.installInitialDomainMapping = installInitialDomainMapping;
|
|
4
|
-
const
|
|
4
|
+
const client_1 = require("../http/client");
|
|
5
5
|
const logger_1 = require("../logger/logger");
|
|
6
6
|
async function installInitialDomainMapping(event, initialDomainMappingJson) {
|
|
7
7
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
@@ -13,7 +13,7 @@ async function installInitialDomainMapping(event, initialDomainMappingJson) {
|
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
15
|
// Get snap-in details
|
|
16
|
-
const snapInResponse = await
|
|
16
|
+
const snapInResponse = await client_1.axiosClient.get(devrevEndpoint + '/internal/snap-ins.get', {
|
|
17
17
|
headers: {
|
|
18
18
|
Authorization: devrevToken,
|
|
19
19
|
},
|
|
@@ -33,7 +33,7 @@ async function installInitialDomainMapping(event, initialDomainMappingJson) {
|
|
|
33
33
|
if (startingRecipeBlueprint &&
|
|
34
34
|
Object.keys(startingRecipeBlueprint).length !== 0) {
|
|
35
35
|
try {
|
|
36
|
-
const recipeBlueprintResponse = await
|
|
36
|
+
const recipeBlueprintResponse = await client_1.axiosClient.post(`${devrevEndpoint}/internal/airdrop.recipe.blueprints.create`, Object.assign({}, startingRecipeBlueprint), {
|
|
37
37
|
headers: {
|
|
38
38
|
Authorization: devrevToken,
|
|
39
39
|
},
|
|
@@ -47,7 +47,7 @@ async function installInitialDomainMapping(event, initialDomainMappingJson) {
|
|
|
47
47
|
}
|
|
48
48
|
// Install the initial domain mappings
|
|
49
49
|
const additionalMappings = initialDomainMappingJson.additional_mappings || {};
|
|
50
|
-
const initialDomainMappingInstallResponse = await
|
|
50
|
+
const initialDomainMappingInstallResponse = await client_1.axiosClient.post(`${devrevEndpoint}/internal/airdrop.recipe.initial-domain-mappings.install`, Object.assign(Object.assign({ external_system_type: 'ADaaS', import_slug: importSlug, snap_in_slug: snapInSlug }, (recipeBlueprintId && {
|
|
51
51
|
starting_recipe_blueprint: recipeBlueprintId,
|
|
52
52
|
})), additionalMappings), {
|
|
53
53
|
headers: {
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import { BaseState } from './base-state';
|
|
2
|
-
import {
|
|
2
|
+
import { StateInterface } from './state.interfaces';
|
|
3
3
|
/**
|
|
4
|
-
* LoadingState is the per-mode state for loading workers. It
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* LoadingState is the per-mode state for loading workers. It seeds the loading
|
|
5
|
+
* SDK state (files-to-load bookkeeping) on top of the shared lifecycle provided
|
|
6
|
+
* by `BaseState`. Loading has no extraction-window resolution.
|
|
7
7
|
*/
|
|
8
|
-
export declare class LoadingState<ConnectorState> extends BaseState<ConnectorState
|
|
8
|
+
export declare class LoadingState<ConnectorState> extends BaseState<ConnectorState> {
|
|
9
9
|
constructor(params: StateInterface<ConnectorState>);
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* Creates and initializes a `LoadingState` for a loading worker.
|
|
13
13
|
*
|
|
14
|
-
* For non-stateless events this fetches
|
|
15
|
-
*
|
|
16
|
-
* extraction-window resolution, so the factory is otherwise minimal.
|
|
14
|
+
* For non-stateless events this fetches persisted state and installs the
|
|
15
|
+
* initial domain mapping if the snap-in version changed.
|
|
17
16
|
*/
|
|
18
17
|
export declare function createLoadingState<ConnectorState>({ event, initialState, initialDomainMapping, options, }: StateInterface<ConnectorState>): Promise<LoadingState<ConnectorState>>;
|
|
19
18
|
//# sourceMappingURL=loading-state.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loading-state.d.ts","sourceRoot":"","sources":["../../src/state/loading-state.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,
|
|
1
|
+
{"version":3,"file":"loading-state.d.ts","sourceRoot":"","sources":["../../src/state/loading-state.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAmB,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAErE;;;;GAIG;AACH,qBAAa,YAAY,CAAC,cAAc,CAAE,SAAQ,SAAS,CAAC,cAAc,CAAC;gBAC7D,MAAM,EAAE,cAAc,CAAC,cAAc,CAAC;CAGnD;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CAAC,cAAc,EAAE,EACvD,KAAK,EACL,YAAY,EACZ,oBAAoB,EACpB,OAAO,GACR,EAAE,cAAc,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC,CAiBxE"}
|
|
@@ -6,22 +6,21 @@ const constants_1 = require("../common/constants");
|
|
|
6
6
|
const base_state_1 = require("./base-state");
|
|
7
7
|
const state_interfaces_1 = require("./state.interfaces");
|
|
8
8
|
/**
|
|
9
|
-
* LoadingState is the per-mode state for loading workers. It
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* LoadingState is the per-mode state for loading workers. It seeds the loading
|
|
10
|
+
* SDK state (files-to-load bookkeeping) on top of the shared lifecycle provided
|
|
11
|
+
* by `BaseState`. Loading has no extraction-window resolution.
|
|
12
12
|
*/
|
|
13
13
|
class LoadingState extends base_state_1.BaseState {
|
|
14
14
|
constructor(params) {
|
|
15
|
-
super(params, state_interfaces_1.
|
|
15
|
+
super(params, state_interfaces_1.loadingSdkState);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
exports.LoadingState = LoadingState;
|
|
19
19
|
/**
|
|
20
20
|
* Creates and initializes a `LoadingState` for a loading worker.
|
|
21
21
|
*
|
|
22
|
-
* For non-stateless events this fetches
|
|
23
|
-
*
|
|
24
|
-
* extraction-window resolution, so the factory is otherwise minimal.
|
|
22
|
+
* For non-stateless events this fetches persisted state and installs the
|
|
23
|
+
* initial domain mapping if the snap-in version changed.
|
|
25
24
|
*/
|
|
26
25
|
async function createLoadingState({ event, initialState, initialDomainMapping, options, }) {
|
|
27
26
|
// Deep clone the initial state to avoid mutating the original state
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/state/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -2,16 +2,7 @@ import { InitialDomainMapping } from '../types/common';
|
|
|
2
2
|
import { AirSyncEvent } from '../types/extraction';
|
|
3
3
|
import { FileToLoad } from '../types/loading';
|
|
4
4
|
import { WorkerAdapterOptions } from '../types/workers';
|
|
5
|
-
|
|
6
|
-
* BaseSdkState holds SDK bookkeeping common to every sync mode.
|
|
7
|
-
*/
|
|
8
|
-
export interface BaseSdkState {
|
|
9
|
-
snapInVersionId?: string;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* ExtractionSdkState holds SDK bookkeeping owned by the extraction modes.
|
|
13
|
-
*/
|
|
14
|
-
export interface ExtractionSdkState extends BaseSdkState {
|
|
5
|
+
export interface SdkState {
|
|
15
6
|
/** The pending (not yet committed) oldest extraction boundary (ISO 8601 timestamp).
|
|
16
7
|
* Set on StartExtractingMetadata, reused across subsequent phases, cleared on AttachmentExtractionDone. */
|
|
17
8
|
pendingWorkersOldest?: string;
|
|
@@ -23,19 +14,15 @@ export interface ExtractionSdkState extends BaseSdkState {
|
|
|
23
14
|
/** The newest point of extraction (ISO 8601 timestamp). */
|
|
24
15
|
workersNewest?: string;
|
|
25
16
|
toDevRev?: ToDevRev;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* LoadingSdkState holds SDK bookkeeping owned by the loading modes.
|
|
29
|
-
*/
|
|
30
|
-
export interface LoadingSdkState extends BaseSdkState {
|
|
31
17
|
fromDevRev?: FromDevRev;
|
|
18
|
+
snapInVersionId?: string;
|
|
32
19
|
}
|
|
33
20
|
/**
|
|
34
21
|
* AdapterStateEnvelope is the v2 on-disk state shape: connector state and SDK
|
|
35
22
|
* bookkeeping are stored as disjoint sub-objects so SDK internals stay
|
|
36
23
|
* encapsulated and never collide with connector keys.
|
|
37
24
|
*/
|
|
38
|
-
export interface AdapterStateEnvelope<ConnectorState
|
|
25
|
+
export interface AdapterStateEnvelope<ConnectorState> {
|
|
39
26
|
connectorState: ConnectorState;
|
|
40
27
|
sdkState: SdkState;
|
|
41
28
|
}
|
|
@@ -62,14 +49,37 @@ export interface StateInterface<ConnectorState> {
|
|
|
62
49
|
initialDomainMapping?: InitialDomainMapping;
|
|
63
50
|
options?: WorkerAdapterOptions;
|
|
64
51
|
}
|
|
65
|
-
export declare const
|
|
66
|
-
|
|
52
|
+
export declare const extractionSdkState: {
|
|
53
|
+
pendingWorkersOldest: string;
|
|
54
|
+
pendingWorkersNewest: string;
|
|
55
|
+
workersOldest: string;
|
|
56
|
+
workersNewest: string;
|
|
57
|
+
snapInVersionId: string;
|
|
58
|
+
toDevRev: {
|
|
59
|
+
attachmentsMetadata: {
|
|
60
|
+
artifactIds: never[];
|
|
61
|
+
lastProcessed: number;
|
|
62
|
+
lastProcessedAttachmentsIdsList: never[];
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
export declare const loadingSdkState: {
|
|
67
|
+
snapInVersionId: string;
|
|
68
|
+
fromDevRev: {
|
|
69
|
+
filesToLoad: never[];
|
|
70
|
+
};
|
|
71
|
+
};
|
|
67
72
|
/**
|
|
68
73
|
* The set of top-level state keys owned by the SDK. Derived from the initial
|
|
69
74
|
* SDK state constants so it auto-updates whenever a new SDK field is added.
|
|
70
75
|
* Used by the migration shim to split a flat v1 state blob into the
|
|
71
76
|
* `{ connectorState, sdkState }` envelope: keys in this set go to `sdkState`,
|
|
72
77
|
* everything else is connector state.
|
|
78
|
+
*
|
|
79
|
+
* `lastSyncStarted` / `lastSuccessfulSyncStarted` are retained here even though
|
|
80
|
+
* they are no longer fields on `SdkState`: a flat v1 blob may still carry them,
|
|
81
|
+
* and they must be recognized as SDK-owned so they are stripped out rather than
|
|
82
|
+
* leaking into connector state during migration.
|
|
73
83
|
*/
|
|
74
84
|
export declare const V1_SDK_STATE_KEYS: ReadonlySet<string>;
|
|
75
85
|
//# sourceMappingURL=state.interfaces.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.interfaces.d.ts","sourceRoot":"","sources":["../../src/state/state.interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD
|
|
1
|
+
{"version":3,"file":"state.interfaces.d.ts","sourceRoot":"","sources":["../../src/state/state.interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,MAAM,WAAW,QAAQ;IACvB;gHAC4G;IAC5G,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;gHAC4G;IAC5G,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,2DAA2D;IAC3D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,2DAA2D;IAC3D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB,CAAC,cAAc;IAClD,cAAc,EAAE,cAAc,CAAC;IAC/B,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED,MAAM,WAAW,QAAQ;IACvB,mBAAmB,EAAE;QACnB,WAAW,EAAE,MAAM,EAAE,CAAC;QACtB,aAAa,EAAE,MAAM,CAAC;QACtB,+BAA+B,CAAC,EAAE,mBAAmB,EAAE,CAAC;KACzD,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,cAAc,CAAC,cAAc;IAC5C,KAAK,EAAE,YAAY,CAAC;IACpB,YAAY,EAAE,cAAc,CAAC;IAC7B,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C,OAAO,CAAC,EAAE,oBAAoB,CAAC;CAChC;AAED,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;CAa9B,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;CAK3B,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iBAAiB,EAAE,WAAW,CAAC,MAAM,CAKhD,CAAC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.V1_SDK_STATE_KEYS = exports.
|
|
4
|
-
exports.
|
|
5
|
-
snapInVersionId: '',
|
|
3
|
+
exports.V1_SDK_STATE_KEYS = exports.loadingSdkState = exports.extractionSdkState = void 0;
|
|
4
|
+
exports.extractionSdkState = {
|
|
6
5
|
pendingWorkersOldest: '',
|
|
7
6
|
pendingWorkersNewest: '',
|
|
8
7
|
workersOldest: '',
|
|
9
8
|
workersNewest: '',
|
|
9
|
+
snapInVersionId: '',
|
|
10
10
|
toDevRev: {
|
|
11
11
|
attachmentsMetadata: {
|
|
12
12
|
artifactIds: [],
|
|
@@ -15,7 +15,7 @@ exports.initialExtractionSdkState = {
|
|
|
15
15
|
},
|
|
16
16
|
},
|
|
17
17
|
};
|
|
18
|
-
exports.
|
|
18
|
+
exports.loadingSdkState = {
|
|
19
19
|
snapInVersionId: '',
|
|
20
20
|
fromDevRev: {
|
|
21
21
|
filesToLoad: [],
|
|
@@ -27,8 +27,15 @@ exports.initialLoadingSdkState = {
|
|
|
27
27
|
* Used by the migration shim to split a flat v1 state blob into the
|
|
28
28
|
* `{ connectorState, sdkState }` envelope: keys in this set go to `sdkState`,
|
|
29
29
|
* everything else is connector state.
|
|
30
|
+
*
|
|
31
|
+
* `lastSyncStarted` / `lastSuccessfulSyncStarted` are retained here even though
|
|
32
|
+
* they are no longer fields on `SdkState`: a flat v1 blob may still carry them,
|
|
33
|
+
* and they must be recognized as SDK-owned so they are stripped out rather than
|
|
34
|
+
* leaking into connector state during migration.
|
|
30
35
|
*/
|
|
31
36
|
exports.V1_SDK_STATE_KEYS = new Set([
|
|
32
|
-
...Object.keys(exports.
|
|
33
|
-
...Object.keys(exports.
|
|
37
|
+
...Object.keys(exports.extractionSdkState),
|
|
38
|
+
...Object.keys(exports.loadingSdkState),
|
|
39
|
+
'lastSyncStarted',
|
|
40
|
+
'lastSuccessfulSyncStarted',
|
|
34
41
|
]);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createLoadingState = exports.LoadingState = exports.createExtractionState = exports.ExtractionState = exports.BaseState = void 0;
|
|
4
|
+
var base_state_1 = require("./base-state");
|
|
5
|
+
Object.defineProperty(exports, "BaseState", { enumerable: true, get: function () { return base_state_1.BaseState; } });
|
|
6
|
+
var extraction_state_1 = require("./extraction-state");
|
|
7
|
+
Object.defineProperty(exports, "ExtractionState", { enumerable: true, get: function () { return extraction_state_1.ExtractionState; } });
|
|
8
|
+
Object.defineProperty(exports, "createExtractionState", { enumerable: true, get: function () { return extraction_state_1.createExtractionState; } });
|
|
9
|
+
var loading_state_1 = require("./loading-state");
|
|
10
|
+
Object.defineProperty(exports, "LoadingState", { enumerable: true, get: function () { return loading_state_1.LoadingState; } });
|
|
11
|
+
Object.defineProperty(exports, "createLoadingState", { enumerable: true, get: function () { return loading_state_1.createLoadingState; } });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TimeUnit, TimeValue } from '../types/extraction';
|
|
2
|
-
import {
|
|
2
|
+
import { SdkState } from '../state/state.interfaces';
|
|
3
3
|
/**
|
|
4
4
|
* Parses a shorthand duration string into its numeric value and unit.
|
|
5
5
|
* Supported units:
|
|
@@ -32,16 +32,15 @@ export declare function applyDuration(baseTimestamp: string, duration: string, o
|
|
|
32
32
|
* - ABSOLUTE: Returns the value directly (must be an ISO 8601 timestamp)
|
|
33
33
|
* - NOW: Returns the current time as ISO 8601
|
|
34
34
|
* - UNBOUNDED: Returns UNBOUNDED_DATE_TIME_VALUE ('1970-01-01T00:00:00.000Z')
|
|
35
|
-
* - WORKERS_OLDEST: Returns workersOldest from state, or
|
|
36
|
-
* - WORKERS_NEWEST: Returns workersNewest from state, or
|
|
37
|
-
* - WORKERS_OLDEST_MINUS_WINDOW: Subtracts duration from workersOldest, or
|
|
38
|
-
* - WORKERS_NEWEST_PLUS_WINDOW: Adds duration to workersNewest, or
|
|
35
|
+
* - WORKERS_OLDEST: Returns workersOldest from state, or UNBOUNDED if not set
|
|
36
|
+
* - WORKERS_NEWEST: Returns workersNewest from state, or UNBOUNDED if not set
|
|
37
|
+
* - WORKERS_OLDEST_MINUS_WINDOW: Subtracts duration from workersOldest, or UNBOUNDED if not set
|
|
38
|
+
* - WORKERS_NEWEST_PLUS_WINDOW: Adds duration to workersNewest, or UNBOUNDED if not set
|
|
39
39
|
*
|
|
40
40
|
* @param timeValue - The TimeValue to resolve
|
|
41
41
|
* @param state - The current SDK state containing workersOldest and workersNewest
|
|
42
42
|
* @returns Resolved ISO 8601 timestamp string
|
|
43
43
|
* @throws Error if required TimeValue.value is missing for ABSOLUTE or *_WINDOW types
|
|
44
|
-
* @throws Error if workersOldest/workersNewest is not set in state for WORKERS_* types
|
|
45
44
|
*/
|
|
46
|
-
export declare function resolveTimeValue(timeValue: TimeValue, state:
|
|
45
|
+
export declare function resolveTimeValue(timeValue: TimeValue, state: SdkState): string;
|
|
47
46
|
//# sourceMappingURL=time-value-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time-value-resolver.d.ts","sourceRoot":"","sources":["../../src/state/time-value-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAiB,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAGrD;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG;IAChD,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,QAAQ,CAAC;CAChB,CAcA;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,KAAK,GAAG,UAAU,GAC5B,MAAM,CA6BR;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,QAAQ,GACd,MAAM,CAyER"}
|
|
@@ -4,7 +4,7 @@ exports.parseDuration = parseDuration;
|
|
|
4
4
|
exports.applyDuration = applyDuration;
|
|
5
5
|
exports.resolveTimeValue = resolveTimeValue;
|
|
6
6
|
const extraction_1 = require("../types/extraction");
|
|
7
|
-
const constants_1 = require("
|
|
7
|
+
const constants_1 = require("../common/constants");
|
|
8
8
|
/**
|
|
9
9
|
* Parses a shorthand duration string into its numeric value and unit.
|
|
10
10
|
* Supported units:
|
|
@@ -71,16 +71,15 @@ function applyDuration(baseTimestamp, duration, operation) {
|
|
|
71
71
|
* - ABSOLUTE: Returns the value directly (must be an ISO 8601 timestamp)
|
|
72
72
|
* - NOW: Returns the current time as ISO 8601
|
|
73
73
|
* - UNBOUNDED: Returns UNBOUNDED_DATE_TIME_VALUE ('1970-01-01T00:00:00.000Z')
|
|
74
|
-
* - WORKERS_OLDEST: Returns workersOldest from state, or
|
|
75
|
-
* - WORKERS_NEWEST: Returns workersNewest from state, or
|
|
76
|
-
* - WORKERS_OLDEST_MINUS_WINDOW: Subtracts duration from workersOldest, or
|
|
77
|
-
* - WORKERS_NEWEST_PLUS_WINDOW: Adds duration to workersNewest, or
|
|
74
|
+
* - WORKERS_OLDEST: Returns workersOldest from state, or UNBOUNDED if not set
|
|
75
|
+
* - WORKERS_NEWEST: Returns workersNewest from state, or UNBOUNDED if not set
|
|
76
|
+
* - WORKERS_OLDEST_MINUS_WINDOW: Subtracts duration from workersOldest, or UNBOUNDED if not set
|
|
77
|
+
* - WORKERS_NEWEST_PLUS_WINDOW: Adds duration to workersNewest, or UNBOUNDED if not set
|
|
78
78
|
*
|
|
79
79
|
* @param timeValue - The TimeValue to resolve
|
|
80
80
|
* @param state - The current SDK state containing workersOldest and workersNewest
|
|
81
81
|
* @returns Resolved ISO 8601 timestamp string
|
|
82
82
|
* @throws Error if required TimeValue.value is missing for ABSOLUTE or *_WINDOW types
|
|
83
|
-
* @throws Error if workersOldest/workersNewest is not set in state for WORKERS_* types
|
|
84
83
|
*/
|
|
85
84
|
function resolveTimeValue(timeValue, state) {
|
|
86
85
|
switch (timeValue.type) {
|
|
@@ -111,7 +110,8 @@ function resolveTimeValue(timeValue, state) {
|
|
|
111
110
|
}
|
|
112
111
|
case extraction_1.TimeValueType.WORKERS_NEWEST: {
|
|
113
112
|
if (!state.workersNewest) {
|
|
114
|
-
|
|
113
|
+
// To support backwards-compatibility for the old state
|
|
114
|
+
return constants_1.UNBOUNDED_DATE_TIME_VALUE;
|
|
115
115
|
}
|
|
116
116
|
return state.workersNewest;
|
|
117
117
|
}
|
|
@@ -130,7 +130,8 @@ function resolveTimeValue(timeValue, state) {
|
|
|
130
130
|
throw new Error("TimeValue of type WORKERS_NEWEST_PLUS_WINDOW must have a value (duration, e.g. '30s', '5m', '2h').");
|
|
131
131
|
}
|
|
132
132
|
if (!state.workersNewest) {
|
|
133
|
-
|
|
133
|
+
// To support backwards-compatibility for the old state
|
|
134
|
+
return constants_1.UNBOUNDED_DATE_TIME_VALUE;
|
|
134
135
|
}
|
|
135
136
|
return applyDuration(state.workersNewest, timeValue.value, 'add');
|
|
136
137
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { AirSyncEvent } from '../types/extraction';
|
|
2
|
-
export declare const MOCK_SERVER_DEFAULT_URL = "http://localhost:0";
|
|
3
2
|
/**
|
|
4
3
|
* Recursively makes all properties of T optional.
|
|
5
4
|
*/
|
|
@@ -16,4 +15,4 @@ export type DeepPartial<T> = {
|
|
|
16
15
|
* deep-merged on top of the defaults.
|
|
17
16
|
*/
|
|
18
17
|
export declare function createMockEvent(mockServerUrl?: string, overrides?: DeepPartial<AirSyncEvent>): AirSyncEvent;
|
|
19
|
-
//# sourceMappingURL=
|
|
18
|
+
//# sourceMappingURL=mock-event.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-event.d.ts","sourceRoot":"","sources":["../../src/testing/mock-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAa,MAAM,qBAAqB,CAAC;AAI9D;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;KAC1B,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAChE,CAAC;AAoCF;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,aAAa,GAAE,MAAgC,EAC/C,SAAS,GAAE,WAAW,CAAC,YAAY,CAAM,GACxC,YAAY,CA+Ed"}
|