import type { PublishTabJob } from "../internal/index.js"; import type { DeployPhase, StudioDeployResult } from "./runStudioDeploy.js"; import type { PreparedJob, StudioJobClient } from "./jobClient.js"; /** * A publish job, as the tab that holds it runs it: prepare, build, upload -- * and then it is content's (valbuild/home, docs/app-mode.md, "Publishing is a * queued job"). Content runs verify and the seal, and "Live" arrives on the * websocket, so a tab that closes after its upload costs nothing. * * The tab holds the job by a lease, renewed on a timer while it works. A * renewal answered `false` means the job is no longer this tab's -- its lease * lapsed and its requests went back to the queue, or it was cancelled -- and * the tab stops: another tab, or this one's next job, will build it. * * Every step is reported by name, so a report retried after a lost answer * does nothing twice, and a failure is reported as the step's: content counts * the attempts and, after the last, fails the job with Try again. */ export type JobPhase = { kind: "preparing"; } | { kind: "deploying"; phase: DeployPhase; } | { kind: "handing-off"; }; export type StudioJobResult = /** * The tab's part is done, and content has the job. `built`: this tab built * and uploaded it. `false` is a job whose build is CI's -- a connected * project's, where the tab's part is the prepare alone -- or, with * `contentOnly`, a job nobody builds: its content goes live on the build * already live. */ { status: "handed-off"; jobId: string; built: boolean; contentOnly?: true; } /** The job is no longer this tab's. Nothing to report. */ | { status: "lost"; jobId: string; } /** * A managed job that needs a build, prepared by a tab that cannot run the * builder (`buildsElsewhere`). Not reported: its lease lapses, it goes back * to the queue, and a builder tab -- opened with one more tap -- takes it. */ | { status: "needs-builder"; jobId: string; } /** A step failed, and was reported as failed. */ | { status: "failed"; jobId: string; message: string; }; /** How often the tab renews its lease. Content's job lease is 30 s. */ export declare const RENEW_EVERY_MS = 10000; export declare function runStudioJob(options: { client: StudioJobClient; job: PublishTabJob; tab: string; /** * Build the job from its prepared sources, stopping once the artifacts are * confirmed: `runStudioDeploy` with `until: "confirmed"` and no commit. */ deploy: (prepared: PreparedJob, onPhase: (phase: DeployPhase) => void) => Promise; onPhase: (phase: JobPhase) => void; renewEveryMs?: number; /** * Can this tab build at all? Connected only: a tab that cannot (no * cross-origin isolation) reports "no build", and CI builds the push. A * managed job never reaches a tab that cannot -- it is handed to one that can. */ canBuild?: () => boolean; /** * Managed, and a tab that cannot build: an iPhone, or the overlay, running * its own publish so that one of content alone needs no tab. A job that * needs a build after all is given back (`needs-builder`) rather than said * to need none -- content refuses that for a managed job, which has no CI. */ buildsElsewhere?: boolean; }): Promise; /** * Run a job until this tab's part of it is over: handed off, lost, or failed * for good. * * A failed step is counted by content, which keeps the job at that step for * the tab to run again -- until its last attempt, when it fails the job. * Whether it is still this tab's is the renewal's answer, so a failure is * followed by one, and a `true` runs it again. */ export declare function runJobToEnd(options: { client: Pick; job: PublishTabJob; tab: string; run: () => Promise; }): Promise;