@librechat/data-schemas 0.0.17 → 0.0.19

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.
@@ -1 +1,2 @@
1
1
  export * from './enum';
2
+ export * from './pagination';
@@ -0,0 +1,16 @@
1
+ export interface CursorPaginationParams {
2
+ limit?: number;
3
+ cursor?: string;
4
+ sortBy?: string;
5
+ sortOrder?: 'asc' | 'desc';
6
+ }
7
+ export interface CursorPaginationResponse<T> {
8
+ data: T[];
9
+ pagination: {
10
+ hasNextPage: boolean;
11
+ hasPreviousPage: boolean;
12
+ nextCursor?: string;
13
+ previousCursor?: string;
14
+ totalCount?: number;
15
+ };
16
+ }
@@ -24,12 +24,12 @@
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  /// <reference types="mongoose/types/inferrawdoctype" />
26
26
  import { FilterQuery } from 'mongoose';
27
- import type { IUser, BalanceConfig, UserCreateData, UserUpdateResult } from '~/types';
27
+ import type { IUser, BalanceConfig, CreateUserRequest, UserDeleteResult } from '~/types';
28
28
  /** Factory function that takes mongoose instance and returns the methods */
29
29
  export declare function createUserMethods(mongoose: typeof import('mongoose')): {
30
30
  findUser: (searchCriteria: FilterQuery<IUser>, fieldsToSelect?: string | string[] | null) => Promise<IUser | null>;
31
31
  countUsers: (filter?: FilterQuery<IUser>) => Promise<number>;
32
- createUser: (data: UserCreateData, balanceConfig?: BalanceConfig, disableTTL?: boolean, returnUser?: boolean) => Promise<mongoose.Types.ObjectId | Partial<IUser>>;
32
+ createUser: (data: CreateUserRequest, balanceConfig?: BalanceConfig, disableTTL?: boolean, returnUser?: boolean) => Promise<mongoose.Types.ObjectId | Partial<IUser>>;
33
33
  updateUser: (userId: string, updateData: Partial<IUser>) => Promise<IUser | null>;
34
34
  searchUsers: ({ searchPattern, limit, fieldsToSelect, }: {
35
35
  searchPattern: string;
@@ -41,7 +41,7 @@ export declare function createUserMethods(mongoose: typeof import('mongoose')):
41
41
  }[]>;
42
42
  getUserById: (userId: string, fieldsToSelect?: string | string[] | null) => Promise<IUser | null>;
43
43
  generateToken: (user: IUser) => Promise<string>;
44
- deleteUserById: (userId: string) => Promise<UserUpdateResult>;
44
+ deleteUserById: (userId: string) => Promise<UserDeleteResult>;
45
45
  toggleUserMemories: (userId: string, memoriesEnabled: boolean) => Promise<IUser | null>;
46
46
  };
47
47
  export type UserMethods = ReturnType<typeof createUserMethods>;
@@ -24,23 +24,41 @@
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  /// <reference types="mongoose/types/inferrawdoctype" />
26
26
  import type { Document, Types } from 'mongoose';
27
+ import { CursorPaginationParams } from '~/common';
27
28
  export interface IGroup extends Document {
28
29
  _id: Types.ObjectId;
29
- /** The name of the group */
30
30
  name: string;
31
- /** Optional description of the group */
32
31
  description?: string;
33
- /** Optional email address for the group */
34
32
  email?: string;
35
- /** Optional avatar URL for the group */
36
33
  avatar?: string;
37
34
  /** Array of member IDs (stores idOnTheSource values, not ObjectIds) */
38
- memberIds: string[];
39
- /** The source of the group ('local' or 'entra') */
35
+ memberIds?: string[];
40
36
  source: 'local' | 'entra';
41
37
  /** External ID (e.g., Entra ID) - required for non-local sources */
42
38
  idOnTheSource?: string;
43
- /** Timestamps */
44
39
  createdAt?: Date;
45
40
  updatedAt?: Date;
46
41
  }
42
+ export interface CreateGroupRequest {
43
+ name: string;
44
+ description?: string;
45
+ email?: string;
46
+ avatar?: string;
47
+ memberIds?: string[];
48
+ source: 'local' | 'entra';
49
+ idOnTheSource?: string;
50
+ }
51
+ export interface UpdateGroupRequest {
52
+ name?: string;
53
+ description?: string;
54
+ email?: string;
55
+ avatar?: string;
56
+ memberIds?: string[];
57
+ source?: 'local' | 'entra' | 'ldap';
58
+ idOnTheSource?: string;
59
+ }
60
+ export interface GroupFilterOptions extends CursorPaginationParams {
61
+ search?: string;
62
+ source?: 'local' | 'entra' | 'ldap';
63
+ hasMember?: string;
64
+ }
@@ -23,8 +23,27 @@
23
23
  /// <reference types="mongoose/types/virtuals" />
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  /// <reference types="mongoose/types/inferrawdoctype" />
26
- import { Document } from 'mongoose';
26
+ import type { Document } from 'mongoose';
27
+ import { CursorPaginationParams } from '~/common';
27
28
  export interface IRole extends Document {
28
29
  name: string;
29
30
  permissions: {};
30
31
  }
32
+ export type RolePermissions = IRole['permissions'];
33
+ type DeepPartial<T> = {
34
+ [K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> : T[K];
35
+ };
36
+ export type RolePermissionsInput = DeepPartial<RolePermissions>;
37
+ export interface CreateRoleRequest {
38
+ name: string;
39
+ permissions: RolePermissionsInput;
40
+ }
41
+ export interface UpdateRoleRequest {
42
+ name?: string;
43
+ permissions?: RolePermissionsInput;
44
+ }
45
+ export interface RoleFilterOptions extends CursorPaginationParams {
46
+ search?: string;
47
+ hasPermission?: string;
48
+ }
49
+ export {};
@@ -23,7 +23,8 @@
23
23
  /// <reference types="mongoose/types/virtuals" />
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  /// <reference types="mongoose/types/inferrawdoctype" />
26
- import { Document, Types } from 'mongoose';
26
+ import type { Document, Types } from 'mongoose';
27
+ import { CursorPaginationParams } from '~/common';
27
28
  export interface IUser extends Document {
28
29
  name?: string;
29
30
  username?: string;
@@ -70,16 +71,34 @@ export interface BalanceConfig {
70
71
  refillIntervalUnit?: string;
71
72
  refillAmount?: number;
72
73
  }
73
- export interface UserCreateData extends Partial<IUser> {
74
+ export interface CreateUserRequest extends Partial<IUser> {
74
75
  email: string;
75
76
  }
76
- export interface UserUpdateResult {
77
+ export interface UpdateUserRequest {
78
+ name?: string;
79
+ username?: string;
80
+ email?: string;
81
+ role?: string;
82
+ emailVerified?: boolean;
83
+ avatar?: string;
84
+ plugins?: string[];
85
+ twoFactorEnabled?: boolean;
86
+ termsAccepted?: boolean;
87
+ personalization?: {
88
+ memories?: boolean;
89
+ };
90
+ }
91
+ export interface UserDeleteResult {
77
92
  deletedCount: number;
78
93
  message: string;
79
94
  }
80
- export interface UserSearchCriteria {
81
- email?: string;
82
- username?: string;
95
+ export interface UserFilterOptions extends CursorPaginationParams {
96
+ _id?: Types.ObjectId | string;
97
+ search?: string;
98
+ role?: string;
99
+ emailVerified?: boolean;
100
+ provider?: string;
101
+ twoFactorEnabled?: boolean;
83
102
  googleId?: string;
84
103
  facebookId?: string;
85
104
  openidId?: string;
@@ -88,7 +107,8 @@ export interface UserSearchCriteria {
88
107
  githubId?: string;
89
108
  discordId?: string;
90
109
  appleId?: string;
91
- _id?: Types.ObjectId | string;
110
+ createdAfter?: string;
111
+ createdBefore?: string;
92
112
  }
93
113
  export interface UserQueryOptions {
94
114
  fieldsToSelect?: string | string[] | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@librechat/data-schemas",
3
- "version": "0.0.17",
3
+ "version": "0.0.19",
4
4
  "description": "Mongoose schemas and models for LibreChat",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",