import * as storybook_open_service from 'storybook/open-service';
import * as storybook_internal_types from 'storybook/internal/types';
import { NormalizedProjectAnnotations, ProjectAnnotations, ComposedStoryFn, StrictArgTypes as StrictArgTypes$1 } from 'storybook/internal/types';
import { StrictArgTypes } from 'storybook/internal/csf';
/** The Standard Typed interface. This is a base type extended by other specs. */
interface StandardTypedV1 {
/** The Standard properties. */
readonly "~standard": StandardTypedV1.Props ;
}
declare namespace StandardTypedV1 {
/** The Standard Typed properties interface. */
interface Props {
/** The version number of the standard. */
readonly version: 1;
/** The vendor name of the schema library. */
readonly vendor: string;
/** Inferred types associated with the schema. */
readonly types?: Types | undefined;
}
/** The Standard Typed types interface. */
interface Types {
/** The input type of the schema. */
readonly input: Input;
/** The output type of the schema. */
readonly output: Output;
}
/** Infers the input type of a Standard Typed. */
type InferInput = NonNullable["input"];
/** Infers the output type of a Standard Typed. */
type InferOutput = NonNullable["output"];
}
/** The Standard Schema interface. */
interface StandardSchemaV1 {
/** The Standard Schema properties. */
readonly "~standard": StandardSchemaV1.Props ;
}
declare namespace StandardSchemaV1 {
/** The Standard Schema properties interface. */
interface Props extends StandardTypedV1.Props {
/** Validates unknown input values. */
readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result | Promise>;
}
/** The result interface of the validate function. */
type Result = SuccessResult | FailureResult;
/** The result interface if validation succeeds. */
interface SuccessResult {
/** The typed output value. */
readonly value: Output;
/** A falsy value for `issues` indicates success. */
readonly issues?: undefined;
}
interface Options {
/** Explicit support for additional vendor-specific parameters, if needed. */
readonly libraryOptions?: Record | undefined;
}
/** The result interface if validation fails. */
interface FailureResult {
/** The issues of failed validation. */
readonly issues: ReadonlyArray;
}
/** The issue interface of the failure output. */
interface Issue {
/** The error message of the issue. */
readonly message: string;
/** The path of the issue, if any. */
readonly path?: ReadonlyArray | undefined;
}
/** The path segment interface of the issue. */
interface PathSegment {
/** The key representing a path segment. */
readonly key: PropertyKey;
}
/** The Standard types interface. */
interface Types extends StandardTypedV1.Types {
}
/** Infers the input type of a Standard. */
type InferInput = StandardTypedV1.InferInput;
/** Infers the output type of a Standard. */
type InferOutput = StandardTypedV1.InferOutput;
}
/** File map used by static snapshot building. Each key represents one serialized state snapshot. */
type StaticStore = Record;
/** Generic Standard Schema constraint used across open-service definitions. */
type AnySchema = StandardSchemaV1;
/** Stable alias for service identifiers across definition, runtime, and registration APIs. */
type ServiceId = string;
/**
* Constrains a service's state to a plain object — the only shape the architecture supports.
*
* This is not an arbitrary restriction; two layers require it:
*
* 1. State is wrapped in a `deepSignal` proxy for fine-grained per-field reactivity, and `deepSignal`
* throws ("this object can't be observed") on primitives, `null`, and `undefined` — there are no
* fields to track on a scalar.
* 2. Cross-peer sync (`applyStatePatch` in `service-sync.ts`) merges state by walking object keys;
* it has no notion of replacing a whole scalar, so the wire protocol only carries keyed objects.
*
* Arrays are technically observable by `deepSignal` but are still rejected here: `applyStatePatch`
* replaces arrays wholesale rather than merging by key, so a *top-level* array state would silently
* fail to sync between peers. Wrap collections in a field instead (`{ items: [...] }`).
*
* Authoring helpers pair this with an `extends object` bound (which rejects primitives, `null`, and
* `undefined` while still accepting both `interface` and `type` declarations). The naked `TState` in
* the intersection keeps it transparent to inference; only an array collapses to the branded error.
*/
type ServiceState = TState & (TState extends readonly unknown[] ? {
__openServiceStateError: 'Service state must be a plain object, not an array.';
} : unknown);
/** Public schema shape exposed when describing a schema-backed service contract. */
type SchemaDescriptor = AnySchema;
/** Raw caller-facing value type accepted by a schema-backed operation. */
type InferSchemaInput = StandardSchemaV1.InferInput;
/** Parsed value type produced by a schema after validation. */
type InferSchemaOutput = StandardSchemaV1.InferOutput;
/**
* Named schema maps are the core inference surface for inline open-service authoring.
*
* `defineService()` infers one input-schema map and one output-schema map per operation family
* (queries and commands). Keeping those maps separate gives TypeScript a place to correlate the
* `input` and `output` properties of each inline object before it contextually types sibling
* callbacks like `handler`, `load`, `staticPath`, and `staticInputs`.
*/
type OperationInputSchemas = Record;
/**
* Output-schema maps must stay key-aligned with their input-schema map.
*
* The authoring helper uses this alias instead of a plain `Record` so each
* operation key retains its own input/output schema pair during inference.
*/
type MatchingOutputSchemas = {
[TKey in keyof TInputSchemas]: AnySchema;
};
/**
* Internal utility used to keep handler maps assignable without collapsing everything to `unknown`.
*/
type BivariantCallback = {
bivarianceHack(...args: TArgs): TResult;
}['bivarianceHack'];
/** Runtime shape shared by all command collections after they are built. */
type Command = Record Promise>;
/**
* Runtime command map derived directly from the inferred command schema maps.
*
* Queries only need command-call typing, not the full command definition objects, so this helper
* keeps query contexts readable while still preserving exact input/output types per command.
*/
type CommandFunctions> = {
[TKey in keyof TCommandInputSchemas]: BivariantCallback<[
input: InferSchemaInput
], Promise>>;
};
/**
* Coarse lifecycle of a query's `load`, modeled after TanStack Query's `status`.
*
* - `pending` — no successful load has completed yet (and none has failed). The query may still
* expose `data` (the synchronous "current best" handler result), but nothing has been loaded.
* - `error` — the most recent attempt (load rejection, or a synchronous handler / validation throw)
* failed. `data` keeps the last successful value, if any.
* - `success` — a load has completed (or the query has no `load`, so there is nothing to load).
*/
type QueryStatus = 'pending' | 'error' | 'success';
/**
* Whether a `load` is currently running, modeled after TanStack Query's `fetchStatus` — but named
* with our own `load` vocabulary because open-service "loads" are any slow async work (computation,
* extraction, I/O), not specifically remote fetching.
*
* - `loading` — a `load` is in flight (the first load, or a reactive background re-load).
* - `idle` — no `load` is currently running.
*/
type LoadStatus = 'loading' | 'idle';
/**
* The reactive state of a subscribed query: its current `data` plus the lifecycle of its `load`.
*
* `data` and `status` are independent. `data` is the synchronous handler result ("current best
* effort") and holds the last successful value (or `undefined` before the first success / when a
* handler throws), while `status`/`loadStatus`/`error` describe the asynchronous `load` lifecycle
* tracked per subscription. A query with no `load` is `success`/`idle` from its first emission.
*
* `isLoading` is intentionally "any load in flight" (TanStack's `isFetching`), and
* `isInitialLoading` is "a load is in flight and there is nothing to show yet"; the names follow our
* `load` vocabulary rather than TanStack's `fetch`/`load` split. Unlike TanStack Query, a
* subscription here can attach to a query whose `data` is already cached in service state, so
* `isInitialLoading` additionally requires `data === undefined` — it never flags over cached data.
*/
type QueryState = {
/** Last successfully produced value; `undefined` before the first success. */
data: TData | undefined;
/** The failure that produced `status: 'error'`, otherwise `undefined`. */
error: Error | undefined;
status: QueryStatus;
loadStatus: LoadStatus;
/** `status === 'pending'`. */
isPending: boolean;
/** `status === 'success'`. */
isSuccess: boolean;
/** `status === 'error'`. */
isError: boolean;
/** `loadStatus === 'loading'` — any load in flight, foreground or background. */
isLoading: boolean;
/** `isPending && isLoading && data === undefined` — a first load with nothing to show yet. */
isInitialLoading: boolean;
/** `isLoading && !isPending` — a background re-load while data is already shown. */
isRefreshing: boolean;
};
/**
* Public runtime shape of a query.
*
* - `.get(input)` reads synchronously: it validates input, runs the handler against current state,
* and returns the validated result. It does **not** fire the query's `load` — it is a pure
* "current best effort" read. (Reads of *other* queries from inside a handler or `load` body still
* participate in dependency tracking, so `.loaded()` and subscriptions trigger those dependency
* loads; a bare consumer `.get()` does not.)
* - `.loaded(input)` awaits the full load — this query's `load` plus every transitively read
* dependency — before resolving with the validated result.
* - `.subscribe(input, callback)` invokes `callback` synchronously with the current {@link QueryState}
* and again whenever tracked state or the load lifecycle changes (deduped on the whole state).
* Subscribing is what fires the query's reactive `load`.
*
* There is intentionally no bare-call form: a previous `query(input)` that returned synchronously
* *and* fired the `load` behind the scenes was removed because the implicit background load was
* confusing. Read with `.get(input)`, await with `.loaded(input)`, observe with `.subscribe(...)`.
*
* Queries whose input schema resolves to `undefined` (for example `v.void()`) may be called with
* zero arguments: `query.get()`, `query.loaded()`.
*/
type InputQuery = {
get(input: TInput): TOutput;
loaded(input: TInput): Promise;
subscribe(input: TInput, callback: (state: QueryState) => void): () => void;
subscribe(input: TInput, selector: (value: TOutput) => TSelected, callback: (state: QueryState) => void): () => void;
};
/** Zero-argument overloads merged into {@link Query} when the input schema is void. */
type VoidQuery = {
get(): TOutput;
loaded(): Promise;
subscribe(callback: (state: QueryState) => void): () => void;
subscribe(selector: (value: TOutput) => TSelected, callback: (state: QueryState) => void): () => void;
};
type Query = undefined extends TInput ? VoidQuery & InputQuery : InputQuery;
/**
* Runtime query map derived directly from the inferred query schema maps.
*
* The query counterpart to {@link CommandFunctions}: it preserves each sibling query's exact
* input/output types on the read-only `self.queries` handle, so a handler or `load` can call
* `self.queries.someQuery.get(input)` without manual casts. `defineService` computes this map from
* the inferred query schema maps and threads it into the handler/load contexts as their `TQueries`;
* the erased {@link AnyQueryFunctions} bound is used everywhere the concrete map is not known.
*/
type QueryFunctions> = {
[TKey in keyof TQueryInputSchemas]: Query, InferSchemaOutput>;
};
/**
* Permissive bound for a `self.queries` handle.
*
* Every {@link Query} — input or void — structurally satisfies {@link InputQuery} (the void
* overloads are additive), so this is the supertype that any concrete {@link QueryFunctions} map is
* assignable to. It is the bound (and erased default) for the `TQueries` parameter below, which lets
* the precise per-service map flow into handler contexts while still erasing cleanly into the
* structural `AnyQueryDefinition` storage constraint. Using `Query` here instead
* would wrongly demand the void zero-arg overloads from input queries.
*/
type AnyQueryFunctions = Record>;
/**
* Read-only service handle exposed to query handlers.
*
* Query handlers are strict readers: they can read state and call sibling queries, but they cannot
* mutate state and cannot invoke commands. Mutations belong in commands; load-side preparation
* belongs in `load`.
*/
type QuerySelf = {
readonly state: TState;
queries: TQueries;
};
/**
* Load handle exposed to `load` functions.
*
* `load` may read state and queries, and may invoke declared commands to mutate state. It does
* not receive `setState` directly — all writes must flow through commands so authors keep one
* documented mutation surface per service.
*/
type LoadSelf = MatchingOutputSchemas, TQueries extends AnyQueryFunctions = AnyQueryFunctions> = QuerySelf & {
commands: CommandFunctions;
};
/**
* Mutable service handle exposed to command handlers.
*
* Commands receive both `setState` for direct state mutation and `commands` so one command can
* delegate to another within the same service.
*/
type CommandSelf = MatchingOutputSchemas, TQueries extends AnyQueryFunctions = AnyQueryFunctions> = LoadSelf & {
setState(mutate: (state: TState) => void): void;
};
type ServiceSummary = {
id: ServiceId;
description?: string;
queryNames: string[];
commandNames: string[];
};
type OperationDescriptor = {
name: string;
description?: string;
input: SchemaDescriptor;
output: SchemaDescriptor;
/** Present when the query declares `staticPath` at definition time. */
staticPath?: true;
};
type ServiceDescriptor = {
id: ServiceId;
description?: string;
queries: Record;
commands: Record;
};
/** Context passed to query handlers. */
type QueryCtx = {
self: QuerySelf;
getService: ServiceRegistryApi['getService'];
};
/** Context passed to `load` functions and static-input enumerators. */
type LoadCtx = MatchingOutputSchemas, TQueries extends AnyQueryFunctions = AnyQueryFunctions> = {
self: LoadSelf;
getService: ServiceRegistryApi['getService'];
};
/** Static input enumerator stored on registered definitions; always receives load context. */
type RegisteredStaticInputs = BivariantCallback<[
ctx: LoadCtx
], unknown[] | Promise>;
/** Context passed to command handlers. */
type CommandCtx = MatchingOutputSchemas, TQueries extends AnyQueryFunctions = AnyQueryFunctions> = {
self: CommandSelf;
getService: ServiceRegistryApi['getService'];
};
/**
* Declarative definition for one query.
*
* Queries validate caller input synchronously, run a synchronous read-only handler, and validate
* the resolved output. The optional `load` hook is fired by subscriptions (reactively) and by
* `.loaded()` callers (drained to completion), deduped per `(service, query, input)` while one is
* already in flight — a bare `.get()` read never fires it.
*
* Queries that participate in static JSON generation declare `staticPath` at definition time.
* `staticInputs` may also be declared here when the input list has no runtime dependencies; inputs
* that need registry or story-index context belong in server registration instead.
*/
type QueryDefinition = MatchingOutputSchemas, TQueries extends AnyQueryFunctions = AnyQueryFunctions> = {
description?: string;
/**
* When true, hides this query from `describeService()` output. Defaults to false. Does not disable
* the query at runtime — callers with a service handle can still invoke it.
*/
internal?: boolean;
input: TInputSchema;
output: TOutputSchema;
/** Logical path for the serialized state snapshot, relative to this service's output folder. */
staticPath?: BivariantCallback<[input: InferSchemaOutput], string>;
/** Dependency-free static build inputs declared alongside the public contract. */
staticInputs?: BivariantCallback<[
], InferSchemaInput[] | Promise[]>>;
handler?: BivariantCallback<[
input: InferSchemaOutput,
ctx: QueryCtx
], InferSchemaInput>;
load?: BivariantCallback<[
input: InferSchemaOutput,
ctx: LoadCtx
], void | Promise>;
};
/**
* Declarative definition for one command.
*
* Commands validate caller input, run against a mutable context, and validate the resolved output.
*/
type CommandDefinition = MatchingOutputSchemas, TQueries extends AnyQueryFunctions = AnyQueryFunctions> = {
description?: string;
/**
* When true, hides this command from `describeService()` output. Defaults to false. Does not
* disable the command at runtime — callers with a service handle can still invoke it.
*/
internal?: boolean;
input: TInputSchema;
output: TOutputSchema;
handler?: BivariantCallback<[
input: InferSchemaOutput,
ctx: CommandCtx
], InferSchemaInput | Promise>>;
};
/** Internal structural constraint used to store any query definition in a record. */
type AnyQueryDefinition = {
description?: string;
internal?: boolean;
input: AnySchema;
output: AnySchema;
staticPath?: BivariantCallback<[input: unknown], string>;
staticInputs?: RegisteredStaticInputs;
handler?: BivariantCallback<[input: unknown, ctx: QueryCtx], unknown>;
load?: BivariantCallback<[input: unknown, ctx: LoadCtx], void | Promise>;
};
/** Internal structural constraint used to store any command definition in a record. */
type AnyCommandDefinition = {
description?: string;
internal?: boolean;
input: AnySchema;
output: AnySchema;
handler?: BivariantCallback<[
input: unknown,
ctx: CommandCtx
], unknown | Promise>;
};
/** Named query map attached to a service definition. */
type Queries = Record>;
/** Named command map attached to a service definition. */
type Commands = Record>;
/** Top-level description of a service: identity, initial state, queries, and commands. */
type ServiceDefinition, TCommands extends Commands, TId extends ServiceId = ServiceId> = {
id: TId;
description?: string;
/**
* When true, hides this service from `listServices()` output. Defaults to false. Does not disable
* the service at runtime — callers can still resolve it through `getService()`.
*/
internal?: boolean;
/**
* Initial state for the service. Must be a plain object (not a primitive, `null`, or array) — see
* {@link ServiceState} for why. The authoring boundary (`defineService`) enforces this; the runtime
* type stays `TState` so already-constructed definitions flow through the registry unchanged.
*/
initialState: TState;
queries: TQueries;
commands: TCommands;
};
/** Structural constraint for any service definition stored in the registry. */
type AnyServiceDefinition = ServiceDefinition, Commands>;
/** Runtime service instance derived from a `ServiceDefinition`. */
type ServiceInstance, TCommands extends Commands> = {
queries: {
[TKey in keyof TQueries]: TQueries[TKey] extends {
input: infer TInputSchema extends AnySchema;
output: infer TOutputSchema extends AnySchema;
} ? Query, InferSchemaOutput> : never;
};
commands: {
[TKey in keyof TCommands]: TCommands[TKey] extends {
input: infer TInputSchema extends AnySchema;
output: infer TOutputSchema extends AnySchema;
} ? (input: InferSchemaInput) => Promise> : never;
};
};
/** Runtime instance type recovered from one authored service definition. */
type ServiceInstanceOf = TDefinition extends ServiceDefinition ? ServiceInstance : never;
interface ServiceRegistryApi {
listServices(): Promise;
describeService(serviceId: ServiceId): Promise;
getService(serviceId: ServiceId): TInstance;
}
type RuntimeService = ServiceInstance, Commands> & ServiceRegistryApi;
type ServiceQueryRegistration = {
/** Static build inputs that may depend on registry or other server context. */
staticInputs?: RegisteredStaticInputs;
};
type ServiceCommandRegistration> = Pick;
type ServiceRegistrationOptions, TCommands extends Commands> = {
queries?: {
[TKey in keyof TQueries]?: ServiceQueryRegistration;
};
commands?: {
[TKey in keyof TCommands]?: ServiceCommandRegistration;
};
};
type ServerServiceRegistration, TCommands extends Commands> = {
definition: ServiceDefinition;
} & ServiceRegistrationOptions;
type InvalidInternalOperationName = {
__internal_naming_error: `Operation "${TName}" has internal: true but must be prefixed with "_"`;
};
type InvalidUnderscoreWithoutInternal = {
__internal_naming_error: `Operation "${TName}" is prefixed with "_" and must set internal: true`;
};
type InternalOperationNaming = TKey extends string ? TKey extends `_${string}` ? {
internal: true;
} | InvalidUnderscoreWithoutInternal : {
internal?: false;
} | InvalidInternalOperationName : {};
/**
* Authoring-side query map derived from separate query input/output schema maps.
*
* The second mapped-type intersection is deliberate. During experiments, TypeScript would infer
* the `input` schema for each inline query, but then lose the corresponding `output` schema before
* it contextually typed sibling callbacks. Repeating the output map through a keyed `output` view
* keeps each query key's input and output schemas correlated while handlers, load hooks, and
* static callbacks are being typed.
*/
type DefinedQueries, TCommandInputSchemas extends OperationInputSchemas, TCommandOutputSchemas extends MatchingOutputSchemas> = {
[TKey in keyof TQueryInputSchemas]: QueryDefinition> & InternalOperationNaming;
} & {
[TKey in keyof TQueryOutputSchemas]: {
output: TQueryOutputSchemas[TKey];
};
};
/**
* Authoring-side command map derived from separate command input/output schema maps.
*
* Commands do not need access to the command schema maps in their own context, but they still
* benefit from the same key-correlation trick as queries so TypeScript preserves each inline
* command object's `output` schema while typing its `handler`.
*/
type DefinedCommands, TQueryInputSchemas extends OperationInputSchemas, TQueryOutputSchemas extends MatchingOutputSchemas> = {
[TKey in keyof TCommandInputSchemas]: CommandDefinition> & InternalOperationNaming;
} & {
[TKey in keyof TCommandOutputSchemas]: {
output: TCommandOutputSchemas[TKey];
};
};
/**
* Finalizes a service definition while preserving inline query and command inference.
*
* The generic order matters here. We infer the per-operation schema maps first, then derive the
* concrete query/command definition maps from those schemas. If we instead ask TypeScript to infer
* the full runtime `ServiceDefinition` maps directly, it widens callback parameters to `unknown`
* before it has correlated each inline object's `input` and `output` properties.
*/
declare const defineService: , const TCommandInputSchemas extends OperationInputSchemas, const TCommandOutputSchemas extends MatchingOutputSchemas, const TId extends ServiceId = ServiceId>(def: {
id: TId;
description?: string;
internal?: boolean;
initialState: ServiceState;
queries: DefinedQueries;
commands: DefinedCommands;
}) => ServiceDefinition, DefinedCommands, TId>;
/**
* Builds the synthetic first-render {@link QueryState} for a subscription hook, from a pure
* `query.get(input)` read.
*
* Subscription hooks must return a {@link QueryState} on their very first render, before the
* subscription's first emission has delivered the real lifecycle (`useSyncExternalStore` reads the
* snapshot during render; the React 16-compatible preview hooks read it synchronously too). `get()`
* returns only data (no lifecycle, no load), so we pair it with a `pending`/`loading` status as a
* placeholder until the subscription delivers the real lifecycle moments later. A throw from
* `get()` (e.g. input validation) becomes an `error` state — mirroring what the subscription would
* emit — so the hook never throws during render.
*
* Shared by the manager-side `useServiceQuery` and the preview-side docs hooks so their first-render
* seeds can never drift apart.
*
* Only the query's `get` method is needed, so the parameter is narrowed to that shape: `TOutput` then
* infers purely (and reliably) from `get`'s return type, rather than through the contravariant
* positions of the full `Query` type — which would widen `TOutput` and break callers that pass a
* query with a hand-written payload type.
*/
declare function seedQueryState(query: {
get(input: TInput): TOutput;
}, input: TInput): QueryState;
declare function seedQueryState(query: {
get(input: TInput): TOutput;
}, input: TInput, selector: (value: TOutput) => TSelected): QueryState;
//#endregion
//#region src/methods/fallback/fallback.d.ts
/**
* Fallback type.
*/
type Fallback>> = MaybeDeepReadonly> | ((dataset?: OutputDataset, InferIssue>, config?: Config>) => MaybeDeepReadonly>);
/**
* Schema with fallback type.
*/
type SchemaWithFallback>, TFallback$1 extends Fallback> = TSchema & {
/**
* The fallback value.
*/
readonly fallback: TFallback$1;
};
//#endregion
//#region src/methods/fallback/fallbackAsync.d.ts
/**
* Fallback async type.
*/
type FallbackAsync> | BaseSchemaAsync>> = MaybeDeepReadonly> | ((dataset?: OutputDataset, InferIssue>, config?: Config>) => MaybePromise>>);
/**
* Schema with fallback async type.
*/
type SchemaWithFallbackAsync> | BaseSchemaAsync>, TFallback$1 extends FallbackAsync> = Omit & {
/**
* The fallback value.
*/
readonly fallback: TFallback$1;
/**
* Whether it's async.
*/
readonly async: true;
/**
* The Standard Schema properties.
*
* @internal
*/
readonly "~standard": StandardProps, InferOutput>;
/**
* Parses unknown input values.
*
* @param dataset The input dataset.
* @param config The configuration.
*
* @returns The output dataset.
*
* @internal
*/
readonly "~run": (dataset: UnknownDataset, config: Config>) => Promise, InferIssue>>;
};
//#endregion
//#region src/types/metadata.d.ts
/**
* Base metadata interface.
*/
interface BaseMetadata {
/**
* The object kind.
*/
readonly kind: "metadata";
/**
* The metadata type.
*/
readonly type: string;
/**
* The metadata reference.
*/
readonly reference: (...args: any[]) => BaseMetadata;
/**
* The input, output and issue type.
*
* @internal
*/
readonly "~types"?: {
readonly input: TInput$1;
readonly output: TInput$1;
readonly issue: never;
} | undefined;
}
//#endregion
//#region src/types/dataset.d.ts
/**
* Unknown dataset interface.
*/
interface UnknownDataset {
/**
* Whether is's typed.
*/
typed?: false;
/**
* The dataset value.
*/
value: unknown;
/**
* The dataset issues.
*/
issues?: undefined;
}
/**
* Success dataset interface.
*/
interface SuccessDataset {
/**
* Whether is's typed.
*/
typed: true;
/**
* The dataset value.
*/
value: TValue$1;
/**
* The dataset issues.
*/
issues?: undefined;
}
/**
* Partial dataset interface.
*/
interface PartialDataset> {
/**
* Whether is's typed.
*/
typed: true;
/**
* The dataset value.
*/
value: TValue$1;
/**
* The dataset issues.
*/
issues: [TIssue, ...TIssue[]];
}
/**
* Failure dataset interface.
*/
interface FailureDataset> {
/**
* Whether is's typed.
*/
typed: false;
/**
* The dataset value.
*/
value: unknown;
/**
* The dataset issues.
*/
issues: [TIssue, ...TIssue[]];
}
/**
* Output dataset type.
*/
type OutputDataset> = SuccessDataset | PartialDataset | FailureDataset;
//#endregion
//#region src/types/standard.d.ts
/**
* The Standard Schema properties interface.
*/
interface StandardProps {
/**
* The version number of the standard.
*/
readonly version: 1;
/**
* The vendor name of the schema library.
*/
readonly vendor: "valibot";
/**
* Validates unknown input values.
*/
readonly validate: (value: unknown) => StandardResult | Promise>;
/**
* Inferred types associated with the schema.
*/
readonly types?: StandardTypes | undefined;
}
/**
* The result interface of the validate function.
*/
type StandardResult = StandardSuccessResult | StandardFailureResult;
/**
* The result interface if validation succeeds.
*/
interface StandardSuccessResult {
/**
* The typed output value.
*/
readonly value: TOutput$1;
/**
* The non-existent issues.
*/
readonly issues?: undefined;
}
/**
* The result interface if validation fails.
*/
interface StandardFailureResult {
/**
* The issues of failed validation.
*/
readonly issues: readonly StandardIssue[];
}
/**
* The issue interface of the failure output.
*/
interface StandardIssue {
/**
* The error message of the issue.
*/
readonly message: string;
/**
* The path of the issue, if any.
*/
readonly path?: readonly (PropertyKey | StandardPathItem)[] | undefined;
}
/**
* The path item interface of the issue.
*/
interface StandardPathItem {
/**
* The key of the path item.
*/
readonly key: PropertyKey;
}
/**
* The Standard Schema types interface.
*/
interface StandardTypes {
/**
* The input type of the schema.
*/
readonly input: TInput$1;
/**
* The output type of the schema.
*/
readonly output: TOutput$1;
}
//#endregion
//#region src/types/schema.d.ts
/**
* Base schema interface.
*/
interface BaseSchema> {
/**
* The object kind.
*/
readonly kind: "schema";
/**
* The schema type.
*/
readonly type: string;
/**
* The schema reference.
*/
readonly reference: (...args: any[]) => BaseSchema>;
/**
* The expected property.
*/
readonly expects: string;
/**
* Whether it's async.
*/
readonly async: false;
/**
* The Standard Schema properties.
*
* @internal
*/
readonly "~standard": StandardProps;
/**
* Parses unknown input values.
*
* @param dataset The input dataset.
* @param config The configuration.
*
* @returns The output dataset.
*
* @internal
*/
readonly "~run": (dataset: UnknownDataset, config: Config>) => OutputDataset;
/**
* The input, output and issue type.
*
* @internal
*/
readonly "~types"?: {
readonly input: TInput$1;
readonly output: TOutput$1;
readonly issue: TIssue;
} | undefined;
}
/**
* Base schema async interface.
*/
interface BaseSchemaAsync> extends Omit, "reference" | "async" | "~run"> {
/**
* The schema reference.
*/
readonly reference: (...args: any[]) => BaseSchema> | BaseSchemaAsync>;
/**
* Whether it's async.
*/
readonly async: true;
/**
* Parses unknown input values.
*
* @param dataset The input dataset.
* @param config The configuration.
*
* @returns The output dataset.
*
* @internal
*/
readonly "~run": (dataset: UnknownDataset, config: Config>) => Promise>;
}
//#endregion
//#region src/types/transformation.d.ts
/**
* Base transformation interface.
*/
interface BaseTransformation> {
/**
* The object kind.
*/
readonly kind: "transformation";
/**
* The transformation type.
*/
readonly type: string;
/**
* The transformation reference.
*/
readonly reference: (...args: any[]) => BaseTransformation>;
/**
* Whether it's async.
*/
readonly async: false;
/**
* Transforms known input values.
*
* @param dataset The input dataset.
* @param config The configuration.
*
* @returns The output dataset.
*
* @internal
*/
readonly "~run": (dataset: SuccessDataset, config: Config>) => OutputDataset | TIssue>;
/**
* The input, output and issue type.
*
* @internal
*/
readonly "~types"?: {
readonly input: TInput$1;
readonly output: TOutput$1;
readonly issue: TIssue;
} | undefined;
}
/**
* Base transformation async interface.
*/
interface BaseTransformationAsync> extends Omit, "reference" | "async" | "~run"> {
/**
* The transformation reference.
*/
readonly reference: (...args: any[]) => BaseTransformation> | BaseTransformationAsync>;
/**
* Whether it's async.
*/
readonly async: true;
/**
* Transforms known input values.
*
* @param dataset The input dataset.
* @param config The configuration.
*
* @returns The output dataset.
*
* @internal
*/
readonly "~run": (dataset: SuccessDataset, config: Config>) => Promise | TIssue>>;
}
//#endregion
//#region src/types/validation.d.ts
/**
* Base validation interface.
*/
interface BaseValidation> {
/**
* The object kind.
*/
readonly kind: "validation";
/**
* The validation type.
*/
readonly type: string;
/**
* The validation reference.
*/
readonly reference: (...args: any[]) => BaseValidation>;
/**
* The expected property.
*/
readonly expects: string | null;
/**
* Whether it's async.
*/
readonly async: false;
/**
* Validates known input values.
*
* @param dataset The input dataset.
* @param config The configuration.
*
* @returns The output dataset.
*
* @internal
*/
readonly "~run": (dataset: OutputDataset>, config: Config>) => OutputDataset | TIssue>;
/**
* The input, output and issue type.
*
* @internal
*/
readonly "~types"?: {
readonly input: TInput$1;
readonly output: TOutput$1;
readonly issue: TIssue;
} | undefined;
}
/**
* Base validation async interface.
*/
interface BaseValidationAsync> extends Omit, "reference" | "async" | "~run"> {
/**
* The validation reference.
*/
readonly reference: (...args: any[]) => BaseValidation> | BaseValidationAsync>;
/**
* Whether it's async.
*/
readonly async: true;
/**
* Validates known input values.
*
* @param dataset The input dataset.
* @param config The configuration.
*
* @returns The output dataset.
*
* @internal
*/
readonly "~run": (dataset: OutputDataset>, config: Config>) => Promise | TIssue>>;
}
//#endregion
//#region src/types/infer.d.ts
/**
* Infer input type.
*/
type InferInput> | BaseSchemaAsync> | BaseValidation> | BaseValidationAsync> | BaseTransformation> | BaseTransformationAsync> | BaseMetadata> = NonNullable["input"];
/**
* Infer output type.
*/
type InferOutput> | BaseSchemaAsync> | BaseValidation> | BaseValidationAsync> | BaseTransformation> | BaseTransformationAsync> | BaseMetadata> = NonNullable["output"];
/**
* Infer issue type.
*/
type InferIssue> | BaseSchemaAsync> | BaseValidation> | BaseValidationAsync> | BaseTransformation> | BaseTransformationAsync> | BaseMetadata