diff --git a/package-lock.json b/package-lock.json index f71a330cb3..c391726fae 100644 --- a/package-lock.json +++ b/package-lock.json @@ -44120,7 +44120,7 @@ }, "packages/data-schemas": { "name": "@librechat/data-schemas", - "version": "0.0.3", + "version": "0.0.4", "license": "MIT", "dependencies": { "mongoose": "^8.12.1" diff --git a/packages/data-schemas/package.json b/packages/data-schemas/package.json index b1845b36a9..5d1ab2cf4e 100644 --- a/packages/data-schemas/package.json +++ b/packages/data-schemas/package.json @@ -1,8 +1,8 @@ { "name": "@librechat/data-schemas", - "version": "0.0.3", - "type": "module", + "version": "0.0.4", "description": "Mongoose schemas and models for LibreChat", + "type": "module", "main": "dist/index.cjs", "module": "dist/index.es.js", "types": "./dist/types/index.d.ts", @@ -13,6 +13,9 @@ "types": "./dist/types/index.d.ts" } }, + "files": [ + "dist" + ], "scripts": { "clean": "rimraf dist", "build": "npm run clean && rollup -c --silent --bundleConfigAsCjs", @@ -55,14 +58,20 @@ "ts-node": "^10.9.2", "typescript": "^5.0.4" }, - "publishConfig": { - "registry": "https://registry.npmjs.org/", - "access": "public" - }, "dependencies": { "mongoose": "^8.12.1" }, "peerDependencies": { "keyv": "^4.5.4" - } + }, + "publishConfig": { + "registry": "https://registry.npmjs.org/", + "access": "public" + }, + "keywords": [ + "mongoose", + "schema", + "typescript", + "librechat" + ] } diff --git a/packages/data-schemas/rollup.config.js b/packages/data-schemas/rollup.config.js index 8b27ce81cb..c9f8838e77 100644 --- a/packages/data-schemas/rollup.config.js +++ b/packages/data-schemas/rollup.config.js @@ -1,25 +1,40 @@ import json from '@rollup/plugin-json'; import typescript from '@rollup/plugin-typescript'; import commonjs from '@rollup/plugin-commonjs'; +import nodeResolve from '@rollup/plugin-node-resolve'; +import peerDepsExternal from 'rollup-plugin-peer-deps-external'; export default { input: 'src/index.ts', output: [ { - file: 'dist/index.cjs', // Changed from index.js to index.cjs - format: 'cjs', + file: 'dist/index.es.js', + format: 'es', sourcemap: true, - exports: 'named', }, { - file: 'dist/index.es.js', - format: 'esm', + file: 'dist/index.cjs', + format: 'cjs', sourcemap: true, - exports: 'named', }, ], - plugins: [json(), commonjs(), typescript({ tsconfig: './tsconfig.json' })], - external: [ - // list your external dependencies + plugins: [ + // Allow importing JSON files + json(), + // Automatically externalize peer dependencies + peerDepsExternal(), + // Resolve modules from node_modules + nodeResolve(), + // Convert CommonJS modules to ES6 + commonjs(), + // Compile TypeScript files and generate type declarations + typescript({ + tsconfig: './tsconfig.json', + declaration: true, + declarationDir: 'dist/types', + rootDir: 'src', + }), ], + // Do not bundle these external dependencies + external: ['mongoose'], }; diff --git a/packages/data-schemas/src/index.ts b/packages/data-schemas/src/index.ts index 2374afcac9..4b3af06b8e 100644 --- a/packages/data-schemas/src/index.ts +++ b/packages/data-schemas/src/index.ts @@ -1,49 +1,68 @@ -import actionSchema from './schema/action'; -import agentSchema from './schema/agent'; -import assistantSchema from './schema/assistant'; -import balanceSchema from './schema/balance'; -import bannerSchema from './schema/banner'; -import categoriesSchema from './schema/categories'; -import conversationTagSchema from './schema/conversationTag'; -import convoSchema from './schema/convo'; -import fileSchema from './schema/file'; -import keySchema from './schema/key'; -import messageSchema from './schema/message'; -import pluginAuthSchema from './schema/pluginAuth'; -import presetSchema from './schema/preset'; -import projectSchema from './schema/project'; -import promptSchema from './schema/prompt'; -import promptGroupSchema from './schema/promptGroup'; -import roleSchema from './schema/role'; -import sessionSchema from './schema/session'; -import shareSchema from './schema/share'; -import tokenSchema from './schema/token'; -import toolCallSchema from './schema/toolCall'; -import transactionSchema from './schema/transaction'; -import userSchema from './schema/user'; +export { default as actionSchema } from './schema/action'; +export type { IAction } from './schema/action'; -export { - actionSchema, - agentSchema, - assistantSchema, - balanceSchema, - bannerSchema, - categoriesSchema, - conversationTagSchema, - convoSchema, - fileSchema, - keySchema, - messageSchema, - pluginAuthSchema, - presetSchema, - projectSchema, - promptSchema, - promptGroupSchema, - roleSchema, - sessionSchema, - shareSchema, - tokenSchema, - toolCallSchema, - transactionSchema, - userSchema, -}; +export { default as agentSchema } from './schema/agent'; +export type { IAgent } from './schema/agent'; + +export { default as assistantSchema } from './schema/assistant'; +export type { IAssistant } from './schema/assistant'; + +export { default as balanceSchema } from './schema/balance'; +export type { IBalance } from './schema/balance'; + +export { default as bannerSchema } from './schema/banner'; +export type { IBanner } from './schema/banner'; + +export { default as categoriesSchema } from './schema/categories'; +export type { ICategory } from './schema/categories'; + +export { default as conversationTagSchema } from './schema/conversationTag'; +export type { IConversationTag } from './schema/conversationTag'; + +export { default as convoSchema } from './schema/convo'; +export type { IConversation } from './schema/convo'; + +export { default as fileSchema } from './schema/file'; +export type { IMongoFile } from './schema/file'; + +export { default as keySchema } from './schema/key'; +export type { IKey } from './schema/key'; + +export { default as messageSchema } from './schema/message'; +export type { IMessage } from './schema/message'; + +export { default as pluginAuthSchema } from './schema/pluginAuth'; +export type { IPluginAuth } from './schema/pluginAuth'; + +export { default as presetSchema } from './schema/preset'; +export type { IPreset } from './schema/preset'; + +export { default as projectSchema } from './schema/project'; +export type { IMongoProject } from './schema/project'; + +export { default as promptSchema } from './schema/prompt'; +export type { IPrompt } from './schema/prompt'; + +export { default as promptGroupSchema } from './schema/promptGroup'; +export type { IPromptGroup, IPromptGroupDocument } from './schema/promptGroup'; + +export { default as roleSchema } from './schema/role'; +export type { IRole } from './schema/role'; + +export { default as sessionSchema } from './schema/session'; +export type { ISession } from './schema/session'; + +export { default as shareSchema } from './schema/share'; +export type { ISharedLink } from './schema/share'; + +export { default as tokenSchema } from './schema/token'; +export type { IToken } from './schema/token'; + +export { default as toolCallSchema } from './schema/toolCall'; +export type { IToolCallData } from './schema/toolCall'; + +export { default as transactionSchema } from './schema/transaction'; +export type { ITransaction } from './schema/transaction'; + +export { default as userSchema } from './schema/user'; +export type { IUser } from './schema/user'; diff --git a/packages/data-schemas/tsconfig.json b/packages/data-schemas/tsconfig.json index 287f21089a..7c5cf16cb2 100644 --- a/packages/data-schemas/tsconfig.json +++ b/packages/data-schemas/tsconfig.json @@ -1,28 +1,19 @@ { "compilerOptions": { - "declaration": true, - "declarationDir": "./dist/types", - "module": "esnext", - "noImplicitAny": true, - "outDir": "./dist", - "target": "es2015", + "target": "ES2019", + "module": "ESNext", "moduleResolution": "node", - "lib": ["es2017", "dom", "ES2021.String"], - "skipLibCheck": true, - "esModuleInterop": true, + "declaration": true, + "declarationDir": "dist/types", + "outDir": "dist", "strict": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "skipLibCheck": true, "forceConsistentCasingInFileNames": true, "resolveJsonModule": true, - "isolatedModules": true, - "noEmit": false, - "sourceMap": true, - "baseUrl": "." + "sourceMap": true }, - "ts-node": { - "experimentalSpecifierResolution": "node", - "transpileOnly": true, - "esm": true - }, - "exclude": ["node_modules", "dist", "types"], - "include": ["src/**/*", "types/index.d.ts", "types/react-query/index.d.ts"] + "include": ["src/**/*"], + "exclude": ["node_modules", "dist", "tests"] }