@okf/ootils 1.4.3 → 1.4.5
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 +1 -0
- package/dist/node.d.ts +1 -0
- package/dist/node.js +54 -20
- package/dist/node.mjs +54 -20
- package/package.json +2 -1
package/dist/node.d.mts
CHANGED
|
@@ -173,6 +173,7 @@ declare class MongoConnector {
|
|
|
173
173
|
*/
|
|
174
174
|
multiConnectToMongoDB(): {};
|
|
175
175
|
multiConnectToMongoDBAsync(): Promise<{}>;
|
|
176
|
+
initiateConnectionEventListeners: (CLUSTER_NAME: any) => void;
|
|
176
177
|
/**
|
|
177
178
|
* Helper function to close clusterConnections object
|
|
178
179
|
*/
|
package/dist/node.d.ts
CHANGED
|
@@ -173,6 +173,7 @@ declare class MongoConnector {
|
|
|
173
173
|
*/
|
|
174
174
|
multiConnectToMongoDB(): {};
|
|
175
175
|
multiConnectToMongoDBAsync(): Promise<{}>;
|
|
176
|
+
initiateConnectionEventListeners: (CLUSTER_NAME: any) => void;
|
|
176
177
|
/**
|
|
177
178
|
* Helper function to close clusterConnections object
|
|
178
179
|
*/
|
package/dist/node.js
CHANGED
|
@@ -5,6 +5,7 @@ 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 __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
9
|
var __esm = (fn, res) => function __init() {
|
|
9
10
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
11
|
};
|
|
@@ -32,6 +33,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
32
33
|
mod
|
|
33
34
|
));
|
|
34
35
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
36
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
35
37
|
|
|
36
38
|
// src/models/Annotations.ts
|
|
37
39
|
var Annotations_exports = {};
|
|
@@ -339,11 +341,30 @@ var require_MongoConnector = __commonJS({
|
|
|
339
341
|
"src/db/MongoConnector.js"(exports2, module2) {
|
|
340
342
|
"use strict";
|
|
341
343
|
var mongoose5 = require("mongoose");
|
|
344
|
+
var { ServerApiVersion } = require("mongodb");
|
|
342
345
|
var AnnotationsSchema = (init_Annotations(), __toCommonJS(Annotations_exports));
|
|
343
346
|
var PlatformConfigsSchema2 = (init_PlatformConfigs(), __toCommonJS(PlatformConfigs_exports));
|
|
344
347
|
var TplSchema2 = (init_Tpl(), __toCommonJS(Tpl_exports));
|
|
345
348
|
var MongoConnector3 = class _MongoConnector {
|
|
346
349
|
constructor(options) {
|
|
350
|
+
__publicField(this, "initiateConnectionEventListeners", (CLUSTER_NAME) => {
|
|
351
|
+
console.log("in initiate connection listeners");
|
|
352
|
+
this.clusterConnections[CLUSTER_NAME].on("open", () => {
|
|
353
|
+
console.log(`\u2705 Mongoose connection open to ${CLUSTER_NAME}`);
|
|
354
|
+
});
|
|
355
|
+
this.clusterConnections[CLUSTER_NAME].on("error", (err) => {
|
|
356
|
+
console.error(
|
|
357
|
+
`\u274C Mongoose connection error: ${err.message} with connection info ${CLUSTER_NAME}`
|
|
358
|
+
);
|
|
359
|
+
process.exit(1);
|
|
360
|
+
});
|
|
361
|
+
this.clusterConnections[CLUSTER_NAME].on("disconnected", () => {
|
|
362
|
+
console.log(`\u{1F50C} Mongoose disconnected from ${CLUSTER_NAME}`);
|
|
363
|
+
});
|
|
364
|
+
this.clusterConnections[CLUSTER_NAME].on("reconnected", () => {
|
|
365
|
+
console.log(`\u{1F504} Mongoose reconnected to ${CLUSTER_NAME}`);
|
|
366
|
+
});
|
|
367
|
+
});
|
|
347
368
|
this.clusterConnections = {};
|
|
348
369
|
this.env = options.env;
|
|
349
370
|
this.dbConfigs = options.dbConfigs;
|
|
@@ -352,6 +373,11 @@ var require_MongoConnector = __commonJS({
|
|
|
352
373
|
// serverSelectionTimeoutMS: 5000,
|
|
353
374
|
// socketTimeoutMS: 45000,
|
|
354
375
|
// family: 4,
|
|
376
|
+
serverApi: {
|
|
377
|
+
version: ServerApiVersion.v1
|
|
378
|
+
},
|
|
379
|
+
maxPoolSize: 40,
|
|
380
|
+
minPoolSize: 5
|
|
355
381
|
};
|
|
356
382
|
_MongoConnector.instance = this;
|
|
357
383
|
if (!this.env) {
|
|
@@ -383,21 +409,7 @@ var require_MongoConnector = __commonJS({
|
|
|
383
409
|
DB_URI,
|
|
384
410
|
this.mongoOptions
|
|
385
411
|
);
|
|
386
|
-
this.
|
|
387
|
-
console.log(`\u2705 Mongoose connection open to ${CLUSTER_NAME}`);
|
|
388
|
-
});
|
|
389
|
-
this.clusterConnections[CLUSTER_NAME].on("error", (err) => {
|
|
390
|
-
console.error(
|
|
391
|
-
`\u274C Mongoose connection error: ${err.message} with connection info ${CLUSTER_NAME}`
|
|
392
|
-
);
|
|
393
|
-
process.exit(1);
|
|
394
|
-
});
|
|
395
|
-
this.clusterConnections[CLUSTER_NAME].on("disconnected", () => {
|
|
396
|
-
console.log(`\u{1F50C} Mongoose disconnected from ${CLUSTER_NAME}`);
|
|
397
|
-
});
|
|
398
|
-
this.clusterConnections[CLUSTER_NAME].on("reconnected", () => {
|
|
399
|
-
console.log(`\u{1F504} Mongoose reconnected to ${CLUSTER_NAME}`);
|
|
400
|
-
});
|
|
412
|
+
this.initiateConnectionEventListeners(CLUSTER_NAME);
|
|
401
413
|
});
|
|
402
414
|
console.log(
|
|
403
415
|
`\u{1F389} Connected to ${Object.keys(this.clusterConnections).length} MongoDB databases`
|
|
@@ -419,11 +431,16 @@ var require_MongoConnector = __commonJS({
|
|
|
419
431
|
`Missing CLUSTER_NAME or DB_URI for environment: ${connectToEnv}`
|
|
420
432
|
);
|
|
421
433
|
}
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
434
|
+
const connection = mongoose5.createConnection(DB_URI, this.mongoOptions);
|
|
435
|
+
this.clusterConnections[CLUSTER_NAME] = connection;
|
|
436
|
+
this.initiateConnectionEventListeners(CLUSTER_NAME);
|
|
437
|
+
await new Promise((resolve, reject) => {
|
|
438
|
+
connection.once("open", () => {
|
|
439
|
+
console.log(`Connected to MongoDB: ${CLUSTER_NAME}`);
|
|
440
|
+
resolve();
|
|
441
|
+
});
|
|
442
|
+
connection.once("error", reject);
|
|
443
|
+
});
|
|
427
444
|
})
|
|
428
445
|
);
|
|
429
446
|
return this.clusterConnections;
|
|
@@ -650,6 +667,7 @@ var require_WorkerManager = __commonJS({
|
|
|
650
667
|
this.activeWorkers = [];
|
|
651
668
|
}
|
|
652
669
|
startAllWorkers() {
|
|
670
|
+
if (process.env.NODE_ENV !== "production") return this.activeWorkers;
|
|
653
671
|
if (this.workers.length === 0) {
|
|
654
672
|
console.log("No workers provided to start");
|
|
655
673
|
return [];
|
|
@@ -973,6 +991,22 @@ var init_GLOBAL_BULLMQ_CONFIG = __esm({
|
|
|
973
991
|
// ...60 seconds (higher throughput for chunking)
|
|
974
992
|
}
|
|
975
993
|
}
|
|
994
|
+
},
|
|
995
|
+
AI_CATEGORIZE_QUEUE: {
|
|
996
|
+
queueConfig: {
|
|
997
|
+
defaultJobOptions: {
|
|
998
|
+
attempts: 3,
|
|
999
|
+
backoff: {
|
|
1000
|
+
type: "exponential",
|
|
1001
|
+
delay: 2e3
|
|
1002
|
+
},
|
|
1003
|
+
removeOnComplete: 50,
|
|
1004
|
+
removeOnFail: 100
|
|
1005
|
+
}
|
|
1006
|
+
},
|
|
1007
|
+
workerConfig: {
|
|
1008
|
+
concurrency: 1
|
|
1009
|
+
}
|
|
976
1010
|
}
|
|
977
1011
|
};
|
|
978
1012
|
}
|
package/dist/node.mjs
CHANGED
|
@@ -4,6 +4,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
8
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
9
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
10
|
}) : x)(function(x) {
|
|
@@ -37,6 +38,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
37
38
|
mod
|
|
38
39
|
));
|
|
39
40
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
41
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
40
42
|
|
|
41
43
|
// src/models/Annotations.ts
|
|
42
44
|
var Annotations_exports = {};
|
|
@@ -344,11 +346,30 @@ var require_MongoConnector = __commonJS({
|
|
|
344
346
|
"src/db/MongoConnector.js"(exports, module) {
|
|
345
347
|
"use strict";
|
|
346
348
|
var mongoose5 = __require("mongoose");
|
|
349
|
+
var { ServerApiVersion } = __require("mongodb");
|
|
347
350
|
var AnnotationsSchema = (init_Annotations(), __toCommonJS(Annotations_exports));
|
|
348
351
|
var PlatformConfigsSchema2 = (init_PlatformConfigs(), __toCommonJS(PlatformConfigs_exports));
|
|
349
352
|
var TplSchema2 = (init_Tpl(), __toCommonJS(Tpl_exports));
|
|
350
353
|
var MongoConnector3 = class _MongoConnector {
|
|
351
354
|
constructor(options) {
|
|
355
|
+
__publicField(this, "initiateConnectionEventListeners", (CLUSTER_NAME) => {
|
|
356
|
+
console.log("in initiate connection listeners");
|
|
357
|
+
this.clusterConnections[CLUSTER_NAME].on("open", () => {
|
|
358
|
+
console.log(`\u2705 Mongoose connection open to ${CLUSTER_NAME}`);
|
|
359
|
+
});
|
|
360
|
+
this.clusterConnections[CLUSTER_NAME].on("error", (err) => {
|
|
361
|
+
console.error(
|
|
362
|
+
`\u274C Mongoose connection error: ${err.message} with connection info ${CLUSTER_NAME}`
|
|
363
|
+
);
|
|
364
|
+
process.exit(1);
|
|
365
|
+
});
|
|
366
|
+
this.clusterConnections[CLUSTER_NAME].on("disconnected", () => {
|
|
367
|
+
console.log(`\u{1F50C} Mongoose disconnected from ${CLUSTER_NAME}`);
|
|
368
|
+
});
|
|
369
|
+
this.clusterConnections[CLUSTER_NAME].on("reconnected", () => {
|
|
370
|
+
console.log(`\u{1F504} Mongoose reconnected to ${CLUSTER_NAME}`);
|
|
371
|
+
});
|
|
372
|
+
});
|
|
352
373
|
this.clusterConnections = {};
|
|
353
374
|
this.env = options.env;
|
|
354
375
|
this.dbConfigs = options.dbConfigs;
|
|
@@ -357,6 +378,11 @@ var require_MongoConnector = __commonJS({
|
|
|
357
378
|
// serverSelectionTimeoutMS: 5000,
|
|
358
379
|
// socketTimeoutMS: 45000,
|
|
359
380
|
// family: 4,
|
|
381
|
+
serverApi: {
|
|
382
|
+
version: ServerApiVersion.v1
|
|
383
|
+
},
|
|
384
|
+
maxPoolSize: 40,
|
|
385
|
+
minPoolSize: 5
|
|
360
386
|
};
|
|
361
387
|
_MongoConnector.instance = this;
|
|
362
388
|
if (!this.env) {
|
|
@@ -388,21 +414,7 @@ var require_MongoConnector = __commonJS({
|
|
|
388
414
|
DB_URI,
|
|
389
415
|
this.mongoOptions
|
|
390
416
|
);
|
|
391
|
-
this.
|
|
392
|
-
console.log(`\u2705 Mongoose connection open to ${CLUSTER_NAME}`);
|
|
393
|
-
});
|
|
394
|
-
this.clusterConnections[CLUSTER_NAME].on("error", (err) => {
|
|
395
|
-
console.error(
|
|
396
|
-
`\u274C Mongoose connection error: ${err.message} with connection info ${CLUSTER_NAME}`
|
|
397
|
-
);
|
|
398
|
-
process.exit(1);
|
|
399
|
-
});
|
|
400
|
-
this.clusterConnections[CLUSTER_NAME].on("disconnected", () => {
|
|
401
|
-
console.log(`\u{1F50C} Mongoose disconnected from ${CLUSTER_NAME}`);
|
|
402
|
-
});
|
|
403
|
-
this.clusterConnections[CLUSTER_NAME].on("reconnected", () => {
|
|
404
|
-
console.log(`\u{1F504} Mongoose reconnected to ${CLUSTER_NAME}`);
|
|
405
|
-
});
|
|
417
|
+
this.initiateConnectionEventListeners(CLUSTER_NAME);
|
|
406
418
|
});
|
|
407
419
|
console.log(
|
|
408
420
|
`\u{1F389} Connected to ${Object.keys(this.clusterConnections).length} MongoDB databases`
|
|
@@ -424,11 +436,16 @@ var require_MongoConnector = __commonJS({
|
|
|
424
436
|
`Missing CLUSTER_NAME or DB_URI for environment: ${connectToEnv}`
|
|
425
437
|
);
|
|
426
438
|
}
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
439
|
+
const connection = mongoose5.createConnection(DB_URI, this.mongoOptions);
|
|
440
|
+
this.clusterConnections[CLUSTER_NAME] = connection;
|
|
441
|
+
this.initiateConnectionEventListeners(CLUSTER_NAME);
|
|
442
|
+
await new Promise((resolve, reject) => {
|
|
443
|
+
connection.once("open", () => {
|
|
444
|
+
console.log(`Connected to MongoDB: ${CLUSTER_NAME}`);
|
|
445
|
+
resolve();
|
|
446
|
+
});
|
|
447
|
+
connection.once("error", reject);
|
|
448
|
+
});
|
|
432
449
|
})
|
|
433
450
|
);
|
|
434
451
|
return this.clusterConnections;
|
|
@@ -655,6 +672,7 @@ var require_WorkerManager = __commonJS({
|
|
|
655
672
|
this.activeWorkers = [];
|
|
656
673
|
}
|
|
657
674
|
startAllWorkers() {
|
|
675
|
+
if (process.env.NODE_ENV !== "production") return this.activeWorkers;
|
|
658
676
|
if (this.workers.length === 0) {
|
|
659
677
|
console.log("No workers provided to start");
|
|
660
678
|
return [];
|
|
@@ -978,6 +996,22 @@ var init_GLOBAL_BULLMQ_CONFIG = __esm({
|
|
|
978
996
|
// ...60 seconds (higher throughput for chunking)
|
|
979
997
|
}
|
|
980
998
|
}
|
|
999
|
+
},
|
|
1000
|
+
AI_CATEGORIZE_QUEUE: {
|
|
1001
|
+
queueConfig: {
|
|
1002
|
+
defaultJobOptions: {
|
|
1003
|
+
attempts: 3,
|
|
1004
|
+
backoff: {
|
|
1005
|
+
type: "exponential",
|
|
1006
|
+
delay: 2e3
|
|
1007
|
+
},
|
|
1008
|
+
removeOnComplete: 50,
|
|
1009
|
+
removeOnFail: 100
|
|
1010
|
+
}
|
|
1011
|
+
},
|
|
1012
|
+
workerConfig: {
|
|
1013
|
+
concurrency: 1
|
|
1014
|
+
}
|
|
981
1015
|
}
|
|
982
1016
|
};
|
|
983
1017
|
}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.4.
|
|
6
|
+
"version": "1.4.5",
|
|
7
7
|
"description": "Utility functions for both browser and Node.js",
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"module": "dist/index.mjs",
|
|
@@ -76,6 +76,7 @@
|
|
|
76
76
|
"dependencies": {
|
|
77
77
|
"bullmq": "^5.58.2",
|
|
78
78
|
"ioredis": "^5.6.1",
|
|
79
|
+
"mongodb": "^6.13.0",
|
|
79
80
|
"mongoose": "^8.15.1"
|
|
80
81
|
}
|
|
81
82
|
}
|