@librechat/data-schemas 0.0.3 → 0.0.5

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 +58 -16
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.es.js +58 -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 +45 -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,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;
@@ -1,26 +0,0 @@
1
- import mongoose, { Schema, Document, Types } from 'mongoose';
2
-
3
- export interface ISession extends Document {
4
- refreshTokenHash: string;
5
- expiration: Date;
6
- user: Types.ObjectId;
7
- }
8
-
9
- const sessionSchema: Schema<ISession> = new Schema({
10
- refreshTokenHash: {
11
- type: String,
12
- required: true,
13
- },
14
- expiration: {
15
- type: Date,
16
- required: true,
17
- expires: 0,
18
- },
19
- user: {
20
- type: mongoose.Schema.Types.ObjectId,
21
- ref: 'User',
22
- required: true,
23
- },
24
- });
25
-
26
- export default sessionSchema;
@@ -1,41 +0,0 @@
1
- import mongoose, { Schema, Document, Types } from 'mongoose';
2
-
3
- export interface ISharedLink extends Document {
4
- conversationId: string;
5
- title?: string;
6
- user?: string;
7
- messages?: Types.ObjectId[];
8
- shareId?: string;
9
- isPublic: boolean;
10
- createdAt?: Date;
11
- updatedAt?: Date;
12
- }
13
-
14
- const shareSchema: Schema<ISharedLink> = new Schema(
15
- {
16
- conversationId: {
17
- type: String,
18
- required: true,
19
- },
20
- title: {
21
- type: String,
22
- index: true,
23
- },
24
- user: {
25
- type: String,
26
- index: true,
27
- },
28
- messages: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Message' }],
29
- shareId: {
30
- type: String,
31
- index: true,
32
- },
33
- isPublic: {
34
- type: Boolean,
35
- default: true,
36
- },
37
- },
38
- { timestamps: true },
39
- );
40
-
41
- export default shareSchema;
@@ -1,50 +0,0 @@
1
- import { Schema, Document, Types } from 'mongoose';
2
-
3
- export interface IToken extends Document {
4
- userId: Types.ObjectId;
5
- email?: string;
6
- type?: string;
7
- identifier?: string;
8
- token: string;
9
- createdAt: Date;
10
- expiresAt: Date;
11
- metadata?: Map<string, unknown>;
12
- }
13
-
14
- const tokenSchema: Schema<IToken> = new Schema({
15
- userId: {
16
- type: Schema.Types.ObjectId,
17
- required: true,
18
- ref: 'user',
19
- },
20
- email: {
21
- type: String,
22
- },
23
- type: {
24
- type: String,
25
- },
26
- identifier: {
27
- type: String,
28
- },
29
- token: {
30
- type: String,
31
- required: true,
32
- },
33
- createdAt: {
34
- type: Date,
35
- required: true,
36
- default: Date.now,
37
- },
38
- expiresAt: {
39
- type: Date,
40
- required: true,
41
- },
42
- metadata: {
43
- type: Map,
44
- of: Schema.Types.Mixed,
45
- },
46
- });
47
-
48
- tokenSchema.index({ expiresAt: 1 }, { expireAfterSeconds: 0 });
49
-
50
- export default tokenSchema;
@@ -1,55 +0,0 @@
1
- import mongoose, { Schema, Document, Types } from 'mongoose';
2
- import type { TAttachment } from 'librechat-data-provider';
3
-
4
- export interface IToolCallData extends Document {
5
- conversationId: string;
6
- messageId: string;
7
- toolId: string;
8
- user: Types.ObjectId;
9
- result?: unknown;
10
- attachments?: TAttachment[];
11
- blockIndex?: number;
12
- partIndex?: number;
13
- createdAt?: Date;
14
- updatedAt?: Date;
15
- }
16
-
17
- const toolCallSchema: Schema<IToolCallData> = new Schema(
18
- {
19
- conversationId: {
20
- type: String,
21
- required: true,
22
- },
23
- messageId: {
24
- type: String,
25
- required: true,
26
- },
27
- toolId: {
28
- type: String,
29
- required: true,
30
- },
31
- user: {
32
- type: mongoose.Schema.Types.ObjectId,
33
- ref: 'User',
34
- required: true,
35
- },
36
- result: {
37
- type: mongoose.Schema.Types.Mixed,
38
- },
39
- attachments: {
40
- type: mongoose.Schema.Types.Mixed,
41
- },
42
- blockIndex: {
43
- type: Number,
44
- },
45
- partIndex: {
46
- type: Number,
47
- },
48
- },
49
- { timestamps: true },
50
- );
51
-
52
- toolCallSchema.index({ messageId: 1, user: 1 });
53
- toolCallSchema.index({ conversationId: 1, user: 1 });
54
-
55
- export default toolCallSchema;
@@ -1,60 +0,0 @@
1
- import mongoose, { Schema, Document, Types } from 'mongoose';
2
-
3
- // @ts-ignore
4
- export interface ITransaction extends Document {
5
- user: Types.ObjectId;
6
- conversationId?: string;
7
- tokenType: 'prompt' | 'completion' | 'credits';
8
- model?: string;
9
- context?: string;
10
- valueKey?: string;
11
- rate?: number;
12
- rawAmount?: number;
13
- tokenValue?: number;
14
- inputTokens?: number;
15
- writeTokens?: number;
16
- readTokens?: number;
17
- createdAt?: Date;
18
- updatedAt?: Date;
19
- }
20
-
21
- const transactionSchema: Schema<ITransaction> = new Schema(
22
- {
23
- user: {
24
- type: mongoose.Schema.Types.ObjectId,
25
- ref: 'User',
26
- index: true,
27
- required: true,
28
- },
29
- conversationId: {
30
- type: String,
31
- ref: 'Conversation',
32
- index: true,
33
- },
34
- tokenType: {
35
- type: String,
36
- enum: ['prompt', 'completion', 'credits'],
37
- required: true,
38
- },
39
- model: {
40
- type: String,
41
- },
42
- context: {
43
- type: String,
44
- },
45
- valueKey: {
46
- type: String,
47
- },
48
- rate: Number,
49
- rawAmount: Number,
50
- tokenValue: Number,
51
- inputTokens: { type: Number },
52
- writeTokens: { type: Number },
53
- readTokens: { type: Number },
54
- },
55
- {
56
- timestamps: true,
57
- },
58
- );
59
-
60
- export default transactionSchema;
@@ -1,163 +0,0 @@
1
- import { Schema, Document } from 'mongoose';
2
- import { SystemRoles } from 'librechat-data-provider';
3
-
4
- export interface IUser extends Document {
5
- name?: string;
6
- username?: string;
7
- email: string;
8
- emailVerified: boolean;
9
- password?: string;
10
- avatar?: string;
11
- provider: string;
12
- role?: string;
13
- googleId?: string;
14
- facebookId?: string;
15
- openidId?: string;
16
- ldapId?: string;
17
- githubId?: string;
18
- discordId?: string;
19
- appleId?: string;
20
- plugins?: unknown[];
21
- twoFactorEnabled?: boolean;
22
- totpSecret?: string;
23
- backupCodes?: Array<{
24
- codeHash: string;
25
- used: boolean;
26
- usedAt?: Date | null;
27
- }>;
28
- refreshToken?: Array<{
29
- refreshToken: string;
30
- }>;
31
- expiresAt?: Date;
32
- termsAccepted?: boolean;
33
- createdAt?: Date;
34
- updatedAt?: Date;
35
- }
36
-
37
- // Session sub-schema
38
- const SessionSchema = new Schema(
39
- {
40
- refreshToken: {
41
- type: String,
42
- default: '',
43
- },
44
- },
45
- { _id: false },
46
- );
47
-
48
- // Backup code sub-schema
49
- const BackupCodeSchema = new Schema(
50
- {
51
- codeHash: { type: String, required: true },
52
- used: { type: Boolean, default: false },
53
- usedAt: { type: Date, default: null },
54
- },
55
- { _id: false },
56
- );
57
-
58
- const User = new Schema<IUser>(
59
- {
60
- name: {
61
- type: String,
62
- },
63
- username: {
64
- type: String,
65
- lowercase: true,
66
- default: '',
67
- },
68
- email: {
69
- type: String,
70
- required: [true, 'can\'t be blank'],
71
- lowercase: true,
72
- unique: true,
73
- match: [/\S+@\S+\.\S+/, 'is invalid'],
74
- index: true,
75
- },
76
- emailVerified: {
77
- type: Boolean,
78
- required: true,
79
- default: false,
80
- },
81
- password: {
82
- type: String,
83
- trim: true,
84
- minlength: 8,
85
- maxlength: 128,
86
- },
87
- avatar: {
88
- type: String,
89
- required: false,
90
- },
91
- provider: {
92
- type: String,
93
- required: true,
94
- default: 'local',
95
- },
96
- role: {
97
- type: String,
98
- default: SystemRoles.USER,
99
- },
100
- googleId: {
101
- type: String,
102
- unique: true,
103
- sparse: true,
104
- },
105
- facebookId: {
106
- type: String,
107
- unique: true,
108
- sparse: true,
109
- },
110
- openidId: {
111
- type: String,
112
- unique: true,
113
- sparse: true,
114
- },
115
- ldapId: {
116
- type: String,
117
- unique: true,
118
- sparse: true,
119
- },
120
- githubId: {
121
- type: String,
122
- unique: true,
123
- sparse: true,
124
- },
125
- discordId: {
126
- type: String,
127
- unique: true,
128
- sparse: true,
129
- },
130
- appleId: {
131
- type: String,
132
- unique: true,
133
- sparse: true,
134
- },
135
- plugins: {
136
- type: Array,
137
- },
138
- twoFactorEnabled: {
139
- type: Boolean,
140
- default: false,
141
- },
142
- totpSecret: {
143
- type: String,
144
- },
145
- backupCodes: {
146
- type: [BackupCodeSchema],
147
- },
148
- refreshToken: {
149
- type: [SessionSchema],
150
- },
151
- expiresAt: {
152
- type: Date,
153
- expires: 604800, // 7 days in seconds
154
- },
155
- termsAccepted: {
156
- type: Boolean,
157
- default: false,
158
- },
159
- },
160
- { timestamps: true },
161
- );
162
-
163
- export default User;
package/tsconfig.json DELETED
@@ -1,28 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "declaration": true,
4
- "declarationDir": "./dist/types",
5
- "module": "esnext",
6
- "noImplicitAny": true,
7
- "outDir": "./dist",
8
- "target": "es2015",
9
- "moduleResolution": "node",
10
- "lib": ["es2017", "dom", "ES2021.String"],
11
- "skipLibCheck": true,
12
- "esModuleInterop": true,
13
- "strict": true,
14
- "forceConsistentCasingInFileNames": true,
15
- "resolveJsonModule": true,
16
- "isolatedModules": true,
17
- "noEmit": false,
18
- "sourceMap": true,
19
- "baseUrl": "."
20
- },
21
- "ts-node": {
22
- "experimentalSpecifierResolution": "node",
23
- "transpileOnly": true,
24
- "esm": true
25
- },
26
- "exclude": ["node_modules", "dist", "types"],
27
- "include": ["src/**/*", "types/index.d.ts", "types/react-query/index.d.ts"]
28
- }
@@ -1,10 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "noEmit": true,
5
- "outDir": "./dist/tests",
6
- "baseUrl": "."
7
- },
8
- "include": ["specs/**/*", "src/**/*"],
9
- "exclude": ["node_modules", "dist"]
10
- }