@okf/ootils 1.3.7 → 1.3.8
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 +94 -1
- package/dist/node.d.ts +94 -1
- package/dist/node.js +321 -0
- package/dist/node.mjs +355 -0
- package/package.json +2 -1
package/dist/node.d.mts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import mongoose, { Connection, Document, Schema, Model, Types } from 'mongoose';
|
|
2
2
|
import IORedis from 'ioredis';
|
|
3
|
+
import * as bullmq from 'bullmq';
|
|
4
|
+
import { Queue } from 'bullmq/dist/esm/classes/queue';
|
|
5
|
+
import { Worker } from 'bullmq/dist/esm/classes/worker';
|
|
3
6
|
|
|
4
7
|
declare const deleteVal: (data: any, valuePath: string) => any;
|
|
5
8
|
|
|
@@ -496,4 +499,94 @@ declare const TplSchema: mongoose.Schema<ITplDocument, mongoose.Model<ITplDocume
|
|
|
496
499
|
__v: number;
|
|
497
500
|
}>;
|
|
498
501
|
|
|
499
|
-
|
|
502
|
+
declare class WorkerManager {
|
|
503
|
+
constructor(workers?: any[]);
|
|
504
|
+
workers: any[];
|
|
505
|
+
activeWorkers: any[];
|
|
506
|
+
startAllWorkers(): any[];
|
|
507
|
+
shutdown(): Promise<void>;
|
|
508
|
+
getStatus(): {
|
|
509
|
+
name: any;
|
|
510
|
+
queueId: any;
|
|
511
|
+
isActive: boolean;
|
|
512
|
+
}[];
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
declare class BaseProducer {
|
|
516
|
+
constructor(config: any);
|
|
517
|
+
config: any;
|
|
518
|
+
queue: Queue<any, any, string, any, any, string>;
|
|
519
|
+
execute(params: any): Promise<void>;
|
|
520
|
+
addBulkJobs(jobs: any): Promise<bullmq.Job<any, any, string>[]>;
|
|
521
|
+
addJob(name: any, data: any, opts?: {}): Promise<bullmq.Job<any, any, string>>;
|
|
522
|
+
getStatus(): Promise<{
|
|
523
|
+
waiting: number;
|
|
524
|
+
active: number;
|
|
525
|
+
completed: number;
|
|
526
|
+
failed: number;
|
|
527
|
+
total: number;
|
|
528
|
+
}>;
|
|
529
|
+
getJobDetails(limit?: number): Promise<{
|
|
530
|
+
waiting: {
|
|
531
|
+
id: any;
|
|
532
|
+
batchIndex: any;
|
|
533
|
+
totalBatches: any;
|
|
534
|
+
rawRecordsCount: any;
|
|
535
|
+
}[];
|
|
536
|
+
active: {
|
|
537
|
+
id: any;
|
|
538
|
+
batchIndex: any;
|
|
539
|
+
totalBatches: any;
|
|
540
|
+
progress: any;
|
|
541
|
+
rawRecordsCount: any;
|
|
542
|
+
}[];
|
|
543
|
+
completed: {
|
|
544
|
+
id: any;
|
|
545
|
+
batchIndex: any;
|
|
546
|
+
totalProcessed: any;
|
|
547
|
+
summary: any;
|
|
548
|
+
}[];
|
|
549
|
+
failed: {
|
|
550
|
+
id: any;
|
|
551
|
+
batchIndex: any;
|
|
552
|
+
error: any;
|
|
553
|
+
attempts: any;
|
|
554
|
+
}[];
|
|
555
|
+
}>;
|
|
556
|
+
stop(): Promise<void>;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
declare class BaseWorker {
|
|
560
|
+
constructor(config: any);
|
|
561
|
+
config: any;
|
|
562
|
+
worker: Worker<any, void, string> | null;
|
|
563
|
+
execute(job: any): Promise<void>;
|
|
564
|
+
start(): Worker<any, void, string>;
|
|
565
|
+
setupEventHandlers(): void;
|
|
566
|
+
onCompleted(job: any, returnValue: any): void;
|
|
567
|
+
onFailed(job: any, err: any): void;
|
|
568
|
+
onProgress(job: any, progress: any): void;
|
|
569
|
+
onError(error: any): void;
|
|
570
|
+
stop(): Promise<void>;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* Creates BullMQ configuration with explicit dependencies
|
|
575
|
+
* @param {Object} params Configuration parameters
|
|
576
|
+
* @param {string} params.env Environment (staging, production, etc.)
|
|
577
|
+
* @param {Object} params.redisCredentials Redis connection details
|
|
578
|
+
* @param {string} params.redisCredentials.REDIS_HOST Redis host
|
|
579
|
+
* @param {number} params.redisCredentials.REDIS_PORT Redis port
|
|
580
|
+
* @param {string} params.redisCredentials.REDIS_PASSWORD Redis password
|
|
581
|
+
* @returns {Object} Complete BullMQ configuration
|
|
582
|
+
*/
|
|
583
|
+
declare function GET_GLOBAL_BULLMQ_CONFIG({ env, redisCredentials }: {
|
|
584
|
+
env: string;
|
|
585
|
+
redisCredentials: {
|
|
586
|
+
REDIS_HOST: string;
|
|
587
|
+
REDIS_PORT: number;
|
|
588
|
+
REDIS_PASSWORD: string;
|
|
589
|
+
};
|
|
590
|
+
}): Object;
|
|
591
|
+
|
|
592
|
+
export { AIChatSchema, AnnotationSchema, BaseProducer, BaseWorker, GET_GLOBAL_BULLMQ_CONFIG, PlatformConfigsSchema, TplSchema, WorkerManager, connectToRedis, deleteVal, extractAllBlocksFromTpl, genTagId, getAIChatModelByTenant, getAIConfigs, getAnnotationsModelByTenant, getDbByTenant, getModelByTenant, getPlatformConfigsModelByTenant, getRedisClient, getTpl, getTplModelByTenant, getVal, initializeGlobalConfig, multiConnectToMongoDB, _recursExtractBlocks as recursivelyExtractBlocks, setVal, toArray, updateGlobalConfig };
|
package/dist/node.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import mongoose, { Connection, Document, Schema, Model, Types } from 'mongoose';
|
|
2
2
|
import IORedis from 'ioredis';
|
|
3
|
+
import * as bullmq from 'bullmq';
|
|
4
|
+
import { Queue } from 'bullmq/dist/esm/classes/queue';
|
|
5
|
+
import { Worker } from 'bullmq/dist/esm/classes/worker';
|
|
3
6
|
|
|
4
7
|
declare const deleteVal: (data: any, valuePath: string) => any;
|
|
5
8
|
|
|
@@ -496,4 +499,94 @@ declare const TplSchema: mongoose.Schema<ITplDocument, mongoose.Model<ITplDocume
|
|
|
496
499
|
__v: number;
|
|
497
500
|
}>;
|
|
498
501
|
|
|
499
|
-
|
|
502
|
+
declare class WorkerManager {
|
|
503
|
+
constructor(workers?: any[]);
|
|
504
|
+
workers: any[];
|
|
505
|
+
activeWorkers: any[];
|
|
506
|
+
startAllWorkers(): any[];
|
|
507
|
+
shutdown(): Promise<void>;
|
|
508
|
+
getStatus(): {
|
|
509
|
+
name: any;
|
|
510
|
+
queueId: any;
|
|
511
|
+
isActive: boolean;
|
|
512
|
+
}[];
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
declare class BaseProducer {
|
|
516
|
+
constructor(config: any);
|
|
517
|
+
config: any;
|
|
518
|
+
queue: Queue<any, any, string, any, any, string>;
|
|
519
|
+
execute(params: any): Promise<void>;
|
|
520
|
+
addBulkJobs(jobs: any): Promise<bullmq.Job<any, any, string>[]>;
|
|
521
|
+
addJob(name: any, data: any, opts?: {}): Promise<bullmq.Job<any, any, string>>;
|
|
522
|
+
getStatus(): Promise<{
|
|
523
|
+
waiting: number;
|
|
524
|
+
active: number;
|
|
525
|
+
completed: number;
|
|
526
|
+
failed: number;
|
|
527
|
+
total: number;
|
|
528
|
+
}>;
|
|
529
|
+
getJobDetails(limit?: number): Promise<{
|
|
530
|
+
waiting: {
|
|
531
|
+
id: any;
|
|
532
|
+
batchIndex: any;
|
|
533
|
+
totalBatches: any;
|
|
534
|
+
rawRecordsCount: any;
|
|
535
|
+
}[];
|
|
536
|
+
active: {
|
|
537
|
+
id: any;
|
|
538
|
+
batchIndex: any;
|
|
539
|
+
totalBatches: any;
|
|
540
|
+
progress: any;
|
|
541
|
+
rawRecordsCount: any;
|
|
542
|
+
}[];
|
|
543
|
+
completed: {
|
|
544
|
+
id: any;
|
|
545
|
+
batchIndex: any;
|
|
546
|
+
totalProcessed: any;
|
|
547
|
+
summary: any;
|
|
548
|
+
}[];
|
|
549
|
+
failed: {
|
|
550
|
+
id: any;
|
|
551
|
+
batchIndex: any;
|
|
552
|
+
error: any;
|
|
553
|
+
attempts: any;
|
|
554
|
+
}[];
|
|
555
|
+
}>;
|
|
556
|
+
stop(): Promise<void>;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
declare class BaseWorker {
|
|
560
|
+
constructor(config: any);
|
|
561
|
+
config: any;
|
|
562
|
+
worker: Worker<any, void, string> | null;
|
|
563
|
+
execute(job: any): Promise<void>;
|
|
564
|
+
start(): Worker<any, void, string>;
|
|
565
|
+
setupEventHandlers(): void;
|
|
566
|
+
onCompleted(job: any, returnValue: any): void;
|
|
567
|
+
onFailed(job: any, err: any): void;
|
|
568
|
+
onProgress(job: any, progress: any): void;
|
|
569
|
+
onError(error: any): void;
|
|
570
|
+
stop(): Promise<void>;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* Creates BullMQ configuration with explicit dependencies
|
|
575
|
+
* @param {Object} params Configuration parameters
|
|
576
|
+
* @param {string} params.env Environment (staging, production, etc.)
|
|
577
|
+
* @param {Object} params.redisCredentials Redis connection details
|
|
578
|
+
* @param {string} params.redisCredentials.REDIS_HOST Redis host
|
|
579
|
+
* @param {number} params.redisCredentials.REDIS_PORT Redis port
|
|
580
|
+
* @param {string} params.redisCredentials.REDIS_PASSWORD Redis password
|
|
581
|
+
* @returns {Object} Complete BullMQ configuration
|
|
582
|
+
*/
|
|
583
|
+
declare function GET_GLOBAL_BULLMQ_CONFIG({ env, redisCredentials }: {
|
|
584
|
+
env: string;
|
|
585
|
+
redisCredentials: {
|
|
586
|
+
REDIS_HOST: string;
|
|
587
|
+
REDIS_PORT: number;
|
|
588
|
+
REDIS_PASSWORD: string;
|
|
589
|
+
};
|
|
590
|
+
}): Object;
|
|
591
|
+
|
|
592
|
+
export { AIChatSchema, AnnotationSchema, BaseProducer, BaseWorker, GET_GLOBAL_BULLMQ_CONFIG, PlatformConfigsSchema, TplSchema, WorkerManager, connectToRedis, deleteVal, extractAllBlocksFromTpl, genTagId, getAIChatModelByTenant, getAIConfigs, getAnnotationsModelByTenant, getDbByTenant, getModelByTenant, getPlatformConfigsModelByTenant, getRedisClient, getTpl, getTplModelByTenant, getVal, initializeGlobalConfig, multiConnectToMongoDB, _recursExtractBlocks as recursivelyExtractBlocks, setVal, toArray, updateGlobalConfig };
|
package/dist/node.js
CHANGED
|
@@ -5,6 +5,12 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __esm = (fn, res) => function __init() {
|
|
9
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
|
+
};
|
|
11
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
12
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
13
|
+
};
|
|
8
14
|
var __export = (target, all) => {
|
|
9
15
|
for (var name in all)
|
|
10
16
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -27,13 +33,318 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
33
|
));
|
|
28
34
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
35
|
|
|
36
|
+
// src/bullmq/WorkerManager.js
|
|
37
|
+
var require_WorkerManager = __commonJS({
|
|
38
|
+
"src/bullmq/WorkerManager.js"(exports2, module2) {
|
|
39
|
+
"use strict";
|
|
40
|
+
var WorkerManager2 = class {
|
|
41
|
+
constructor(workers = []) {
|
|
42
|
+
this.workers = workers;
|
|
43
|
+
this.activeWorkers = [];
|
|
44
|
+
}
|
|
45
|
+
startAllWorkers() {
|
|
46
|
+
if (this.workers.length === 0) {
|
|
47
|
+
console.log("No workers provided to start");
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
console.log("\u{1F680} Starting all workers...");
|
|
51
|
+
this.workers.forEach((WorkerClass) => {
|
|
52
|
+
try {
|
|
53
|
+
const workerInstance = new WorkerClass();
|
|
54
|
+
workerInstance.start();
|
|
55
|
+
this.activeWorkers.push({
|
|
56
|
+
name: WorkerClass.name,
|
|
57
|
+
instance: workerInstance
|
|
58
|
+
});
|
|
59
|
+
console.log(`\u2705 Started ${WorkerClass.name}`);
|
|
60
|
+
} catch (error) {
|
|
61
|
+
console.error(`\u274C Failed to start ${WorkerClass.name}:`, error);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
console.log(`\u{1F389} Successfully started ${this.activeWorkers.length} workers`);
|
|
65
|
+
return this.activeWorkers;
|
|
66
|
+
}
|
|
67
|
+
async shutdown() {
|
|
68
|
+
console.log("\u{1F6D1} Stopping all workers...");
|
|
69
|
+
const stopPromises = this.activeWorkers.map(
|
|
70
|
+
({ name, instance }) => instance.stop().catch(
|
|
71
|
+
(err) => console.error(`\u274C Error stopping ${name}:`, err)
|
|
72
|
+
)
|
|
73
|
+
);
|
|
74
|
+
await Promise.all(stopPromises);
|
|
75
|
+
this.activeWorkers = [];
|
|
76
|
+
console.log("\u2705 All workers stopped");
|
|
77
|
+
}
|
|
78
|
+
getStatus() {
|
|
79
|
+
return this.activeWorkers.map(({ name, instance }) => ({
|
|
80
|
+
name,
|
|
81
|
+
queueId: instance.config?.id || "unknown",
|
|
82
|
+
isActive: !!instance.worker
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
module2.exports = { WorkerManager: WorkerManager2 };
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// src/bullmq/BaseProducer.js
|
|
91
|
+
var require_BaseProducer = __commonJS({
|
|
92
|
+
"src/bullmq/BaseProducer.js"(exports2, module2) {
|
|
93
|
+
"use strict";
|
|
94
|
+
var { Queue } = require("bullmq");
|
|
95
|
+
var BaseProducer2 = class {
|
|
96
|
+
constructor(config) {
|
|
97
|
+
this.config = config;
|
|
98
|
+
this.queue = new Queue(config.id, config.queueConfig);
|
|
99
|
+
}
|
|
100
|
+
async execute(params) {
|
|
101
|
+
throw new Error("execute() method must be implemented by subclass");
|
|
102
|
+
}
|
|
103
|
+
async addBulkJobs(jobs) {
|
|
104
|
+
try {
|
|
105
|
+
const results = await this.queue.addBulk(jobs);
|
|
106
|
+
console.log(`\u2705 ${this.constructor.name}: Successfully queued ${results.length} jobs`);
|
|
107
|
+
return results;
|
|
108
|
+
} catch (error) {
|
|
109
|
+
console.error(`\u274C ${this.constructor.name}: Failed to queue jobs:`, error);
|
|
110
|
+
throw error;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
async addJob(name, data, opts = {}) {
|
|
114
|
+
try {
|
|
115
|
+
const job = await this.queue.add(name, data, opts);
|
|
116
|
+
console.log(`\u2705 ${this.constructor.name}: Successfully queued job ${job.id}`);
|
|
117
|
+
return job;
|
|
118
|
+
} catch (error) {
|
|
119
|
+
console.error(`\u274C ${this.constructor.name}: Failed to queue job:`, error);
|
|
120
|
+
throw error;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
async getStatus() {
|
|
124
|
+
const waiting = await this.queue.getWaiting();
|
|
125
|
+
const active = await this.queue.getActive();
|
|
126
|
+
const completed = await this.queue.getCompleted();
|
|
127
|
+
const failed = await this.queue.getFailed();
|
|
128
|
+
return {
|
|
129
|
+
waiting: waiting.length,
|
|
130
|
+
active: active.length,
|
|
131
|
+
completed: completed.length,
|
|
132
|
+
failed: failed.length,
|
|
133
|
+
total: waiting.length + active.length + completed.length + failed.length
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
async getJobDetails(limit = 10) {
|
|
137
|
+
const waiting = await this.queue.getWaiting(0, limit - 1);
|
|
138
|
+
const active = await this.queue.getActive(0, limit - 1);
|
|
139
|
+
const completed = await this.queue.getCompleted(0, limit - 1);
|
|
140
|
+
const failed = await this.queue.getFailed(0, limit - 1);
|
|
141
|
+
return {
|
|
142
|
+
waiting: waiting.map((job) => ({
|
|
143
|
+
id: job.id,
|
|
144
|
+
batchIndex: job.data?.batchIndex,
|
|
145
|
+
totalBatches: job.data?.totalBatches,
|
|
146
|
+
rawRecordsCount: job.data?.rawBatchData?.length
|
|
147
|
+
})),
|
|
148
|
+
active: active.map((job) => ({
|
|
149
|
+
id: job.id,
|
|
150
|
+
batchIndex: job.data?.batchIndex,
|
|
151
|
+
totalBatches: job.data?.totalBatches,
|
|
152
|
+
progress: job.progress,
|
|
153
|
+
rawRecordsCount: job.data?.rawBatchData?.length
|
|
154
|
+
})),
|
|
155
|
+
completed: completed.map((job) => ({
|
|
156
|
+
id: job.id,
|
|
157
|
+
batchIndex: job.returnvalue?.batchIndex,
|
|
158
|
+
totalProcessed: job.returnvalue?.totalItemsProcessed,
|
|
159
|
+
summary: job.returnvalue?.summary
|
|
160
|
+
})),
|
|
161
|
+
failed: failed.map((job) => ({
|
|
162
|
+
id: job.id,
|
|
163
|
+
batchIndex: job.data?.batchIndex,
|
|
164
|
+
error: job.failedReason,
|
|
165
|
+
attempts: job.attemptsMade
|
|
166
|
+
}))
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
async stop() {
|
|
170
|
+
if (this.queue) {
|
|
171
|
+
await this.queue.close();
|
|
172
|
+
console.log(`\u{1F6D1} ${this.constructor.name} queue closed`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
module2.exports = { BaseProducer: BaseProducer2 };
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
// src/bullmq/BaseWorker.js
|
|
181
|
+
var require_BaseWorker = __commonJS({
|
|
182
|
+
"src/bullmq/BaseWorker.js"(exports2, module2) {
|
|
183
|
+
"use strict";
|
|
184
|
+
var { Worker } = require("bullmq");
|
|
185
|
+
var BaseWorker2 = class {
|
|
186
|
+
constructor(config) {
|
|
187
|
+
this.config = config;
|
|
188
|
+
this.worker = null;
|
|
189
|
+
}
|
|
190
|
+
async execute(job) {
|
|
191
|
+
throw new Error("execute() method must be implemented by subclass");
|
|
192
|
+
}
|
|
193
|
+
start() {
|
|
194
|
+
this.worker = new Worker(
|
|
195
|
+
this.config.id,
|
|
196
|
+
this.execute.bind(this),
|
|
197
|
+
this.config.workerConfig
|
|
198
|
+
);
|
|
199
|
+
this.setupEventHandlers();
|
|
200
|
+
console.log(`\u{1F680} ${this.constructor.name} started for queue: ${this.config.id}`);
|
|
201
|
+
return this.worker;
|
|
202
|
+
}
|
|
203
|
+
setupEventHandlers() {
|
|
204
|
+
this.worker.on("completed", (job, returnValue) => {
|
|
205
|
+
this.onCompleted(job, returnValue);
|
|
206
|
+
});
|
|
207
|
+
this.worker.on("failed", (job, err) => {
|
|
208
|
+
this.onFailed(job, err);
|
|
209
|
+
});
|
|
210
|
+
this.worker.on("progress", (job, progress) => {
|
|
211
|
+
this.onProgress(job, progress);
|
|
212
|
+
});
|
|
213
|
+
this.worker.on("error", (error) => {
|
|
214
|
+
this.onError(error);
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
onCompleted(job, returnValue) {
|
|
218
|
+
console.log(`\u2705 Job ${job.id} completed in ${this.constructor.name}`);
|
|
219
|
+
}
|
|
220
|
+
onFailed(job, err) {
|
|
221
|
+
console.error(`\u{1F4A5} Job ${job.id} failed in ${this.constructor.name}:`, err.message);
|
|
222
|
+
}
|
|
223
|
+
onProgress(job, progress) {
|
|
224
|
+
console.log(`\u{1F4CA} Job ${job.id} progress in ${this.constructor.name}: ${progress}%`);
|
|
225
|
+
}
|
|
226
|
+
onError(error) {
|
|
227
|
+
console.error(`\u274C Worker error in ${this.constructor.name}:`, error);
|
|
228
|
+
}
|
|
229
|
+
async stop() {
|
|
230
|
+
if (this.worker) {
|
|
231
|
+
await this.worker.close();
|
|
232
|
+
console.log(`\u{1F6D1} ${this.constructor.name} stopped`);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
module2.exports = { BaseWorker: BaseWorker2 };
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
// src/bullmq/GLOBAL_BULLMQ_CONFIG.js
|
|
241
|
+
var GLOBAL_BULLMQ_CONFIG_exports = {};
|
|
242
|
+
__export(GLOBAL_BULLMQ_CONFIG_exports, {
|
|
243
|
+
BASE_BULLMQ_CONFIG: () => BASE_BULLMQ_CONFIG
|
|
244
|
+
});
|
|
245
|
+
var BASE_BULLMQ_CONFIG;
|
|
246
|
+
var init_GLOBAL_BULLMQ_CONFIG = __esm({
|
|
247
|
+
"src/bullmq/GLOBAL_BULLMQ_CONFIG.js"() {
|
|
248
|
+
"use strict";
|
|
249
|
+
BASE_BULLMQ_CONFIG = {
|
|
250
|
+
PLUGIN__MAD_USERS_SYNC_QUEUE: {
|
|
251
|
+
id: "plugin--mad-users-sync-queue",
|
|
252
|
+
queueConfig: {
|
|
253
|
+
defaultJobOptions: {
|
|
254
|
+
backoff: {
|
|
255
|
+
type: "exponential",
|
|
256
|
+
delay: 2e3
|
|
257
|
+
},
|
|
258
|
+
attempts: 3,
|
|
259
|
+
removeOnComplete: 100,
|
|
260
|
+
removeOnFail: 50
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
workerConfig: {
|
|
264
|
+
concurrency: 1,
|
|
265
|
+
// Process jobs one at a time to avoid race conditions
|
|
266
|
+
limiter: {
|
|
267
|
+
max: 10,
|
|
268
|
+
// Max 10 jobs per...
|
|
269
|
+
duration: 6e4
|
|
270
|
+
// ...60 seconds (rate limiting)
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
// Chunk Processing Queue
|
|
275
|
+
CHUNK_PROCESSING_QUEUE: {
|
|
276
|
+
id: "chunk-processing-queue",
|
|
277
|
+
queueConfig: {
|
|
278
|
+
defaultJobOptions: {
|
|
279
|
+
backoff: {
|
|
280
|
+
type: "exponential",
|
|
281
|
+
delay: 2e3
|
|
282
|
+
},
|
|
283
|
+
attempts: 3,
|
|
284
|
+
removeOnComplete: 100,
|
|
285
|
+
removeOnFail: 50
|
|
286
|
+
}
|
|
287
|
+
},
|
|
288
|
+
workerConfig: {
|
|
289
|
+
concurrency: 10,
|
|
290
|
+
// Process 10 jobs at once for chunk processing
|
|
291
|
+
limiter: {
|
|
292
|
+
max: 5,
|
|
293
|
+
// Max 50 jobs per...
|
|
294
|
+
duration: 6e4
|
|
295
|
+
// ...60 seconds (higher throughput for chunking)
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
// src/bullmq/GET_GLOBAL_BULLMQ_CONFIG.js
|
|
304
|
+
var require_GET_GLOBAL_BULLMQ_CONFIG = __commonJS({
|
|
305
|
+
"src/bullmq/GET_GLOBAL_BULLMQ_CONFIG.js"(exports2, module2) {
|
|
306
|
+
"use strict";
|
|
307
|
+
var { default: Redis } = require("ioredis");
|
|
308
|
+
var { BASE_BULLMQ_CONFIG: BASE_BULLMQ_CONFIG2 } = (init_GLOBAL_BULLMQ_CONFIG(), __toCommonJS(GLOBAL_BULLMQ_CONFIG_exports));
|
|
309
|
+
function GET_GLOBAL_BULLMQ_CONFIG2({ env, redisCredentials }) {
|
|
310
|
+
const redisConnectionForBullMQ = new Redis({
|
|
311
|
+
host: redisCredentials.REDIS_HOST,
|
|
312
|
+
port: redisCredentials.REDIS_PORT,
|
|
313
|
+
password: redisCredentials.REDIS_PASSWORD,
|
|
314
|
+
maxRetriesPerRequest: null
|
|
315
|
+
});
|
|
316
|
+
return Object.keys(BASE_BULLMQ_CONFIG2).reduce((acc, key) => ({
|
|
317
|
+
...acc,
|
|
318
|
+
[key]: {
|
|
319
|
+
...BASE_BULLMQ_CONFIG2[key],
|
|
320
|
+
id: BASE_BULLMQ_CONFIG2[key].id + `_${env}`,
|
|
321
|
+
// suffix env to queue to keep it unique for each environment
|
|
322
|
+
queueConfig: {
|
|
323
|
+
connection: redisConnectionForBullMQ,
|
|
324
|
+
...BASE_BULLMQ_CONFIG2[key].queueConfig
|
|
325
|
+
},
|
|
326
|
+
workerConfig: {
|
|
327
|
+
connection: redisConnectionForBullMQ,
|
|
328
|
+
...BASE_BULLMQ_CONFIG2[key].workerConfig
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}), {});
|
|
332
|
+
}
|
|
333
|
+
module2.exports = { GET_GLOBAL_BULLMQ_CONFIG: GET_GLOBAL_BULLMQ_CONFIG2 };
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
|
|
30
337
|
// src/node.ts
|
|
31
338
|
var node_exports = {};
|
|
32
339
|
__export(node_exports, {
|
|
33
340
|
AIChatSchema: () => AIChat_default,
|
|
34
341
|
AnnotationSchema: () => Annotations_default,
|
|
342
|
+
BaseProducer: () => import_BaseProducer.BaseProducer,
|
|
343
|
+
BaseWorker: () => import_BaseWorker.BaseWorker,
|
|
344
|
+
GET_GLOBAL_BULLMQ_CONFIG: () => import_GET_GLOBAL_BULLMQ_CONFIG.GET_GLOBAL_BULLMQ_CONFIG,
|
|
35
345
|
PlatformConfigsSchema: () => PlatformConfigs_default,
|
|
36
346
|
TplSchema: () => Tpl_default,
|
|
347
|
+
WorkerManager: () => import_WorkerManager.WorkerManager,
|
|
37
348
|
connectToRedis: () => connectToRedis,
|
|
38
349
|
deleteVal: () => deleteVal,
|
|
39
350
|
extractAllBlocksFromTpl: () => extractAllBlocksFromTpl,
|
|
@@ -887,12 +1198,22 @@ var getAIConfigs = async ({
|
|
|
887
1198
|
}
|
|
888
1199
|
});
|
|
889
1200
|
};
|
|
1201
|
+
|
|
1202
|
+
// src/node.ts
|
|
1203
|
+
var import_WorkerManager = __toESM(require_WorkerManager());
|
|
1204
|
+
var import_BaseProducer = __toESM(require_BaseProducer());
|
|
1205
|
+
var import_BaseWorker = __toESM(require_BaseWorker());
|
|
1206
|
+
var import_GET_GLOBAL_BULLMQ_CONFIG = __toESM(require_GET_GLOBAL_BULLMQ_CONFIG());
|
|
890
1207
|
// Annotate the CommonJS export names for ESM import in node:
|
|
891
1208
|
0 && (module.exports = {
|
|
892
1209
|
AIChatSchema,
|
|
893
1210
|
AnnotationSchema,
|
|
1211
|
+
BaseProducer,
|
|
1212
|
+
BaseWorker,
|
|
1213
|
+
GET_GLOBAL_BULLMQ_CONFIG,
|
|
894
1214
|
PlatformConfigsSchema,
|
|
895
1215
|
TplSchema,
|
|
1216
|
+
WorkerManager,
|
|
896
1217
|
connectToRedis,
|
|
897
1218
|
deleteVal,
|
|
898
1219
|
extractAllBlocksFromTpl,
|
package/dist/node.mjs
CHANGED
|
@@ -1,3 +1,344 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
|
+
}) : x)(function(x) {
|
|
10
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
11
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
12
|
+
});
|
|
13
|
+
var __esm = (fn, res) => function __init() {
|
|
14
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
15
|
+
};
|
|
16
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
17
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
18
|
+
};
|
|
19
|
+
var __export = (target, all) => {
|
|
20
|
+
for (var name in all)
|
|
21
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
22
|
+
};
|
|
23
|
+
var __copyProps = (to, from, except, desc) => {
|
|
24
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
25
|
+
for (let key of __getOwnPropNames(from))
|
|
26
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
27
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
28
|
+
}
|
|
29
|
+
return to;
|
|
30
|
+
};
|
|
31
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
32
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
33
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
34
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
35
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
36
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
37
|
+
mod
|
|
38
|
+
));
|
|
39
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
40
|
+
|
|
41
|
+
// src/bullmq/WorkerManager.js
|
|
42
|
+
var require_WorkerManager = __commonJS({
|
|
43
|
+
"src/bullmq/WorkerManager.js"(exports, module) {
|
|
44
|
+
"use strict";
|
|
45
|
+
var WorkerManager2 = class {
|
|
46
|
+
constructor(workers = []) {
|
|
47
|
+
this.workers = workers;
|
|
48
|
+
this.activeWorkers = [];
|
|
49
|
+
}
|
|
50
|
+
startAllWorkers() {
|
|
51
|
+
if (this.workers.length === 0) {
|
|
52
|
+
console.log("No workers provided to start");
|
|
53
|
+
return [];
|
|
54
|
+
}
|
|
55
|
+
console.log("\u{1F680} Starting all workers...");
|
|
56
|
+
this.workers.forEach((WorkerClass) => {
|
|
57
|
+
try {
|
|
58
|
+
const workerInstance = new WorkerClass();
|
|
59
|
+
workerInstance.start();
|
|
60
|
+
this.activeWorkers.push({
|
|
61
|
+
name: WorkerClass.name,
|
|
62
|
+
instance: workerInstance
|
|
63
|
+
});
|
|
64
|
+
console.log(`\u2705 Started ${WorkerClass.name}`);
|
|
65
|
+
} catch (error) {
|
|
66
|
+
console.error(`\u274C Failed to start ${WorkerClass.name}:`, error);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
console.log(`\u{1F389} Successfully started ${this.activeWorkers.length} workers`);
|
|
70
|
+
return this.activeWorkers;
|
|
71
|
+
}
|
|
72
|
+
async shutdown() {
|
|
73
|
+
console.log("\u{1F6D1} Stopping all workers...");
|
|
74
|
+
const stopPromises = this.activeWorkers.map(
|
|
75
|
+
({ name, instance }) => instance.stop().catch(
|
|
76
|
+
(err) => console.error(`\u274C Error stopping ${name}:`, err)
|
|
77
|
+
)
|
|
78
|
+
);
|
|
79
|
+
await Promise.all(stopPromises);
|
|
80
|
+
this.activeWorkers = [];
|
|
81
|
+
console.log("\u2705 All workers stopped");
|
|
82
|
+
}
|
|
83
|
+
getStatus() {
|
|
84
|
+
return this.activeWorkers.map(({ name, instance }) => ({
|
|
85
|
+
name,
|
|
86
|
+
queueId: instance.config?.id || "unknown",
|
|
87
|
+
isActive: !!instance.worker
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
module.exports = { WorkerManager: WorkerManager2 };
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// src/bullmq/BaseProducer.js
|
|
96
|
+
var require_BaseProducer = __commonJS({
|
|
97
|
+
"src/bullmq/BaseProducer.js"(exports, module) {
|
|
98
|
+
"use strict";
|
|
99
|
+
var { Queue } = __require("bullmq");
|
|
100
|
+
var BaseProducer2 = class {
|
|
101
|
+
constructor(config) {
|
|
102
|
+
this.config = config;
|
|
103
|
+
this.queue = new Queue(config.id, config.queueConfig);
|
|
104
|
+
}
|
|
105
|
+
async execute(params) {
|
|
106
|
+
throw new Error("execute() method must be implemented by subclass");
|
|
107
|
+
}
|
|
108
|
+
async addBulkJobs(jobs) {
|
|
109
|
+
try {
|
|
110
|
+
const results = await this.queue.addBulk(jobs);
|
|
111
|
+
console.log(`\u2705 ${this.constructor.name}: Successfully queued ${results.length} jobs`);
|
|
112
|
+
return results;
|
|
113
|
+
} catch (error) {
|
|
114
|
+
console.error(`\u274C ${this.constructor.name}: Failed to queue jobs:`, error);
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
async addJob(name, data, opts = {}) {
|
|
119
|
+
try {
|
|
120
|
+
const job = await this.queue.add(name, data, opts);
|
|
121
|
+
console.log(`\u2705 ${this.constructor.name}: Successfully queued job ${job.id}`);
|
|
122
|
+
return job;
|
|
123
|
+
} catch (error) {
|
|
124
|
+
console.error(`\u274C ${this.constructor.name}: Failed to queue job:`, error);
|
|
125
|
+
throw error;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
async getStatus() {
|
|
129
|
+
const waiting = await this.queue.getWaiting();
|
|
130
|
+
const active = await this.queue.getActive();
|
|
131
|
+
const completed = await this.queue.getCompleted();
|
|
132
|
+
const failed = await this.queue.getFailed();
|
|
133
|
+
return {
|
|
134
|
+
waiting: waiting.length,
|
|
135
|
+
active: active.length,
|
|
136
|
+
completed: completed.length,
|
|
137
|
+
failed: failed.length,
|
|
138
|
+
total: waiting.length + active.length + completed.length + failed.length
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
async getJobDetails(limit = 10) {
|
|
142
|
+
const waiting = await this.queue.getWaiting(0, limit - 1);
|
|
143
|
+
const active = await this.queue.getActive(0, limit - 1);
|
|
144
|
+
const completed = await this.queue.getCompleted(0, limit - 1);
|
|
145
|
+
const failed = await this.queue.getFailed(0, limit - 1);
|
|
146
|
+
return {
|
|
147
|
+
waiting: waiting.map((job) => ({
|
|
148
|
+
id: job.id,
|
|
149
|
+
batchIndex: job.data?.batchIndex,
|
|
150
|
+
totalBatches: job.data?.totalBatches,
|
|
151
|
+
rawRecordsCount: job.data?.rawBatchData?.length
|
|
152
|
+
})),
|
|
153
|
+
active: active.map((job) => ({
|
|
154
|
+
id: job.id,
|
|
155
|
+
batchIndex: job.data?.batchIndex,
|
|
156
|
+
totalBatches: job.data?.totalBatches,
|
|
157
|
+
progress: job.progress,
|
|
158
|
+
rawRecordsCount: job.data?.rawBatchData?.length
|
|
159
|
+
})),
|
|
160
|
+
completed: completed.map((job) => ({
|
|
161
|
+
id: job.id,
|
|
162
|
+
batchIndex: job.returnvalue?.batchIndex,
|
|
163
|
+
totalProcessed: job.returnvalue?.totalItemsProcessed,
|
|
164
|
+
summary: job.returnvalue?.summary
|
|
165
|
+
})),
|
|
166
|
+
failed: failed.map((job) => ({
|
|
167
|
+
id: job.id,
|
|
168
|
+
batchIndex: job.data?.batchIndex,
|
|
169
|
+
error: job.failedReason,
|
|
170
|
+
attempts: job.attemptsMade
|
|
171
|
+
}))
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
async stop() {
|
|
175
|
+
if (this.queue) {
|
|
176
|
+
await this.queue.close();
|
|
177
|
+
console.log(`\u{1F6D1} ${this.constructor.name} queue closed`);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
module.exports = { BaseProducer: BaseProducer2 };
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
// src/bullmq/BaseWorker.js
|
|
186
|
+
var require_BaseWorker = __commonJS({
|
|
187
|
+
"src/bullmq/BaseWorker.js"(exports, module) {
|
|
188
|
+
"use strict";
|
|
189
|
+
var { Worker } = __require("bullmq");
|
|
190
|
+
var BaseWorker2 = class {
|
|
191
|
+
constructor(config) {
|
|
192
|
+
this.config = config;
|
|
193
|
+
this.worker = null;
|
|
194
|
+
}
|
|
195
|
+
async execute(job) {
|
|
196
|
+
throw new Error("execute() method must be implemented by subclass");
|
|
197
|
+
}
|
|
198
|
+
start() {
|
|
199
|
+
this.worker = new Worker(
|
|
200
|
+
this.config.id,
|
|
201
|
+
this.execute.bind(this),
|
|
202
|
+
this.config.workerConfig
|
|
203
|
+
);
|
|
204
|
+
this.setupEventHandlers();
|
|
205
|
+
console.log(`\u{1F680} ${this.constructor.name} started for queue: ${this.config.id}`);
|
|
206
|
+
return this.worker;
|
|
207
|
+
}
|
|
208
|
+
setupEventHandlers() {
|
|
209
|
+
this.worker.on("completed", (job, returnValue) => {
|
|
210
|
+
this.onCompleted(job, returnValue);
|
|
211
|
+
});
|
|
212
|
+
this.worker.on("failed", (job, err) => {
|
|
213
|
+
this.onFailed(job, err);
|
|
214
|
+
});
|
|
215
|
+
this.worker.on("progress", (job, progress) => {
|
|
216
|
+
this.onProgress(job, progress);
|
|
217
|
+
});
|
|
218
|
+
this.worker.on("error", (error) => {
|
|
219
|
+
this.onError(error);
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
onCompleted(job, returnValue) {
|
|
223
|
+
console.log(`\u2705 Job ${job.id} completed in ${this.constructor.name}`);
|
|
224
|
+
}
|
|
225
|
+
onFailed(job, err) {
|
|
226
|
+
console.error(`\u{1F4A5} Job ${job.id} failed in ${this.constructor.name}:`, err.message);
|
|
227
|
+
}
|
|
228
|
+
onProgress(job, progress) {
|
|
229
|
+
console.log(`\u{1F4CA} Job ${job.id} progress in ${this.constructor.name}: ${progress}%`);
|
|
230
|
+
}
|
|
231
|
+
onError(error) {
|
|
232
|
+
console.error(`\u274C Worker error in ${this.constructor.name}:`, error);
|
|
233
|
+
}
|
|
234
|
+
async stop() {
|
|
235
|
+
if (this.worker) {
|
|
236
|
+
await this.worker.close();
|
|
237
|
+
console.log(`\u{1F6D1} ${this.constructor.name} stopped`);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
module.exports = { BaseWorker: BaseWorker2 };
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
// src/bullmq/GLOBAL_BULLMQ_CONFIG.js
|
|
246
|
+
var GLOBAL_BULLMQ_CONFIG_exports = {};
|
|
247
|
+
__export(GLOBAL_BULLMQ_CONFIG_exports, {
|
|
248
|
+
BASE_BULLMQ_CONFIG: () => BASE_BULLMQ_CONFIG
|
|
249
|
+
});
|
|
250
|
+
var BASE_BULLMQ_CONFIG;
|
|
251
|
+
var init_GLOBAL_BULLMQ_CONFIG = __esm({
|
|
252
|
+
"src/bullmq/GLOBAL_BULLMQ_CONFIG.js"() {
|
|
253
|
+
"use strict";
|
|
254
|
+
BASE_BULLMQ_CONFIG = {
|
|
255
|
+
PLUGIN__MAD_USERS_SYNC_QUEUE: {
|
|
256
|
+
id: "plugin--mad-users-sync-queue",
|
|
257
|
+
queueConfig: {
|
|
258
|
+
defaultJobOptions: {
|
|
259
|
+
backoff: {
|
|
260
|
+
type: "exponential",
|
|
261
|
+
delay: 2e3
|
|
262
|
+
},
|
|
263
|
+
attempts: 3,
|
|
264
|
+
removeOnComplete: 100,
|
|
265
|
+
removeOnFail: 50
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
workerConfig: {
|
|
269
|
+
concurrency: 1,
|
|
270
|
+
// Process jobs one at a time to avoid race conditions
|
|
271
|
+
limiter: {
|
|
272
|
+
max: 10,
|
|
273
|
+
// Max 10 jobs per...
|
|
274
|
+
duration: 6e4
|
|
275
|
+
// ...60 seconds (rate limiting)
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
// Chunk Processing Queue
|
|
280
|
+
CHUNK_PROCESSING_QUEUE: {
|
|
281
|
+
id: "chunk-processing-queue",
|
|
282
|
+
queueConfig: {
|
|
283
|
+
defaultJobOptions: {
|
|
284
|
+
backoff: {
|
|
285
|
+
type: "exponential",
|
|
286
|
+
delay: 2e3
|
|
287
|
+
},
|
|
288
|
+
attempts: 3,
|
|
289
|
+
removeOnComplete: 100,
|
|
290
|
+
removeOnFail: 50
|
|
291
|
+
}
|
|
292
|
+
},
|
|
293
|
+
workerConfig: {
|
|
294
|
+
concurrency: 10,
|
|
295
|
+
// Process 10 jobs at once for chunk processing
|
|
296
|
+
limiter: {
|
|
297
|
+
max: 5,
|
|
298
|
+
// Max 50 jobs per...
|
|
299
|
+
duration: 6e4
|
|
300
|
+
// ...60 seconds (higher throughput for chunking)
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
// src/bullmq/GET_GLOBAL_BULLMQ_CONFIG.js
|
|
309
|
+
var require_GET_GLOBAL_BULLMQ_CONFIG = __commonJS({
|
|
310
|
+
"src/bullmq/GET_GLOBAL_BULLMQ_CONFIG.js"(exports, module) {
|
|
311
|
+
"use strict";
|
|
312
|
+
var { default: Redis } = __require("ioredis");
|
|
313
|
+
var { BASE_BULLMQ_CONFIG: BASE_BULLMQ_CONFIG2 } = (init_GLOBAL_BULLMQ_CONFIG(), __toCommonJS(GLOBAL_BULLMQ_CONFIG_exports));
|
|
314
|
+
function GET_GLOBAL_BULLMQ_CONFIG2({ env, redisCredentials }) {
|
|
315
|
+
const redisConnectionForBullMQ = new Redis({
|
|
316
|
+
host: redisCredentials.REDIS_HOST,
|
|
317
|
+
port: redisCredentials.REDIS_PORT,
|
|
318
|
+
password: redisCredentials.REDIS_PASSWORD,
|
|
319
|
+
maxRetriesPerRequest: null
|
|
320
|
+
});
|
|
321
|
+
return Object.keys(BASE_BULLMQ_CONFIG2).reduce((acc, key) => ({
|
|
322
|
+
...acc,
|
|
323
|
+
[key]: {
|
|
324
|
+
...BASE_BULLMQ_CONFIG2[key],
|
|
325
|
+
id: BASE_BULLMQ_CONFIG2[key].id + `_${env}`,
|
|
326
|
+
// suffix env to queue to keep it unique for each environment
|
|
327
|
+
queueConfig: {
|
|
328
|
+
connection: redisConnectionForBullMQ,
|
|
329
|
+
...BASE_BULLMQ_CONFIG2[key].queueConfig
|
|
330
|
+
},
|
|
331
|
+
workerConfig: {
|
|
332
|
+
connection: redisConnectionForBullMQ,
|
|
333
|
+
...BASE_BULLMQ_CONFIG2[key].workerConfig
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}), {});
|
|
337
|
+
}
|
|
338
|
+
module.exports = { GET_GLOBAL_BULLMQ_CONFIG: GET_GLOBAL_BULLMQ_CONFIG2 };
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
|
|
1
342
|
// src/utils/getterSetterDeleter/utils/set_deleteVal.ts
|
|
2
343
|
var set_deleteVal = (action, data, valuePath, value) => {
|
|
3
344
|
if (valuePath === void 0) return;
|
|
@@ -828,11 +1169,25 @@ var getAIConfigs = async ({
|
|
|
828
1169
|
}
|
|
829
1170
|
});
|
|
830
1171
|
};
|
|
1172
|
+
|
|
1173
|
+
// src/node.ts
|
|
1174
|
+
var import_WorkerManager = __toESM(require_WorkerManager());
|
|
1175
|
+
var import_BaseProducer = __toESM(require_BaseProducer());
|
|
1176
|
+
var import_BaseWorker = __toESM(require_BaseWorker());
|
|
1177
|
+
var import_GET_GLOBAL_BULLMQ_CONFIG = __toESM(require_GET_GLOBAL_BULLMQ_CONFIG());
|
|
1178
|
+
var export_BaseProducer = import_BaseProducer.BaseProducer;
|
|
1179
|
+
var export_BaseWorker = import_BaseWorker.BaseWorker;
|
|
1180
|
+
var export_GET_GLOBAL_BULLMQ_CONFIG = import_GET_GLOBAL_BULLMQ_CONFIG.GET_GLOBAL_BULLMQ_CONFIG;
|
|
1181
|
+
var export_WorkerManager = import_WorkerManager.WorkerManager;
|
|
831
1182
|
export {
|
|
832
1183
|
AIChat_default as AIChatSchema,
|
|
833
1184
|
Annotations_default as AnnotationSchema,
|
|
1185
|
+
export_BaseProducer as BaseProducer,
|
|
1186
|
+
export_BaseWorker as BaseWorker,
|
|
1187
|
+
export_GET_GLOBAL_BULLMQ_CONFIG as GET_GLOBAL_BULLMQ_CONFIG,
|
|
834
1188
|
PlatformConfigs_default as PlatformConfigsSchema,
|
|
835
1189
|
Tpl_default as TplSchema,
|
|
1190
|
+
export_WorkerManager as WorkerManager,
|
|
836
1191
|
connectToRedis,
|
|
837
1192
|
deleteVal,
|
|
838
1193
|
extractAllBlocksFromTpl,
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.3.
|
|
6
|
+
"version": "1.3.8",
|
|
7
7
|
"description": "Utility functions for both browser and Node.js",
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"module": "dist/index.mjs",
|
|
@@ -74,6 +74,7 @@
|
|
|
74
74
|
"typescript": "^5.8.2"
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
|
+
"bullmq": "^5.58.2",
|
|
77
78
|
"ioredis": "^5.6.1",
|
|
78
79
|
"mongoose": "^8.15.1"
|
|
79
80
|
}
|