@okf/ootils 1.16.0 → 1.17.1
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/node.d.mts +4 -0
- package/dist/node.d.ts +4 -0
- package/dist/node.js +28 -0
- package/dist/node.mjs +28 -0
- package/package.json +1 -1
package/dist/node.d.mts
CHANGED
|
@@ -1180,6 +1180,10 @@ declare class BaseProducer {
|
|
|
1180
1180
|
execute(params: any): Promise<void>;
|
|
1181
1181
|
addBulkJobs(jobs: any): Promise<bullmq.Job<any, any, string>[]>;
|
|
1182
1182
|
addJob(name: any, data: any, opts?: {}): Promise<bullmq.Job<any, any, string>>;
|
|
1183
|
+
removeJobs(jobIds: any): Promise<{
|
|
1184
|
+
removed: number;
|
|
1185
|
+
results: any[];
|
|
1186
|
+
}>;
|
|
1183
1187
|
getStatus(): Promise<{
|
|
1184
1188
|
waiting: number;
|
|
1185
1189
|
active: number;
|
package/dist/node.d.ts
CHANGED
|
@@ -1180,6 +1180,10 @@ declare class BaseProducer {
|
|
|
1180
1180
|
execute(params: any): Promise<void>;
|
|
1181
1181
|
addBulkJobs(jobs: any): Promise<bullmq.Job<any, any, string>[]>;
|
|
1182
1182
|
addJob(name: any, data: any, opts?: {}): Promise<bullmq.Job<any, any, string>>;
|
|
1183
|
+
removeJobs(jobIds: any): Promise<{
|
|
1184
|
+
removed: number;
|
|
1185
|
+
results: any[];
|
|
1186
|
+
}>;
|
|
1183
1187
|
getStatus(): Promise<{
|
|
1184
1188
|
waiting: number;
|
|
1185
1189
|
active: number;
|
package/dist/node.js
CHANGED
|
@@ -432,6 +432,7 @@ var init_Annotations = __esm({
|
|
|
432
432
|
AnnotationSchema.index({ createdAt: -1 });
|
|
433
433
|
AnnotationSchema.index({ "annotations.annoKey": 1 });
|
|
434
434
|
AnnotationSchema.index({ "kp_date_published": -1 });
|
|
435
|
+
AnnotationSchema.index({ "meta.contentType": 1, "meta.valuePath": 1, topicId: 1 });
|
|
435
436
|
AnnotationSchema.pre("save", function(next) {
|
|
436
437
|
this.updatedAt = /* @__PURE__ */ new Date();
|
|
437
438
|
next();
|
|
@@ -1328,6 +1329,33 @@ var require_BaseProducer = __commonJS({
|
|
|
1328
1329
|
throw error;
|
|
1329
1330
|
}
|
|
1330
1331
|
}
|
|
1332
|
+
async removeJobs(jobIds) {
|
|
1333
|
+
if (!jobIds || jobIds.length === 0) {
|
|
1334
|
+
return { removed: 0, results: [] };
|
|
1335
|
+
}
|
|
1336
|
+
try {
|
|
1337
|
+
const results = await Promise.all(
|
|
1338
|
+
jobIds.map(async (jobId) => {
|
|
1339
|
+
try {
|
|
1340
|
+
const job = await this.queue.getJob(jobId);
|
|
1341
|
+
if (job) {
|
|
1342
|
+
await job.remove();
|
|
1343
|
+
return { jobId, removed: true };
|
|
1344
|
+
}
|
|
1345
|
+
return { jobId, removed: false, reason: "not found" };
|
|
1346
|
+
} catch (err) {
|
|
1347
|
+
return { jobId, removed: false, reason: err.message };
|
|
1348
|
+
}
|
|
1349
|
+
})
|
|
1350
|
+
);
|
|
1351
|
+
const removedCount = results.filter((r) => r.removed).length;
|
|
1352
|
+
console.log(`\u{1F5D1}\uFE0F ${this.constructor.name}: Removed ${removedCount}/${jobIds.length} jobs`);
|
|
1353
|
+
return { removed: removedCount, results };
|
|
1354
|
+
} catch (error) {
|
|
1355
|
+
console.error(`\u274C ${this.constructor.name}: Failed to remove jobs:`, error);
|
|
1356
|
+
throw error;
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1331
1359
|
async getStatus() {
|
|
1332
1360
|
const waiting = await this.queue.getWaiting();
|
|
1333
1361
|
const active = await this.queue.getActive();
|
package/dist/node.mjs
CHANGED
|
@@ -437,6 +437,7 @@ var init_Annotations = __esm({
|
|
|
437
437
|
AnnotationSchema.index({ createdAt: -1 });
|
|
438
438
|
AnnotationSchema.index({ "annotations.annoKey": 1 });
|
|
439
439
|
AnnotationSchema.index({ "kp_date_published": -1 });
|
|
440
|
+
AnnotationSchema.index({ "meta.contentType": 1, "meta.valuePath": 1, topicId: 1 });
|
|
440
441
|
AnnotationSchema.pre("save", function(next) {
|
|
441
442
|
this.updatedAt = /* @__PURE__ */ new Date();
|
|
442
443
|
next();
|
|
@@ -1333,6 +1334,33 @@ var require_BaseProducer = __commonJS({
|
|
|
1333
1334
|
throw error;
|
|
1334
1335
|
}
|
|
1335
1336
|
}
|
|
1337
|
+
async removeJobs(jobIds) {
|
|
1338
|
+
if (!jobIds || jobIds.length === 0) {
|
|
1339
|
+
return { removed: 0, results: [] };
|
|
1340
|
+
}
|
|
1341
|
+
try {
|
|
1342
|
+
const results = await Promise.all(
|
|
1343
|
+
jobIds.map(async (jobId) => {
|
|
1344
|
+
try {
|
|
1345
|
+
const job = await this.queue.getJob(jobId);
|
|
1346
|
+
if (job) {
|
|
1347
|
+
await job.remove();
|
|
1348
|
+
return { jobId, removed: true };
|
|
1349
|
+
}
|
|
1350
|
+
return { jobId, removed: false, reason: "not found" };
|
|
1351
|
+
} catch (err) {
|
|
1352
|
+
return { jobId, removed: false, reason: err.message };
|
|
1353
|
+
}
|
|
1354
|
+
})
|
|
1355
|
+
);
|
|
1356
|
+
const removedCount = results.filter((r) => r.removed).length;
|
|
1357
|
+
console.log(`\u{1F5D1}\uFE0F ${this.constructor.name}: Removed ${removedCount}/${jobIds.length} jobs`);
|
|
1358
|
+
return { removed: removedCount, results };
|
|
1359
|
+
} catch (error) {
|
|
1360
|
+
console.error(`\u274C ${this.constructor.name}: Failed to remove jobs:`, error);
|
|
1361
|
+
throw error;
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1336
1364
|
async getStatus() {
|
|
1337
1365
|
const waiting = await this.queue.getWaiting();
|
|
1338
1366
|
const active = await this.queue.getActive();
|