@semiont/make-meaning 0.2.32-build.70 → 0.2.32-build.71
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/index.d.ts +37 -7
- package/dist/index.js +133 -78
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JobWorker, JobQueue, AnyJob } from '@semiont/jobs';
|
|
1
|
+
import { JobWorker, JobQueue, AnyJob, DetectionResult, RunningJob, DetectionParams, DetectionProgress, GenerationResult, GenerationParams, GenerationProgress, HighlightDetectionResult, HighlightDetectionParams, HighlightDetectionProgress, AssessmentDetectionResult, AssessmentDetectionParams, AssessmentDetectionProgress, CommentDetectionResult, CommentDetectionParams, CommentDetectionProgress, TagDetectionResult, TagDetectionParams, TagDetectionProgress } from '@semiont/jobs';
|
|
2
2
|
import { EventStore } from '@semiont/event-sourcing';
|
|
3
3
|
import { RepresentationStore } from '@semiont/content';
|
|
4
4
|
import { EnvironmentConfig, ResourceId, StoredEvent, ResourceAnnotations, AnnotationId, AnnotationCategory, GraphPath, GraphConnection } from '@semiont/core';
|
|
@@ -35,7 +35,7 @@ declare class ReferenceDetectionWorker extends JobWorker {
|
|
|
35
35
|
constructor(jobQueue: JobQueue, config: EnvironmentConfig, eventStore: EventStore, inferenceClient: InferenceClient);
|
|
36
36
|
protected getWorkerName(): string;
|
|
37
37
|
protected canProcessJob(job: AnyJob): boolean;
|
|
38
|
-
protected executeJob(job: AnyJob): Promise<
|
|
38
|
+
protected executeJob(job: AnyJob): Promise<DetectionResult>;
|
|
39
39
|
/**
|
|
40
40
|
* Detect entity references in resource using AI
|
|
41
41
|
* Self-contained implementation for reference detection
|
|
@@ -44,6 +44,11 @@ declare class ReferenceDetectionWorker extends JobWorker {
|
|
|
44
44
|
*/
|
|
45
45
|
detectReferences(resource: ResourceDescriptor$2, entityTypes: string[], includeDescriptiveReferences?: boolean): Promise<DetectedAnnotation[]>;
|
|
46
46
|
private processDetectionJob;
|
|
47
|
+
/**
|
|
48
|
+
* Emit completion event with result data
|
|
49
|
+
* Override base class to emit job.completed event with foundCount
|
|
50
|
+
*/
|
|
51
|
+
protected emitCompletionEvent(job: RunningJob<DetectionParams, DetectionProgress>, result: DetectionResult): Promise<void>;
|
|
47
52
|
protected handleJobFailure(job: AnyJob, error: any): Promise<void>;
|
|
48
53
|
/**
|
|
49
54
|
* Update job progress and emit events to Event Store
|
|
@@ -68,8 +73,13 @@ declare class GenerationWorker extends JobWorker {
|
|
|
68
73
|
constructor(jobQueue: JobQueue, config: EnvironmentConfig, eventStore: EventStore, inferenceClient: InferenceClient);
|
|
69
74
|
protected getWorkerName(): string;
|
|
70
75
|
protected canProcessJob(job: AnyJob): boolean;
|
|
71
|
-
protected executeJob(job: AnyJob): Promise<
|
|
76
|
+
protected executeJob(job: AnyJob): Promise<GenerationResult>;
|
|
72
77
|
private processGenerationJob;
|
|
78
|
+
/**
|
|
79
|
+
* Emit completion event with result data
|
|
80
|
+
* Override base class to emit job.completed event with resultResourceId
|
|
81
|
+
*/
|
|
82
|
+
protected emitCompletionEvent(job: RunningJob<GenerationParams, GenerationProgress>, result: GenerationResult): Promise<void>;
|
|
73
83
|
/**
|
|
74
84
|
* Update job progress and emit events to Event Store
|
|
75
85
|
* Overrides base class to also emit job progress events
|
|
@@ -92,7 +102,12 @@ declare class HighlightDetectionWorker extends JobWorker {
|
|
|
92
102
|
constructor(jobQueue: JobQueue, config: EnvironmentConfig, eventStore: EventStore, inferenceClient: InferenceClient);
|
|
93
103
|
protected getWorkerName(): string;
|
|
94
104
|
protected canProcessJob(job: AnyJob): boolean;
|
|
95
|
-
protected executeJob(job: AnyJob): Promise<
|
|
105
|
+
protected executeJob(job: AnyJob): Promise<HighlightDetectionResult>;
|
|
106
|
+
/**
|
|
107
|
+
* Emit completion event with result data
|
|
108
|
+
* Override base class to emit job.completed event
|
|
109
|
+
*/
|
|
110
|
+
protected emitCompletionEvent(job: RunningJob<HighlightDetectionParams, HighlightDetectionProgress>, _result: HighlightDetectionResult): Promise<void>;
|
|
96
111
|
/**
|
|
97
112
|
* Override updateJobProgress to emit events to Event Store
|
|
98
113
|
*/
|
|
@@ -117,7 +132,12 @@ declare class AssessmentDetectionWorker extends JobWorker {
|
|
|
117
132
|
constructor(jobQueue: JobQueue, config: EnvironmentConfig, eventStore: EventStore, inferenceClient: InferenceClient);
|
|
118
133
|
protected getWorkerName(): string;
|
|
119
134
|
protected canProcessJob(job: AnyJob): boolean;
|
|
120
|
-
protected executeJob(job: AnyJob): Promise<
|
|
135
|
+
protected executeJob(job: AnyJob): Promise<AssessmentDetectionResult>;
|
|
136
|
+
/**
|
|
137
|
+
* Emit completion event with result data
|
|
138
|
+
* Override base class to emit job.completed event
|
|
139
|
+
*/
|
|
140
|
+
protected emitCompletionEvent(job: RunningJob<AssessmentDetectionParams, AssessmentDetectionProgress>, _result: AssessmentDetectionResult): Promise<void>;
|
|
121
141
|
/**
|
|
122
142
|
* Override updateJobProgress to emit events to Event Store
|
|
123
143
|
*/
|
|
@@ -142,7 +162,12 @@ declare class CommentDetectionWorker extends JobWorker {
|
|
|
142
162
|
constructor(jobQueue: JobQueue, config: EnvironmentConfig, eventStore: EventStore, inferenceClient: InferenceClient);
|
|
143
163
|
protected getWorkerName(): string;
|
|
144
164
|
protected canProcessJob(job: AnyJob): boolean;
|
|
145
|
-
protected executeJob(job: AnyJob): Promise<
|
|
165
|
+
protected executeJob(job: AnyJob): Promise<CommentDetectionResult>;
|
|
166
|
+
/**
|
|
167
|
+
* Emit completion event with result data
|
|
168
|
+
* Override base class to emit job.completed event
|
|
169
|
+
*/
|
|
170
|
+
protected emitCompletionEvent(job: RunningJob<CommentDetectionParams, CommentDetectionProgress>, _result: CommentDetectionResult): Promise<void>;
|
|
146
171
|
/**
|
|
147
172
|
* Override updateJobProgress to emit events to Event Store
|
|
148
173
|
*/
|
|
@@ -168,7 +193,12 @@ declare class TagDetectionWorker extends JobWorker {
|
|
|
168
193
|
constructor(jobQueue: JobQueue, config: EnvironmentConfig, eventStore: EventStore, inferenceClient: InferenceClient);
|
|
169
194
|
protected getWorkerName(): string;
|
|
170
195
|
protected canProcessJob(job: AnyJob): boolean;
|
|
171
|
-
protected executeJob(job: AnyJob): Promise<
|
|
196
|
+
protected executeJob(job: AnyJob): Promise<TagDetectionResult>;
|
|
197
|
+
/**
|
|
198
|
+
* Emit completion event with result data
|
|
199
|
+
* Override base class to emit job.completed event
|
|
200
|
+
*/
|
|
201
|
+
protected emitCompletionEvent(job: RunningJob<TagDetectionParams, TagDetectionProgress>, _result: TagDetectionResult): Promise<void>;
|
|
172
202
|
/**
|
|
173
203
|
* Override updateJobProgress to emit events to Event Store
|
|
174
204
|
*/
|
package/dist/index.js
CHANGED
|
@@ -219,7 +219,7 @@ var ReferenceDetectionWorker = class extends JobWorker {
|
|
|
219
219
|
if (job.status !== "running") {
|
|
220
220
|
throw new Error(`Job must be in running state to execute, got: ${job.status}`);
|
|
221
221
|
}
|
|
222
|
-
await this.processDetectionJob(job);
|
|
222
|
+
return await this.processDetectionJob(job);
|
|
223
223
|
}
|
|
224
224
|
/**
|
|
225
225
|
* Detect entity references in resource using AI
|
|
@@ -375,6 +375,28 @@ var ReferenceDetectionWorker = class extends JobWorker {
|
|
|
375
375
|
await this.updateJobProgress(updatedJob);
|
|
376
376
|
}
|
|
377
377
|
console.log(`[ReferenceDetectionWorker] \u2705 Detection complete: ${totalFound} entities found, ${totalEmitted} events emitted, ${totalErrors} errors`);
|
|
378
|
+
return {
|
|
379
|
+
totalFound,
|
|
380
|
+
totalEmitted,
|
|
381
|
+
errors: totalErrors
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Emit completion event with result data
|
|
386
|
+
* Override base class to emit job.completed event with foundCount
|
|
387
|
+
*/
|
|
388
|
+
async emitCompletionEvent(job, result) {
|
|
389
|
+
await this.eventStore.appendEvent({
|
|
390
|
+
type: "job.completed",
|
|
391
|
+
resourceId: job.params.resourceId,
|
|
392
|
+
userId: job.metadata.userId,
|
|
393
|
+
version: 1,
|
|
394
|
+
payload: {
|
|
395
|
+
jobId: job.metadata.id,
|
|
396
|
+
jobType: "detection",
|
|
397
|
+
foundCount: result.totalFound
|
|
398
|
+
}
|
|
399
|
+
});
|
|
378
400
|
}
|
|
379
401
|
async handleJobFailure(job, error) {
|
|
380
402
|
await super.handleJobFailure(job, error);
|
|
@@ -412,7 +434,6 @@ var ReferenceDetectionWorker = class extends JobWorker {
|
|
|
412
434
|
version: 1
|
|
413
435
|
};
|
|
414
436
|
const isFirstUpdate = detJob.progress.processedEntityTypes === 0;
|
|
415
|
-
const isFinalUpdate = detJob.progress.processedEntityTypes === detJob.progress.totalEntityTypes && detJob.progress.totalEntityTypes > 0;
|
|
416
437
|
if (isFirstUpdate) {
|
|
417
438
|
await this.eventStore.appendEvent({
|
|
418
439
|
type: "job.started",
|
|
@@ -423,16 +444,6 @@ var ReferenceDetectionWorker = class extends JobWorker {
|
|
|
423
444
|
totalSteps: detJob.params.entityTypes.length
|
|
424
445
|
}
|
|
425
446
|
});
|
|
426
|
-
} else if (isFinalUpdate) {
|
|
427
|
-
await this.eventStore.appendEvent({
|
|
428
|
-
type: "job.completed",
|
|
429
|
-
...baseEvent,
|
|
430
|
-
payload: {
|
|
431
|
-
jobId: detJob.metadata.id,
|
|
432
|
-
jobType: detJob.metadata.type,
|
|
433
|
-
foundCount: detJob.progress.entitiesFound
|
|
434
|
-
}
|
|
435
|
-
});
|
|
436
447
|
} else {
|
|
437
448
|
const percentage = Math.round(detJob.progress.processedEntityTypes / detJob.progress.totalEntityTypes * 100);
|
|
438
449
|
await this.eventStore.appendEvent({
|
|
@@ -588,7 +599,7 @@ var GenerationWorker = class extends JobWorker2 {
|
|
|
588
599
|
if (job.status !== "running") {
|
|
589
600
|
throw new Error(`Job must be in running state to execute, got: ${job.status}`);
|
|
590
601
|
}
|
|
591
|
-
await this.processGenerationJob(job);
|
|
602
|
+
return await this.processGenerationJob(job);
|
|
592
603
|
}
|
|
593
604
|
async processGenerationJob(job) {
|
|
594
605
|
console.log(`[GenerationWorker] Processing generation for reference ${job.params.referenceId} (job: ${job.metadata.id})`);
|
|
@@ -705,9 +716,7 @@ var GenerationWorker = class extends JobWorker2 {
|
|
|
705
716
|
progress: {
|
|
706
717
|
stage: "linking",
|
|
707
718
|
percentage: 95,
|
|
708
|
-
message: "Linking reference..."
|
|
709
|
-
resultResourceId: rId
|
|
710
|
-
// Store for job.completed event
|
|
719
|
+
message: "Linking reference..."
|
|
711
720
|
}
|
|
712
721
|
};
|
|
713
722
|
console.log(`[GenerationWorker] \u{1F517} ${updatedJob.progress.message}`);
|
|
@@ -738,13 +747,33 @@ var GenerationWorker = class extends JobWorker2 {
|
|
|
738
747
|
progress: {
|
|
739
748
|
stage: "linking",
|
|
740
749
|
percentage: 100,
|
|
741
|
-
message: "Complete!"
|
|
742
|
-
resultResourceId: rId
|
|
743
|
-
// Store for job.completed event
|
|
750
|
+
message: "Complete!"
|
|
744
751
|
}
|
|
745
752
|
};
|
|
746
753
|
await this.updateJobProgress(updatedJob);
|
|
747
754
|
console.log(`[GenerationWorker] \u2705 Generation complete: created resource ${rId}`);
|
|
755
|
+
return {
|
|
756
|
+
resourceId: rId,
|
|
757
|
+
resourceName
|
|
758
|
+
};
|
|
759
|
+
}
|
|
760
|
+
/**
|
|
761
|
+
* Emit completion event with result data
|
|
762
|
+
* Override base class to emit job.completed event with resultResourceId
|
|
763
|
+
*/
|
|
764
|
+
async emitCompletionEvent(job, result) {
|
|
765
|
+
await this.eventStore.appendEvent({
|
|
766
|
+
type: "job.completed",
|
|
767
|
+
resourceId: job.params.sourceResourceId,
|
|
768
|
+
userId: job.metadata.userId,
|
|
769
|
+
version: 1,
|
|
770
|
+
payload: {
|
|
771
|
+
jobId: job.metadata.id,
|
|
772
|
+
jobType: "generation",
|
|
773
|
+
resultResourceId: result.resourceId,
|
|
774
|
+
annotationUri: annotationUri(`${this.config.services.backend.publicURL}/annotations/${job.params.referenceId}`)
|
|
775
|
+
}
|
|
776
|
+
});
|
|
748
777
|
}
|
|
749
778
|
/**
|
|
750
779
|
* Update job progress and emit events to Event Store
|
|
@@ -775,17 +804,6 @@ var GenerationWorker = class extends JobWorker2 {
|
|
|
775
804
|
// fetching, generating, creating, linking, complete
|
|
776
805
|
}
|
|
777
806
|
});
|
|
778
|
-
} else if (genJob.progress.stage === "linking" && genJob.progress.percentage === 100) {
|
|
779
|
-
await this.eventStore.appendEvent({
|
|
780
|
-
type: "job.completed",
|
|
781
|
-
...baseEvent,
|
|
782
|
-
payload: {
|
|
783
|
-
jobId: genJob.metadata.id,
|
|
784
|
-
jobType: genJob.metadata.type,
|
|
785
|
-
resultResourceId: genJob.progress.resultResourceId,
|
|
786
|
-
annotationUri: annotationUri(`${this.config.services.backend.publicURL}/annotations/${genJob.params.referenceId}`)
|
|
787
|
-
}
|
|
788
|
-
});
|
|
789
807
|
} else {
|
|
790
808
|
await this.eventStore.appendEvent({
|
|
791
809
|
type: "job.progress",
|
|
@@ -829,7 +847,23 @@ var HighlightDetectionWorker = class extends JobWorker3 {
|
|
|
829
847
|
throw new Error(`Job must be in running state to execute, got: ${job.status}`);
|
|
830
848
|
}
|
|
831
849
|
this.isFirstProgress = true;
|
|
832
|
-
await this.processHighlightDetectionJob(job);
|
|
850
|
+
return await this.processHighlightDetectionJob(job);
|
|
851
|
+
}
|
|
852
|
+
/**
|
|
853
|
+
* Emit completion event with result data
|
|
854
|
+
* Override base class to emit job.completed event
|
|
855
|
+
*/
|
|
856
|
+
async emitCompletionEvent(job, _result) {
|
|
857
|
+
await this.eventStore.appendEvent({
|
|
858
|
+
type: "job.completed",
|
|
859
|
+
resourceId: job.params.resourceId,
|
|
860
|
+
userId: job.metadata.userId,
|
|
861
|
+
version: 1,
|
|
862
|
+
payload: {
|
|
863
|
+
jobId: job.metadata.id,
|
|
864
|
+
jobType: "highlight-detection"
|
|
865
|
+
}
|
|
866
|
+
});
|
|
833
867
|
}
|
|
834
868
|
/**
|
|
835
869
|
* Override updateJobProgress to emit events to Event Store
|
|
@@ -846,7 +880,6 @@ var HighlightDetectionWorker = class extends JobWorker3 {
|
|
|
846
880
|
userId: hlJob.metadata.userId,
|
|
847
881
|
version: 1
|
|
848
882
|
};
|
|
849
|
-
const isComplete = hlJob.progress.percentage === 100;
|
|
850
883
|
if (this.isFirstProgress) {
|
|
851
884
|
this.isFirstProgress = false;
|
|
852
885
|
await this.eventStore.appendEvent({
|
|
@@ -857,16 +890,6 @@ var HighlightDetectionWorker = class extends JobWorker3 {
|
|
|
857
890
|
jobType: hlJob.metadata.type
|
|
858
891
|
}
|
|
859
892
|
});
|
|
860
|
-
} else if (isComplete) {
|
|
861
|
-
await this.eventStore.appendEvent({
|
|
862
|
-
type: "job.completed",
|
|
863
|
-
...baseEvent,
|
|
864
|
-
payload: {
|
|
865
|
-
jobId: hlJob.metadata.id,
|
|
866
|
-
jobType: hlJob.metadata.type
|
|
867
|
-
// Note: result would come from job.result, but that's handled by base class
|
|
868
|
-
}
|
|
869
|
-
});
|
|
870
893
|
} else {
|
|
871
894
|
await this.eventStore.appendEvent({
|
|
872
895
|
type: "job.progress",
|
|
@@ -956,6 +979,10 @@ var HighlightDetectionWorker = class extends JobWorker3 {
|
|
|
956
979
|
};
|
|
957
980
|
await this.updateJobProgress(updatedJob);
|
|
958
981
|
console.log(`[HighlightDetectionWorker] \u2705 Created ${created}/${highlights.length} highlights`);
|
|
982
|
+
return {
|
|
983
|
+
highlightsFound: highlights.length,
|
|
984
|
+
highlightsCreated: created
|
|
985
|
+
};
|
|
959
986
|
}
|
|
960
987
|
async createHighlightAnnotation(resourceId2, creatorUserId, highlight) {
|
|
961
988
|
const backendUrl = this.config.services.backend?.publicURL;
|
|
@@ -1026,7 +1053,23 @@ var AssessmentDetectionWorker = class extends JobWorker4 {
|
|
|
1026
1053
|
throw new Error(`Job must be in running state to execute, got: ${job.status}`);
|
|
1027
1054
|
}
|
|
1028
1055
|
this.isFirstProgress = true;
|
|
1029
|
-
await this.processAssessmentDetectionJob(job);
|
|
1056
|
+
return await this.processAssessmentDetectionJob(job);
|
|
1057
|
+
}
|
|
1058
|
+
/**
|
|
1059
|
+
* Emit completion event with result data
|
|
1060
|
+
* Override base class to emit job.completed event
|
|
1061
|
+
*/
|
|
1062
|
+
async emitCompletionEvent(job, _result) {
|
|
1063
|
+
await this.eventStore.appendEvent({
|
|
1064
|
+
type: "job.completed",
|
|
1065
|
+
resourceId: job.params.resourceId,
|
|
1066
|
+
userId: job.metadata.userId,
|
|
1067
|
+
version: 1,
|
|
1068
|
+
payload: {
|
|
1069
|
+
jobId: job.metadata.id,
|
|
1070
|
+
jobType: "assessment-detection"
|
|
1071
|
+
}
|
|
1072
|
+
});
|
|
1030
1073
|
}
|
|
1031
1074
|
/**
|
|
1032
1075
|
* Override updateJobProgress to emit events to Event Store
|
|
@@ -1043,7 +1086,6 @@ var AssessmentDetectionWorker = class extends JobWorker4 {
|
|
|
1043
1086
|
userId: assJob.metadata.userId,
|
|
1044
1087
|
version: 1
|
|
1045
1088
|
};
|
|
1046
|
-
const isComplete = assJob.progress.percentage === 100;
|
|
1047
1089
|
if (this.isFirstProgress) {
|
|
1048
1090
|
this.isFirstProgress = false;
|
|
1049
1091
|
await this.eventStore.appendEvent({
|
|
@@ -1054,16 +1096,6 @@ var AssessmentDetectionWorker = class extends JobWorker4 {
|
|
|
1054
1096
|
jobType: assJob.metadata.type
|
|
1055
1097
|
}
|
|
1056
1098
|
});
|
|
1057
|
-
} else if (isComplete) {
|
|
1058
|
-
await this.eventStore.appendEvent({
|
|
1059
|
-
type: "job.completed",
|
|
1060
|
-
...baseEvent,
|
|
1061
|
-
payload: {
|
|
1062
|
-
jobId: assJob.metadata.id,
|
|
1063
|
-
jobType: assJob.metadata.type
|
|
1064
|
-
// Note: result would come from job.result, but that's handled by base class
|
|
1065
|
-
}
|
|
1066
|
-
});
|
|
1067
1099
|
} else {
|
|
1068
1100
|
await this.eventStore.appendEvent({
|
|
1069
1101
|
type: "job.progress",
|
|
@@ -1154,6 +1186,10 @@ var AssessmentDetectionWorker = class extends JobWorker4 {
|
|
|
1154
1186
|
};
|
|
1155
1187
|
await this.updateJobProgress(updatedJob);
|
|
1156
1188
|
console.log(`[AssessmentDetectionWorker] \u2705 Created ${created}/${assessments.length} assessments`);
|
|
1189
|
+
return {
|
|
1190
|
+
assessmentsFound: assessments.length,
|
|
1191
|
+
assessmentsCreated: created
|
|
1192
|
+
};
|
|
1157
1193
|
}
|
|
1158
1194
|
async createAssessmentAnnotation(resourceId2, creatorUserId, assessment) {
|
|
1159
1195
|
const backendUrl = this.config.services.backend?.publicURL;
|
|
@@ -1227,7 +1263,23 @@ var CommentDetectionWorker = class extends JobWorker5 {
|
|
|
1227
1263
|
throw new Error(`Job must be in running state to execute, got: ${job.status}`);
|
|
1228
1264
|
}
|
|
1229
1265
|
this.isFirstProgress = true;
|
|
1230
|
-
await this.processCommentDetectionJob(job);
|
|
1266
|
+
return await this.processCommentDetectionJob(job);
|
|
1267
|
+
}
|
|
1268
|
+
/**
|
|
1269
|
+
* Emit completion event with result data
|
|
1270
|
+
* Override base class to emit job.completed event
|
|
1271
|
+
*/
|
|
1272
|
+
async emitCompletionEvent(job, _result) {
|
|
1273
|
+
await this.eventStore.appendEvent({
|
|
1274
|
+
type: "job.completed",
|
|
1275
|
+
resourceId: job.params.resourceId,
|
|
1276
|
+
userId: job.metadata.userId,
|
|
1277
|
+
version: 1,
|
|
1278
|
+
payload: {
|
|
1279
|
+
jobId: job.metadata.id,
|
|
1280
|
+
jobType: "comment-detection"
|
|
1281
|
+
}
|
|
1282
|
+
});
|
|
1231
1283
|
}
|
|
1232
1284
|
/**
|
|
1233
1285
|
* Override updateJobProgress to emit events to Event Store
|
|
@@ -1244,7 +1296,6 @@ var CommentDetectionWorker = class extends JobWorker5 {
|
|
|
1244
1296
|
userId: cdJob.metadata.userId,
|
|
1245
1297
|
version: 1
|
|
1246
1298
|
};
|
|
1247
|
-
const isComplete = cdJob.progress.percentage === 100;
|
|
1248
1299
|
if (this.isFirstProgress) {
|
|
1249
1300
|
this.isFirstProgress = false;
|
|
1250
1301
|
await this.eventStore.appendEvent({
|
|
@@ -1255,16 +1306,6 @@ var CommentDetectionWorker = class extends JobWorker5 {
|
|
|
1255
1306
|
jobType: cdJob.metadata.type
|
|
1256
1307
|
}
|
|
1257
1308
|
});
|
|
1258
|
-
} else if (isComplete) {
|
|
1259
|
-
await this.eventStore.appendEvent({
|
|
1260
|
-
type: "job.completed",
|
|
1261
|
-
...baseEvent,
|
|
1262
|
-
payload: {
|
|
1263
|
-
jobId: cdJob.metadata.id,
|
|
1264
|
-
jobType: cdJob.metadata.type
|
|
1265
|
-
// Note: result would come from job.result, but that's handled by base class
|
|
1266
|
-
}
|
|
1267
|
-
});
|
|
1268
1309
|
} else {
|
|
1269
1310
|
await this.eventStore.appendEvent({
|
|
1270
1311
|
type: "job.progress",
|
|
@@ -1355,6 +1396,10 @@ var CommentDetectionWorker = class extends JobWorker5 {
|
|
|
1355
1396
|
};
|
|
1356
1397
|
await this.updateJobProgress(updatedJob);
|
|
1357
1398
|
console.log(`[CommentDetectionWorker] \u2705 Created ${created}/${comments.length} comments`);
|
|
1399
|
+
return {
|
|
1400
|
+
commentsFound: comments.length,
|
|
1401
|
+
commentsCreated: created
|
|
1402
|
+
};
|
|
1358
1403
|
}
|
|
1359
1404
|
async createCommentAnnotation(resourceId2, userId_, comment) {
|
|
1360
1405
|
const backendUrl = this.config.services.backend?.publicURL;
|
|
@@ -1436,7 +1481,23 @@ var TagDetectionWorker = class extends JobWorker6 {
|
|
|
1436
1481
|
throw new Error(`Job must be in running state to execute, got: ${job.status}`);
|
|
1437
1482
|
}
|
|
1438
1483
|
this.isFirstProgress = true;
|
|
1439
|
-
await this.processTagDetectionJob(job);
|
|
1484
|
+
return await this.processTagDetectionJob(job);
|
|
1485
|
+
}
|
|
1486
|
+
/**
|
|
1487
|
+
* Emit completion event with result data
|
|
1488
|
+
* Override base class to emit job.completed event
|
|
1489
|
+
*/
|
|
1490
|
+
async emitCompletionEvent(job, _result) {
|
|
1491
|
+
await this.eventStore.appendEvent({
|
|
1492
|
+
type: "job.completed",
|
|
1493
|
+
resourceId: job.params.resourceId,
|
|
1494
|
+
userId: job.metadata.userId,
|
|
1495
|
+
version: 1,
|
|
1496
|
+
payload: {
|
|
1497
|
+
jobId: job.metadata.id,
|
|
1498
|
+
jobType: "tag-detection"
|
|
1499
|
+
}
|
|
1500
|
+
});
|
|
1440
1501
|
}
|
|
1441
1502
|
/**
|
|
1442
1503
|
* Override updateJobProgress to emit events to Event Store
|
|
@@ -1453,7 +1514,6 @@ var TagDetectionWorker = class extends JobWorker6 {
|
|
|
1453
1514
|
userId: tdJob.metadata.userId,
|
|
1454
1515
|
version: 1
|
|
1455
1516
|
};
|
|
1456
|
-
const isComplete = tdJob.progress.percentage === 100;
|
|
1457
1517
|
if (this.isFirstProgress) {
|
|
1458
1518
|
this.isFirstProgress = false;
|
|
1459
1519
|
await this.eventStore.appendEvent({
|
|
@@ -1464,16 +1524,6 @@ var TagDetectionWorker = class extends JobWorker6 {
|
|
|
1464
1524
|
jobType: tdJob.metadata.type
|
|
1465
1525
|
}
|
|
1466
1526
|
});
|
|
1467
|
-
} else if (isComplete) {
|
|
1468
|
-
await this.eventStore.appendEvent({
|
|
1469
|
-
type: "job.completed",
|
|
1470
|
-
...baseEvent,
|
|
1471
|
-
payload: {
|
|
1472
|
-
jobId: tdJob.metadata.id,
|
|
1473
|
-
jobType: tdJob.metadata.type
|
|
1474
|
-
// Note: result would come from job.result, but that's handled by base class
|
|
1475
|
-
}
|
|
1476
|
-
});
|
|
1477
1527
|
} else {
|
|
1478
1528
|
await this.eventStore.appendEvent({
|
|
1479
1529
|
type: "job.progress",
|
|
@@ -1588,6 +1638,11 @@ var TagDetectionWorker = class extends JobWorker6 {
|
|
|
1588
1638
|
};
|
|
1589
1639
|
await this.updateJobProgress(updatedJob);
|
|
1590
1640
|
console.log(`[TagDetectionWorker] \u2705 Created ${created}/${allTags.length} tags across ${job.params.categories.length} categories`);
|
|
1641
|
+
return {
|
|
1642
|
+
tagsFound: allTags.length,
|
|
1643
|
+
tagsCreated: created,
|
|
1644
|
+
byCategory
|
|
1645
|
+
};
|
|
1591
1646
|
}
|
|
1592
1647
|
async createTagAnnotation(resourceId2, userId_, schemaId, tag) {
|
|
1593
1648
|
const backendUrl = this.config.services.backend?.publicURL;
|