|
|
@ -25,48 +25,3 @@ export type FactTrigger = {
|
|
|
|
scopeConversationId: string;
|
|
|
|
scopeConversationId: string;
|
|
|
|
createdAt?: string;
|
|
|
|
createdAt?: string;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export type User = Omit<Users, "id"> & {
|
|
|
|
|
|
|
|
id: string;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export interface Entity<T> {
|
|
|
|
|
|
|
|
construct: (data: T) => T;
|
|
|
|
|
|
|
|
create: (data: Omit<T, "id">) => Promise<T>;
|
|
|
|
|
|
|
|
createMany: (data: Omit<T, "id">[]) => Promise<T[]>;
|
|
|
|
|
|
|
|
findAll: (user?: { userId: string }) => Promise<T[]>;
|
|
|
|
|
|
|
|
findById: (id: string) => Promise<T | undefined>;
|
|
|
|
|
|
|
|
update: (id: string, data: Partial<T>) => Promise<void>;
|
|
|
|
|
|
|
|
delete: (id: string) => Promise<void>;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export interface ConversationEntity extends Entity<Conversation> {
|
|
|
|
|
|
|
|
fetchMessages: (conversationId: string) => Promise<Array<CommittedMessage>>;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export interface FactEntity extends Entity<Fact> {
|
|
|
|
|
|
|
|
findByConversationId: (conversationId: string) => Promise<Array<Fact>>;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export interface MessageEntity extends Entity<CommittedMessage> {
|
|
|
|
|
|
|
|
findByConversationId: (
|
|
|
|
|
|
|
|
conversationId: string
|
|
|
|
|
|
|
|
) => Promise<Array<CommittedMessage>>;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export type FactTriggerEntity = Entity<FactTrigger> & {
|
|
|
|
|
|
|
|
findByFactId: (factId: string) => Promise<Array<FactTrigger>>;
|
|
|
|
|
|
|
|
findByConversationId: (conversationId: string) => Promise<Array<FactTrigger>>;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export type UserEntity = Entity<User> & {
|
|
|
|
|
|
|
|
findByEmailAddress: (emailAddress: string) => Promise<User | undefined>;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export interface ApplicationDatabase {
|
|
|
|
|
|
|
|
conversations: ConversationEntity;
|
|
|
|
|
|
|
|
factTriggers: FactTriggerEntity;
|
|
|
|
|
|
|
|
facts: FactEntity;
|
|
|
|
|
|
|
|
messages: MessageEntity;
|
|
|
|
|
|
|
|
users: UserEntity;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|