@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/storage/memory.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* all state in-process with no persistence or multi-process safety guarantees.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { generateId } from
|
|
9
|
+
import { generateId } from '../utils/id';
|
|
10
10
|
import type {
|
|
11
11
|
StorageAdapter,
|
|
12
12
|
WorkflowRunRecord,
|
|
@@ -15,7 +15,7 @@ import type {
|
|
|
15
15
|
ListRunsOptions,
|
|
16
16
|
ListEventsOptions,
|
|
17
17
|
PaginatedResult,
|
|
18
|
-
} from
|
|
18
|
+
} from './types';
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* In-memory implementation of StorageAdapter.
|
|
@@ -40,9 +40,7 @@ export class MemoryStorageAdapter implements StorageAdapter {
|
|
|
40
40
|
// ============================================================================
|
|
41
41
|
|
|
42
42
|
/** Create and persist a new workflow run record. */
|
|
43
|
-
async createRun(
|
|
44
|
-
run: Omit<WorkflowRunRecord, "id" | "createdAt">,
|
|
45
|
-
): Promise<WorkflowRunRecord> {
|
|
43
|
+
async createRun(run: Omit<WorkflowRunRecord, 'id' | 'createdAt'>): Promise<WorkflowRunRecord> {
|
|
46
44
|
const record: WorkflowRunRecord = {
|
|
47
45
|
...run,
|
|
48
46
|
id: generateId(),
|
|
@@ -58,10 +56,7 @@ export class MemoryStorageAdapter implements StorageAdapter {
|
|
|
58
56
|
}
|
|
59
57
|
|
|
60
58
|
/** Apply partial updates to an existing workflow run. No-op if the run does not exist. */
|
|
61
|
-
async updateRun(
|
|
62
|
-
runId: string,
|
|
63
|
-
updates: Partial<WorkflowRunRecord>,
|
|
64
|
-
): Promise<void> {
|
|
59
|
+
async updateRun(runId: string, updates: Partial<WorkflowRunRecord>): Promise<void> {
|
|
65
60
|
const run = this.runs.get(runId);
|
|
66
61
|
if (run) {
|
|
67
62
|
Object.assign(run, updates);
|
|
@@ -69,36 +64,32 @@ export class MemoryStorageAdapter implements StorageAdapter {
|
|
|
69
64
|
}
|
|
70
65
|
|
|
71
66
|
/** List workflow runs with optional filtering, sorting, and pagination. */
|
|
72
|
-
async listRuns(
|
|
73
|
-
options: ListRunsOptions = {},
|
|
74
|
-
): Promise<PaginatedResult<WorkflowRunRecord>> {
|
|
67
|
+
async listRuns(options: ListRunsOptions = {}): Promise<PaginatedResult<WorkflowRunRecord>> {
|
|
75
68
|
let items = Array.from(this.runs.values());
|
|
76
69
|
|
|
77
70
|
// Filter by kind
|
|
78
71
|
if (options.kind) {
|
|
79
|
-
items = items.filter(
|
|
72
|
+
items = items.filter(r => r.kind === options.kind);
|
|
80
73
|
}
|
|
81
74
|
|
|
82
75
|
// Filter by status
|
|
83
76
|
if (options.status) {
|
|
84
|
-
const statuses = Array.isArray(options.status)
|
|
85
|
-
|
|
86
|
-
: [options.status];
|
|
87
|
-
items = items.filter((r) => statuses.includes(r.status));
|
|
77
|
+
const statuses = Array.isArray(options.status) ? options.status : [options.status];
|
|
78
|
+
items = items.filter(r => statuses.includes(r.status));
|
|
88
79
|
}
|
|
89
80
|
|
|
90
81
|
// Filter by parentRunId
|
|
91
82
|
if (options.parentRunId !== undefined) {
|
|
92
|
-
items = items.filter(
|
|
83
|
+
items = items.filter(r => r.parentRunId === options.parentRunId);
|
|
93
84
|
}
|
|
94
85
|
|
|
95
86
|
// Sort
|
|
96
|
-
const orderBy = options.orderBy ??
|
|
97
|
-
const direction = options.orderDirection ??
|
|
87
|
+
const orderBy = options.orderBy ?? 'createdAt';
|
|
88
|
+
const direction = options.orderDirection ?? 'desc';
|
|
98
89
|
items.sort((a, b) => {
|
|
99
90
|
const aVal = a[orderBy]?.getTime() ?? 0;
|
|
100
91
|
const bVal = b[orderBy]?.getTime() ?? 0;
|
|
101
|
-
return direction ===
|
|
92
|
+
return direction === 'asc' ? aVal - bVal : bVal - aVal;
|
|
102
93
|
});
|
|
103
94
|
|
|
104
95
|
const total = items.length;
|
|
@@ -115,9 +106,7 @@ export class MemoryStorageAdapter implements StorageAdapter {
|
|
|
115
106
|
// ============================================================================
|
|
116
107
|
|
|
117
108
|
/** Create and persist a new step execution record. */
|
|
118
|
-
async createStep(
|
|
119
|
-
step: Omit<WorkflowRunStepRecord, "id">,
|
|
120
|
-
): Promise<WorkflowRunStepRecord> {
|
|
109
|
+
async createStep(step: Omit<WorkflowRunStepRecord, 'id'>): Promise<WorkflowRunStepRecord> {
|
|
121
110
|
const record: WorkflowRunStepRecord = {
|
|
122
111
|
...step,
|
|
123
112
|
id: generateId(),
|
|
@@ -132,10 +121,7 @@ export class MemoryStorageAdapter implements StorageAdapter {
|
|
|
132
121
|
}
|
|
133
122
|
|
|
134
123
|
/** Apply partial updates to an existing step record. No-op if the step does not exist. */
|
|
135
|
-
async updateStep(
|
|
136
|
-
stepId: string,
|
|
137
|
-
updates: Partial<WorkflowRunStepRecord>,
|
|
138
|
-
): Promise<void> {
|
|
124
|
+
async updateStep(stepId: string, updates: Partial<WorkflowRunStepRecord>): Promise<void> {
|
|
139
125
|
const step = this.steps.get(stepId);
|
|
140
126
|
if (step) {
|
|
141
127
|
Object.assign(step, updates);
|
|
@@ -145,10 +131,8 @@ export class MemoryStorageAdapter implements StorageAdapter {
|
|
|
145
131
|
/** Retrieve all step records for a workflow run, ordered by start time ascending. */
|
|
146
132
|
async getStepsForRun(runId: string): Promise<WorkflowRunStepRecord[]> {
|
|
147
133
|
return Array.from(this.steps.values())
|
|
148
|
-
.filter(
|
|
149
|
-
.sort(
|
|
150
|
-
(a, b) => (a.startedAt?.getTime() ?? 0) - (b.startedAt?.getTime() ?? 0),
|
|
151
|
-
);
|
|
134
|
+
.filter(s => s.runId === runId)
|
|
135
|
+
.sort((a, b) => (a.startedAt?.getTime() ?? 0) - (b.startedAt?.getTime() ?? 0));
|
|
152
136
|
}
|
|
153
137
|
|
|
154
138
|
// ============================================================================
|
|
@@ -156,7 +140,7 @@ export class MemoryStorageAdapter implements StorageAdapter {
|
|
|
156
140
|
// ============================================================================
|
|
157
141
|
|
|
158
142
|
/** Persist a workflow event record. */
|
|
159
|
-
async saveEvent(event: Omit<WorkflowEventRecord,
|
|
143
|
+
async saveEvent(event: Omit<WorkflowEventRecord, 'id'>): Promise<void> {
|
|
160
144
|
const record: WorkflowEventRecord = {
|
|
161
145
|
...event,
|
|
162
146
|
id: generateId(),
|
|
@@ -165,22 +149,17 @@ export class MemoryStorageAdapter implements StorageAdapter {
|
|
|
165
149
|
}
|
|
166
150
|
|
|
167
151
|
/** Retrieve events for a workflow run with optional filtering and pagination. */
|
|
168
|
-
async getEventsForRun(
|
|
169
|
-
runId
|
|
170
|
-
options: ListEventsOptions = {},
|
|
171
|
-
): Promise<WorkflowEventRecord[]> {
|
|
172
|
-
let items = Array.from(this.events.values()).filter(
|
|
173
|
-
(e) => e.runId === runId,
|
|
174
|
-
);
|
|
152
|
+
async getEventsForRun(runId: string, options: ListEventsOptions = {}): Promise<WorkflowEventRecord[]> {
|
|
153
|
+
let items = Array.from(this.events.values()).filter(e => e.runId === runId);
|
|
175
154
|
|
|
176
155
|
// Filter by step
|
|
177
156
|
if (options.stepKey) {
|
|
178
|
-
items = items.filter(
|
|
157
|
+
items = items.filter(e => e.stepKey === options.stepKey);
|
|
179
158
|
}
|
|
180
159
|
|
|
181
160
|
// Filter by level
|
|
182
161
|
if (options.level) {
|
|
183
|
-
items = items.filter(
|
|
162
|
+
items = items.filter(e => e.level === options.level);
|
|
184
163
|
}
|
|
185
164
|
|
|
186
165
|
// Sort by timestamp
|