@okf/ootils 1.27.0 → 1.28.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.d.mts +106 -8
- package/dist/browser.d.ts +106 -8
- package/dist/browser.js +294 -11
- package/dist/browser.mjs +291 -10
- package/dist/node.d.mts +106 -8
- package/dist/node.d.ts +106 -8
- package/dist/node.js +294 -11
- package/dist/node.mjs +291 -10
- package/dist/universal.d.mts +106 -8
- package/dist/universal.d.ts +106 -8
- package/dist/universal.js +294 -11
- package/dist/universal.mjs +291 -10
- package/package.json +1 -1
package/dist/node.mjs
CHANGED
|
@@ -2607,6 +2607,7 @@ var buildFilterConfigurations = ({ groups, type, selectedTpls, allTpls, isRollup
|
|
|
2607
2607
|
filterKey,
|
|
2608
2608
|
contentType: element.contentType,
|
|
2609
2609
|
path: element.valuePath,
|
|
2610
|
+
...element.comp && { comp: element.comp },
|
|
2610
2611
|
source: {
|
|
2611
2612
|
filterType: "tplType",
|
|
2612
2613
|
contentType: element.contentType,
|
|
@@ -2632,6 +2633,7 @@ var buildFilterConfigurations = ({ groups, type, selectedTpls, allTpls, isRollup
|
|
|
2632
2633
|
filterKey: valuePathFilterKey,
|
|
2633
2634
|
contentType: element.contentType,
|
|
2634
2635
|
path: element.valuePath,
|
|
2636
|
+
...element.comp && { comp: element.comp },
|
|
2635
2637
|
source: {
|
|
2636
2638
|
filterType: "tplType",
|
|
2637
2639
|
contentType: element.contentType,
|
|
@@ -2657,6 +2659,7 @@ var buildFilterConfigurations = ({ groups, type, selectedTpls, allTpls, isRollup
|
|
|
2657
2659
|
filterKey: dateFilterKey,
|
|
2658
2660
|
contentType: element.contentType,
|
|
2659
2661
|
path: element.valuePath,
|
|
2662
|
+
...element.comp && { comp: element.comp },
|
|
2660
2663
|
source: { filterType: "dateRangeType" },
|
|
2661
2664
|
target: { filterType: "dateRangeType", valuePath: element.valuePath }
|
|
2662
2665
|
};
|
|
@@ -2674,6 +2677,7 @@ var buildFilterConfigurations = ({ groups, type, selectedTpls, allTpls, isRollup
|
|
|
2674
2677
|
filterKey: numberFilterKey,
|
|
2675
2678
|
contentType: element.contentType,
|
|
2676
2679
|
path: element.valuePath,
|
|
2680
|
+
...element.comp && { comp: element.comp },
|
|
2677
2681
|
source: { filterType: "numberRangeType", valuePath: element.valuePath },
|
|
2678
2682
|
target: { filterType: "numberRangeType", valuePath: element.valuePath }
|
|
2679
2683
|
};
|
|
@@ -2794,6 +2798,7 @@ var buildFilterConfigurations = ({ groups, type, selectedTpls, allTpls, isRollup
|
|
|
2794
2798
|
filterKey: tagFilterKey,
|
|
2795
2799
|
contentType: element.tagType,
|
|
2796
2800
|
path: `tags.${element.tagType}`,
|
|
2801
|
+
...element.comp && { comp: element.comp },
|
|
2797
2802
|
source: allProfileTpls.some(
|
|
2798
2803
|
(tpl) => tpl.kp_content_type === element.tagType
|
|
2799
2804
|
) ? {
|
|
@@ -2935,6 +2940,7 @@ var extractAndOrganizeBlocks = (selectedTpls, allTpls) => {
|
|
|
2935
2940
|
contentType: tpl.kp_content_type,
|
|
2936
2941
|
blocks: allBlocks.filter((block) => block.valuePath.startsWith("tags.")).map((block) => ({
|
|
2937
2942
|
tagType: block.props.tagType,
|
|
2943
|
+
comp: block.comp,
|
|
2938
2944
|
filterType: "tagType"
|
|
2939
2945
|
}))
|
|
2940
2946
|
};
|
|
@@ -2962,6 +2968,7 @@ var extractAndOrganizeBlocks = (selectedTpls, allTpls) => {
|
|
|
2962
2968
|
value: block.valuePath,
|
|
2963
2969
|
saveValueAsString: block.props?.saveValueAsString,
|
|
2964
2970
|
contentType: tpl.kp_content_type,
|
|
2971
|
+
comp: block.comp,
|
|
2965
2972
|
filterType: "valuePathType"
|
|
2966
2973
|
}))
|
|
2967
2974
|
};
|
|
@@ -2976,6 +2983,7 @@ var extractAndOrganizeBlocks = (selectedTpls, allTpls) => {
|
|
|
2976
2983
|
value: block.valuePath,
|
|
2977
2984
|
saveValueAsString: block.props?.saveValueAsString,
|
|
2978
2985
|
contentType: tpl.kp_content_type,
|
|
2986
|
+
comp: block.comp,
|
|
2979
2987
|
block,
|
|
2980
2988
|
filterType: "split_valuePathType"
|
|
2981
2989
|
}))
|
|
@@ -2990,6 +2998,7 @@ var extractAndOrganizeBlocks = (selectedTpls, allTpls) => {
|
|
|
2990
2998
|
display: block.props?.shortLabel || block.props?.label || block.valuePath,
|
|
2991
2999
|
value: block.valuePath,
|
|
2992
3000
|
contentType: tpl.kp_content_type,
|
|
3001
|
+
comp: block.comp,
|
|
2993
3002
|
filterType: "dateRangeType"
|
|
2994
3003
|
}))
|
|
2995
3004
|
};
|
|
@@ -3003,6 +3012,7 @@ var extractAndOrganizeBlocks = (selectedTpls, allTpls) => {
|
|
|
3003
3012
|
display: block.props?.shortLabel || block.props?.label || block.valuePath,
|
|
3004
3013
|
value: block.valuePath,
|
|
3005
3014
|
contentType: tpl.kp_content_type,
|
|
3015
|
+
comp: block.comp,
|
|
3006
3016
|
filterType: "numberRangeType"
|
|
3007
3017
|
}))
|
|
3008
3018
|
};
|
|
@@ -3249,6 +3259,240 @@ var _self_managed_buildAnnoHierarchyConfig = ({
|
|
|
3249
3259
|
};
|
|
3250
3260
|
};
|
|
3251
3261
|
|
|
3262
|
+
// src/utils/autoGenFilterConfigsFromTpl/utils/buildTagTypeParentMap.ts
|
|
3263
|
+
var buildTagTypeParentMap = (tagTypesInGroup, allTpls) => {
|
|
3264
|
+
const tagTypeSet = new Set(tagTypesInGroup);
|
|
3265
|
+
const parentMap = /* @__PURE__ */ new Map();
|
|
3266
|
+
for (const tagType of tagTypesInGroup) {
|
|
3267
|
+
const tpl = allTpls.find((t) => t.kp_content_type === tagType);
|
|
3268
|
+
if (!tpl) continue;
|
|
3269
|
+
const blocks = extractAllBlocksFromTpl({ tpl });
|
|
3270
|
+
const tagBlocks = blocks.filter(
|
|
3271
|
+
(block) => block.valuePath?.startsWith("tags.") && block.props?.tagType
|
|
3272
|
+
);
|
|
3273
|
+
for (const block of tagBlocks) {
|
|
3274
|
+
const referencedTagType = block.props.tagType;
|
|
3275
|
+
if (tagTypeSet.has(referencedTagType) && referencedTagType !== tagType) {
|
|
3276
|
+
parentMap.set(tagType, referencedTagType);
|
|
3277
|
+
break;
|
|
3278
|
+
}
|
|
3279
|
+
}
|
|
3280
|
+
}
|
|
3281
|
+
for (const child of parentMap.keys()) {
|
|
3282
|
+
const visited = /* @__PURE__ */ new Set();
|
|
3283
|
+
let current = child;
|
|
3284
|
+
while (current && parentMap.has(current)) {
|
|
3285
|
+
if (visited.has(current)) {
|
|
3286
|
+
parentMap.delete(current);
|
|
3287
|
+
break;
|
|
3288
|
+
}
|
|
3289
|
+
visited.add(current);
|
|
3290
|
+
current = parentMap.get(current);
|
|
3291
|
+
}
|
|
3292
|
+
}
|
|
3293
|
+
return parentMap;
|
|
3294
|
+
};
|
|
3295
|
+
var attachParentFields = (filters, allTpls) => {
|
|
3296
|
+
const tagTypeFilters = filters.filter(
|
|
3297
|
+
(f) => f.source?.filterType === "tagType" && f.source?.tagType
|
|
3298
|
+
);
|
|
3299
|
+
if (tagTypeFilters.length === 0) return filters;
|
|
3300
|
+
const tagTypesInGroup = tagTypeFilters.map((f) => f.source.tagType);
|
|
3301
|
+
const parentMap = buildTagTypeParentMap(tagTypesInGroup, allTpls);
|
|
3302
|
+
if (parentMap.size === 0) return filters;
|
|
3303
|
+
const tagTypeToFilterId = /* @__PURE__ */ new Map();
|
|
3304
|
+
for (const f of tagTypeFilters) {
|
|
3305
|
+
tagTypeToFilterId.set(f.source.tagType, f.filterId);
|
|
3306
|
+
}
|
|
3307
|
+
return filters.map((f) => {
|
|
3308
|
+
if (f.source?.filterType !== "tagType" || !f.source?.tagType) return f;
|
|
3309
|
+
const parentTagType = parentMap.get(f.source.tagType);
|
|
3310
|
+
if (!parentTagType) return f;
|
|
3311
|
+
const parentFilterId = tagTypeToFilterId.get(parentTagType);
|
|
3312
|
+
if (!parentFilterId) return f;
|
|
3313
|
+
return { ...f, parentFilterId };
|
|
3314
|
+
});
|
|
3315
|
+
};
|
|
3316
|
+
var sortFiltersHierarchically = (filters) => {
|
|
3317
|
+
if (filters.length <= 1) return filters;
|
|
3318
|
+
const hasHierarchy = filters.some((f) => f.parentFilterId);
|
|
3319
|
+
if (!hasHierarchy) return filters;
|
|
3320
|
+
const childrenOf = /* @__PURE__ */ new Map();
|
|
3321
|
+
const roots = [];
|
|
3322
|
+
for (const f of filters) {
|
|
3323
|
+
if (!f.parentFilterId) {
|
|
3324
|
+
roots.push(f);
|
|
3325
|
+
} else {
|
|
3326
|
+
const siblings = childrenOf.get(f.parentFilterId) || [];
|
|
3327
|
+
siblings.push(f);
|
|
3328
|
+
childrenOf.set(f.parentFilterId, siblings);
|
|
3329
|
+
}
|
|
3330
|
+
}
|
|
3331
|
+
const sorted = [];
|
|
3332
|
+
const visited = /* @__PURE__ */ new Set();
|
|
3333
|
+
const visit = (filter) => {
|
|
3334
|
+
if (visited.has(filter.filterId)) return;
|
|
3335
|
+
visited.add(filter.filterId);
|
|
3336
|
+
sorted.push(filter);
|
|
3337
|
+
const children = childrenOf.get(filter.filterId) || [];
|
|
3338
|
+
for (const child of children) {
|
|
3339
|
+
visit(child);
|
|
3340
|
+
}
|
|
3341
|
+
};
|
|
3342
|
+
for (const root of roots) {
|
|
3343
|
+
visit(root);
|
|
3344
|
+
}
|
|
3345
|
+
for (const f of filters) {
|
|
3346
|
+
if (!visited.has(f.filterId)) {
|
|
3347
|
+
sorted.push(f);
|
|
3348
|
+
}
|
|
3349
|
+
}
|
|
3350
|
+
return sorted;
|
|
3351
|
+
};
|
|
3352
|
+
|
|
3353
|
+
// src/utils/autoGenFilterConfigsFromTpl/utils/_self_managed_buildDocHierarchyConfig.ts
|
|
3354
|
+
var _self_managed_buildDocHierarchyConfig = ({
|
|
3355
|
+
combinedDocumentBlocks,
|
|
3356
|
+
docRollupBlocks,
|
|
3357
|
+
selectedTpls,
|
|
3358
|
+
allTpls,
|
|
3359
|
+
commonDocumentFilters,
|
|
3360
|
+
flatDocFilters = false
|
|
3361
|
+
}) => {
|
|
3362
|
+
const allGroups = compareAndGroupBlocks(combinedDocumentBlocks);
|
|
3363
|
+
const commonGroup = allGroups.find(
|
|
3364
|
+
(g) => g.contentTypes.length === selectedTpls.length
|
|
3365
|
+
);
|
|
3366
|
+
const commonFilterConfigs = commonGroup ? sortFiltersHierarchically(
|
|
3367
|
+
attachParentFields(
|
|
3368
|
+
buildFilterConfigurations({
|
|
3369
|
+
groups: [commonGroup],
|
|
3370
|
+
type: "tags",
|
|
3371
|
+
selectedTpls,
|
|
3372
|
+
allTpls,
|
|
3373
|
+
isRollup: false,
|
|
3374
|
+
isAnno: false
|
|
3375
|
+
}).flatMap((s) => s.configs),
|
|
3376
|
+
allTpls
|
|
3377
|
+
)
|
|
3378
|
+
) : [];
|
|
3379
|
+
const multiDatasetGroups = selectedTpls.length >= 2 ? allGroups.filter(
|
|
3380
|
+
(g) => g.contentTypes.length > 1 && g.contentTypes.length < selectedTpls.length
|
|
3381
|
+
) : [];
|
|
3382
|
+
const sharedAcrossMultiple = multiDatasetGroups.map((group) => {
|
|
3383
|
+
const groupFilterConfigs = sortFiltersHierarchically(
|
|
3384
|
+
attachParentFields(
|
|
3385
|
+
buildFilterConfigurations({
|
|
3386
|
+
groups: [group],
|
|
3387
|
+
type: "tags",
|
|
3388
|
+
selectedTpls,
|
|
3389
|
+
allTpls,
|
|
3390
|
+
isRollup: false,
|
|
3391
|
+
isAnno: false
|
|
3392
|
+
}).flatMap((s) => s.configs),
|
|
3393
|
+
allTpls
|
|
3394
|
+
)
|
|
3395
|
+
);
|
|
3396
|
+
const display = group.contentTypes.map((ct) => {
|
|
3397
|
+
const tplData = allTpls.find(
|
|
3398
|
+
(t) => t.kp_content_type === ct
|
|
3399
|
+
);
|
|
3400
|
+
return tplData?.general?.content?.title || ct;
|
|
3401
|
+
}).join(" + ");
|
|
3402
|
+
return {
|
|
3403
|
+
contentTypes: group.contentTypes,
|
|
3404
|
+
display,
|
|
3405
|
+
filters: groupFilterConfigs
|
|
3406
|
+
};
|
|
3407
|
+
}).filter((g) => g.filters.length > 0);
|
|
3408
|
+
const commonFilterIds = new Set(commonFilterConfigs.map((f) => f.filterId));
|
|
3409
|
+
const perDataset = selectedTpls.map((tpl) => {
|
|
3410
|
+
const tplBlocks = combinedDocumentBlocks.find(
|
|
3411
|
+
(b) => b.contentType === tpl.kp_content_type
|
|
3412
|
+
);
|
|
3413
|
+
const singleTplGroup = [
|
|
3414
|
+
{
|
|
3415
|
+
contentTypes: [tpl.kp_content_type],
|
|
3416
|
+
elements: tplBlocks?.blocks || []
|
|
3417
|
+
}
|
|
3418
|
+
];
|
|
3419
|
+
const filters = buildFilterConfigurations({
|
|
3420
|
+
groups: singleTplGroup,
|
|
3421
|
+
type: "tags",
|
|
3422
|
+
selectedTpls: [tpl],
|
|
3423
|
+
allTpls,
|
|
3424
|
+
isRollup: false,
|
|
3425
|
+
isAnno: false
|
|
3426
|
+
}).flatMap((s) => s.configs);
|
|
3427
|
+
const filtersWithCommonFlag = filters.map((f) => ({
|
|
3428
|
+
...f,
|
|
3429
|
+
isSharedFilter: commonFilterIds.has(f.filterId)
|
|
3430
|
+
}));
|
|
3431
|
+
const rollupData = docRollupBlocks?.find(
|
|
3432
|
+
(b) => b.contentType === tpl.kp_content_type
|
|
3433
|
+
);
|
|
3434
|
+
const rollupGroups = rollupData?.blocks?.length ? compareAndGroupBlocks([rollupData]) : [];
|
|
3435
|
+
const rollupConfigs = rollupGroups.length ? buildFilterConfigurations({
|
|
3436
|
+
groups: rollupGroups,
|
|
3437
|
+
type: "tags",
|
|
3438
|
+
selectedTpls: [tpl],
|
|
3439
|
+
allTpls,
|
|
3440
|
+
isRollup: true,
|
|
3441
|
+
isAnno: false
|
|
3442
|
+
}).flatMap((s) => s.configs) : [];
|
|
3443
|
+
const tplData = allTpls.find(
|
|
3444
|
+
(t) => t.kp_content_type === tpl.kp_content_type
|
|
3445
|
+
);
|
|
3446
|
+
const rollupSourceKeys = new Set(
|
|
3447
|
+
rollupConfigs.map((r) => JSON.stringify(r.source))
|
|
3448
|
+
);
|
|
3449
|
+
const dedupedFilters = filtersWithCommonFlag.filter(
|
|
3450
|
+
(f) => !rollupSourceKeys.has(JSON.stringify(f.source))
|
|
3451
|
+
);
|
|
3452
|
+
const combined = [...dedupedFilters, ...rollupConfigs];
|
|
3453
|
+
const combinedWithParents = sortFiltersHierarchically(
|
|
3454
|
+
attachParentFields(combined, allTpls)
|
|
3455
|
+
);
|
|
3456
|
+
const rollupFilterIds = new Set(rollupConfigs.map((r) => r.filterId));
|
|
3457
|
+
const filtersWithParents = combinedWithParents.filter(
|
|
3458
|
+
(f) => !rollupFilterIds.has(f.filterId)
|
|
3459
|
+
);
|
|
3460
|
+
const rollupsWithParents = combinedWithParents.filter(
|
|
3461
|
+
(f) => rollupFilterIds.has(f.filterId)
|
|
3462
|
+
);
|
|
3463
|
+
return {
|
|
3464
|
+
contentType: tpl.kp_content_type,
|
|
3465
|
+
display: tplData?.general?.content?.title || tpl.kp_content_type,
|
|
3466
|
+
filters: filtersWithParents,
|
|
3467
|
+
rollups: rollupsWithParents
|
|
3468
|
+
};
|
|
3469
|
+
});
|
|
3470
|
+
const filteredPerDataset = perDataset.filter(
|
|
3471
|
+
(d) => d.filters.length > 0 || d.rollups.length > 0
|
|
3472
|
+
);
|
|
3473
|
+
if (commonFilterConfigs.length === 0 && sharedAcrossMultiple.length === 0 && filteredPerDataset.every((d) => d.filters.length === 0)) {
|
|
3474
|
+
return null;
|
|
3475
|
+
}
|
|
3476
|
+
const flatCommonDocFilters = commonDocumentFilters.flatMap(
|
|
3477
|
+
(s) => s.configs || [s]
|
|
3478
|
+
);
|
|
3479
|
+
const shouldFlatten = flatDocFilters && selectedTpls.length === 1;
|
|
3480
|
+
return {
|
|
3481
|
+
filterId: "docHierarchy_document_filters",
|
|
3482
|
+
display: "Combined Content Filters",
|
|
3483
|
+
filterKey: "docHierarchyType::doc",
|
|
3484
|
+
source: {
|
|
3485
|
+
filterType: "docHierarchyType",
|
|
3486
|
+
flatDocFilters: shouldFlatten,
|
|
3487
|
+
commonFilters: commonFilterConfigs,
|
|
3488
|
+
sharedAcrossMultiple,
|
|
3489
|
+
commonDocumentFilters: flatCommonDocFilters,
|
|
3490
|
+
perDataset: filteredPerDataset
|
|
3491
|
+
},
|
|
3492
|
+
target: { filterType: "docHierarchyType" }
|
|
3493
|
+
};
|
|
3494
|
+
};
|
|
3495
|
+
|
|
3252
3496
|
// src/utils/autoGenFilterConfigsFromTpl/utils/TEMP_removeDuplicateFilters.ts
|
|
3253
3497
|
var TEMP_removeDuplicateFilters = (filterGroups) => {
|
|
3254
3498
|
return filterGroups.map((group) => {
|
|
@@ -3385,7 +3629,25 @@ var autoGenFilterConfigsFromTpl = ({
|
|
|
3385
3629
|
...annotationRollupSections
|
|
3386
3630
|
].filter((section) => Array.isArray(section.configs) ? section.configs.length > 0 : true)
|
|
3387
3631
|
};
|
|
3388
|
-
const
|
|
3632
|
+
const isSMTDocFilterUI = isSelfManagedTenant && filterScopes.includes("doc");
|
|
3633
|
+
const final_documentTagsFilterConfigs = isSMTDocFilterUI ? (() => {
|
|
3634
|
+
const docHierarchyConfig = _self_managed_buildDocHierarchyConfig({
|
|
3635
|
+
combinedDocumentBlocks: extractedBlocks.combinedDocumentBlocks,
|
|
3636
|
+
docRollupBlocks: extractedBlocks.docRollupBlocks,
|
|
3637
|
+
selectedTpls,
|
|
3638
|
+
allTpls,
|
|
3639
|
+
commonDocumentFilters
|
|
3640
|
+
});
|
|
3641
|
+
if (!docHierarchyConfig) return { sectionId: "documentTagsSection", sectionTitle: "Document Filters", configs: [] };
|
|
3642
|
+
return {
|
|
3643
|
+
sectionId: "documentTagsSection",
|
|
3644
|
+
// sectionTitle: 'Document Filters',
|
|
3645
|
+
configs: [{
|
|
3646
|
+
sectionId: "self_managed_consolidated_doc_filters",
|
|
3647
|
+
configs: [docHierarchyConfig]
|
|
3648
|
+
}]
|
|
3649
|
+
};
|
|
3650
|
+
})() : {
|
|
3389
3651
|
sectionId: "documentTagsSection",
|
|
3390
3652
|
sectionTitle: "Document Filters",
|
|
3391
3653
|
configs: [
|
|
@@ -3401,20 +3663,33 @@ var autoGenFilterConfigsFromTpl = ({
|
|
|
3401
3663
|
};
|
|
3402
3664
|
|
|
3403
3665
|
// src/utils/genCleanCamelCaseId.ts
|
|
3404
|
-
var genCleanCamelCaseId = (id) => {
|
|
3666
|
+
var genCleanCamelCaseId = (id, options) => {
|
|
3405
3667
|
if (!id || typeof id !== "string") return id;
|
|
3406
|
-
const
|
|
3407
|
-
|
|
3668
|
+
const { stripNonAlphanumeric = false, maxLength } = options || {};
|
|
3669
|
+
const baseClean = /^\p{Ll}[\p{L}\p{N}]*$/u.test(id) || /^a\d[\p{L}\p{N}]*$/u.test(id);
|
|
3670
|
+
const withinMaxLength = maxLength ? id.length <= maxLength : true;
|
|
3671
|
+
const hasNoNonAlpha = stripNonAlphanumeric ? /^[a-zA-Z0-9]+$/.test(id) : true;
|
|
3672
|
+
if (baseClean && withinMaxLength && hasNoNonAlpha) return id;
|
|
3408
3673
|
const words = id.split(/[^\p{L}\p{N}]+/u).filter(Boolean);
|
|
3409
3674
|
if (words.length === 0) return "a";
|
|
3410
|
-
|
|
3675
|
+
let result = words.map((word, i) => {
|
|
3411
3676
|
const lower = word.toLowerCase();
|
|
3412
3677
|
return i === 0 ? lower : lower.charAt(0).toUpperCase() + lower.slice(1);
|
|
3413
3678
|
}).join("");
|
|
3414
|
-
|
|
3679
|
+
if (/^\d/.test(result)) result = "a" + result;
|
|
3680
|
+
if (stripNonAlphanumeric) {
|
|
3681
|
+
result = result.replace(/[^a-zA-Z0-9]/g, "");
|
|
3682
|
+
}
|
|
3683
|
+
if (maxLength) {
|
|
3684
|
+
result = result.slice(0, maxLength);
|
|
3685
|
+
}
|
|
3686
|
+
return result;
|
|
3415
3687
|
};
|
|
3416
3688
|
|
|
3417
|
-
// src/utils/
|
|
3689
|
+
// src/utils/genCleanContentTypeId.ts
|
|
3690
|
+
var genCleanContentTypeId = (text) => genCleanCamelCaseId(text, { stripNonAlphanumeric: true, maxLength: 40 });
|
|
3691
|
+
|
|
3692
|
+
// src/utils/genCleanValuePath.ts
|
|
3418
3693
|
var CHARS = "abcdefghijklmnopqrstuvwxyz0123456789";
|
|
3419
3694
|
function genShortId(length = 4) {
|
|
3420
3695
|
let result = "";
|
|
@@ -3423,11 +3698,15 @@ function genShortId(length = 4) {
|
|
|
3423
3698
|
}
|
|
3424
3699
|
return result;
|
|
3425
3700
|
}
|
|
3426
|
-
var
|
|
3701
|
+
var genCleanValuePath = (text) => {
|
|
3702
|
+
const maxLength = 10;
|
|
3703
|
+
const shortIdLength = 4;
|
|
3427
3704
|
if (!text || typeof text !== "string") return text;
|
|
3705
|
+
const idempotencyPattern = new RegExp(`^[a-z][a-z0-9]*_[a-z0-9]{${shortIdLength}}$`);
|
|
3706
|
+
if (idempotencyPattern.test(text)) return text;
|
|
3428
3707
|
let cleaned = text.replace(/[^a-zA-Z0-9]/g, "").toLowerCase();
|
|
3429
3708
|
if (!cleaned) {
|
|
3430
|
-
throw new Error(`[
|
|
3709
|
+
throw new Error(`[genCleanValuePath] Input "${text}" contains no alphanumeric characters`);
|
|
3431
3710
|
}
|
|
3432
3711
|
if (/^\d/.test(cleaned)) cleaned = "a" + cleaned;
|
|
3433
3712
|
const truncated = cleaned.slice(0, maxLength);
|
|
@@ -3856,6 +4135,7 @@ export {
|
|
|
3856
4135
|
UI_CONTENT,
|
|
3857
4136
|
export_WorkerManager as WorkerManager,
|
|
3858
4137
|
_self_managed_buildAnnoHierarchyConfig,
|
|
4138
|
+
_self_managed_buildDocHierarchyConfig,
|
|
3859
4139
|
_self_managed_getFixedAnnoRollupBlocks,
|
|
3860
4140
|
_self_managed_getFixedAnnoTagBlock,
|
|
3861
4141
|
autoGenFilterConfigsFromTpl,
|
|
@@ -3865,7 +4145,8 @@ export {
|
|
|
3865
4145
|
extractAllBlocksFromTpl,
|
|
3866
4146
|
extractAndOrganizeBlocks,
|
|
3867
4147
|
genCleanCamelCaseId,
|
|
3868
|
-
|
|
4148
|
+
genCleanContentTypeId,
|
|
4149
|
+
genCleanValuePath,
|
|
3869
4150
|
genTagId,
|
|
3870
4151
|
generateFilterKey,
|
|
3871
4152
|
export_getAIChatModelByTenant as getAIChatModelByTenant,
|
package/dist/universal.d.mts
CHANGED
|
@@ -1020,6 +1020,51 @@ declare const _self_managed_buildAnnoHierarchyConfig: ({ annotationTagsCount, }:
|
|
|
1020
1020
|
};
|
|
1021
1021
|
} | null;
|
|
1022
1022
|
|
|
1023
|
+
/**
|
|
1024
|
+
* Builds a consolidated docHierarchyType config for self-managed tenants.
|
|
1025
|
+
*
|
|
1026
|
+
* Produces a single filter config that contains:
|
|
1027
|
+
* - commonFilters: filters present in ALL selected templates
|
|
1028
|
+
* - sharedAcrossMultiple: groups of filters shared by 2+ (but not all) templates
|
|
1029
|
+
* - perDataset: each template's complete filter list + rollup configs
|
|
1030
|
+
* - commonDocumentFilters: Author, Published Date, etc.
|
|
1031
|
+
*
|
|
1032
|
+
* This is consumed by DocHierarchyFilter on the frontend to render the
|
|
1033
|
+
* drilldown-based document filter UI.
|
|
1034
|
+
*/
|
|
1035
|
+
declare const _self_managed_buildDocHierarchyConfig: ({ combinedDocumentBlocks, docRollupBlocks, selectedTpls, allTpls, commonDocumentFilters, flatDocFilters, }: {
|
|
1036
|
+
combinedDocumentBlocks: any[];
|
|
1037
|
+
docRollupBlocks: any[];
|
|
1038
|
+
selectedTpls: any[];
|
|
1039
|
+
allTpls: any[];
|
|
1040
|
+
commonDocumentFilters: any[];
|
|
1041
|
+
flatDocFilters?: boolean;
|
|
1042
|
+
}) => {
|
|
1043
|
+
filterId: string;
|
|
1044
|
+
display: string;
|
|
1045
|
+
filterKey: string;
|
|
1046
|
+
source: {
|
|
1047
|
+
filterType: string;
|
|
1048
|
+
flatDocFilters: boolean;
|
|
1049
|
+
commonFilters: any[];
|
|
1050
|
+
sharedAcrossMultiple: {
|
|
1051
|
+
contentTypes: any;
|
|
1052
|
+
display: any;
|
|
1053
|
+
filters: any[];
|
|
1054
|
+
}[];
|
|
1055
|
+
commonDocumentFilters: any[];
|
|
1056
|
+
perDataset: {
|
|
1057
|
+
contentType: any;
|
|
1058
|
+
display: any;
|
|
1059
|
+
filters: any[];
|
|
1060
|
+
rollups: any[];
|
|
1061
|
+
}[];
|
|
1062
|
+
};
|
|
1063
|
+
target: {
|
|
1064
|
+
filterType: string;
|
|
1065
|
+
};
|
|
1066
|
+
} | null;
|
|
1067
|
+
|
|
1023
1068
|
/**
|
|
1024
1069
|
* TEMP_removeDuplicateFilters - Removes duplicate rollup and tag-type filters
|
|
1025
1070
|
*
|
|
@@ -1114,6 +1159,37 @@ declare const autoGenFilterConfigsFromTpl: ({ selectedTpls, allTpls, filterScope
|
|
|
1114
1159
|
sectionId: string;
|
|
1115
1160
|
configs: any[];
|
|
1116
1161
|
}[];
|
|
1162
|
+
} | {
|
|
1163
|
+
sectionId: string;
|
|
1164
|
+
configs: {
|
|
1165
|
+
sectionId: string;
|
|
1166
|
+
configs: {
|
|
1167
|
+
filterId: string;
|
|
1168
|
+
display: string;
|
|
1169
|
+
filterKey: string;
|
|
1170
|
+
source: {
|
|
1171
|
+
filterType: string;
|
|
1172
|
+
flatDocFilters: boolean;
|
|
1173
|
+
commonFilters: any[];
|
|
1174
|
+
sharedAcrossMultiple: {
|
|
1175
|
+
contentTypes: any;
|
|
1176
|
+
display: any;
|
|
1177
|
+
filters: any[];
|
|
1178
|
+
}[];
|
|
1179
|
+
commonDocumentFilters: any[];
|
|
1180
|
+
perDataset: {
|
|
1181
|
+
contentType: any;
|
|
1182
|
+
display: any;
|
|
1183
|
+
filters: any[];
|
|
1184
|
+
rollups: any[];
|
|
1185
|
+
}[];
|
|
1186
|
+
};
|
|
1187
|
+
target: {
|
|
1188
|
+
filterType: string;
|
|
1189
|
+
};
|
|
1190
|
+
}[];
|
|
1191
|
+
}[];
|
|
1192
|
+
sectionTitle?: undefined;
|
|
1117
1193
|
} | {
|
|
1118
1194
|
sectionId: string;
|
|
1119
1195
|
sectionTitle: string;
|
|
@@ -1184,11 +1260,30 @@ declare const UI_CONTENT: {
|
|
|
1184
1260
|
};
|
|
1185
1261
|
};
|
|
1186
1262
|
|
|
1187
|
-
|
|
1263
|
+
interface GenCleanCamelCaseIdOptions {
|
|
1264
|
+
/** Strip all non-alphanumeric chars (A-Z, a-z, 0-9 only). Default: false */
|
|
1265
|
+
stripNonAlphanumeric?: boolean;
|
|
1266
|
+
/** Truncate result to this max length. Default: no limit */
|
|
1267
|
+
maxLength?: number;
|
|
1268
|
+
}
|
|
1269
|
+
declare const genCleanCamelCaseId: (id: string, options?: GenCleanCamelCaseIdOptions) => string;
|
|
1270
|
+
|
|
1271
|
+
/**
|
|
1272
|
+
* Generates a clean, deterministic contentType ID from text.
|
|
1273
|
+
* Wraps genCleanCamelCaseId with stripNonAlphanumeric + maxLength 40.
|
|
1274
|
+
*
|
|
1275
|
+
* Idempotent: running twice produces the same output.
|
|
1276
|
+
*
|
|
1277
|
+
* @example
|
|
1278
|
+
* genCleanContentTypeId("My Articles!") => "myArticles"
|
|
1279
|
+
* genCleanContentTypeId("myArticles") => "myArticles" (idempotent)
|
|
1280
|
+
* genCleanContentTypeId("123 Test") => "a123Test"
|
|
1281
|
+
*/
|
|
1282
|
+
declare const genCleanContentTypeId: (text: string) => string;
|
|
1188
1283
|
|
|
1189
1284
|
/**
|
|
1190
1285
|
* Generates a clean, short, unique ID from text input.
|
|
1191
|
-
* Used for
|
|
1286
|
+
* Used for block valuePaths in templates.
|
|
1192
1287
|
*
|
|
1193
1288
|
* 1. Strips all characters except A-Z, a-z, 0-9
|
|
1194
1289
|
* 2. Lowercases the result
|
|
@@ -1196,15 +1291,18 @@ declare const genCleanCamelCaseId: (id: string) => string;
|
|
|
1196
1291
|
* 4. Truncates to maxLength (default 10)
|
|
1197
1292
|
* 5. Appends _{random id} (default 4 chars)
|
|
1198
1293
|
*
|
|
1294
|
+
* Idempotent: if input already matches the output pattern
|
|
1295
|
+
* (lowercase alphanumeric + _hash suffix), returns as-is.
|
|
1296
|
+
*
|
|
1199
1297
|
* @param text - The input text to convert
|
|
1200
|
-
* @param maxLength - Max characters before the random suffix (default 10
|
|
1298
|
+
* @param maxLength - Max characters before the random suffix (default 10)
|
|
1201
1299
|
* @param shortIdLength - Length of the random suffix (default 4)
|
|
1202
1300
|
*
|
|
1203
1301
|
* @example
|
|
1204
|
-
*
|
|
1205
|
-
*
|
|
1206
|
-
*
|
|
1302
|
+
* genCleanValuePath("Author Name") => "authorname_x7k2"
|
|
1303
|
+
* genCleanValuePath("authorname_x7k2") => "authorname_x7k2" (idempotent)
|
|
1304
|
+
* genCleanValuePath("123 Test") => "a123test_ab4d"
|
|
1207
1305
|
*/
|
|
1208
|
-
declare const
|
|
1306
|
+
declare const genCleanValuePath: (text: string) => string;
|
|
1209
1307
|
|
|
1210
|
-
export { BASE_BULLMQ_CONFIG, FILTER_IDS, TEMP_removeDuplicateFilters, UI_CONTENT, _self_managed_buildAnnoHierarchyConfig, _self_managed_getFixedAnnoRollupBlocks, _self_managed_getFixedAnnoTagBlock, autoGenFilterConfigsFromTpl, buildFilterConfigurations, compareAndGroupBlocks, deleteVal, extractAllBlocksFromTpl, extractAndOrganizeBlocks, genCleanCamelCaseId,
|
|
1308
|
+
export { BASE_BULLMQ_CONFIG, FILTER_IDS, TEMP_removeDuplicateFilters, UI_CONTENT, _self_managed_buildAnnoHierarchyConfig, _self_managed_buildDocHierarchyConfig, _self_managed_getFixedAnnoRollupBlocks, _self_managed_getFixedAnnoTagBlock, autoGenFilterConfigsFromTpl, buildFilterConfigurations, compareAndGroupBlocks, deleteVal, extractAllBlocksFromTpl, extractAndOrganizeBlocks, genCleanCamelCaseId, genCleanContentTypeId, genCleanValuePath, genTagId, generateFilterKey, getFilterKeyForBlock, getPlatformContextContent, getRollupPossibilities, getRoutePathToEditContent, getRoutePathToModerateContent, getRoutePathToPublishedContent, getVal, mergeAnnoDataIntoAnnotationsTags, parseSpecialConfigSyntax, processAuthorAndCommonFilters, _recursExtractBlocks as recursivelyExtractBlocks, segrigateDocs, setVal, toArray };
|