import { z } from "zod"; /** * The navigable full-page view — its presence is the sole signal a branded app * is navigable (spec 002-workbench-extension-api, US5). * @public */ export declare type App = InterfaceOfType<"app">; /** * User-facing input for `unstable_defineApp`. Excludes the internal * `applicationType` — that field is validated by the schema but is not part of * the public surface (Sanity-owned apps set it via `@ts-expect-error`). * @public */ export declare type DefineAppInput = Omit< z.output, "applicationType" >; /** * Runtime-validation schema for `unstable_defineApp`. Validates the full shape * including the internal `applicationType`; the user-facing `DefineAppInput` * type below omits that field. Services land in a later step and extend this * object additively via `.extend(...)`. * @internal */ declare const DefineAppInputSchema: z.ZodObject< { name: z.ZodString; title: z.ZodString; icon: z.ZodOptional; group: z.ZodOptional< z.ZodEnum<{ "dock.system": "dock.system"; "dock.applications": "dock.applications"; "dock.user": "dock.user"; }> >; priority: z.ZodOptional; entry: z.ZodOptional; organizationId: z.ZodOptional; views: z.ZodOptional< z.ZodArray< z.ZodDiscriminatedUnion< [ z.ZodObject< { name: z.ZodString; src: z.ZodString; type: z.ZodLiteral<"panel">; }, z.core.$strip >, ], "type" > > >; services: z.ZodOptional< z.ZodArray< z.ZodDiscriminatedUnion< [ z.ZodObject< { name: z.ZodString; src: z.ZodString; type: z.ZodLiteral<"worker">; }, z.core.$strip >, ], "type" > > >; applicationType: z.ZodOptional< z.ZodEnum<{ coreApp: "coreApp"; studio: "studio"; canvas: "canvas"; dashboard: "dashboard"; "media-library": "media-library"; system: "system"; }> >; }, z.core.$strip >; /** * The branded result of `unstable_defineApp`. Carries the same fields as the * input plus the internal brand — users only ever see `DefineAppInput`. * @public */ export declare interface DefineAppResult extends DefineAppInput { readonly [WORKBENCH_APP]: true; } /** * The result of `unstable_defineService`: the author's callback, the service * type, and the internal contract version the worker artifact targets. * @public */ declare interface DefinedService { readonly type: TType; /** @internal */ readonly version: typeof SERVICE_CONTRACT_VERSION; readonly run: ServiceCallbacksByType[TType]; } /** * The result of `unstable_defineView`: the author's component(s), the view type, * and the internal contract version the build artifact targets. * @public */ declare interface DefinedView { readonly type: TType; /** @internal */ readonly version: typeof VIEW_CONTRACT_VERSION; readonly components: ViewComponentsByType[TType]; } /** * Dock group identifier. The API does not block a user app from declaring a * reserved group (e.g. `dock.system`); priority conventions keep Sanity-owned * apps ahead. * @public */ export declare type DockGroup = z.output; /** Dock groups an app can place itself into. */ declare const DockGroup_2: z.ZodEnum<{ "dock.system": "dock.system"; "dock.applications": "dock.applications"; "dock.user": "dock.user"; }>; /** * Dock group identifier. The API does not block a user app from declaring a * reserved group (e.g. `dock.system`); priority conventions keep Sanity-owned * apps ahead. * @public */ declare type DockGroup = z.output; /** @public */ export declare type Interface = z.output; /** The interface record for a given `interface_type`. @public */ declare type InterfaceOfType = Extract< Interface, { interface_type: T; } >; /** * An interface record discriminated on `interface_type` — a `panel` renders in * the dock, a `worker` runs a background service, an `app` is the navigable * full-page view. snake_case matches the service JSON. * @public */ export declare const InterfaceSchema: z.ZodDiscriminatedUnion< [ z.ZodObject< { interface_type: z.ZodLiteral<"panel">; id: z.ZodString; deployment_id: z.ZodString; name: z.ZodString; entry_point: z.ZodString; }, z.core.$strip >, z.ZodObject< { interface_type: z.ZodLiteral<"worker">; id: z.ZodString; deployment_id: z.ZodString; name: z.ZodString; entry_point: z.ZodString; }, z.core.$strip >, z.ZodObject< { interface_type: z.ZodLiteral<"app">; id: z.ZodString; deployment_id: z.ZodString; name: z.ZodString; entry_point: z.ZodString; }, z.core.$strip >, ], "interface_type" >; /** * Every supported interface type — the first argument to `unstable_defineView`. * @public */ declare type InterfaceType = keyof typeof VIEW_COMPONENTS; /** @public */ export declare type LocalApp = LocalInterfaceOfType<"app">; /** @public */ export declare type LocalInterface = z.output; /** The {@link InterfaceOfType} counterpart without `id`/`deployment_id`. @public */ declare type LocalInterfaceOfType = Extract< LocalInterface, { interface_type: T; } >; /** * An {@link Interface} without the service-assigned `id`/`deployment_id` a local * dev server can't provide — the shape the workbench renders from. * @public */ export declare const LocalInterfaceSchema: z.ZodDiscriminatedUnion< [ z.ZodObject< { interface_type: z.ZodLiteral<"panel">; name: z.ZodString; entry_point: z.ZodString; }, z.core.$strip >, z.ZodObject< { interface_type: z.ZodLiteral<"worker">; name: z.ZodString; entry_point: z.ZodString; }, z.core.$strip >, z.ZodObject< { interface_type: z.ZodLiteral<"app">; name: z.ZodString; entry_point: z.ZodString; }, z.core.$strip >, ], "interface_type" >; /** @public */ export declare type LocalPanel = LocalInterfaceOfType<"panel">; /** * A local application's service — a {@link Service} without the * service-assigned `id`/`deployment_id`, i.e. the worker-typed subset of the * `LocalInterface` union. * @public */ export declare type LocalService = Omit; /** @public */ export declare type Panel = InterfaceOfType<"panel">; /** * A panel's view-component slot — the module-federation expose for one island. * @public */ export declare type PanelComponent = keyof PanelViewComponents; declare type PanelInterface = z.output; /** * The `panel` interface record the application service returns — and what a * panel component receives as its `view`. */ declare const PanelInterfaceSchema: z.ZodObject< { interface_type: z.ZodLiteral<"panel">; id: z.ZodString; deployment_id: z.ZodString; name: z.ZodString; entry_point: z.ZodString; }, z.core.$strip >; declare interface PanelViewComponents { title: ViewComponent; panel: ViewComponent; } /** * Props a panel component receives: its interface record, minus the * service-assigned `id`/`deployment_id` a local dev server can't provide. * @public */ declare type PanelViewProps = ViewComponentBaseProps< Omit >; /** * A service an application runs — the worker-typed interface record, the same * shape the application service returns in its `interfaces` list (the * `interface_type: "worker"` member of the `Interface` union, counterpart of * `Panel`). Defined off {@link WorkerInterfaceSchema} here rather than extracted * from the union, so this module owns the worker shape without depending back on * `views/interface` (which folds this schema into the union). * @public */ export declare type Service = z.output; /** * Contract version stamped on every defined service. Lets the workbench host * and the generated worker artifact evolve the service contract without * breaking already-deployed services; bumped only on a breaking change. * @internal */ declare const SERVICE_CONTRACT_VERSION = 1; /** * A service callback. Runs once inside the worker on start; returns an optional * disposer the host calls before terminating the worker. * @public */ declare type ServiceCallback = (context: ServiceContext) => void | (() => void); /** The callback shape each service type defines, keyed by type. */ declare interface ServiceCallbacksByType { worker: ServiceCallback; } /** * Context every service callback receives when its worker starts. Mirrors how a * view component receives its `view` — the service receives its own `service`. * The OS handle a service acts through (e.g. dock badges) lands in a later * iteration; this iteration just runs the worker. * @public */ declare interface ServiceContext { readonly service: ServiceInfo; } /** * The service's own declaration, surfaced to the callback. * @public */ declare interface ServiceInfo { readonly type: string; readonly name: string; } /** * Every supported service type. The first argument to `unstable_defineService`. * Add a service type by adding its schema above and registering it here + in * the declaration union below. * @public */ declare type ServiceType = "worker"; /** * 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 declare function unstable_defineApp( input: DefineAppInput, ): DefineAppResult; /** * Define a Sanity Workbench background service. The first argument narrows the * callback shape — `"worker"` runs the callback inside a Web Worker, where it * can emit dock-badge updates via `os.updateBadge(...)` and return a disposer. * * Identity at runtime: returns the callback tagged with its type and the * contract version, for the CLI build to generate a worker artifact from. Used * as the default export of a service's `src` file. * @public */ export declare function unstable_defineService( type: TType, run: ServiceCallbacksByType[TType], ): DefinedService; /** * Define a Sanity Workbench view. The first argument narrows the component shape * and the props each component receives — `"panel"` yields a `{ title, panel }` * record whose components are typed with the panel props. * * Returns the component(s) tagged with their type and the contract version, for * the CLI build to generate render artifacts from. Used as the default export of * a view's `src` file. * @public */ export declare function unstable_defineView( type: TType, components: ViewComponentsByType[TType], ): DefinedView; /** * Component slots each interface type exposes, in render order — source of * truth for the build (one render artifact per component) and for * {@link InterfaceType}. Add a type by adding its module and registering it here. * @internal */ declare const VIEW_COMPONENTS: { readonly panel: readonly ["title", "panel"]; }; /** * Contract version stamped on every defined view — lets the host and the * generated artifact evolve the contract without breaking deployed views. * @internal */ declare const VIEW_CONTRACT_VERSION = 1; /** * A view component. The return is opaque so `@sanity/federation` carries no * React dependency — the generated artifact renders it with the app's own React. * @public */ declare type ViewComponent = (props: TProps) => unknown; /** * Props every view component receives, whatever its type. Per-type props * compose from this, so a prop added here reaches every view. * @public */ declare interface ViewComponentBaseProps { view: TView; } /** * The components each interface type exposes, keyed by type. * @public */ declare interface ViewComponentsByType { panel: PanelViewComponents; } /** * 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. */ declare const WORKBENCH_APP: unique symbol; /** * A `worker` interface — what the application service stores and returns. On * the type level a service is just an interface discriminated by * `interface_type`; the build turns a `{ type, name, src }` declaration into * this `interface_type: "worker"` record the workbench host runs. Shares the * interface shape (`id`/`deployment_id`/`name`/`entry_point`) with views, and * is folded into the {@link InterfaceSchema} union over in `views/interface`. */ declare const WorkerInterfaceSchema: z.ZodObject< { interface_type: z.ZodLiteral<"worker">; id: z.ZodString; deployment_id: z.ZodString; name: z.ZodString; entry_point: z.ZodString; }, z.core.$strip >; export {};