@usehelical/workflows 0.0.1-alpha.2 → 0.0.1-alpha.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.
@@ -1,4 +1,4 @@
1
- import { W as WorkflowStatus, a as WorkflowEntry, Q as QueueEntry, M as MessageDefinition, S as StateDefinition } from './state-CmpqDrnz.mjs';
1
+ import { W as WorkflowStatus, a as WorkflowEntry, Q as QueueEntry, M as MessageDefinition, S as StateDefinition } from './state-CmpqDrnz.js';
2
2
 
3
3
  interface Run<TReturn = unknown> {
4
4
  id: string;
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from './runtime';
2
+ //# sourceMappingURL=index.js.map
3
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.mjs","sourcesContent":[]}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js","sourcesContent":[]}
@@ -0,0 +1,43 @@
1
+ import { S as StateDefinition, M as MessageDefinition } from './state-CmpqDrnz.js';
2
+ export { b as QueueDefinition, Q as QueueEntry, c as QueueOptions, d as QueueRateLimit, e as WorkflowDefinition, a as WorkflowEntry, f as WorkflowFunction, W as WorkflowStatus, g as defineMessage, h as defineQueue, i as defineState, j as defineWorkflow } from './state-CmpqDrnz.js';
3
+
4
+ type RetryConfig = {
5
+ maxRetries?: number;
6
+ retryDelay?: number;
7
+ backOffRate?: number;
8
+ };
9
+ type StepOptions = RetryConfig & {
10
+ name?: string;
11
+ };
12
+ type StepFunction<Args extends unknown[], R> = (...args: Args) => Promise<R> | R;
13
+ type StepDefinition<TArgs extends unknown[], TReturn> = {
14
+ fn: StepFunction<TArgs, TReturn>;
15
+ args: TArgs;
16
+ options: StepOptions;
17
+ };
18
+ declare function defineStep<TArgs extends unknown[], TReturn>(fn: StepFunction<TArgs, TReturn>, options?: StepOptions): (...args: TArgs) => StepDefinition<TArgs, TReturn>;
19
+
20
+ declare function runStep<TArgs extends unknown[], TReturn>(step: StepDefinition<TArgs, TReturn>): Promise<TReturn | (TReturn extends void ? void : TReturn)>;
21
+ declare function executeStepWithRetries<TArgs extends unknown[], TReturn>(stepName: string, fn: StepFunction<TArgs, TReturn>, args: TArgs, retryConfig: RetryConfig): Promise<TReturn>;
22
+
23
+ declare function setState<T = unknown>(state: StateDefinition<T> | string, value: T): Promise<void | (T extends void ? void : T)>;
24
+
25
+ declare function receiveMessage<T>(message: MessageDefinition<T> | string): Promise<T>;
26
+
27
+ /**
28
+ * Generates a stable, unique step ID based on the current run ID and sequence ID.
29
+ * This ID is deterministic and will remain the same across retries, making it
30
+ * suitable for use as an idempotency key with third-party systems.
31
+ *
32
+ * The step ID is a SHA-256 hash of the run ID and sequence ID, formatted as a
33
+ * hex string for easy use with external APIs.
34
+ *
35
+ * @returns A unique, stable identifier for the current step execution
36
+ */
37
+ declare function getStepId(): string;
38
+
39
+ declare function getAbortSignal(): AbortSignal;
40
+
41
+ declare function getRunId(): string;
42
+
43
+ export { MessageDefinition, type RetryConfig, StateDefinition, type StepDefinition, type StepFunction, defineStep, executeStepWithRetries, getAbortSignal, getRunId, getStepId, receiveMessage, runStep, setState };
@@ -3,5 +3,6 @@ export * from './queue';
3
3
  export * from './state';
4
4
  export * from './step';
5
5
  export * from './workflow';
6
- //# sourceMappingURL=workflows.mjs.map
7
- //# sourceMappingURL=workflows.mjs.map
6
+ export * from './steps';
7
+ //# sourceMappingURL=workflows.js.map
8
+ //# sourceMappingURL=workflows.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"workflows.mjs","sourcesContent":[]}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"workflows.js","sourcesContent":[]}
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@usehelical/workflows",
3
- "version": "0.0.1-alpha.2",
3
+ "version": "0.0.1-alpha.4",
4
4
  "description": "simple typesage durable workflows without magic",
5
5
  "main": "./dist/index.js",
6
+ "type": "module",
6
7
  "types": "./dist/index.d.ts",
7
8
  "exports": {
8
9
  ".": {
@@ -39,6 +40,7 @@
39
40
  "devDependencies": {
40
41
  "@electric-sql/pglite": "^0.3.15",
41
42
  "@eslint/js": "^9.39.2",
43
+ "@types/node": "^25.2.0",
42
44
  "@types/pg": "^8.16.0",
43
45
  "@vitest/coverage-v8": "^4.0.18",
44
46
  "eslint": "^9.39.2",
package/dist/index.mjs DELETED
@@ -1,3 +0,0 @@
1
- export * from './runtime';
2
- //# sourceMappingURL=index.mjs.map
3
- //# sourceMappingURL=index.mjs.map
@@ -1,19 +0,0 @@
1
- export { M as MessageDefinition, b as QueueDefinition, Q as QueueEntry, c as QueueOptions, d as QueueRateLimit, S as StateDefinition, e as WorkflowDefinition, a as WorkflowEntry, f as WorkflowFunction, W as WorkflowStatus, g as defineMessage, h as defineQueue, i as defineState, j as defineWorkflow } from './state-CmpqDrnz.mjs';
2
-
3
- type RetryConfig = {
4
- maxRetries?: number;
5
- retryDelay?: number;
6
- backOffRate?: number;
7
- };
8
- type StepOptions = RetryConfig & {
9
- name?: string;
10
- };
11
- type StepFunction<Args extends unknown[], R> = (...args: Args) => Promise<R> | R;
12
- type StepDefinition<TArgs extends unknown[], TReturn> = {
13
- fn: StepFunction<TArgs, TReturn>;
14
- args: TArgs;
15
- options: StepOptions;
16
- };
17
- declare function defineStep<TArgs extends unknown[], TReturn>(fn: StepFunction<TArgs, TReturn>, options?: StepOptions): (...args: TArgs) => StepDefinition<TArgs, TReturn>;
18
-
19
- export { type RetryConfig, type StepDefinition, type StepFunction, defineStep };