awaitly 2.0.0 → 3.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.
Files changed (88) hide show
  1. package/dist/di-Biw_plBn.d.cts +15 -0
  2. package/dist/di-DxyH2N3i.d.ts +15 -0
  3. package/dist/durable.cjs +4670 -0
  4. package/dist/durable.cjs.map +1 -0
  5. package/dist/durable.d.cts +9 -0
  6. package/dist/durable.d.ts +9 -0
  7. package/dist/durable.js +4610 -0
  8. package/dist/durable.js.map +1 -0
  9. package/dist/{di-BbFFfO8y.d.ts → duration-BjVn3QpB.d.cts} +1 -15
  10. package/dist/{di-BDlT7InM.d.cts → duration-BjVn3QpB.d.ts} +1 -15
  11. package/dist/engine.cjs +4501 -0
  12. package/dist/engine.cjs.map +1 -0
  13. package/dist/engine.d.cts +113 -0
  14. package/dist/engine.d.ts +113 -0
  15. package/dist/engine.js +4474 -0
  16. package/dist/engine.js.map +1 -0
  17. package/dist/{errors-DtXvrCiO.d.cts → errors-sDSeaZBO.d.cts} +1 -1
  18. package/dist/{errors-DtXvrCiO.d.ts → errors-sDSeaZBO.d.ts} +1 -1
  19. package/dist/guards-CwQZro1F.d.ts +72 -0
  20. package/dist/guards-DhhOJZda.d.cts +72 -0
  21. package/dist/hitl-BnnnLzh2.d.cts +468 -0
  22. package/dist/hitl-pYfkQMv_.d.ts +468 -0
  23. package/dist/hitl.cjs +646 -0
  24. package/dist/hitl.cjs.map +1 -0
  25. package/dist/hitl.d.cts +440 -0
  26. package/dist/hitl.d.ts +440 -0
  27. package/dist/hitl.js +605 -0
  28. package/dist/hitl.js.map +1 -0
  29. package/dist/index-Bew12SZ8.d.ts +417 -0
  30. package/dist/index-Bwt-iz50.d.cts +417 -0
  31. package/dist/{types-B8NfNRGX.d.ts → index-Cv4K_3sZ.d.ts} +2 -1162
  32. package/dist/{types-BZ2f4MRR.d.cts → index-ICmfQi08.d.cts} +2 -1162
  33. package/dist/index.cjs.map +1 -1
  34. package/dist/index.d.cts +11 -1527
  35. package/dist/index.d.ts +11 -1527
  36. package/dist/persistence.cjs +552 -0
  37. package/dist/persistence.cjs.map +1 -0
  38. package/dist/persistence.d.cts +254 -0
  39. package/dist/persistence.d.ts +254 -0
  40. package/dist/persistence.js +499 -0
  41. package/dist/persistence.js.map +1 -0
  42. package/dist/reliability.cjs +1651 -0
  43. package/dist/reliability.cjs.map +1 -0
  44. package/dist/reliability.d.cts +1442 -0
  45. package/dist/reliability.d.ts +1442 -0
  46. package/dist/reliability.js +1589 -0
  47. package/dist/reliability.js.map +1 -0
  48. package/dist/result.d.cts +1 -1
  49. package/dist/result.d.ts +1 -1
  50. package/dist/run.cjs +2283 -0
  51. package/dist/run.cjs.map +1 -0
  52. package/dist/run.d.cts +90 -0
  53. package/dist/run.d.ts +90 -0
  54. package/dist/run.js +2247 -0
  55. package/dist/run.js.map +1 -0
  56. package/dist/saga.cjs +3699 -0
  57. package/dist/saga.cjs.map +1 -0
  58. package/dist/saga.d.cts +162 -0
  59. package/dist/saga.d.ts +162 -0
  60. package/dist/saga.js +3670 -0
  61. package/dist/saga.js.map +1 -0
  62. package/dist/store-contract-BI98VYmX.d.ts +66 -0
  63. package/dist/store-contract-C2HyR_o6.d.cts +66 -0
  64. package/dist/streaming.cjs +895 -0
  65. package/dist/streaming.cjs.map +1 -0
  66. package/dist/streaming.d.cts +594 -0
  67. package/dist/streaming.d.ts +594 -0
  68. package/dist/streaming.js +832 -0
  69. package/dist/streaming.js.map +1 -0
  70. package/dist/testing.d.cts +4 -2
  71. package/dist/testing.d.ts +4 -2
  72. package/dist/types-BDTxgKKc.d.ts +845 -0
  73. package/dist/types-C9Y71dua.d.cts +845 -0
  74. package/dist/types-d8q8iQlk.d.cts +323 -0
  75. package/dist/types-sObbY4mX.d.ts +323 -0
  76. package/dist/webhook.cjs +461 -0
  77. package/dist/webhook.cjs.map +1 -0
  78. package/dist/webhook.d.cts +497 -0
  79. package/dist/webhook.d.ts +497 -0
  80. package/dist/webhook.js +422 -0
  81. package/dist/webhook.js.map +1 -0
  82. package/dist/workflow.cjs +2 -2614
  83. package/dist/workflow.cjs.map +1 -1
  84. package/dist/workflow.d.cts +12 -3023
  85. package/dist/workflow.d.ts +12 -3023
  86. package/dist/workflow.js +2 -2535
  87. package/dist/workflow.js.map +1 -1
  88. package/package.json +46 -1
@@ -0,0 +1,113 @@
1
+ import { S as SnapshotStore, c as AnyResultFn, d as WorkflowContext } from './types-C9Y71dua.cjs';
2
+ import { a as RunStep } from './index-ICmfQi08.cjs';
3
+ import { D as DurableOptions } from './index-Bwt-iz50.cjs';
4
+ import './types-d8q8iQlk.cjs';
5
+ import '@standard-schema/spec';
6
+ import './errors-sDSeaZBO.cjs';
7
+
8
+ /** A registered workflow definition */
9
+ interface WorkflowRegistration<Deps extends Readonly<Record<string, AnyResultFn>> = Readonly<Record<string, AnyResultFn>>> {
10
+ /** Workflow dependencies (Result-returning functions) */
11
+ deps: Deps;
12
+ /** Workflow function */
13
+ fn: (context: {
14
+ step: RunStep<any>;
15
+ deps: Deps;
16
+ ctx: WorkflowContext;
17
+ }) => any;
18
+ /** Default durable options (version, lockTtlMs, etc.) */
19
+ durableDefaults?: Partial<Pick<DurableOptions, 'version' | 'lockTtlMs' | 'heartbeatIntervalMs'>>;
20
+ }
21
+ interface EnqueueOptions {
22
+ /** Custom workflow execution ID (default: auto-generated UUID) */
23
+ id?: string;
24
+ /** Idempotency key for deduplication */
25
+ idempotencyKey?: string;
26
+ /** Workflow input for idempotency conflict detection */
27
+ input?: unknown;
28
+ /** Custom metadata */
29
+ metadata?: Record<string, unknown>;
30
+ }
31
+ interface ScheduleOptions {
32
+ /** Repeat interval in milliseconds */
33
+ intervalMs: number;
34
+ /** Run immediately on schedule creation */
35
+ immediate?: boolean;
36
+ }
37
+ interface EngineOptions {
38
+ /** Snapshot store for workflow persistence */
39
+ store: SnapshotStore;
40
+ /** Registered workflows keyed by name */
41
+ workflows: Record<string, WorkflowRegistration>;
42
+ /** Max parallel workflow runs per tick (default: 5) */
43
+ concurrency?: number;
44
+ /** Event handler */
45
+ onEvent?: (event: EngineEvent) => void;
46
+ /** Error handler for background operations */
47
+ onError?: (error: unknown) => void;
48
+ }
49
+ type EngineEvent = {
50
+ type: "engine_start";
51
+ ts: number;
52
+ } | {
53
+ type: "engine_stop";
54
+ ts: number;
55
+ } | {
56
+ type: "engine_tick";
57
+ ts: number;
58
+ processed: number;
59
+ } | {
60
+ type: "workflow_enqueued";
61
+ workflowName: string;
62
+ id: string;
63
+ ts: number;
64
+ } | {
65
+ type: "workflow_started";
66
+ workflowName: string;
67
+ id: string;
68
+ ts: number;
69
+ } | {
70
+ type: "workflow_completed";
71
+ workflowName: string;
72
+ id: string;
73
+ ts: number;
74
+ } | {
75
+ type: "workflow_failed";
76
+ workflowName: string;
77
+ id: string;
78
+ error: unknown;
79
+ ts: number;
80
+ } | {
81
+ type: "schedule_created";
82
+ workflowName: string;
83
+ scheduleId: string;
84
+ intervalMs: number;
85
+ ts: number;
86
+ } | {
87
+ type: "schedule_removed";
88
+ scheduleId: string;
89
+ ts: number;
90
+ };
91
+ interface Engine {
92
+ /** Enqueue a workflow for execution. Returns the workflow execution ID. */
93
+ enqueue(name: string, options?: EnqueueOptions): Promise<string>;
94
+ /** Schedule recurring workflow execution. Returns the schedule ID. */
95
+ schedule(name: string, options: ScheduleOptions & EnqueueOptions): string;
96
+ /** Remove a schedule */
97
+ unschedule(scheduleId: string): boolean;
98
+ /** Start the polling loop */
99
+ start(pollIntervalMs?: number): void;
100
+ /** Stop the polling loop gracefully */
101
+ stop(): Promise<void>;
102
+ /** Execute a single tick manually (process pending workflows). Returns number processed. */
103
+ tick(): Promise<number>;
104
+ /** Get engine status */
105
+ status(): {
106
+ running: boolean;
107
+ pendingSchedules: number;
108
+ };
109
+ }
110
+
111
+ declare function createEngine(options: EngineOptions): Engine;
112
+
113
+ export { type Engine, type EngineEvent, type EngineOptions, type EnqueueOptions, type ScheduleOptions, type WorkflowRegistration, createEngine };
@@ -0,0 +1,113 @@
1
+ import { S as SnapshotStore, c as AnyResultFn, d as WorkflowContext } from './types-BDTxgKKc.js';
2
+ import { a as RunStep } from './index-Cv4K_3sZ.js';
3
+ import { D as DurableOptions } from './index-Bew12SZ8.js';
4
+ import './types-sObbY4mX.js';
5
+ import '@standard-schema/spec';
6
+ import './errors-sDSeaZBO.js';
7
+
8
+ /** A registered workflow definition */
9
+ interface WorkflowRegistration<Deps extends Readonly<Record<string, AnyResultFn>> = Readonly<Record<string, AnyResultFn>>> {
10
+ /** Workflow dependencies (Result-returning functions) */
11
+ deps: Deps;
12
+ /** Workflow function */
13
+ fn: (context: {
14
+ step: RunStep<any>;
15
+ deps: Deps;
16
+ ctx: WorkflowContext;
17
+ }) => any;
18
+ /** Default durable options (version, lockTtlMs, etc.) */
19
+ durableDefaults?: Partial<Pick<DurableOptions, 'version' | 'lockTtlMs' | 'heartbeatIntervalMs'>>;
20
+ }
21
+ interface EnqueueOptions {
22
+ /** Custom workflow execution ID (default: auto-generated UUID) */
23
+ id?: string;
24
+ /** Idempotency key for deduplication */
25
+ idempotencyKey?: string;
26
+ /** Workflow input for idempotency conflict detection */
27
+ input?: unknown;
28
+ /** Custom metadata */
29
+ metadata?: Record<string, unknown>;
30
+ }
31
+ interface ScheduleOptions {
32
+ /** Repeat interval in milliseconds */
33
+ intervalMs: number;
34
+ /** Run immediately on schedule creation */
35
+ immediate?: boolean;
36
+ }
37
+ interface EngineOptions {
38
+ /** Snapshot store for workflow persistence */
39
+ store: SnapshotStore;
40
+ /** Registered workflows keyed by name */
41
+ workflows: Record<string, WorkflowRegistration>;
42
+ /** Max parallel workflow runs per tick (default: 5) */
43
+ concurrency?: number;
44
+ /** Event handler */
45
+ onEvent?: (event: EngineEvent) => void;
46
+ /** Error handler for background operations */
47
+ onError?: (error: unknown) => void;
48
+ }
49
+ type EngineEvent = {
50
+ type: "engine_start";
51
+ ts: number;
52
+ } | {
53
+ type: "engine_stop";
54
+ ts: number;
55
+ } | {
56
+ type: "engine_tick";
57
+ ts: number;
58
+ processed: number;
59
+ } | {
60
+ type: "workflow_enqueued";
61
+ workflowName: string;
62
+ id: string;
63
+ ts: number;
64
+ } | {
65
+ type: "workflow_started";
66
+ workflowName: string;
67
+ id: string;
68
+ ts: number;
69
+ } | {
70
+ type: "workflow_completed";
71
+ workflowName: string;
72
+ id: string;
73
+ ts: number;
74
+ } | {
75
+ type: "workflow_failed";
76
+ workflowName: string;
77
+ id: string;
78
+ error: unknown;
79
+ ts: number;
80
+ } | {
81
+ type: "schedule_created";
82
+ workflowName: string;
83
+ scheduleId: string;
84
+ intervalMs: number;
85
+ ts: number;
86
+ } | {
87
+ type: "schedule_removed";
88
+ scheduleId: string;
89
+ ts: number;
90
+ };
91
+ interface Engine {
92
+ /** Enqueue a workflow for execution. Returns the workflow execution ID. */
93
+ enqueue(name: string, options?: EnqueueOptions): Promise<string>;
94
+ /** Schedule recurring workflow execution. Returns the schedule ID. */
95
+ schedule(name: string, options: ScheduleOptions & EnqueueOptions): string;
96
+ /** Remove a schedule */
97
+ unschedule(scheduleId: string): boolean;
98
+ /** Start the polling loop */
99
+ start(pollIntervalMs?: number): void;
100
+ /** Stop the polling loop gracefully */
101
+ stop(): Promise<void>;
102
+ /** Execute a single tick manually (process pending workflows). Returns number processed. */
103
+ tick(): Promise<number>;
104
+ /** Get engine status */
105
+ status(): {
106
+ running: boolean;
107
+ pendingSchedules: number;
108
+ };
109
+ }
110
+
111
+ declare function createEngine(options: EngineOptions): Engine;
112
+
113
+ export { type Engine, type EngineEvent, type EngineOptions, type EnqueueOptions, type ScheduleOptions, type WorkflowRegistration, createEngine };