mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-27 09:46:25 +02:00
- Create zero/tables/inbox.ts (notifications) - Create zero/tables/documents.ts (documents, search_source_connectors) - Create zero/tables/chat.ts (new_chat_messages, chat_comments, chat_session_state) - Create zero/schema.ts (combines tables, defines relationships, exports zql) - Consolidate Zero type augmentations into types/zero.d.ts
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import { createSchema, createBuilder, relationships } from "@rocicorp/zero";
|
|
import { chatCommentTable, chatSessionStateTable, newChatMessageTable } from "./tables/chat";
|
|
import { documentTable, searchSourceConnectorTable } from "./tables/documents";
|
|
import { notificationTable } from "./tables/inbox";
|
|
|
|
const chatCommentRelationships = relationships(chatCommentTable, ({ one }) => ({
|
|
message: one({
|
|
sourceField: ["messageId"],
|
|
destSchema: newChatMessageTable,
|
|
destField: ["id"],
|
|
}),
|
|
parent: one({
|
|
sourceField: ["parentId"],
|
|
destSchema: chatCommentTable,
|
|
destField: ["id"],
|
|
}),
|
|
}));
|
|
|
|
const newChatMessageRelationships = relationships(newChatMessageTable, ({ many }) => ({
|
|
comments: many({
|
|
sourceField: ["id"],
|
|
destSchema: chatCommentTable,
|
|
destField: ["messageId"],
|
|
}),
|
|
}));
|
|
|
|
export const schema = createSchema({
|
|
tables: [
|
|
notificationTable,
|
|
documentTable,
|
|
searchSourceConnectorTable,
|
|
newChatMessageTable,
|
|
chatCommentTable,
|
|
chatSessionStateTable,
|
|
],
|
|
relationships: [chatCommentRelationships, newChatMessageRelationships],
|
|
});
|
|
|
|
export type Schema = typeof schema;
|
|
|
|
export const zql = createBuilder(schema);
|