@doeixd/machine 0.0.13 → 0.0.17
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.
- package/README.md +67 -15
- package/dist/cjs/development/core.js +1852 -0
- package/dist/cjs/development/core.js.map +7 -0
- package/dist/cjs/development/index.js +1341 -1374
- package/dist/cjs/development/index.js.map +4 -4
- package/dist/cjs/production/core.js +1 -0
- package/dist/cjs/production/index.js +5 -5
- package/dist/esm/development/core.js +1829 -0
- package/dist/esm/development/core.js.map +7 -0
- package/dist/esm/development/index.js +1341 -1374
- package/dist/esm/development/index.js.map +4 -4
- package/dist/esm/production/core.js +1 -0
- package/dist/esm/production/index.js +5 -5
- package/dist/types/core.d.ts +18 -0
- package/dist/types/core.d.ts.map +1 -0
- package/dist/types/functional-combinators.d.ts +3 -5
- package/dist/types/functional-combinators.d.ts.map +1 -1
- package/dist/types/index.d.ts +241 -18
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/middleware/composition.d.ts +460 -0
- package/dist/types/middleware/composition.d.ts.map +1 -0
- package/dist/types/middleware/core.d.ts +196 -0
- package/dist/types/middleware/core.d.ts.map +1 -0
- package/dist/types/middleware/history.d.ts +54 -0
- package/dist/types/middleware/history.d.ts.map +1 -0
- package/dist/types/middleware/index.d.ts +10 -0
- package/dist/types/middleware/index.d.ts.map +1 -0
- package/dist/types/middleware/snapshot.d.ts +63 -0
- package/dist/types/middleware/snapshot.d.ts.map +1 -0
- package/dist/types/middleware/time-travel.d.ts +81 -0
- package/dist/types/middleware/time-travel.d.ts.map +1 -0
- package/package.json +19 -6
- package/src/core.ts +167 -0
- package/src/entry-react.ts +9 -0
- package/src/entry-solid.ts +9 -0
- package/src/functional-combinators.ts +3 -3
- package/src/index.ts +374 -101
- package/src/middleware/composition.ts +944 -0
- package/src/middleware/core.ts +573 -0
- package/src/middleware/history.ts +104 -0
- package/src/middleware/index.ts +13 -0
- package/src/middleware/snapshot.ts +153 -0
- package/src/middleware/time-travel.ts +236 -0
- package/src/middleware.ts +735 -1614
- package/src/prototype_functional.ts +46 -0
- package/src/reproduce_issue.ts +26 -0
- package/dist/types/middleware.d.ts +0 -1048
- package/dist/types/middleware.d.ts.map +0 -1
- package/dist/types/runtime-extract.d.ts +0 -53
- package/dist/types/runtime-extract.d.ts.map +0 -1
|
@@ -0,0 +1,460 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Middleware composition and pipeline utilities
|
|
3
|
+
*/
|
|
4
|
+
import type { BaseMachine, Context } from '../index';
|
|
5
|
+
import type { MiddlewareContext, MiddlewareResult, MiddlewareError, MiddlewareHooks, MiddlewareOptions } from './core';
|
|
6
|
+
import { type HistoryEntry, type Serializer } from './history';
|
|
7
|
+
import { type WithTimeTravel, type WithHistory, type WithSnapshot } from './time-travel';
|
|
8
|
+
/**
|
|
9
|
+
* A middleware function that transforms a machine.
|
|
10
|
+
* @template M - The input machine type
|
|
11
|
+
* @template R - The output machine type (usually extends M)
|
|
12
|
+
*/
|
|
13
|
+
export type MiddlewareFn<M extends BaseMachine<any>, R extends BaseMachine<any> = M> = (machine: M) => R;
|
|
14
|
+
/**
|
|
15
|
+
* A conditional middleware that may or may not be applied based on a predicate.
|
|
16
|
+
* @template M - The machine type
|
|
17
|
+
*/
|
|
18
|
+
export type ConditionalMiddleware<M extends BaseMachine<any>> = {
|
|
19
|
+
/** The middleware function to apply */
|
|
20
|
+
middleware: MiddlewareFn<M>;
|
|
21
|
+
/** Predicate function that determines if the middleware should be applied */
|
|
22
|
+
when: (machine: M) => boolean;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* A named middleware entry for registry-based composition.
|
|
26
|
+
* @template M - The machine type
|
|
27
|
+
*/
|
|
28
|
+
export type NamedMiddleware<M extends BaseMachine<any>> = {
|
|
29
|
+
/** Unique name for the middleware */
|
|
30
|
+
name: string;
|
|
31
|
+
/** The middleware function */
|
|
32
|
+
middleware: MiddlewareFn<M>;
|
|
33
|
+
/** Optional description */
|
|
34
|
+
description?: string;
|
|
35
|
+
/** Optional priority for ordering (higher numbers = applied later) */
|
|
36
|
+
priority?: number;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Configuration for middleware pipeline execution.
|
|
40
|
+
*/
|
|
41
|
+
export interface PipelineConfig {
|
|
42
|
+
/** Whether to continue execution if a middleware throws an error */
|
|
43
|
+
continueOnError?: boolean;
|
|
44
|
+
/** Whether to log errors from middlewares */
|
|
45
|
+
logErrors?: boolean;
|
|
46
|
+
/** Custom error handler */
|
|
47
|
+
onError?: (error: Error, middlewareIndex: number, middlewareName?: string) => void;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Result of pipeline execution.
|
|
51
|
+
*/
|
|
52
|
+
export type PipelineResult<M extends BaseMachine<any>> = M;
|
|
53
|
+
/**
|
|
54
|
+
* Type-level utility for composing middleware return types.
|
|
55
|
+
* This enables perfect TypeScript inference when chaining middlewares.
|
|
56
|
+
*/
|
|
57
|
+
export type ComposeResult<M extends BaseMachine<any>, Ms extends readonly MiddlewareFn<any, any>[]> = Ms extends readonly [infer First, ...infer Rest] ? First extends MiddlewareFn<any, infer R> ? Rest extends readonly MiddlewareFn<any, any>[] ? ComposeResult<R, Rest> : R : M : M;
|
|
58
|
+
/**
|
|
59
|
+
* Compose multiple middleware functions into a single middleware stack.
|
|
60
|
+
* Middleware is applied left-to-right (first middleware wraps outermost).
|
|
61
|
+
*
|
|
62
|
+
* @template M - The machine type
|
|
63
|
+
* @param machine - The base machine
|
|
64
|
+
* @param middlewares - Array of middleware functions
|
|
65
|
+
* @returns A new machine with all middleware applied
|
|
66
|
+
*/
|
|
67
|
+
export declare function compose<M extends BaseMachine<any>>(machine: M, ...middlewares: Array<(m: M) => M>): M;
|
|
68
|
+
/**
|
|
69
|
+
* Type-safe middleware composition with perfect inference.
|
|
70
|
+
* Composes multiple middlewares into a single transformation chain.
|
|
71
|
+
*
|
|
72
|
+
* @template M - The input machine type
|
|
73
|
+
* @template Ms - Array of middleware functions
|
|
74
|
+
* @param machine - The machine to enhance
|
|
75
|
+
* @param middlewares - Middleware functions to apply in order
|
|
76
|
+
* @returns The machine with all middlewares applied, with precise type inference
|
|
77
|
+
*/
|
|
78
|
+
export declare function composeTyped<M extends BaseMachine<any>, Ms extends readonly MiddlewareFn<any, any>[]>(machine: M, ...middlewares: Ms): ComposeResult<M, Ms>;
|
|
79
|
+
/**
|
|
80
|
+
* Fluent middleware composer for building complex middleware chains.
|
|
81
|
+
* Provides excellent TypeScript inference and IntelliSense.
|
|
82
|
+
*/
|
|
83
|
+
declare class MiddlewareChainBuilder<M extends BaseMachine<any>> {
|
|
84
|
+
private machine;
|
|
85
|
+
constructor(machine: M);
|
|
86
|
+
/**
|
|
87
|
+
* Add a middleware to the composition chain.
|
|
88
|
+
* @param middleware - The middleware function to add
|
|
89
|
+
* @returns A new composer with the middleware applied
|
|
90
|
+
*/
|
|
91
|
+
with<M2 extends MiddlewareFn<any, any>>(middleware: M2): MiddlewareChainBuilder<ReturnType<M2> extends BaseMachine<any> ? ReturnType<M2> : M>;
|
|
92
|
+
/**
|
|
93
|
+
* Build the final machine with all middlewares applied.
|
|
94
|
+
*/
|
|
95
|
+
build(): M;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Create a fluent middleware chain builder.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* const enhanced = chain(counter)
|
|
103
|
+
* .with(withHistory())
|
|
104
|
+
* .with(withSnapshot())
|
|
105
|
+
* .with(withTimeTravel())
|
|
106
|
+
* .build();
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
export declare function chain<M extends BaseMachine<any>>(machine: M): MiddlewareChainBuilder<M>;
|
|
110
|
+
/**
|
|
111
|
+
* Create a conditional middleware that only applies when a predicate is true.
|
|
112
|
+
*
|
|
113
|
+
* @template M - The machine type
|
|
114
|
+
* @param middleware - The middleware to conditionally apply
|
|
115
|
+
* @param predicate - Function that determines when to apply the middleware
|
|
116
|
+
* @returns A conditional middleware that can be called directly or used in pipelines
|
|
117
|
+
*/
|
|
118
|
+
export declare function when<M extends BaseMachine<any>>(middleware: MiddlewareFn<M>, predicate: (machine: M) => boolean): ConditionalMiddleware<M> & MiddlewareFn<M>;
|
|
119
|
+
/**
|
|
120
|
+
* Create a middleware that only applies in development mode.
|
|
121
|
+
*
|
|
122
|
+
* @template M - The machine type
|
|
123
|
+
* @param middleware - The middleware to apply in development
|
|
124
|
+
* @returns A conditional middleware for development mode
|
|
125
|
+
*/
|
|
126
|
+
export declare function inDevelopment<M extends BaseMachine<any>>(middleware: MiddlewareFn<M>): ConditionalMiddleware<M> & MiddlewareFn<M>;
|
|
127
|
+
/**
|
|
128
|
+
* Create a middleware that only applies when a context property matches a value.
|
|
129
|
+
*
|
|
130
|
+
* @template M - The machine type
|
|
131
|
+
* @template K - The context key
|
|
132
|
+
* @param key - The context property key
|
|
133
|
+
* @param value - The value to match
|
|
134
|
+
* @param middleware - The middleware to apply when the condition matches
|
|
135
|
+
* @returns A conditional middleware
|
|
136
|
+
*/
|
|
137
|
+
export declare function whenContext<M extends BaseMachine<any>, K extends keyof Context<M>>(key: K, value: Context<M>[K], middleware: MiddlewareFn<M>): ConditionalMiddleware<M> & MiddlewareFn<M>;
|
|
138
|
+
/**
|
|
139
|
+
* Create a middleware registry for managing reusable middleware configurations.
|
|
140
|
+
*/
|
|
141
|
+
export declare function createMiddlewareRegistry<M extends BaseMachine<any>>(): {
|
|
142
|
+
/**
|
|
143
|
+
* Register a middleware by name.
|
|
144
|
+
*/
|
|
145
|
+
register(name: string, middleware: MiddlewareFn<M>, description?: string, priority?: number): {
|
|
146
|
+
register(name: string, middleware: MiddlewareFn<M>, description?: string, priority?: number): /*elided*/ any;
|
|
147
|
+
/**
|
|
148
|
+
* Unregister a middleware by name.
|
|
149
|
+
*/
|
|
150
|
+
unregister(name: string): boolean;
|
|
151
|
+
/**
|
|
152
|
+
* Check if a middleware is registered.
|
|
153
|
+
*/
|
|
154
|
+
has(name: string): boolean;
|
|
155
|
+
/**
|
|
156
|
+
* Get a registered middleware by name.
|
|
157
|
+
*/
|
|
158
|
+
get(name: string): NamedMiddleware<M> | undefined;
|
|
159
|
+
/**
|
|
160
|
+
* List all registered middlewares.
|
|
161
|
+
*/
|
|
162
|
+
list(): NamedMiddleware<M>[];
|
|
163
|
+
/**
|
|
164
|
+
* Apply a selection of registered middlewares to a machine.
|
|
165
|
+
* Middlewares are applied in priority order (lowest to highest).
|
|
166
|
+
*/
|
|
167
|
+
apply(machine: M, middlewareNames: string[]): M;
|
|
168
|
+
/**
|
|
169
|
+
* Apply all registered middlewares to a machine in priority order.
|
|
170
|
+
*/
|
|
171
|
+
applyAll(machine: M): M;
|
|
172
|
+
};
|
|
173
|
+
/**
|
|
174
|
+
* Unregister a middleware by name.
|
|
175
|
+
*/
|
|
176
|
+
unregister(name: string): boolean;
|
|
177
|
+
/**
|
|
178
|
+
* Check if a middleware is registered.
|
|
179
|
+
*/
|
|
180
|
+
has(name: string): boolean;
|
|
181
|
+
/**
|
|
182
|
+
* Get a registered middleware by name.
|
|
183
|
+
*/
|
|
184
|
+
get(name: string): NamedMiddleware<M> | undefined;
|
|
185
|
+
/**
|
|
186
|
+
* List all registered middlewares.
|
|
187
|
+
*/
|
|
188
|
+
list(): NamedMiddleware<M>[];
|
|
189
|
+
/**
|
|
190
|
+
* Apply a selection of registered middlewares to a machine.
|
|
191
|
+
* Middlewares are applied in priority order (lowest to highest).
|
|
192
|
+
*/
|
|
193
|
+
apply(machine: M, middlewareNames: string[]): M;
|
|
194
|
+
/**
|
|
195
|
+
* Apply all registered middlewares to a machine in priority order.
|
|
196
|
+
*/
|
|
197
|
+
applyAll(machine: M): M;
|
|
198
|
+
};
|
|
199
|
+
/**
|
|
200
|
+
* Create a middleware pipeline with error handling and conditional execution.
|
|
201
|
+
*
|
|
202
|
+
* @template M - The machine type
|
|
203
|
+
* @param config - Pipeline configuration
|
|
204
|
+
* @returns A function that executes middlewares in a pipeline
|
|
205
|
+
*/
|
|
206
|
+
export declare function createPipeline<M extends BaseMachine<any>>(config?: PipelineConfig): {
|
|
207
|
+
<Ms extends Array<MiddlewareFn<M> | ConditionalMiddleware<M>>>(machine: M, ...middlewares: Ms): {
|
|
208
|
+
machine: M;
|
|
209
|
+
errors: Array<{
|
|
210
|
+
error: Error;
|
|
211
|
+
middlewareIndex: number;
|
|
212
|
+
middlewareName?: string;
|
|
213
|
+
}>;
|
|
214
|
+
success: boolean;
|
|
215
|
+
};
|
|
216
|
+
};
|
|
217
|
+
/**
|
|
218
|
+
* Combine multiple middlewares with short-circuiting.
|
|
219
|
+
*/
|
|
220
|
+
export declare function combine<M extends BaseMachine<any>>(...middlewares: Array<MiddlewareFn<M>>): MiddlewareFn<M>;
|
|
221
|
+
/**
|
|
222
|
+
* Create a middleware that applies different middlewares based on context.
|
|
223
|
+
*/
|
|
224
|
+
export declare function branch<M extends BaseMachine<any>>(branches: Array<[predicate: (machine: M) => boolean, middleware: MiddlewareFn<M>]>, fallback?: MiddlewareFn<M>): MiddlewareFn<M>;
|
|
225
|
+
/**
|
|
226
|
+
* Enhanced type guard to check if a value is a middleware function with better inference.
|
|
227
|
+
*/
|
|
228
|
+
export declare function isMiddlewareFn<M extends BaseMachine<any>, R extends BaseMachine<any> = M>(value: any): value is MiddlewareFn<M, R>;
|
|
229
|
+
/**
|
|
230
|
+
* Enhanced type guard to check if a value is a conditional middleware with better inference.
|
|
231
|
+
*/
|
|
232
|
+
export declare function isConditionalMiddleware<M extends BaseMachine<any>>(value: any): value is ConditionalMiddleware<M>;
|
|
233
|
+
/**
|
|
234
|
+
* Type guard to check if a value is a middleware result with strict type checking.
|
|
235
|
+
*/
|
|
236
|
+
export declare function isMiddlewareResult<C extends object>(value: any, contextType?: C): value is MiddlewareResult<C>;
|
|
237
|
+
/**
|
|
238
|
+
* Type guard to check if a value is middleware context with strict type checking.
|
|
239
|
+
*/
|
|
240
|
+
export declare function isMiddlewareContext<C extends object>(value: any, contextType?: C): value is MiddlewareContext<C>;
|
|
241
|
+
/**
|
|
242
|
+
* Type guard to check if a value is middleware error with strict type checking.
|
|
243
|
+
*/
|
|
244
|
+
export declare function isMiddlewareError<C extends object>(value: any, contextType?: C): value is MiddlewareError<C>;
|
|
245
|
+
/**
|
|
246
|
+
* Type guard to check if a value is middleware hooks with strict type checking.
|
|
247
|
+
*/
|
|
248
|
+
export declare function isMiddlewareHooks<C extends object>(value: any, _contextType?: C): value is MiddlewareHooks<C>;
|
|
249
|
+
/**
|
|
250
|
+
* Type guard to check if a value is middleware options with strict type checking.
|
|
251
|
+
*/
|
|
252
|
+
export declare function isMiddlewareOptions(value: any): value is MiddlewareOptions;
|
|
253
|
+
/**
|
|
254
|
+
* Type guard to check if a value is a named middleware with strict type checking.
|
|
255
|
+
*/
|
|
256
|
+
export declare function isNamedMiddleware<M extends BaseMachine<any>>(value: any): value is NamedMiddleware<M>;
|
|
257
|
+
/**
|
|
258
|
+
* Type guard to check if a value is pipeline config with strict type checking.
|
|
259
|
+
*/
|
|
260
|
+
export declare function isPipelineConfig(value: any): value is PipelineConfig;
|
|
261
|
+
/**
|
|
262
|
+
* Configuration for logging middleware.
|
|
263
|
+
*/
|
|
264
|
+
export interface LoggingOptions {
|
|
265
|
+
logger?: (message: string) => void;
|
|
266
|
+
includeArgs?: boolean;
|
|
267
|
+
includeContext?: boolean;
|
|
268
|
+
logLevel?: 'debug' | 'info' | 'warn' | 'error';
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Configuration for analytics middleware.
|
|
272
|
+
*/
|
|
273
|
+
export interface AnalyticsOptions {
|
|
274
|
+
eventPrefix?: string;
|
|
275
|
+
includePrevContext?: boolean;
|
|
276
|
+
includeArgs?: boolean;
|
|
277
|
+
includeTiming?: boolean;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Configuration for validation middleware.
|
|
281
|
+
*/
|
|
282
|
+
export interface ValidationOptions {
|
|
283
|
+
throwOnFailure?: boolean;
|
|
284
|
+
logFailures?: boolean;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Configuration for error reporting middleware.
|
|
288
|
+
*/
|
|
289
|
+
export interface ErrorReportingOptions {
|
|
290
|
+
includeArgs?: boolean;
|
|
291
|
+
includeStackTrace?: boolean;
|
|
292
|
+
reportTo?: string[];
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Configuration for performance monitoring middleware.
|
|
296
|
+
*/
|
|
297
|
+
export interface PerformanceOptions {
|
|
298
|
+
includeArgs?: boolean;
|
|
299
|
+
includeContext?: boolean;
|
|
300
|
+
warnThreshold?: number;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Configuration for retry middleware.
|
|
304
|
+
*/
|
|
305
|
+
export interface RetryOptions {
|
|
306
|
+
maxAttempts?: number;
|
|
307
|
+
maxRetries?: number;
|
|
308
|
+
shouldRetry?: (error: Error, attempt: number) => boolean;
|
|
309
|
+
backoffMs?: number | ((attempt: number) => number);
|
|
310
|
+
delay?: number | ((attempt: number) => number);
|
|
311
|
+
backoffMultiplier?: number;
|
|
312
|
+
onRetry?: (error: Error, attempt: number) => void;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Configuration for history middleware.
|
|
316
|
+
*/
|
|
317
|
+
export interface HistoryOptions {
|
|
318
|
+
maxSize?: number;
|
|
319
|
+
serializer?: Serializer<any[]>;
|
|
320
|
+
onEntry?: (entry: HistoryEntry) => void;
|
|
321
|
+
includeTimestamps?: boolean;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Configuration for snapshot middleware.
|
|
325
|
+
*/
|
|
326
|
+
export interface SnapshotOptions {
|
|
327
|
+
maxSize?: number;
|
|
328
|
+
serializer?: Serializer<Context<any>>;
|
|
329
|
+
captureSnapshot?: (before: Context<any>, after: Context<any>) => any;
|
|
330
|
+
onlyOnChange?: boolean;
|
|
331
|
+
includeDiff?: boolean;
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Configuration for time travel middleware.
|
|
335
|
+
*/
|
|
336
|
+
export interface TimeTravelOptions {
|
|
337
|
+
maxSize?: number;
|
|
338
|
+
serializer?: Serializer;
|
|
339
|
+
onRecord?: (type: 'history' | 'snapshot', data: any) => void;
|
|
340
|
+
enableReplay?: boolean;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Generic middleware builder with perfect TypeScript inference.
|
|
344
|
+
* Provides a fluent API for configuring and applying middleware.
|
|
345
|
+
*/
|
|
346
|
+
export declare class MiddlewareBuilder<M extends BaseMachine<any>> {
|
|
347
|
+
private machine;
|
|
348
|
+
private middlewares;
|
|
349
|
+
constructor(machine: M);
|
|
350
|
+
/**
|
|
351
|
+
* Add logging middleware with type-safe configuration.
|
|
352
|
+
*/
|
|
353
|
+
withLogging(options?: LoggingOptions): MiddlewareBuilder<M>;
|
|
354
|
+
/**
|
|
355
|
+
* Add analytics middleware with type-safe configuration.
|
|
356
|
+
*/
|
|
357
|
+
withAnalytics(track: (event: string, data?: any) => void, options?: AnalyticsOptions): MiddlewareBuilder<M>;
|
|
358
|
+
/**
|
|
359
|
+
* Add validation middleware with type-safe configuration.
|
|
360
|
+
*/
|
|
361
|
+
withValidation(validator: (ctx: MiddlewareContext<Context<M>>) => boolean | void, _options?: ValidationOptions): MiddlewareBuilder<M>;
|
|
362
|
+
/**
|
|
363
|
+
* Add permission checking middleware with type-safe configuration.
|
|
364
|
+
*/
|
|
365
|
+
withPermissions(checker: (ctx: MiddlewareContext<Context<M>>) => boolean): MiddlewareBuilder<M>;
|
|
366
|
+
/**
|
|
367
|
+
* Add error reporting middleware with type-safe configuration.
|
|
368
|
+
*/
|
|
369
|
+
withErrorReporting(reporter: (error: Error, ctx: MiddlewareError<Context<M>>) => void, options?: ErrorReportingOptions): MiddlewareBuilder<M>;
|
|
370
|
+
/**
|
|
371
|
+
* Add performance monitoring middleware with type-safe configuration.
|
|
372
|
+
*/
|
|
373
|
+
withPerformanceMonitoring(tracker: (metric: {
|
|
374
|
+
transitionName: string;
|
|
375
|
+
duration: number;
|
|
376
|
+
context: Context<M>;
|
|
377
|
+
}) => void, _options?: PerformanceOptions): MiddlewareBuilder<M>;
|
|
378
|
+
/**
|
|
379
|
+
* Add retry middleware with type-safe configuration.
|
|
380
|
+
*/
|
|
381
|
+
withRetry(options?: RetryOptions): MiddlewareBuilder<M>;
|
|
382
|
+
/**
|
|
383
|
+
* Add history tracking middleware with type-safe configuration.
|
|
384
|
+
*/
|
|
385
|
+
withHistory(options?: HistoryOptions): MiddlewareBuilder<WithHistory<M>>;
|
|
386
|
+
/**
|
|
387
|
+
* Add snapshot tracking middleware with type-safe configuration.
|
|
388
|
+
*/
|
|
389
|
+
withSnapshot(options?: SnapshotOptions): MiddlewareBuilder<WithSnapshot<M>>;
|
|
390
|
+
/**
|
|
391
|
+
* Add time travel middleware with type-safe configuration.
|
|
392
|
+
*/
|
|
393
|
+
withTimeTravel(options?: TimeTravelOptions): MiddlewareBuilder<WithTimeTravel<M>>;
|
|
394
|
+
/**
|
|
395
|
+
* Add debugging middleware (combination of history, snapshot, and time travel).
|
|
396
|
+
*/
|
|
397
|
+
withDebugging(): MiddlewareBuilder<WithDebugging<M>>;
|
|
398
|
+
/**
|
|
399
|
+
* Add a custom middleware function.
|
|
400
|
+
*/
|
|
401
|
+
withCustom<R extends BaseMachine<any> = M>(middleware: MiddlewareFn<M, R>): MiddlewareBuilder<R>;
|
|
402
|
+
/**
|
|
403
|
+
* Add a conditional middleware.
|
|
404
|
+
*/
|
|
405
|
+
withConditional(middleware: MiddlewareFn<M>, predicate: (machine: M) => boolean): MiddlewareBuilder<M>;
|
|
406
|
+
/**
|
|
407
|
+
* Build the final machine with all configured middleware applied.
|
|
408
|
+
*/
|
|
409
|
+
build(): M;
|
|
410
|
+
/**
|
|
411
|
+
* Get the middleware chain without building (for inspection or further composition).
|
|
412
|
+
*/
|
|
413
|
+
getChain(): Array<(machine: any) => any>;
|
|
414
|
+
/**
|
|
415
|
+
* Clear all configured middleware.
|
|
416
|
+
*/
|
|
417
|
+
clear(): MiddlewareBuilder<M>;
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Create a typed middleware builder for a machine.
|
|
421
|
+
* Provides perfect TypeScript inference for middleware configuration.
|
|
422
|
+
*
|
|
423
|
+
* @example
|
|
424
|
+
* ```typescript
|
|
425
|
+
* const enhancedMachine = middlewareBuilder(myMachine)
|
|
426
|
+
* .withLogging({ includeArgs: true })
|
|
427
|
+
* .withAnalytics(trackEvent)
|
|
428
|
+
* .withHistory({ maxSize: 100 })
|
|
429
|
+
* .withRetry({ maxAttempts: 3 })
|
|
430
|
+
* .build();
|
|
431
|
+
* ```
|
|
432
|
+
*/
|
|
433
|
+
export declare function middlewareBuilder<M extends BaseMachine<any>>(machine: M): MiddlewareBuilder<M>;
|
|
434
|
+
/**
|
|
435
|
+
* Create a middleware factory function with pre-configured options.
|
|
436
|
+
* Useful for creating reusable middleware configurations.
|
|
437
|
+
*/
|
|
438
|
+
export declare function createMiddlewareFactory<M extends BaseMachine<any>>(defaultOptions?: {
|
|
439
|
+
logging?: LoggingOptions;
|
|
440
|
+
analytics?: {
|
|
441
|
+
track: (event: string, data?: any) => void;
|
|
442
|
+
options?: AnalyticsOptions;
|
|
443
|
+
};
|
|
444
|
+
history?: HistoryOptions;
|
|
445
|
+
snapshot?: SnapshotOptions;
|
|
446
|
+
timeTravel?: TimeTravelOptions;
|
|
447
|
+
retry?: RetryOptions;
|
|
448
|
+
}): {
|
|
449
|
+
create: (machine: M) => MiddlewareBuilder<M>;
|
|
450
|
+
};
|
|
451
|
+
/**
|
|
452
|
+
* Common middleware combination types for better DX.
|
|
453
|
+
*/
|
|
454
|
+
export type WithDebugging<M extends BaseMachine<any>> = WithTimeTravel<WithSnapshot<WithHistory<M>>>;
|
|
455
|
+
/**
|
|
456
|
+
* Convenience function for the most common debugging middleware stack.
|
|
457
|
+
*/
|
|
458
|
+
export declare function withDebugging<M extends BaseMachine<any>>(machine: M): WithDebugging<M>;
|
|
459
|
+
export {};
|
|
460
|
+
//# sourceMappingURL=composition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composition.d.ts","sourceRoot":"","sources":["../../../src/middleware/composition.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,iBAAiB,EAClB,MAAM,QAAQ,CAAC;AAUhB,OAAO,EAAe,KAAK,YAAY,EAAE,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5E,OAAO,EAAkB,KAAK,cAAc,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAMzG;;;;GAIG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;AAEzG;;;GAGG;AACH,MAAM,MAAM,qBAAqB,CAAC,CAAC,SAAS,WAAW,CAAC,GAAG,CAAC,IAAI;IAC9D,uCAAuC;IACvC,UAAU,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;IAC5B,6EAA6E;IAC7E,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,OAAO,CAAC;CAC/B,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,WAAW,CAAC,GAAG,CAAC,IAAI;IACxD,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,8BAA8B;IAC9B,UAAU,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;IAC5B,2BAA2B;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC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AAa,CAAC,CAAC,CAAC,CAEtF"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Core middleware types and basic middleware creation
|
|
3
|
+
*/
|
|
4
|
+
import type { Context, BaseMachine } from '../index';
|
|
5
|
+
/**
|
|
6
|
+
* Context object passed to middleware hooks containing transition metadata.
|
|
7
|
+
* @template C - The context object type
|
|
8
|
+
*/
|
|
9
|
+
export interface MiddlewareContext<C extends object> {
|
|
10
|
+
/** The name of the transition being called */
|
|
11
|
+
transitionName: string;
|
|
12
|
+
/** The current machine context before the transition */
|
|
13
|
+
context: Readonly<C>;
|
|
14
|
+
/** Arguments passed to the transition function */
|
|
15
|
+
args: any[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Result object passed to after hooks containing transition outcome.
|
|
19
|
+
* @template C - The context object type
|
|
20
|
+
*/
|
|
21
|
+
export interface MiddlewareResult<C extends object> {
|
|
22
|
+
/** The name of the transition that was called */
|
|
23
|
+
transitionName: string;
|
|
24
|
+
/** The context before the transition */
|
|
25
|
+
prevContext: Readonly<C>;
|
|
26
|
+
/** The context after the transition */
|
|
27
|
+
nextContext: Readonly<C>;
|
|
28
|
+
/** Arguments that were passed to the transition */
|
|
29
|
+
args: any[];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Error context passed to error hooks.
|
|
33
|
+
* @template C - The context object type
|
|
34
|
+
*/
|
|
35
|
+
export interface MiddlewareError<C extends object> {
|
|
36
|
+
/** The name of the transition that failed */
|
|
37
|
+
transitionName: string;
|
|
38
|
+
/** The context when the error occurred */
|
|
39
|
+
context: Readonly<C>;
|
|
40
|
+
/** Arguments that were passed to the transition */
|
|
41
|
+
args: any[];
|
|
42
|
+
/** The error that was thrown */
|
|
43
|
+
error: Error;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Configuration object for middleware hooks.
|
|
47
|
+
* All hooks are optional - provide only the ones you need.
|
|
48
|
+
* @template C - The context object type
|
|
49
|
+
*/
|
|
50
|
+
export interface MiddlewareHooks<C extends object> {
|
|
51
|
+
/**
|
|
52
|
+
* Called before a transition executes.
|
|
53
|
+
* Can be used for validation, logging, analytics, etc.
|
|
54
|
+
*
|
|
55
|
+
* @param ctx - Transition context with machine state and transition details
|
|
56
|
+
* @returns void to continue, CANCEL to abort silently, or Promise for async validation
|
|
57
|
+
*/
|
|
58
|
+
before?: (ctx: MiddlewareContext<C>) => void | typeof CANCEL | Promise<void | typeof CANCEL>;
|
|
59
|
+
/**
|
|
60
|
+
* Called after a transition successfully executes.
|
|
61
|
+
* Receives both the previous and next context.
|
|
62
|
+
* Cannot prevent the transition (it already happened).
|
|
63
|
+
*
|
|
64
|
+
* @param result - Transition result with before/after contexts and transition details
|
|
65
|
+
*/
|
|
66
|
+
after?: (result: MiddlewareResult<C>) => void | Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Called when a transition throws an error.
|
|
69
|
+
* Can be used for error reporting, recovery, etc.
|
|
70
|
+
*
|
|
71
|
+
* @param error - Error context with transition details and error information
|
|
72
|
+
*/
|
|
73
|
+
error?: (error: MiddlewareError<C>) => void | Promise<void>;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Options for configuring middleware behavior.
|
|
77
|
+
*/
|
|
78
|
+
export interface MiddlewareOptions {
|
|
79
|
+
/** Whether to continue execution if a hook throws an error */
|
|
80
|
+
continueOnError?: boolean;
|
|
81
|
+
/** Whether to log errors from hooks */
|
|
82
|
+
logErrors?: boolean;
|
|
83
|
+
/** Custom error handler for hook errors */
|
|
84
|
+
onError?: (error: Error, hookName: string, ctx: any) => void;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Symbol used to cancel a transition from a before hook.
|
|
88
|
+
*/
|
|
89
|
+
export declare const CANCEL: unique symbol;
|
|
90
|
+
/**
|
|
91
|
+
* Creates a middleware function that wraps machine transitions with hooks.
|
|
92
|
+
*
|
|
93
|
+
* @template M - The machine type
|
|
94
|
+
* @param machine - The machine to instrument
|
|
95
|
+
* @param hooks - Middleware hooks to execute
|
|
96
|
+
* @param options - Middleware configuration options
|
|
97
|
+
* @returns A new machine with middleware applied
|
|
98
|
+
*/
|
|
99
|
+
export declare function createMiddleware<M extends BaseMachine<any>>(machine: M, hooks: MiddlewareHooks<Context<M>>, options?: MiddlewareOptions): M;
|
|
100
|
+
/**
|
|
101
|
+
* Creates a simple logging middleware that logs all transitions.
|
|
102
|
+
*
|
|
103
|
+
* @template M - The machine type
|
|
104
|
+
* @param machine - The machine to add logging to
|
|
105
|
+
* @param options - Logging configuration options
|
|
106
|
+
* @returns A new machine with logging middleware
|
|
107
|
+
*/
|
|
108
|
+
export declare function withLogging<M extends BaseMachine<any>>(machine: M, options?: {
|
|
109
|
+
logger?: (message: string) => void;
|
|
110
|
+
includeArgs?: boolean;
|
|
111
|
+
includeContext?: boolean;
|
|
112
|
+
}): M;
|
|
113
|
+
/**
|
|
114
|
+
* Creates analytics tracking middleware.
|
|
115
|
+
*
|
|
116
|
+
* @template M - The machine type
|
|
117
|
+
* @param machine - The machine to track
|
|
118
|
+
* @param track - Analytics tracking function
|
|
119
|
+
* @param options - Configuration options
|
|
120
|
+
* @returns A new machine with analytics tracking
|
|
121
|
+
*/
|
|
122
|
+
export declare function withAnalytics<M extends BaseMachine<any>>(machine: M, track: (event: string, data?: any) => void, options?: {
|
|
123
|
+
eventPrefix?: string;
|
|
124
|
+
includePrevContext?: boolean;
|
|
125
|
+
includeArgs?: boolean;
|
|
126
|
+
}): M;
|
|
127
|
+
/**
|
|
128
|
+
* Creates validation middleware that runs before transitions.
|
|
129
|
+
*
|
|
130
|
+
* @template M - The machine type
|
|
131
|
+
* @param machine - The machine to validate
|
|
132
|
+
* @param validator - Validation function
|
|
133
|
+
* @returns A new machine with validation
|
|
134
|
+
*/
|
|
135
|
+
export declare function withValidation<M extends BaseMachine<any>>(machine: M, validator: (ctx: MiddlewareContext<Context<M>>) => boolean | void): M;
|
|
136
|
+
/**
|
|
137
|
+
* Creates permission-checking middleware.
|
|
138
|
+
*
|
|
139
|
+
* @template M - The machine type
|
|
140
|
+
* @param machine - The machine to protect
|
|
141
|
+
* @param checker - Permission checking function
|
|
142
|
+
* @returns A new machine with permission checks
|
|
143
|
+
*/
|
|
144
|
+
export declare function withPermissions<M extends BaseMachine<any>>(machine: M, checker: (ctx: MiddlewareContext<Context<M>>) => boolean): M;
|
|
145
|
+
/**
|
|
146
|
+
* Creates error reporting middleware.
|
|
147
|
+
*
|
|
148
|
+
* @template M - The machine type
|
|
149
|
+
* @param machine - The machine to monitor
|
|
150
|
+
* @param reporter - Error reporting function
|
|
151
|
+
* @param options - Configuration options
|
|
152
|
+
* @returns A new machine with error reporting
|
|
153
|
+
*/
|
|
154
|
+
export declare function withErrorReporting<M extends BaseMachine<any>>(machine: M, reporter: (error: Error, ctx: any) => void, options?: {
|
|
155
|
+
includeArgs?: boolean;
|
|
156
|
+
}): M;
|
|
157
|
+
/**
|
|
158
|
+
* Creates performance monitoring middleware.
|
|
159
|
+
*
|
|
160
|
+
* @template M - The machine type
|
|
161
|
+
* @param machine - The machine to monitor
|
|
162
|
+
* @param tracker - Performance tracking function
|
|
163
|
+
* @returns A new machine with performance monitoring
|
|
164
|
+
*/
|
|
165
|
+
export declare function withPerformanceMonitoring<M extends BaseMachine<any>>(machine: M, tracker: (metric: {
|
|
166
|
+
transitionName: string;
|
|
167
|
+
duration: number;
|
|
168
|
+
context: Context<M>;
|
|
169
|
+
}) => void): M;
|
|
170
|
+
/**
|
|
171
|
+
* Creates retry middleware for failed transitions.
|
|
172
|
+
*
|
|
173
|
+
* @template M - The machine type
|
|
174
|
+
* @param machine - The machine to add retry logic to
|
|
175
|
+
* @param options - Retry configuration
|
|
176
|
+
* @returns A new machine with retry logic
|
|
177
|
+
*/
|
|
178
|
+
export declare function withRetry<M extends BaseMachine<any>>(machine: M, options?: {
|
|
179
|
+
maxAttempts?: number;
|
|
180
|
+
maxRetries?: number;
|
|
181
|
+
shouldRetry?: (error: Error, attempt: number) => boolean;
|
|
182
|
+
backoffMs?: number | ((attempt: number) => number);
|
|
183
|
+
delay?: number | ((attempt: number) => number);
|
|
184
|
+
backoffMultiplier?: number;
|
|
185
|
+
onRetry?: (error: Error, attempt: number) => void;
|
|
186
|
+
}): M;
|
|
187
|
+
/**
|
|
188
|
+
* Creates custom middleware from hooks.
|
|
189
|
+
*
|
|
190
|
+
* @template M - The machine type
|
|
191
|
+
* @param hooks - Middleware hooks
|
|
192
|
+
* @param options - Middleware options
|
|
193
|
+
* @returns A middleware function
|
|
194
|
+
*/
|
|
195
|
+
export declare function createCustomMiddleware<M extends BaseMachine<any>>(hooks: MiddlewareHooks<Context<M>>, options?: MiddlewareOptions): (machine: M) => M;
|
|
196
|
+
//# sourceMappingURL=core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../src/middleware/core.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAMrD;;;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,eA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