@doeixd/machine 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/middleware.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAMpD;;;GAGG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC,SAAS,MAAM;IACjD,8CAA8C;IAC9C,cAAc,EAAE,MAAM,CAAC;IACvB,wDAAwD;IACxD,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IACrB,kDAAkD;IAClD,IAAI,EAAE,GAAG,EAAE,CAAC;CACb;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,MAAM;IAChD,iDAAiD;IACjD,cAAc,EAAE,MAAM,CAAC;IACvB,wCAAwC;IACxC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IACzB,uCAAuC;IACvC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IACzB,mDAAmD;IACnD,IAAI,EAAE,GAAG,EAAE,CAAC;CACb;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC,SAAS,MAAM;IAC/C,6CAA6C;IAC7C,cAAc,EAAE,MAAM,CAAC;IACvB,0CAA0C;IAC1C,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IACrB,mDAAmD;IACnD,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,gCAAgC;IAChC,KAAK,EAAE,KAAK,CAAC;CACd;AAED;;;;GAIG;AACH;;;;;GAKG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC,SAAS,MAAM;IAC/C;;;;;;;;;;;;;;;OAeG;IACH,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,iBAAiB,CAAC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;;;;GAcG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,WAAW,CAAC,GAAG,CAAC,EAC/C,QAAQ,EAAE,KAAK,CAAC,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,OAAO,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,EAClF,QAAQ,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,GACzB,YAAY,CAAC,CAAC,CAAC,CASjB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,WAAW,CAAC,GAAG,CAAC,EACvD,KAAK,EAAE,GAAG,GACT,KAAK,IAAI,YAAY,CAAC,CAAC,CAAC,CAE1B;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,WAAW,CAAC,GAAG,CAAC,EAChE,KAAK,EAAE,GAAG,GACT,KAAK,IAAI,qBAAqB,CAAC,CAAC,CAAC,CAQnC"}
@@ -10,6 +10,13 @@
10
10
  * and generate a formal Statechart (JSON) that perfectly matches your implementation,
11
11
  * including resolving Class Constructors to their names.
12
12
  */
13
+ /**
14
+ * Options passed to async transition functions, including cancellation support.
15
+ */
16
+ export interface TransitionOptions {
17
+ /** AbortSignal for cancelling long-running async operations. */
18
+ signal: AbortSignal;
19
+ }
13
20
  /**
14
21
  * A unique symbol used to "brand" a type with metadata.
15
22
  * This key allows the static analyzer to find the metadata within a complex type signature.
@@ -17,10 +24,18 @@
17
24
  export declare const META_KEY: unique symbol;
18
25
  /**
19
26
  * Runtime metadata symbol.
27
+ /**
20
28
  * Non-enumerable property key for storing metadata on function objects at runtime.
21
29
  * @internal
22
30
  */
23
31
  export declare const RUNTIME_META: unique symbol;
32
+ /**
33
+ * Local definition of Machine type to avoid circular imports.
34
+ * @internal
35
+ */
36
+ type Machine<C extends object> = {
37
+ readonly context: C;
38
+ } & Record<string, (...args: any[]) => Machine<any>>;
24
39
  /**
25
40
  * Helper type representing a Class Constructor.
26
41
  * Used to reference target states by their class definition rather than magic strings.
@@ -141,14 +156,19 @@ export declare function guarded<F extends (...args: any[]) => any, M extends Tra
141
156
  * Annotates a transition with an Invoked Service (asynchronous effect).
142
157
  *
143
158
  * @param service - configuration for the service (source, onDone target, onError target).
144
- * @param implementation - The async function implementation.
159
+ * @param implementation - The async function implementation that receives an AbortSignal.
145
160
  * @example
146
161
  * load = invoke(
147
162
  * { src: "fetchData", onDone: LoadedMachine, onError: ErrorMachine },
148
- * async () => { ... }
163
+ * async ({ signal }) => {
164
+ * const response = await fetch('/api/data', { signal });
165
+ * return new LoadedMachine({ data: await response.json() });
166
+ * }
149
167
  * );
150
168
  */
151
- export declare function invoke<D extends ClassConstructor, E extends ClassConstructor, F extends (...args: any[]) => any>(service: {
169
+ export declare function invoke<D extends ClassConstructor, E extends ClassConstructor, F extends (options: {
170
+ signal: AbortSignal;
171
+ }) => any>(service: {
152
172
  src: string;
153
173
  onDone: D;
154
174
  onError: E;
@@ -168,6 +188,87 @@ export declare function invoke<D extends ClassConstructor, E extends ClassConstr
168
188
  export declare function action<F extends (...args: any[]) => any, M extends TransitionMeta>(action: ActionMeta, transition: WithMeta<F, M>): WithMeta<F, M & {
169
189
  actions: [typeof action];
170
190
  }>;
191
+ /**
192
+ * Configuration options for guard behavior when conditions fail.
193
+ */
194
+ export interface GuardOptions<C extends object = any> {
195
+ /** What to do when guard fails */
196
+ onFail?: 'throw' | 'ignore' | GuardFallback<C>;
197
+ /** Custom error message for 'throw' mode */
198
+ errorMessage?: string;
199
+ /** Additional metadata for statechart extraction */
200
+ description?: string;
201
+ }
202
+ /**
203
+ * A fallback machine or function that returns a machine when guard fails.
204
+ */
205
+ export type GuardFallback<C extends object> = ((this: Machine<C>, ...args: any[]) => Machine<C>) | Machine<C>;
206
+ /**
207
+ * A guarded transition that checks conditions at runtime before executing.
208
+ * Can be called with either machine or context as 'this' binding.
209
+ */
210
+ export type GuardedTransition<C extends object, T extends Machine<any>> = {
211
+ (...args: any[]): T | Machine<C> | Promise<T | Machine<C>>;
212
+ readonly __guard: true;
213
+ readonly condition: (ctx: C, ...args: any[]) => boolean | Promise<boolean>;
214
+ readonly transition: (...args: any[]) => T;
215
+ };
216
+ /**
217
+ * Creates a runtime guard that checks conditions before executing transitions.
218
+ * This provides actual runtime protection, unlike the `guarded` primitive which only adds metadata.
219
+ *
220
+ * @template C - The context type
221
+ * @template T - The transition return type
222
+ * @param condition - Function that returns true if transition should proceed
223
+ * @param transition - The transition function to execute if condition passes
224
+ * @param options - Configuration for guard failure behavior
225
+ * @returns A guarded transition function
226
+ *
227
+ * @example
228
+ * ```typescript
229
+ * const machine = createMachine({ balance: 100 }, {
230
+ * withdraw: guard(
231
+ * (ctx, amount) => ctx.balance >= amount,
232
+ * function(amount: number) {
233
+ * return createMachine({ balance: this.balance - amount }, this);
234
+ * },
235
+ * { onFail: 'throw', errorMessage: 'Insufficient funds' }
236
+ * )
237
+ * });
238
+ *
239
+ * machine.withdraw(50); // ✅ Works
240
+ * machine.withdraw(200); // ❌ Throws "Insufficient funds"
241
+ * ```
242
+ */
243
+ export declare function guard<C extends object, T extends Machine<any>>(condition: (ctx: C, ...args: any[]) => boolean | Promise<boolean>, transition: (...args: any[]) => T, options?: GuardOptions<C>): GuardedTransition<C, T>;
244
+ /**
245
+ * Fluent API for creating guarded transitions.
246
+ * Provides a more readable way to define conditional transitions.
247
+ *
248
+ * @template C - The context type
249
+ * @param condition - Function that returns true if transition should proceed
250
+ * @returns A fluent interface for defining the guarded transition
251
+ *
252
+ * @example
253
+ * ```typescript
254
+ * const machine = createMachine({ isAdmin: false }, {
255
+ * deleteUser: whenGuard((ctx) => ctx.isAdmin)
256
+ * .do(function(userId: string) {
257
+ * return createMachine({ ...this.context, deleted: userId }, this);
258
+ * })
259
+ * .else(function() {
260
+ * return createMachine({ ...this.context, error: 'Unauthorized' }, this);
261
+ * })
262
+ * });
263
+ * ```
264
+ */
265
+ export declare function whenGuard<C extends object>(condition: (ctx: C, ...args: any[]) => boolean | Promise<boolean>): {
266
+ /**
267
+ * Define the transition to execute when the condition passes.
268
+ * Returns a guarded transition that can optionally have an else clause.
269
+ */
270
+ do<T extends Machine<any>>(transition: (...args: any[]) => T): GuardedTransition<C, T>;
271
+ };
171
272
  /**
172
273
  * Flexible metadata wrapper for functional and type-state patterns.
173
274
  *
@@ -199,4 +300,5 @@ export declare function action<F extends (...args: any[]) => any, M extends Tran
199
300
  * );
200
301
  */
201
302
  export declare function metadata<T>(_meta: Partial<TransitionMeta>, value: T): T;
303
+ export {};
202
304
  //# sourceMappingURL=primitives.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"primitives.d.ts","sourceRoot":"","sources":["../../src/primitives.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH;;;GAGG;AACH,eAAO,MAAM,QAAQ,eAAwB,CAAC;AAE9C;;;;GAIG;AACH,eAAO,MAAM,YAAY,eAAqC,CAAC;AAE/D;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,+CAA+C;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,mDAAmD;IACnD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,8DAA8D;IAC9D,GAAG,EAAE,MAAM,CAAC;IACZ,mDAAmD;IACnD,MAAM,EAAE,gBAAgB,CAAC;IACzB,iDAAiD;IACjD,OAAO,EAAE,gBAAgB,CAAC;IAC1B,4BAA4B;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,qDAAqD;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,uDAAuD;IAC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;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,eAAe,EAAE,GAAG,EACpB,MAAM,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GACzC,GAAG,CAUL"}
@@ -0,0 +1,313 @@
1
+ /**
2
+ * @file A collection of high-level, type-safe utility functions for @doeixd/machine.
3
+ * @description These helpers provide ergonomic improvements for common patterns like
4
+ * state checking, event creation, debugging, and composing transitions.
5
+ */
6
+ import { Machine, AsyncMachine, MaybePromise, Context, Event, Transitions, TransitionArgs } from './index';
7
+ /**
8
+ * A type representing a Class Constructor, used for type guards.
9
+ */
10
+ type ClassConstructor = new (...args: any[]) => any;
11
+ /**
12
+ * A type-safe way to check if a machine is in a specific state, acting as a Type Guard.
13
+ * This is the preferred way to do state checking when using class-based machines.
14
+ *
15
+ * @template T - The class constructor type to check against.
16
+ * @param machine - The machine instance to check.
17
+ * @param machineClass - The class constructor representing the state.
18
+ * @returns {boolean} `true` if the machine is an instance of the class, narrowing its type.
19
+ *
20
+ * @example
21
+ * declare const machine: LoggedInMachine | LoggedOutMachine;
22
+ *
23
+ * if (isState(machine, LoggedInMachine)) {
24
+ * // `machine` is now correctly typed as LoggedInMachine
25
+ * machine.logout();
26
+ * }
27
+ */
28
+ export declare function isState<T extends ClassConstructor>(machine: any, machineClass: T): machine is InstanceType<T>;
29
+ /**
30
+ * A type-safe factory function for creating event objects for `runMachine`.
31
+ * This provides full autocompletion and type checking for event names and their arguments.
32
+ *
33
+ * @template M - The machine type the event belongs to.
34
+ * @template K - The specific event name (transition method name).
35
+ * @param type - The name of the event (e.g., "increment").
36
+ * @param args - The arguments for that event, correctly typed.
37
+ * @returns A type-safe event object ready to be passed to `dispatch`.
38
+ *
39
+ * @example
40
+ * // Given: type MyMachine = Machine<{...}> & { add: (n: number) => any }
41
+ * const event = createEvent<MyMachine, 'add'>('add', 5);
42
+ * // `event` is correctly typed as { type: "add"; args: [number] }
43
+ *
44
+ * await runner.dispatch(event);
45
+ */
46
+ export declare function createEvent<M extends Machine<any>, K extends keyof Transitions<M> & string>(type: K, ...args: TransitionArgs<M, K>): Event<M>;
47
+ /**
48
+ * Creates a new machine instance by shallowly merging a partial context into the
49
+ * current context, preserving all original transitions.
50
+ *
51
+ * @template M - The machine type.
52
+ * @param machine - The original machine instance.
53
+ * @param partialContext - An object with a subset of context properties to update.
54
+ * @returns A new machine instance of the same type with the merged context.
55
+ *
56
+ * @example
57
+ * const user = new User({ name: 'Alex', age: 30, status: 'active' });
58
+ * const updatedUser = mergeContext(user, { status: 'inactive' });
59
+ * // updatedUser.context is { name: 'Alex', age: 30, status: 'inactive' }
60
+ */
61
+ export declare function mergeContext<M extends Machine<any>>(machine: M, partialContext: Partial<Context<M>>): M;
62
+ /**
63
+ * Sequentially applies a series of transitions to a machine.
64
+ * This function correctly handles both synchronous and asynchronous transitions,
65
+ * always returning a Promise with the final machine state.
66
+ *
67
+ * @template M - The machine type, must be compatible with AsyncMachine.
68
+ * @param initialMachine - The starting machine state.
69
+ * @param transitions - An array of functions, each taking a machine and returning the next.
70
+ * @returns A `Promise` that resolves to the final machine state after all transitions complete.
71
+ *
72
+ * @example
73
+ * const finalState = await pipeTransitions(
74
+ * new Counter({ count: 0 }),
75
+ * (m) => m.increment(), // sync
76
+ * (m) => m.addAsync(5), // async
77
+ * (m) => m.increment() // sync
78
+ * );
79
+ * // finalState.context.count will be 6
80
+ */
81
+ export declare function pipeTransitions<M extends AsyncMachine<any>>(initialMachine: M, ...transitions: ((m: M) => MaybePromise<M>)[]): Promise<M>;
82
+ /**
83
+ * A "tap" utility for logging a machine's context without interrupting a chain of operations.
84
+ * It prints the context to the console and returns the machine instance unchanged.
85
+ *
86
+ * @template M - The machine type.
87
+ * @param machine - The machine instance to log.
88
+ * @param label - An optional label to print before the context object.
89
+ * @returns The original, unmodified machine instance.
90
+ *
91
+ * @example
92
+ * import { logState as tap } from './utils';
93
+ *
94
+ * await pipeTransitions(
95
+ * new Counter({ count: 0 }),
96
+ * tap, // Logs: { count: 0 }
97
+ * (m) => m.increment(),
98
+ * (m) => tap(m, 'After increment:') // Logs: After increment: { count: 1 }
99
+ * );
100
+ */
101
+ export declare function logState<M extends Machine<any>>(machine: M, label?: string): M;
102
+ /**
103
+ * Calls a transition function with an explicit `this` context.
104
+ * Useful for invoking transition methods with proper context binding.
105
+ *
106
+ * @template C - The context type that the function expects as `this`.
107
+ * @template F - The function type with a `this` parameter.
108
+ * @template A - The argument types for the function.
109
+ * @param fn - The transition function to call.
110
+ * @param context - The context object to bind as `this`.
111
+ * @param args - Arguments to pass to the function.
112
+ * @returns The result of calling the function with the given context and arguments.
113
+ *
114
+ * @example
115
+ * type MyContext = { count: number };
116
+ * const increment = function(this: MyContext) { return this.count + 1; };
117
+ * const result = call(increment, { count: 5 }); // Returns 6
118
+ *
119
+ * // Particularly useful with machine transitions:
120
+ * import { call } from '@doeixd/machine/utils';
121
+ * const nextMachine = yield* step(call(m.increment, m.context));
122
+ */
123
+ export declare function call<C, F extends (this: C, ...args: any[]) => any>(fn: F, context: C, ...args: Parameters<F> extends [any, ...infer Rest] ? Rest : never): ReturnType<F>;
124
+ /**
125
+ * Binds all transition methods of a machine to its context automatically.
126
+ * Returns a Proxy that intercepts method calls and binds them to `machine.context`.
127
+ * This eliminates the need to use `.call(m.context, ...)` for every transition.
128
+ *
129
+ * Automatically recursively wraps returned machines, enabling seamless chaining
130
+ * in generator-based flows.
131
+ *
132
+ * @template M - The machine type with a `context` property and transition methods.
133
+ * @param machine - The machine instance to wrap.
134
+ * @returns A Proxy of the machine where all callable properties (transitions) are automatically bound to the machine's context.
135
+ *
136
+ * @example
137
+ * type CounterContext = { count: number };
138
+ * const counter = bindTransitions(createMachine({ count: 0 }, {
139
+ * increment(this: CounterContext) { return createCounter(this.count + 1); }
140
+ * }));
141
+ *
142
+ * // Now you can call transitions directly without .call():
143
+ * const next = counter.increment(); // Works! This is automatically bound.
144
+ *
145
+ * // Particularly useful with generators:
146
+ * const result = run(function* (m) {
147
+ * m = yield* step(m.increment()); // Clean syntax
148
+ * m = yield* step(m.add(5)); // No .call() needed
149
+ * return m;
150
+ * }, bindTransitions(counter));
151
+ *
152
+ * @remarks
153
+ * The Proxy preserves all original properties and methods. Non-callable properties
154
+ * are accessed directly from the machine. Callable properties are wrapped to bind
155
+ * them to `machine.context` before invocation. Returned machines are automatically
156
+ * re-wrapped to maintain binding across transition chains.
157
+ */
158
+ export declare function bindTransitions<M extends {
159
+ context: any;
160
+ }>(machine: M): M;
161
+ /**
162
+ * A strongly-typed wrapper class for binding transitions to machine context.
163
+ * Unlike the Proxy-based `bindTransitions`, this class preserves full type safety
164
+ * and provides better IDE support through explicit property forwarding.
165
+ *
166
+ * @template M - The machine type with a `context` property and transition methods.
167
+ *
168
+ * @example
169
+ * type CounterContext = { count: number };
170
+ * const counter = createMachine({ count: 0 }, {
171
+ * increment(this: CounterContext) { return createCounter(this.count + 1); }
172
+ * });
173
+ *
174
+ * const bound = new BoundMachine(counter);
175
+ *
176
+ * // All transitions are automatically bound to context
177
+ * const result = run(function* (m) {
178
+ * m = yield* step(m.increment());
179
+ * m = yield* step(m.add(5));
180
+ * return m.context.count;
181
+ * }, bound);
182
+ *
183
+ * @remarks
184
+ * Advantages over Proxy-based `bindTransitions`:
185
+ * - Full type safety with TypeScript's type system
186
+ * - Returned machines are automatically re-wrapped
187
+ * - Better IDE autocompletion and hover information
188
+ * - No type casting needed
189
+ *
190
+ * Disadvantages:
191
+ * - Requires explicit instance creation: `new BoundMachine(m)` vs `bindTransitions(m)`
192
+ * - Not a transparent drop-in replacement for the original machine
193
+ */
194
+ export declare class BoundMachine<M extends {
195
+ context: any;
196
+ }> {
197
+ private readonly wrappedMachine;
198
+ [key: string | symbol]: any;
199
+ constructor(machine: M);
200
+ }
201
+ /**
202
+ * Creates a sequence machine that orchestrates multi-step flows by automatically
203
+ * advancing through a series of machines. When the current machine reaches a "final"
204
+ * state (determined by the isFinal predicate), the sequence automatically transitions
205
+ * to the next machine in the sequence.
206
+ *
207
+ * This is perfect for wizard-style flows, multi-step processes, or any scenario where
208
+ * you need to chain machines together with automatic progression.
209
+ *
210
+ * @template M - The tuple of machine types in the sequence.
211
+ * @param machines - The machines to sequence, in order.
212
+ * @param isFinal - A predicate function that determines when a machine is in a final state.
213
+ * Called after each transition to check if the sequence should advance.
214
+ * @returns A new machine that wraps the sequence, delegating to the current machine
215
+ * and automatically advancing when each machine reaches its final state.
216
+ *
217
+ * @example
218
+ * ```typescript
219
+ * // Define form machines with final states
220
+ * class NameForm extends MachineBase<{ name: string; valid: boolean }> {
221
+ * submit = (name: string) => new NameForm({ name, valid: name.length > 0 });
222
+ * }
223
+ *
224
+ * class EmailForm extends MachineBase<{ email: string; valid: boolean }> {
225
+ * submit = (email: string) => new EmailForm({ email, valid: email.includes('@') });
226
+ * }
227
+ *
228
+ * class PasswordForm extends MachineBase<{ password: string; valid: boolean }> {
229
+ * submit = (password: string) => new PasswordForm({ password, valid: password.length >= 8 });
230
+ * }
231
+ *
232
+ * // Create sequence that advances when each form becomes valid
233
+ * const wizard = sequence(
234
+ * [new NameForm({ name: '', valid: false }),
235
+ * new EmailForm({ email: '', valid: false }),
236
+ * new PasswordForm({ password: '', valid: false })],
237
+ * (machine) => machine.context.valid // Advance when valid becomes true
238
+ * );
239
+ *
240
+ * // Usage - automatically advances through forms
241
+ * let current = wizard;
242
+ * current = current.submit('John'); // Still on NameForm (not valid yet)
243
+ * current = current.submit('John Doe'); // Advances to EmailForm (name is valid)
244
+ * current = current.submit('john@'); // Still on EmailForm (not valid yet)
245
+ * current = current.submit('john@example.com'); // Advances to PasswordForm
246
+ * current = current.submit('12345678'); // Advances to end of sequence
247
+ * ```
248
+ *
249
+ * @example
250
+ * ```typescript
251
+ * // Async sequence with API calls
252
+ * const authSequence = sequence(
253
+ * [new LoginForm(), new TwoFactorForm(), new Dashboard()],
254
+ * (machine) => machine.context.authenticated === true
255
+ * );
256
+ *
257
+ * // The sequence handles async transitions automatically
258
+ * const finalState = await authSequence.login('user@example.com', 'password');
259
+ * ```
260
+ *
261
+ * @example
262
+ * ```typescript
263
+ * // Complex predicate - advance based on multiple conditions
264
+ * const complexSequence = sequence(
265
+ * [step1Machine, step2Machine, step3Machine],
266
+ * (machine) => {
267
+ * // Advance when all required fields are filled AND validated
268
+ * return machine.context.requiredFields.every(f => f.filled) &&
269
+ * machine.context.validationErrors.length === 0;
270
+ * }
271
+ * );
272
+ * ```
273
+ *
274
+ * @remarks
275
+ * - The sequence maintains the union type of all machines in the sequence
276
+ * - Transitions are delegated to the current machine in the sequence
277
+ * - When a machine reaches a final state, the sequence automatically advances
278
+ * - If the sequence reaches the end, further transitions return the final machine
279
+ * - The isFinal predicate is called after every transition to check advancement
280
+ * - Works with both sync and async machines (returns MaybePromise)
281
+ */
282
+ export declare function sequence<M extends readonly [Machine<any>, ...Machine<any>[]]>(machines: M, isFinal: (machine: M[number]) => boolean): M[number];
283
+ /**
284
+ * Convenience overload for sequencing exactly 2 machines.
285
+ * Provides better type inference and IntelliSense for common 2-step flows.
286
+ *
287
+ * @example
288
+ * ```typescript
289
+ * const flow = sequence2(
290
+ * new LoginForm(),
291
+ * new Dashboard(),
292
+ * (machine) => machine.context.authenticated
293
+ * );
294
+ * ```
295
+ */
296
+ export declare function sequence2<M1 extends Machine<any>, M2 extends Machine<any>>(machine1: M1, machine2: M2, isFinal: (machine: M1 | M2) => boolean): M1 | M2;
297
+ /**
298
+ * Convenience overload for sequencing exactly 3 machines.
299
+ * Provides better type inference and IntelliSense for common 3-step flows.
300
+ *
301
+ * @example
302
+ * ```typescript
303
+ * const wizard = sequence3(
304
+ * new NameForm({ name: '', valid: false }),
305
+ * new EmailForm({ email: '', valid: false }),
306
+ * new PasswordForm({ password: '', valid: false }),
307
+ * (machine) => machine.context.valid
308
+ * );
309
+ * ```
310
+ */
311
+ export declare function sequence3<M1 extends Machine<any>, M2 extends Machine<any>, M3 extends Machine<any>>(machine1: M1, machine2: M2, machine3: M3, isFinal: (machine: M1 | M2 | M3) => boolean): M1 | M2 | M3;
312
+ export {};
313
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,OAAO,EACP,KAAK,EACL,WAAW,EACX,cAAc,EAEf,MAAM,SAAS,CAAC;AAMjB;;GAEG;AACH,KAAK,gBAAgB,GAAG,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;AAEpD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,gBAAgB,EAChD,OAAO,EAAE,GAAG,EACZ,YAAY,EAAE,CAAC,GACd,OAAO,IAAI,YAAY,CAAC,CAAC,CAAC,CAE5B;AAOD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,WAAW,CACzB,CAAC,SAAS,OAAO,CAAC,GAAG,CAAC,EACtB,CAAC,SAAS,MAAM,WAAW,CAAC,CAAC,CAAC,GAAG,MAAM,EACvC,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAElD;AAOD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,OAAO,CAAC,GAAG,CAAC,EACjD,OAAO,EAAE,CAAC,EACV,cAAc,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAClC,CAAC,CAEH;AAOD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,eAAe,CAAC,CAAC,SAAS,YAAY,CAAC,GAAG,CAAC,EAC/D,cAAc,EAAE,CAAC,EACjB,GAAG,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,YAAY,CAAC,CAAC,CA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AAE,CAAC,EAEpD,QAAQ,EAAE,CAAC,EACX,OAAO,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,OAAO,GACvC,CAAC,CAAC,MAAM,CAAC,CAEX;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CACvB,EAAE,SAAS,OAAO,CAAC,GAAG,CAAC,EACvB,EAAE,SAAS,OAAO,CAAC,GAAG,CAAC,EAEvB,QAAQ,EAAE,EAAE,EACZ,QAAQ,EAAE,EAAE,EACZ,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,GAAG,EAAE,KAAK,OAAO,GACrC,EAAE,GAAG,EAAE,CAET;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,SAAS,CACvB,EAAE,SAAS,OAAO,CAAC,GAAG,CAAC,EACvB,EAAE,SAAS,OAAO,CAAC,GAAG,CAAC,EACvB,EAAE,SAAS,OAAO,CAAC,GAAG,CAAC,EAEvB,QAAQ,EAAE,EAAE,EACZ,QAAQ,EAAE,EAAE,EACZ,QAAQ,EAAE,EAAE,EACZ,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,OAAO,GAC1C,EAAE,GAAG,EAAE,GAAG,EAAE,CAEd"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doeixd/machine",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "files": [
5
5
  "dist",
6
6
  "src"
@@ -71,7 +71,7 @@
71
71
  "watch": "pridepack watch",
72
72
  "start": "pridepack start",
73
73
  "dev": "pridepack dev",
74
- "test": "vitest --test",
74
+ "test": "vitest run",
75
75
  "extract": "tsx scripts/extract-statechart.ts --config .statechart.config.ts",
76
76
  "extract:watch": "tsx scripts/extract-statechart.ts --config .statechart.config.ts --watch",
77
77
  "extract:validate": "tsx scripts/extract-statechart.ts --config .statechart.config.ts --validate",