mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-02-17 07:58:08 +01:00
🔧 refactor: Integrate PrincipalModel Enum for Principal Handling
- Replaced string literals for principal models ('User', 'Group') with the new PrincipalModel enum across various models, services, and tests to enhance type safety and consistency.
- Updated permission handling in multiple files to utilize the PrincipalModel enum, improving maintainability and reducing potential errors.
- Ensured all relevant tests reflect these changes to maintain coverage and functionality.
This commit is contained in:
parent
49d1cefe71
commit
28d63dab71
10 changed files with 61 additions and 30 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import { Schema } from 'mongoose';
|
||||
import { PrincipalType } from 'librechat-data-provider';
|
||||
import { PrincipalType, PrincipalModel, ResourceType } from 'librechat-data-provider';
|
||||
import type { IAclEntry } from '~/types';
|
||||
|
||||
const aclEntrySchema = new Schema<IAclEntry>(
|
||||
|
|
@ -19,14 +19,14 @@ const aclEntrySchema = new Schema<IAclEntry>(
|
|||
},
|
||||
principalModel: {
|
||||
type: String,
|
||||
enum: ['User', 'Group'],
|
||||
enum: Object.values(PrincipalModel),
|
||||
required: function (this: IAclEntry) {
|
||||
return this.principalType !== PrincipalType.PUBLIC;
|
||||
},
|
||||
},
|
||||
resourceType: {
|
||||
type: String,
|
||||
enum: ['agent', 'project', 'file', 'prompt', 'promptGroup'],
|
||||
enum: Object.values(ResourceType),
|
||||
required: true,
|
||||
},
|
||||
resourceId: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue