mirror of https://github.com/buster-so/buster.git
initial commit to move files
This commit is contained in:
parent
71994c1142
commit
f23d933cc1
|
@ -1,11 +1,11 @@
|
|||
import { and, eq, isNull } from 'drizzle-orm';
|
||||
import type { InferSelectModel } from 'drizzle-orm';
|
||||
import { z } from 'zod';
|
||||
import { db } from '../connection';
|
||||
import { dashboardFiles, messages, messagesToFiles, metricFiles } from '../schema';
|
||||
import { db } from '../../connection';
|
||||
import { dashboardFiles, messages, messagesToFiles, metricFiles } from '../../schema';
|
||||
|
||||
// Type inference from schema
|
||||
export type Message = InferSelectModel<typeof messages>;
|
||||
type Message = InferSelectModel<typeof messages>;
|
||||
|
||||
/**
|
||||
* Input schemas
|
|
@ -1,8 +1,8 @@
|
|||
import type { InferSelectModel } from 'drizzle-orm';
|
||||
import { and, eq, isNull } from 'drizzle-orm';
|
||||
import { z } from 'zod';
|
||||
import { db } from '../connection';
|
||||
import { dashboardFiles, messages, messagesToFiles } from '../schema';
|
||||
import { db } from '../../connection';
|
||||
import { dashboardFiles, messages, messagesToFiles } from '../../schema';
|
||||
|
||||
// Input schema for type safety
|
||||
const GetChatDashboardFilesInputSchema = z.object({
|
|
@ -0,0 +1,13 @@
|
|||
// Export all asset-related functionality
|
||||
export {
|
||||
generateAssetMessages,
|
||||
createMessageFileAssociation,
|
||||
GenerateAssetMessagesInputSchema,
|
||||
type GenerateAssetMessagesInput,
|
||||
} from './assets';
|
||||
|
||||
export {
|
||||
getChatDashboardFiles,
|
||||
type DashboardFileContext,
|
||||
type DashboardFile,
|
||||
} from './dashboards';
|
|
@ -1,13 +1,13 @@
|
|||
import { and, eq, isNull } from 'drizzle-orm';
|
||||
import type { InferSelectModel } from 'drizzle-orm';
|
||||
import { z } from 'zod';
|
||||
import { db } from '../connection';
|
||||
import { chats, messages, userFavorites, users } from '../schema';
|
||||
import { db } from '../../connection';
|
||||
import { chats, messages, userFavorites, users } from '../../schema';
|
||||
|
||||
// Type inference from schema
|
||||
export type Chat = InferSelectModel<typeof chats>;
|
||||
export type Message = InferSelectModel<typeof messages>;
|
||||
export type User = InferSelectModel<typeof users>;
|
||||
type Message = InferSelectModel<typeof messages>;
|
||||
type User = InferSelectModel<typeof users>;
|
||||
|
||||
// Create a type for updateable chat fields by excluding auto-managed fields
|
||||
type UpdateableChatFields = Partial<
|
||||
|
@ -164,17 +164,6 @@ export async function createMessage(input: CreateMessageInput): Promise<Message>
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all messages for a chat
|
||||
*/
|
||||
export async function getMessagesForChat(chatId: string): Promise<Message[]> {
|
||||
return db
|
||||
.select()
|
||||
.from(messages)
|
||||
.where(and(eq(messages.chatId, chatId), isNull(messages.deletedAt)))
|
||||
.orderBy(messages.createdAt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Flexibly update chat fields - only updates fields that are provided
|
||||
* Accepts a partial Chat object and updates only the provided fields
|
|
@ -0,0 +1,14 @@
|
|||
// Export all chat-related functionality
|
||||
export {
|
||||
createChat,
|
||||
updateChat,
|
||||
getChatWithDetails,
|
||||
createMessage,
|
||||
CreateChatInputSchema,
|
||||
GetChatInputSchema,
|
||||
CreateMessageInputSchema,
|
||||
type CreateChatInput,
|
||||
type GetChatInput,
|
||||
type CreateMessageInput,
|
||||
type Chat,
|
||||
} from './chats';
|
|
@ -0,0 +1 @@
|
|||
export * from './organizationDataSource';
|
|
@ -1,78 +1,7 @@
|
|||
// Export all database helpers
|
||||
export * from './messages';
|
||||
export * from './users';
|
||||
|
||||
// Message helpers (domain-organized)
|
||||
export {
|
||||
getMessageContext,
|
||||
MessageContextInputSchema,
|
||||
MessageContextOutputSchema,
|
||||
type MessageContextInput,
|
||||
type MessageContextOutput,
|
||||
} from './messages/messageContext';
|
||||
|
||||
export {
|
||||
getChatConversationHistory,
|
||||
ChatConversationHistoryInputSchema,
|
||||
ChatConversationHistoryOutputSchema,
|
||||
type ChatConversationHistoryInput,
|
||||
type ChatConversationHistoryOutput,
|
||||
} from './messages/chatConversationHistory';
|
||||
|
||||
// Data source helpers
|
||||
export {
|
||||
getOrganizationDataSource,
|
||||
OrganizationDataSourceInputSchema,
|
||||
OrganizationDataSourceOutputSchema,
|
||||
type OrganizationDataSourceInput,
|
||||
type OrganizationDataSourceOutput,
|
||||
} from './dataSources/organizationDataSource';
|
||||
|
||||
// Chat helpers
|
||||
export {
|
||||
createChat,
|
||||
updateChat,
|
||||
getChatWithDetails,
|
||||
createMessage,
|
||||
getMessagesForChat,
|
||||
CreateChatInputSchema,
|
||||
GetChatInputSchema,
|
||||
CreateMessageInputSchema,
|
||||
type CreateChatInput,
|
||||
type GetChatInput,
|
||||
type CreateMessageInput,
|
||||
type Chat,
|
||||
type Message,
|
||||
} from './chats';
|
||||
|
||||
// Asset helpers
|
||||
export {
|
||||
generateAssetMessages,
|
||||
createMessageFileAssociation,
|
||||
GenerateAssetMessagesInputSchema,
|
||||
type GenerateAssetMessagesInput,
|
||||
} from './assets';
|
||||
|
||||
// Dashboard helpers
|
||||
export {
|
||||
getChatDashboardFiles,
|
||||
type DashboardFileContext,
|
||||
type DashboardFile,
|
||||
} from './dashboards';
|
||||
|
||||
// Organization helpers
|
||||
export {
|
||||
getUserOrganizationId,
|
||||
GetUserOrganizationInputSchema,
|
||||
type GetUserOrganizationInput,
|
||||
type UserToOrganization,
|
||||
} from './organizations';
|
||||
|
||||
// Braintrust metadata helper
|
||||
export {
|
||||
getBraintrustMetadata,
|
||||
BraintrustMetadataInputSchema,
|
||||
BraintrustMetadataOutputSchema,
|
||||
type BraintrustMetadataInput,
|
||||
type BraintrustMetadataOutput,
|
||||
} from './braintrustMetadata';
|
||||
export * from './dataSources';
|
||||
export * from './assets';
|
||||
export * from './metadata';
|
||||
export * from './chats';
|
||||
export * from './organizations';
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
// Export all message-related functionality
|
||||
export * from './messages';
|
||||
export * from './chatConversationHistory';
|
||||
export * from './messageContext';
|
|
@ -1,7 +1,7 @@
|
|||
import type { InferSelectModel } from 'drizzle-orm';
|
||||
import { and, desc, eq, isNull } from 'drizzle-orm';
|
||||
import { db } from '../connection';
|
||||
import { messages } from '../schema';
|
||||
import { db } from '../../connection';
|
||||
import { messages } from '../../schema';
|
||||
|
||||
export type Message = InferSelectModel<typeof messages>;
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
import { eq } from 'drizzle-orm';
|
||||
import { z } from 'zod';
|
||||
import { db } from '../connection';
|
||||
import { organizations, users } from '../schema';
|
||||
import { getMessageContext } from './messages/messageContext';
|
||||
import { db } from '../../connection';
|
||||
import { organizations, users } from '../../schema';
|
||||
import { getMessageContext } from '../messages/messageContext';
|
||||
|
||||
// Input schema
|
||||
export const BraintrustMetadataInputSchema = z.object({
|
|
@ -0,0 +1,8 @@
|
|||
// Export all metadata-related functionality
|
||||
export {
|
||||
getBraintrustMetadata,
|
||||
BraintrustMetadataInputSchema,
|
||||
BraintrustMetadataOutputSchema,
|
||||
type BraintrustMetadataInput,
|
||||
type BraintrustMetadataOutput,
|
||||
} from './braintrustMetadata';
|
|
@ -0,0 +1,7 @@
|
|||
// Export all organization-related functionality
|
||||
export {
|
||||
getUserOrganizationId,
|
||||
GetUserOrganizationInputSchema,
|
||||
type GetUserOrganizationInput,
|
||||
type UserToOrganization,
|
||||
} from './organizations';
|
|
@ -1,8 +1,8 @@
|
|||
import { and, eq, isNull } from 'drizzle-orm';
|
||||
import type { InferSelectModel } from 'drizzle-orm';
|
||||
import { z } from 'zod';
|
||||
import { db } from '../connection';
|
||||
import { usersToOrganizations } from '../schema';
|
||||
import { db } from '../../connection';
|
||||
import { usersToOrganizations } from '../../schema';
|
||||
|
||||
// Type inference from schema
|
||||
export type UserToOrganization = InferSelectModel<typeof usersToOrganizations>;
|
Loading…
Reference in New Issue