@librechat/data-schemas 0.0.3 → 0.0.4

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.
Files changed (61) hide show
  1. package/dist/index.cjs +35 -16
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.es.js +35 -16
  4. package/dist/index.es.js.map +1 -1
  5. package/dist/types/index.d.ts +46 -0
  6. package/dist/types/schema/action.d.ts +62 -0
  7. package/dist/types/schema/agent.d.ts +64 -0
  8. package/dist/types/schema/assistant.d.ts +49 -0
  9. package/dist/types/schema/balance.d.ts +40 -0
  10. package/dist/types/schema/banner.d.ts +44 -0
  11. package/dist/types/schema/categories.d.ts +40 -0
  12. package/dist/types/schema/conversationTag.d.ts +43 -0
  13. package/dist/types/schema/convo.d.ts +76 -0
  14. package/dist/types/schema/defaults.d.ts +169 -0
  15. package/dist/types/schema/file.d.ts +53 -0
  16. package/dist/types/schema/key.d.ts +34 -0
  17. package/dist/types/schema/message.d.ts +63 -0
  18. package/dist/types/schema/pluginAuth.d.ts +36 -0
  19. package/dist/types/schema/preset.d.ts +73 -0
  20. package/dist/types/schema/project.d.ts +43 -0
  21. package/dist/types/schema/prompt.d.ts +36 -0
  22. package/dist/types/schema/promptGroup.d.ts +51 -0
  23. package/dist/types/schema/role.d.ts +31 -0
  24. package/dist/types/schema/session.d.ts +33 -0
  25. package/dist/types/schema/share.d.ts +38 -0
  26. package/dist/types/schema/token.d.ts +38 -0
  27. package/dist/types/schema/toolCall.d.ts +41 -0
  28. package/dist/types/schema/transaction.d.ts +44 -0
  29. package/dist/types/schema/user.d.ts +68 -0
  30. package/package.json +16 -7
  31. package/babel.config.cjs +0 -4
  32. package/jest.config.mjs +0 -19
  33. package/librechat-data-schemas-0.0.3.tgz +0 -0
  34. package/rollup.config.js +0 -25
  35. package/src/index.ts +0 -49
  36. package/src/schema/action.ts +0 -78
  37. package/src/schema/agent.ts +0 -124
  38. package/src/schema/assistant.ts +0 -52
  39. package/src/schema/balance.ts +0 -22
  40. package/src/schema/banner.ts +0 -43
  41. package/src/schema/categories.ts +0 -21
  42. package/src/schema/conversationTag.ts +0 -41
  43. package/src/schema/convo.ts +0 -101
  44. package/src/schema/defaults.ts +0 -138
  45. package/src/schema/file.ts +0 -111
  46. package/src/schema/key.ts +0 -31
  47. package/src/schema/message.ts +0 -185
  48. package/src/schema/pluginAuth.ts +0 -33
  49. package/src/schema/preset.ts +0 -85
  50. package/src/schema/project.ts +0 -34
  51. package/src/schema/prompt.ts +0 -42
  52. package/src/schema/promptGroup.ts +0 -85
  53. package/src/schema/role.ts +0 -91
  54. package/src/schema/session.ts +0 -26
  55. package/src/schema/share.ts +0 -41
  56. package/src/schema/token.ts +0 -50
  57. package/src/schema/toolCall.ts +0 -55
  58. package/src/schema/transaction.ts +0 -60
  59. package/src/schema/user.ts +0 -163
  60. package/tsconfig.json +0 -28
  61. package/tsconfig.spec.json +0 -10
@@ -1,111 +0,0 @@
1
- import mongoose, { Schema, Document, Types } from 'mongoose';
2
- import { FileSources } from 'librechat-data-provider';
3
-
4
- // @ts-ignore
5
- export interface IMongoFile extends Document {
6
- user: Types.ObjectId;
7
- conversationId?: string;
8
- file_id: string;
9
- temp_file_id?: string;
10
- bytes: number;
11
- text?: string;
12
- filename: string;
13
- filepath: string;
14
- object: 'file';
15
- embedded?: boolean;
16
- type: string;
17
- context?: string;
18
- usage: number;
19
- source: string;
20
- model?: string;
21
- width?: number;
22
- height?: number;
23
- metadata?: {
24
- fileIdentifier?: string;
25
- };
26
- expiresAt?: Date;
27
- createdAt?: Date;
28
- updatedAt?: Date;
29
- }
30
-
31
- const file: Schema<IMongoFile> = new Schema(
32
- {
33
- user: {
34
- type: mongoose.Schema.Types.ObjectId,
35
- ref: 'User',
36
- index: true,
37
- required: true,
38
- },
39
- conversationId: {
40
- type: String,
41
- ref: 'Conversation',
42
- index: true,
43
- },
44
- file_id: {
45
- type: String,
46
- index: true,
47
- required: true,
48
- },
49
- temp_file_id: {
50
- type: String,
51
- },
52
- bytes: {
53
- type: Number,
54
- required: true,
55
- },
56
- filename: {
57
- type: String,
58
- required: true,
59
- },
60
- filepath: {
61
- type: String,
62
- required: true,
63
- },
64
- object: {
65
- type: String,
66
- required: true,
67
- default: 'file',
68
- },
69
- embedded: {
70
- type: Boolean,
71
- },
72
- type: {
73
- type: String,
74
- required: true,
75
- },
76
- text: {
77
- type: String,
78
- },
79
- context: {
80
- type: String,
81
- },
82
- usage: {
83
- type: Number,
84
- required: true,
85
- default: 0,
86
- },
87
- source: {
88
- type: String,
89
- default: FileSources.local,
90
- },
91
- model: {
92
- type: String,
93
- },
94
- width: Number,
95
- height: Number,
96
- metadata: {
97
- fileIdentifier: String,
98
- },
99
- expiresAt: {
100
- type: Date,
101
- expires: 3600, // 1 hour in seconds
102
- },
103
- },
104
- {
105
- timestamps: true,
106
- },
107
- );
108
-
109
- file.index({ createdAt: 1, updatedAt: 1 });
110
-
111
- export default file;
package/src/schema/key.ts DELETED
@@ -1,31 +0,0 @@
1
- import mongoose, { Schema, Document, Types } from 'mongoose';
2
-
3
- export interface IKey extends Document {
4
- userId: Types.ObjectId;
5
- name: string;
6
- value: string;
7
- expiresAt?: Date;
8
- }
9
-
10
- const keySchema: Schema<IKey> = new Schema({
11
- userId: {
12
- type: mongoose.Schema.Types.ObjectId,
13
- ref: 'User',
14
- required: true,
15
- },
16
- name: {
17
- type: String,
18
- required: true,
19
- },
20
- value: {
21
- type: String,
22
- required: true,
23
- },
24
- expiresAt: {
25
- type: Date,
26
- },
27
- });
28
-
29
- keySchema.index({ expiresAt: 1 }, { expireAfterSeconds: 0 });
30
-
31
- export default keySchema;
@@ -1,185 +0,0 @@
1
- import mongoose, { Schema, Document } from 'mongoose';
2
-
3
- // @ts-ignore
4
- export interface IMessage extends Document {
5
- messageId: string;
6
- conversationId: string;
7
- user: string;
8
- model?: string;
9
- endpoint?: string;
10
- conversationSignature?: string;
11
- clientId?: string;
12
- invocationId?: number;
13
- parentMessageId?: string;
14
- tokenCount?: number;
15
- summaryTokenCount?: number;
16
- sender?: string;
17
- text?: string;
18
- summary?: string;
19
- isCreatedByUser: boolean;
20
- unfinished?: boolean;
21
- error?: boolean;
22
- finish_reason?: string;
23
- _meiliIndex?: boolean;
24
- files?: unknown[];
25
- plugin?: {
26
- latest?: string;
27
- inputs?: unknown[];
28
- outputs?: string;
29
- };
30
- plugins?: unknown[];
31
- content?: unknown[];
32
- thread_id?: string;
33
- iconURL?: string;
34
- attachments?: unknown[];
35
- expiredAt?: Date;
36
- createdAt?: Date;
37
- updatedAt?: Date;
38
- }
39
-
40
- const messageSchema: Schema<IMessage> = new Schema(
41
- {
42
- messageId: {
43
- type: String,
44
- unique: true,
45
- required: true,
46
- index: true,
47
- meiliIndex: true,
48
- },
49
- conversationId: {
50
- type: String,
51
- index: true,
52
- required: true,
53
- meiliIndex: true,
54
- },
55
- user: {
56
- type: String,
57
- index: true,
58
- required: true,
59
- default: null,
60
- },
61
- model: {
62
- type: String,
63
- default: null,
64
- },
65
- endpoint: {
66
- type: String,
67
- },
68
- conversationSignature: {
69
- type: String,
70
- },
71
- clientId: {
72
- type: String,
73
- },
74
- invocationId: {
75
- type: Number,
76
- },
77
- parentMessageId: {
78
- type: String,
79
- },
80
- tokenCount: {
81
- type: Number,
82
- },
83
- summaryTokenCount: {
84
- type: Number,
85
- },
86
- sender: {
87
- type: String,
88
- meiliIndex: true,
89
- },
90
- text: {
91
- type: String,
92
- meiliIndex: true,
93
- },
94
- summary: {
95
- type: String,
96
- },
97
- isCreatedByUser: {
98
- type: Boolean,
99
- required: true,
100
- default: false,
101
- },
102
- unfinished: {
103
- type: Boolean,
104
- default: false,
105
- },
106
- error: {
107
- type: Boolean,
108
- default: false,
109
- },
110
- finish_reason: {
111
- type: String,
112
- },
113
- _meiliIndex: {
114
- type: Boolean,
115
- required: false,
116
- select: false,
117
- default: false,
118
- },
119
- files: { type: [{ type: mongoose.Schema.Types.Mixed }], default: undefined },
120
- plugin: {
121
- type: {
122
- latest: {
123
- type: String,
124
- required: false,
125
- },
126
- inputs: {
127
- type: [mongoose.Schema.Types.Mixed],
128
- required: false,
129
- default: undefined,
130
- },
131
- outputs: {
132
- type: String,
133
- required: false,
134
- },
135
- },
136
- default: undefined,
137
- },
138
- plugins: { type: [{ type: mongoose.Schema.Types.Mixed }], default: undefined },
139
- content: {
140
- type: [{ type: mongoose.Schema.Types.Mixed }],
141
- default: undefined,
142
- meiliIndex: true,
143
- },
144
- thread_id: {
145
- type: String,
146
- },
147
- /* frontend components */
148
- iconURL: {
149
- type: String,
150
- },
151
- attachments: { type: [{ type: mongoose.Schema.Types.Mixed }], default: undefined },
152
- /*
153
- attachments: {
154
- type: [
155
- {
156
- file_id: String,
157
- filename: String,
158
- filepath: String,
159
- expiresAt: Date,
160
- width: Number,
161
- height: Number,
162
- type: String,
163
- conversationId: String,
164
- messageId: {
165
- type: String,
166
- required: true,
167
- },
168
- toolCallId: String,
169
- },
170
- ],
171
- default: undefined,
172
- },
173
- */
174
- expiredAt: {
175
- type: Date,
176
- },
177
- },
178
- { timestamps: true },
179
- );
180
-
181
- messageSchema.index({ expiredAt: 1 }, { expireAfterSeconds: 0 });
182
- messageSchema.index({ createdAt: 1 });
183
- messageSchema.index({ messageId: 1, user: 1 }, { unique: true });
184
-
185
- export default messageSchema;
@@ -1,33 +0,0 @@
1
- import { Schema, Document } from 'mongoose';
2
-
3
- export interface IPluginAuth extends Document {
4
- authField: string;
5
- value: string;
6
- userId: string;
7
- pluginKey?: string;
8
- createdAt?: Date;
9
- updatedAt?: Date;
10
- }
11
-
12
- const pluginAuthSchema: Schema<IPluginAuth> = new Schema(
13
- {
14
- authField: {
15
- type: String,
16
- required: true,
17
- },
18
- value: {
19
- type: String,
20
- required: true,
21
- },
22
- userId: {
23
- type: String,
24
- required: true,
25
- },
26
- pluginKey: {
27
- type: String,
28
- },
29
- },
30
- { timestamps: true },
31
- );
32
-
33
- export default pluginAuthSchema;
@@ -1,85 +0,0 @@
1
- import mongoose, { Schema, Document } from 'mongoose';
2
- import { conversationPreset } from './defaults';
3
-
4
- // @ts-ignore
5
- export interface IPreset extends Document {
6
- presetId: string;
7
- title: string;
8
- user: string | null;
9
- defaultPreset?: boolean;
10
- order?: number;
11
- // Additional fields from conversationPreset and others will be available via an index signature.
12
- endpoint?: string;
13
- endpointType?: string;
14
- model?: string;
15
- region?: string;
16
- chatGptLabel?: string;
17
- examples?: unknown[];
18
- modelLabel?: string;
19
- promptPrefix?: string;
20
- temperature?: number;
21
- top_p?: number;
22
- topP?: number;
23
- topK?: number;
24
- maxOutputTokens?: number;
25
- maxTokens?: number;
26
- presence_penalty?: number;
27
- frequency_penalty?: number;
28
- file_ids?: string[];
29
- resendImages?: boolean;
30
- promptCache?: boolean;
31
- thinking?: boolean;
32
- thinkingBudget?: number;
33
- system?: string;
34
- resendFiles?: boolean;
35
- imageDetail?: string;
36
- agent_id?: string;
37
- assistant_id?: string;
38
- instructions?: string;
39
- stop?: string[];
40
- isArchived?: boolean;
41
- iconURL?: string;
42
- greeting?: string;
43
- spec?: string;
44
- tags?: string[];
45
- tools?: string[];
46
- maxContextTokens?: number;
47
- max_tokens?: number;
48
- reasoning_effort?: string;
49
- // end of additional fields
50
- agentOptions?: unknown;
51
- }
52
-
53
- const presetSchema: Schema<IPreset> = new Schema(
54
- {
55
- presetId: {
56
- type: String,
57
- unique: true,
58
- required: true,
59
- index: true,
60
- },
61
- title: {
62
- type: String,
63
- default: 'New Chat',
64
- meiliIndex: true,
65
- },
66
- user: {
67
- type: String,
68
- default: null,
69
- },
70
- defaultPreset: {
71
- type: Boolean,
72
- },
73
- order: {
74
- type: Number,
75
- },
76
- ...conversationPreset,
77
- agentOptions: {
78
- type: mongoose.Schema.Types.Mixed,
79
- default: null,
80
- },
81
- },
82
- { timestamps: true },
83
- );
84
-
85
- export default presetSchema;
@@ -1,34 +0,0 @@
1
- import { Schema, Document, Types } from 'mongoose';
2
-
3
- export interface IMongoProject extends Document {
4
- name: string;
5
- promptGroupIds: Types.ObjectId[];
6
- agentIds: string[];
7
- createdAt?: Date;
8
- updatedAt?: Date;
9
- }
10
-
11
- const projectSchema = new Schema<IMongoProject>(
12
- {
13
- name: {
14
- type: String,
15
- required: true,
16
- index: true,
17
- },
18
- promptGroupIds: {
19
- type: [Schema.Types.ObjectId],
20
- ref: 'PromptGroup',
21
- default: [],
22
- },
23
- agentIds: {
24
- type: [String],
25
- ref: 'Agent',
26
- default: [],
27
- },
28
- },
29
- {
30
- timestamps: true,
31
- },
32
- );
33
-
34
- export default projectSchema;
@@ -1,42 +0,0 @@
1
- import { Schema, Document, Types } from 'mongoose';
2
-
3
- export interface IPrompt extends Document {
4
- groupId: Types.ObjectId;
5
- author: Types.ObjectId;
6
- prompt: string;
7
- type: 'text' | 'chat';
8
- createdAt?: Date;
9
- updatedAt?: Date;
10
- }
11
-
12
- const promptSchema: Schema<IPrompt> = new Schema(
13
- {
14
- groupId: {
15
- type: Schema.Types.ObjectId,
16
- ref: 'PromptGroup',
17
- required: true,
18
- index: true,
19
- },
20
- author: {
21
- type: Schema.Types.ObjectId,
22
- ref: 'User',
23
- required: true,
24
- },
25
- prompt: {
26
- type: String,
27
- required: true,
28
- },
29
- type: {
30
- type: String,
31
- enum: ['text', 'chat'],
32
- required: true,
33
- },
34
- },
35
- {
36
- timestamps: true,
37
- },
38
- );
39
-
40
- promptSchema.index({ createdAt: 1, updatedAt: 1 });
41
-
42
- export default promptSchema;
@@ -1,85 +0,0 @@
1
- import { Schema, Document, Types } from 'mongoose';
2
- import { Constants } from 'librechat-data-provider';
3
-
4
- export interface IPromptGroup {
5
- name: string;
6
- numberOfGenerations: number;
7
- oneliner: string;
8
- category: string;
9
- projectIds: Types.ObjectId[];
10
- productionId: Types.ObjectId;
11
- author: Types.ObjectId;
12
- authorName: string;
13
- command?: string;
14
- createdAt?: Date;
15
- updatedAt?: Date;
16
- }
17
-
18
- export interface IPromptGroupDocument extends IPromptGroup, Document {}
19
-
20
- const promptGroupSchema = new Schema<IPromptGroupDocument>(
21
- {
22
- name: {
23
- type: String,
24
- required: true,
25
- index: true,
26
- },
27
- numberOfGenerations: {
28
- type: Number,
29
- default: 0,
30
- },
31
- oneliner: {
32
- type: String,
33
- default: '',
34
- },
35
- category: {
36
- type: String,
37
- default: '',
38
- index: true,
39
- },
40
- projectIds: {
41
- type: [Schema.Types.ObjectId],
42
- ref: 'Project',
43
- index: true,
44
- default: [],
45
- },
46
- productionId: {
47
- type: Schema.Types.ObjectId,
48
- ref: 'Prompt',
49
- required: true,
50
- index: true,
51
- },
52
- author: {
53
- type: Schema.Types.ObjectId,
54
- ref: 'User',
55
- required: true,
56
- index: true,
57
- },
58
- authorName: {
59
- type: String,
60
- required: true,
61
- },
62
- command: {
63
- type: String,
64
- index: true,
65
- validate: {
66
- validator: function (v: unknown): boolean {
67
- return v === undefined || v === null || v === '' || /^[a-z0-9-]+$/.test(v);
68
- },
69
- message: (props: unknown) =>
70
- `${props.value} is not a valid command. Only lowercase alphanumeric characters and hyphens are allowed.`,
71
- },
72
- maxlength: [
73
- Constants.COMMANDS_MAX_LENGTH as number,
74
- `Command cannot be longer than ${Constants.COMMANDS_MAX_LENGTH} characters`,
75
- ],
76
- }, // Casting here bypasses the type error for the command field.
77
- },
78
- {
79
- timestamps: true,
80
- },
81
- );
82
-
83
- promptGroupSchema.index({ createdAt: 1, updatedAt: 1 });
84
-
85
- export default promptGroupSchema;
@@ -1,91 +0,0 @@
1
- import { Schema, Document } from 'mongoose';
2
- import { PermissionTypes, Permissions } from 'librechat-data-provider';
3
-
4
- export interface IRole extends Document {
5
- name: string;
6
- [PermissionTypes.BOOKMARKS]?: {
7
- [Permissions.USE]?: boolean;
8
- };
9
- [PermissionTypes.PROMPTS]?: {
10
- [Permissions.SHARED_GLOBAL]?: boolean;
11
- [Permissions.USE]?: boolean;
12
- [Permissions.CREATE]?: boolean;
13
- };
14
- [PermissionTypes.AGENTS]?: {
15
- [Permissions.SHARED_GLOBAL]?: boolean;
16
- [Permissions.USE]?: boolean;
17
- [Permissions.CREATE]?: boolean;
18
- };
19
- [PermissionTypes.MULTI_CONVO]?: {
20
- [Permissions.USE]?: boolean;
21
- };
22
- [PermissionTypes.TEMPORARY_CHAT]?: {
23
- [Permissions.USE]?: boolean;
24
- };
25
- [PermissionTypes.RUN_CODE]?: {
26
- [Permissions.USE]?: boolean;
27
- };
28
- }
29
-
30
- const roleSchema: Schema<IRole> = new Schema({
31
- name: {
32
- type: String,
33
- required: true,
34
- unique: true,
35
- index: true,
36
- },
37
- [PermissionTypes.BOOKMARKS]: {
38
- [Permissions.USE]: {
39
- type: Boolean,
40
- default: true,
41
- },
42
- },
43
- [PermissionTypes.PROMPTS]: {
44
- [Permissions.SHARED_GLOBAL]: {
45
- type: Boolean,
46
- default: false,
47
- },
48
- [Permissions.USE]: {
49
- type: Boolean,
50
- default: true,
51
- },
52
- [Permissions.CREATE]: {
53
- type: Boolean,
54
- default: true,
55
- },
56
- },
57
- [PermissionTypes.AGENTS]: {
58
- [Permissions.SHARED_GLOBAL]: {
59
- type: Boolean,
60
- default: false,
61
- },
62
- [Permissions.USE]: {
63
- type: Boolean,
64
- default: true,
65
- },
66
- [Permissions.CREATE]: {
67
- type: Boolean,
68
- default: true,
69
- },
70
- },
71
- [PermissionTypes.MULTI_CONVO]: {
72
- [Permissions.USE]: {
73
- type: Boolean,
74
- default: true,
75
- },
76
- },
77
- [PermissionTypes.TEMPORARY_CHAT]: {
78
- [Permissions.USE]: {
79
- type: Boolean,
80
- default: true,
81
- },
82
- },
83
- [PermissionTypes.RUN_CODE]: {
84
- [Permissions.USE]: {
85
- type: Boolean,
86
- default: true,
87
- },
88
- },
89
- });
90
-
91
- export default roleSchema;