Merge remote-tracking branch 'upstream/dev' into feat/whatsapp-gateway-integration

This commit is contained in:
Anish Sarkar 2026-06-02 01:22:32 +05:30
commit 2e64d5d3de
15 changed files with 472 additions and 136 deletions

View file

@ -0,0 +1,14 @@
import { defineQuery } from "@rocicorp/zero";
import { z } from "zod";
import { zql } from "../schema/index";
// Mirrors chat byThread: client passes the parent id, the REST route still
// authorizes via `automation_id -> search_space`. No search_space_id on the
// table by design.
export const automationRunQueries = {
byAutomation: defineQuery(
z.object({ automationId: z.number() }),
({ args: { automationId } }) =>
zql.automation_runs.where("automationId", automationId).orderBy("createdAt", "desc")
),
};

View file

@ -1,4 +1,5 @@
import { defineQueries } from "@rocicorp/zero";
import { automationRunQueries } from "./automations";
import { chatSessionQueries, commentQueries, messageQueries } from "./chat";
import { connectorQueries, documentQueries } from "./documents";
import { folderQueries } from "./folders";
@ -14,4 +15,5 @@ export const queries = defineQueries({
comments: commentQueries,
chatSession: chatSessionQueries,
user: userQueries,
automationRuns: automationRunQueries,
});

View file

@ -0,0 +1,18 @@
import { json, number, string, table } from "@rocicorp/zero";
// 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.
// Mirrors the publication shape in migration 148.
export const automationRunTable = table("automation_runs")
.columns({
id: number(),
automationId: number().from("automation_id"),
triggerId: number().optional().from("trigger_id"),
status: string(),
stepResults: json().from("step_results"),
startedAt: number().optional().from("started_at"),
finishedAt: number().optional().from("finished_at"),
createdAt: number().from("created_at"),
})
.primaryKey("id");

View file

@ -1,4 +1,5 @@
import { createBuilder, createSchema, relationships } from "@rocicorp/zero";
import { automationRunTable } from "./automations";
import { chatCommentTable, chatSessionStateTable, newChatMessageTable } from "./chat";
import { documentTable, searchSourceConnectorTable } from "./documents";
import { folderTable } from "./folders";
@ -36,6 +37,7 @@ export const schema = createSchema({
chatCommentTable,
chatSessionStateTable,
userTable,
automationRunTable,
],
relationships: [chatCommentRelationships, newChatMessageRelationships],
});