@devrev/ts-adaas 1.13.1-beta.0 → 1.13.1-beta.2
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/common/helpers.d.ts +5 -0
- package/dist/common/helpers.d.ts.map +1 -1
- package/dist/common/helpers.js +27 -0
- package/dist/tests/spawn-worker/delete-event-type.test.d.ts +2 -0
- package/dist/tests/spawn-worker/delete-event-type.test.d.ts.map +1 -0
- package/dist/tests/spawn-worker/delete-event-type.test.js +31 -0
- package/dist/tests/spawn-worker/extraction.d.ts +4 -0
- package/dist/tests/spawn-worker/extraction.d.ts.map +1 -0
- package/dist/tests/spawn-worker/extraction.js +19 -0
- package/dist/tests/spawn-worker/some-cleanup-worker.d.ts +2 -0
- package/dist/tests/spawn-worker/some-cleanup-worker.d.ts.map +1 -0
- package/dist/tests/spawn-worker/some-cleanup-worker.js +16 -0
- package/dist/tests/spawn-worker/unknown-event-type.d.ts +2 -0
- package/dist/tests/spawn-worker/unknown-event-type.d.ts.map +1 -0
- package/dist/tests/spawn-worker/unknown-event-type.js +19 -0
- package/dist/tests/spawn-worker/unknown-event-type.test.d.ts +2 -0
- package/dist/tests/spawn-worker/unknown-event-type.test.d.ts.map +1 -0
- package/dist/tests/spawn-worker/unknown-event-type.test.js +21 -0
- package/dist/workers/spawn.d.ts.map +1 -1
- package/dist/workers/spawn.js +19 -61
- package/dist/workers/worker-adapter.d.ts.map +1 -1
- package/dist/workers/worker-adapter.js +2 -0
- package/package.json +1 -1
package/dist/common/helpers.d.ts
CHANGED
|
@@ -3,6 +3,11 @@ import { FileToLoad, LoaderEventType, LoaderReport, StatsFileObject } from '../t
|
|
|
3
3
|
export declare function getTimeoutErrorEventType(eventType: EventType): {
|
|
4
4
|
eventType: ExtractorEventType | LoaderEventType;
|
|
5
5
|
};
|
|
6
|
+
export declare function getNoScriptEventType(eventType: EventType): {
|
|
7
|
+
eventType: ExtractorEventType;
|
|
8
|
+
} | {
|
|
9
|
+
eventType: LoaderEventType;
|
|
10
|
+
};
|
|
6
11
|
export declare function getSyncDirection({ event }: {
|
|
7
12
|
event: AirdropEvent;
|
|
8
13
|
}): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/common/helpers.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,YAAY,EACZ,SAAS,EACT,kBAAkB,EACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAEL,UAAU,EACV,eAAe,EACf,YAAY,EACZ,eAAe,EAChB,MAAM,kBAAkB,CAAC;AAM1B,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,SAAS,GAAG;IAC9D,SAAS,EAAE,kBAAkB,GAAG,eAAe,CAAC;CACjD,CAmFA;AAED,wBAAgB,gBAAgB,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,YAAY,CAAA;CAAE,UAElE;AAED,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,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;AAGD,wBAAgB,iBAAiB,QAiBhC;AAED,wBAAsB,KAAK,CAAC,EAAE,EAAE,MAAM,oBAGrC;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAmBzD;AAED,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,C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AE,MAAM,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,cAAc,IAAI,UAAU,CAmD3C"}
|
package/dist/common/helpers.js
CHANGED
|
@@ -34,6 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.getTimeoutErrorEventType = getTimeoutErrorEventType;
|
|
37
|
+
exports.getNoScriptEventType = getNoScriptEventType;
|
|
37
38
|
exports.getSyncDirection = getSyncDirection;
|
|
38
39
|
exports.getFilesToLoad = getFilesToLoad;
|
|
39
40
|
exports.addReportToLoaderReport = addReportToLoaderReport;
|
|
@@ -119,6 +120,32 @@ function getTimeoutErrorEventType(eventType) {
|
|
|
119
120
|
};
|
|
120
121
|
}
|
|
121
122
|
}
|
|
123
|
+
function getNoScriptEventType(eventType) {
|
|
124
|
+
switch (eventType) {
|
|
125
|
+
case extraction_1.EventType.StartDeletingExtractorState:
|
|
126
|
+
return {
|
|
127
|
+
eventType: extraction_1.ExtractorEventType.ExtractorStateDeletionDone,
|
|
128
|
+
};
|
|
129
|
+
case extraction_1.EventType.StartDeletingExtractorAttachmentsState:
|
|
130
|
+
return {
|
|
131
|
+
eventType: extraction_1.ExtractorEventType.ExtractorAttachmentsStateDeletionDone,
|
|
132
|
+
};
|
|
133
|
+
case extraction_1.EventType.StartDeletingLoaderState:
|
|
134
|
+
return {
|
|
135
|
+
eventType: loading_1.LoaderEventType.LoaderStateDeletionDone,
|
|
136
|
+
};
|
|
137
|
+
case extraction_1.EventType.StartDeletingLoaderAttachmentState:
|
|
138
|
+
return {
|
|
139
|
+
eventType: loading_1.LoaderEventType.LoaderAttachmentStateDeletionDone,
|
|
140
|
+
};
|
|
141
|
+
default:
|
|
142
|
+
console.error('Event type not recognized in getNoScriptEventType function: ' +
|
|
143
|
+
eventType);
|
|
144
|
+
return {
|
|
145
|
+
eventType: loading_1.LoaderEventType.UnknownEventType,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
}
|
|
122
149
|
function getSyncDirection({ event }) {
|
|
123
150
|
return event.payload.event_context.mode;
|
|
124
151
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-event-type.test.d.ts","sourceRoot":"","sources":["../../../src/tests/spawn-worker/delete-event-type.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const extraction_1 = require("../../types/extraction");
|
|
7
|
+
const jest_setup_1 = require("../jest.setup");
|
|
8
|
+
const test_helpers_1 = require("../test-helpers");
|
|
9
|
+
const extraction_2 = __importDefault(require("./extraction"));
|
|
10
|
+
describe('Delete event type', () => {
|
|
11
|
+
it('should successfully emit delete done event when the incoming event is start delete and there is no script passed', async () => {
|
|
12
|
+
const event = (0, test_helpers_1.createEvent)({
|
|
13
|
+
eventType: extraction_1.EventType.StartDeletingExtractorState,
|
|
14
|
+
});
|
|
15
|
+
await (0, extraction_2.default)([event]);
|
|
16
|
+
const lastRequest = jest_setup_1.mockServer.getLastRequest();
|
|
17
|
+
expect(lastRequest === null || lastRequest === void 0 ? void 0 : lastRequest.url).toContain('/callback_url');
|
|
18
|
+
expect(lastRequest === null || lastRequest === void 0 ? void 0 : lastRequest.method).toBe('POST');
|
|
19
|
+
expect((lastRequest === null || lastRequest === void 0 ? void 0 : lastRequest.body).event_type).toBe(extraction_1.ExtractorEventType.ExtractorStateDeletionDone);
|
|
20
|
+
});
|
|
21
|
+
it('should successfully emit delete done event when the incoming event is start delete and there is a script passed', async () => {
|
|
22
|
+
const event = (0, test_helpers_1.createEvent)({
|
|
23
|
+
eventType: extraction_1.EventType.StartDeletingExtractorState,
|
|
24
|
+
});
|
|
25
|
+
await (0, extraction_2.default)([event], __dirname + '/some-cleanup-worker');
|
|
26
|
+
const lastRequest = jest_setup_1.mockServer.getLastRequest();
|
|
27
|
+
expect(lastRequest === null || lastRequest === void 0 ? void 0 : lastRequest.url).toContain('/callback_url');
|
|
28
|
+
expect(lastRequest === null || lastRequest === void 0 ? void 0 : lastRequest.method).toBe('POST');
|
|
29
|
+
expect((lastRequest === null || lastRequest === void 0 ? void 0 : lastRequest.body).event_type).toBe(extraction_1.ExtractorEventType.ExtractorStateDeletionDone);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extraction.d.ts","sourceRoot":"","sources":["../../../src/tests/spawn-worker/extraction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAS,MAAM,aAAa,CAAC;AASlD,QAAA,MAAM,GAAG,GAAU,QAAQ,YAAY,EAAE,EAAE,aAAa,MAAM,kBAY7D,CAAC;AAEF,eAAe,GAAG,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const index_1 = require("../../index");
|
|
4
|
+
const initialState = {};
|
|
5
|
+
const initialDomainMapping = {};
|
|
6
|
+
const run = async (events, workerPath) => {
|
|
7
|
+
for (const event of events) {
|
|
8
|
+
await (0, index_1.spawn)({
|
|
9
|
+
event,
|
|
10
|
+
initialState,
|
|
11
|
+
workerPath,
|
|
12
|
+
initialDomainMapping,
|
|
13
|
+
options: {
|
|
14
|
+
isLocalDevelopment: true,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
exports.default = run;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"some-cleanup-worker.d.ts","sourceRoot":"","sources":["../../../src/tests/spawn-worker/some-cleanup-worker.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const index_1 = require("../../index");
|
|
4
|
+
(0, index_1.processTask)({
|
|
5
|
+
task: async ({ adapter }) => {
|
|
6
|
+
console.log('Some cleanup logic executed.');
|
|
7
|
+
await adapter.emit(index_1.ExtractorEventType.ExtractorStateDeletionDone);
|
|
8
|
+
},
|
|
9
|
+
onTimeout: async ({ adapter }) => {
|
|
10
|
+
await adapter.emit(index_1.ExtractorEventType.ExtractorStateDeletionError, {
|
|
11
|
+
error: {
|
|
12
|
+
message: 'Failed to execute cleanup logic. Lambda timeout.',
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
},
|
|
16
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unknown-event-type.d.ts","sourceRoot":"","sources":["../../../src/tests/spawn-worker/unknown-event-type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const index_1 = require("../../index");
|
|
4
|
+
(0, index_1.processTask)({
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
6
|
+
task: async ({ adapter }) => {
|
|
7
|
+
await new Promise((resolve) => setTimeout(() => {
|
|
8
|
+
console.log('task should not be called.');
|
|
9
|
+
resolve(true);
|
|
10
|
+
}, 1000));
|
|
11
|
+
},
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
13
|
+
onTimeout: async ({ adapter }) => {
|
|
14
|
+
await new Promise((resolve) => setTimeout(() => {
|
|
15
|
+
console.log('onTimeout should not be called.');
|
|
16
|
+
resolve(true);
|
|
17
|
+
}, 1000));
|
|
18
|
+
},
|
|
19
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unknown-event-type.test.d.ts","sourceRoot":"","sources":["../../../src/tests/spawn-worker/unknown-event-type.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const extraction_1 = require("../../types/extraction");
|
|
7
|
+
const jest_setup_1 = require("../jest.setup");
|
|
8
|
+
const test_helpers_1 = require("../test-helpers");
|
|
9
|
+
const extraction_2 = __importDefault(require("./extraction"));
|
|
10
|
+
describe('Unknown event type', () => {
|
|
11
|
+
it('should successfully emit unknown event type when the event type is not found', async () => {
|
|
12
|
+
const event = (0, test_helpers_1.createEvent)({
|
|
13
|
+
eventType: 'INVALID_EVENT_TYPE',
|
|
14
|
+
});
|
|
15
|
+
await (0, extraction_2.default)([event], __dirname + '/unknown-event-type');
|
|
16
|
+
const lastRequest = jest_setup_1.mockServer.getLastRequest();
|
|
17
|
+
expect(lastRequest === null || lastRequest === void 0 ? void 0 : lastRequest.url).toContain('/callback_url');
|
|
18
|
+
expect(lastRequest === null || lastRequest === void 0 ? void 0 : lastRequest.method).toBe('POST');
|
|
19
|
+
expect((lastRequest === null || lastRequest === void 0 ? void 0 : lastRequest.body).event_type).toBe(extraction_1.ExtractorEventType.UnknownEventType);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -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;
|
|
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,CAqFvD;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,6 @@ 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
|
-
const types_1 = require("../types");
|
|
19
18
|
function getWorkerPath({ event, workerBasePath, }) {
|
|
20
19
|
let path = null;
|
|
21
20
|
switch (event.payload.event_type) {
|
|
@@ -48,26 +47,25 @@ function getWorkerPath({ event, workerBasePath, }) {
|
|
|
48
47
|
* @returns {Promise<Spawn>} - A new instance of Spawn class
|
|
49
48
|
*/
|
|
50
49
|
async function spawn({ event, initialState, workerPath, initialDomainMapping, options, baseWorkerPath, }) {
|
|
51
|
-
//
|
|
52
|
-
//
|
|
50
|
+
// Translate incoming event type for backwards compatibility. This allows the
|
|
51
|
+
// SDK to accept both old and new event type formats. Then update the event with the translated event type.
|
|
53
52
|
const originalEventType = event.payload.event_type;
|
|
54
53
|
const translatedEventType = (0, event_type_translation_1.translateIncomingEventType)(event.payload.event_type);
|
|
55
|
-
// Update the event with the translated event type
|
|
56
54
|
event.payload.event_type = translatedEventType;
|
|
55
|
+
// Read the command line arguments to check if the local flag is passed.
|
|
56
|
+
const argv = await (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv)).argv;
|
|
57
|
+
if (argv._.includes('local') && options) {
|
|
58
|
+
options.isLocalDevelopment = true;
|
|
59
|
+
}
|
|
60
|
+
const originalConsole = console;
|
|
61
|
+
// eslint-disable-next-line no-global-assign
|
|
62
|
+
console = new logger_1.Logger({ event, options });
|
|
57
63
|
if (translatedEventType !== originalEventType) {
|
|
58
64
|
console.log(`Event type translated from ${originalEventType} to ${translatedEventType}.`);
|
|
59
65
|
}
|
|
60
66
|
if (options === null || options === void 0 ? void 0 : options.isLocalDevelopment) {
|
|
61
67
|
console.log('Snap-in is running in local development mode.');
|
|
62
68
|
}
|
|
63
|
-
// read the command line arguments to check if the local flag is passed
|
|
64
|
-
const argv = await (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv)).argv;
|
|
65
|
-
if (argv._.includes('local')) {
|
|
66
|
-
options = Object.assign(Object.assign({}, (options || {})), { isLocalDevelopment: true });
|
|
67
|
-
}
|
|
68
|
-
const originalConsole = console;
|
|
69
|
-
// eslint-disable-next-line no-global-assign
|
|
70
|
-
console = new logger_1.Logger({ event, options });
|
|
71
69
|
let script = null;
|
|
72
70
|
if (workerPath != null) {
|
|
73
71
|
script = workerPath;
|
|
@@ -85,6 +83,7 @@ async function spawn({ event, initialState, workerPath, initialDomainMapping, op
|
|
|
85
83
|
workerBasePath: baseWorkerPath !== null && baseWorkerPath !== void 0 ? baseWorkerPath : __dirname,
|
|
86
84
|
});
|
|
87
85
|
}
|
|
86
|
+
// If a script is found for the event type, spawn a new worker.
|
|
88
87
|
if (script) {
|
|
89
88
|
try {
|
|
90
89
|
const worker = await (0, create_worker_1.createWorker)({
|
|
@@ -112,55 +111,14 @@ async function spawn({ event, initialState, workerPath, initialDomainMapping, op
|
|
|
112
111
|
}
|
|
113
112
|
}
|
|
114
113
|
else {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
case extraction_1.EventType.StartDeletingLoaderAttachmentState:
|
|
124
|
-
await (0, control_protocol_1.emit)({
|
|
125
|
-
event,
|
|
126
|
-
eventType: types_1.LoaderEventType.LoaderAttachmentStateDeletionDone,
|
|
127
|
-
});
|
|
128
|
-
return;
|
|
129
|
-
case extraction_1.EventType.StartDeletingExtractorState:
|
|
130
|
-
await (0, control_protocol_1.emit)({
|
|
131
|
-
event,
|
|
132
|
-
eventType: extraction_1.ExtractorEventType.ExtractorStateDeletionDone,
|
|
133
|
-
});
|
|
134
|
-
return;
|
|
135
|
-
case extraction_1.EventType.StartDeletingLoaderState:
|
|
136
|
-
await (0, control_protocol_1.emit)({
|
|
137
|
-
event,
|
|
138
|
-
eventType: types_1.LoaderEventType.LoaderStateDeletionDone,
|
|
139
|
-
});
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
console.error('Script was not found for event type: ' + event.payload.event_type + '.');
|
|
143
|
-
try {
|
|
144
|
-
await (0, control_protocol_1.emit)({
|
|
145
|
-
event,
|
|
146
|
-
eventType: extraction_1.ExtractorEventType.UnknownEventType,
|
|
147
|
-
data: {
|
|
148
|
-
error: {
|
|
149
|
-
message: 'Unrecognized event type in spawn ' +
|
|
150
|
-
event.payload.event_type +
|
|
151
|
-
'.',
|
|
152
|
-
},
|
|
153
|
-
},
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
catch (error) {
|
|
157
|
-
console.error('Error while emitting event.', (0, logger_1.serializeError)(error));
|
|
158
|
-
return Promise.reject(error);
|
|
159
|
-
}
|
|
160
|
-
finally {
|
|
161
|
-
// eslint-disable-next-line no-global-assign
|
|
162
|
-
console = originalConsole;
|
|
163
|
-
}
|
|
114
|
+
const { eventType } = (0, helpers_2.getNoScriptEventType)(event.payload.event_type);
|
|
115
|
+
await (0, control_protocol_1.emit)({
|
|
116
|
+
event,
|
|
117
|
+
eventType,
|
|
118
|
+
});
|
|
119
|
+
// eslint-disable-next-line no-global-assign
|
|
120
|
+
console = originalConsole;
|
|
121
|
+
return Promise.resolve();
|
|
164
122
|
}
|
|
165
123
|
}
|
|
166
124
|
class Spawn {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-adapter.d.ts","sourceRoot":"","sources":["../../src/workers/worker-adapter.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAE9E,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EACL,YAAY,EACZ,SAAS,EAET,kCAAkC,EAClC,yCAAyC,EACzC,kBAAkB,EAClB,2BAA2B,EAC3B,2BAA2B,EAC5B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAEL,wBAAwB,EACxB,kBAAkB,EAClB,6BAA6B,EAC7B,UAAU,EACV,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,qBAAqB,EAEtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EAGrB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,QAAQ,EAAkB,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"worker-adapter.d.ts","sourceRoot":"","sources":["../../src/workers/worker-adapter.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,OAAO,EAAE,I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;IACH,OAAO,CAAC,iBAAiB;IAcnB,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;IAmD7B;;;;;;OAMG;IACG,iBAAiB,CAAC,QAAQ,EAAE,EAChC,MAAM,EACN,UAAU,EACV,SAAa,GACd,EAAE;QACD,MAAM,EAAE,yCAAyC,CAAC;QAClD,UAAU,CAAC,EAAE,kCAAkC,CAC7C,cAAc,EACd,oBAAoB,EAAE,EACtB,QAAQ,CACT,CAAC;QACF,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,2BAA2B,CAAC;CAsHzC"}
|
|
@@ -19,6 +19,7 @@ const extraction_1 = require("../types/extraction");
|
|
|
19
19
|
const loading_1 = require("../types/loading");
|
|
20
20
|
const workers_1 = require("../types/workers");
|
|
21
21
|
const uploader_1 = require("../uploader/uploader");
|
|
22
|
+
const event_type_translation_1 = require("../common/event-type-translation");
|
|
22
23
|
function createWorkerAdapter({ event, adapterState, options, }) {
|
|
23
24
|
return new WorkerAdapter({
|
|
24
25
|
event,
|
|
@@ -118,6 +119,7 @@ class WorkerAdapter {
|
|
|
118
119
|
* @param data - The data to be sent with the event
|
|
119
120
|
*/
|
|
120
121
|
async emit(newEventType, data) {
|
|
122
|
+
newEventType = (0, event_type_translation_1.translateOutgoingEventType)(newEventType);
|
|
121
123
|
if (this.hasWorkerEmitted) {
|
|
122
124
|
console.warn(`Trying to emit event with event type: ${newEventType}. Ignoring emit request because it has already been emitted.`);
|
|
123
125
|
return;
|
package/package.json
CHANGED