@okf/ootils 1.3.3 → 1.3.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/browser.d.mts +128 -0
- package/dist/browser.d.ts +128 -0
- package/dist/browser.js +314 -0
- package/dist/browser.mjs +282 -0
- package/dist/{index.d.mts → node.d.mts} +127 -35
- package/dist/{index.d.ts → node.d.ts} +127 -35
- package/dist/{index.js → node.js} +282 -166
- package/dist/{index.mjs → node.mjs} +276 -161
- package/dist/universal.d.mts +128 -0
- package/dist/universal.d.ts +128 -0
- package/dist/universal.js +314 -0
- package/dist/universal.mjs +282 -0
- package/package.json +35 -5
|
@@ -314,12 +314,12 @@ var require_Tpl = __commonJS({
|
|
|
314
314
|
}
|
|
315
315
|
});
|
|
316
316
|
|
|
317
|
-
// src/
|
|
318
|
-
var
|
|
319
|
-
__export(
|
|
320
|
-
add: () => add,
|
|
317
|
+
// src/node.ts
|
|
318
|
+
var node_exports = {};
|
|
319
|
+
__export(node_exports, {
|
|
321
320
|
connectToRedis: () => connectToRedis,
|
|
322
321
|
deleteVal: () => deleteVal,
|
|
322
|
+
extractAllBlocksFromTpl: () => extractAllBlocksFromTpl,
|
|
323
323
|
genTagId: () => genTagId,
|
|
324
324
|
getAIConfigs: () => getAIConfigs,
|
|
325
325
|
getAnnotationsModelByTenant: () => getAnnotationsModelByTenant,
|
|
@@ -333,14 +333,285 @@ __export(index_exports, {
|
|
|
333
333
|
initializeGlobalConfig: () => initializeGlobalConfig,
|
|
334
334
|
multiConnectToMongoDB: () => multiConnectToMongoDB,
|
|
335
335
|
setVal: () => setVal,
|
|
336
|
+
toArray: () => toArray,
|
|
336
337
|
updateGlobalConfig: () => updateGlobalConfig
|
|
337
338
|
});
|
|
338
|
-
module.exports = __toCommonJS(
|
|
339
|
+
module.exports = __toCommonJS(node_exports);
|
|
339
340
|
|
|
340
|
-
// src/utils/
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
341
|
+
// src/utils/getterSetterDeleter/utils/set_deleteVal.ts
|
|
342
|
+
var set_deleteVal = (action, data, valuePath, value) => {
|
|
343
|
+
if (valuePath === void 0) return;
|
|
344
|
+
if (valuePath === null && action === "set") {
|
|
345
|
+
data = value;
|
|
346
|
+
return data;
|
|
347
|
+
}
|
|
348
|
+
let dataRef = data;
|
|
349
|
+
const keysArray = valuePath.split(".");
|
|
350
|
+
const len = keysArray.length;
|
|
351
|
+
let valIsUndefined = false;
|
|
352
|
+
for (let i = 0; i < len - 1; i++) {
|
|
353
|
+
const key = keysArray[i];
|
|
354
|
+
if (!dataRef[key]) {
|
|
355
|
+
if (action === "set") {
|
|
356
|
+
const nextKey = keysArray[i + 1];
|
|
357
|
+
if (nextKey && !isNaN(parseInt(nextKey))) {
|
|
358
|
+
dataRef[key] = [];
|
|
359
|
+
} else {
|
|
360
|
+
dataRef[key] = {};
|
|
361
|
+
}
|
|
362
|
+
} else {
|
|
363
|
+
valIsUndefined = true;
|
|
364
|
+
break;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
dataRef = dataRef[key];
|
|
368
|
+
}
|
|
369
|
+
if (valIsUndefined) return void 0;
|
|
370
|
+
if (action === "set") {
|
|
371
|
+
dataRef[keysArray[len - 1]] = value;
|
|
372
|
+
return data;
|
|
373
|
+
} else if (action === "delete") {
|
|
374
|
+
if (Array.isArray(dataRef)) {
|
|
375
|
+
dataRef.splice(parseInt(keysArray[len - 1]), 1);
|
|
376
|
+
} else {
|
|
377
|
+
delete dataRef[keysArray[len - 1]];
|
|
378
|
+
}
|
|
379
|
+
return data;
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
// src/utils/getterSetterDeleter/deleteVal.ts
|
|
384
|
+
var deleteVal = (data, valuePath) => {
|
|
385
|
+
return set_deleteVal("delete", data, valuePath);
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
// src/utils/getterSetterDeleter/setVal.ts
|
|
389
|
+
var setVal = (data, valuePath, value) => {
|
|
390
|
+
return set_deleteVal("set", data, valuePath, value);
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
// src/utils/getterSetterDeleter/utils/flattenArrayOfArrays.ts
|
|
394
|
+
var flattenArrayOfArrays = ({
|
|
395
|
+
array,
|
|
396
|
+
flattenLastArray = true,
|
|
397
|
+
toReturn = []
|
|
398
|
+
}) => {
|
|
399
|
+
array.map((ary) => {
|
|
400
|
+
if (Array.isArray(ary)) {
|
|
401
|
+
if (flattenLastArray === true) {
|
|
402
|
+
if (ary.some((childAry) => !Array.isArray(childAry))) {
|
|
403
|
+
toReturn.push(ary);
|
|
404
|
+
} else {
|
|
405
|
+
flattenArrayOfArrays({ array: ary, flattenLastArray, toReturn });
|
|
406
|
+
}
|
|
407
|
+
} else {
|
|
408
|
+
flattenArrayOfArrays({ array: ary, flattenLastArray, toReturn });
|
|
409
|
+
}
|
|
410
|
+
} else {
|
|
411
|
+
toReturn.push(ary);
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
return toReturn;
|
|
415
|
+
};
|
|
416
|
+
|
|
417
|
+
// src/utils/getterSetterDeleter/getVal.ts
|
|
418
|
+
var getVal = (data, valuePath, options = {}, depthIdx = 0) => {
|
|
419
|
+
let value = null;
|
|
420
|
+
const getFinalVal = (data2, valuePath2, options2, depthIdx2) => {
|
|
421
|
+
return Array.isArray(data2) ? data2.map((R) => getValV2_getter(R, valuePath2, options2, depthIdx2)) : getValV2_getter(data2, valuePath2, options2, depthIdx2);
|
|
422
|
+
};
|
|
423
|
+
if (Array.isArray(valuePath)) {
|
|
424
|
+
for (let i = 0; i < valuePath.length; i++) {
|
|
425
|
+
value = getFinalVal(data, valuePath[i], options, depthIdx);
|
|
426
|
+
if (value) break;
|
|
427
|
+
}
|
|
428
|
+
} else {
|
|
429
|
+
value = getFinalVal(data, valuePath, options, depthIdx);
|
|
430
|
+
}
|
|
431
|
+
return value;
|
|
432
|
+
};
|
|
433
|
+
var getValV2_getter = (data, valuePath, options, depthIdx) => {
|
|
434
|
+
const { flattenIfValueIsArray = true } = options;
|
|
435
|
+
if (valuePath === null) return data;
|
|
436
|
+
let dataRef = data;
|
|
437
|
+
const keysArray = valuePath.split(".");
|
|
438
|
+
const len = keysArray.length;
|
|
439
|
+
let valIsUndefined = false;
|
|
440
|
+
let thisIterationFoundAry = false;
|
|
441
|
+
for (let i = 0; i < len - 1; i++) {
|
|
442
|
+
const key = keysArray[i];
|
|
443
|
+
if (!thisIterationFoundAry) {
|
|
444
|
+
if (!dataRef[key]) {
|
|
445
|
+
valIsUndefined = true;
|
|
446
|
+
break;
|
|
447
|
+
}
|
|
448
|
+
dataRef = dataRef[key];
|
|
449
|
+
} else {
|
|
450
|
+
const nestedAryResponse = dataRef.map((dataRefItem) => {
|
|
451
|
+
const remainingValuePath = keysArray.filter((dd, ii) => ii >= i).join(".");
|
|
452
|
+
return getVal(dataRefItem, remainingValuePath, options, depthIdx + 1);
|
|
453
|
+
});
|
|
454
|
+
return flattenArrayOfArrays({
|
|
455
|
+
array: nestedAryResponse,
|
|
456
|
+
flattenLastArray: depthIdx === 0 && flattenIfValueIsArray === false ? false : true
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
if (Array.isArray(dataRef) && Number.isNaN(parseInt(keysArray[i + 1]))) thisIterationFoundAry = true;
|
|
460
|
+
}
|
|
461
|
+
if (valIsUndefined) return void 0;
|
|
462
|
+
if (thisIterationFoundAry) {
|
|
463
|
+
const toReturn = dataRef.map((d) => d[keysArray[len - 1]]);
|
|
464
|
+
return flattenArrayOfArrays({
|
|
465
|
+
array: toReturn,
|
|
466
|
+
flattenLastArray: flattenIfValueIsArray
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
return dataRef[keysArray[len - 1]];
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
// src/utils/genTagId.ts
|
|
473
|
+
var convertFromRichText = (value) => {
|
|
474
|
+
if (!value) return "";
|
|
475
|
+
let val = "";
|
|
476
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
477
|
+
return String(value);
|
|
478
|
+
}
|
|
479
|
+
if (typeof value === "object" && "blocks" in value && Array.isArray(value.blocks)) {
|
|
480
|
+
for (let i = 0; i < value.blocks.length; i++) {
|
|
481
|
+
const block = value.blocks[i];
|
|
482
|
+
if (block && block.text && block.text.length > 0) {
|
|
483
|
+
val = val + block.text;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
return val;
|
|
488
|
+
};
|
|
489
|
+
var genTagId = (tagName) => {
|
|
490
|
+
let toReturn = convertFromRichText(tagName);
|
|
491
|
+
const regex = /[^\p{L}\p{N}\+]+/gui;
|
|
492
|
+
toReturn = toReturn.trim().toLowerCase().replace(regex, "_");
|
|
493
|
+
toReturn = toReturn.replace(/\+/g, "plus");
|
|
494
|
+
return toReturn.replace(/^_+|_+$/, "");
|
|
495
|
+
};
|
|
496
|
+
|
|
497
|
+
// src/utils/toArray.ts
|
|
498
|
+
var toArray = (property) => {
|
|
499
|
+
if (!property && (property !== false && property !== 0)) return [];
|
|
500
|
+
if (Array.isArray(property)) return property;
|
|
501
|
+
return [property];
|
|
502
|
+
};
|
|
503
|
+
|
|
504
|
+
// src/utils/extractAllBlocksFromTpl.ts
|
|
505
|
+
var extractAllBlocksFromTpl = ({
|
|
506
|
+
tpl,
|
|
507
|
+
buildersWhitelist
|
|
508
|
+
}) => {
|
|
509
|
+
if (tpl.category === "userProfiles") {
|
|
510
|
+
const allBlocksAry = [];
|
|
511
|
+
if (tpl.kp_templates?.myProfileConfig) {
|
|
512
|
+
_recursExtractBlocks({
|
|
513
|
+
data: tpl.kp_templates.myProfileConfig,
|
|
514
|
+
cb: (block) => allBlocksAry.push(block),
|
|
515
|
+
sectionStack: [],
|
|
516
|
+
blockPathPrefix: "kp_templates.myProfileConfig"
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
return allBlocksAry;
|
|
520
|
+
} else {
|
|
521
|
+
return extractAllBlocksFromStructuredTpls({ tpl, buildersWhitelist });
|
|
522
|
+
}
|
|
523
|
+
};
|
|
524
|
+
var _recursExtractBlocks = ({
|
|
525
|
+
data,
|
|
526
|
+
cb,
|
|
527
|
+
sectionStack = [],
|
|
528
|
+
blockPathPrefix = ""
|
|
529
|
+
}) => {
|
|
530
|
+
data.forEach((d, idx) => {
|
|
531
|
+
if (!d.blocks) {
|
|
532
|
+
cb({
|
|
533
|
+
...d,
|
|
534
|
+
sectionStack,
|
|
535
|
+
blockPath: `${blockPathPrefix}.${idx}`
|
|
536
|
+
});
|
|
537
|
+
} else {
|
|
538
|
+
_recursExtractBlocks({
|
|
539
|
+
data: d.blocks,
|
|
540
|
+
cb,
|
|
541
|
+
sectionStack: [...sectionStack, d],
|
|
542
|
+
blockPathPrefix: `${blockPathPrefix}.${idx}.blocks`
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
});
|
|
546
|
+
};
|
|
547
|
+
var extractAllBlocksFromStructuredTpls = ({
|
|
548
|
+
tpl,
|
|
549
|
+
buildersWhitelist
|
|
550
|
+
}) => {
|
|
551
|
+
const allBlocksAry = [];
|
|
552
|
+
if (tpl.kp_templates) {
|
|
553
|
+
for (let spaceId in tpl.kp_templates) {
|
|
554
|
+
let conf = tpl.kp_templates[spaceId];
|
|
555
|
+
if (conf.builder && buildersWhitelist && !buildersWhitelist.includes(conf.builder)) {
|
|
556
|
+
continue;
|
|
557
|
+
}
|
|
558
|
+
if (!conf.subSpaces) {
|
|
559
|
+
_extractBlocksFromSomeBuilders({
|
|
560
|
+
conf,
|
|
561
|
+
confPath: `kp_templates.${spaceId}`,
|
|
562
|
+
allBlocksAry
|
|
563
|
+
});
|
|
564
|
+
} else {
|
|
565
|
+
conf.subSpaces.forEach((sub, subIdx) => {
|
|
566
|
+
if (sub.builder && buildersWhitelist && !buildersWhitelist.includes(sub.builder)) {
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
_extractBlocksFromSomeBuilders({
|
|
570
|
+
conf: sub,
|
|
571
|
+
confPath: `kp_templates.${spaceId}.subSpaces.${subIdx}`,
|
|
572
|
+
allBlocksAry
|
|
573
|
+
});
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
if (buildersWhitelist && !buildersWhitelist.includes("kp_settings")) {
|
|
579
|
+
return allBlocksAry;
|
|
580
|
+
}
|
|
581
|
+
if (tpl.kp_settings && tpl.kp_settings.length > 0) {
|
|
582
|
+
_recursExtractBlocks({
|
|
583
|
+
data: tpl.kp_settings,
|
|
584
|
+
cb: (block) => allBlocksAry.push(block),
|
|
585
|
+
blockPathPrefix: "kp_settings"
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
return allBlocksAry;
|
|
589
|
+
};
|
|
590
|
+
var _extractBlocksFromSomeBuilders = ({
|
|
591
|
+
conf,
|
|
592
|
+
confPath,
|
|
593
|
+
allBlocksAry
|
|
594
|
+
}) => {
|
|
595
|
+
if (conf.builder === "FormBuilder") {
|
|
596
|
+
const configs = conf.configs || [];
|
|
597
|
+
_recursExtractBlocks({
|
|
598
|
+
data: configs,
|
|
599
|
+
cb: (block) => allBlocksAry.push(block),
|
|
600
|
+
blockPathPrefix: `${confPath}.configs`
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
if (conf.builder === "MetaBuilder") {
|
|
604
|
+
const inputs = conf.configs?.inputs || {};
|
|
605
|
+
const inputBlockConfigsToPush = Object.keys(inputs).map((inputBlockKey) => {
|
|
606
|
+
const value = inputs[inputBlockKey];
|
|
607
|
+
return {
|
|
608
|
+
...value,
|
|
609
|
+
blockPath: `${confPath}.configs.inputs.${inputBlockKey}`
|
|
610
|
+
};
|
|
611
|
+
});
|
|
612
|
+
allBlocksAry.push(...inputBlockConfigsToPush);
|
|
613
|
+
}
|
|
614
|
+
};
|
|
344
615
|
|
|
345
616
|
// src/db/mongodb.ts
|
|
346
617
|
var import_mongoose = __toESM(require("mongoose"));
|
|
@@ -584,167 +855,11 @@ var getAIConfigs = async ({
|
|
|
584
855
|
}
|
|
585
856
|
});
|
|
586
857
|
};
|
|
587
|
-
|
|
588
|
-
// src/utils/getterSetterDeleter/utils/set_deleteVal.ts
|
|
589
|
-
var set_deleteVal = (action, data, valuePath, value) => {
|
|
590
|
-
if (valuePath === void 0) return;
|
|
591
|
-
if (valuePath === null && action === "set") {
|
|
592
|
-
data = value;
|
|
593
|
-
return data;
|
|
594
|
-
}
|
|
595
|
-
let dataRef = data;
|
|
596
|
-
const keysArray = valuePath.split(".");
|
|
597
|
-
const len = keysArray.length;
|
|
598
|
-
let valIsUndefined = false;
|
|
599
|
-
for (let i = 0; i < len - 1; i++) {
|
|
600
|
-
const key = keysArray[i];
|
|
601
|
-
if (!dataRef[key]) {
|
|
602
|
-
if (action === "set") {
|
|
603
|
-
const nextKey = keysArray[i + 1];
|
|
604
|
-
if (nextKey && !isNaN(parseInt(nextKey))) {
|
|
605
|
-
dataRef[key] = [];
|
|
606
|
-
} else {
|
|
607
|
-
dataRef[key] = {};
|
|
608
|
-
}
|
|
609
|
-
} else {
|
|
610
|
-
valIsUndefined = true;
|
|
611
|
-
break;
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
dataRef = dataRef[key];
|
|
615
|
-
}
|
|
616
|
-
if (valIsUndefined) return void 0;
|
|
617
|
-
if (action === "set") {
|
|
618
|
-
dataRef[keysArray[len - 1]] = value;
|
|
619
|
-
return data;
|
|
620
|
-
} else if (action === "delete") {
|
|
621
|
-
if (Array.isArray(dataRef)) {
|
|
622
|
-
dataRef.splice(parseInt(keysArray[len - 1]), 1);
|
|
623
|
-
} else {
|
|
624
|
-
delete dataRef[keysArray[len - 1]];
|
|
625
|
-
}
|
|
626
|
-
return data;
|
|
627
|
-
}
|
|
628
|
-
};
|
|
629
|
-
|
|
630
|
-
// src/utils/getterSetterDeleter/deleteVal.ts
|
|
631
|
-
var deleteVal = (data, valuePath) => {
|
|
632
|
-
return set_deleteVal("delete", data, valuePath);
|
|
633
|
-
};
|
|
634
|
-
|
|
635
|
-
// src/utils/getterSetterDeleter/setVal.ts
|
|
636
|
-
var setVal = (data, valuePath, value) => {
|
|
637
|
-
return set_deleteVal("set", data, valuePath, value);
|
|
638
|
-
};
|
|
639
|
-
|
|
640
|
-
// src/utils/getterSetterDeleter/utils/flattenArrayOfArrays.ts
|
|
641
|
-
var flattenArrayOfArrays = ({
|
|
642
|
-
array,
|
|
643
|
-
flattenLastArray = true,
|
|
644
|
-
toReturn = []
|
|
645
|
-
}) => {
|
|
646
|
-
array.map((ary) => {
|
|
647
|
-
if (Array.isArray(ary)) {
|
|
648
|
-
if (flattenLastArray === true) {
|
|
649
|
-
if (ary.some((childAry) => !Array.isArray(childAry))) {
|
|
650
|
-
toReturn.push(ary);
|
|
651
|
-
} else {
|
|
652
|
-
flattenArrayOfArrays({ array: ary, flattenLastArray, toReturn });
|
|
653
|
-
}
|
|
654
|
-
} else {
|
|
655
|
-
flattenArrayOfArrays({ array: ary, flattenLastArray, toReturn });
|
|
656
|
-
}
|
|
657
|
-
} else {
|
|
658
|
-
toReturn.push(ary);
|
|
659
|
-
}
|
|
660
|
-
});
|
|
661
|
-
return toReturn;
|
|
662
|
-
};
|
|
663
|
-
|
|
664
|
-
// src/utils/getterSetterDeleter/getVal.ts
|
|
665
|
-
var getVal = (data, valuePath, options = {}, depthIdx = 0) => {
|
|
666
|
-
let value = null;
|
|
667
|
-
const getFinalVal = (data2, valuePath2, options2, depthIdx2) => {
|
|
668
|
-
return Array.isArray(data2) ? data2.map((R) => getValV2_getter(R, valuePath2, options2, depthIdx2)) : getValV2_getter(data2, valuePath2, options2, depthIdx2);
|
|
669
|
-
};
|
|
670
|
-
if (Array.isArray(valuePath)) {
|
|
671
|
-
for (let i = 0; i < valuePath.length; i++) {
|
|
672
|
-
value = getFinalVal(data, valuePath[i], options, depthIdx);
|
|
673
|
-
if (value) break;
|
|
674
|
-
}
|
|
675
|
-
} else {
|
|
676
|
-
value = getFinalVal(data, valuePath, options, depthIdx);
|
|
677
|
-
}
|
|
678
|
-
return value;
|
|
679
|
-
};
|
|
680
|
-
var getValV2_getter = (data, valuePath, options, depthIdx) => {
|
|
681
|
-
const { flattenIfValueIsArray = true } = options;
|
|
682
|
-
if (valuePath === null) return data;
|
|
683
|
-
let dataRef = data;
|
|
684
|
-
const keysArray = valuePath.split(".");
|
|
685
|
-
const len = keysArray.length;
|
|
686
|
-
let valIsUndefined = false;
|
|
687
|
-
let thisIterationFoundAry = false;
|
|
688
|
-
for (let i = 0; i < len - 1; i++) {
|
|
689
|
-
const key = keysArray[i];
|
|
690
|
-
if (!thisIterationFoundAry) {
|
|
691
|
-
if (!dataRef[key]) {
|
|
692
|
-
valIsUndefined = true;
|
|
693
|
-
break;
|
|
694
|
-
}
|
|
695
|
-
dataRef = dataRef[key];
|
|
696
|
-
} else {
|
|
697
|
-
const nestedAryResponse = dataRef.map((dataRefItem) => {
|
|
698
|
-
const remainingValuePath = keysArray.filter((dd, ii) => ii >= i).join(".");
|
|
699
|
-
return getVal(dataRefItem, remainingValuePath, options, depthIdx + 1);
|
|
700
|
-
});
|
|
701
|
-
return flattenArrayOfArrays({
|
|
702
|
-
array: nestedAryResponse,
|
|
703
|
-
flattenLastArray: depthIdx === 0 && flattenIfValueIsArray === false ? false : true
|
|
704
|
-
});
|
|
705
|
-
}
|
|
706
|
-
if (Array.isArray(dataRef) && Number.isNaN(parseInt(keysArray[i + 1]))) thisIterationFoundAry = true;
|
|
707
|
-
}
|
|
708
|
-
if (valIsUndefined) return void 0;
|
|
709
|
-
if (thisIterationFoundAry) {
|
|
710
|
-
const toReturn = dataRef.map((d) => d[keysArray[len - 1]]);
|
|
711
|
-
return flattenArrayOfArrays({
|
|
712
|
-
array: toReturn,
|
|
713
|
-
flattenLastArray: flattenIfValueIsArray
|
|
714
|
-
});
|
|
715
|
-
}
|
|
716
|
-
return dataRef[keysArray[len - 1]];
|
|
717
|
-
};
|
|
718
|
-
|
|
719
|
-
// src/utils/genTagId.ts
|
|
720
|
-
var convertFromRichText = (value) => {
|
|
721
|
-
if (!value) return "";
|
|
722
|
-
let val = "";
|
|
723
|
-
if (typeof value === "string" || typeof value === "number") {
|
|
724
|
-
return String(value);
|
|
725
|
-
}
|
|
726
|
-
if (typeof value === "object" && "blocks" in value && Array.isArray(value.blocks)) {
|
|
727
|
-
for (let i = 0; i < value.blocks.length; i++) {
|
|
728
|
-
const block = value.blocks[i];
|
|
729
|
-
if (block && block.text && block.text.length > 0) {
|
|
730
|
-
val = val + block.text;
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
|
-
}
|
|
734
|
-
return val;
|
|
735
|
-
};
|
|
736
|
-
var genTagId = (tagName) => {
|
|
737
|
-
let toReturn = convertFromRichText(tagName);
|
|
738
|
-
const regex = /[^\p{L}\p{N}\+]+/gui;
|
|
739
|
-
toReturn = toReturn.trim().toLowerCase().replace(regex, "_");
|
|
740
|
-
toReturn = toReturn.replace(/\+/g, "plus");
|
|
741
|
-
return toReturn.replace(/^_+|_+$/, "");
|
|
742
|
-
};
|
|
743
858
|
// Annotate the CommonJS export names for ESM import in node:
|
|
744
859
|
0 && (module.exports = {
|
|
745
|
-
add,
|
|
746
860
|
connectToRedis,
|
|
747
861
|
deleteVal,
|
|
862
|
+
extractAllBlocksFromTpl,
|
|
748
863
|
genTagId,
|
|
749
864
|
getAIConfigs,
|
|
750
865
|
getAnnotationsModelByTenant,
|
|
@@ -758,5 +873,6 @@ var genTagId = (tagName) => {
|
|
|
758
873
|
initializeGlobalConfig,
|
|
759
874
|
multiConnectToMongoDB,
|
|
760
875
|
setVal,
|
|
876
|
+
toArray,
|
|
761
877
|
updateGlobalConfig
|
|
762
878
|
});
|