@gravito/flux 3.0.3 → 4.0.0

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.
@@ -1,117 +1,17 @@
1
1
  import {
2
- BunSQLiteStorage
3
- } from "./chunk-EZGSU6AW.js";
4
-
5
- // src/errors.ts
6
- var FluxErrorCode = /* @__PURE__ */ ((FluxErrorCode2) => {
7
- FluxErrorCode2["WORKFLOW_NOT_FOUND"] = "WORKFLOW_NOT_FOUND";
8
- FluxErrorCode2["WORKFLOW_INVALID_INPUT"] = "WORKFLOW_INVALID_INPUT";
9
- FluxErrorCode2["WORKFLOW_DEFINITION_CHANGED"] = "WORKFLOW_DEFINITION_CHANGED";
10
- FluxErrorCode2["WORKFLOW_NAME_MISMATCH"] = "WORKFLOW_NAME_MISMATCH";
11
- FluxErrorCode2["INVALID_STATE_TRANSITION"] = "INVALID_STATE_TRANSITION";
12
- FluxErrorCode2["WORKFLOW_NOT_SUSPENDED"] = "WORKFLOW_NOT_SUSPENDED";
13
- FluxErrorCode2["INVALID_STEP_INDEX"] = "INVALID_STEP_INDEX";
14
- FluxErrorCode2["STEP_TIMEOUT"] = "STEP_TIMEOUT";
15
- FluxErrorCode2["STEP_NOT_FOUND"] = "STEP_NOT_FOUND";
16
- FluxErrorCode2["CONCURRENT_MODIFICATION"] = "CONCURRENT_MODIFICATION";
17
- FluxErrorCode2["EMPTY_WORKFLOW"] = "EMPTY_WORKFLOW";
18
- FluxErrorCode2["NO_RECOVERY_ACTION"] = "NO_RECOVERY_ACTION";
19
- FluxErrorCode2["INVALID_JSON_POINTER"] = "INVALID_JSON_POINTER";
20
- FluxErrorCode2["INVALID_PATH_TRAVERSAL"] = "INVALID_PATH_TRAVERSAL";
21
- FluxErrorCode2["CANNOT_REPLACE_ROOT"] = "CANNOT_REPLACE_ROOT";
22
- FluxErrorCode2["CANNOT_REMOVE_ROOT"] = "CANNOT_REMOVE_ROOT";
23
- return FluxErrorCode2;
24
- })(FluxErrorCode || {});
25
- var FluxError = class extends Error {
26
- /**
27
- * Creates a new FluxError.
28
- *
29
- * @param message - Human-readable error description.
30
- * @param code - Machine-readable error code.
31
- * @param context - Additional metadata related to the error.
32
- */
33
- constructor(message, code, context) {
34
- super(message);
35
- this.code = code;
36
- this.context = context;
37
- this.name = "FluxError";
38
- }
39
- };
40
- function workflowNotFound(id) {
41
- return new FluxError(`Workflow not found: ${id}`, "WORKFLOW_NOT_FOUND" /* WORKFLOW_NOT_FOUND */, {
42
- workflowId: id
43
- });
44
- }
45
- function invalidStateTransition(from, to) {
46
- return new FluxError(
47
- `Invalid state transition: ${from} \u2192 ${to}`,
48
- "INVALID_STATE_TRANSITION" /* INVALID_STATE_TRANSITION */,
49
- { from, to }
50
- );
51
- }
52
- function invalidInput(workflowName) {
53
- return new FluxError(
54
- `Invalid input for workflow "${workflowName}"`,
55
- "WORKFLOW_INVALID_INPUT" /* WORKFLOW_INVALID_INPUT */,
56
- { workflowName }
57
- );
58
- }
59
- function workflowNameMismatch(expected, received) {
60
- return new FluxError(
61
- `Workflow name mismatch: ${received} !== ${expected}`,
62
- "WORKFLOW_NAME_MISMATCH" /* WORKFLOW_NAME_MISMATCH */,
63
- { expected, received }
64
- );
65
- }
66
- function workflowDefinitionChanged() {
67
- return new FluxError(
68
- "Workflow definition changed; operation is not safe",
69
- "WORKFLOW_DEFINITION_CHANGED" /* WORKFLOW_DEFINITION_CHANGED */
70
- );
71
- }
72
- function workflowNotSuspended(status) {
73
- return new FluxError(
74
- `Workflow is not suspended (status: ${status})`,
75
- "WORKFLOW_NOT_SUSPENDED" /* WORKFLOW_NOT_SUSPENDED */,
76
- { status }
77
- );
78
- }
79
- function stepNotFound(step) {
80
- return new FluxError(`Step not found: ${step}`, "STEP_NOT_FOUND" /* STEP_NOT_FOUND */, { step });
81
- }
82
- function invalidStepIndex(index) {
83
- return new FluxError(`Invalid step index: ${index}`, "INVALID_STEP_INDEX" /* INVALID_STEP_INDEX */, { index });
84
- }
85
- function emptyWorkflow(workflowName) {
86
- return new FluxError(`Workflow "${workflowName}" has no steps`, "EMPTY_WORKFLOW" /* EMPTY_WORKFLOW */, {
87
- workflowName
88
- });
89
- }
90
- function noRecoveryAction(stepName) {
91
- return new FluxError(
92
- `No recovery action registered for step: ${stepName}`,
93
- "NO_RECOVERY_ACTION" /* NO_RECOVERY_ACTION */,
94
- { stepName }
95
- );
96
- }
97
- function invalidJsonPointer(path) {
98
- return new FluxError(`Invalid JSON Pointer: ${path}`, "INVALID_JSON_POINTER" /* INVALID_JSON_POINTER */, {
99
- path
100
- });
101
- }
102
- function invalidPathTraversal(segment, current) {
103
- return new FluxError(
104
- `Cannot access property '${segment}' on ${current}`,
105
- "INVALID_PATH_TRAVERSAL" /* INVALID_PATH_TRAVERSAL */,
106
- { segment, currentType: typeof current }
107
- );
108
- }
109
- function cannotReplaceRoot() {
110
- return new FluxError("Cannot replace root object", "CANNOT_REPLACE_ROOT" /* CANNOT_REPLACE_ROOT */);
111
- }
112
- function cannotRemoveRoot() {
113
- return new FluxError("Cannot remove root object", "CANNOT_REMOVE_ROOT" /* CANNOT_REMOVE_ROOT */);
114
- }
2
+ BunSQLiteStorage,
3
+ FluxError,
4
+ emptyWorkflow,
5
+ invalidInput,
6
+ invalidStateTransition,
7
+ invalidStepIndex,
8
+ noRecoveryAction,
9
+ stepNotFound,
10
+ workflowDefinitionChanged,
11
+ workflowNameMismatch,
12
+ workflowNotFound,
13
+ workflowNotSuspended
14
+ } from "./chunk-UZKSACBE.js";
115
15
 
116
16
  // src/builder/WorkflowBuilder.ts
117
17
  var WorkflowBuilder = class {
@@ -3096,8 +2996,10 @@ var PostgreSQLStorage = class {
3096
2996
  };
3097
2997
  function validateSqlIdentifier(value, field) {
3098
2998
  if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(value)) {
3099
- throw new Error(
3100
- `Invalid ${field}: "${value}". Only letters, numbers, and underscores are allowed.`
2999
+ throw new FluxError(
3000
+ `Invalid ${field}: "${value}". Only letters, numbers, and underscores are allowed.`,
3001
+ "WORKFLOW_INVALID_INPUT" /* WORKFLOW_INVALID_INPUT */,
3002
+ { field, value }
3101
3003
  );
3102
3004
  }
3103
3005
  return value;
@@ -3523,6 +3425,16 @@ var OrbitFlux = class _OrbitFlux {
3523
3425
  };
3524
3426
  this.engine = new FluxEngine(engineConfig);
3525
3427
  core.container.instance(exposeAs, this.engine);
3428
+ const health = core.container.make("health");
3429
+ if (health) {
3430
+ const engine = this.engine;
3431
+ health.register("flux", async () => ({
3432
+ status: engine ? "healthy" : "unhealthy",
3433
+ details: {
3434
+ storage: typeof storage === "string" ? storage : "custom"
3435
+ }
3436
+ }));
3437
+ }
3526
3438
  core.logger.info(
3527
3439
  `[OrbitFlux] Initialized (Storage: ${typeof storage === "string" ? storage : "custom"})`
3528
3440
  );
@@ -3550,22 +3462,6 @@ var OrbitFlux = class _OrbitFlux {
3550
3462
  };
3551
3463
 
3552
3464
  export {
3553
- FluxErrorCode,
3554
- FluxError,
3555
- workflowNotFound,
3556
- invalidStateTransition,
3557
- invalidInput,
3558
- workflowNameMismatch,
3559
- workflowDefinitionChanged,
3560
- workflowNotSuspended,
3561
- stepNotFound,
3562
- invalidStepIndex,
3563
- emptyWorkflow,
3564
- noRecoveryAction,
3565
- invalidJsonPointer,
3566
- invalidPathTraversal,
3567
- cannotReplaceRoot,
3568
- cannotRemoveRoot,
3569
3465
  WorkflowBuilder,
3570
3466
  createWorkflow,
3571
3467
  BatchExecutor,
@@ -3583,4 +3479,4 @@ export {
3583
3479
  FluxSilentLogger,
3584
3480
  OrbitFlux
3585
3481
  };
3586
- //# sourceMappingURL=chunk-M2ZRQRF4.js.map
3482
+ //# sourceMappingURL=chunk-JUCSCBHA.js.map