/** * Publishing what the tab just built. * * The same conversation `val publish` has, with the same parsers, and the same * shape of state machine -- declare, upload what content does not already hold, * confirm, verify, promote. It is written out again here rather than shared * with the CLI's `runPublish` because the two differ in every input and in what * they do when something goes wrong: the CLI reads artifacts off a disk it * controls, takes a token, prints lines and sets an exit code; this holds them * in memory, has no credential, and has to leave an EDITOR with something they * can act on. * * What is shared is what must not drift: the wire shapes and their parsers * (`@valbuild/shared/internal`) and the artifact key namespace * (`@valbuild/tanstack-build`). Those are the parts where a second, slightly * different copy is how two publishers come to disagree with one service. * * ## No progress reporting beyond phases, on purpose * * Byte-level upload progress would need `XMLHttpRequest` per artifact, and a * publish is dozens of small ones rather than one big one -- so what a person * sees from counting artifacts is the same and the code is a quarter the size. * * ## Why it never throws * * Every exit is a value. A publish that failed has to say WHICH step and leave * the commit intact; a thrown error at an await boundary in a React handler is * an unhandled rejection and a spinner that never stops. */ import type { PublishArtifact } from "@valbuild/tanstack-build"; import { type DeclareBody, type PublishProblem } from "../internal/index.js"; import { StudioPublishClient } from "./publishClient.js"; /** Which step the publish is on, for the one line an editor is shown. */ export type PublishPhase = { kind: "declaring"; } | { kind: "uploading"; done: number; total: number; } | { kind: "confirming"; } | { kind: "verifying"; } | { kind: "promoting"; }; export type StudioPublishResult = { status: "live"; publishId: string; url: string | null; } /** Content had already taken this exact build. Not a failure. */ | { status: "already-live"; publishId: string; url: string | null; } /** * Stopped after the artifacts were confirmed, as `until: "confirmed"` asks: * a publish JOB's tab does no more than that, and content runs verify and * the seal (valbuild/home, docs/app-mode.md, "Publishing is a queued job"). */ | { status: "uploaded"; publishId: string; } | { status: "failed"; /** `null` when it failed before content had accepted anything. */ publishId: string | null; message: string; problems: PublishProblem[]; }; export declare function runStudioPublish(args: { client: StudioPublishClient; artifacts: PublishArtifact[]; declare: DeclareBody; onPhase: (phase: PublishPhase) => void; /** Stop once the artifacts are confirmed: for a publish job's tab. */ until?: "confirmed"; }): Promise;