/** * The Studio's side of the content service's publish API. * * Same conversation `val publish` has -- declare, upload, confirm, verify, * promote -- and deliberately the same PARSERS: `parseDeclare` and the rest * come from `@valbuild/shared/internal`, where they live precisely so that two * publishers cannot come to disagree about what content said. * * ## Two things differ from the CLI's client, and both are the same fact * * A browser holds a session cookie for the app's origin and no credential * content would accept -- content's publish API takes a project token and * refuses everything else. So: * * - **Every call goes to this origin**, at `/api/val/publish-api`, and the * deployment swaps the credential on the way (see `ValOpsHttp.publishApi`). * Nothing here has a token, and nothing here should ever be given one. * - **The uploads do not.** A slot is a presigned URL for object storage, and * those bytes go straight there rather than through the isolate -- which is * the whole reason the API hands out slots instead of accepting the artifacts * itself. `credentials: "omit"` on those, because a presigned URL carries its * own authorisation and a cookie sent to a storage host is a cookie leaked to * one. */ import { ArtifactsResponse, BuildTargetResponse, DeclareBody, DeclareResponse, PromoteResponse, StatusResponse, UploadSlot, VerifyResponse, publishApiOf, type PublishApiAt } from "../internal/index.js"; export { StudioPublishError, callJson, isTransientPublishError, } from "./callJson.js"; export { publishApiOf, type PublishApiAt }; /** An artifact the live build has and this publish re-declares by hash. */ export type CarriedArtifact = { key: string; sha256: string; bytes: number; }; /** See {@link StudioPublishClient.publicFiles}. */ export type LivePublicFiles = { carried: CarriedArtifact[]; } | { paths: string[]; } | null; /** Object storage refused the bytes, or could not be reached. */ export declare class StudioUploadError extends Error { readonly statusCode: number; readonly key: string; constructor(statusCode: number, key: string, message: string); } export type StudioPublishClient = { /** * What to build against, and what to build -- the two reads a publish makes * before it has anything to declare. * * On this type rather than beside it because they go through the same proxy * with the same credential, and because a caller holding one of them and not * the other can do nothing at all. */ buildTarget(): Promise; /** `null` when the project has never published. */ projectSource(): Promise | null>; /** * What the live build serves from `public/`: by hash when content published * it, by path when only the loader knows, `null` when neither can say. See * `publicFiles` and `publicPaths` on `GET /v1/project-source`, which this * reads with {@link projectSource} in one request. */ publicFiles(): Promise; declare(body: DeclareBody): Promise; confirmArtifacts(publishId: string): Promise; verify(publishId: string): Promise; promote(publishId: string): Promise; status(publishId: string): Promise; /** The artifact's bytes, straight to object storage. */ upload(slot: UploadSlot, body: string): Promise; }; /** * A slot's permission to write has run out. * * Its own shape because it is not a failure: the answer is to declare again for * fresh slots, and a publish that treated it as one would give up an upload * short of the finish. */ export declare function isExpiredSlot(error: unknown): boolean; export declare function createStudioPublishClient(options: PublishApiAt & { fetchImpl?: typeof fetch; }): StudioPublishClient;