@librechat/data-schemas 0.0.8 → 0.0.10
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 +724 -35
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +724 -36
- package/dist/index.es.js.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/methods/index.d.ts +23 -1
- package/dist/types/methods/memory.d.ts +35 -0
- package/dist/types/methods/pluginAuth.d.ts +36 -0
- package/dist/types/methods/share.d.ts +38 -0
- package/dist/types/methods/share.test.d.ts +1 -0
- package/dist/types/methods/user.d.ts +1 -0
- package/dist/types/models/index.d.ts +1 -0
- package/dist/types/models/memory.d.ts +27 -0
- package/dist/types/models/plugins/mongoMeili.d.ts +23 -1
- package/dist/types/schema/index.d.ts +1 -0
- package/dist/types/schema/memory.d.ts +29 -0
- package/dist/types/schema/pluginAuth.d.ts +2 -9
- package/dist/types/types/index.d.ts +30 -0
- package/dist/types/types/memory.d.ts +63 -0
- package/dist/types/types/pluginAuth.d.ts +59 -0
- package/dist/types/types/share.d.ts +82 -0
- package/dist/types/types/user.d.ts +3 -0
- package/package.json +6 -4
- package/README.md +0 -114
|
@@ -23,7 +23,9 @@
|
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
/// <reference types="mongoose/types/inferrawdoctype" />
|
|
26
|
-
import type {
|
|
26
|
+
import type { SearchResponse } from 'meilisearch';
|
|
27
|
+
import type { CallbackWithoutResultAndOptionalError, Document, Schema, Model } from 'mongoose';
|
|
28
|
+
import type { IConversation, IMessage } from '~/types';
|
|
27
29
|
interface MongoMeiliOptions {
|
|
28
30
|
host: string;
|
|
29
31
|
apiKey: string;
|
|
@@ -31,6 +33,26 @@ interface MongoMeiliOptions {
|
|
|
31
33
|
primaryKey: string;
|
|
32
34
|
mongoose: typeof import('mongoose');
|
|
33
35
|
}
|
|
36
|
+
interface MeiliIndexable {
|
|
37
|
+
[key: string]: unknown;
|
|
38
|
+
_meiliIndex?: boolean;
|
|
39
|
+
}
|
|
40
|
+
interface _DocumentWithMeiliIndex extends Document {
|
|
41
|
+
_meiliIndex?: boolean;
|
|
42
|
+
preprocessObjectForIndex?: () => Record<string, unknown>;
|
|
43
|
+
addObjectToMeili?: (next: CallbackWithoutResultAndOptionalError) => Promise<void>;
|
|
44
|
+
updateObjectToMeili?: (next: CallbackWithoutResultAndOptionalError) => Promise<void>;
|
|
45
|
+
deleteObjectFromMeili?: (next: CallbackWithoutResultAndOptionalError) => Promise<void>;
|
|
46
|
+
postSaveHook?: (next: CallbackWithoutResultAndOptionalError) => void;
|
|
47
|
+
postUpdateHook?: (next: CallbackWithoutResultAndOptionalError) => void;
|
|
48
|
+
postRemoveHook?: (next: CallbackWithoutResultAndOptionalError) => void;
|
|
49
|
+
}
|
|
50
|
+
export type DocumentWithMeiliIndex = _DocumentWithMeiliIndex & IConversation & Partial<IMessage>;
|
|
51
|
+
export interface SchemaWithMeiliMethods extends Model<DocumentWithMeiliIndex> {
|
|
52
|
+
syncWithMeili(): Promise<void>;
|
|
53
|
+
setMeiliIndexSettings(settings: Record<string, unknown>): Promise<unknown>;
|
|
54
|
+
meiliSearch(q: string, params?: Record<string, unknown>, populate?: boolean): Promise<SearchResponse<MeiliIndexable, Record<string, unknown>>>;
|
|
55
|
+
}
|
|
34
56
|
/**
|
|
35
57
|
* Mongoose plugin to synchronize MongoDB collections with a MeiliSearch index.
|
|
36
58
|
*
|
|
@@ -21,3 +21,4 @@ export { default as tokenSchema } from './token';
|
|
|
21
21
|
export { default as toolCallSchema } from './toolCall';
|
|
22
22
|
export { default as transactionSchema } from './transaction';
|
|
23
23
|
export { default as userSchema } from './user';
|
|
24
|
+
export { default as memorySchema } from './memory';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/// <reference types="mongoose/types/aggregate" />
|
|
2
|
+
/// <reference types="mongoose/types/callback" />
|
|
3
|
+
/// <reference types="mongoose/types/collection" />
|
|
4
|
+
/// <reference types="mongoose/types/connection" />
|
|
5
|
+
/// <reference types="mongoose/types/cursor" />
|
|
6
|
+
/// <reference types="mongoose/types/document" />
|
|
7
|
+
/// <reference types="mongoose/types/error" />
|
|
8
|
+
/// <reference types="mongoose/types/expressions" />
|
|
9
|
+
/// <reference types="mongoose/types/helpers" />
|
|
10
|
+
/// <reference types="mongoose/types/middlewares" />
|
|
11
|
+
/// <reference types="mongoose/types/indexes" />
|
|
12
|
+
/// <reference types="mongoose/types/models" />
|
|
13
|
+
/// <reference types="mongoose/types/mongooseoptions" />
|
|
14
|
+
/// <reference types="mongoose/types/pipelinestage" />
|
|
15
|
+
/// <reference types="mongoose/types/populate" />
|
|
16
|
+
/// <reference types="mongoose/types/query" />
|
|
17
|
+
/// <reference types="mongoose/types/schemaoptions" />
|
|
18
|
+
/// <reference types="mongoose/types/schematypes" />
|
|
19
|
+
/// <reference types="mongoose/types/session" />
|
|
20
|
+
/// <reference types="mongoose/types/types" />
|
|
21
|
+
/// <reference types="mongoose/types/utility" />
|
|
22
|
+
/// <reference types="mongoose/types/validation" />
|
|
23
|
+
/// <reference types="mongoose/types/virtuals" />
|
|
24
|
+
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
+
/// <reference types="mongoose/types/inferrawdoctype" />
|
|
26
|
+
import { Schema } from 'mongoose';
|
|
27
|
+
import type { IMemoryEntry } from '~/types/memory';
|
|
28
|
+
declare const MemoryEntrySchema: Schema<IMemoryEntry>;
|
|
29
|
+
export default MemoryEntrySchema;
|
|
@@ -23,14 +23,7 @@
|
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
/// <reference types="mongoose/types/inferrawdoctype" />
|
|
26
|
-
import { Schema
|
|
27
|
-
|
|
28
|
-
authField: string;
|
|
29
|
-
value: string;
|
|
30
|
-
userId: string;
|
|
31
|
-
pluginKey?: string;
|
|
32
|
-
createdAt?: Date;
|
|
33
|
-
updatedAt?: Date;
|
|
34
|
-
}
|
|
26
|
+
import { Schema } from 'mongoose';
|
|
27
|
+
import type { IPluginAuth } from '~/types';
|
|
35
28
|
declare const pluginAuthSchema: Schema<IPluginAuth>;
|
|
36
29
|
export default pluginAuthSchema;
|
|
@@ -1,3 +1,30 @@
|
|
|
1
|
+
/// <reference types="mongoose/types/aggregate" />
|
|
2
|
+
/// <reference types="mongoose/types/callback" />
|
|
3
|
+
/// <reference types="mongoose/types/collection" />
|
|
4
|
+
/// <reference types="mongoose/types/connection" />
|
|
5
|
+
/// <reference types="mongoose/types/cursor" />
|
|
6
|
+
/// <reference types="mongoose/types/document" />
|
|
7
|
+
/// <reference types="mongoose/types/error" />
|
|
8
|
+
/// <reference types="mongoose/types/expressions" />
|
|
9
|
+
/// <reference types="mongoose/types/helpers" />
|
|
10
|
+
/// <reference types="mongoose/types/middlewares" />
|
|
11
|
+
/// <reference types="mongoose/types/indexes" />
|
|
12
|
+
/// <reference types="mongoose/types/models" />
|
|
13
|
+
/// <reference types="mongoose/types/mongooseoptions" />
|
|
14
|
+
/// <reference types="mongoose/types/pipelinestage" />
|
|
15
|
+
/// <reference types="mongoose/types/populate" />
|
|
16
|
+
/// <reference types="mongoose/types/query" />
|
|
17
|
+
/// <reference types="mongoose/types/schemaoptions" />
|
|
18
|
+
/// <reference types="mongoose/types/schematypes" />
|
|
19
|
+
/// <reference types="mongoose/types/session" />
|
|
20
|
+
/// <reference types="mongoose/types/types" />
|
|
21
|
+
/// <reference types="mongoose/types/utility" />
|
|
22
|
+
/// <reference types="mongoose/types/validation" />
|
|
23
|
+
/// <reference types="mongoose/types/virtuals" />
|
|
24
|
+
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
+
/// <reference types="mongoose/types/inferrawdoctype" />
|
|
26
|
+
import type { Types } from 'mongoose';
|
|
27
|
+
export type ObjectId = Types.ObjectId;
|
|
1
28
|
export * from './user';
|
|
2
29
|
export * from './token';
|
|
3
30
|
export * from './convo';
|
|
@@ -10,3 +37,6 @@ export * from './role';
|
|
|
10
37
|
export * from './action';
|
|
11
38
|
export * from './assistant';
|
|
12
39
|
export * from './file';
|
|
40
|
+
export * from './share';
|
|
41
|
+
export * from './pluginAuth';
|
|
42
|
+
export * from './memory';
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/// <reference types="mongoose/types/aggregate" />
|
|
2
|
+
/// <reference types="mongoose/types/callback" />
|
|
3
|
+
/// <reference types="mongoose/types/collection" />
|
|
4
|
+
/// <reference types="mongoose/types/connection" />
|
|
5
|
+
/// <reference types="mongoose/types/cursor" />
|
|
6
|
+
/// <reference types="mongoose/types/document" />
|
|
7
|
+
/// <reference types="mongoose/types/error" />
|
|
8
|
+
/// <reference types="mongoose/types/expressions" />
|
|
9
|
+
/// <reference types="mongoose/types/helpers" />
|
|
10
|
+
/// <reference types="mongoose/types/middlewares" />
|
|
11
|
+
/// <reference types="mongoose/types/indexes" />
|
|
12
|
+
/// <reference types="mongoose/types/models" />
|
|
13
|
+
/// <reference types="mongoose/types/mongooseoptions" />
|
|
14
|
+
/// <reference types="mongoose/types/pipelinestage" />
|
|
15
|
+
/// <reference types="mongoose/types/populate" />
|
|
16
|
+
/// <reference types="mongoose/types/query" />
|
|
17
|
+
/// <reference types="mongoose/types/schemaoptions" />
|
|
18
|
+
/// <reference types="mongoose/types/schematypes" />
|
|
19
|
+
/// <reference types="mongoose/types/session" />
|
|
20
|
+
/// <reference types="mongoose/types/types" />
|
|
21
|
+
/// <reference types="mongoose/types/utility" />
|
|
22
|
+
/// <reference types="mongoose/types/validation" />
|
|
23
|
+
/// <reference types="mongoose/types/virtuals" />
|
|
24
|
+
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
+
/// <reference types="mongoose/types/inferrawdoctype" />
|
|
26
|
+
import type { Types, Document } from 'mongoose';
|
|
27
|
+
export interface IMemoryEntry extends Document {
|
|
28
|
+
userId: Types.ObjectId;
|
|
29
|
+
key: string;
|
|
30
|
+
value: string;
|
|
31
|
+
tokenCount?: number;
|
|
32
|
+
updated_at?: Date;
|
|
33
|
+
}
|
|
34
|
+
export interface IMemoryEntryLean {
|
|
35
|
+
_id: Types.ObjectId;
|
|
36
|
+
userId: Types.ObjectId;
|
|
37
|
+
key: string;
|
|
38
|
+
value: string;
|
|
39
|
+
tokenCount?: number;
|
|
40
|
+
updated_at?: Date;
|
|
41
|
+
__v?: number;
|
|
42
|
+
}
|
|
43
|
+
export interface SetMemoryParams {
|
|
44
|
+
userId: string | Types.ObjectId;
|
|
45
|
+
key: string;
|
|
46
|
+
value: string;
|
|
47
|
+
tokenCount?: number;
|
|
48
|
+
}
|
|
49
|
+
export interface DeleteMemoryParams {
|
|
50
|
+
userId: string | Types.ObjectId;
|
|
51
|
+
key: string;
|
|
52
|
+
}
|
|
53
|
+
export interface GetFormattedMemoriesParams {
|
|
54
|
+
userId: string | Types.ObjectId;
|
|
55
|
+
}
|
|
56
|
+
export interface MemoryResult {
|
|
57
|
+
ok: boolean;
|
|
58
|
+
}
|
|
59
|
+
export interface FormattedMemoriesResult {
|
|
60
|
+
withKeys: string;
|
|
61
|
+
withoutKeys: string;
|
|
62
|
+
totalTokens?: number;
|
|
63
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/// <reference types="mongoose/types/aggregate" />
|
|
2
|
+
/// <reference types="mongoose/types/callback" />
|
|
3
|
+
/// <reference types="mongoose/types/collection" />
|
|
4
|
+
/// <reference types="mongoose/types/connection" />
|
|
5
|
+
/// <reference types="mongoose/types/cursor" />
|
|
6
|
+
/// <reference types="mongoose/types/document" />
|
|
7
|
+
/// <reference types="mongoose/types/error" />
|
|
8
|
+
/// <reference types="mongoose/types/expressions" />
|
|
9
|
+
/// <reference types="mongoose/types/helpers" />
|
|
10
|
+
/// <reference types="mongoose/types/middlewares" />
|
|
11
|
+
/// <reference types="mongoose/types/indexes" />
|
|
12
|
+
/// <reference types="mongoose/types/models" />
|
|
13
|
+
/// <reference types="mongoose/types/mongooseoptions" />
|
|
14
|
+
/// <reference types="mongoose/types/pipelinestage" />
|
|
15
|
+
/// <reference types="mongoose/types/populate" />
|
|
16
|
+
/// <reference types="mongoose/types/query" />
|
|
17
|
+
/// <reference types="mongoose/types/schemaoptions" />
|
|
18
|
+
/// <reference types="mongoose/types/schematypes" />
|
|
19
|
+
/// <reference types="mongoose/types/session" />
|
|
20
|
+
/// <reference types="mongoose/types/types" />
|
|
21
|
+
/// <reference types="mongoose/types/utility" />
|
|
22
|
+
/// <reference types="mongoose/types/validation" />
|
|
23
|
+
/// <reference types="mongoose/types/virtuals" />
|
|
24
|
+
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
+
/// <reference types="mongoose/types/inferrawdoctype" />
|
|
26
|
+
import type { Document } from 'mongoose';
|
|
27
|
+
export interface IPluginAuth extends Document {
|
|
28
|
+
authField: string;
|
|
29
|
+
value: string;
|
|
30
|
+
userId: string;
|
|
31
|
+
pluginKey?: string;
|
|
32
|
+
createdAt?: Date;
|
|
33
|
+
updatedAt?: Date;
|
|
34
|
+
}
|
|
35
|
+
export interface PluginAuthQuery {
|
|
36
|
+
userId: string;
|
|
37
|
+
authField?: string;
|
|
38
|
+
pluginKey?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface FindPluginAuthParams {
|
|
41
|
+
userId: string;
|
|
42
|
+
authField: string;
|
|
43
|
+
}
|
|
44
|
+
export interface FindPluginAuthsByKeysParams {
|
|
45
|
+
userId: string;
|
|
46
|
+
pluginKeys: string[];
|
|
47
|
+
}
|
|
48
|
+
export interface UpdatePluginAuthParams {
|
|
49
|
+
userId: string;
|
|
50
|
+
authField: string;
|
|
51
|
+
pluginKey: string;
|
|
52
|
+
value: string;
|
|
53
|
+
}
|
|
54
|
+
export interface DeletePluginAuthParams {
|
|
55
|
+
userId: string;
|
|
56
|
+
authField?: string;
|
|
57
|
+
pluginKey?: string;
|
|
58
|
+
all?: boolean;
|
|
59
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/// <reference types="mongoose/types/aggregate" />
|
|
2
|
+
/// <reference types="mongoose/types/callback" />
|
|
3
|
+
/// <reference types="mongoose/types/collection" />
|
|
4
|
+
/// <reference types="mongoose/types/connection" />
|
|
5
|
+
/// <reference types="mongoose/types/cursor" />
|
|
6
|
+
/// <reference types="mongoose/types/document" />
|
|
7
|
+
/// <reference types="mongoose/types/error" />
|
|
8
|
+
/// <reference types="mongoose/types/expressions" />
|
|
9
|
+
/// <reference types="mongoose/types/helpers" />
|
|
10
|
+
/// <reference types="mongoose/types/middlewares" />
|
|
11
|
+
/// <reference types="mongoose/types/indexes" />
|
|
12
|
+
/// <reference types="mongoose/types/models" />
|
|
13
|
+
/// <reference types="mongoose/types/mongooseoptions" />
|
|
14
|
+
/// <reference types="mongoose/types/pipelinestage" />
|
|
15
|
+
/// <reference types="mongoose/types/populate" />
|
|
16
|
+
/// <reference types="mongoose/types/query" />
|
|
17
|
+
/// <reference types="mongoose/types/schemaoptions" />
|
|
18
|
+
/// <reference types="mongoose/types/schematypes" />
|
|
19
|
+
/// <reference types="mongoose/types/session" />
|
|
20
|
+
/// <reference types="mongoose/types/types" />
|
|
21
|
+
/// <reference types="mongoose/types/utility" />
|
|
22
|
+
/// <reference types="mongoose/types/validation" />
|
|
23
|
+
/// <reference types="mongoose/types/virtuals" />
|
|
24
|
+
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
+
/// <reference types="mongoose/types/inferrawdoctype" />
|
|
26
|
+
import type { Types } from 'mongoose';
|
|
27
|
+
import type { IMessage } from './message';
|
|
28
|
+
export interface ISharedLink {
|
|
29
|
+
_id?: Types.ObjectId;
|
|
30
|
+
conversationId: string;
|
|
31
|
+
title?: string;
|
|
32
|
+
user?: string;
|
|
33
|
+
messages?: Types.ObjectId[];
|
|
34
|
+
shareId?: string;
|
|
35
|
+
isPublic: boolean;
|
|
36
|
+
createdAt?: Date;
|
|
37
|
+
updatedAt?: Date;
|
|
38
|
+
}
|
|
39
|
+
export interface ShareServiceError extends Error {
|
|
40
|
+
code: string;
|
|
41
|
+
}
|
|
42
|
+
export interface SharedLinksResult {
|
|
43
|
+
links: Array<{
|
|
44
|
+
shareId: string;
|
|
45
|
+
title: string;
|
|
46
|
+
isPublic: boolean;
|
|
47
|
+
createdAt: Date;
|
|
48
|
+
conversationId: string;
|
|
49
|
+
}>;
|
|
50
|
+
nextCursor?: Date;
|
|
51
|
+
hasNextPage: boolean;
|
|
52
|
+
}
|
|
53
|
+
export interface SharedMessagesResult {
|
|
54
|
+
conversationId: string;
|
|
55
|
+
messages: Array<IMessage>;
|
|
56
|
+
shareId: string;
|
|
57
|
+
title?: string;
|
|
58
|
+
isPublic: boolean;
|
|
59
|
+
createdAt?: Date;
|
|
60
|
+
updatedAt?: Date;
|
|
61
|
+
}
|
|
62
|
+
export interface CreateShareResult {
|
|
63
|
+
shareId: string;
|
|
64
|
+
conversationId: string;
|
|
65
|
+
}
|
|
66
|
+
export interface UpdateShareResult {
|
|
67
|
+
shareId: string;
|
|
68
|
+
conversationId: string;
|
|
69
|
+
}
|
|
70
|
+
export interface DeleteShareResult {
|
|
71
|
+
success: boolean;
|
|
72
|
+
shareId: string;
|
|
73
|
+
message: string;
|
|
74
|
+
}
|
|
75
|
+
export interface GetShareLinkResult {
|
|
76
|
+
shareId: string | null;
|
|
77
|
+
success: boolean;
|
|
78
|
+
}
|
|
79
|
+
export interface DeleteAllSharesResult {
|
|
80
|
+
message: string;
|
|
81
|
+
deletedCount: number;
|
|
82
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@librechat/data-schemas",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"description": "Mongoose schemas and models for LibreChat",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
"@types/traverse": "^0.6.37",
|
|
52
52
|
"jest": "^29.5.0",
|
|
53
53
|
"jest-junit": "^16.0.0",
|
|
54
|
+
"mongodb-memory-server": "^10.1.4",
|
|
54
55
|
"rimraf": "^5.0.1",
|
|
55
56
|
"rollup": "^4.22.4",
|
|
56
57
|
"rollup-plugin-generate-package-json": "^3.2.0",
|
|
@@ -60,13 +61,14 @@
|
|
|
60
61
|
"typescript": "^5.0.4"
|
|
61
62
|
},
|
|
62
63
|
"peerDependencies": {
|
|
63
|
-
"keyv": "^5.3.2",
|
|
64
|
-
"mongoose": "^8.12.1",
|
|
65
|
-
"librechat-data-provider": "*",
|
|
66
64
|
"jsonwebtoken": "^9.0.2",
|
|
65
|
+
"keyv": "^5.3.2",
|
|
67
66
|
"klona": "^2.0.6",
|
|
67
|
+
"librechat-data-provider": "*",
|
|
68
68
|
"lodash": "^4.17.21",
|
|
69
69
|
"meilisearch": "^0.38.0",
|
|
70
|
+
"mongoose": "^8.12.1",
|
|
71
|
+
"nanoid": "^3.3.7",
|
|
70
72
|
"traverse": "^0.6.11",
|
|
71
73
|
"winston": "^3.17.0",
|
|
72
74
|
"winston-daily-rotate-file": "^5.0.0"
|
package/README.md
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
# `@librechat/data-schemas`
|
|
2
|
-
|
|
3
|
-
Mongoose schemas and models for LibreChat. This package provides a comprehensive collection of Mongoose schemas used across the LibreChat project, enabling robust data modeling and validation for various entities such as actions, agents, messages, users, and more.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
## Features
|
|
7
|
-
|
|
8
|
-
- **Modular Schemas:** Includes schemas for actions, agents, assistants, balance, banners, categories, conversation tags, conversations, files, keys, messages, plugin authentication, presets, projects, prompts, prompt groups, roles, sessions, shared links, tokens, tool calls, transactions, and users.
|
|
9
|
-
- **TypeScript Support:** Provides TypeScript definitions for type-safe development.
|
|
10
|
-
- **Ready for Mongoose Integration:** Easily integrate with Mongoose to create models and interact with your MongoDB database.
|
|
11
|
-
- **Flexible & Extensible:** Designed to support the evolving needs of LibreChat while being adaptable to other projects.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
## Installation
|
|
15
|
-
|
|
16
|
-
Install the package via npm or yarn:
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
npm install @librechat/data-schemas
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
Or with yarn:
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
yarn add @librechat/data-schemas
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
## Usage
|
|
30
|
-
|
|
31
|
-
After installation, you can import and use the schemas in your project. For example, to create a Mongoose model for a user:
|
|
32
|
-
|
|
33
|
-
```js
|
|
34
|
-
import mongoose from 'mongoose';
|
|
35
|
-
import { userSchema } from '@librechat/data-schemas';
|
|
36
|
-
|
|
37
|
-
const UserModel = mongoose.model('User', userSchema);
|
|
38
|
-
|
|
39
|
-
// Now you can use UserModel to create, read, update, and delete user documents.
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
You can also import other schemas as needed:
|
|
43
|
-
|
|
44
|
-
```js
|
|
45
|
-
import { actionSchema, agentSchema, messageSchema } from '@librechat/data-schemas';
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
Each schema is designed to integrate seamlessly with Mongoose and provides indexes, timestamps, and validations tailored for LibreChat’s use cases.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
## Development
|
|
52
|
-
|
|
53
|
-
This package uses Rollup and TypeScript for building and bundling.
|
|
54
|
-
|
|
55
|
-
### Available Scripts
|
|
56
|
-
|
|
57
|
-
- **Build:**
|
|
58
|
-
Cleans the `dist` directory and builds the package.
|
|
59
|
-
```bash
|
|
60
|
-
npm run build
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
- **Build Watch:**
|
|
64
|
-
Rebuilds automatically on file changes.
|
|
65
|
-
```bash
|
|
66
|
-
npm run build:watch
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
- **Test:**
|
|
70
|
-
Runs tests with coverage in watch mode.
|
|
71
|
-
```bash
|
|
72
|
-
npm run test
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
- **Test (CI):**
|
|
76
|
-
Runs tests with coverage for CI environments.
|
|
77
|
-
```bash
|
|
78
|
-
npm run test:ci
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
- **Verify:**
|
|
82
|
-
Runs tests in CI mode to verify code integrity.
|
|
83
|
-
```bash
|
|
84
|
-
npm run verify
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
- **Clean:**
|
|
88
|
-
Removes the `dist` directory.
|
|
89
|
-
```bash
|
|
90
|
-
npm run clean
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
For those using Bun, equivalent scripts are available:
|
|
94
|
-
- **Bun Clean:** `bun run b:clean`
|
|
95
|
-
- **Bun Build:** `bun run b:build`
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
## Repository & Issues
|
|
99
|
-
|
|
100
|
-
The source code is maintained on GitHub.
|
|
101
|
-
- **Repository:** [LibreChat Repository](https://github.com/danny-avila/LibreChat.git)
|
|
102
|
-
- **Issues & Bug Reports:** [LibreChat Issues](https://github.com/danny-avila/LibreChat/issues)
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
## License
|
|
106
|
-
|
|
107
|
-
This project is licensed under the [MIT License](LICENSE).
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
## Contributing
|
|
111
|
-
|
|
112
|
-
Contributions to improve and expand the data schemas are welcome. If you have suggestions, improvements, or bug fixes, please open an issue or submit a pull request on the [GitHub repository](https://github.com/danny-avila/LibreChat/issues).
|
|
113
|
-
|
|
114
|
-
For more detailed documentation on each schema and model, please refer to the source code or visit the [LibreChat website](https://librechat.ai).
|