import { Effect, Option } from 'effect'; import type { CommandDefinition } from '../command/index.js'; import type { AnyCommand, CommandMatcher, Resolver } from './internal.js'; export type { AnyCommand, CommandMatcher, Resolver }; /** A typed Command instance carrying the result Message type via its * `effect` field, so passing `FetchWeather({ zipCode })` to `Story.Command.resolve` * preserves the link between the Command and its declared result Message. */ type AnyCommandInstance = Readonly<{ name: string; args?: Record; effect: Effect.Effect; }>; /** An immutable test simulation of a Foldkit program. */ export type StorySimulation = Readonly<{ /** @internal Carries the Message type through the step chain. */ _phantomMessage?: Message; model: Model; commands: ReadonlyArray; outMessage: OutMessage; }>; /** A callable step that sets the initial Model. Carries phantom type for compile-time validation. */ export type WithStep = Readonly<{ _phantomModel: Model; }> & ((simulation: StorySimulation) => StorySimulation); /** A model-assertion step produced by {@link model}. */ export type ModelStep = Readonly<{ readonly _tag: 'ModelStep'; readonly assert: (model: Model) => void; }>; /** A single step in a story: a {@link WithStep}, a {@link ModelStep}, * or a simulation transform. */ export type StoryStep = WithStep> | ModelStep> | ((sim: StorySimulation) => StorySimulation); /** Sets the initial Model for a test story. */ export { with_ as with }; declare const with_: (model: Model) => WithStep; /** Sends a Message through update. Commands stay pending until resolve or * resolveAll. */ export declare const message: (message_: MessageInput) => (simulation: StorySimulation) => StorySimulation; /** Runs an assertion function against the current Model. */ export declare const model: (f: (model: Model) => void) => ModelStep; /** Steps that operate on the pending Commands of a story simulation. * Destructure as `const { Command } = Story` for concise call sites. */ export declare const Command: { /** Resolves a specific pending Command with the given result Message. */ readonly resolve: { (definition: CommandDefinition, resultMessage: ResultMessage): (simulation: StorySimulation) => StorySimulation; (definition: CommandDefinition, resultMessage: ResultMessage, toParentMessage: (message: ResultMessage) => ParentMessage): (simulation: StorySimulation) => StorySimulation; (instance: AnyCommandInstance, resultMessage: ResultMessage): (simulation: StorySimulation) => StorySimulation; (instance: AnyCommandInstance, resultMessage: ResultMessage, toParentMessage: (message: ResultMessage) => ParentMessage): (simulation: StorySimulation) => StorySimulation; }; /** Resolves listed Commands with their result Messages, cascading through any * Commands the result produces. Each entry resolves exactly one matching * dispatch in declaration order; compose with `Array.makeBy` for N * identical responses. Resolvers carry across calls; a new entry replaces * any leftovers sharing its Definition or Instance shape (latest wins). */ readonly resolveAll: >(...resolvers: { [K in keyof R]: Resolver; }) => (simulation: StorySimulation) => StorySimulation; /** Asserts that every given Command is among the pending Commands. */ readonly expectHas: (...matchers: ReadonlyArray) => (simulation: StorySimulation) => StorySimulation; /** Asserts that the pending Commands match the given definitions exactly (order-independent). */ readonly expectExact: (...matchers: ReadonlyArray) => (simulation: StorySimulation) => StorySimulation; /** Asserts that there are no pending Commands. */ readonly expectNone: () => (simulation: StorySimulation) => StorySimulation; }; /** Asserts that the OutMessage is Some with the expected value. */ export declare const expectOutMessage: (expected: Expected) => (simulation: StorySimulation>) => StorySimulation>; /** Asserts that the OutMessage is None. */ export declare const expectNoOutMessage: () => (simulation: StorySimulation>) => StorySimulation>; /** Executes a test story. Throws if any Commands remain unresolved. */ export declare const story: { (updateFn: (model: Model, message: Message) => readonly [Model, ReadonlyArray, OutMessage], ...steps: ReadonlyArray>>): void; (updateFn: (model: Model, message: Message) => readonly [Model, ReadonlyArray], ...steps: ReadonlyArray>>): void; }; //# sourceMappingURL=story.d.ts.map