import type { ActionDef } from "./actions.js"; import type { ConstraintBuilder, ConstraintData } from "./constraints.js"; import type { InferContext, LifecycleProp, PropDef } from "./props.js"; import type { RelationDef } from "./relations.js"; import type { TransitionBuilder, TransitionData } from "./transitions.js"; import type { ModelRef } from "./types.js"; export type ConstraintHelpers = { rule: () => ConstraintBuilder; }; export type ModelDef = Record, A extends Record = Record, R extends Record = Record, T extends Record = Record, C extends Record = Record> = IfProvided<"actions", A> & IfProvided<"constraints", StripConstraintMethods> & IfProvided<"props", P> & IfProvided<"relations", R> & IfProvided<"transitions", StripTransitionMethods> & ModelRef & { readonly area?: string; readonly name: Name; }; /** * Extracts the state union from lifecycle() props only (not oneOf). * Returns `never` if zero or multiple lifecycle() props exist — only one allowed per model. */ export type StatesOf

> = IsUnion> extends true ? never : string & { [K in keyof P]: P[K] extends LifecycleProp ? T[number] : never; }[keyof P]; export type TransitionHelpers = { from: (state: F) => { to: (toState: T) => TransitionBuilder; }; }; type ConstraintDefBase = { readonly kind: "constraint"; }; /** * Makes field K required when V has concrete keys (user-provided), * optional when V has a string index signature (unparameterized default). * Depends on ModelDef defaults being Record and model() defaults * being Record — both have `string` as keyof. */ type IfProvided = string extends keyof V ? { readonly [k in K]?: V; } : { readonly [k in K]: V; }; type IsUnion = [T] extends [UnionToIntersection] ? false : true; type LifecycleKeys

> = { [K in keyof P]: P[K] extends LifecycleProp ? K : never; }[keyof P]; type StripConstraintMethods> = { readonly [K in keyof C]: ToConstraintData; }; type StripTransitionMethods> = { readonly [K in keyof T]: ToTransitionData; }; type ToConstraintData = T extends ConstraintBuilder ? ConstraintData : T extends ConstraintData ? ConstraintData : T; type ToTransitionData = T extends TransitionBuilder ? TransitionData : T extends TransitionData ? TransitionData : T; type TransitionDefBase = { readonly from: string; readonly kind: "transition"; readonly to: string; }; type UnionToIntersection = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void ? I : never; export declare function model = Record, const A extends Record = Record, const R extends Record = Record, T extends Record = Record, C extends Record = Record>(name: Name, config: { readonly actions?: A; /** Optional grouping label for `dopespec map` (falls back to folder). */ readonly area?: string; readonly constraints?: (helpers: ConstraintHelpers, Extract>) => C; readonly props?: P; readonly relations?: R; readonly transitions?: (helpers: TransitionHelpers, StatesOf

>) => T; }): ModelDef; export {}; //# sourceMappingURL=model.d.ts.map