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";
|
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
|
// Thin live row: status + per-step progress only. Heavy fields
|
||||||
// (definition_snapshot, inputs, output, artifacts, error) stay on REST
|
// (definition_snapshot, inputs, output, artifacts, error) stay on REST
|
||||||
// (`GET /automations/{id}/runs/{run_id}`) and load on detail expand.
|
// (`GET /automations/{id}/runs/{run_id}`) and load on detail expand.
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,13 @@ export const newChatMessageTable = table("new_chat_messages")
|
||||||
})
|
})
|
||||||
.primaryKey("id");
|
.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")
|
export const chatCommentTable = table("chat_comments")
|
||||||
.columns({
|
.columns({
|
||||||
id: number(),
|
id: number(),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,11 @@
|
||||||
import { createBuilder, createSchema, relationships } from "@rocicorp/zero";
|
import { createBuilder, createSchema, relationships } from "@rocicorp/zero";
|
||||||
import { automationRunTable } from "./automations";
|
import { automationRunTable, automationTable } from "./automations";
|
||||||
import { chatCommentTable, chatSessionStateTable, newChatMessageTable } from "./chat";
|
import {
|
||||||
|
chatCommentTable,
|
||||||
|
chatSessionStateTable,
|
||||||
|
newChatMessageTable,
|
||||||
|
newChatThreadTable,
|
||||||
|
} from "./chat";
|
||||||
import { documentTable, searchSourceConnectorTable } from "./documents";
|
import { documentTable, searchSourceConnectorTable } from "./documents";
|
||||||
import { folderTable } from "./folders";
|
import { folderTable } from "./folders";
|
||||||
import { notificationTable } from "./inbox";
|
import { notificationTable } from "./inbox";
|
||||||
|
|
@ -18,14 +23,40 @@ const chatCommentRelationships = relationships(chatCommentTable, ({ one }) => ({
|
||||||
destSchema: chatCommentTable,
|
destSchema: chatCommentTable,
|
||||||
destField: ["id"],
|
destField: ["id"],
|
||||||
}),
|
}),
|
||||||
|
thread: one({
|
||||||
|
sourceField: ["threadId"],
|
||||||
|
destSchema: newChatThreadTable,
|
||||||
|
destField: ["id"],
|
||||||
|
}),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const newChatMessageRelationships = relationships(newChatMessageTable, ({ many }) => ({
|
const newChatMessageRelationships = relationships(newChatMessageTable, ({ one, many }) => ({
|
||||||
comments: many({
|
comments: many({
|
||||||
sourceField: ["id"],
|
sourceField: ["id"],
|
||||||
destSchema: chatCommentTable,
|
destSchema: chatCommentTable,
|
||||||
destField: ["messageId"],
|
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({
|
export const schema = createSchema({
|
||||||
|
|
@ -34,14 +65,21 @@ export const schema = createSchema({
|
||||||
documentTable,
|
documentTable,
|
||||||
folderTable,
|
folderTable,
|
||||||
searchSourceConnectorTable,
|
searchSourceConnectorTable,
|
||||||
|
newChatThreadTable,
|
||||||
newChatMessageTable,
|
newChatMessageTable,
|
||||||
chatCommentTable,
|
chatCommentTable,
|
||||||
chatSessionStateTable,
|
chatSessionStateTable,
|
||||||
userTable,
|
userTable,
|
||||||
|
automationTable,
|
||||||
automationRunTable,
|
automationRunTable,
|
||||||
podcastTable,
|
podcastTable,
|
||||||
],
|
],
|
||||||
relationships: [chatCommentRelationships, newChatMessageRelationships],
|
relationships: [
|
||||||
|
chatCommentRelationships,
|
||||||
|
newChatMessageRelationships,
|
||||||
|
chatSessionStateThreadRelationships,
|
||||||
|
automationRunRelationships,
|
||||||
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
export type Schema = typeof schema;
|
export type Schema = typeof schema;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue