import type { DefineAppInput } from "./schemas"; /** * Nominal brand the CLI discriminates on to enable the workbench build/deploy * codepath. Registered via `Symbol.for` so the marker survives module-realm * boundaries — consumers (the CLI) re-derive the same global symbol with * `Symbol.for` rather than importing it, so it stays internal to this module. */ const WORKBENCH_APP: unique symbol = Symbol.for("sanity.workbench.defineApp"); /** * The branded result of `unstable_defineApp`. Carries the same fields as the * input plus the internal brand — users only ever see `DefineAppInput`. * @public */ export interface DefineAppResult extends DefineAppInput { readonly [WORKBENCH_APP]: true; } /** * Declare a Sanity Workbench application. Identity at runtime — returns the * same object reference, tagged with the workbench brand. Field validation * (Blueprints `name` pattern etc.) runs at build time in the CLI via the * `DefineAppInput` schema; this helper stays a thin, pure identity wrapper. * @public */ export function unstable_defineApp(input: DefineAppInput): DefineAppResult { return Object.defineProperty(input, WORKBENCH_APP, { value: true, enumerable: false, configurable: false, writable: false, }) as DefineAppResult; }