@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
@@ -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 "../utils/id";
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 "./types";
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((r) => r.kind === options.kind);
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
- ? options.status
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((r) => r.parentRunId === options.parentRunId);
83
+ items = items.filter(r => r.parentRunId === options.parentRunId);
93
84
  }
94
85
 
95
86
  // Sort
96
- const orderBy = options.orderBy ?? "createdAt";
97
- const direction = options.orderDirection ?? "desc";
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 === "asc" ? aVal - bVal : bVal - aVal;
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((s) => s.runId === runId)
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, "id">): Promise<void> {
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: string,
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((e) => e.stepKey === options.stepKey);
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((e) => e.level === options.level);
162
+ items = items.filter(e => e.level === options.level);
184
163
  }
185
164
 
186
165
  // Sort by timestamp