@gravito/flux 1.0.0-beta.2 → 1.0.0-beta.4

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.
Files changed (65) hide show
  1. package/README.zh-TW.md +189 -0
  2. package/assets/flux-branching.svg +84 -0
  3. package/dist/bun.cjs +7 -0
  4. package/dist/bun.cjs.map +1 -0
  5. package/dist/{storage/BunSQLiteStorage.d.ts → bun.d.cts} +8 -5
  6. package/dist/bun.d.ts +72 -5
  7. package/dist/bun.js +2 -2
  8. package/dist/bun.js.map +1 -0
  9. package/dist/chunk-J37UUMLM.js +858 -0
  10. package/dist/chunk-J37UUMLM.js.map +1 -0
  11. package/dist/chunk-RPECIW7O.cjs +858 -0
  12. package/dist/chunk-RPECIW7O.cjs.map +1 -0
  13. package/dist/chunk-SJSPR4ZU.cjs +173 -0
  14. package/dist/chunk-SJSPR4ZU.cjs.map +1 -0
  15. package/dist/{chunk-qjdtqchy.js → chunk-ZAMVC732.js} +35 -7
  16. package/dist/chunk-ZAMVC732.js.map +1 -0
  17. package/dist/index.cjs +121 -0
  18. package/dist/index.cjs.map +1 -0
  19. package/dist/index.d.cts +43 -0
  20. package/dist/index.d.ts +40 -35
  21. package/dist/index.js +102 -460
  22. package/dist/index.js.map +1 -0
  23. package/dist/index.node.cjs +28 -0
  24. package/dist/index.node.cjs.map +1 -0
  25. package/dist/index.node.d.cts +499 -0
  26. package/dist/index.node.d.ts +494 -13
  27. package/dist/index.node.js +28 -0
  28. package/dist/index.node.js.map +1 -0
  29. package/dist/{types.d.ts → types-DvVHBmP6.d.cts} +59 -18
  30. package/dist/types-DvVHBmP6.d.ts +235 -0
  31. package/package.json +25 -21
  32. package/dist/builder/WorkflowBuilder.d.ts +0 -96
  33. package/dist/builder/WorkflowBuilder.d.ts.map +0 -1
  34. package/dist/builder/index.d.ts +0 -2
  35. package/dist/builder/index.d.ts.map +0 -1
  36. package/dist/bun.d.ts.map +0 -1
  37. package/dist/core/ContextManager.d.ts +0 -40
  38. package/dist/core/ContextManager.d.ts.map +0 -1
  39. package/dist/core/StateMachine.d.ts +0 -43
  40. package/dist/core/StateMachine.d.ts.map +0 -1
  41. package/dist/core/StepExecutor.d.ts +0 -34
  42. package/dist/core/StepExecutor.d.ts.map +0 -1
  43. package/dist/core/index.d.ts +0 -4
  44. package/dist/core/index.d.ts.map +0 -1
  45. package/dist/engine/FluxEngine.d.ts +0 -66
  46. package/dist/engine/FluxEngine.d.ts.map +0 -1
  47. package/dist/engine/index.d.ts +0 -2
  48. package/dist/engine/index.d.ts.map +0 -1
  49. package/dist/index.d.ts.map +0 -1
  50. package/dist/index.node.d.ts.map +0 -1
  51. package/dist/logger/FluxLogger.d.ts +0 -40
  52. package/dist/logger/FluxLogger.d.ts.map +0 -1
  53. package/dist/logger/index.d.ts +0 -2
  54. package/dist/logger/index.d.ts.map +0 -1
  55. package/dist/node/index.mjs +0 -619
  56. package/dist/orbit/OrbitFlux.d.ts +0 -107
  57. package/dist/orbit/OrbitFlux.d.ts.map +0 -1
  58. package/dist/orbit/index.d.ts +0 -2
  59. package/dist/orbit/index.d.ts.map +0 -1
  60. package/dist/storage/BunSQLiteStorage.d.ts.map +0 -1
  61. package/dist/storage/MemoryStorage.d.ts +0 -28
  62. package/dist/storage/MemoryStorage.d.ts.map +0 -1
  63. package/dist/storage/index.d.ts +0 -3
  64. package/dist/storage/index.d.ts.map +0 -1
  65. package/dist/types.d.ts.map +0 -1
@@ -8,11 +8,11 @@
8
8
  /**
9
9
  * Workflow execution status
10
10
  */
11
- export type WorkflowStatus = 'pending' | 'running' | 'paused' | 'completed' | 'failed';
11
+ type WorkflowStatus = 'pending' | 'running' | 'paused' | 'completed' | 'failed';
12
12
  /**
13
13
  * Step execution result
14
14
  */
15
- export interface StepResult<T = unknown> {
15
+ interface StepResult<T = unknown> {
16
16
  success: boolean;
17
17
  data?: T;
18
18
  error?: Error;
@@ -21,7 +21,7 @@ export interface StepResult<T = unknown> {
21
21
  /**
22
22
  * Step execution history entry
23
23
  */
24
- export interface StepExecution {
24
+ interface StepExecution {
25
25
  name: string;
26
26
  status: 'pending' | 'running' | 'completed' | 'failed' | 'skipped';
27
27
  startedAt?: Date;
@@ -33,17 +33,17 @@ export interface StepExecution {
33
33
  /**
34
34
  * Step definition
35
35
  */
36
- export interface StepDefinition<TContext = WorkflowContext> {
36
+ interface StepDefinition<TInput = any, TData = any> {
37
37
  /** Step name (unique within workflow) */
38
38
  name: string;
39
39
  /** Step handler function */
40
- handler: (ctx: TContext) => Promise<void> | void;
40
+ handler: (ctx: WorkflowContext<TInput, TData>) => Promise<void> | void;
41
41
  /** Number of retries on failure */
42
42
  retries?: number;
43
43
  /** Timeout in milliseconds */
44
44
  timeout?: number;
45
45
  /** Condition to skip this step */
46
- when?: (ctx: TContext) => boolean;
46
+ when?: (ctx: WorkflowContext<TInput, TData>) => boolean;
47
47
  /** Mark as commit step (always executes even on replay) */
48
48
  commit?: boolean;
49
49
  }
@@ -52,7 +52,7 @@ export interface StepDefinition<TContext = WorkflowContext> {
52
52
  *
53
53
  * Passed to each step handler with accumulated data.
54
54
  */
55
- export interface WorkflowContext<TInput = unknown, TData = Record<string, unknown>> {
55
+ interface WorkflowContext<TInput = unknown, TData = Record<string, unknown>> {
56
56
  /** Unique workflow instance ID */
57
57
  readonly id: string;
58
58
  /** Workflow definition name */
@@ -71,12 +71,12 @@ export interface WorkflowContext<TInput = unknown, TData = Record<string, unknow
71
71
  /**
72
72
  * Serializable workflow state for persistence
73
73
  */
74
- export interface WorkflowState {
74
+ interface WorkflowState<TInput = any, TData = any> {
75
75
  id: string;
76
76
  name: string;
77
77
  status: WorkflowStatus;
78
- input: unknown;
79
- data: Record<string, unknown>;
78
+ input: TInput;
79
+ data: TData;
80
80
  currentStep: number;
81
81
  history: StepExecution[];
82
82
  createdAt: Date;
@@ -87,18 +87,35 @@ export interface WorkflowState {
87
87
  /**
88
88
  * Workflow definition (immutable blueprint)
89
89
  */
90
- export interface WorkflowDefinition<TInput = unknown> {
90
+ interface WorkflowDefinition<TInput = unknown, TData = Record<string, unknown>> {
91
91
  /** Workflow name */
92
92
  name: string;
93
93
  /** Step definitions in order */
94
- steps: StepDefinition[];
94
+ steps: StepDefinition<TInput, TData>[];
95
95
  /** Input schema validator (optional) */
96
96
  validateInput?: (input: unknown) => input is TInput;
97
97
  }
98
+ /**
99
+ * Workflow descriptor (serializable metadata)
100
+ */
101
+ interface WorkflowDescriptor {
102
+ name: string;
103
+ steps: StepDescriptor[];
104
+ }
105
+ /**
106
+ * Step descriptor (serializable metadata)
107
+ */
108
+ interface StepDescriptor {
109
+ name: string;
110
+ commit: boolean;
111
+ retries?: number;
112
+ timeout?: number;
113
+ hasCondition: boolean;
114
+ }
98
115
  /**
99
116
  * Workflow storage adapter interface
100
117
  */
101
- export interface WorkflowStorage {
118
+ interface WorkflowStorage {
102
119
  /**
103
120
  * Save workflow state
104
121
  */
@@ -127,7 +144,7 @@ export interface WorkflowStorage {
127
144
  /**
128
145
  * Workflow filter options
129
146
  */
130
- export interface WorkflowFilter {
147
+ interface WorkflowFilter {
131
148
  name?: string;
132
149
  status?: WorkflowStatus | WorkflowStatus[];
133
150
  limit?: number;
@@ -145,20 +162,43 @@ export interface WorkflowFilter {
145
162
  * })
146
163
  * ```
147
164
  */
148
- export interface FluxLogger {
165
+ interface FluxLogger {
149
166
  debug(message: string, ...args: unknown[]): void;
150
167
  info(message: string, ...args: unknown[]): void;
151
168
  warn(message: string, ...args: unknown[]): void;
152
169
  error(message: string, ...args: unknown[]): void;
153
170
  }
171
+ type FluxTraceEventType = 'workflow:start' | 'workflow:complete' | 'workflow:error' | 'step:start' | 'step:complete' | 'step:error' | 'step:skipped' | 'step:retry';
172
+ interface FluxTraceEvent {
173
+ type: FluxTraceEventType;
174
+ timestamp: number;
175
+ workflowId: string;
176
+ workflowName: string;
177
+ stepName?: string;
178
+ stepIndex?: number;
179
+ commit?: boolean;
180
+ retries?: number;
181
+ maxRetries?: number;
182
+ duration?: number;
183
+ error?: string;
184
+ status?: WorkflowStatus | StepExecution['status'];
185
+ input?: unknown;
186
+ data?: Record<string, unknown>;
187
+ meta?: Record<string, unknown>;
188
+ }
189
+ interface FluxTraceSink {
190
+ emit(event: FluxTraceEvent): void | Promise<void>;
191
+ }
154
192
  /**
155
193
  * Workflow engine configuration
156
194
  */
157
- export interface FluxConfig {
195
+ interface FluxConfig {
158
196
  /** Storage adapter */
159
197
  storage?: WorkflowStorage;
160
198
  /** Logger instance */
161
199
  logger?: FluxLogger;
200
+ /** Trace sink for workflow events */
201
+ trace?: FluxTraceSink;
162
202
  /** Default retry count for steps */
163
203
  defaultRetries?: number;
164
204
  /** Default timeout for steps (ms) */
@@ -177,7 +217,7 @@ export interface FluxConfig {
177
217
  /**
178
218
  * Workflow execution result
179
219
  */
180
- export interface FluxResult<TData = Record<string, unknown>> {
220
+ interface FluxResult<TData = Record<string, unknown>> {
181
221
  /** Workflow instance ID */
182
222
  id: string;
183
223
  /** Final status */
@@ -191,4 +231,5 @@ export interface FluxResult<TData = Record<string, unknown>> {
191
231
  /** Error if failed */
192
232
  error?: Error;
193
233
  }
194
- //# sourceMappingURL=types.d.ts.map
234
+
235
+ export type { FluxConfig as F, StepDefinition as S, WorkflowDefinition as W, FluxLogger as a, FluxResult as b, FluxTraceEvent as c, FluxTraceEventType as d, FluxTraceSink as e, StepDescriptor as f, StepExecution as g, StepResult as h, WorkflowContext as i, WorkflowDescriptor as j, WorkflowFilter as k, WorkflowState as l, WorkflowStatus as m, WorkflowStorage as n };
@@ -0,0 +1,235 @@
1
+ /**
2
+ * @fileoverview Core type definitions for @gravito/flux
3
+ *
4
+ * Platform-agnostic workflow engine types.
5
+ *
6
+ * @module @gravito/flux
7
+ */
8
+ /**
9
+ * Workflow execution status
10
+ */
11
+ type WorkflowStatus = 'pending' | 'running' | 'paused' | 'completed' | 'failed';
12
+ /**
13
+ * Step execution result
14
+ */
15
+ interface StepResult<T = unknown> {
16
+ success: boolean;
17
+ data?: T;
18
+ error?: Error;
19
+ duration: number;
20
+ }
21
+ /**
22
+ * Step execution history entry
23
+ */
24
+ interface StepExecution {
25
+ name: string;
26
+ status: 'pending' | 'running' | 'completed' | 'failed' | 'skipped';
27
+ startedAt?: Date;
28
+ completedAt?: Date;
29
+ duration?: number;
30
+ error?: string;
31
+ retries: number;
32
+ }
33
+ /**
34
+ * Step definition
35
+ */
36
+ interface StepDefinition<TInput = any, TData = any> {
37
+ /** Step name (unique within workflow) */
38
+ name: string;
39
+ /** Step handler function */
40
+ handler: (ctx: WorkflowContext<TInput, TData>) => Promise<void> | void;
41
+ /** Number of retries on failure */
42
+ retries?: number;
43
+ /** Timeout in milliseconds */
44
+ timeout?: number;
45
+ /** Condition to skip this step */
46
+ when?: (ctx: WorkflowContext<TInput, TData>) => boolean;
47
+ /** Mark as commit step (always executes even on replay) */
48
+ commit?: boolean;
49
+ }
50
+ /**
51
+ * Workflow execution context
52
+ *
53
+ * Passed to each step handler with accumulated data.
54
+ */
55
+ interface WorkflowContext<TInput = unknown, TData = Record<string, unknown>> {
56
+ /** Unique workflow instance ID */
57
+ readonly id: string;
58
+ /** Workflow definition name */
59
+ readonly name: string;
60
+ /** Original input data */
61
+ readonly input: TInput;
62
+ /** Accumulated step data (mutable) */
63
+ data: TData;
64
+ /** Current workflow status */
65
+ readonly status: WorkflowStatus;
66
+ /** Current step index */
67
+ readonly currentStep: number;
68
+ /** Step execution history */
69
+ readonly history: StepExecution[];
70
+ }
71
+ /**
72
+ * Serializable workflow state for persistence
73
+ */
74
+ interface WorkflowState<TInput = any, TData = any> {
75
+ id: string;
76
+ name: string;
77
+ status: WorkflowStatus;
78
+ input: TInput;
79
+ data: TData;
80
+ currentStep: number;
81
+ history: StepExecution[];
82
+ createdAt: Date;
83
+ updatedAt: Date;
84
+ completedAt?: Date;
85
+ error?: string;
86
+ }
87
+ /**
88
+ * Workflow definition (immutable blueprint)
89
+ */
90
+ interface WorkflowDefinition<TInput = unknown, TData = Record<string, unknown>> {
91
+ /** Workflow name */
92
+ name: string;
93
+ /** Step definitions in order */
94
+ steps: StepDefinition<TInput, TData>[];
95
+ /** Input schema validator (optional) */
96
+ validateInput?: (input: unknown) => input is TInput;
97
+ }
98
+ /**
99
+ * Workflow descriptor (serializable metadata)
100
+ */
101
+ interface WorkflowDescriptor {
102
+ name: string;
103
+ steps: StepDescriptor[];
104
+ }
105
+ /**
106
+ * Step descriptor (serializable metadata)
107
+ */
108
+ interface StepDescriptor {
109
+ name: string;
110
+ commit: boolean;
111
+ retries?: number;
112
+ timeout?: number;
113
+ hasCondition: boolean;
114
+ }
115
+ /**
116
+ * Workflow storage adapter interface
117
+ */
118
+ interface WorkflowStorage {
119
+ /**
120
+ * Save workflow state
121
+ */
122
+ save(state: WorkflowState): Promise<void>;
123
+ /**
124
+ * Load workflow state by ID
125
+ */
126
+ load(id: string): Promise<WorkflowState | null>;
127
+ /**
128
+ * List workflow states with optional filter
129
+ */
130
+ list(filter?: WorkflowFilter): Promise<WorkflowState[]>;
131
+ /**
132
+ * Delete workflow state
133
+ */
134
+ delete(id: string): Promise<void>;
135
+ /**
136
+ * Initialize storage (create tables, etc.)
137
+ */
138
+ init?(): Promise<void>;
139
+ /**
140
+ * Cleanup storage resources
141
+ */
142
+ close?(): Promise<void>;
143
+ }
144
+ /**
145
+ * Workflow filter options
146
+ */
147
+ interface WorkflowFilter {
148
+ name?: string;
149
+ status?: WorkflowStatus | WorkflowStatus[];
150
+ limit?: number;
151
+ offset?: number;
152
+ }
153
+ /**
154
+ * Logger interface for FluxEngine
155
+ *
156
+ * Implement this to create custom loggers.
157
+ *
158
+ * @example
159
+ * ```typescript
160
+ * const engine = new FluxEngine({
161
+ * logger: new FluxConsoleLogger()
162
+ * })
163
+ * ```
164
+ */
165
+ interface FluxLogger {
166
+ debug(message: string, ...args: unknown[]): void;
167
+ info(message: string, ...args: unknown[]): void;
168
+ warn(message: string, ...args: unknown[]): void;
169
+ error(message: string, ...args: unknown[]): void;
170
+ }
171
+ type FluxTraceEventType = 'workflow:start' | 'workflow:complete' | 'workflow:error' | 'step:start' | 'step:complete' | 'step:error' | 'step:skipped' | 'step:retry';
172
+ interface FluxTraceEvent {
173
+ type: FluxTraceEventType;
174
+ timestamp: number;
175
+ workflowId: string;
176
+ workflowName: string;
177
+ stepName?: string;
178
+ stepIndex?: number;
179
+ commit?: boolean;
180
+ retries?: number;
181
+ maxRetries?: number;
182
+ duration?: number;
183
+ error?: string;
184
+ status?: WorkflowStatus | StepExecution['status'];
185
+ input?: unknown;
186
+ data?: Record<string, unknown>;
187
+ meta?: Record<string, unknown>;
188
+ }
189
+ interface FluxTraceSink {
190
+ emit(event: FluxTraceEvent): void | Promise<void>;
191
+ }
192
+ /**
193
+ * Workflow engine configuration
194
+ */
195
+ interface FluxConfig {
196
+ /** Storage adapter */
197
+ storage?: WorkflowStorage;
198
+ /** Logger instance */
199
+ logger?: FluxLogger;
200
+ /** Trace sink for workflow events */
201
+ trace?: FluxTraceSink;
202
+ /** Default retry count for steps */
203
+ defaultRetries?: number;
204
+ /** Default timeout for steps (ms) */
205
+ defaultTimeout?: number;
206
+ /** Enable parallel execution for independent steps */
207
+ parallel?: boolean;
208
+ /** Event handlers */
209
+ on?: {
210
+ stepStart?: (step: string, ctx: WorkflowContext) => void;
211
+ stepComplete?: (step: string, ctx: WorkflowContext, result: StepResult) => void;
212
+ stepError?: (step: string, ctx: WorkflowContext, error: Error) => void;
213
+ workflowComplete?: (ctx: WorkflowContext) => void;
214
+ workflowError?: (ctx: WorkflowContext, error: Error) => void;
215
+ };
216
+ }
217
+ /**
218
+ * Workflow execution result
219
+ */
220
+ interface FluxResult<TData = Record<string, unknown>> {
221
+ /** Workflow instance ID */
222
+ id: string;
223
+ /** Final status */
224
+ status: WorkflowStatus;
225
+ /** Accumulated data from all steps */
226
+ data: TData;
227
+ /** Step execution history */
228
+ history: StepExecution[];
229
+ /** Total execution duration (ms) */
230
+ duration: number;
231
+ /** Error if failed */
232
+ error?: Error;
233
+ }
234
+
235
+ export type { FluxConfig as F, StepDefinition as S, WorkflowDefinition as W, FluxLogger as a, FluxResult as b, FluxTraceEvent as c, FluxTraceEventType as d, FluxTraceSink as e, StepDescriptor as f, StepExecution as g, StepResult as h, WorkflowContext as i, WorkflowDescriptor as j, WorkflowFilter as k, WorkflowState as l, WorkflowStatus as m, WorkflowStorage as n };
package/package.json CHANGED
@@ -1,30 +1,29 @@
1
1
  {
2
2
  "name": "@gravito/flux",
3
- "version": "1.0.0-beta.2",
3
+ "version": "1.0.0-beta.4",
4
4
  "description": "Platform-agnostic workflow engine for Gravito",
5
5
  "type": "module",
6
- "main": "./dist/node/index.cjs",
7
- "module": "./dist/node/index.mjs",
6
+ "main": "./dist/index.node.cjs",
7
+ "module": "./dist/index.node.js",
8
8
  "types": "./dist/index.d.ts",
9
9
  "exports": {
10
10
  ".": {
11
+ "types": "./dist/index.d.ts",
11
12
  "bun": {
12
- "import": "./dist/index.js",
13
- "types": "./dist/index.d.ts"
13
+ "import": "./dist/index.js"
14
14
  },
15
15
  "node": {
16
- "import": "./dist/node/index.mjs",
17
- "require": "./dist/node/index.cjs",
16
+ "import": "./dist/index.node.js",
17
+ "require": "./dist/index.node.cjs",
18
18
  "types": "./dist/index.node.d.ts"
19
19
  },
20
- "import": "./dist/node/index.mjs",
21
- "require": "./dist/node/index.cjs",
22
- "types": "./dist/index.d.ts"
20
+ "import": "./dist/index.js",
21
+ "require": "./dist/index.cjs"
23
22
  },
24
23
  "./bun": {
24
+ "types": "./dist/bun.d.ts",
25
25
  "bun": {
26
- "import": "./dist/bun.js",
27
- "types": "./dist/bun.d.ts"
26
+ "import": "./dist/bun.js"
28
27
  }
29
28
  }
30
29
  },
@@ -34,29 +33,31 @@
34
33
  "files": [
35
34
  "dist",
36
35
  "README.md",
37
- "README.zh-TW.md",
38
36
  "bin",
39
- "dev"
37
+ "dev",
38
+ "assets"
40
39
  ],
41
40
  "scripts": {
42
- "build": "bun run build.ts",
41
+ "build": "tsup",
43
42
  "dev:viewer": "node ./bin/flux.js dev --trace ./.flux/trace.ndjson --port 4280",
44
- "typecheck": "tsc --noEmit",
45
- "test": "bun test"
43
+ "typecheck": "bun tsc -p tsconfig.json --noEmit --skipLibCheck",
44
+ "test": "bun test",
45
+ "test:coverage": "bun test --coverage --coverage-threshold=80",
46
+ "test:ci": "bun test --coverage --coverage-threshold=80"
46
47
  },
47
48
  "peerDependencies": {
48
- "gravito-core": "1.0.0-beta.6"
49
+ "@gravito/core": "workspace:*"
49
50
  },
50
51
  "peerDependenciesMeta": {
51
- "gravito-core": {
52
+ "@gravito/core": {
52
53
  "optional": true
53
54
  }
54
55
  },
55
56
  "devDependencies": {
56
57
  "bun-types": "latest",
57
- "gravito-core": "1.0.0-beta.6",
58
+ "@gravito/core": "workspace:*",
58
59
  "tsup": "^8.5.1",
59
- "typescript": "^5.0.0"
60
+ "typescript": "^5.9.3"
60
61
  },
61
62
  "keywords": [
62
63
  "gravito",
@@ -72,5 +73,8 @@
72
73
  "type": "git",
73
74
  "url": "https://github.com/gravito-framework/gravito.git",
74
75
  "directory": "packages/flux"
76
+ },
77
+ "publishConfig": {
78
+ "access": "public"
75
79
  }
76
80
  }
@@ -1,96 +0,0 @@
1
- /**
2
- * @fileoverview Workflow Builder - Fluent API for defining workflows
3
- *
4
- * Type-safe, chainable workflow definition.
5
- *
6
- * @module @gravito/flux/builder
7
- */
8
- import type { WorkflowContext, WorkflowDefinition } from '../types';
9
- /**
10
- * Step options
11
- */
12
- interface StepOptions {
13
- retries?: number;
14
- timeout?: number;
15
- when?: (ctx: WorkflowContext) => boolean;
16
- }
17
- /**
18
- * Workflow Builder
19
- *
20
- * Provides fluent API for defining workflows with type inference.
21
- *
22
- * @example
23
- * ```typescript
24
- * const workflow = createWorkflow('order-process')
25
- * .input<{ orderId: string }>()
26
- * .step('validate', async (ctx) => {
27
- * ctx.data.order = await fetchOrder(ctx.input.orderId)
28
- * })
29
- * .step('process', async (ctx) => {
30
- * await processOrder(ctx.data.order)
31
- * })
32
- * .commit('notify', async (ctx) => {
33
- * await sendEmail(ctx.data.order.email)
34
- * })
35
- * ```
36
- */
37
- export declare class WorkflowBuilder<TInput = unknown> {
38
- private _name;
39
- private _steps;
40
- private _validateInput?;
41
- constructor(name: string);
42
- /**
43
- * Define input type
44
- *
45
- * This method is used for TypeScript type inference.
46
- */
47
- input<T>(): WorkflowBuilder<T>;
48
- /**
49
- * Add input validator
50
- */
51
- validate(validator: (input: unknown) => input is TInput): this;
52
- /**
53
- * Add a step to the workflow
54
- */
55
- step(name: string, handler: (ctx: WorkflowContext<TInput>) => Promise<void> | void, options?: StepOptions): this;
56
- /**
57
- * Add a commit step (always executes, even on replay)
58
- *
59
- * Commit steps are for side effects that should not be skipped,
60
- * such as database writes or external API calls.
61
- */
62
- commit(name: string, handler: (ctx: WorkflowContext<TInput>) => Promise<void> | void, options?: StepOptions): this;
63
- /**
64
- * Build the workflow definition
65
- */
66
- build(): WorkflowDefinition<TInput>;
67
- /**
68
- * Get workflow name
69
- */
70
- get name(): string;
71
- /**
72
- * Get step count
73
- */
74
- get stepCount(): number;
75
- }
76
- /**
77
- * Create a new workflow builder
78
- *
79
- * @param name - Unique workflow name
80
- * @returns WorkflowBuilder instance
81
- *
82
- * @example
83
- * ```typescript
84
- * const uploadFlow = createWorkflow('image-upload')
85
- * .input<{ file: Buffer }>()
86
- * .step('resize', async (ctx) => {
87
- * ctx.data.resized = await sharp(ctx.input.file).resize(200).toBuffer()
88
- * })
89
- * .commit('save', async (ctx) => {
90
- * await storage.put(ctx.data.resized)
91
- * })
92
- * ```
93
- */
94
- export declare function createWorkflow(name: string): WorkflowBuilder;
95
- export {};
96
- //# sourceMappingURL=WorkflowBuilder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"WorkflowBuilder.d.ts","sourceRoot":"","sources":["../../src/builder/WorkflowBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAkB,eAAe,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAEnF;;GAEG;AACH,UAAU,WAAW;IACnB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,OAAO,CAAA;CACzC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,eAAe,CAAC,MAAM,GAAG,OAAO;IAC3C,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,cAAc,CAAC,CAAqC;gBAEhD,IAAI,EAAE,MAAM;IAIxB;;;;OAIG;IACH,KAAK,CAAC,CAAC,KAAK,eAAe,CAAC,CAAC,CAAC;IAI9B;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,KAAK,IAAI,MAAM,GAAG,IAAI;IAK9D;;OAEG;IACH,IAAI,CACF,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,CAAC,GAAG,EAAE,eAAe,CAAC,MAAM,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,EAC/D,OAAO,CAAC,EAAE,WAAW,GACpB,IAAI;IAYP;;;;;OAKG;IACH,MAAM,CACJ,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,CAAC,GAAG,EAAE,eAAe,CAAC,MAAM,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,EAC/D,OAAO,CAAC,EAAE,WAAW,GACpB,IAAI;IAYP;;OAEG;IACH,KAAK,IAAI,kBAAkB,CAAC,MAAM,CAAC;IAYnC;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,IAAI,SAAS,IAAI,MAAM,CAEtB;CACF;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAE5D"}
@@ -1,2 +0,0 @@
1
- export { createWorkflow, WorkflowBuilder } from './WorkflowBuilder';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/builder/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA"}
package/dist/bun.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"bun.d.ts","sourceRoot":"","sources":["../src/bun.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,gBAAgB,EAAE,KAAK,uBAAuB,EAAE,MAAM,4BAA4B,CAAA"}
@@ -1,40 +0,0 @@
1
- /**
2
- * @fileoverview Context Manager for workflow execution
3
- *
4
- * Manages workflow context lifecycle and state snapshots.
5
- *
6
- * @module @gravito/flux/core
7
- */
8
- import type { WorkflowContext, WorkflowState, WorkflowStatus } from '../types';
9
- /**
10
- * Context Manager
11
- *
12
- * Creates and manages workflow execution contexts.
13
- */
14
- export declare class ContextManager {
15
- /**
16
- * Create a new workflow context
17
- */
18
- create<TInput>(name: string, input: TInput, stepCount: number): WorkflowContext<TInput>;
19
- /**
20
- * Restore context from saved state
21
- */
22
- restore<TInput>(state: WorkflowState): WorkflowContext<TInput>;
23
- /**
24
- * Convert context to serializable state
25
- */
26
- toState(ctx: WorkflowContext): WorkflowState;
27
- /**
28
- * Update context status (returns new context for immutability)
29
- */
30
- updateStatus(ctx: WorkflowContext, status: WorkflowStatus): WorkflowContext;
31
- /**
32
- * Advance to next step
33
- */
34
- advanceStep(ctx: WorkflowContext): WorkflowContext;
35
- /**
36
- * Update step name in history
37
- */
38
- setStepName(ctx: WorkflowContext, index: number, name: string): void;
39
- }
40
- //# sourceMappingURL=ContextManager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ContextManager.d.ts","sourceRoot":"","sources":["../../src/core/ContextManager.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAiB,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAS7F;;;;GAIG;AACH,qBAAa,cAAc;IACzB;;OAEG;IACH,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC;IAkBvF;;OAEG;IACH,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,aAAa,GAAG,eAAe,CAAC,MAAM,CAAC;IAY9D;;OAEG;IACH,OAAO,CAAC,GAAG,EAAE,eAAe,GAAG,aAAa;IAc5C;;OAEG;IACH,YAAY,CAAC,GAAG,EAAE,eAAe,EAAE,MAAM,EAAE,cAAc,GAAG,eAAe;IAO3E;;OAEG;IACH,WAAW,CAAC,GAAG,EAAE,eAAe,GAAG,eAAe;IAOlD;;OAEG;IACH,WAAW,CAAC,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;CAKrE"}