@devrev/ts-adaas 1.12.3-beta.3 → 1.12.3-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/dist/tests/backwards-compatibility/backwards-compatibility.test.d.ts.map +1 -1
- package/dist/tests/backwards-compatibility/backwards-compatibility.test.js +27 -1
- package/dist/types/workers.d.ts +7 -3
- package/dist/types/workers.d.ts.map +1 -1
- package/dist/workers/spawn.d.ts +1 -1
- package/dist/workers/spawn.d.ts.map +1 -1
- package/dist/workers/spawn.js +7 -6
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backwards-compatibility.test.d.ts","sourceRoot":"","sources":["../../../src/tests/backwards-compatibility/backwards-compatibility.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EAGd,WAAW,EAGX,kBAAkB,EAKnB,MAAM,gCAAgC,CAAC;AAgBxC,wBAAgB,0BAA0B,CACxC,WAAW,EAAE,WAAW,GAAG,cAAc,GAAG,kBAAkB,EAC9D,eAAe,EAAE,WAAW,GAAG,cAAc,GAAG,kBAAkB,
|
|
1
|
+
{"version":3,"file":"backwards-compatibility.test.d.ts","sourceRoot":"","sources":["../../../src/tests/backwards-compatibility/backwards-compatibility.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EAGd,WAAW,EAGX,kBAAkB,EAKnB,MAAM,gCAAgC,CAAC;AAgBxC,wBAAgB,0BAA0B,CACxC,WAAW,EAAE,WAAW,GAAG,cAAc,GAAG,kBAAkB,EAC9D,eAAe,EAAE,WAAW,GAAG,cAAc,GAAG,kBAAkB,QAuHnE"}
|
|
@@ -14,7 +14,29 @@ function checkFunctionCompatibility(newFunction, currentFunction) {
|
|
|
14
14
|
.slice(0, lengthOfPreviousParameters)
|
|
15
15
|
.map((p) => p.name);
|
|
16
16
|
const currentFunctionParamNames = currentFunction.parameters.map((p) => p.name);
|
|
17
|
-
|
|
17
|
+
// Check each parameter position for destructured parameter compatibility
|
|
18
|
+
for (let i = 0; i <
|
|
19
|
+
Math.min(newFunctionParamNames.length, currentFunctionParamNames.length); i++) {
|
|
20
|
+
const newParam = newFunctionParamNames[i];
|
|
21
|
+
const currentParam = currentFunctionParamNames[i];
|
|
22
|
+
// If both are destructured parameters (contain '{')
|
|
23
|
+
if (newParam.includes('{') && currentParam.includes('{')) {
|
|
24
|
+
// Extract field names from destructured parameters
|
|
25
|
+
const extractFields = (param) => param
|
|
26
|
+
.replace(/[{}\s]/g, '')
|
|
27
|
+
.split(',')
|
|
28
|
+
.filter((f) => f.length > 0);
|
|
29
|
+
const newFields = extractFields(newParam);
|
|
30
|
+
const currentFields = extractFields(currentParam);
|
|
31
|
+
// Check that all current fields are present in new fields
|
|
32
|
+
const missingFields = currentFields.filter((field) => !newFields.includes(field));
|
|
33
|
+
expect(missingFields).toEqual([]);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
// For non-destructured parameters, they must match exactly
|
|
37
|
+
expect(newParam).toEqual(currentParam);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
18
40
|
});
|
|
19
41
|
it(`Function ${newFunction.displayName} should have compatible parameter types with the current function`, () => {
|
|
20
42
|
const newFunctionParamTypes = newFunction.parameters
|
|
@@ -53,6 +75,10 @@ function checkFunctionCompatibility(newFunction, currentFunction) {
|
|
|
53
75
|
if (currentParam.isOptional && !newParam.isOptional) {
|
|
54
76
|
throw new Error(`Parameter ${newParam.name} became required but was optional`);
|
|
55
77
|
}
|
|
78
|
+
// Skip interface compatibility check for destructured parameters
|
|
79
|
+
if (newParam.name.includes('{') || currentParam.name.includes('{')) {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
56
82
|
}
|
|
57
83
|
});
|
|
58
84
|
}
|
package/dist/types/workers.d.ts
CHANGED
|
@@ -24,15 +24,13 @@ export interface WorkerAdapterInterface<ConnectorState> {
|
|
|
24
24
|
* @param {boolean=} isLocalDevelopment - A flag to indicate if the adapter is being used in local development
|
|
25
25
|
* @param {number=} timeout - The timeout for the worker thread
|
|
26
26
|
* @param {number=} batchSize - Maximum number of extracted items in a batch
|
|
27
|
-
* @param {string=} baseWorkerPath - The base path for the worker files, usually `__dirname`
|
|
28
27
|
* @param {Record<EventType, string>=} workerPathOverrides - A map of event types to custom worker paths to override default worker paths
|
|
29
28
|
*/
|
|
30
29
|
export interface WorkerAdapterOptions {
|
|
31
30
|
isLocalDevelopment?: boolean;
|
|
32
31
|
timeout?: number;
|
|
33
32
|
batchSize?: number;
|
|
34
|
-
|
|
35
|
-
workerPathOverrides?: Partial<Record<EventType, string>>;
|
|
33
|
+
workerPathOverrides?: WorkerPathOverrides;
|
|
36
34
|
}
|
|
37
35
|
/**
|
|
38
36
|
* SpawnInterface is an interface for Spawn class.
|
|
@@ -60,6 +58,7 @@ export interface SpawnInterface {
|
|
|
60
58
|
* @param {string} workerPath - The path to the worker file
|
|
61
59
|
* @param {string} initialDomainMapping - The initial domain mapping
|
|
62
60
|
* @param {WorkerAdapterOptions} options - The options to create a new instance of Spawn class
|
|
61
|
+
* @param {string=} baseWorkerPath - The base path for the worker files, usually `__dirname`
|
|
63
62
|
*/
|
|
64
63
|
export interface SpawnFactoryInterface<ConnectorState> {
|
|
65
64
|
event: AirdropEvent;
|
|
@@ -67,6 +66,7 @@ export interface SpawnFactoryInterface<ConnectorState> {
|
|
|
67
66
|
workerPath?: string;
|
|
68
67
|
options?: WorkerAdapterOptions;
|
|
69
68
|
initialDomainMapping?: InitialDomainMapping;
|
|
69
|
+
baseWorkerPath?: string;
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
72
|
* TaskAdapterInterface is an interface for TaskAdapter class.
|
|
@@ -141,4 +141,8 @@ export interface GetWorkerPathInterface {
|
|
|
141
141
|
event: AirdropEvent;
|
|
142
142
|
workerBasePath?: string | null;
|
|
143
143
|
}
|
|
144
|
+
/**
|
|
145
|
+
* WorkerPathOverrides represents a mapping of event types to custom worker paths.
|
|
146
|
+
*/
|
|
147
|
+
export type WorkerPathOverrides = Partial<Record<EventType, string>>;
|
|
144
148
|
//# sourceMappingURL=workers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workers.d.ts","sourceRoot":"","sources":["../../src/types/workers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAE3E,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEhD;;;;;;;GAOG;AACH,MAAM,WAAW,sBAAsB,CAAC,cAAc;IACpD,KAAK,EAAE,YAAY,CAAC;IACpB,YAAY,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IACpC,OAAO,CAAC,EAAE,oBAAoB,CAAC;CAChC;AAED
|
|
1
|
+
{"version":3,"file":"workers.d.ts","sourceRoot":"","sources":["../../src/types/workers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAE3E,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEhD;;;;;;;GAOG;AACH,MAAM,WAAW,sBAAsB,CAAC,cAAc;IACpD,KAAK,EAAE,YAAY,CAAC;IACpB,YAAY,EAAE,KAAK,CAAC,cAAc,CAAC,C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AAY,WAAW;IACvB,WAAW,UAAU;IACrB,UAAU,SAAS;CACpB;AAED;;GAEG;AACH,oBAAY,oBAAoB;IAC9B,oBAAoB,SAAS;IAC7B,iBAAiB,SAAS;IAC1B,gBAAgB,QAAQ;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,oBAAoB,CAAC,oBAAoB,CAAC;IACnD,OAAO,EAAE;QACP,SAAS,EAAE,kBAAkB,GAAG,eAAe,CAAC;KACjD,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,oBAAoB,CAAC,iBAAiB,CAAC;CACjD;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,oBAAoB,GAAG,iBAAiB,CAAC;AAErE;;GAEG;AACH,MAAM,WAAW,UAAU,CAAC,cAAc;IACxC,KAAK,EAAE,YAAY,CAAC;IACpB,YAAY,EAAE,cAAc,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C,OAAO,CAAC,EAAE,oBAAoB,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,YAAY,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC"}
|
package/dist/workers/spawn.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { SpawnFactoryInterface, SpawnInterface } from '../types/workers';
|
|
|
10
10
|
* @param {string} options.workerPath - The path to the worker file
|
|
11
11
|
* @returns {Promise<Spawn>} - A new instance of Spawn class
|
|
12
12
|
*/
|
|
13
|
-
export declare function spawn<ConnectorState>({ event, initialState, workerPath, initialDomainMapping, options, }: SpawnFactoryInterface<ConnectorState>): Promise<void>;
|
|
13
|
+
export declare function spawn<ConnectorState>({ event, initialState, workerPath, initialDomainMapping, options, baseWorkerPath, }: SpawnFactoryInterface<ConnectorState>): Promise<void>;
|
|
14
14
|
export declare class Spawn {
|
|
15
15
|
private event;
|
|
16
16
|
private alreadyEmitted;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spawn.d.ts","sourceRoot":"","sources":["../../src/workers/spawn.ts"],"names":[],"mappings":"AAYA,OAAO,EAEL,qBAAqB,EACrB,cAAc,EAGf,MAAM,kBAAkB,CAAC;AAmC1B;;;;;;;;;;GAUG;AACH,wBAAsB,KAAK,CAAC,cAAc,EAAE,EAC1C,KAAK,EACL,YAAY,EACZ,UAAU,EACV,oBAAoB,EACpB,OAAO,
|
|
1
|
+
{"version":3,"file":"spawn.d.ts","sourceRoot":"","sources":["../../src/workers/spawn.ts"],"names":[],"mappings":"AAYA,OAAO,EAEL,qBAAqB,EACrB,cAAc,EAGf,MAAM,kBAAkB,CAAC;AAmC1B;;;;;;;;;;GAUG;AACH,wBAAsB,KAAK,CAAC,cAAc,EAAE,EAC1C,KAAK,EACL,YAAY,EACZ,UAAU,EACV,oBAAoB,EACpB,OAAO,EACP,cAAc,GACf,EAAE,qBAAqB,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAuGvD;AAED,qBAAa,KAAK;IAChB,OAAO,CAAC,KAAK,CAAe;IAC5B,OAAO,CAAC,cAAc,CAAU;IAChC,OAAO,CAAC,oBAAoB,CAAkC;IAC9D,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,gBAAgB,CAA4C;IACpE,OAAO,CAAC,gBAAgB,CAA4C;IACpE,OAAO,CAAC,wBAAwB,CAA6C;IAC7E,OAAO,CAAC,OAAO,CAA4C;IAC3D,OAAO,CAAC,eAAe,CAAU;IACjC,OAAO,CAAC,MAAM,CAAS;gBACX,EACV,KAAK,EACL,MAAM,EACN,OAAO,EACP,OAAO,EACP,eAAe,GAChB,EAAE,cAAc;IAgGjB,OAAO,CAAC,aAAa;YAYP,kBAAkB;CAiCjC"}
|
package/dist/workers/spawn.js
CHANGED
|
@@ -15,7 +15,7 @@ const extraction_1 = require("../types/extraction");
|
|
|
15
15
|
const workers_1 = require("../types/workers");
|
|
16
16
|
const constants_1 = require("../common/constants");
|
|
17
17
|
const create_worker_1 = require("./create-worker");
|
|
18
|
-
function getWorkerPath({ event, workerBasePath }) {
|
|
18
|
+
function getWorkerPath({ event, workerBasePath, }) {
|
|
19
19
|
let path = null;
|
|
20
20
|
switch (event.payload.event_type) {
|
|
21
21
|
case extraction_1.EventType.StartExtractingExternalSyncUnits:
|
|
@@ -46,8 +46,7 @@ function getWorkerPath({ event, workerBasePath }) {
|
|
|
46
46
|
* @param {string} options.workerPath - The path to the worker file
|
|
47
47
|
* @returns {Promise<Spawn>} - A new instance of Spawn class
|
|
48
48
|
*/
|
|
49
|
-
async function spawn({ event, initialState, workerPath, initialDomainMapping, options, }) {
|
|
50
|
-
var _a;
|
|
49
|
+
async function spawn({ event, initialState, workerPath, initialDomainMapping, options, baseWorkerPath, }) {
|
|
51
50
|
// Translates incoming event type for backwards compatibility
|
|
52
51
|
// This allows the SDK to accept both old and new event type formats
|
|
53
52
|
const originalEventType = event.payload.event_type;
|
|
@@ -72,15 +71,17 @@ async function spawn({ event, initialState, workerPath, initialDomainMapping, op
|
|
|
72
71
|
if (workerPath != null) {
|
|
73
72
|
script = workerPath;
|
|
74
73
|
}
|
|
75
|
-
else if (
|
|
74
|
+
else if (baseWorkerPath != null &&
|
|
76
75
|
(options === null || options === void 0 ? void 0 : options.workerPathOverrides) != null &&
|
|
77
76
|
options.workerPathOverrides[translatedEventType] != null) {
|
|
78
|
-
script =
|
|
77
|
+
script =
|
|
78
|
+
baseWorkerPath +
|
|
79
|
+
options.workerPathOverrides[translatedEventType];
|
|
79
80
|
}
|
|
80
81
|
else {
|
|
81
82
|
script = getWorkerPath({
|
|
82
83
|
event,
|
|
83
|
-
workerBasePath:
|
|
84
|
+
workerBasePath: baseWorkerPath !== null && baseWorkerPath !== void 0 ? baseWorkerPath : __dirname,
|
|
84
85
|
});
|
|
85
86
|
}
|
|
86
87
|
if (script) {
|
package/package.json
CHANGED