/** * The app registry — the one registration channel, validated. * * `createApp({ registry })` takes a `{ handlers, actors, projections, workflows, * commands }` object grouping every `define*` primitive by kind. Two sources * produce that object, and the runtime treats them identically: * * - **build / dev** — `import { registry } from "virtual:nwire-registry/"`, * generated by the `@nwire/scan` unplugin (no hand-authored list). * - **manual** — `defineRegistry({ handlers: [createTodo, listTodos], … })`, * written by hand for an edge target with no bundler, a test, or a one-off. * * Because both feed the same `createApp({ registry })` seam, this module gives * the object a STRICT, validated contract: every entry must be a real primitive * whose `$kind` matches the group it sits in, with a unique name. A malformed * registry — a projection dropped into `handlers`, a duplicate name, a missing * `name` — fails loudly at construction instead of misbehaving three layers * deep. `defineRegistry` fills missing groups with `[]` and validates; passing a * raw object to `createApp` validates the same way. */ import type { DiscoveredPrimitives } from "./app-discovery.js"; /** The validated registry shape — the one object `createApp({ registry })` takes. */ export type AppRegistry = DiscoveredPrimitives; /** A registry as authored — any group may be omitted (defaults to `[]`). */ export type RegistryInput = Partial; /** * Thrown when a registry object is malformed. `errors` lists every problem so a * hand-authored registry surfaces all of them in one boot failure. */ export declare class RegistryValidationError extends Error { readonly errors: readonly string[]; constructor(message: string, errors: readonly string[]); } /** * Validate a registry object strictly. Aggregates every problem and throws a * single {@link RegistryValidationError} listing them all. Used by `createApp` * on every `registry` it receives — vite-generated or hand-written. * * @param input The registry to validate. Missing groups are treated as empty. * @param label Optional source label woven into the error (e.g. an app name). */ export declare function assertValidRegistry(input: RegistryInput, label?: string): void; /** * Declare an app registry by hand. Fills every missing group with `[]`, * validates strictly (see {@link assertValidRegistry}), and returns the frozen, * fully-shaped object — interchangeable with the one the unplugin generates. * * The input's own type is preserved (not widened to `any[]` groups) so * `createApp({ registry })` can derive the app's typed public surface from the * `.public()` primitives it finds in `handlers` and `events`. * * export const registry = defineRegistry({ * handlers: [createTodo, listTodos], * commands: [backfillTodos], * }) * createApp({ appName: "app", registry }) */ export declare function defineRegistry(input: T): T & Omit;