@usehelical/workflows 0.0.1-alpha.3 → 0.0.1-alpha.5
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.
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
|
-
import { W as
|
|
2
|
-
|
|
3
|
-
interface Run<TReturn = unknown> {
|
|
4
|
-
id: string;
|
|
5
|
-
status: () => Promise<WorkflowStatus>;
|
|
6
|
-
result: () => Promise<TReturn>;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
type RunWorkflowOptions = {
|
|
10
|
-
timeout?: number;
|
|
11
|
-
deadline?: number;
|
|
12
|
-
};
|
|
1
|
+
import { W as WorkflowEntry, Q as QueueEntry, R as RunWorkflowOptions, a as Run, M as MessageDefinition, S as StateDefinition } from './state-DmLPhezR.js';
|
|
13
2
|
|
|
14
3
|
type QueueWorkflowOptions = {
|
|
15
4
|
timeout?: number;
|
|
@@ -34,6 +34,17 @@ declare function defineWorkflow<TArgs extends unknown[], TReturn>(fn: WorkflowFu
|
|
|
34
34
|
}): () => WorkflowDefinition<TArgs, TReturn>;
|
|
35
35
|
type WorkflowEntry<TArgs extends unknown[] = unknown[], TReturn = unknown> = () => WorkflowDefinition<TArgs, TReturn>;
|
|
36
36
|
|
|
37
|
+
interface Run<TReturn = unknown> {
|
|
38
|
+
id: string;
|
|
39
|
+
status: () => Promise<WorkflowStatus>;
|
|
40
|
+
result: () => Promise<TReturn>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
type RunWorkflowOptions = {
|
|
44
|
+
timeout?: number;
|
|
45
|
+
deadline?: number;
|
|
46
|
+
};
|
|
47
|
+
|
|
37
48
|
type MessageDefinition<T> = {
|
|
38
49
|
name: string;
|
|
39
50
|
data?: T;
|
|
@@ -46,4 +57,4 @@ interface StateDefinition<T> {
|
|
|
46
57
|
}
|
|
47
58
|
declare function defineState<T>(name: string): StateDefinition<T>;
|
|
48
59
|
|
|
49
|
-
export { type MessageDefinition as M, type QueueEntry as Q, type StateDefinition as S,
|
|
60
|
+
export { type MessageDefinition as M, type QueueEntry as Q, type RunWorkflowOptions as R, type StateDefinition as S, type WorkflowEntry as W, type Run as a, type QueueDefinition as b, type QueueOptions as c, type QueueRateLimit as d, type WorkflowDefinition as e, type WorkflowFunction as f, WorkflowStatus as g, defineMessage as h, defineQueue as i, defineState as j, defineWorkflow as k };
|
package/dist/workflows.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { S as StateDefinition, M as MessageDefinition, W as WorkflowEntry, R as RunWorkflowOptions, a as Run } from './state-DmLPhezR.js';
|
|
2
|
+
export { b as QueueDefinition, Q as QueueEntry, c as QueueOptions, d as QueueRateLimit, e as WorkflowDefinition, f as WorkflowFunction, g as WorkflowStatus, h as defineMessage, i as defineQueue, j as defineState, k as defineWorkflow } from './state-DmLPhezR.js';
|
|
2
3
|
|
|
3
4
|
type RetryConfig = {
|
|
4
5
|
maxRetries?: number;
|
|
@@ -16,4 +17,34 @@ type StepDefinition<TArgs extends unknown[], TReturn> = {
|
|
|
16
17
|
};
|
|
17
18
|
declare function defineStep<TArgs extends unknown[], TReturn>(fn: StepFunction<TArgs, TReturn>, options?: StepOptions): (...args: TArgs) => StepDefinition<TArgs, TReturn>;
|
|
18
19
|
|
|
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>;
|
|
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
|
+
declare function sleep(ms: number): Promise<void>;
|
|
44
|
+
declare function cancellableSleep(ms: number, signal?: AbortSignal): Promise<void>;
|
|
45
|
+
|
|
46
|
+
declare function randomUUID(): Promise<string | undefined>;
|
|
47
|
+
|
|
48
|
+
declare function runWorkflow<TArgs extends unknown[], TReturn>(wf: WorkflowEntry<TArgs, TReturn> | string, args?: TArgs, options?: RunWorkflowOptions): Promise<Run<TReturn>>;
|
|
49
|
+
|
|
50
|
+
export { MessageDefinition, type RetryConfig, StateDefinition, type StepDefinition, type StepFunction, WorkflowEntry, cancellableSleep, defineStep, executeStepWithRetries, getAbortSignal, getRunId, getStepId, randomUUID, receiveMessage, runStep, runWorkflow, setState, sleep };
|
package/dist/workflows.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usehelical/workflows",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.5",
|
|
4
4
|
"description": "simple typesage durable workflows without magic",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@electric-sql/pglite": "^0.3.15",
|
|
42
42
|
"@eslint/js": "^9.39.2",
|
|
43
|
+
"@types/node": "^25.2.0",
|
|
43
44
|
"@types/pg": "^8.16.0",
|
|
44
45
|
"@vitest/coverage-v8": "^4.0.18",
|
|
45
46
|
"eslint": "^9.39.2",
|