ConusAI vendor v0.1.0-beta.114
ci / gate (push) Waiting to run

This commit is contained in:
ConusAI vendor v0.1.0-beta.114
2026-11-14 09:56:45 +00:00
commit 1ce8d23c35
867 changed files with 122104 additions and 0 deletions
+48
View File
@@ -0,0 +1,48 @@
"use client"
// The project's documents and one document, live (umbrella TS6.4 and TS6.6): the page's loader reads them
// and its view hands them over as the seed, so the page arrives complete; these keep them current through
// the organization's live stream. The job's change of a document -- taken, read, failed -- is a change of
// `documents.document` (contract/collections.ts), and each read again answers the files, the rows and the
// line counts together, under the list's permission. An upload or a decision on a line is this person's
// own write: the component that made it reads again (`refetch`) once it has answered, so nothing reloads.
import type { ProjectSlugs } from "@conusai-kit/ui"
import { useRead } from "@conusai-kit/ui/data"
import { DOCUMENT_COLLECTION, type DocumentView, type LineView } from "../contract/index.js"
const liveness = (slugs: ProjectSlugs) => ({
org: slugs.org,
topic: { ws: slugs.workspace, project: slugs.project },
entities: [DOCUMENT_COLLECTION.entity],
})
export function useLiveDocuments(
slugs: ProjectSlugs,
seed: readonly DocumentView[],
): { documents: readonly DocumentView[]; refetch(): Promise<void> } {
const { data, refetch } = useRead<{ documents: readonly DocumentView[] }>(
DOCUMENT_COLLECTION.list,
{ ...slugs },
{ live: liveness(slugs), initial: { documents: seed } },
)
return { documents: data?.documents ?? seed, refetch }
}
export interface DocumentWithLines {
readonly document: DocumentView
readonly lines: readonly LineView[]
}
export function useLiveDocument(
slugs: ProjectSlugs,
fileId: string,
seed: DocumentWithLines,
): DocumentWithLines & { refetch(): Promise<void> } {
const { data, refetch } = useRead<DocumentWithLines>(
"documents.document.get",
{ ...slugs, fileId },
{ live: liveness(slugs), initial: seed },
)
return { ...(data ?? seed), refetch }
}