@librechat/data-schemas 0.0.18 → 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 +65 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +65 -23
- package/dist/index.es.js.map +1 -1
- package/dist/types/common/index.d.ts +1 -0
- package/dist/types/common/pagination.d.ts +16 -0
- package/dist/types/methods/agentCategory.d.ts +3 -2
- package/dist/types/methods/user.d.ts +3 -3
- package/dist/types/schema/agentCategory.d.ts +3 -3
- package/dist/types/types/agentCategory.d.ts +2 -0
- package/dist/types/types/group.d.ts +25 -7
- package/dist/types/types/role.d.ts +20 -1
- package/dist/types/types/user.d.ts +27 -7
- 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
|
});
|
|
@@ -1354,6 +1358,7 @@ const groupSchema = new Schema({
|
|
|
1354
1358
|
memberIds: [
|
|
1355
1359
|
{
|
|
1356
1360
|
type: String,
|
|
1361
|
+
required: false,
|
|
1357
1362
|
},
|
|
1358
1363
|
],
|
|
1359
1364
|
source: {
|
|
@@ -1808,7 +1813,7 @@ const transports$1 = [
|
|
|
1808
1813
|
zippedArchive: true,
|
|
1809
1814
|
maxSize: '20m',
|
|
1810
1815
|
maxFiles: '14d',
|
|
1811
|
-
format: fileFormat$1,
|
|
1816
|
+
format: winston.format.combine(fileFormat$1, winston.format.json()),
|
|
1812
1817
|
}),
|
|
1813
1818
|
];
|
|
1814
1819
|
if (useDebugLogging$1) {
|
|
@@ -3542,6 +3547,7 @@ function createAgentCategoryMethods(mongoose) {
|
|
|
3542
3547
|
description: category.description || '',
|
|
3543
3548
|
order: category.order || index,
|
|
3544
3549
|
isActive: true,
|
|
3550
|
+
custom: category.custom || false,
|
|
3545
3551
|
},
|
|
3546
3552
|
},
|
|
3547
3553
|
upsert: true,
|
|
@@ -3606,60 +3612,96 @@ function createAgentCategoryMethods(mongoose) {
|
|
|
3606
3612
|
return await AgentCategory.find({}).sort({ order: 1, label: 1 }).lean();
|
|
3607
3613
|
}
|
|
3608
3614
|
/**
|
|
3609
|
-
* Ensure default categories exist
|
|
3610
|
-
* @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
|
|
3611
3617
|
*/
|
|
3612
3618
|
async function ensureDefaultCategories() {
|
|
3613
|
-
const
|
|
3614
|
-
if (existingCategories.length > 0) {
|
|
3615
|
-
return false; // Categories already exist
|
|
3616
|
-
}
|
|
3619
|
+
const AgentCategory = mongoose.models.AgentCategory;
|
|
3617
3620
|
const defaultCategories = [
|
|
3618
3621
|
{
|
|
3619
3622
|
value: 'general',
|
|
3620
|
-
label: '
|
|
3621
|
-
description: '
|
|
3623
|
+
label: 'com_agents_category_general',
|
|
3624
|
+
description: 'com_agents_category_general_description',
|
|
3622
3625
|
order: 0,
|
|
3623
3626
|
},
|
|
3624
3627
|
{
|
|
3625
3628
|
value: 'hr',
|
|
3626
|
-
label: '
|
|
3627
|
-
description: '
|
|
3629
|
+
label: 'com_agents_category_hr',
|
|
3630
|
+
description: 'com_agents_category_hr_description',
|
|
3628
3631
|
order: 1,
|
|
3629
3632
|
},
|
|
3630
3633
|
{
|
|
3631
3634
|
value: 'rd',
|
|
3632
|
-
label: '
|
|
3633
|
-
description: '
|
|
3635
|
+
label: 'com_agents_category_rd',
|
|
3636
|
+
description: 'com_agents_category_rd_description',
|
|
3634
3637
|
order: 2,
|
|
3635
3638
|
},
|
|
3636
3639
|
{
|
|
3637
3640
|
value: 'finance',
|
|
3638
|
-
label: '
|
|
3639
|
-
description: '
|
|
3641
|
+
label: 'com_agents_category_finance',
|
|
3642
|
+
description: 'com_agents_category_finance_description',
|
|
3640
3643
|
order: 3,
|
|
3641
3644
|
},
|
|
3642
3645
|
{
|
|
3643
3646
|
value: 'it',
|
|
3644
|
-
label: '
|
|
3645
|
-
description: '
|
|
3647
|
+
label: 'com_agents_category_it',
|
|
3648
|
+
description: 'com_agents_category_it_description',
|
|
3646
3649
|
order: 4,
|
|
3647
3650
|
},
|
|
3648
3651
|
{
|
|
3649
3652
|
value: 'sales',
|
|
3650
|
-
label: '
|
|
3651
|
-
description: '
|
|
3653
|
+
label: 'com_agents_category_sales',
|
|
3654
|
+
description: 'com_agents_category_sales_description',
|
|
3652
3655
|
order: 5,
|
|
3653
3656
|
},
|
|
3654
3657
|
{
|
|
3655
3658
|
value: 'aftersales',
|
|
3656
|
-
label: '
|
|
3657
|
-
description: '
|
|
3659
|
+
label: 'com_agents_category_aftersales',
|
|
3660
|
+
description: 'com_agents_category_aftersales_description',
|
|
3658
3661
|
order: 6,
|
|
3659
3662
|
},
|
|
3660
3663
|
];
|
|
3661
|
-
await
|
|
3662
|
-
|
|
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;
|
|
3663
3705
|
}
|
|
3664
3706
|
return {
|
|
3665
3707
|
getActiveCategories,
|