1// Wire types shared by the CLI and the Worker.2// This package must stay runtime-agnostic: Web APIs only, no Deno.* or Workers globals.34/** A single file entry in a manifest. Keys are kept short because they're hashed verbatim. */5export interface ManifestFile {6 /** sha256 hex of the file bytes */7 h: string;8 /** size in bytes */9 s: number;10 /** content-type, resolved at push time by the CLI */11 ct: string;12}1314/** A push's complete file set — the content-addressed description of a site version. */15export interface Manifest {16 /** manifest format version */17 v: 1;18 /** path (relative, forward slashes, no leading ./) → file entry */19 files: Record<string, ManifestFile>;20}2122/** A push destination: a raw address, or a vault (optionally with an alias). */23export type Target =24 | { address: number }25 | { vault: string; alias?: string | null };2627/** Body of `POST /api/push/prepare`: the manifest the client wants to push. */28export interface PrepareRequest {29 manifest: Manifest;30}3132/** Reply to `prepare`: the manifest's hash and which blobs the server still needs. */33export interface PrepareResponse {34 manifestHash: string;35 /** blob hashes the server does not have yet */36 missing: string[];37}3839/** Body of `POST /api/push/commit`: finalize a push at `target` with an optional TTL. */40export interface CommitRequest {41 manifest: Manifest;42 target: Target;43 /** days until expiry; "forever" = no expiry; omitted = server default (14) */44 ttl?: number | "forever";45}4647/** Reply to `commit`: the allocated address and the live URL for the new push. */48export interface CommitResponse {49 /** 4-hex address, e.g. "2a3f" */50 address: string;51 url: string;52 alias: string | null;53 manifestHash: string;54 /** unix seconds, null = permanent */55 expiresAt: number | null;56 /** push sequence number for this site */57 seq: number;58}5960/** Summary of a single site, as returned by list/status endpoints. */61export interface SiteInfo {62 address: string;63 vault: string;64 alias: string | null;65 manifestHash: string;66 createdAt: number;67 updatedAt: number;68 expiresAt: number | null;69 url: string;70 protected: boolean;71}7273/** One entry in a site's push history. */74export interface PushInfo {75 seq: number;76 manifestHash: string;77 pushedAt: number;78 note: string | null;79}8081/** A site plus its retained push history (powers `nzip revert`). */82export interface SiteDetail extends SiteInfo {83 history: PushInfo[];84}8586/** A registered vault: its slot, name, and current site count. */87export interface VaultInfo {88 slot: number;89 name: string;90 createdAt: number;91 siteCount: number;92}9394/** Reply to `GET /api/status`: server version and a snapshot of vaults and sites. */95export interface StatusResponse {96 ok: true;97 version: string;98 vaults: VaultInfo[];99 siteCount: number;100 /** sites expiring within 48h */101 expiringSoon: number;102}103104/** Body of a revert request: the push sequence number to repoint to (defaults to previous). */105export interface RevertRequest {106 toSeq?: number;107}108109/** Body of a site PATCH: change TTL and/or password. Omitted fields are left unchanged. */110export interface PatchSiteRequest {111 ttl?: number | "forever";112 /** set a password (string), clear it (null), or leave unchanged (undefined) */113 password?: string | null;114}115116/** Standard error envelope returned by the API on failure. */117export interface ApiError {118 error: string;119}