@multiplier-labs/stepflow 0.3.1 → 0.3.3

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 (84) hide show
  1. package/.codekin/reports/comments/2026-04-04_comment-assessment.md +179 -0
  2. package/.codekin/reports/complexity/2026-04-03_complexity-report.md +152 -0
  3. package/.codekin/reports/dependencies/2026-04-04_dependency-health.md +94 -0
  4. package/.codekin/reports/docs-audit/2026-04-04_docs-audit.md +10 -0
  5. package/.codekin/reports/security/2026-04-03_security-audit.md +208 -0
  6. package/.github/CODEOWNERS +15 -0
  7. package/.github/dependabot.yml +23 -0
  8. package/.github/workflows/ci.yml +38 -0
  9. package/.github/workflows/publish.yml +11 -5
  10. package/.github/workflows/security.yml +29 -0
  11. package/CHANGELOG.md +34 -0
  12. package/README.md +24 -0
  13. package/SECURITY.md +40 -0
  14. package/dist/{chunk-FQCT3I2A.js → chunk-4VOKMGP6.js} +23 -42
  15. package/dist/chunk-4VOKMGP6.js.map +1 -0
  16. package/dist/{chunk-XCF4PLN7.js → chunk-GYPNJBDP.js} +12 -16
  17. package/dist/chunk-GYPNJBDP.js.map +1 -0
  18. package/dist/{chunk-U5QGN3RT.js → chunk-KHTUWLVZ.js} +14 -47
  19. package/dist/chunk-KHTUWLVZ.js.map +1 -0
  20. package/dist/{chunk-GXY66V7Q.js → chunk-ML35PIHX.js} +1 -1
  21. package/dist/chunk-ML35PIHX.js.map +1 -0
  22. package/dist/events/index.d.ts +4 -4
  23. package/dist/events/index.js +1 -1
  24. package/dist/{index-CPfGsmrp.d.ts → index-Dzr437iW.d.ts} +6 -6
  25. package/dist/index.d.ts +14 -12
  26. package/dist/index.js +40 -82
  27. package/dist/index.js.map +1 -1
  28. package/dist/scheduler/index.d.ts +4 -4
  29. package/dist/scheduler/index.js +2 -2
  30. package/dist/storage/index.d.ts +13 -13
  31. package/dist/storage/index.js +2 -2
  32. package/dist/{types-BlwFEGzj.d.ts → types-DSEjiLMj.d.ts} +16 -15
  33. package/dist/{types-DzkEqnQJ.d.ts → types-DZUdWmCc.d.ts} +2 -2
  34. package/dist/{types-BVShq7zT.d.ts → types-K5Gjk3H_.d.ts} +4 -4
  35. package/docs/stepflow-api-reference.md +2 -3
  36. package/package.json +7 -6
  37. package/src/core/engine.test.ts +466 -522
  38. package/src/core/engine.ts +42 -67
  39. package/src/core/index.ts +3 -3
  40. package/src/core/orchestrator.ts +64 -83
  41. package/src/core/types.ts +7 -29
  42. package/src/events/index.ts +4 -4
  43. package/src/events/memory.test.ts +39 -41
  44. package/src/events/memory.ts +7 -10
  45. package/src/events/socketio.test.ts +112 -162
  46. package/src/events/socketio.ts +20 -27
  47. package/src/events/types.ts +16 -19
  48. package/src/events/webhook.test.ts +197 -235
  49. package/src/events/webhook.ts +44 -71
  50. package/src/index.ts +19 -19
  51. package/src/planning/index.ts +6 -3
  52. package/src/planning/planner.ts +66 -91
  53. package/src/planning/planning.test.ts +303 -366
  54. package/src/planning/registry.test.ts +204 -251
  55. package/src/planning/registry.ts +39 -43
  56. package/src/planning/types.ts +23 -27
  57. package/src/scheduler/cron.test.ts +141 -150
  58. package/src/scheduler/cron.ts +32 -67
  59. package/src/scheduler/index.ts +4 -14
  60. package/src/scheduler/postgres-persistence.ts +71 -99
  61. package/src/scheduler/sqlite-persistence.test.ts +96 -96
  62. package/src/scheduler/sqlite-persistence.ts +12 -19
  63. package/src/scheduler/types.ts +4 -9
  64. package/src/storage/index.ts +5 -5
  65. package/src/storage/memory.test.ts +133 -183
  66. package/src/storage/memory.ts +21 -42
  67. package/src/storage/postgres.ts +197 -393
  68. package/src/storage/sqlite.test.ts +154 -281
  69. package/src/storage/sqlite.ts +50 -85
  70. package/src/storage/types.ts +33 -58
  71. package/src/utils/errors.test.ts +78 -80
  72. package/src/utils/errors.ts +27 -57
  73. package/src/utils/id.ts +3 -3
  74. package/src/utils/index.ts +4 -4
  75. package/src/utils/logger.test.ts +52 -58
  76. package/src/utils/logger.ts +4 -4
  77. package/src/utils/postgres-deps.ts +4 -4
  78. package/src/utils/retry.test.ts +47 -67
  79. package/src/utils/retry.ts +9 -9
  80. package/dist/chunk-FQCT3I2A.js.map +0 -1
  81. package/dist/chunk-GXY66V7Q.js.map +0 -1
  82. package/dist/chunk-U5QGN3RT.js.map +0 -1
  83. package/dist/chunk-XCF4PLN7.js.map +0 -1
  84. package/src/scheduler/postgres-persistence.test.ts +0 -906
@@ -5,13 +5,8 @@
5
5
  * Clients can subscribe to specific run IDs or receive all events.
6
6
  */
7
7
 
8
- import type {
9
- EventTransport,
10
- EventCallback,
11
- Unsubscribe,
12
- WorkflowEvent,
13
- } from "./types";
14
- import type { Logger } from "../core/types";
8
+ import type { EventTransport, EventCallback, Unsubscribe, WorkflowEvent } from './types';
9
+ import type { Logger } from '../core/types';
15
10
 
16
11
  /**
17
12
  * Minimal Socket.IO Server interface.
@@ -39,7 +34,7 @@ export interface SocketIOSocket {
39
34
  */
40
35
  export type SocketIOAuthorizeFn = (
41
36
  runId: string,
42
- socket: SocketIOSocket,
37
+ socket: SocketIOSocket
43
38
  ) => boolean | Promise<boolean>;
44
39
 
45
40
  /**
@@ -100,17 +95,15 @@ export class SocketIOEventTransport implements EventTransport {
100
95
 
101
96
  constructor(config: SocketIOEventTransportConfig) {
102
97
  this.io = config.io;
103
- this.eventName = config.eventName ?? "workflow:event";
104
- this.roomPrefix = config.roomPrefix ?? "run:";
98
+ this.eventName = config.eventName ?? 'workflow:event';
99
+ this.roomPrefix = config.roomPrefix ?? 'run:';
105
100
  this.broadcastGlobal = config.broadcastGlobal ?? true;
106
- this.globalRoom = config.globalRoom ?? "workflow:all";
101
+ this.globalRoom = config.globalRoom ?? 'workflow:all';
107
102
  this.logger = config.logger ?? {
108
103
  debug() {},
109
104
  info() {},
110
105
  warn() {},
111
- error(message: string, ...args: unknown[]) {
112
- console.error(message, ...args);
113
- },
106
+ error(message: string, ...args: unknown[]) { console.error(message, ...args); },
114
107
  };
115
108
  }
116
109
 
@@ -140,7 +133,7 @@ export class SocketIOEventTransport implements EventTransport {
140
133
  try {
141
134
  callback(event);
142
135
  } catch (error) {
143
- this.logger.error("Event callback error:", error);
136
+ this.logger.error('Event callback error:', error);
144
137
  }
145
138
  }
146
139
  }
@@ -149,7 +142,7 @@ export class SocketIOEventTransport implements EventTransport {
149
142
  try {
150
143
  callback(event);
151
144
  } catch (error) {
152
- this.logger.error("Event callback error:", error);
145
+ this.logger.error('Event callback error:', error);
153
146
  }
154
147
  }
155
148
  }
@@ -207,12 +200,12 @@ export class SocketIOEventTransport implements EventTransport {
207
200
  */
208
201
  setupClientHandlers(
209
202
  socket: SocketIOSocket,
210
- authorize: SocketIOAuthorizeFn,
203
+ authorize: SocketIOAuthorizeFn
211
204
  ): void {
212
205
  // Subscribe to a specific run
213
- socket.on("workflow:subscribe", async (...args: unknown[]) => {
206
+ socket.on('workflow:subscribe', async (...args: unknown[]) => {
214
207
  const runId = args[0];
215
- if (typeof runId !== "string") return;
208
+ if (typeof runId !== 'string') return;
216
209
 
217
210
  try {
218
211
  const allowed = await authorize(runId, socket);
@@ -221,7 +214,7 @@ export class SocketIOEventTransport implements EventTransport {
221
214
  return;
222
215
  }
223
216
  } catch (error) {
224
- this.logger.error("Authorization check failed:", error);
217
+ this.logger.error('Authorization check failed:', error);
225
218
  return;
226
219
  }
227
220
 
@@ -229,23 +222,23 @@ export class SocketIOEventTransport implements EventTransport {
229
222
  });
230
223
 
231
224
  // Unsubscribe from a specific run
232
- socket.on("workflow:unsubscribe", (...args: unknown[]) => {
225
+ socket.on('workflow:unsubscribe', (...args: unknown[]) => {
233
226
  const runId = args[0];
234
- if (typeof runId === "string") {
227
+ if (typeof runId === 'string') {
235
228
  socket.leave(`${this.roomPrefix}${runId}`);
236
229
  }
237
230
  });
238
231
 
239
232
  // Subscribe to all events (requires authorization to pass with '*' as runId)
240
- socket.on("workflow:subscribe:all", async () => {
233
+ socket.on('workflow:subscribe:all', async () => {
241
234
  try {
242
- const allowed = await authorize("*", socket);
235
+ const allowed = await authorize('*', socket);
243
236
  if (!allowed) {
244
- this.logger.warn("Global subscription denied");
237
+ this.logger.warn('Global subscription denied');
245
238
  return;
246
239
  }
247
240
  } catch (error) {
248
- this.logger.error("Authorization check failed:", error);
241
+ this.logger.error('Authorization check failed:', error);
249
242
  return;
250
243
  }
251
244
 
@@ -253,7 +246,7 @@ export class SocketIOEventTransport implements EventTransport {
253
246
  });
254
247
 
255
248
  // Unsubscribe from all events
256
- socket.on("workflow:unsubscribe:all", () => {
249
+ socket.on('workflow:unsubscribe:all', () => {
257
250
  socket.leave(this.globalRoom);
258
251
  });
259
252
  }
@@ -2,7 +2,7 @@
2
2
  * Event system types for the workflow engine.
3
3
  */
4
4
 
5
- import type { WorkflowKind } from "../core/types";
5
+ import type { WorkflowKind } from '../core/types';
6
6
 
7
7
  // ============================================================================
8
8
  // Event Types
@@ -12,20 +12,20 @@ import type { WorkflowKind } from "../core/types";
12
12
  * Built-in event types emitted by the workflow engine.
13
13
  */
14
14
  export type BuiltInEventType =
15
- | "run.created"
16
- | "run.queued"
17
- | "run.dequeued"
18
- | "run.started"
19
- | "run.resumed"
20
- | "run.completed"
21
- | "run.failed"
22
- | "run.canceled"
23
- | "run.timeout"
24
- | "step.started"
25
- | "step.completed"
26
- | "step.failed"
27
- | "step.skipped"
28
- | "step.retry";
15
+ | 'run.created'
16
+ | 'run.queued'
17
+ | 'run.dequeued'
18
+ | 'run.started'
19
+ | 'run.resumed'
20
+ | 'run.completed'
21
+ | 'run.failed'
22
+ | 'run.canceled'
23
+ | 'run.timeout'
24
+ | 'step.started'
25
+ | 'step.completed'
26
+ | 'step.failed'
27
+ | 'step.skipped'
28
+ | 'step.retry';
29
29
 
30
30
  /**
31
31
  * Event types emitted by the workflow engine.
@@ -104,10 +104,7 @@ export interface EventTransport {
104
104
  * Optional: Filter events by type.
105
105
  * @returns Unsubscribe function
106
106
  */
107
- subscribeToType?(
108
- eventType: WorkflowEventType,
109
- callback: EventCallback,
110
- ): Unsubscribe;
107
+ subscribeToType?(eventType: WorkflowEventType, callback: EventCallback): Unsubscribe;
111
108
 
112
109
  /**
113
110
  * Optional: Persist event for later retrieval.