import type { BuildTargetResponse } from "../internal/index.js"; import type { StudioDeployResult } from "./runStudioDeploy.js"; /** A proposal as content answers it, as far as a build reads it. */ export type BuiltProposal = { staged?: { inputs: string | null; buildRequired: boolean; } | null; built?: { hash: string; inputs?: string | null; } | null; /** * A build the platform was asked for and has not served * (`buildProposalOnServer`): `pending`, or `failed` with why. Absent from * content that does not build. */ serverBuild?: { state: "pending" | "failed"; inputs: string; error: string | null; } | null; }; /** The calls a build of a proposal makes. An error carries content's `status`. */ export type ProposalBuildClient

= { /** Its files, and what is staged. */ files(name: string): Promise<{ files: Record; staged: { inputs: string | null; buildRequired: boolean; }; }>; /** What it builds on: its own layer, or the site's. */ buildTarget(name: string): Promise<{ target: BuildTargetResponse; layer: "site" | "own"; }>; serveBuild(name: string, build: { publishId: string; inputs: string; }): Promise

; get(name: string): Promise

; }; /** What a build of the proposal came to. */ export type ProposalBuildOutcome

= { status: "built"; hash: string | null; proposal: P; } | { status: "nothing-staged"; } | { status: "already-built"; hash: string | null; } | { status: "failed"; message: string; /** * Stopped by whoever started it (`signal`), not by anything wrong with * the build: nothing to fix, and nothing to show as an error. */ cancelled?: true; }; /** What a cancelled build answers. */ export declare const BUILD_CANCELLED_MESSAGE = "The build was cancelled."; /** * Where a build of the proposal is, around the deploy: the deploy's own steps * are the Studio's deploy state (`useStudioDeployState`), and these are the * parts before and after it. * * - `reading`: the proposal's files and the target to build them on. * - `deploying`: the deploy is running; its state says which step. * - `serving`: content is putting the build up at the proposal's address. * - `waiting`: that request did not come back -- a gateway gave up on it -- * and content is asked until it says the proposal is built. */ export type ProposalBuildStep = { kind: "reading"; } | { kind: "deploying"; } | { kind: "serving"; since: number; } | { kind: "waiting"; since: number; }; export declare function withoutLockfiles(files: Record): Record; /** How long, and how often, content is asked whether it served the build. */ export declare const SERVE_WAIT_MS: number; export declare const SERVE_POLL_MS = 5000; /** * Build the proposal's staged files and serve the build at its address. * * The files and what they are for (`inputs`) come in one answer, so the build * names exactly what it was made of; content refuses it if they were staged * again meanwhile. The tab builds as for a publish and stops once the build is * uploaded -- nothing goes live -- and content hands it to the platform. * * Serving can take longer than a gateway waits for an answer, and content * finishes it all the same. So a gateway that gives up is not a failure: the * proposal is read until it says it is built from these inputs, and served * once more only if it never does. */ export declare function buildProposal

(deps: { name: string; client: ProposalBuildClient

; /** * `target`: the proposal's own, when it changed the dependencies and builds * on the layer content had built for it; `undefined` builds on the site's, * as every build of a proposal did before. */ deploy: (files: Record, target: BuildTargetResponse | undefined, signal: AbortSignal | undefined) => Promise; /** * Whether this document can build at all (`canBuildHere`): Safari cannot, * and a proposal's build has no builder tab to hand off to yet. */ canBuildHere: () => boolean; onStep?: (step: ProposalBuildStep) => void; /** * Stops the build: Cancel, or a watchdog that saw it stall. Answered at * once, whatever the build was waiting on, and nothing after it is done -- * a build stopped while it uploads is never served. Aborted with an `Error` * of its own, the build fails with that error's message; otherwise it is * `cancelled`. */ signal?: AbortSignal; /** For tests: the clock, and waiting on it. */ now?: () => number; sleep?: (ms: number) => Promise; }): Promise>; /** What content answers, in `details.code`, for a project it does not build yet. */ export declare const SERVER_BUILDS_OFF = "server-builds-off"; /** How often the proposal is read while the platform builds it. */ export declare const SERVER_BUILD_POLL_MS = 1000; /** * How long a build by the platform is waited for. It is seconds * (valbuild/home `docs/plans/server-builds.md`); this is for the platform not * answering, never for a build that is merely slow. */ export declare const SERVER_BUILD_WAIT_MS: number; /** * Where a build by the platform is (`buildProposalOnServer`): reading what is * staged, then Val Build building, rendering and serving it. Its own type, * not `ProposalBuildStep`'s, which every page that runs `buildProposal` * switches over. */ export type ServerBuildStep = { kind: "reading"; } | { kind: "on-server"; since: number; /** What Val Build says of it, when it says (`buildProgress`). */ progress?: ServerBuildProgress | null; }; /** * How far the platform's build is (valbuild/home * `GET /proposals/:name/build-progress`): its place in the queue, the step * the builder says it is at, and `built` once the builder is done and the * build is being checked and served. */ export type ServerBuildProgress = { queued: number | null; step: { label: string; index: number; of: number; } | null; built: boolean; }; /** The calls a build by the platform makes. An error carries content's `status`. */ export type ServerBuildClient

= Pick, "get"> & { /** Ask the platform to build the staged files `inputs` names: `/build` without a publish. */ askBuild(name: string, inputs: string): Promise

; /** * How far the build of `inputs` is, or `null` when that cannot be told: * content from before it said, or a build of other files. Optional: a * client without it shows the build without progress. */ buildProgress?(name: string, inputs: string): Promise; }; /** * Have the platform build the proposal's staged files and serve the build at * its address (valbuild/home `docs/plans/server-builds.md`): nothing is built * in this tab, so no bundler is loaded, no builder tab is opened, and a tab * that closes meanwhile loses nothing. * * Content answers at once and builds in a job; the proposal is read until it * says the build of these inputs is served, or why it is not. `off` when * content does not build this project yet: `buildProposal` builds it in the * tab, as before. * * A cancel stops the waiting, not the build: the platform finishes it, and * the proposal's address serves it when it renders. */ export declare function buildProposalOnServer

(deps: { name: string; client: ServerBuildClient

; onStep?: (step: ServerBuildStep) => void; signal?: AbortSignal; /** For tests: the clock, and waiting on it. */ now?: () => number; sleep?: (ms: number) => Promise; }): Promise | { status: "off"; }>;