openworkflow 0.4.1 → 0.6.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.
Files changed (220) hide show
  1. package/README.md +43 -345
  2. package/dist/backend-test/backend.testsuite.d.ts +20 -0
  3. package/dist/backend-test/backend.testsuite.d.ts.map +1 -0
  4. package/dist/{core → backend-test}/backend.testsuite.js +191 -59
  5. package/dist/backend-test/index.d.ts +2 -0
  6. package/dist/backend-test/index.d.ts.map +1 -0
  7. package/dist/backend-test/index.js +1 -0
  8. package/dist/{core/backend.d.ts → backend.d.ts} +7 -5
  9. package/dist/backend.d.ts.map +1 -0
  10. package/dist/{core/backend.js → backend.js} +0 -1
  11. package/dist/backend.testsuite.d.ts +20 -0
  12. package/dist/backend.testsuite.d.ts.map +1 -0
  13. package/dist/{core/backend-test-suite.js → backend.testsuite.js} +301 -171
  14. package/dist/bin/openworkflow.d.ts +3 -0
  15. package/dist/bin/openworkflow.d.ts.map +1 -0
  16. package/dist/bin/openworkflow.js +43 -0
  17. package/dist/chaos.test.d.ts +2 -0
  18. package/dist/chaos.test.d.ts.map +1 -0
  19. package/dist/chaos.test.js +88 -0
  20. package/dist/client.d.ts +141 -0
  21. package/dist/client.d.ts.map +1 -0
  22. package/dist/{sdk/sdk.js → client.js} +43 -71
  23. package/dist/client.test.d.ts +2 -0
  24. package/dist/client.test.d.ts.map +1 -0
  25. package/dist/{sdk/sdk.test.js → client.test.js} +130 -14
  26. package/dist/core/duration.d.ts +4 -2
  27. package/dist/core/duration.d.ts.map +1 -1
  28. package/dist/core/duration.js +3 -2
  29. package/dist/core/duration.test.js +0 -1
  30. package/dist/core/error.d.ts +14 -0
  31. package/dist/core/error.d.ts.map +1 -0
  32. package/dist/core/error.js +17 -0
  33. package/dist/core/error.test.d.ts +2 -0
  34. package/dist/core/error.test.d.ts.map +1 -0
  35. package/dist/core/error.test.js +60 -0
  36. package/dist/core/json.js +0 -1
  37. package/dist/core/result.d.ts +14 -4
  38. package/dist/core/result.d.ts.map +1 -1
  39. package/dist/core/result.js +10 -1
  40. package/dist/core/result.test.js +2 -2
  41. package/dist/core/retry.d.ts +0 -9
  42. package/dist/core/retry.d.ts.map +1 -1
  43. package/dist/core/retry.js +0 -15
  44. package/dist/core/schema.js +0 -1
  45. package/dist/core/step.d.ts +1 -32
  46. package/dist/core/step.d.ts.map +1 -1
  47. package/dist/core/step.js +0 -36
  48. package/dist/core/step.test.js +1 -75
  49. package/dist/core/workflow.d.ts +2 -47
  50. package/dist/core/workflow.d.ts.map +1 -1
  51. package/dist/core/workflow.js +0 -45
  52. package/dist/core/workflow.test.js +1 -104
  53. package/dist/driver.d.ts +116 -0
  54. package/dist/driver.d.ts.map +1 -0
  55. package/dist/driver.js +1 -0
  56. package/dist/{execution/execution.d.ts → execution.d.ts} +4 -26
  57. package/dist/execution.d.ts.map +1 -0
  58. package/dist/{execution/execution.js → execution.js} +4 -5
  59. package/dist/execution.test.d.ts.map +1 -0
  60. package/dist/{execution/execution.test.js → execution.test.js} +4 -5
  61. package/dist/factory.d.ts +74 -0
  62. package/dist/factory.d.ts.map +1 -0
  63. package/dist/factory.js +72 -0
  64. package/dist/index.d.ts +6 -9
  65. package/dist/index.d.ts.map +1 -1
  66. package/dist/index.js +4 -5
  67. package/dist/internal.d.ts +7 -0
  68. package/dist/internal.d.ts.map +1 -0
  69. package/dist/internal.js +2 -0
  70. package/dist/node-sqlite/backend.d.ts +52 -0
  71. package/dist/node-sqlite/backend.d.ts.map +1 -0
  72. package/dist/node-sqlite/backend.js +673 -0
  73. package/dist/node-sqlite/index.d.ts +11 -0
  74. package/dist/node-sqlite/index.d.ts.map +1 -0
  75. package/dist/node-sqlite/index.js +7 -0
  76. package/dist/node-sqlite/sqlite.d.ts +60 -0
  77. package/dist/node-sqlite/sqlite.d.ts.map +1 -0
  78. package/dist/{backend-sqlite → node-sqlite}/sqlite.js +20 -3
  79. package/dist/postgres/backend.d.ts +44 -0
  80. package/dist/postgres/backend.d.ts.map +1 -0
  81. package/dist/postgres/backend.js +534 -0
  82. package/dist/postgres/backend.test.d.ts +2 -0
  83. package/dist/postgres/backend.test.d.ts.map +1 -0
  84. package/dist/postgres/backend.test.js +19 -0
  85. package/dist/postgres/driver.d.ts +81 -0
  86. package/dist/postgres/driver.d.ts.map +1 -0
  87. package/dist/postgres/driver.js +63 -0
  88. package/dist/postgres/index.d.ts +11 -0
  89. package/dist/postgres/index.d.ts.map +1 -0
  90. package/dist/postgres/index.js +7 -0
  91. package/dist/postgres/internal.d.ts +2 -0
  92. package/dist/postgres/internal.d.ts.map +1 -0
  93. package/dist/postgres/internal.js +1 -0
  94. package/dist/postgres/postgres.d.ts +42 -0
  95. package/dist/postgres/postgres.d.ts.map +1 -0
  96. package/dist/postgres/postgres.js +233 -0
  97. package/dist/postgres/postgres.test.d.ts +2 -0
  98. package/dist/postgres/postgres.test.d.ts.map +1 -0
  99. package/dist/postgres/postgres.test.js +45 -0
  100. package/dist/postgres/scripts/db-migrate.d.ts +2 -0
  101. package/dist/postgres/scripts/db-migrate.d.ts.map +1 -0
  102. package/dist/postgres/scripts/db-migrate.js +4 -0
  103. package/dist/postgres/scripts/db-reset.d.ts +2 -0
  104. package/dist/postgres/scripts/db-reset.d.ts.map +1 -0
  105. package/dist/postgres/scripts/db-reset.js +5 -0
  106. package/dist/postgres/scripts/squawk.d.ts +2 -0
  107. package/dist/postgres/scripts/squawk.d.ts.map +1 -0
  108. package/dist/postgres/scripts/squawk.js +16 -0
  109. package/dist/postgres/vitest.global-setup.d.ts +3 -0
  110. package/dist/postgres/vitest.global-setup.d.ts.map +1 -0
  111. package/dist/postgres/vitest.global-setup.js +7 -0
  112. package/dist/postgres.d.ts +2 -0
  113. package/dist/postgres.d.ts.map +1 -0
  114. package/dist/postgres.js +1 -0
  115. package/dist/registry.d.ts +27 -0
  116. package/dist/registry.d.ts.map +1 -0
  117. package/dist/registry.js +48 -0
  118. package/dist/registry.test.d.ts +2 -0
  119. package/dist/registry.test.d.ts.map +1 -0
  120. package/dist/registry.test.js +109 -0
  121. package/dist/{backend-sqlite → sqlite}/backend.d.ts +8 -4
  122. package/dist/sqlite/backend.d.ts.map +1 -0
  123. package/dist/{backend-sqlite → sqlite}/backend.js +35 -9
  124. package/dist/sqlite/backend.test.d.ts +2 -0
  125. package/dist/sqlite/backend.test.d.ts.map +1 -0
  126. package/dist/sqlite/backend.test.js +50 -0
  127. package/dist/sqlite/driver.d.ts +79 -0
  128. package/dist/sqlite/driver.d.ts.map +1 -0
  129. package/dist/sqlite/driver.js +62 -0
  130. package/dist/sqlite/index.d.ts +13 -0
  131. package/dist/sqlite/index.d.ts.map +1 -0
  132. package/dist/sqlite/index.js +11 -0
  133. package/dist/sqlite/internal.d.ts +2 -0
  134. package/dist/sqlite/internal.d.ts.map +1 -0
  135. package/dist/sqlite/internal.js +1 -0
  136. package/dist/{backend-sqlite → sqlite}/sqlite.d.ts +18 -2
  137. package/dist/sqlite/sqlite.d.ts.map +1 -0
  138. package/dist/sqlite/sqlite.js +246 -0
  139. package/dist/sqlite/sqlite.test.d.ts +2 -0
  140. package/dist/sqlite/sqlite.test.d.ts.map +1 -0
  141. package/dist/sqlite/sqlite.test.js +171 -0
  142. package/dist/sqlite.d.ts +2 -0
  143. package/dist/sqlite.d.ts.map +1 -0
  144. package/dist/sqlite.js +1 -0
  145. package/dist/tsconfig.tsbuildinfo +1 -1
  146. package/dist/{worker/worker.d.ts → worker.d.ts} +11 -4
  147. package/dist/worker.d.ts.map +1 -0
  148. package/dist/{worker/worker.js → worker.js} +20 -11
  149. package/dist/{worker/worker.test.d.ts.map → worker.test.d.ts.map} +1 -1
  150. package/dist/{worker/worker.test.js → worker.test.js} +136 -22
  151. package/dist/workflow.d.ts +60 -0
  152. package/dist/workflow.d.ts.map +1 -0
  153. package/dist/workflow.js +48 -0
  154. package/dist/workflow.test.d.ts +2 -0
  155. package/dist/workflow.test.d.ts.map +1 -0
  156. package/dist/workflow.test.js +84 -0
  157. package/package.json +28 -4
  158. package/dist/backend-sqlite/backend.d.ts.map +0 -1
  159. package/dist/backend-sqlite/backend.js.map +0 -1
  160. package/dist/backend-sqlite/index.d.ts +0 -2
  161. package/dist/backend-sqlite/index.d.ts.map +0 -1
  162. package/dist/backend-sqlite/index.js +0 -2
  163. package/dist/backend-sqlite/index.js.map +0 -1
  164. package/dist/backend-sqlite/sqlite.d.ts.map +0 -1
  165. package/dist/backend-sqlite/sqlite.js.map +0 -1
  166. package/dist/config/config.d.ts +0 -102
  167. package/dist/config/config.d.ts.map +0 -1
  168. package/dist/config/config.js +0 -29
  169. package/dist/config/config.js.map +0 -1
  170. package/dist/config/index.d.ts +0 -3
  171. package/dist/config/index.d.ts.map +0 -1
  172. package/dist/config/index.js +0 -2
  173. package/dist/config/index.js.map +0 -1
  174. package/dist/config.d.ts +0 -28
  175. package/dist/config.d.ts.map +0 -1
  176. package/dist/config.js +0 -41
  177. package/dist/config.js.map +0 -1
  178. package/dist/core/backend-test-suite.d.ts +0 -22
  179. package/dist/core/backend-test-suite.d.ts.map +0 -1
  180. package/dist/core/backend-test-suite.js.map +0 -1
  181. package/dist/core/backend.d.ts.map +0 -1
  182. package/dist/core/backend.js.map +0 -1
  183. package/dist/core/backend.testsuite.d.ts +0 -21
  184. package/dist/core/backend.testsuite.d.ts.map +0 -1
  185. package/dist/core/backend.testsuite.js.map +0 -1
  186. package/dist/core/duration.js.map +0 -1
  187. package/dist/core/duration.test.js.map +0 -1
  188. package/dist/core/json.js.map +0 -1
  189. package/dist/core/result.js.map +0 -1
  190. package/dist/core/result.test.js.map +0 -1
  191. package/dist/core/retry.js.map +0 -1
  192. package/dist/core/retry.test.d.ts +0 -2
  193. package/dist/core/retry.test.d.ts.map +0 -1
  194. package/dist/core/retry.test.js +0 -36
  195. package/dist/core/retry.test.js.map +0 -1
  196. package/dist/core/schema.js.map +0 -1
  197. package/dist/core/step.js.map +0 -1
  198. package/dist/core/step.test.js.map +0 -1
  199. package/dist/core/workflow.js.map +0 -1
  200. package/dist/core/workflow.test.js.map +0 -1
  201. package/dist/execution/execution.d.ts.map +0 -1
  202. package/dist/execution/execution.js.map +0 -1
  203. package/dist/execution/execution.test.d.ts.map +0 -1
  204. package/dist/execution/execution.test.js.map +0 -1
  205. package/dist/global.d.ts +0 -62
  206. package/dist/global.d.ts.map +0 -1
  207. package/dist/global.js +0 -78
  208. package/dist/global.js.map +0 -1
  209. package/dist/index.js.map +0 -1
  210. package/dist/sdk/sdk.d.ts +0 -182
  211. package/dist/sdk/sdk.d.ts.map +0 -1
  212. package/dist/sdk/sdk.js.map +0 -1
  213. package/dist/sdk/sdk.test.d.ts +0 -2
  214. package/dist/sdk/sdk.test.d.ts.map +0 -1
  215. package/dist/sdk/sdk.test.js.map +0 -1
  216. package/dist/worker/worker.d.ts.map +0 -1
  217. package/dist/worker/worker.js.map +0 -1
  218. package/dist/worker/worker.test.js.map +0 -1
  219. /package/dist/{execution/execution.test.d.ts → execution.test.d.ts} +0 -0
  220. /package/dist/{worker/worker.test.d.ts → worker.test.d.ts} +0 -0
package/dist/core/step.js CHANGED
@@ -1,28 +1,8 @@
1
1
  import { parseDuration } from "./duration.js";
2
2
  import { err, ok } from "./result.js";
3
- /**
4
- * Serialize an error to a JSON-compatible format. Pure function that converts
5
- * any error into a SerializedError object.
6
- *
7
- * @param error - The error to serialize (can be Error instance or any value)
8
- * @returns A JSON-serializable error object
9
- */
10
- export function serializeError(error) {
11
- if (error instanceof Error) {
12
- return {
13
- name: error.name,
14
- message: error.message,
15
- stack: error.stack ?? null,
16
- };
17
- }
18
- return {
19
- message: String(error),
20
- };
21
- }
22
3
  /**
23
4
  * Create a step attempt cache from an array of attempts. Only includes
24
5
  * successful attempts (completed or succeeded status).
25
- *
26
6
  * @param attempts - Array of step attempts to cache
27
7
  * @returns An immutable map of step name to successful attempt
28
8
  */
@@ -33,7 +13,6 @@ export function createStepAttemptCacheFromAttempts(attempts) {
33
13
  }
34
14
  /**
35
15
  * Get a cached step attempt by name.
36
- *
37
16
  * @param cache - The step attempt cache
38
17
  * @param stepName - The name of the step to look up
39
18
  * @returns The cached attempt or undefined if not found
@@ -41,20 +20,9 @@ export function createStepAttemptCacheFromAttempts(attempts) {
41
20
  export function getCachedStepAttempt(cache, stepName) {
42
21
  return cache.get(stepName);
43
22
  }
44
- /**
45
- * Check if a step attempt is cached (has completed successfully).
46
- *
47
- * @param cache - The step attempt cache
48
- * @param stepName - The name of the step to check
49
- * @returns True if the step has a cached successful result
50
- */
51
- export function hasCompletedStep(cache, stepName) {
52
- return cache.has(stepName);
53
- }
54
23
  /**
55
24
  * Add a step attempt to the cache (returns new cache, original unchanged). This
56
25
  * is an immutable operation.
57
- *
58
26
  * @param cache - The existing step attempt cache
59
27
  * @param attempt - The attempt to add
60
28
  * @returns A new cache with the attempt added
@@ -65,7 +33,6 @@ export function addToStepAttemptCache(cache, attempt) {
65
33
  /**
66
34
  * Convert a step function result to a JSON-compatible value. Undefined values
67
35
  * are converted to null for JSON serialization.
68
- *
69
36
  * @param result - The result from a step function
70
37
  * @returns A JSON-serializable value
71
38
  */
@@ -74,7 +41,6 @@ export function normalizeStepOutput(result) {
74
41
  }
75
42
  /**
76
43
  * Calculate the resume time for a sleep step.
77
- *
78
44
  * @param duration - The duration string to sleep for
79
45
  * @param now - The current timestamp (defaults to Date.now())
80
46
  * @returns A Result containing the resume Date or an Error
@@ -88,7 +54,6 @@ export function calculateSleepResumeAt(duration, now = Date.now()) {
88
54
  }
89
55
  /**
90
56
  * Create the context object for a sleep step attempt.
91
- *
92
57
  * @param resumeAt - The time when the sleep should resume
93
58
  * @returns The context object for the sleep step
94
59
  */
@@ -98,4 +63,3 @@ export function createSleepContext(resumeAt) {
98
63
  resumeAt: resumeAt.toISOString(),
99
64
  };
100
65
  }
101
- //# sourceMappingURL=step.js.map
@@ -1,64 +1,6 @@
1
1
  import { ok } from "./result.js";
2
- import { serializeError, createStepAttemptCacheFromAttempts, getCachedStepAttempt, hasCompletedStep, addToStepAttemptCache, normalizeStepOutput, calculateSleepResumeAt, createSleepContext, } from "./step.js";
2
+ import { createStepAttemptCacheFromAttempts, getCachedStepAttempt, addToStepAttemptCache, normalizeStepOutput, calculateSleepResumeAt, createSleepContext, } from "./step.js";
3
3
  import { describe, expect, test } from "vitest";
4
- describe("serializeError", () => {
5
- test("serializes Error instance with name, message, and stack", () => {
6
- const error = new Error("Something went wrong");
7
- const result = serializeError(error);
8
- expect(result.name).toBe("Error");
9
- expect(result.message).toBe("Something went wrong");
10
- expect(result.stack).toBeDefined();
11
- expect(typeof result.stack).toBe("string");
12
- });
13
- test("serializes TypeError with correct name", () => {
14
- const error = new TypeError("Invalid type");
15
- const result = serializeError(error);
16
- expect(result.name).toBe("TypeError");
17
- expect(result.message).toBe("Invalid type");
18
- });
19
- test("serializes custom Error subclass", () => {
20
- class CustomError extends Error {
21
- constructor(message) {
22
- super(message);
23
- this.name = "CustomError";
24
- }
25
- }
26
- const error = new CustomError("Custom error message");
27
- const result = serializeError(error);
28
- expect(result.name).toBe("CustomError");
29
- expect(result.message).toBe("Custom error message");
30
- });
31
- test("serializes Error without stack as null", () => {
32
- const error = new Error("No stack");
33
- // @ts-expect-error testing edge case
34
- error.stack = undefined;
35
- const result = serializeError(error);
36
- expect(result.stack).toBeNull();
37
- });
38
- test("serializes string to message", () => {
39
- const result = serializeError("string error");
40
- expect(result.message).toBe("string error");
41
- expect(result.name).toBeUndefined();
42
- expect(result.stack).toBeUndefined();
43
- });
44
- test("serializes number to message", () => {
45
- const result = serializeError(42);
46
- expect(result.message).toBe("42");
47
- });
48
- test("serializes null to message", () => {
49
- const result = serializeError(null);
50
- expect(result.message).toBe("null");
51
- });
52
- test("serializes undefined to message", () => {
53
- // eslint-disable-next-line unicorn/no-useless-undefined
54
- const result = serializeError(undefined);
55
- expect(result.message).toBe("undefined");
56
- });
57
- test("serializes object to message using String()", () => {
58
- const result = serializeError({ foo: "bar" });
59
- expect(result.message).toBe("[object Object]");
60
- });
61
- });
62
4
  describe("createStepAttemptCacheFromAttempts", () => {
63
5
  test("creates empty cache from empty array", () => {
64
6
  const cache = createStepAttemptCacheFromAttempts([]);
@@ -151,21 +93,6 @@ describe("getCachedStepAttempt", () => {
151
93
  expect(getCachedStepAttempt(cache, "step-1 ")).toBeUndefined();
152
94
  });
153
95
  });
154
- describe("hasCompletedStep", () => {
155
- test("returns true when step is in cache", () => {
156
- const attempt = createMockStepAttempt({ stepName: "step-x" });
157
- const cache = new Map([["step-x", attempt]]);
158
- expect(hasCompletedStep(cache, "step-x")).toBe(true);
159
- });
160
- test("returns false when step is not in cache", () => {
161
- const cache = new Map();
162
- expect(hasCompletedStep(cache, "step-y")).toBe(false);
163
- });
164
- test("returns false for empty cache", () => {
165
- const cache = new Map();
166
- expect(hasCompletedStep(cache, "any-step")).toBe(false);
167
- });
168
- });
169
96
  describe("addToStepAttemptCache", () => {
170
97
  test("adds attempt to empty cache", () => {
171
98
  const cache = new Map();
@@ -337,4 +264,3 @@ function createMockStepAttempt(overrides = {}) {
337
264
  ...overrides,
338
265
  };
339
266
  }
340
- //# sourceMappingURL=step.test.js.map
@@ -1,3 +1,4 @@
1
+ import type { SerializedError } from "./error.js";
1
2
  import { JsonValue } from "./json.js";
2
3
  import type { StandardSchemaV1 } from "./schema.js";
3
4
  /**
@@ -18,7 +19,7 @@ export interface WorkflowRun {
18
19
  context: JsonValue | null;
19
20
  input: JsonValue | null;
20
21
  output: JsonValue | null;
21
- error: JsonValue | null;
22
+ error: SerializedError | null;
22
23
  attempts: number;
23
24
  parentStepAttemptNamespaceId: string | null;
24
25
  parentStepAttemptId: string | null;
@@ -49,30 +50,9 @@ export type ValidationResult<T> = {
49
50
  success: false;
50
51
  error: string;
51
52
  };
52
- /**
53
- * Configuration options for a workflow definition.
54
- */
55
- export interface WorkflowConfig<TSchema extends StandardSchemaV1 | undefined = undefined> {
56
- /** The unique name of the workflow. */
57
- name: string;
58
- /** Optional version string for zero-downtime deployments. */
59
- version?: string;
60
- /** Optional schema for input validation (Standard Schema v1). */
61
- schema?: TSchema;
62
- }
63
- /**
64
- * Default configuration for result polling when awaiting workflow completion.
65
- */
66
- export declare const DEFAULT_WORKFLOW_RESULT_CONFIG: {
67
- /** Polling interval in milliseconds (1 second) */
68
- readonly pollIntervalMs: 1000;
69
- /** Timeout in milliseconds (5 minutes) */
70
- readonly timeoutMs: number;
71
- };
72
53
  /**
73
54
  * Validate input against a Standard Schema. Pure async function that validates
74
55
  * input and returns a ValidationResult.
75
- *
76
56
  * @param schema - The Standard Schema to validate against (or null/undefined
77
57
  * for no validation)
78
58
  * @param input - The input value to validate
@@ -80,29 +60,4 @@ export declare const DEFAULT_WORKFLOW_RESULT_CONFIG: {
80
60
  * message
81
61
  */
82
62
  export declare function validateInput<RunInput, Input>(schema: StandardSchemaV1<RunInput, Input> | null | undefined, input: RunInput | undefined): Promise<ValidationResult<Input>>;
83
- /**
84
- * Create a workflow configuration object with defaults applied.
85
- *
86
- * @param config - The user-provided workflow configuration
87
- * @returns A normalized workflow configuration
88
- */
89
- export declare function createWorkflowConfig<TSchema extends StandardSchemaV1 | undefined = undefined>(config: Readonly<WorkflowConfig<TSchema>>): Readonly<{
90
- name: string;
91
- version: string | null;
92
- schema: TSchema | null;
93
- }>;
94
- /**
95
- * Check if a workflow definition has a schema for validation.
96
- *
97
- * @param config - The workflow configuration
98
- * @returns True if the workflow has a schema configured
99
- */
100
- export declare function hasSchema<TSchema extends StandardSchemaV1 | undefined>(config: Readonly<WorkflowConfig<TSchema>>): boolean;
101
- /**
102
- * Check if a workflow run status represents a terminal state.
103
- *
104
- * @param status - The workflow run status
105
- * @returns True if the status is terminal (completed, failed, or canceled)
106
- */
107
- export declare function isTerminalStatus(status: string): status is "succeeded" | "completed" | "failed" | "canceled";
108
63
  //# sourceMappingURL=workflow.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../core/workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC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UAAU,EAAE,IAAI,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,IAAI,GAAG,IAAI,CAAC;IACvB,UAAU,EAAE,IAAI,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,OAAO,EAAE,QAAQ,IAAI,OAAO,SAAS,gBAAgB,GACzE,gBAAgB,CAAC,UAAU,CAAC,OAAO,CAAC,GACpC,QAAQ,CAAC;AAEb;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,OAAO,EAAE,QAAQ,IAAI,OAAO,SAAS,gBAAgB,GAC1E,gBAAgB,CAAC,WAAW,CAAC,OAAO,CAAC,GACrC,QAAQ,CAAC;AAEb;;;GAGG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAC1B;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GAC3B;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtC;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CAAC,QAAQ,EAAE,KAAK,EACjD,MAAM,EAAE,gBAAgB,CAAC,QAAQ,EAAE,KAAK,CAAC,GAAG,IAAI,GAAG,SAAS,EAC5D,KAAK,EAAE,QAAQ,GAAG,SAAS,GAC1B,OAAO,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,CA4BlC"}
@@ -1,16 +1,6 @@
1
- /**
2
- * Default configuration for result polling when awaiting workflow completion.
3
- */
4
- export const DEFAULT_WORKFLOW_RESULT_CONFIG = {
5
- /** Polling interval in milliseconds (1 second) */
6
- pollIntervalMs: 1000,
7
- /** Timeout in milliseconds (5 minutes) */
8
- timeoutMs: 5 * 60 * 1000,
9
- };
10
1
  /**
11
2
  * Validate input against a Standard Schema. Pure async function that validates
12
3
  * input and returns a ValidationResult.
13
- *
14
4
  * @param schema - The Standard Schema to validate against (or null/undefined
15
5
  * for no validation)
16
6
  * @param input - The input value to validate
@@ -42,38 +32,3 @@ export async function validateInput(schema, input) {
42
32
  value: resolved.value,
43
33
  };
44
34
  }
45
- /**
46
- * Create a workflow configuration object with defaults applied.
47
- *
48
- * @param config - The user-provided workflow configuration
49
- * @returns A normalized workflow configuration
50
- */
51
- export function createWorkflowConfig(config) {
52
- return {
53
- name: config.name,
54
- version: config.version ?? null,
55
- schema: config.schema ?? null,
56
- };
57
- }
58
- /**
59
- * Check if a workflow definition has a schema for validation.
60
- *
61
- * @param config - The workflow configuration
62
- * @returns True if the workflow has a schema configured
63
- */
64
- export function hasSchema(config) {
65
- return Boolean(config.schema);
66
- }
67
- /**
68
- * Check if a workflow run status represents a terminal state.
69
- *
70
- * @param status - The workflow run status
71
- * @returns True if the status is terminal (completed, failed, or canceled)
72
- */
73
- export function isTerminalStatus(status) {
74
- return (status === "succeeded" ||
75
- status === "completed" ||
76
- status === "failed" ||
77
- status === "canceled");
78
- }
79
- //# sourceMappingURL=workflow.js.map
@@ -1,4 +1,4 @@
1
- import { validateInput, createWorkflowConfig, hasSchema, isTerminalStatus, DEFAULT_WORKFLOW_RESULT_CONFIG, } from "./workflow.js";
1
+ import { validateInput } from "./workflow.js";
2
2
  import { describe, expect, test } from "vitest";
3
3
  describe("validateInput", () => {
4
4
  test("returns success with input when no schema provided (null)", async () => {
@@ -102,108 +102,6 @@ describe("validateInput", () => {
102
102
  }
103
103
  });
104
104
  });
105
- describe("createWorkflowConfig", () => {
106
- test("creates config with required name", () => {
107
- const config = createWorkflowConfig({ name: "my-workflow" });
108
- expect(config.name).toBe("my-workflow");
109
- expect(config.version).toBeNull();
110
- expect(config.schema).toBeNull();
111
- });
112
- test("preserves provided version", () => {
113
- const config = createWorkflowConfig({
114
- name: "versioned-workflow",
115
- version: "1.0.0",
116
- });
117
- expect(config.name).toBe("versioned-workflow");
118
- expect(config.version).toBe("1.0.0");
119
- });
120
- test("preserves provided schema", () => {
121
- const schema = createMockSchema({
122
- validate: (input) => ({ value: input }),
123
- });
124
- const config = createWorkflowConfig({
125
- name: "validated-workflow",
126
- schema,
127
- });
128
- expect(config.name).toBe("validated-workflow");
129
- expect(config.schema).toBe(schema);
130
- });
131
- test("creates config with all options", () => {
132
- const schema = createMockSchema({
133
- validate: (input) => ({ value: input }),
134
- });
135
- const config = createWorkflowConfig({
136
- name: "full-workflow",
137
- version: "2.5.0",
138
- schema,
139
- });
140
- expect(config.name).toBe("full-workflow");
141
- expect(config.version).toBe("2.5.0");
142
- expect(config.schema).toBe(schema);
143
- });
144
- test("returns frozen/readonly config object", () => {
145
- const config = createWorkflowConfig({ name: "readonly-workflow" });
146
- expect(config.name).toBe("readonly-workflow");
147
- // The function signature specifies Readonly<>, so we trust type safety
148
- });
149
- });
150
- describe("hasSchema", () => {
151
- test("returns false when no schema provided", () => {
152
- const config = { name: "no-schema-workflow" };
153
- expect(hasSchema(config)).toBe(false);
154
- });
155
- test("returns false when schema is undefined", () => {
156
- const config = { name: "undefined-schema", schema: undefined };
157
- expect(hasSchema(config)).toBe(false);
158
- });
159
- test("returns true when schema is provided", () => {
160
- const schema = createMockSchema({
161
- validate: (input) => ({ value: input }),
162
- });
163
- const config = { name: "with-schema", schema };
164
- expect(hasSchema(config)).toBe(true);
165
- });
166
- test("returns true for any truthy schema value", () => {
167
- const config = { name: "truthy-schema", schema: {} };
168
- expect(hasSchema(config)).toBe(true);
169
- });
170
- });
171
- describe("isTerminalStatus", () => {
172
- test("returns true for 'completed' status", () => {
173
- expect(isTerminalStatus("completed")).toBe(true);
174
- });
175
- test("returns true for 'succeeded' status (deprecated)", () => {
176
- expect(isTerminalStatus("succeeded")).toBe(true);
177
- });
178
- test("returns true for 'failed' status", () => {
179
- expect(isTerminalStatus("failed")).toBe(true);
180
- });
181
- test("returns true for 'canceled' status", () => {
182
- expect(isTerminalStatus("canceled")).toBe(true);
183
- });
184
- test("returns false for 'pending' status", () => {
185
- expect(isTerminalStatus("pending")).toBe(false);
186
- });
187
- test("returns false for 'running' status", () => {
188
- expect(isTerminalStatus("running")).toBe(false);
189
- });
190
- test("returns false for 'sleeping' status", () => {
191
- expect(isTerminalStatus("sleeping")).toBe(false);
192
- });
193
- test("returns false for unknown status strings", () => {
194
- expect(isTerminalStatus("unknown")).toBe(false);
195
- expect(isTerminalStatus("")).toBe(false);
196
- expect(isTerminalStatus("COMPLETED")).toBe(false);
197
- });
198
- });
199
- describe("DEFAULT_WORKFLOW_RESULT_CONFIG", () => {
200
- test("has expected poll interval", () => {
201
- expect(DEFAULT_WORKFLOW_RESULT_CONFIG.pollIntervalMs).toBe(1000);
202
- });
203
- test("has expected timeout (5 minutes)", () => {
204
- expect(DEFAULT_WORKFLOW_RESULT_CONFIG.timeoutMs).toBe(5 * 60 * 1000);
205
- });
206
- });
207
105
  function createMockSchema(options) {
208
106
  return {
209
107
  "~standard": {
@@ -213,4 +111,3 @@ function createMockSchema(options) {
213
111
  },
214
112
  };
215
113
  }
216
- //# sourceMappingURL=workflow.test.js.map
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Drizzle-style driver model for OpenWorkflow backends.
3
+ *
4
+ * This module provides a driver abstraction layer that separates the database
5
+ * client (driver) from the backend operations. It follows the Drizzle ORM
6
+ * pattern where:
7
+ *
8
+ * 1. A `Driver` wraps the low-level database client
9
+ * 2. A `DriverConfig` specifies connection and namespace options
10
+ * 3. The `openworkflow()` factory function creates an `OpenWorkflow` instance
11
+ *
12
+ * Example usage with PostgreSQL:
13
+ * ```ts
14
+ * import { openworkflow } from 'openworkflow';
15
+ * import { postgres } from 'openworkflow/postgres';
16
+ *
17
+ * // Simple usage with connection string
18
+ * const ow = openworkflow(postgres(process.env.DATABASE_URL));
19
+ *
20
+ * // With config options
21
+ * const ow = openworkflow(postgres({
22
+ * connection: process.env.DATABASE_URL,
23
+ * namespace: 'my-app',
24
+ * }));
25
+ * ```
26
+ *
27
+ * Example usage with SQLite:
28
+ * ```ts
29
+ * import { openworkflow } from 'openworkflow';
30
+ * import { sqlite } from 'openworkflow/sqlite';
31
+ *
32
+ * const ow = openworkflow(sqlite(':memory:'));
33
+ * ```
34
+ */
35
+ import type { Backend } from "./backend.js";
36
+ /**
37
+ * A driver creates Backend instances from database connections.
38
+ * This is the core abstraction that allows OpenWorkflow to work with
39
+ * different database backends using the same API.
40
+ *
41
+ * Drivers are typically created using helper functions like:
42
+ * - `postgres()` from 'openworkflow/postgres'
43
+ * - `sqlite()` from 'openworkflow/sqlite'
44
+ */
45
+ export interface Driver {
46
+ /**
47
+ * Unique identifier for this driver type.
48
+ */
49
+ readonly dialect: DriverDialect;
50
+ /**
51
+ * Creates a new Backend instance from this driver.
52
+ * This method handles connection setup and migrations.
53
+ */
54
+ createBackend(): Promise<Backend> | Backend;
55
+ /**
56
+ * The underlying database client, if available.
57
+ * This can be used for advanced operations or debugging.
58
+ */
59
+ readonly $client?: unknown;
60
+ }
61
+ /**
62
+ * Supported driver dialects.
63
+ */
64
+ export type DriverDialect = "postgres" | "sqlite";
65
+ /**
66
+ * Common configuration options for all drivers.
67
+ */
68
+ export interface DriverConfig {
69
+ /**
70
+ * The namespace for workflow runs. Defaults to 'default'.
71
+ * This allows multiple applications to share the same database.
72
+ */
73
+ namespace?: string;
74
+ /**
75
+ * Whether to automatically run migrations on connection.
76
+ * Defaults to true.
77
+ */
78
+ runMigrations?: boolean;
79
+ /**
80
+ * Optional logger for debugging.
81
+ */
82
+ logger?: DriverLogger;
83
+ }
84
+ /**
85
+ * Logger interface for driver operations.
86
+ */
87
+ export interface DriverLogger {
88
+ /**
89
+ * Log a message at info level.
90
+ */
91
+ logQuery?(query: string, params?: unknown[]): void;
92
+ /**
93
+ * Log a message at error level.
94
+ */
95
+ error?(message: string, error?: unknown): void;
96
+ }
97
+ /**
98
+ * Configuration options for the openworkflow factory function.
99
+ */
100
+ export interface OpenWorkflowConfig {
101
+ /**
102
+ * Optional logger for debugging.
103
+ */
104
+ logger?: DriverLogger;
105
+ }
106
+ /**
107
+ * A driver that is ready to create backends.
108
+ * This type is used to ensure the driver has been properly configured.
109
+ */
110
+ export interface PreparedDriver<TClient = unknown> extends Driver {
111
+ /**
112
+ * The underlying database client.
113
+ */
114
+ readonly $client: TClient;
115
+ }
116
+ //# sourceMappingURL=driver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../driver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C;;;;;;;;GAQG;AACH,MAAM,WAAW,MAAM;IACrB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;IAEhC;;;OAGG;IACH,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IAE5C;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG,QAAQ,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;OAEG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,QAAQ,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAEnD;;OAEG;IACH,KAAK,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CAChD;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc,CAAC,OAAO,GAAG,OAAO,CAAE,SAAQ,MAAM;IAC/D;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B"}
package/dist/driver.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -1,7 +1,7 @@
1
- import type { Backend } from "../core/backend.js";
2
- import type { DurationString } from "../core/duration.js";
3
- import type { StepAttempt } from "../core/step.js";
4
- import type { WorkflowRun } from "../core/workflow.js";
1
+ import type { Backend } from "./backend.js";
2
+ import type { DurationString } from "./core/duration.js";
3
+ import type { StepAttempt } from "./core/step.js";
4
+ import type { WorkflowRun } from "./core/workflow.js";
5
5
  /**
6
6
  * Config for an individual step defined with `step.run()`.
7
7
  */
@@ -37,14 +37,6 @@ export interface WorkflowFunctionParams<Input> {
37
37
  * to define the workflow's steps.
38
38
  */
39
39
  export type WorkflowFunction<Input, Output> = (params: Readonly<WorkflowFunctionParams<Input>>) => Promise<Output> | Output;
40
- /**
41
- * Signal thrown when a workflow needs to sleep. Contains the time when the
42
- * workflow should resume.
43
- */
44
- export declare class SleepSignal extends Error {
45
- readonly resumeAt: Date;
46
- constructor(resumeAt: Readonly<Date>);
47
- }
48
40
  /**
49
41
  * Configures the options for a StepExecutor.
50
42
  */
@@ -54,19 +46,6 @@ export interface StepExecutorOptions {
54
46
  workerId: string;
55
47
  attempts: StepAttempt[];
56
48
  }
57
- /**
58
- * Replays prior step attempts and persists new ones while memoizing
59
- * deterministic step outputs.
60
- */
61
- export declare class StepExecutor implements StepApi {
62
- private readonly backend;
63
- private readonly workflowRunId;
64
- private readonly workerId;
65
- private cache;
66
- constructor(options: Readonly<StepExecutorOptions>);
67
- run<Output>(config: Readonly<StepFunctionConfig>, fn: StepFunction<Output>): Promise<Output>;
68
- sleep(name: string, duration: DurationString): Promise<void>;
69
- }
70
49
  /**
71
50
  * Parameters for the workflow execution use case.
72
51
  */
@@ -84,7 +63,6 @@ export interface ExecuteWorkflowParams {
84
63
  * - Creating the step executor
85
64
  * - Executing the workflow function
86
65
  * - Completing, failing, or sleeping the workflow run based on the outcome
87
- *
88
66
  * @param params - The execution parameters
89
67
  */
90
68
  export declare function executeWorkflow(params: Readonly<ExecuteWorkflowParams>): Promise<void>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../execution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGzD,OAAO,KAAK,EAAE,WAAW,EAAoB,MAAM,gBAAgB,CAAC;AASpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,MAAM,WAAW,OAAO;IACtB,GAAG,CAAC,MAAM,EACR,MAAM,EAAE,QAAQ,CAAC,kBAAkB,CAAC,EACpC,EAAE,EAAE,YAAY,CAAC,MAAM,CAAC,GACvB,OAAO,CAAC,MAAM,CAAC,CAAC;IACnB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9D;AAED;;;GAGG;AACH,MAAM,MAAM,YAAY,CAAC,MAAM,IAAI,MAC/B,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,GAC3B,MAAM,GACN,SAAS,CAAC;AAEd;;GAEG;AACH,MAAM,WAAW,sBAAsB,CAAC,KAAK;IAC3C,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,MAAM,gBAAgB,CAAC,KAAK,EAAE,MAAM,IAAI,CAC5C,MAAM,EAAE,QAAQ,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC,KAC5C,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;AAgB9B;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,WAAW,EAAE,CAAC;CACzB;AAoGD;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,WAAW,CAAC;IACzB,UAAU,EAAE,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC/C,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,QAAQ,CAAC,qBAAqB,CAAC,GACtC,OAAO,CAAC,IAAI,CAAC,CA4Ff"}
@@ -1,9 +1,10 @@
1
- import { serializeError, createStepAttemptCacheFromAttempts, getCachedStepAttempt, addToStepAttemptCache, normalizeStepOutput, calculateSleepResumeAt, createSleepContext, } from "../core/step.js";
1
+ import { serializeError } from "./core/error.js";
2
+ import { createStepAttemptCacheFromAttempts, getCachedStepAttempt, addToStepAttemptCache, normalizeStepOutput, calculateSleepResumeAt, createSleepContext, } from "./core/step.js";
2
3
  /**
3
4
  * Signal thrown when a workflow needs to sleep. Contains the time when the
4
5
  * workflow should resume.
5
6
  */
6
- export class SleepSignal extends Error {
7
+ class SleepSignal extends Error {
7
8
  resumeAt;
8
9
  constructor(resumeAt) {
9
10
  super("SleepSignal");
@@ -15,7 +16,7 @@ export class SleepSignal extends Error {
15
16
  * Replays prior step attempts and persists new ones while memoizing
16
17
  * deterministic step outputs.
17
18
  */
18
- export class StepExecutor {
19
+ class StepExecutor {
19
20
  backend;
20
21
  workflowRunId;
21
22
  workerId;
@@ -101,7 +102,6 @@ export class StepExecutor {
101
102
  * - Creating the step executor
102
103
  * - Executing the workflow function
103
104
  * - Completing, failing, or sleeping the workflow run based on the outcome
104
- *
105
105
  * @param params - The execution parameters
106
106
  */
107
107
  export async function executeWorkflow(params) {
@@ -185,4 +185,3 @@ export async function executeWorkflow(params) {
185
185
  });
186
186
  }
187
187
  }
188
- //# sourceMappingURL=execution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution.test.d.ts","sourceRoot":"","sources":["../execution.test.ts"],"names":[],"mappings":""}