feat: add Zero schema with 6 table definitions and relationships

- 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
This commit is contained in:
CREDO23 2026-03-23 17:44:05 +02:00
parent 8298aad2d7
commit af2bd744fb
5 changed files with 125 additions and 0 deletions

View file

@ -0,0 +1,41 @@
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);