@devrev/ts-adaas 1.17.0 → 1.17.1-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-adapter.d.ts","sourceRoot":"","sources":["../../../src/multithreading/worker-adapter/worker-adapter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"worker-adapter.d.ts","sourceRoot":"","sources":["../../../src/multithreading/worker-adapter/worker-adapter.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EACL,oBAAoB,EACpB,aAAa,EACd,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EACL,YAAY,EACZ,SAAS,EAET,kCAAkC,EAClC,yCAAyC,EACzC,kBAAkB,EAClB,2BAA2B,EAC3B,2BAA2B,EAC5B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAEL,wBAAwB,EACxB,kBAAkB,EAClB,6BAA6B,EAC7B,UAAU,EACV,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,qBAAqB,EAEtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EAGrB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,QAAQ,EAAkB,MAAM,oCAAoC,CAAC;AAI9E,wBAAgB,mBAAmB,CAAC,cAAc,EAAE,EAClD,KAAK,EACL,YAAY,EACZ,OAAO,GACR,EAAE,sBAAsB,CAAC,cAAc,CAAC,GAAG,aAAa,CAAC,cAAc,CAAC,CAMxE;AAED;;;;;;;;;;;;;;GAcG;AACH,qBAAa,aAAa,CAAC,cAAc;IACvC,QAAQ,CAAC,KAAK,EAAE,Y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AAE,MAAM,EAAE,CAAC;KAC9B;IA4BK,eAAe,CAAC,EACpB,MAAM,GACP,EAAE;QACD,MAAM,EAAE,6BAA6B,CAAC,wBAAwB,CAAC,CAAC;KACjE,GAAG,OAAO,CAAC,qBAAqB,CAAC;IA6E5B,QAAQ,CAAC,EACb,IAAI,EACJ,cAAc,GACf,EAAE;QACD,IAAI,EAAE,kBAAkB,CAAC;QACzB,cAAc,EAAE,cAAc,CAAC;KAChC,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAkMvB,iBAAiB,CACrB,UAAU,EAAE,oBAAoB,EAChC,MAAM,EAAE,yCAAyC,GAChD,OAAO,CAAC,2BAA2B,CAAC;IA6GvC;;;OAGG;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;IAqD7B;;;;;;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;CAyHzC"}
|
|
@@ -191,11 +191,13 @@ class WorkerAdapter {
|
|
|
191
191
|
if ((_b = data === null || data === void 0 ? void 0 : data.error) === null || _b === void 0 ? void 0 : _b.message) {
|
|
192
192
|
data.error.message = (0, helpers_1.truncateMessage)(data.error.message);
|
|
193
193
|
}
|
|
194
|
+
const isExtractionEvent = Object.values(extraction_1.ExtractorEventType).includes(newEventType);
|
|
195
|
+
const isLoaderEvent = Object.values(loading_1.LoaderEventType).includes(newEventType);
|
|
194
196
|
await (0, control_protocol_1.emit)({
|
|
195
197
|
eventType: newEventType,
|
|
196
198
|
event: this.event,
|
|
197
|
-
data: Object.assign(Object.assign({}, data), (
|
|
198
|
-
? {
|
|
199
|
+
data: Object.assign(Object.assign(Object.assign({}, data), (isExtractionEvent ? { artifacts: this.artifacts } : {})), (isLoaderEvent
|
|
200
|
+
? { reports: this.reports, processed_files: this.processedFiles }
|
|
199
201
|
: {})),
|
|
200
202
|
});
|
|
201
203
|
const message = {
|
|
@@ -569,5 +569,116 @@ describe(worker_adapter_1.WorkerAdapter.name, () => {
|
|
|
569
569
|
});
|
|
570
570
|
expect(counter.counter).toBe(1);
|
|
571
571
|
});
|
|
572
|
+
it('should include artifacts in data for extraction events', async () => {
|
|
573
|
+
const { emit: mockEmit } = require('../../common/control-protocol');
|
|
574
|
+
adapter['adapterState'].postState = jest
|
|
575
|
+
.fn()
|
|
576
|
+
.mockResolvedValue(undefined);
|
|
577
|
+
adapter.uploadAllRepos = jest.fn().mockResolvedValue(undefined);
|
|
578
|
+
adapter['_artifacts'] = [
|
|
579
|
+
{ id: 'art-1', item_count: 10, item_type: 'issues' },
|
|
580
|
+
];
|
|
581
|
+
await adapter.emit(types_1.ExtractorEventType.DataExtractionDone);
|
|
582
|
+
expect(mockEmit).toHaveBeenCalledWith(expect.objectContaining({
|
|
583
|
+
data: expect.objectContaining({
|
|
584
|
+
artifacts: expect.arrayContaining([
|
|
585
|
+
expect.objectContaining({ id: 'art-1' }),
|
|
586
|
+
]),
|
|
587
|
+
}),
|
|
588
|
+
}));
|
|
589
|
+
// Should not include loader-specific fields
|
|
590
|
+
const callData = mockEmit.mock.calls[0][0].data;
|
|
591
|
+
expect(callData).not.toHaveProperty('reports');
|
|
592
|
+
expect(callData).not.toHaveProperty('processed_files');
|
|
593
|
+
});
|
|
594
|
+
it('should include reports and processed_files in data for loader events', async () => {
|
|
595
|
+
const { emit: mockEmit } = require('../../common/control-protocol');
|
|
596
|
+
adapter['adapterState'].postState = jest
|
|
597
|
+
.fn()
|
|
598
|
+
.mockResolvedValue(undefined);
|
|
599
|
+
adapter.uploadAllRepos = jest.fn().mockResolvedValue(undefined);
|
|
600
|
+
adapter['loaderReports'] = [
|
|
601
|
+
{ item_type: 'tasks', created: 5 },
|
|
602
|
+
];
|
|
603
|
+
adapter['_processedFiles'] = ['file-1', 'file-2'];
|
|
604
|
+
await adapter.emit(types_1.LoaderEventType.DataLoadingDone);
|
|
605
|
+
expect(mockEmit).toHaveBeenCalledWith(expect.objectContaining({
|
|
606
|
+
data: expect.objectContaining({
|
|
607
|
+
reports: expect.arrayContaining([
|
|
608
|
+
expect.objectContaining({ item_type: 'tasks' }),
|
|
609
|
+
]),
|
|
610
|
+
processed_files: ['file-1', 'file-2'],
|
|
611
|
+
}),
|
|
612
|
+
}));
|
|
613
|
+
// Should not include extraction-specific fields
|
|
614
|
+
const callData = mockEmit.mock.calls[0][0].data;
|
|
615
|
+
expect(callData).not.toHaveProperty('artifacts');
|
|
616
|
+
});
|
|
617
|
+
it('should not include artifacts, reports, or processed_files for unknown event types', async () => {
|
|
618
|
+
const { emit: mockEmit } = require('../../common/control-protocol');
|
|
619
|
+
adapter['adapterState'].postState = jest
|
|
620
|
+
.fn()
|
|
621
|
+
.mockResolvedValue(undefined);
|
|
622
|
+
adapter.uploadAllRepos = jest.fn().mockResolvedValue(undefined);
|
|
623
|
+
adapter['_artifacts'] = [
|
|
624
|
+
{ id: 'art-1', item_count: 10, item_type: 'issues' },
|
|
625
|
+
];
|
|
626
|
+
adapter['loaderReports'] = [
|
|
627
|
+
{ item_type: 'tasks', created: 5 },
|
|
628
|
+
];
|
|
629
|
+
adapter['_processedFiles'] = ['file-1'];
|
|
630
|
+
await adapter.emit('SOME_UNKNOWN_EVENT');
|
|
631
|
+
const callData = mockEmit.mock.calls[0][0].data;
|
|
632
|
+
expect(callData).not.toHaveProperty('artifacts');
|
|
633
|
+
expect(callData).not.toHaveProperty('reports');
|
|
634
|
+
expect(callData).not.toHaveProperty('processed_files');
|
|
635
|
+
});
|
|
636
|
+
it('should include artifacts for all ExtractorEventType values', async () => {
|
|
637
|
+
var _a, _b;
|
|
638
|
+
const { emit: mockEmit } = require('../../common/control-protocol');
|
|
639
|
+
const extractorEvents = [
|
|
640
|
+
types_1.ExtractorEventType.DataExtractionDone,
|
|
641
|
+
types_1.ExtractorEventType.DataExtractionProgress,
|
|
642
|
+
types_1.ExtractorEventType.DataExtractionError,
|
|
643
|
+
types_1.ExtractorEventType.AttachmentExtractionDone,
|
|
644
|
+
types_1.ExtractorEventType.AttachmentExtractionProgress,
|
|
645
|
+
];
|
|
646
|
+
for (const eventType of extractorEvents) {
|
|
647
|
+
jest.clearAllMocks();
|
|
648
|
+
adapter.hasWorkerEmitted = false;
|
|
649
|
+
adapter['adapterState'].postState = jest
|
|
650
|
+
.fn()
|
|
651
|
+
.mockResolvedValue(undefined);
|
|
652
|
+
adapter.uploadAllRepos = jest.fn().mockResolvedValue(undefined);
|
|
653
|
+
await adapter.emit(eventType);
|
|
654
|
+
const callData = (_b = (_a = mockEmit.mock.calls[0]) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.data;
|
|
655
|
+
expect(callData).toHaveProperty('artifacts');
|
|
656
|
+
expect(callData).not.toHaveProperty('reports');
|
|
657
|
+
}
|
|
658
|
+
});
|
|
659
|
+
it('should include reports and processed_files for all LoaderEventType values', async () => {
|
|
660
|
+
var _a, _b;
|
|
661
|
+
const { emit: mockEmit } = require('../../common/control-protocol');
|
|
662
|
+
const loaderEvents = [
|
|
663
|
+
types_1.LoaderEventType.DataLoadingDone,
|
|
664
|
+
types_1.LoaderEventType.DataLoadingProgress,
|
|
665
|
+
types_1.LoaderEventType.DataLoadingError,
|
|
666
|
+
types_1.LoaderEventType.AttachmentLoadingDone,
|
|
667
|
+
types_1.LoaderEventType.AttachmentLoadingProgress,
|
|
668
|
+
];
|
|
669
|
+
for (const eventType of loaderEvents) {
|
|
670
|
+
jest.clearAllMocks();
|
|
671
|
+
adapter.hasWorkerEmitted = false;
|
|
672
|
+
adapter['adapterState'].postState = jest
|
|
673
|
+
.fn()
|
|
674
|
+
.mockResolvedValue(undefined);
|
|
675
|
+
adapter.uploadAllRepos = jest.fn().mockResolvedValue(undefined);
|
|
676
|
+
await adapter.emit(eventType);
|
|
677
|
+
const callData = (_b = (_a = mockEmit.mock.calls[0]) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.data;
|
|
678
|
+
expect(callData).toHaveProperty('reports');
|
|
679
|
+
expect(callData).toHaveProperty('processed_files');
|
|
680
|
+
expect(callData).not.toHaveProperty('artifacts');
|
|
681
|
+
}
|
|
682
|
+
});
|
|
572
683
|
});
|
|
573
684
|
});
|