mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-26 21:39:43 +02:00
fix(zero):add authz parent schemas
This commit is contained in:
parent
3cbd109e8d
commit
90c3dc98ca
3 changed files with 56 additions and 4 deletions
|
|
@ -1,5 +1,12 @@
|
|||
import { json, number, string, table } from "@rocicorp/zero";
|
||||
|
||||
export const automationTable = table("automations")
|
||||
.columns({
|
||||
id: number(),
|
||||
searchSpaceId: number().from("search_space_id"),
|
||||
})
|
||||
.primaryKey("id");
|
||||
|
||||
// Thin live row: status + per-step progress only. Heavy fields
|
||||
// (definition_snapshot, inputs, output, artifacts, error) stay on REST
|
||||
// (`GET /automations/{id}/runs/{run_id}`) and load on detail expand.
|
||||
|
|
|
|||
|
|
@ -20,6 +20,13 @@ export const newChatMessageTable = table("new_chat_messages")
|
|||
})
|
||||
.primaryKey("id");
|
||||
|
||||
export const newChatThreadTable = table("new_chat_threads")
|
||||
.columns({
|
||||
id: number(),
|
||||
searchSpaceId: number().from("search_space_id"),
|
||||
})
|
||||
.primaryKey("id");
|
||||
|
||||
export const chatCommentTable = table("chat_comments")
|
||||
.columns({
|
||||
id: number(),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,11 @@
|
|||
import { createBuilder, createSchema, relationships } from "@rocicorp/zero";
|
||||
import { automationRunTable } from "./automations";
|
||||
import { chatCommentTable, chatSessionStateTable, newChatMessageTable } from "./chat";
|
||||
import { automationRunTable, automationTable } from "./automations";
|
||||
import {
|
||||
chatCommentTable,
|
||||
chatSessionStateTable,
|
||||
newChatMessageTable,
|
||||
newChatThreadTable,
|
||||
} from "./chat";
|
||||
import { documentTable, searchSourceConnectorTable } from "./documents";
|
||||
import { folderTable } from "./folders";
|
||||
import { notificationTable } from "./inbox";
|
||||
|
|
@ -18,14 +23,40 @@ const chatCommentRelationships = relationships(chatCommentTable, ({ one }) => ({
|
|||
destSchema: chatCommentTable,
|
||||
destField: ["id"],
|
||||
}),
|
||||
thread: one({
|
||||
sourceField: ["threadId"],
|
||||
destSchema: newChatThreadTable,
|
||||
destField: ["id"],
|
||||
}),
|
||||
}));
|
||||
|
||||
const newChatMessageRelationships = relationships(newChatMessageTable, ({ many }) => ({
|
||||
const newChatMessageRelationships = relationships(newChatMessageTable, ({ one, many }) => ({
|
||||
comments: many({
|
||||
sourceField: ["id"],
|
||||
destSchema: chatCommentTable,
|
||||
destField: ["messageId"],
|
||||
}),
|
||||
thread: one({
|
||||
sourceField: ["threadId"],
|
||||
destSchema: newChatThreadTable,
|
||||
destField: ["id"],
|
||||
}),
|
||||
}));
|
||||
|
||||
const chatSessionStateThreadRelationships = relationships(chatSessionStateTable, ({ one }) => ({
|
||||
thread: one({
|
||||
sourceField: ["threadId"],
|
||||
destSchema: newChatThreadTable,
|
||||
destField: ["id"],
|
||||
}),
|
||||
}));
|
||||
|
||||
const automationRunRelationships = relationships(automationRunTable, ({ one }) => ({
|
||||
automation: one({
|
||||
sourceField: ["automationId"],
|
||||
destSchema: automationTable,
|
||||
destField: ["id"],
|
||||
}),
|
||||
}));
|
||||
|
||||
export const schema = createSchema({
|
||||
|
|
@ -34,14 +65,21 @@ export const schema = createSchema({
|
|||
documentTable,
|
||||
folderTable,
|
||||
searchSourceConnectorTable,
|
||||
newChatThreadTable,
|
||||
newChatMessageTable,
|
||||
chatCommentTable,
|
||||
chatSessionStateTable,
|
||||
userTable,
|
||||
automationTable,
|
||||
automationRunTable,
|
||||
podcastTable,
|
||||
],
|
||||
relationships: [chatCommentRelationships, newChatMessageRelationships],
|
||||
relationships: [
|
||||
chatCommentRelationships,
|
||||
newChatMessageRelationships,
|
||||
chatSessionStateThreadRelationships,
|
||||
automationRunRelationships,
|
||||
],
|
||||
});
|
||||
|
||||
export type Schema = typeof schema;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue