@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
@@ -1,43 +0,0 @@
1
- /**
2
- * @fileoverview State Machine for workflow status transitions
3
- *
4
- * Pure state machine with no runtime dependencies.
5
- *
6
- * @module @gravito/flux/core
7
- */
8
- import type { WorkflowStatus } from '../types';
9
- /**
10
- * State Machine for workflow status management
11
- *
12
- * Provides validated state transitions using EventTarget for events.
13
- */
14
- export declare class StateMachine extends EventTarget {
15
- private _status;
16
- /**
17
- * Current status
18
- */
19
- get status(): WorkflowStatus;
20
- /**
21
- * Check if transition to target status is allowed
22
- */
23
- canTransition(to: WorkflowStatus): boolean;
24
- /**
25
- * Transition to a new status
26
- *
27
- * @throws {Error} If transition is not allowed
28
- */
29
- transition(to: WorkflowStatus): void;
30
- /**
31
- * Force set status (for replay/restore)
32
- */
33
- forceStatus(status: WorkflowStatus): void;
34
- /**
35
- * Check if workflow is in terminal state
36
- */
37
- isTerminal(): boolean;
38
- /**
39
- * Check if workflow can be executed
40
- */
41
- canExecute(): boolean;
42
- }
43
- //# sourceMappingURL=StateMachine.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"StateMachine.d.ts","sourceRoot":"","sources":["../../src/core/StateMachine.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAa9C;;;;GAIG;AACH,qBAAa,YAAa,SAAQ,WAAW;IAC3C,OAAO,CAAC,OAAO,CAA4B;IAE3C;;OAEG;IACH,IAAI,MAAM,IAAI,cAAc,CAE3B;IAED;;OAEG;IACH,aAAa,CAAC,EAAE,EAAE,cAAc,GAAG,OAAO;IAI1C;;;;OAIG;IACH,UAAU,CAAC,EAAE,EAAE,cAAc,GAAG,IAAI;IAgBpC;;OAEG;IACH,WAAW,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI;IAIzC;;OAEG;IACH,UAAU,IAAI,OAAO;IAIrB;;OAEG;IACH,UAAU,IAAI,OAAO;CAGtB"}
@@ -1,34 +0,0 @@
1
- /**
2
- * @fileoverview Step Executor for workflow steps
3
- *
4
- * Handles step execution with retry and timeout support.
5
- *
6
- * @module @gravito/flux/core
7
- */
8
- import type { StepDefinition, StepExecution, StepResult, WorkflowContext } from '../types';
9
- /**
10
- * Step Executor
11
- *
12
- * Executes individual workflow steps with retry and timeout support.
13
- */
14
- export declare class StepExecutor {
15
- private defaultRetries;
16
- private defaultTimeout;
17
- constructor(options?: {
18
- defaultRetries?: number;
19
- defaultTimeout?: number;
20
- });
21
- /**
22
- * Execute a step with retry and timeout
23
- */
24
- execute(step: StepDefinition, ctx: WorkflowContext, execution: StepExecution): Promise<StepResult>;
25
- /**
26
- * Execute handler with timeout
27
- */
28
- private executeWithTimeout;
29
- /**
30
- * Sleep helper
31
- */
32
- private sleep;
33
- }
34
- //# sourceMappingURL=StepExecutor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"StepExecutor.d.ts","sourceRoot":"","sources":["../../src/core/StepExecutor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE1F;;;;GAIG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,cAAc,CAAQ;IAC9B,OAAO,CAAC,cAAc,CAAQ;gBAElB,OAAO,GAAE;QAAE,cAAc,CAAC,EAAE,MAAM,CAAC;QAAC,cAAc,CAAC,EAAE,MAAM,CAAA;KAAO;IAK9E;;OAEG;IACG,OAAO,CACX,IAAI,EAAE,cAAc,EACpB,GAAG,EAAE,eAAe,EACpB,SAAS,EAAE,aAAa,GACvB,OAAO,CAAC,UAAU,CAAC;IA0DtB;;OAEG;YACW,kBAAkB;IAYhC;;OAEG;IACH,OAAO,CAAC,KAAK;CAGd"}
@@ -1,4 +0,0 @@
1
- export { ContextManager } from './ContextManager';
2
- export { StateMachine } from './StateMachine';
3
- export { StepExecutor } from './StepExecutor';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA"}
@@ -1,66 +0,0 @@
1
- /**
2
- * @fileoverview Flux Engine - Main workflow execution engine
3
- *
4
- * Orchestrates workflow execution with storage and event handling.
5
- *
6
- * @module @gravito/flux
7
- */
8
- import { WorkflowBuilder } from '../builder/WorkflowBuilder';
9
- import type { FluxConfig, FluxResult, WorkflowDefinition, WorkflowStorage } from '../types';
10
- /**
11
- * Flux Engine
12
- *
13
- * Main workflow execution engine.
14
- *
15
- * @example
16
- * ```typescript
17
- * const engine = new FluxEngine({ storage: new MemoryStorage() })
18
- *
19
- * const workflow = createWorkflow('process-order')
20
- * .input<{ orderId: string }>()
21
- * .step('fetch', async (ctx) => { ... })
22
- * .step('validate', async (ctx) => { ... })
23
- * .commit('save', async (ctx) => { ... })
24
- *
25
- * const result = await engine.execute(workflow, { orderId: '123' })
26
- * ```
27
- */
28
- export declare class FluxEngine {
29
- private storage;
30
- private executor;
31
- private contextManager;
32
- private config;
33
- constructor(config?: FluxConfig);
34
- /**
35
- * Execute a workflow with input data
36
- *
37
- * @param workflow - Workflow builder or definition
38
- * @param input - Input data for the workflow
39
- * @returns Execution result
40
- */
41
- execute<TInput, TData = Record<string, unknown>>(workflow: WorkflowBuilder<TInput> | WorkflowDefinition<TInput>, input: TInput): Promise<FluxResult<TData>>;
42
- /**
43
- * Resume a paused or failed workflow
44
- *
45
- * @param workflowId - Workflow instance ID
46
- * @returns Execution result or null if not found
47
- */
48
- resume<TData = Record<string, unknown>>(workflowId: string): Promise<FluxResult<TData> | null>;
49
- /**
50
- * Get workflow state by ID
51
- */
52
- get(workflowId: string): Promise<import("..").WorkflowState | null>;
53
- /**
54
- * List workflows
55
- */
56
- list(filter?: Parameters<WorkflowStorage['list']>[0]): Promise<import("..").WorkflowState[]>;
57
- /**
58
- * Initialize engine (init storage)
59
- */
60
- init(): Promise<void>;
61
- /**
62
- * Shutdown engine (cleanup)
63
- */
64
- close(): Promise<void>;
65
- }
66
- //# sourceMappingURL=FluxEngine.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FluxEngine.d.ts","sourceRoot":"","sources":["../../src/engine/FluxEngine.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAK5D,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EAEV,kBAAkB,EAClB,eAAe,EAChB,MAAM,UAAU,CAAA;AAEjB;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,QAAQ,CAAc;IAC9B,OAAO,CAAC,cAAc,CAAgB;IACtC,OAAO,CAAC,MAAM,CAAY;gBAEd,MAAM,GAAE,UAAe;IAUnC;;;;;;OAMG;IACG,OAAO,CAAC,MAAM,EAAE,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACnD,QAAQ,EAAE,eAAe,CAAC,MAAM,CAAC,GAAG,kBAAkB,CAAC,MAAM,CAAC,EAC9D,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAoH7B;;;;;OAKG;IACG,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1C,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IAUpC;;OAEG;IACG,GAAG,CAAC,UAAU,EAAE,MAAM;IAI5B;;OAEG;IACG,IAAI,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAI1D;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
@@ -1,2 +0,0 @@
1
- export { FluxEngine } from './FluxEngine';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/engine/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAGH,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAElD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAEhD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAEzE,OAAO,EAAE,SAAS,EAAE,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACpE,OAAO,EAAE,gBAAgB,EAAE,KAAK,uBAAuB,EAAE,MAAM,4BAA4B,CAAA;AAE3F,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAGvD,YAAY,EAEV,UAAU,EAEV,UAAU,EACV,UAAU,EAEV,cAAc,EACd,aAAa,EACb,UAAU,EACV,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,aAAa,EAEb,cAAc,EAEd,eAAe,GAChB,MAAM,SAAS,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.node.d.ts","sourceRoot":"","sources":["../src/index.node.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAE3E,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAGhD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAIvD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAElD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAEzE,OAAO,EAAE,SAAS,EAAE,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAGpE,YAAY,EAEV,UAAU,EAEV,UAAU,EACV,UAAU,EAEV,cAAc,EACd,aAAa,EACb,UAAU,EACV,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,aAAa,EAEb,cAAc,EAEd,eAAe,GAChB,MAAM,SAAS,CAAA"}
@@ -1,40 +0,0 @@
1
- /**
2
- * @fileoverview Console Logger for FluxEngine
3
- *
4
- * Default logger implementation using console.
5
- *
6
- * @module @gravito/flux
7
- */
8
- import type { FluxLogger } from '../types';
9
- /**
10
- * Console Logger
11
- *
12
- * Default logger that outputs to console.
13
- *
14
- * @example
15
- * ```typescript
16
- * const engine = new FluxEngine({
17
- * logger: new FluxConsoleLogger()
18
- * })
19
- * ```
20
- */
21
- export declare class FluxConsoleLogger implements FluxLogger {
22
- private prefix;
23
- constructor(prefix?: string);
24
- debug(message: string, ...args: unknown[]): void;
25
- info(message: string, ...args: unknown[]): void;
26
- warn(message: string, ...args: unknown[]): void;
27
- error(message: string, ...args: unknown[]): void;
28
- }
29
- /**
30
- * Silent Logger
31
- *
32
- * Logger that outputs nothing (for testing or production).
33
- */
34
- export declare class FluxSilentLogger implements FluxLogger {
35
- debug(): void;
36
- info(): void;
37
- warn(): void;
38
- error(): void;
39
- }
40
- //# sourceMappingURL=FluxLogger.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FluxLogger.d.ts","sourceRoot":"","sources":["../../src/logger/FluxLogger.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAE1C;;;;;;;;;;;GAWG;AACH,qBAAa,iBAAkB,YAAW,UAAU;IAClD,OAAO,CAAC,MAAM,CAAQ;gBAEV,MAAM,SAAW;IAI7B,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAIhD,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAI/C,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;IAI/C,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;CAGjD;AAED;;;;GAIG;AACH,qBAAa,gBAAiB,YAAW,UAAU;IACjD,KAAK,IAAI,IAAI;IACb,IAAI,IAAI,IAAI;IACZ,IAAI,IAAI,IAAI;IACZ,KAAK,IAAI,IAAI;CACd"}
@@ -1,2 +0,0 @@
1
- export { FluxConsoleLogger, FluxSilentLogger } from './FluxLogger';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/logger/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA"}