@okf/ootils 1.26.1 → 1.26.3
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/browser.d.mts +54 -7
- package/dist/browser.d.ts +54 -7
- package/dist/browser.js +28 -0
- package/dist/browser.mjs +28 -0
- package/dist/node.d.mts +175 -33
- package/dist/node.d.ts +175 -33
- package/dist/node.js +277 -79
- package/dist/node.mjs +274 -77
- package/dist/universal.d.mts +54 -7
- package/dist/universal.d.ts +54 -7
- package/dist/universal.js +28 -0
- package/dist/universal.mjs +28 -0
- package/package.json +1 -1
package/dist/node.mjs
CHANGED
|
@@ -223,6 +223,34 @@ var init_GLOBAL_BULLMQ_CONFIG = __esm({
|
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
225
|
},
|
|
226
|
+
SENTIMENT_AND_NER_QUEUE: {
|
|
227
|
+
id: "sentiment-and-ner-queue",
|
|
228
|
+
queueConfig: {
|
|
229
|
+
defaultJobOptions: {
|
|
230
|
+
attempts: 3,
|
|
231
|
+
backoff: {
|
|
232
|
+
type: "exponential",
|
|
233
|
+
delay: 2e3
|
|
234
|
+
},
|
|
235
|
+
removeOnComplete: 30,
|
|
236
|
+
removeOnFail: 100
|
|
237
|
+
},
|
|
238
|
+
streams: {
|
|
239
|
+
events: {
|
|
240
|
+
maxLen: 10
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
workerConfig: {
|
|
245
|
+
concurrency: 1,
|
|
246
|
+
lockDuration: 9e4,
|
|
247
|
+
maxStalledCount: 3,
|
|
248
|
+
limiter: {
|
|
249
|
+
max: 100,
|
|
250
|
+
duration: 6e4
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
},
|
|
226
254
|
AI_AUTO_ANNOTATE_QUEUE: {
|
|
227
255
|
id: "ai-auto-annotate-queue",
|
|
228
256
|
queueConfig: {
|
|
@@ -879,31 +907,54 @@ var require_ElasticSearchConnector = __commonJS({
|
|
|
879
907
|
"use strict";
|
|
880
908
|
var { Client } = __require("@elastic/elasticsearch");
|
|
881
909
|
var ElasticSearchConnector2 = class _ElasticSearchConnector {
|
|
910
|
+
/**
|
|
911
|
+
* @param {Object} options
|
|
912
|
+
*
|
|
913
|
+
* Multi-env mode (preferred):
|
|
914
|
+
* { env: 'dev', configs: { dev: { cloudId, apiKey }, staging: { cloudId, apiKey }, prod: { cloudId, apiKey } } }
|
|
915
|
+
*
|
|
916
|
+
* Legacy single-env mode (backwards compat):
|
|
917
|
+
* { cloudId: '...', apiKey: '...' }
|
|
918
|
+
*/
|
|
882
919
|
constructor(options = {}) {
|
|
920
|
+
this.env = options.env || null;
|
|
921
|
+
this.clients = {};
|
|
883
922
|
this.client = null;
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
if (!this.apiKey) {
|
|
891
|
-
throw new Error("API Key must be provided in constructor options or ELASTIC_API_KEY environment variable");
|
|
923
|
+
if (options.configs) {
|
|
924
|
+
this._configs = options.configs;
|
|
925
|
+
} else if (options.cloudId && options.apiKey) {
|
|
926
|
+
this._legacyConfig = { cloudId: options.cloudId, apiKey: options.apiKey };
|
|
927
|
+
} else {
|
|
928
|
+
throw new Error("ElasticSearchConnector: provide either { configs } for multi-env or { cloudId, apiKey } for single-env");
|
|
892
929
|
}
|
|
930
|
+
_ElasticSearchConnector.instance = this;
|
|
893
931
|
}
|
|
894
932
|
/**
|
|
895
|
-
* Initialize Elasticsearch client
|
|
933
|
+
* Initialize Elasticsearch client(s).
|
|
934
|
+
* Multi-env: connects to all configured envs.
|
|
935
|
+
* Legacy: connects a single client.
|
|
896
936
|
*/
|
|
897
937
|
connect() {
|
|
898
|
-
this.
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
938
|
+
if (this._configs) {
|
|
939
|
+
for (const [env, conf] of Object.entries(this._configs)) {
|
|
940
|
+
if (!conf.cloudId || !conf.apiKey) {
|
|
941
|
+
console.log(`[ES] Skipping env "${env}" \u2014 missing cloudId or apiKey`);
|
|
942
|
+
continue;
|
|
943
|
+
}
|
|
944
|
+
this.clients[env] = new Client({
|
|
945
|
+
cloud: { id: conf.cloudId },
|
|
946
|
+
auth: { apiKey: conf.apiKey }
|
|
947
|
+
});
|
|
904
948
|
}
|
|
905
|
-
|
|
906
|
-
|
|
949
|
+
this.client = this.clients[this.env] || null;
|
|
950
|
+
console.log(`\u2705 Elasticsearch clients initialized for envs: ${Object.keys(this.clients).join(", ")}`);
|
|
951
|
+
} else {
|
|
952
|
+
this.client = new Client({
|
|
953
|
+
cloud: { id: this._legacyConfig.cloudId },
|
|
954
|
+
auth: { apiKey: this._legacyConfig.apiKey }
|
|
955
|
+
});
|
|
956
|
+
console.log("\u2705 Elasticsearch client initialized");
|
|
957
|
+
}
|
|
907
958
|
return this.client;
|
|
908
959
|
}
|
|
909
960
|
// Static method to get the instance
|
|
@@ -913,22 +964,43 @@ var require_ElasticSearchConnector = __commonJS({
|
|
|
913
964
|
}
|
|
914
965
|
return _ElasticSearchConnector.instance;
|
|
915
966
|
}
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
967
|
+
/**
|
|
968
|
+
* Get an Elasticsearch client.
|
|
969
|
+
* @param {string} [env] - Optional env to get a specific env's client.
|
|
970
|
+
* If omitted, returns the current env's client (backwards compat).
|
|
971
|
+
*/
|
|
972
|
+
static getClient(env) {
|
|
973
|
+
const inst = _ElasticSearchConnector.instance;
|
|
974
|
+
if (!inst) {
|
|
975
|
+
throw new Error("ElasticSearchConnector not initialized");
|
|
976
|
+
}
|
|
977
|
+
if (env && inst.clients[env]) {
|
|
978
|
+
return inst.clients[env];
|
|
920
979
|
}
|
|
921
|
-
|
|
980
|
+
if (inst.client) {
|
|
981
|
+
return inst.client;
|
|
982
|
+
}
|
|
983
|
+
throw new Error("ElasticSearchConnector not initialized or client not connected");
|
|
984
|
+
}
|
|
985
|
+
static getEnv() {
|
|
986
|
+
return _ElasticSearchConnector.instance?.env;
|
|
922
987
|
}
|
|
923
988
|
/**
|
|
924
|
-
* Close
|
|
989
|
+
* Close all Elasticsearch clients.
|
|
925
990
|
*/
|
|
926
991
|
async close() {
|
|
927
|
-
|
|
992
|
+
for (const [env, client] of Object.entries(this.clients)) {
|
|
993
|
+
try {
|
|
994
|
+
await client.close();
|
|
995
|
+
} catch (_) {
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
if (this.client && !Object.values(this.clients).includes(this.client)) {
|
|
928
999
|
await this.client.close();
|
|
929
|
-
console.log("\u2705 Elasticsearch client closed");
|
|
930
|
-
this.client = null;
|
|
931
1000
|
}
|
|
1001
|
+
this.clients = {};
|
|
1002
|
+
this.client = null;
|
|
1003
|
+
console.log("\u2705 Elasticsearch client(s) closed");
|
|
932
1004
|
}
|
|
933
1005
|
};
|
|
934
1006
|
ElasticSearchConnector2.instance = null;
|
|
@@ -1071,11 +1143,55 @@ var init_GeneratedTopics = __esm({
|
|
|
1071
1143
|
}
|
|
1072
1144
|
});
|
|
1073
1145
|
|
|
1146
|
+
// src/models/GeneratedEntities.ts
|
|
1147
|
+
import { Schema as Schema3 } from "mongoose";
|
|
1148
|
+
var GeneratedEntitiesSchema, GeneratedEntities_default;
|
|
1149
|
+
var init_GeneratedEntities = __esm({
|
|
1150
|
+
"src/models/GeneratedEntities.ts"() {
|
|
1151
|
+
"use strict";
|
|
1152
|
+
GeneratedEntitiesSchema = new Schema3(
|
|
1153
|
+
{
|
|
1154
|
+
canonicalName: {
|
|
1155
|
+
type: String,
|
|
1156
|
+
trim: true,
|
|
1157
|
+
required: true
|
|
1158
|
+
},
|
|
1159
|
+
type: {
|
|
1160
|
+
type: String,
|
|
1161
|
+
required: true,
|
|
1162
|
+
trim: true
|
|
1163
|
+
},
|
|
1164
|
+
embeddings: {
|
|
1165
|
+
type: [Number],
|
|
1166
|
+
required: true
|
|
1167
|
+
},
|
|
1168
|
+
aliases: {
|
|
1169
|
+
type: [String],
|
|
1170
|
+
default: []
|
|
1171
|
+
}
|
|
1172
|
+
},
|
|
1173
|
+
{ timestamps: true, collection: "SYSTEM_generatedEntities" }
|
|
1174
|
+
);
|
|
1175
|
+
GeneratedEntitiesSchema.index(
|
|
1176
|
+
{
|
|
1177
|
+
canonicalName: 1,
|
|
1178
|
+
type: 1
|
|
1179
|
+
},
|
|
1180
|
+
{
|
|
1181
|
+
unique: true,
|
|
1182
|
+
name: "unique_entity_per_type"
|
|
1183
|
+
}
|
|
1184
|
+
);
|
|
1185
|
+
GeneratedEntities_default = GeneratedEntitiesSchema;
|
|
1186
|
+
}
|
|
1187
|
+
});
|
|
1188
|
+
|
|
1074
1189
|
// src/models/index.ts
|
|
1075
1190
|
var models_exports = {};
|
|
1076
1191
|
__export(models_exports, {
|
|
1077
1192
|
AIChatSchema: () => AIChat_default,
|
|
1078
1193
|
AnnotationSchema: () => Annotations_default,
|
|
1194
|
+
GeneratedEntitiesSchema: () => GeneratedEntities_default,
|
|
1079
1195
|
GeneratedTopicsSchema: () => GeneratedTopics_default,
|
|
1080
1196
|
PlatformConfigsSchema: () => PlatformConfigs_default,
|
|
1081
1197
|
TplSchema: () => Tpl_default
|
|
@@ -1088,6 +1204,7 @@ var init_models = __esm({
|
|
|
1088
1204
|
init_PlatformConfigs();
|
|
1089
1205
|
init_Tpl();
|
|
1090
1206
|
init_GeneratedTopics();
|
|
1207
|
+
init_GeneratedEntities();
|
|
1091
1208
|
}
|
|
1092
1209
|
});
|
|
1093
1210
|
|
|
@@ -1128,7 +1245,7 @@ var require_getModelByTenant = __commonJS({
|
|
|
1128
1245
|
"src/db/getModelByTenant.js"(exports, module) {
|
|
1129
1246
|
"use strict";
|
|
1130
1247
|
var { getDbByTenant: getDbByTenant2 } = (init_getDbByTenant(), __toCommonJS(getDbByTenant_exports));
|
|
1131
|
-
var { AIChatSchema: AIChatSchema2, AnnotationSchema: AnnotationSchema2, PlatformConfigsSchema: PlatformConfigsSchema2, TplSchema: TplSchema2, GeneratedTopicsSchema: GeneratedTopicsSchema2 } = (init_models(), __toCommonJS(models_exports));
|
|
1248
|
+
var { AIChatSchema: AIChatSchema2, AnnotationSchema: AnnotationSchema2, PlatformConfigsSchema: PlatformConfigsSchema2, TplSchema: TplSchema2, GeneratedTopicsSchema: GeneratedTopicsSchema2, GeneratedEntitiesSchema: GeneratedEntitiesSchema2 } = (init_models(), __toCommonJS(models_exports));
|
|
1132
1249
|
var getModelByTenant3 = ({ tenant, modelName, schema, env }) => {
|
|
1133
1250
|
if (!tenant) {
|
|
1134
1251
|
throw new Error("tenant id has not been provided");
|
|
@@ -1169,13 +1286,20 @@ var require_getModelByTenant = __commonJS({
|
|
|
1169
1286
|
schema: GeneratedTopicsSchema2,
|
|
1170
1287
|
env
|
|
1171
1288
|
});
|
|
1289
|
+
var getGeneratedEntitiesModelByTenant2 = ({ tenant, env }) => getModelByTenant3({
|
|
1290
|
+
tenant,
|
|
1291
|
+
modelName: "generatedEntities",
|
|
1292
|
+
schema: GeneratedEntitiesSchema2,
|
|
1293
|
+
env
|
|
1294
|
+
});
|
|
1172
1295
|
module.exports = {
|
|
1173
1296
|
getModelByTenant: getModelByTenant3,
|
|
1174
1297
|
getAIChatModelByTenant: getAIChatModelByTenant2,
|
|
1175
1298
|
getAnnotationsModelByTenant: getAnnotationsModelByTenant2,
|
|
1176
1299
|
getPlatformConfigsModelByTenant: getPlatformConfigsModelByTenant2,
|
|
1177
1300
|
getTplModelByTenant: getTplModelByTenant2,
|
|
1178
|
-
getGeneratedTopicsModelByTenant: getGeneratedTopicsModelByTenant2
|
|
1301
|
+
getGeneratedTopicsModelByTenant: getGeneratedTopicsModelByTenant2,
|
|
1302
|
+
getGeneratedEntitiesModelByTenant: getGeneratedEntitiesModelByTenant2
|
|
1179
1303
|
};
|
|
1180
1304
|
}
|
|
1181
1305
|
});
|
|
@@ -1240,6 +1364,36 @@ var init_SecretManagerConnector = __esm({
|
|
|
1240
1364
|
const configs = _SecretManagerConnector.getSecret("envSpecificConfigs");
|
|
1241
1365
|
return env ? configs[env] : configs;
|
|
1242
1366
|
}
|
|
1367
|
+
/**
|
|
1368
|
+
* Get Redis configs for all envs, structured for RedisCacheConnector multi-env mode.
|
|
1369
|
+
* @returns {{ dev: { host, port, password }, staging: { host, port, password }, prod: { host, port, password } }}
|
|
1370
|
+
*/
|
|
1371
|
+
static getRedisConfigsForAllEnvs() {
|
|
1372
|
+
const all = _SecretManagerConnector.getEnvSpecificConfigs();
|
|
1373
|
+
const result = {};
|
|
1374
|
+
for (const env of Object.keys(all)) {
|
|
1375
|
+
const c = all[env];
|
|
1376
|
+
if (c?.REDIS_HOST) {
|
|
1377
|
+
result[env] = { host: c.REDIS_HOST, port: c.REDIS_PORT, password: c.REDIS_PASSWORD };
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
return result;
|
|
1381
|
+
}
|
|
1382
|
+
/**
|
|
1383
|
+
* Get Elasticsearch configs for all envs, structured for ElasticSearchConnector multi-env mode.
|
|
1384
|
+
* @returns {{ dev: { cloudId, apiKey }, staging: { cloudId, apiKey }, prod: { cloudId, apiKey } }}
|
|
1385
|
+
*/
|
|
1386
|
+
static getElasticConfigsForAllEnvs() {
|
|
1387
|
+
const all = _SecretManagerConnector.getEnvSpecificConfigs();
|
|
1388
|
+
const result = {};
|
|
1389
|
+
for (const env of Object.keys(all)) {
|
|
1390
|
+
const c = all[env];
|
|
1391
|
+
if (c?.ELASTIC_CLOUD_ID) {
|
|
1392
|
+
result[env] = { cloudId: c.ELASTIC_CLOUD_ID, apiKey: c.ELASTIC_API_KEY };
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
return result;
|
|
1396
|
+
}
|
|
1243
1397
|
static async addSecretVersion(secretName, data) {
|
|
1244
1398
|
const instance = _SecretManagerConnector.instance;
|
|
1245
1399
|
const payload = Buffer.from(JSON.stringify(data, null, 2));
|
|
@@ -3271,24 +3425,56 @@ var BASE_SETTINGS_FOR_CONFIGS_CACHE = [
|
|
|
3271
3425
|
}
|
|
3272
3426
|
];
|
|
3273
3427
|
var RedisCacheConnector = class _RedisCacheConnector {
|
|
3428
|
+
/**
|
|
3429
|
+
* @param {Object} options
|
|
3430
|
+
*
|
|
3431
|
+
* Multi-env mode (preferred):
|
|
3432
|
+
* { env: 'dev', configs: { dev: { host, port, password }, staging: { host, port, password }, prod: { host, port, password } } }
|
|
3433
|
+
*
|
|
3434
|
+
* Legacy single-env mode (backwards compat):
|
|
3435
|
+
* { host: '...', port: 6379, password: '...', env: 'dev' }
|
|
3436
|
+
*/
|
|
3274
3437
|
constructor(options = {}) {
|
|
3275
3438
|
/**
|
|
3276
|
-
* Initialize Redis client
|
|
3439
|
+
* Initialize Redis client(s).
|
|
3440
|
+
* Multi-env: connects to all configured envs.
|
|
3441
|
+
* Legacy: connects a single client.
|
|
3277
3442
|
*/
|
|
3278
3443
|
__publicField(this, "connect", async () => {
|
|
3279
3444
|
try {
|
|
3280
|
-
this.
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3445
|
+
if (this._configs) {
|
|
3446
|
+
for (const [env, conf] of Object.entries(this._configs)) {
|
|
3447
|
+
if (!conf.host || !conf.port || !conf.password) {
|
|
3448
|
+
console.log(`[Redis] Skipping env "${env}" \u2014 missing config`);
|
|
3449
|
+
continue;
|
|
3450
|
+
}
|
|
3451
|
+
const redisClient = new Redis({
|
|
3452
|
+
host: conf.host,
|
|
3453
|
+
port: conf.port,
|
|
3454
|
+
password: conf.password
|
|
3455
|
+
});
|
|
3456
|
+
await new Promise((resolve, reject) => {
|
|
3457
|
+
redisClient.on("ready", resolve);
|
|
3458
|
+
redisClient.on("error", reject);
|
|
3459
|
+
});
|
|
3460
|
+
this.clients[env] = redisClient;
|
|
3461
|
+
}
|
|
3462
|
+
this.client = this.clients[this.env] || null;
|
|
3463
|
+
console.log(`\u2705 Redis clients initialized for envs: ${Object.keys(this.clients).join(", ")}`);
|
|
3464
|
+
} else {
|
|
3465
|
+
this.client = new Redis({
|
|
3466
|
+
host: this._legacyConfig.host,
|
|
3467
|
+
port: this._legacyConfig.port,
|
|
3468
|
+
password: this._legacyConfig.password
|
|
3469
|
+
});
|
|
3470
|
+
this.client.on("connect", () => {
|
|
3471
|
+
console.log("\u2705 Connected to our redis cache instance!");
|
|
3472
|
+
});
|
|
3473
|
+
await new Promise((resolve, reject) => {
|
|
3474
|
+
this.client.on("ready", resolve);
|
|
3475
|
+
this.client.on("error", reject);
|
|
3476
|
+
});
|
|
3477
|
+
}
|
|
3292
3478
|
return this.client;
|
|
3293
3479
|
} catch (err) {
|
|
3294
3480
|
console.error(err.message);
|
|
@@ -3300,24 +3486,20 @@ var RedisCacheConnector = class _RedisCacheConnector {
|
|
|
3300
3486
|
"RedisCacheConnector instance already exists. Use RedisCacheConnector.getInstance() instead."
|
|
3301
3487
|
);
|
|
3302
3488
|
}
|
|
3303
|
-
this.client = null;
|
|
3304
|
-
this.host = options.host;
|
|
3305
3489
|
this.env = options.env;
|
|
3306
|
-
this.
|
|
3307
|
-
this.
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
throw new Error("
|
|
3314
|
-
}
|
|
3315
|
-
if (!this.password) {
|
|
3316
|
-
throw new Error("Password must be provided in constructor options");
|
|
3490
|
+
this.clients = {};
|
|
3491
|
+
this.client = null;
|
|
3492
|
+
if (options.configs) {
|
|
3493
|
+
this._configs = options.configs;
|
|
3494
|
+
} else if (options.host && options.port && options.password) {
|
|
3495
|
+
this._legacyConfig = { host: options.host, port: options.port, password: options.password };
|
|
3496
|
+
} else {
|
|
3497
|
+
throw new Error("RedisCacheConnector: provide either { configs } for multi-env or { host, port, password } for single-env");
|
|
3317
3498
|
}
|
|
3318
3499
|
if (!this.env) {
|
|
3319
3500
|
throw new Error("Env must be provided in constructor options");
|
|
3320
3501
|
}
|
|
3502
|
+
_RedisCacheConnector.instance = this;
|
|
3321
3503
|
}
|
|
3322
3504
|
static getEnv() {
|
|
3323
3505
|
if (!_RedisCacheConnector.instance) {
|
|
@@ -3332,14 +3514,23 @@ var RedisCacheConnector = class _RedisCacheConnector {
|
|
|
3332
3514
|
}
|
|
3333
3515
|
return _RedisCacheConnector.instance;
|
|
3334
3516
|
}
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3517
|
+
/**
|
|
3518
|
+
* Get a Redis client.
|
|
3519
|
+
* @param {string} [env] - Optional env to get a specific env's client.
|
|
3520
|
+
* If omitted, returns the current env's client (backwards compat).
|
|
3521
|
+
*/
|
|
3522
|
+
static getClient(env) {
|
|
3523
|
+
const inst = _RedisCacheConnector.instance;
|
|
3524
|
+
if (!inst) {
|
|
3525
|
+
throw new Error("RedisCacheConnector not initialized or client not connected");
|
|
3526
|
+
}
|
|
3527
|
+
if (env && inst.clients[env]) {
|
|
3528
|
+
return inst.clients[env];
|
|
3341
3529
|
}
|
|
3342
|
-
|
|
3530
|
+
if (inst.client) {
|
|
3531
|
+
return inst.client;
|
|
3532
|
+
}
|
|
3533
|
+
throw new Error("RedisCacheConnector not initialized or client not connected");
|
|
3343
3534
|
}
|
|
3344
3535
|
/**
|
|
3345
3536
|
* Find documents in Redis cache
|
|
@@ -3353,8 +3544,8 @@ var RedisCacheConnector = class _RedisCacheConnector {
|
|
|
3353
3544
|
*/
|
|
3354
3545
|
static async findConfigsInCache({ tenant, modelName, type, env }) {
|
|
3355
3546
|
try {
|
|
3356
|
-
const client = this.getClient();
|
|
3357
3547
|
const environment = env || this.getEnv();
|
|
3548
|
+
const client = this.getClient(environment);
|
|
3358
3549
|
const keyPrefix = `${environment}:${tenant}:${modelName}:`;
|
|
3359
3550
|
const keys = await client.keys(`${keyPrefix}${type || "*"}`);
|
|
3360
3551
|
if (keys.length === 0) {
|
|
@@ -3419,12 +3610,6 @@ var RedisCacheConnector = class _RedisCacheConnector {
|
|
|
3419
3610
|
/**
|
|
3420
3611
|
* Generate Redis key for config caching
|
|
3421
3612
|
* @private
|
|
3422
|
-
* @param {Object} params - Parameters for key generation
|
|
3423
|
-
* @param {string} params.tenant - The tenant identifier
|
|
3424
|
-
* @param {'platformConfigs'|'tpl'} params.modelName - The model/collection name
|
|
3425
|
-
* @param {string} params.type - The document type
|
|
3426
|
-
* @param {string} [params.env] - Environment (defaults to current env)
|
|
3427
|
-
* @returns {string} The Redis key
|
|
3428
3613
|
*/
|
|
3429
3614
|
static _getRedisKeyForConfig({ tenant, modelName, type, env }) {
|
|
3430
3615
|
const environment = env || this.getEnv();
|
|
@@ -3442,12 +3627,13 @@ var RedisCacheConnector = class _RedisCacheConnector {
|
|
|
3442
3627
|
* @see {platformConfigTypes} for valid platformConfigs type values
|
|
3443
3628
|
*/
|
|
3444
3629
|
static async setOneConfigInCache({ tenant, modelName, type, val, env }) {
|
|
3445
|
-
const
|
|
3630
|
+
const environment = env || this.getEnv();
|
|
3631
|
+
const client = this.getClient(environment);
|
|
3446
3632
|
const cacheKey = this._getRedisKeyForConfig({
|
|
3447
3633
|
tenant,
|
|
3448
3634
|
modelName,
|
|
3449
3635
|
type,
|
|
3450
|
-
env
|
|
3636
|
+
env: environment
|
|
3451
3637
|
});
|
|
3452
3638
|
await client.set(cacheKey, JSON.stringify(val));
|
|
3453
3639
|
}
|
|
@@ -3473,12 +3659,13 @@ var RedisCacheConnector = class _RedisCacheConnector {
|
|
|
3473
3659
|
newVal,
|
|
3474
3660
|
env
|
|
3475
3661
|
}) {
|
|
3476
|
-
const
|
|
3662
|
+
const environment = env || this.getEnv();
|
|
3663
|
+
const client = this.getClient(environment);
|
|
3477
3664
|
const cacheKey = this._getRedisKeyForConfig({
|
|
3478
3665
|
tenant,
|
|
3479
3666
|
modelName,
|
|
3480
3667
|
type,
|
|
3481
|
-
env
|
|
3668
|
+
env: environment
|
|
3482
3669
|
});
|
|
3483
3670
|
const delResult = await client.del(cacheKey);
|
|
3484
3671
|
let setResult;
|
|
@@ -3503,8 +3690,8 @@ var RedisCacheConnector = class _RedisCacheConnector {
|
|
|
3503
3690
|
*/
|
|
3504
3691
|
static async loadTplsAndPlatformConfigsToCache({ tenant }) {
|
|
3505
3692
|
try {
|
|
3506
|
-
const client = this.getClient();
|
|
3507
3693
|
const environment = this.getEnv();
|
|
3694
|
+
const client = this.getClient(environment);
|
|
3508
3695
|
if (!tenant) throw new Error("No tenant/s defined to recache");
|
|
3509
3696
|
console.log(`Loading configs and templates into cache...`);
|
|
3510
3697
|
const tenantToClusterMapping = import_MongoConnector2.MongoConnector.getTenantToClusterMapping();
|
|
@@ -3554,14 +3741,21 @@ var RedisCacheConnector = class _RedisCacheConnector {
|
|
|
3554
3741
|
}
|
|
3555
3742
|
}
|
|
3556
3743
|
/**
|
|
3557
|
-
* Close
|
|
3744
|
+
* Close all Redis clients.
|
|
3558
3745
|
*/
|
|
3559
3746
|
async close() {
|
|
3560
|
-
|
|
3747
|
+
for (const [env, client] of Object.entries(this.clients)) {
|
|
3748
|
+
try {
|
|
3749
|
+
await client.quit();
|
|
3750
|
+
} catch (_) {
|
|
3751
|
+
}
|
|
3752
|
+
}
|
|
3753
|
+
if (this.client && !Object.values(this.clients).includes(this.client)) {
|
|
3561
3754
|
await this.client.quit();
|
|
3562
|
-
console.log("\u2705 Redis client closed");
|
|
3563
|
-
this.client = null;
|
|
3564
3755
|
}
|
|
3756
|
+
this.clients = {};
|
|
3757
|
+
this.client = null;
|
|
3758
|
+
console.log("\u2705 Redis client closed");
|
|
3565
3759
|
}
|
|
3566
3760
|
};
|
|
3567
3761
|
RedisCacheConnector.instance = null;
|
|
@@ -3589,6 +3783,7 @@ var export_ProducerManager = import_ProducerManager.ProducerManager;
|
|
|
3589
3783
|
var export_WorkerManager = import_WorkerManager.WorkerManager;
|
|
3590
3784
|
var export_getAIChatModelByTenant = import_getModelByTenant2.getAIChatModelByTenant;
|
|
3591
3785
|
var export_getAnnotationsModelByTenant = import_getModelByTenant2.getAnnotationsModelByTenant;
|
|
3786
|
+
var export_getGeneratedEntitiesModelByTenant = import_getModelByTenant2.getGeneratedEntitiesModelByTenant;
|
|
3592
3787
|
var export_getGeneratedTopicsModelByTenant = import_getModelByTenant2.getGeneratedTopicsModelByTenant;
|
|
3593
3788
|
var export_getModelByTenant = import_getModelByTenant2.getModelByTenant;
|
|
3594
3789
|
var export_getPlatformConfigsModelByTenant = import_getModelByTenant2.getPlatformConfigsModelByTenant;
|
|
@@ -3604,6 +3799,7 @@ export {
|
|
|
3604
3799
|
export_ElasticSearchConnector as ElasticSearchConnector,
|
|
3605
3800
|
FILTER_IDS,
|
|
3606
3801
|
export_GET_GLOBAL_BULLMQ_CONFIG as GET_GLOBAL_BULLMQ_CONFIG,
|
|
3802
|
+
GeneratedEntities_default as GeneratedEntitiesSchema,
|
|
3607
3803
|
GeneratedTopics_default as GeneratedTopicsSchema,
|
|
3608
3804
|
export_MongoConnector as MongoConnector,
|
|
3609
3805
|
PlatformConfigs_default as PlatformConfigsSchema,
|
|
@@ -3629,6 +3825,7 @@ export {
|
|
|
3629
3825
|
export_getAnnotationsModelByTenant as getAnnotationsModelByTenant,
|
|
3630
3826
|
getDbByTenant,
|
|
3631
3827
|
getFilterKeyForBlock,
|
|
3828
|
+
export_getGeneratedEntitiesModelByTenant as getGeneratedEntitiesModelByTenant,
|
|
3632
3829
|
export_getGeneratedTopicsModelByTenant as getGeneratedTopicsModelByTenant,
|
|
3633
3830
|
export_getModelByTenant as getModelByTenant,
|
|
3634
3831
|
export_getPlatformConfigsModelByTenant as getPlatformConfigsModelByTenant,
|
package/dist/universal.d.mts
CHANGED
|
@@ -502,7 +502,7 @@ declare namespace BASE_BULLMQ_CONFIG {
|
|
|
502
502
|
}
|
|
503
503
|
export { workerConfig_5 as workerConfig };
|
|
504
504
|
}
|
|
505
|
-
namespace
|
|
505
|
+
namespace SENTIMENT_AND_NER_QUEUE {
|
|
506
506
|
let id_6: string;
|
|
507
507
|
export { id_6 as id };
|
|
508
508
|
export namespace queueConfig_6 {
|
|
@@ -539,10 +539,17 @@ declare namespace BASE_BULLMQ_CONFIG {
|
|
|
539
539
|
export { lockDuration_6 as lockDuration };
|
|
540
540
|
let maxStalledCount_6: number;
|
|
541
541
|
export { maxStalledCount_6 as maxStalledCount };
|
|
542
|
+
export namespace limiter_3 {
|
|
543
|
+
let max_3: number;
|
|
544
|
+
export { max_3 as max };
|
|
545
|
+
let duration_3: number;
|
|
546
|
+
export { duration_3 as duration };
|
|
547
|
+
}
|
|
548
|
+
export { limiter_3 as limiter };
|
|
542
549
|
}
|
|
543
550
|
export { workerConfig_6 as workerConfig };
|
|
544
551
|
}
|
|
545
|
-
namespace
|
|
552
|
+
namespace AI_AUTO_ANNOTATE_QUEUE {
|
|
546
553
|
let id_7: string;
|
|
547
554
|
export { id_7 as id };
|
|
548
555
|
export namespace queueConfig_7 {
|
|
@@ -582,7 +589,7 @@ declare namespace BASE_BULLMQ_CONFIG {
|
|
|
582
589
|
}
|
|
583
590
|
export { workerConfig_7 as workerConfig };
|
|
584
591
|
}
|
|
585
|
-
namespace
|
|
592
|
+
namespace ANNOS_ELASTIC_SYNC_QUEUE {
|
|
586
593
|
let id_8: string;
|
|
587
594
|
export { id_8 as id };
|
|
588
595
|
export namespace queueConfig_8 {
|
|
@@ -622,7 +629,7 @@ declare namespace BASE_BULLMQ_CONFIG {
|
|
|
622
629
|
}
|
|
623
630
|
export { workerConfig_8 as workerConfig };
|
|
624
631
|
}
|
|
625
|
-
namespace
|
|
632
|
+
namespace CHUNKS_ELASTIC_SYNC_QUEUE {
|
|
626
633
|
let id_9: string;
|
|
627
634
|
export { id_9 as id };
|
|
628
635
|
export namespace queueConfig_9 {
|
|
@@ -662,7 +669,7 @@ declare namespace BASE_BULLMQ_CONFIG {
|
|
|
662
669
|
}
|
|
663
670
|
export { workerConfig_9 as workerConfig };
|
|
664
671
|
}
|
|
665
|
-
namespace
|
|
672
|
+
namespace CONTENT_ELASTIC_SYNC_QUEUE {
|
|
666
673
|
let id_10: string;
|
|
667
674
|
export { id_10 as id };
|
|
668
675
|
export namespace queueConfig_10 {
|
|
@@ -676,8 +683,6 @@ declare namespace BASE_BULLMQ_CONFIG {
|
|
|
676
683
|
export { delay_10 as delay };
|
|
677
684
|
}
|
|
678
685
|
export { backoff_10 as backoff };
|
|
679
|
-
let delay_11: number;
|
|
680
|
-
export { delay_11 as delay };
|
|
681
686
|
let removeOnComplete_10: number;
|
|
682
687
|
export { removeOnComplete_10 as removeOnComplete };
|
|
683
688
|
let removeOnFail_10: number;
|
|
@@ -704,6 +709,48 @@ declare namespace BASE_BULLMQ_CONFIG {
|
|
|
704
709
|
}
|
|
705
710
|
export { workerConfig_10 as workerConfig };
|
|
706
711
|
}
|
|
712
|
+
namespace REINDEX_QUEUE {
|
|
713
|
+
let id_11: string;
|
|
714
|
+
export { id_11 as id };
|
|
715
|
+
export namespace queueConfig_11 {
|
|
716
|
+
export namespace defaultJobOptions_11 {
|
|
717
|
+
let attempts_11: number;
|
|
718
|
+
export { attempts_11 as attempts };
|
|
719
|
+
export namespace backoff_11 {
|
|
720
|
+
let type_11: string;
|
|
721
|
+
export { type_11 as type };
|
|
722
|
+
let delay_11: number;
|
|
723
|
+
export { delay_11 as delay };
|
|
724
|
+
}
|
|
725
|
+
export { backoff_11 as backoff };
|
|
726
|
+
let delay_12: number;
|
|
727
|
+
export { delay_12 as delay };
|
|
728
|
+
let removeOnComplete_11: number;
|
|
729
|
+
export { removeOnComplete_11 as removeOnComplete };
|
|
730
|
+
let removeOnFail_11: number;
|
|
731
|
+
export { removeOnFail_11 as removeOnFail };
|
|
732
|
+
}
|
|
733
|
+
export { defaultJobOptions_11 as defaultJobOptions };
|
|
734
|
+
export namespace streams_11 {
|
|
735
|
+
export namespace events_11 {
|
|
736
|
+
let maxLen_11: number;
|
|
737
|
+
export { maxLen_11 as maxLen };
|
|
738
|
+
}
|
|
739
|
+
export { events_11 as events };
|
|
740
|
+
}
|
|
741
|
+
export { streams_11 as streams };
|
|
742
|
+
}
|
|
743
|
+
export { queueConfig_11 as queueConfig };
|
|
744
|
+
export namespace workerConfig_11 {
|
|
745
|
+
let concurrency_11: number;
|
|
746
|
+
export { concurrency_11 as concurrency };
|
|
747
|
+
let lockDuration_11: number;
|
|
748
|
+
export { lockDuration_11 as lockDuration };
|
|
749
|
+
let maxStalledCount_11: number;
|
|
750
|
+
export { maxStalledCount_11 as maxStalledCount };
|
|
751
|
+
}
|
|
752
|
+
export { workerConfig_11 as workerConfig };
|
|
753
|
+
}
|
|
707
754
|
}
|
|
708
755
|
|
|
709
756
|
interface PlatformContextContentItem {
|