From e61308387cc8275d04ad83ff1128ea1a8ea97129 Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Wed, 10 Jun 2026 18:44:35 +0200 Subject: [PATCH] feat(podcasts): add zero schema and queries --- surfsense_web/zero/queries/index.ts | 2 ++ surfsense_web/zero/queries/podcasts.ts | 12 ++++++++++++ surfsense_web/zero/schema/index.ts | 2 ++ surfsense_web/zero/schema/podcasts.ts | 19 +++++++++++++++++++ 4 files changed, 35 insertions(+) create mode 100644 surfsense_web/zero/queries/podcasts.ts create mode 100644 surfsense_web/zero/schema/podcasts.ts diff --git a/surfsense_web/zero/queries/index.ts b/surfsense_web/zero/queries/index.ts index fe711f5d3..45df8fa98 100644 --- a/surfsense_web/zero/queries/index.ts +++ b/surfsense_web/zero/queries/index.ts @@ -4,6 +4,7 @@ import { chatSessionQueries, commentQueries, messageQueries } from "./chat"; import { connectorQueries, documentQueries } from "./documents"; import { folderQueries } from "./folders"; import { notificationQueries } from "./inbox"; +import { podcastQueries } from "./podcasts"; import { userQueries } from "./user"; export const queries = defineQueries({ @@ -16,4 +17,5 @@ export const queries = defineQueries({ chatSession: chatSessionQueries, user: userQueries, automationRuns: automationRunQueries, + podcasts: podcastQueries, }); diff --git a/surfsense_web/zero/queries/podcasts.ts b/surfsense_web/zero/queries/podcasts.ts new file mode 100644 index 000000000..5298534dd --- /dev/null +++ b/surfsense_web/zero/queries/podcasts.ts @@ -0,0 +1,12 @@ +import { defineQuery } from "@rocicorp/zero"; +import { z } from "zod"; +import { zql } from "../schema/index"; + +export const podcastQueries = { + bySpace: defineQuery(z.object({ searchSpaceId: z.number() }), ({ args: { searchSpaceId } }) => + zql.podcasts.where("searchSpaceId", searchSpaceId).orderBy("createdAt", "desc") + ), + byId: defineQuery(z.object({ podcastId: z.number() }), ({ args: { podcastId } }) => + zql.podcasts.where("id", podcastId).one() + ), +}; diff --git a/surfsense_web/zero/schema/index.ts b/surfsense_web/zero/schema/index.ts index d6731e371..d1187ddab 100644 --- a/surfsense_web/zero/schema/index.ts +++ b/surfsense_web/zero/schema/index.ts @@ -4,6 +4,7 @@ import { chatCommentTable, chatSessionStateTable, newChatMessageTable } from "./ import { documentTable, searchSourceConnectorTable } from "./documents"; import { folderTable } from "./folders"; import { notificationTable } from "./inbox"; +import { podcastTable } from "./podcasts"; import { userTable } from "./user"; const chatCommentRelationships = relationships(chatCommentTable, ({ one }) => ({ @@ -38,6 +39,7 @@ export const schema = createSchema({ chatSessionStateTable, userTable, automationRunTable, + podcastTable, ], relationships: [chatCommentRelationships, newChatMessageRelationships], }); diff --git a/surfsense_web/zero/schema/podcasts.ts b/surfsense_web/zero/schema/podcasts.ts new file mode 100644 index 000000000..d473d776f --- /dev/null +++ b/surfsense_web/zero/schema/podcasts.ts @@ -0,0 +1,19 @@ +import { json, number, string, table } from "@rocicorp/zero"; + +// Mirrors PODCAST_COLS in the backend zero_publication. status drives the +// lifecycle UI by push; spec is the reviewable brief. The bulky source_content +// and transcript are intentionally not published and are fetched over REST. +export const podcastTable = table("podcasts") + .columns({ + id: number(), + title: string(), + status: string(), + spec: json().optional(), + specVersion: number().from("spec_version"), + durationSeconds: number().optional().from("duration_seconds"), + error: string().optional(), + searchSpaceId: number().from("search_space_id"), + threadId: number().optional().from("thread_id"), + createdAt: number().from("created_at"), + }) + .primaryKey("id");