@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.
- package/.codekin/reports/comments/2026-04-04_comment-assessment.md +179 -0
- package/.codekin/reports/complexity/2026-04-03_complexity-report.md +152 -0
- package/.codekin/reports/dependencies/2026-04-04_dependency-health.md +94 -0
- package/.codekin/reports/docs-audit/2026-04-04_docs-audit.md +10 -0
- package/.codekin/reports/security/2026-04-03_security-audit.md +208 -0
- package/.github/CODEOWNERS +15 -0
- package/.github/dependabot.yml +23 -0
- package/.github/workflows/ci.yml +38 -0
- package/.github/workflows/publish.yml +11 -5
- package/.github/workflows/security.yml +29 -0
- package/CHANGELOG.md +34 -0
- package/README.md +24 -0
- package/SECURITY.md +40 -0
- package/dist/{chunk-FQCT3I2A.js → chunk-4VOKMGP6.js} +23 -42
- package/dist/chunk-4VOKMGP6.js.map +1 -0
- package/dist/{chunk-XCF4PLN7.js → chunk-GYPNJBDP.js} +12 -16
- package/dist/chunk-GYPNJBDP.js.map +1 -0
- package/dist/{chunk-U5QGN3RT.js → chunk-KHTUWLVZ.js} +14 -47
- package/dist/chunk-KHTUWLVZ.js.map +1 -0
- package/dist/{chunk-GXY66V7Q.js → chunk-ML35PIHX.js} +1 -1
- package/dist/chunk-ML35PIHX.js.map +1 -0
- package/dist/events/index.d.ts +4 -4
- package/dist/events/index.js +1 -1
- package/dist/{index-CPfGsmrp.d.ts → index-Dzr437iW.d.ts} +6 -6
- package/dist/index.d.ts +14 -12
- package/dist/index.js +40 -82
- package/dist/index.js.map +1 -1
- package/dist/scheduler/index.d.ts +4 -4
- package/dist/scheduler/index.js +2 -2
- package/dist/storage/index.d.ts +13 -13
- package/dist/storage/index.js +2 -2
- package/dist/{types-BlwFEGzj.d.ts → types-DSEjiLMj.d.ts} +16 -15
- package/dist/{types-DzkEqnQJ.d.ts → types-DZUdWmCc.d.ts} +2 -2
- package/dist/{types-BVShq7zT.d.ts → types-K5Gjk3H_.d.ts} +4 -4
- package/docs/stepflow-api-reference.md +2 -3
- package/package.json +7 -6
- package/src/core/engine.test.ts +466 -522
- package/src/core/engine.ts +42 -67
- package/src/core/index.ts +3 -3
- package/src/core/orchestrator.ts +64 -83
- package/src/core/types.ts +7 -29
- package/src/events/index.ts +4 -4
- package/src/events/memory.test.ts +39 -41
- package/src/events/memory.ts +7 -10
- package/src/events/socketio.test.ts +112 -162
- package/src/events/socketio.ts +20 -27
- package/src/events/types.ts +16 -19
- package/src/events/webhook.test.ts +197 -235
- package/src/events/webhook.ts +44 -71
- package/src/index.ts +19 -19
- package/src/planning/index.ts +6 -3
- package/src/planning/planner.ts +66 -91
- package/src/planning/planning.test.ts +303 -366
- package/src/planning/registry.test.ts +204 -251
- package/src/planning/registry.ts +39 -43
- package/src/planning/types.ts +23 -27
- package/src/scheduler/cron.test.ts +141 -150
- package/src/scheduler/cron.ts +32 -67
- package/src/scheduler/index.ts +4 -14
- package/src/scheduler/postgres-persistence.ts +71 -99
- package/src/scheduler/sqlite-persistence.test.ts +96 -96
- package/src/scheduler/sqlite-persistence.ts +12 -19
- package/src/scheduler/types.ts +4 -9
- package/src/storage/index.ts +5 -5
- package/src/storage/memory.test.ts +133 -183
- package/src/storage/memory.ts +21 -42
- package/src/storage/postgres.ts +197 -393
- package/src/storage/sqlite.test.ts +154 -281
- package/src/storage/sqlite.ts +50 -85
- package/src/storage/types.ts +33 -58
- package/src/utils/errors.test.ts +78 -80
- package/src/utils/errors.ts +27 -57
- package/src/utils/id.ts +3 -3
- package/src/utils/index.ts +4 -4
- package/src/utils/logger.test.ts +52 -58
- package/src/utils/logger.ts +4 -4
- package/src/utils/postgres-deps.ts +4 -4
- package/src/utils/retry.test.ts +47 -67
- package/src/utils/retry.ts +9 -9
- package/dist/chunk-FQCT3I2A.js.map +0 -1
- package/dist/chunk-GXY66V7Q.js.map +0 -1
- package/dist/chunk-U5QGN3RT.js.map +0 -1
- package/dist/chunk-XCF4PLN7.js.map +0 -1
- package/src/scheduler/postgres-persistence.test.ts +0 -906
package/src/events/socketio.ts
CHANGED
|
@@ -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
|
-
|
|
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 ??
|
|
104
|
-
this.roomPrefix = config.roomPrefix ??
|
|
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 ??
|
|
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(
|
|
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(
|
|
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(
|
|
206
|
+
socket.on('workflow:subscribe', async (...args: unknown[]) => {
|
|
214
207
|
const runId = args[0];
|
|
215
|
-
if (typeof runId !==
|
|
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(
|
|
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(
|
|
225
|
+
socket.on('workflow:unsubscribe', (...args: unknown[]) => {
|
|
233
226
|
const runId = args[0];
|
|
234
|
-
if (typeof runId ===
|
|
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(
|
|
233
|
+
socket.on('workflow:subscribe:all', async () => {
|
|
241
234
|
try {
|
|
242
|
-
const allowed = await authorize(
|
|
235
|
+
const allowed = await authorize('*', socket);
|
|
243
236
|
if (!allowed) {
|
|
244
|
-
this.logger.warn(
|
|
237
|
+
this.logger.warn('Global subscription denied');
|
|
245
238
|
return;
|
|
246
239
|
}
|
|
247
240
|
} catch (error) {
|
|
248
|
-
this.logger.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(
|
|
249
|
+
socket.on('workflow:unsubscribe:all', () => {
|
|
257
250
|
socket.leave(this.globalRoom);
|
|
258
251
|
});
|
|
259
252
|
}
|
package/src/events/types.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Event system types for the workflow engine.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import type { WorkflowKind } from
|
|
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
|
-
|
|
|
16
|
-
|
|
|
17
|
-
|
|
|
18
|
-
|
|
|
19
|
-
|
|
|
20
|
-
|
|
|
21
|
-
|
|
|
22
|
-
|
|
|
23
|
-
|
|
|
24
|
-
|
|
|
25
|
-
|
|
|
26
|
-
|
|
|
27
|
-
|
|
|
28
|
-
|
|
|
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.
|