first commit
This commit is contained in:
185
lib/types/index.ts
Normal file
185
lib/types/index.ts
Normal file
@@ -0,0 +1,185 @@
|
||||
// Types pour les collections MongoDB LibreChat (structure réelle)
|
||||
export interface LibreChatUser extends Record<string, unknown> {
|
||||
_id: string;
|
||||
name: string;
|
||||
username: string;
|
||||
email: string;
|
||||
emailVerified: boolean;
|
||||
password: string;
|
||||
avatar: string | null;
|
||||
provider: string;
|
||||
role: 'ADMIN' | 'USER';
|
||||
plugins: unknown[];
|
||||
twoFactorEnabled: boolean;
|
||||
termsAccepted: boolean;
|
||||
personalization: {
|
||||
memories: boolean;
|
||||
_id: string;
|
||||
};
|
||||
backupCodes: unknown[];
|
||||
refreshToken: unknown[];
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
__v: number;
|
||||
}
|
||||
|
||||
export interface LibreChatConversation extends Record<string, unknown> {
|
||||
_id: string;
|
||||
conversationId: string;
|
||||
user: string; // ObjectId du user
|
||||
__v: number;
|
||||
_meiliIndex: boolean;
|
||||
agent_id: string;
|
||||
createdAt: Date;
|
||||
endpoint: string;
|
||||
endpointType: string;
|
||||
expiredAt: Date | null;
|
||||
files: unknown[];
|
||||
isArchived: boolean;
|
||||
messages: string[]; // Array d'ObjectIds
|
||||
model: string;
|
||||
resendFiles: boolean;
|
||||
tags: unknown[];
|
||||
title: string;
|
||||
updatedAt: Date;
|
||||
}
|
||||
|
||||
export interface LibreChatMessage extends Record<string, unknown> {
|
||||
_id: string;
|
||||
messageId: string;
|
||||
user: string; // ObjectId du user
|
||||
__v: number;
|
||||
_meiliIndex: boolean;
|
||||
conversationId: string;
|
||||
createdAt: Date;
|
||||
endpoint: string;
|
||||
error: boolean;
|
||||
expiredAt: Date | null;
|
||||
isCreatedByUser: boolean;
|
||||
model: string | null;
|
||||
parentMessageId: string;
|
||||
sender: string;
|
||||
text: string;
|
||||
tokenCount: number;
|
||||
unfinished: boolean;
|
||||
updatedAt: Date;
|
||||
}
|
||||
|
||||
export interface LibreChatTransaction extends Record<string, unknown> {
|
||||
_id: string;
|
||||
user: string; // ObjectId
|
||||
conversationId: string;
|
||||
tokenType: 'prompt' | 'completion';
|
||||
model: string;
|
||||
context: string;
|
||||
rawAmount: number;
|
||||
tokenValue: number;
|
||||
rate: number;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
__v: number;
|
||||
}
|
||||
|
||||
export interface LibreChatBalance extends Record<string, unknown> {
|
||||
_id: string;
|
||||
user: string; // ObjectId
|
||||
__v: number;
|
||||
autoRefillEnabled: boolean;
|
||||
lastRefill: Date;
|
||||
refillAmount: number;
|
||||
refillIntervalUnit: string;
|
||||
refillIntervalValue: number;
|
||||
tokenCredits: number;
|
||||
}
|
||||
|
||||
// Types legacy pour compatibilité
|
||||
export interface User extends Record<string, unknown> {
|
||||
_id: string;
|
||||
name: string;
|
||||
email: string;
|
||||
role: string;
|
||||
credits: number;
|
||||
isActive: boolean;
|
||||
createdAt: Date;
|
||||
lastLogin?: Date;
|
||||
}
|
||||
|
||||
export interface Conversation extends Record<string, unknown> {
|
||||
_id: string;
|
||||
title: string;
|
||||
participants: string[];
|
||||
messageCount: number;
|
||||
status: 'active' | 'archived' | 'deleted';
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}
|
||||
|
||||
export interface Transaction extends Record<string, unknown> {
|
||||
_id: string;
|
||||
userId: string;
|
||||
amount: number;
|
||||
type: 'credit' | 'debit';
|
||||
description: string;
|
||||
createdAt: Date;
|
||||
}
|
||||
|
||||
export interface Message extends Record<string, unknown> {
|
||||
_id: string;
|
||||
conversationId: string;
|
||||
userId: string;
|
||||
content: string;
|
||||
role: 'user' | 'assistant' | 'system';
|
||||
createdAt: Date;
|
||||
}
|
||||
|
||||
export interface Balance extends Record<string, unknown> {
|
||||
_id: string;
|
||||
userId: string;
|
||||
credits: number;
|
||||
lastUpdated: Date;
|
||||
}
|
||||
|
||||
export interface DashboardMetrics {
|
||||
totalUsers: number;
|
||||
activeUsers: number;
|
||||
totalAdmins: number;
|
||||
totalCredits: number;
|
||||
activeConversations: number;
|
||||
totalMessages: number;
|
||||
totalTokensConsumed: number;
|
||||
totalCreditsUsed: number;
|
||||
recentTransactions: Transaction[];
|
||||
}
|
||||
|
||||
// Types pour les autres collections
|
||||
export interface AccessRole extends Record<string, unknown> {
|
||||
_id: string;
|
||||
name: string;
|
||||
permissions: string[];
|
||||
}
|
||||
|
||||
export interface Agent extends Record<string, unknown> {
|
||||
_id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
category: string;
|
||||
isActive: boolean;
|
||||
}
|
||||
|
||||
export interface File extends Record<string, unknown> {
|
||||
_id: string;
|
||||
filename: string;
|
||||
size: number;
|
||||
uploadedBy: string;
|
||||
uploadedAt: Date;
|
||||
}
|
||||
|
||||
// Types génériques pour les collections MongoDB
|
||||
export interface MongoDocument extends Record<string, unknown> {
|
||||
_id: string;
|
||||
createdAt?: Date;
|
||||
updatedAt?: Date;
|
||||
}
|
||||
|
||||
// Type utilitaire pour les collections
|
||||
export type CollectionItem = MongoDocument & Record<string, unknown>;
|
||||
Reference in New Issue
Block a user