@librechat/data-schemas 0.0.19 → 0.0.20
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/index.cjs +64 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +64 -23
- package/dist/index.es.js.map +1 -1
- package/dist/types/methods/agentCategory.d.ts +3 -2
- package/dist/types/schema/agentCategory.d.ts +3 -3
- package/dist/types/types/agentCategory.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -217,6 +217,10 @@ const agentCategorySchema = new Schema({
|
|
|
217
217
|
default: true,
|
|
218
218
|
index: true,
|
|
219
219
|
},
|
|
220
|
+
custom: {
|
|
221
|
+
type: Boolean,
|
|
222
|
+
default: false,
|
|
223
|
+
},
|
|
220
224
|
}, {
|
|
221
225
|
timestamps: true,
|
|
222
226
|
});
|
|
@@ -1809,7 +1813,7 @@ const transports$1 = [
|
|
|
1809
1813
|
zippedArchive: true,
|
|
1810
1814
|
maxSize: '20m',
|
|
1811
1815
|
maxFiles: '14d',
|
|
1812
|
-
format: fileFormat$1,
|
|
1816
|
+
format: winston.format.combine(fileFormat$1, winston.format.json()),
|
|
1813
1817
|
}),
|
|
1814
1818
|
];
|
|
1815
1819
|
if (useDebugLogging$1) {
|
|
@@ -3543,6 +3547,7 @@ function createAgentCategoryMethods(mongoose) {
|
|
|
3543
3547
|
description: category.description || '',
|
|
3544
3548
|
order: category.order || index,
|
|
3545
3549
|
isActive: true,
|
|
3550
|
+
custom: category.custom || false,
|
|
3546
3551
|
},
|
|
3547
3552
|
},
|
|
3548
3553
|
upsert: true,
|
|
@@ -3607,60 +3612,96 @@ function createAgentCategoryMethods(mongoose) {
|
|
|
3607
3612
|
return await AgentCategory.find({}).sort({ order: 1, label: 1 }).lean();
|
|
3608
3613
|
}
|
|
3609
3614
|
/**
|
|
3610
|
-
* Ensure default categories exist
|
|
3611
|
-
* @returns Promise<boolean> - true if categories were
|
|
3615
|
+
* Ensure default categories exist and update them if they don't have localization keys
|
|
3616
|
+
* @returns Promise<boolean> - true if categories were created/updated, false if no changes
|
|
3612
3617
|
*/
|
|
3613
3618
|
async function ensureDefaultCategories() {
|
|
3614
|
-
const
|
|
3615
|
-
if (existingCategories.length > 0) {
|
|
3616
|
-
return false; // Categories already exist
|
|
3617
|
-
}
|
|
3619
|
+
const AgentCategory = mongoose.models.AgentCategory;
|
|
3618
3620
|
const defaultCategories = [
|
|
3619
3621
|
{
|
|
3620
3622
|
value: 'general',
|
|
3621
|
-
label: '
|
|
3622
|
-
description: '
|
|
3623
|
+
label: 'com_agents_category_general',
|
|
3624
|
+
description: 'com_agents_category_general_description',
|
|
3623
3625
|
order: 0,
|
|
3624
3626
|
},
|
|
3625
3627
|
{
|
|
3626
3628
|
value: 'hr',
|
|
3627
|
-
label: '
|
|
3628
|
-
description: '
|
|
3629
|
+
label: 'com_agents_category_hr',
|
|
3630
|
+
description: 'com_agents_category_hr_description',
|
|
3629
3631
|
order: 1,
|
|
3630
3632
|
},
|
|
3631
3633
|
{
|
|
3632
3634
|
value: 'rd',
|
|
3633
|
-
label: '
|
|
3634
|
-
description: '
|
|
3635
|
+
label: 'com_agents_category_rd',
|
|
3636
|
+
description: 'com_agents_category_rd_description',
|
|
3635
3637
|
order: 2,
|
|
3636
3638
|
},
|
|
3637
3639
|
{
|
|
3638
3640
|
value: 'finance',
|
|
3639
|
-
label: '
|
|
3640
|
-
description: '
|
|
3641
|
+
label: 'com_agents_category_finance',
|
|
3642
|
+
description: 'com_agents_category_finance_description',
|
|
3641
3643
|
order: 3,
|
|
3642
3644
|
},
|
|
3643
3645
|
{
|
|
3644
3646
|
value: 'it',
|
|
3645
|
-
label: '
|
|
3646
|
-
description: '
|
|
3647
|
+
label: 'com_agents_category_it',
|
|
3648
|
+
description: 'com_agents_category_it_description',
|
|
3647
3649
|
order: 4,
|
|
3648
3650
|
},
|
|
3649
3651
|
{
|
|
3650
3652
|
value: 'sales',
|
|
3651
|
-
label: '
|
|
3652
|
-
description: '
|
|
3653
|
+
label: 'com_agents_category_sales',
|
|
3654
|
+
description: 'com_agents_category_sales_description',
|
|
3653
3655
|
order: 5,
|
|
3654
3656
|
},
|
|
3655
3657
|
{
|
|
3656
3658
|
value: 'aftersales',
|
|
3657
|
-
label: '
|
|
3658
|
-
description: '
|
|
3659
|
+
label: 'com_agents_category_aftersales',
|
|
3660
|
+
description: 'com_agents_category_aftersales_description',
|
|
3659
3661
|
order: 6,
|
|
3660
3662
|
},
|
|
3661
3663
|
];
|
|
3662
|
-
await
|
|
3663
|
-
|
|
3664
|
+
const existingCategories = await getAllCategories();
|
|
3665
|
+
const existingCategoryMap = new Map(existingCategories.map((cat) => [cat.value, cat]));
|
|
3666
|
+
const updates = [];
|
|
3667
|
+
let created = 0;
|
|
3668
|
+
for (const defaultCategory of defaultCategories) {
|
|
3669
|
+
const existingCategory = existingCategoryMap.get(defaultCategory.value);
|
|
3670
|
+
if (existingCategory) {
|
|
3671
|
+
const isNotCustom = !existingCategory.custom;
|
|
3672
|
+
const needsLocalization = !existingCategory.label.startsWith('com_');
|
|
3673
|
+
if (isNotCustom && needsLocalization) {
|
|
3674
|
+
updates.push({
|
|
3675
|
+
value: defaultCategory.value,
|
|
3676
|
+
label: defaultCategory.label,
|
|
3677
|
+
description: defaultCategory.description,
|
|
3678
|
+
});
|
|
3679
|
+
}
|
|
3680
|
+
}
|
|
3681
|
+
else {
|
|
3682
|
+
await createCategory({
|
|
3683
|
+
...defaultCategory,
|
|
3684
|
+
isActive: true,
|
|
3685
|
+
custom: false,
|
|
3686
|
+
});
|
|
3687
|
+
created++;
|
|
3688
|
+
}
|
|
3689
|
+
}
|
|
3690
|
+
if (updates.length > 0) {
|
|
3691
|
+
const bulkOps = updates.map((update) => ({
|
|
3692
|
+
updateOne: {
|
|
3693
|
+
filter: { value: update.value, custom: { $ne: true } },
|
|
3694
|
+
update: {
|
|
3695
|
+
$set: {
|
|
3696
|
+
label: update.label,
|
|
3697
|
+
description: update.description,
|
|
3698
|
+
},
|
|
3699
|
+
},
|
|
3700
|
+
},
|
|
3701
|
+
}));
|
|
3702
|
+
await AgentCategory.bulkWrite(bulkOps, { ordered: false });
|
|
3703
|
+
}
|
|
3704
|
+
return updates.length > 0 || created > 0;
|
|
3664
3705
|
}
|
|
3665
3706
|
return {
|
|
3666
3707
|
getActiveCategories,
|