mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-02-11 20:14:24 +01:00
experimental: npm link test
This commit is contained in:
parent
f9c0e9853f
commit
a2a3f5c044
7 changed files with 124 additions and 50 deletions
|
|
@ -64,13 +64,13 @@
|
|||
"klona": "^2.0.6",
|
||||
"lodash": "^4.17.21",
|
||||
"meilisearch": "^0.38.0",
|
||||
"mongoose": "^8.12.1",
|
||||
"traverse": "^0.6.11",
|
||||
"winston": "^3.17.0",
|
||||
"winston-daily-rotate-file": "^5.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"keyv": "^5.3.2"
|
||||
"keyv": "^5.3.2",
|
||||
"mongoose": "^8.12.1"
|
||||
},
|
||||
"publishConfig": {
|
||||
"registry": "https://registry.npmjs.org/",
|
||||
|
|
|
|||
|
|
@ -1,65 +1,66 @@
|
|||
export { default as logger } from './config/winston';
|
||||
export { default as meiliLogger } from './config/meiliLogger';
|
||||
export * from './types';
|
||||
export * from './models';
|
||||
export * from './methods';
|
||||
export { Role } from './models/role';
|
||||
// export { default as logger } from './config/winston';
|
||||
// export { default as meiliLogger } from './config/meiliLogger';
|
||||
// export * from './types';
|
||||
// export * from './models';
|
||||
// export * from './methods';
|
||||
|
||||
// Export schemas (if needed for direct access)
|
||||
export { default as userSchema } from './schema/user';
|
||||
export { default as sessionSchema } from './schema/session';
|
||||
export { default as tokenSchema } from './schema/token';
|
||||
// // Export schemas (if needed for direct access)
|
||||
// export { default as userSchema } from './schema/user';
|
||||
// export { default as sessionSchema } from './schema/session';
|
||||
// export { default as tokenSchema } from './schema/token';
|
||||
|
||||
// Export utility functions from schemas
|
||||
export { signPayload, hashToken } from './schema/session';
|
||||
// // Export utility functions from schemas
|
||||
// export { signPayload, hashToken } from './schema/session';
|
||||
|
||||
export { default as actionSchema } from './schema/action';
|
||||
// export { default as actionSchema } from './schema/action';
|
||||
|
||||
export { default as agentSchema } from './schema/agent';
|
||||
// export { default as agentSchema } from './schema/agent';
|
||||
|
||||
export { default as assistantSchema } from './schema/assistant';
|
||||
// export { default as assistantSchema } from './schema/assistant';
|
||||
|
||||
export { default as balanceSchema } from './schema/balance';
|
||||
// export { default as balanceSchema } from './schema/balance';
|
||||
|
||||
export { default as bannerSchema } from './schema/banner';
|
||||
export type { IBanner } from './schema/banner';
|
||||
// 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 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 conversationTagSchema } from './schema/conversationTag';
|
||||
// export type { IConversationTag } from './schema/conversationTag';
|
||||
|
||||
export { default as convoSchema } from './schema/convo';
|
||||
// export { default as convoSchema } from './schema/convo';
|
||||
|
||||
export { default as fileSchema } from './schema/file';
|
||||
// export { default as fileSchema } from './schema/file';
|
||||
|
||||
export { default as keySchema } from './schema/key';
|
||||
// export { default as keySchema } from './schema/key';
|
||||
|
||||
export { default as messageSchema } from './schema/message';
|
||||
export type { IMessage } from './schema/message';
|
||||
// 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 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 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 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 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 promptGroupSchema } from './schema/promptGroup';
|
||||
// export type { IPromptGroup, IPromptGroupDocument } from './schema/promptGroup';
|
||||
|
||||
export { default as roleSchema } from './schema/role';
|
||||
// export { default as roleSchema } from './schema/role';
|
||||
|
||||
export { default as shareSchema } from './schema/share';
|
||||
export type { ISharedLink } from './schema/share';
|
||||
// export { default as shareSchema } from './schema/share';
|
||||
// export type { ISharedLink } from './schema/share';
|
||||
|
||||
export { default as toolCallSchema } from './schema/toolCall';
|
||||
export type { IToolCallData } from './schema/toolCall';
|
||||
// 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 transactionSchema } from './schema/transaction';
|
||||
// export type { ITransaction } from './schema/transaction';
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import mongoose from 'mongoose';
|
||||
import mongoose from '~/mongoose';
|
||||
import roleSchema from '~/schema/role';
|
||||
import type { IRole } from '~/types';
|
||||
|
||||
export const Role = mongoose.models.Role || mongoose.model<IRole>('Role', roleSchema);
|
||||
export const Role = mongoose.models.Role || mongoose.model('Role', roleSchema) as any;
|
||||
|
|
|
|||
58
packages/data-schemas/src/mongoose.ts
Normal file
58
packages/data-schemas/src/mongoose.ts
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
/**
|
||||
* Mongoose peer dependency loader
|
||||
* This handles loading mongoose from the parent project for proper peer dependency resolution
|
||||
*/
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let mongoose: any;
|
||||
|
||||
try {
|
||||
// First try to require mongoose normally (this works in production)
|
||||
mongoose = require('mongoose');
|
||||
} catch (error) {
|
||||
try {
|
||||
// If that fails, try to require from parent context (for npm link scenarios)
|
||||
// This is the TypeScript equivalent of the parent-require solution
|
||||
const Module = require('module');
|
||||
const originalRequire = Module.prototype.require;
|
||||
|
||||
// Try to find mongoose in parent module paths
|
||||
const parentPaths = require.main?.paths || [];
|
||||
for (const parentPath of parentPaths) {
|
||||
try {
|
||||
const parentRequire = Module.createRequire(parentPath + '/package.json');
|
||||
mongoose = parentRequire('mongoose');
|
||||
break;
|
||||
} catch {
|
||||
// Continue to next path
|
||||
}
|
||||
}
|
||||
|
||||
if (!mongoose) {
|
||||
// Last resort: use eval to get parent require
|
||||
const parentRequire = eval('require');
|
||||
mongoose = parentRequire('mongoose');
|
||||
}
|
||||
} catch (parentError) {
|
||||
throw new Error(
|
||||
'Could not load mongoose. Make sure mongoose is installed in the parent project or available as a peer dependency.\n' +
|
||||
`Local require error: ${error}\n` +
|
||||
`Parent require error: ${parentError}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default mongoose;
|
||||
|
||||
// Also export common mongoose items for convenience
|
||||
export const {
|
||||
Schema,
|
||||
model,
|
||||
models,
|
||||
connect,
|
||||
connection,
|
||||
Document,
|
||||
Types,
|
||||
Query,
|
||||
Model,
|
||||
} = mongoose;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import { Schema } from 'mongoose';
|
||||
import { Schema } from '~/mongoose';
|
||||
import { PermissionTypes, Permissions } from 'librechat-data-provider';
|
||||
import type { IRole } from '~/types';
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue