@multiplier-labs/stepflow 0.3.3 → 0.3.6

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/README.md +9 -0
  2. package/dist/{chunk-GYPNJBDP.js → chunk-D5HW7VEG.js} +269 -48
  3. package/dist/chunk-D5HW7VEG.js.map +1 -0
  4. package/dist/{chunk-KHTUWLVZ.js → chunk-FMPJBK2N.js} +55 -10
  5. package/dist/chunk-FMPJBK2N.js.map +1 -0
  6. package/dist/{chunk-ML35PIHX.js → chunk-JPXPB7U5.js} +52 -2
  7. package/dist/chunk-JPXPB7U5.js.map +1 -0
  8. package/dist/{chunk-4VOKMGP6.js → chunk-JUPZEBR3.js} +519 -522
  9. package/dist/chunk-JUPZEBR3.js.map +1 -0
  10. package/dist/events/index.d.ts +58 -3
  11. package/dist/events/index.js +1 -1
  12. package/dist/{index-Dzr437iW.d.ts → index-Cd0IZ40L.d.ts} +50 -11
  13. package/dist/index.d.ts +2 -12
  14. package/dist/index.js +764 -485
  15. package/dist/index.js.map +1 -1
  16. package/dist/scheduler/index.d.ts +1 -1
  17. package/dist/scheduler/index.js +2 -2
  18. package/dist/storage/index.d.ts +313 -47
  19. package/dist/storage/index.js +4 -2
  20. package/package.json +27 -13
  21. package/.codekin/reports/comments/2026-04-04_comment-assessment.md +0 -179
  22. package/.codekin/reports/complexity/2026-04-03_complexity-report.md +0 -152
  23. package/.codekin/reports/dependencies/2026-04-04_dependency-health.md +0 -94
  24. package/.codekin/reports/docs-audit/2026-04-04_docs-audit.md +0 -10
  25. package/.codekin/reports/security/2026-04-03_security-audit.md +0 -208
  26. package/.github/CODEOWNERS +0 -15
  27. package/.github/dependabot.yml +0 -23
  28. package/.github/workflows/ci.yml +0 -38
  29. package/.github/workflows/publish.yml +0 -36
  30. package/.github/workflows/security.yml +0 -29
  31. package/CHANGELOG.md +0 -34
  32. package/SECURITY.md +0 -40
  33. package/dist/chunk-4VOKMGP6.js.map +0 -1
  34. package/dist/chunk-GYPNJBDP.js.map +0 -1
  35. package/dist/chunk-KHTUWLVZ.js.map +0 -1
  36. package/dist/chunk-ML35PIHX.js.map +0 -1
  37. package/docs/github-packages-setup.md +0 -97
  38. package/docs/stepflow-api-reference.md +0 -1661
  39. package/src/core/engine.test.ts +0 -1365
  40. package/src/core/engine.ts +0 -692
  41. package/src/core/index.ts +0 -7
  42. package/src/core/orchestrator.ts +0 -571
  43. package/src/core/types.ts +0 -220
  44. package/src/events/index.ts +0 -8
  45. package/src/events/memory.test.ts +0 -107
  46. package/src/events/memory.ts +0 -92
  47. package/src/events/socketio.test.ts +0 -378
  48. package/src/events/socketio.ts +0 -262
  49. package/src/events/types.ts +0 -118
  50. package/src/events/webhook.test.ts +0 -657
  51. package/src/events/webhook.ts +0 -564
  52. package/src/index.ts +0 -270
  53. package/src/planning/index.ts +0 -55
  54. package/src/planning/planner.ts +0 -576
  55. package/src/planning/planning.test.ts +0 -727
  56. package/src/planning/registry.test.ts +0 -398
  57. package/src/planning/registry.ts +0 -365
  58. package/src/planning/types.ts +0 -566
  59. package/src/scheduler/cron.test.ts +0 -471
  60. package/src/scheduler/cron.ts +0 -414
  61. package/src/scheduler/index.ts +0 -8
  62. package/src/scheduler/postgres-persistence.ts +0 -518
  63. package/src/scheduler/sqlite-persistence.test.ts +0 -235
  64. package/src/scheduler/sqlite-persistence.ts +0 -261
  65. package/src/scheduler/types.ts +0 -73
  66. package/src/storage/index.ts +0 -27
  67. package/src/storage/memory.test.ts +0 -349
  68. package/src/storage/memory.ts +0 -227
  69. package/src/storage/postgres.ts +0 -1354
  70. package/src/storage/sqlite.test.ts +0 -466
  71. package/src/storage/sqlite.ts +0 -627
  72. package/src/storage/types.ts +0 -343
  73. package/src/utils/errors.test.ts +0 -150
  74. package/src/utils/errors.ts +0 -161
  75. package/src/utils/id.ts +0 -21
  76. package/src/utils/index.ts +0 -8
  77. package/src/utils/logger.test.ts +0 -121
  78. package/src/utils/logger.ts +0 -96
  79. package/src/utils/postgres-deps.ts +0 -63
  80. package/src/utils/retry.test.ts +0 -177
  81. package/src/utils/retry.ts +0 -121
  82. package/tsconfig.json +0 -21
  83. package/tsup.config.ts +0 -14
  84. package/vitest.config.ts +0 -9
@@ -1,235 +0,0 @@
1
- import { describe, it, expect, beforeEach, afterEach } from 'vitest';
2
- import Database from 'better-sqlite3';
3
- import { SQLiteSchedulePersistence } from './sqlite-persistence';
4
- import type { WorkflowSchedule } from './types';
5
-
6
- describe('SQLiteSchedulePersistence', () => {
7
- let db: Database.Database;
8
- let persistence: SQLiteSchedulePersistence;
9
-
10
- beforeEach(() => {
11
- // Use in-memory database for testing
12
- db = new Database(':memory:');
13
- persistence = new SQLiteSchedulePersistence({ db });
14
- });
15
-
16
- afterEach(() => {
17
- db.close();
18
- });
19
-
20
- describe('saveSchedule', () => {
21
- it('should save a cron schedule', async () => {
22
- const schedule: WorkflowSchedule = {
23
- id: 'test-1',
24
- workflowKind: 'test.workflow',
25
- triggerType: 'cron',
26
- cronExpression: '0 * * * *',
27
- timezone: 'UTC',
28
- enabled: true,
29
- input: { foo: 'bar' },
30
- metadata: { user: 'test' },
31
- };
32
-
33
- await persistence.saveSchedule(schedule);
34
-
35
- const loaded = await persistence.loadSchedules();
36
- expect(loaded).toHaveLength(1);
37
- expect(loaded[0].id).toBe('test-1');
38
- expect(loaded[0].cronExpression).toBe('0 * * * *');
39
- expect(loaded[0].input).toEqual({ foo: 'bar' });
40
- });
41
-
42
- it('should save a workflow completion trigger', async () => {
43
- const schedule: WorkflowSchedule = {
44
- id: 'test-2',
45
- workflowKind: 'notification.send',
46
- triggerType: 'workflow_completed',
47
- triggerOnWorkflowKind: 'order.process',
48
- triggerOnStatus: ['succeeded', 'failed'],
49
- enabled: true,
50
- };
51
-
52
- await persistence.saveSchedule(schedule);
53
-
54
- const loaded = await persistence.loadSchedules();
55
- expect(loaded).toHaveLength(1);
56
- expect(loaded[0].triggerType).toBe('workflow_completed');
57
- expect(loaded[0].triggerOnWorkflowKind).toBe('order.process');
58
- expect(loaded[0].triggerOnStatus).toEqual(['succeeded', 'failed']);
59
- });
60
-
61
- it('should save schedule with dates', async () => {
62
- const lastRunAt = new Date('2024-01-01T12:00:00Z');
63
- const nextRunAt = new Date('2024-01-01T13:00:00Z');
64
-
65
- const schedule: WorkflowSchedule = {
66
- id: 'test-3',
67
- workflowKind: 'test.workflow',
68
- triggerType: 'cron',
69
- cronExpression: '0 * * * *',
70
- enabled: true,
71
- lastRunAt,
72
- lastRunId: 'run-123',
73
- nextRunAt,
74
- };
75
-
76
- await persistence.saveSchedule(schedule);
77
-
78
- const loaded = await persistence.loadSchedules();
79
- expect(loaded[0].lastRunAt).toEqual(lastRunAt);
80
- expect(loaded[0].lastRunId).toBe('run-123');
81
- expect(loaded[0].nextRunAt).toEqual(nextRunAt);
82
- });
83
- });
84
-
85
- describe('loadSchedules', () => {
86
- it('should return empty array when no schedules', async () => {
87
- const schedules = await persistence.loadSchedules();
88
- expect(schedules).toHaveLength(0);
89
- });
90
-
91
- it('should load multiple schedules', async () => {
92
- await persistence.saveSchedule({
93
- id: 'schedule-1',
94
- workflowKind: 'workflow.a',
95
- triggerType: 'cron',
96
- cronExpression: '0 * * * *',
97
- enabled: true,
98
- });
99
-
100
- await persistence.saveSchedule({
101
- id: 'schedule-2',
102
- workflowKind: 'workflow.b',
103
- triggerType: 'manual',
104
- enabled: false,
105
- });
106
-
107
- const schedules = await persistence.loadSchedules();
108
- expect(schedules).toHaveLength(2);
109
- });
110
- });
111
-
112
- describe('updateSchedule', () => {
113
- it('should update enabled status', async () => {
114
- await persistence.saveSchedule({
115
- id: 'update-1',
116
- workflowKind: 'test.workflow',
117
- triggerType: 'cron',
118
- cronExpression: '0 * * * *',
119
- enabled: true,
120
- });
121
-
122
- await persistence.updateSchedule('update-1', { enabled: false });
123
-
124
- const loaded = await persistence.loadSchedules();
125
- expect(loaded[0].enabled).toBe(false);
126
- });
127
-
128
- it('should update cron expression', async () => {
129
- await persistence.saveSchedule({
130
- id: 'update-2',
131
- workflowKind: 'test.workflow',
132
- triggerType: 'cron',
133
- cronExpression: '0 * * * *',
134
- enabled: true,
135
- });
136
-
137
- await persistence.updateSchedule('update-2', {
138
- cronExpression: '30 * * * *',
139
- });
140
-
141
- const loaded = await persistence.loadSchedules();
142
- expect(loaded[0].cronExpression).toBe('30 * * * *');
143
- });
144
-
145
- it('should update lastRunAt and lastRunId', async () => {
146
- await persistence.saveSchedule({
147
- id: 'update-3',
148
- workflowKind: 'test.workflow',
149
- triggerType: 'cron',
150
- cronExpression: '0 * * * *',
151
- enabled: true,
152
- });
153
-
154
- const now = new Date();
155
- await persistence.updateSchedule('update-3', {
156
- lastRunAt: now,
157
- lastRunId: 'run-456',
158
- });
159
-
160
- const loaded = await persistence.loadSchedules();
161
- expect(loaded[0].lastRunAt).toEqual(now);
162
- expect(loaded[0].lastRunId).toBe('run-456');
163
- });
164
-
165
- it('should throw for non-existent schedule', async () => {
166
- await expect(
167
- persistence.updateSchedule('nonexistent', { enabled: false })
168
- ).rejects.toThrow('Schedule not found');
169
- });
170
- });
171
-
172
- describe('deleteSchedule', () => {
173
- it('should delete a schedule', async () => {
174
- await persistence.saveSchedule({
175
- id: 'delete-1',
176
- workflowKind: 'test.workflow',
177
- triggerType: 'cron',
178
- cronExpression: '0 * * * *',
179
- enabled: true,
180
- });
181
-
182
- await persistence.deleteSchedule('delete-1');
183
-
184
- const loaded = await persistence.loadSchedules();
185
- expect(loaded).toHaveLength(0);
186
- });
187
-
188
- it('should handle deleting non-existent schedule gracefully', async () => {
189
- // This should not throw
190
- await persistence.deleteSchedule('nonexistent');
191
- });
192
- });
193
-
194
- describe('data integrity', () => {
195
- it('should preserve all fields through save/load cycle', async () => {
196
- const schedule: WorkflowSchedule = {
197
- id: 'integrity-1',
198
- workflowKind: 'complex.workflow',
199
- triggerType: 'workflow_completed',
200
- triggerOnWorkflowKind: 'parent.workflow',
201
- triggerOnStatus: ['succeeded'],
202
- input: { nested: { value: 123 } },
203
- metadata: { tags: ['a', 'b'] },
204
- enabled: true,
205
- lastRunAt: new Date('2024-06-15T10:30:00Z'),
206
- lastRunId: 'run-789',
207
- nextRunAt: new Date('2024-06-15T11:00:00Z'),
208
- };
209
-
210
- await persistence.saveSchedule(schedule);
211
-
212
- const loaded = await persistence.loadSchedules();
213
- expect(loaded[0]).toEqual(schedule);
214
- });
215
-
216
- it('should handle null/undefined values correctly', async () => {
217
- const schedule: WorkflowSchedule = {
218
- id: 'nullable-1',
219
- workflowKind: 'test.workflow',
220
- triggerType: 'manual',
221
- enabled: false,
222
- // All other optional fields are undefined
223
- };
224
-
225
- await persistence.saveSchedule(schedule);
226
-
227
- const loaded = await persistence.loadSchedules();
228
- expect(loaded[0].cronExpression).toBeUndefined();
229
- expect(loaded[0].timezone).toBeUndefined();
230
- expect(loaded[0].input).toBeUndefined();
231
- expect(loaded[0].metadata).toBeUndefined();
232
- expect(loaded[0].lastRunAt).toBeUndefined();
233
- });
234
- });
235
- });
@@ -1,261 +0,0 @@
1
- /**
2
- * SQLite persistence adapter for schedules.
3
- *
4
- * Stores workflow schedules in a SQLite database table.
5
- */
6
-
7
- import type { Database, Statement } from 'better-sqlite3';
8
- import type { WorkflowSchedule } from './types';
9
- import type { SchedulePersistence } from './cron';
10
- import { generateId } from '../utils/id';
11
-
12
- // ============================================================================
13
- // Configuration Types
14
- // ============================================================================
15
-
16
- /**
17
- * Configuration for SQLiteSchedulePersistence.
18
- */
19
- export interface SQLiteSchedulePersistenceConfig {
20
- /** SQLite database instance */
21
- db: Database;
22
-
23
- /** Table name for schedules (default: workflow_schedules) */
24
- tableName?: string;
25
- }
26
-
27
- // ============================================================================
28
- // SQLiteSchedulePersistence Class
29
- // ============================================================================
30
-
31
- /**
32
- * SQLite-based persistence for workflow schedules.
33
- *
34
- * @example
35
- * ```typescript
36
- * import Database from 'better-sqlite3';
37
- *
38
- * const db = new Database('workflow.db');
39
- * const persistence = new SQLiteSchedulePersistence({ db });
40
- *
41
- * const scheduler = new CronScheduler({
42
- * engine,
43
- * persistence,
44
- * });
45
- * ```
46
- */
47
- export class SQLiteSchedulePersistence implements SchedulePersistence {
48
- private db: Database;
49
- private tableName: string;
50
- private stmts: {
51
- insert: Statement;
52
- update: Statement;
53
- delete: Statement;
54
- getAll: Statement;
55
- getById: Statement;
56
- } | null = null;
57
-
58
- constructor(config: SQLiteSchedulePersistenceConfig) {
59
- this.db = config.db;
60
- this.tableName = config.tableName ?? 'workflow_schedules';
61
- if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(this.tableName)) {
62
- throw new Error(`Invalid table name: ${this.tableName}`);
63
- }
64
- this.initializeDatabase();
65
- }
66
-
67
- // ============================================================================
68
- // Database Initialization
69
- // ============================================================================
70
-
71
- private initializeDatabase(): void {
72
- // Create schedules table.
73
- // Schema layout:
74
- // id — unique schedule identifier (TEXT PK)
75
- // workflow_kind — target workflow type to spawn
76
- // trigger_type — 'cron', 'workflow_completed', or 'manual'
77
- // cron_expression — cron expression for time-based triggers (nullable)
78
- // timezone — IANA timezone for cron evaluation (nullable)
79
- // trigger_on_* — fields for workflow-completion triggers
80
- // input / metadata — JSON-serialized payloads for spawned runs
81
- // enabled — whether this schedule is active (0/1)
82
- // last_run_at/id — most recent execution tracking
83
- // next_run_at — next scheduled execution time
84
- // created_at/updated_at — audit timestamps
85
- // No migration strategy is currently implemented; table is created idempotently.
86
- this.db.exec(`
87
- CREATE TABLE IF NOT EXISTS ${this.tableName} (
88
- id TEXT PRIMARY KEY,
89
- workflow_kind TEXT NOT NULL,
90
- trigger_type TEXT NOT NULL,
91
- cron_expression TEXT,
92
- timezone TEXT,
93
- trigger_on_workflow_kind TEXT,
94
- trigger_on_status TEXT,
95
- input TEXT,
96
- metadata TEXT,
97
- enabled INTEGER NOT NULL DEFAULT 1,
98
- last_run_at TEXT,
99
- last_run_id TEXT,
100
- next_run_at TEXT,
101
- created_at TEXT NOT NULL DEFAULT (datetime('now')),
102
- updated_at TEXT NOT NULL DEFAULT (datetime('now'))
103
- )
104
- `);
105
-
106
- // Create indexes
107
- this.db.exec(`
108
- CREATE INDEX IF NOT EXISTS idx_${this.tableName}_workflow_kind
109
- ON ${this.tableName}(workflow_kind);
110
-
111
- CREATE INDEX IF NOT EXISTS idx_${this.tableName}_enabled
112
- ON ${this.tableName}(enabled);
113
-
114
- CREATE INDEX IF NOT EXISTS idx_${this.tableName}_trigger_type
115
- ON ${this.tableName}(trigger_type);
116
- `);
117
-
118
- // Prepare statements
119
- this.stmts = {
120
- insert: this.db.prepare(`
121
- INSERT INTO ${this.tableName} (
122
- id, workflow_kind, trigger_type, cron_expression, timezone,
123
- trigger_on_workflow_kind, trigger_on_status, input, metadata,
124
- enabled, last_run_at, last_run_id, next_run_at
125
- ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
126
- `),
127
- update: this.db.prepare(`
128
- UPDATE ${this.tableName}
129
- SET workflow_kind = COALESCE(?, workflow_kind),
130
- trigger_type = COALESCE(?, trigger_type),
131
- cron_expression = ?,
132
- timezone = ?,
133
- trigger_on_workflow_kind = ?,
134
- trigger_on_status = ?,
135
- input = ?,
136
- metadata = ?,
137
- enabled = COALESCE(?, enabled),
138
- last_run_at = ?,
139
- last_run_id = ?,
140
- next_run_at = ?,
141
- updated_at = datetime('now')
142
- WHERE id = ?
143
- `),
144
- delete: this.db.prepare(`
145
- DELETE FROM ${this.tableName} WHERE id = ?
146
- `),
147
- getAll: this.db.prepare(`
148
- SELECT * FROM ${this.tableName}
149
- `),
150
- getById: this.db.prepare(`
151
- SELECT * FROM ${this.tableName} WHERE id = ?
152
- `),
153
- };
154
- }
155
-
156
- // ============================================================================
157
- // SchedulePersistence Interface Implementation
158
- // ============================================================================
159
-
160
- async loadSchedules(): Promise<WorkflowSchedule[]> {
161
- const rows = this.stmts!.getAll.all() as ScheduleRow[];
162
- return rows.map(row => this.rowToSchedule(row));
163
- }
164
-
165
- async saveSchedule(schedule: WorkflowSchedule): Promise<void> {
166
- this.stmts!.insert.run(
167
- schedule.id,
168
- schedule.workflowKind,
169
- schedule.triggerType,
170
- schedule.cronExpression ?? null,
171
- schedule.timezone ?? null,
172
- schedule.triggerOnWorkflowKind ?? null,
173
- schedule.triggerOnStatus ? JSON.stringify(schedule.triggerOnStatus) : null,
174
- schedule.input ? JSON.stringify(schedule.input) : null,
175
- schedule.metadata ? JSON.stringify(schedule.metadata) : null,
176
- schedule.enabled ? 1 : 0,
177
- schedule.lastRunAt?.toISOString() ?? null,
178
- schedule.lastRunId ?? null,
179
- schedule.nextRunAt?.toISOString() ?? null
180
- );
181
- }
182
-
183
- async updateSchedule(scheduleId: string, updates: Partial<WorkflowSchedule>): Promise<void> {
184
- // Get existing schedule to merge with updates
185
- const existing = this.stmts!.getById.get(scheduleId) as ScheduleRow | undefined;
186
- if (!existing) {
187
- throw new Error(`Schedule not found: ${scheduleId}`);
188
- }
189
-
190
- const merged = {
191
- ...this.rowToSchedule(existing),
192
- ...updates,
193
- };
194
-
195
- this.stmts!.update.run(
196
- updates.workflowKind ?? null,
197
- updates.triggerType ?? null,
198
- merged.cronExpression ?? null,
199
- merged.timezone ?? null,
200
- merged.triggerOnWorkflowKind ?? null,
201
- merged.triggerOnStatus ? JSON.stringify(merged.triggerOnStatus) : null,
202
- merged.input ? JSON.stringify(merged.input) : null,
203
- merged.metadata ? JSON.stringify(merged.metadata) : null,
204
- updates.enabled !== undefined ? (updates.enabled ? 1 : 0) : null,
205
- merged.lastRunAt?.toISOString() ?? null,
206
- merged.lastRunId ?? null,
207
- merged.nextRunAt?.toISOString() ?? null,
208
- scheduleId
209
- );
210
- }
211
-
212
- async deleteSchedule(scheduleId: string): Promise<void> {
213
- this.stmts!.delete.run(scheduleId);
214
- }
215
-
216
- // ============================================================================
217
- // Helper Methods
218
- // ============================================================================
219
-
220
- private rowToSchedule(row: ScheduleRow): WorkflowSchedule {
221
- return {
222
- id: row.id,
223
- workflowKind: row.workflow_kind,
224
- triggerType: row.trigger_type as WorkflowSchedule['triggerType'],
225
- cronExpression: row.cron_expression ?? undefined,
226
- timezone: row.timezone ?? undefined,
227
- triggerOnWorkflowKind: row.trigger_on_workflow_kind ?? undefined,
228
- triggerOnStatus: row.trigger_on_status
229
- ? JSON.parse(row.trigger_on_status)
230
- : undefined,
231
- input: row.input ? JSON.parse(row.input) : undefined,
232
- metadata: row.metadata ? JSON.parse(row.metadata) : undefined,
233
- enabled: row.enabled === 1,
234
- lastRunAt: row.last_run_at ? new Date(row.last_run_at) : undefined,
235
- lastRunId: row.last_run_id ?? undefined,
236
- nextRunAt: row.next_run_at ? new Date(row.next_run_at) : undefined,
237
- };
238
- }
239
- }
240
-
241
- // ============================================================================
242
- // Types
243
- // ============================================================================
244
-
245
- interface ScheduleRow {
246
- id: string;
247
- workflow_kind: string;
248
- trigger_type: string;
249
- cron_expression: string | null;
250
- timezone: string | null;
251
- trigger_on_workflow_kind: string | null;
252
- trigger_on_status: string | null;
253
- input: string | null;
254
- metadata: string | null;
255
- enabled: number;
256
- last_run_at: string | null;
257
- last_run_id: string | null;
258
- next_run_at: string | null;
259
- created_at: string;
260
- updated_at: string;
261
- }
@@ -1,73 +0,0 @@
1
- /**
2
- * Scheduler types for the workflow engine.
3
- * Defines the type contracts for the cron and workflow-completion trigger
4
- * scheduler, implemented by {@link CronScheduler}, {@link SQLiteSchedulePersistence},
5
- * and {@link PostgresSchedulePersistence}.
6
- */
7
-
8
- import type { WorkflowKind, RunStatus } from '../core/types';
9
-
10
- /**
11
- * Schedule trigger types.
12
- */
13
- export type TriggerType = 'cron' | 'workflow_completed' | 'manual';
14
-
15
- /**
16
- * Schedule definition.
17
- */
18
- export interface WorkflowSchedule {
19
- id: string;
20
- workflowKind: WorkflowKind;
21
- triggerType: TriggerType;
22
-
23
- /** Cron expression for time-based triggers (e.g. `0 0 * * *` for daily). Only used when triggerType is 'cron'. */
24
- cronExpression?: string;
25
- /** IANA timezone for cron evaluation (e.g. 'America/New_York'). Defaults to 'UTC'. */
26
- timezone?: string;
27
-
28
- /** Workflow kind that triggers this schedule on completion. Only used when triggerType is 'workflow_completed'. */
29
- triggerOnWorkflowKind?: WorkflowKind;
30
- /** Run statuses that activate the completion trigger. If empty, any terminal status triggers. */
31
- triggerOnStatus?: RunStatus[];
32
-
33
- /** Input payload passed to the spawned workflow run. */
34
- input?: Record<string, unknown>;
35
- /** Arbitrary metadata attached to the spawned workflow run. */
36
- metadata?: Record<string, unknown>;
37
-
38
- /** Whether this schedule is active. Disabled schedules are not evaluated. */
39
- enabled: boolean;
40
- /** Timestamp of the most recent run spawned by this schedule. */
41
- lastRunAt?: Date;
42
- /** Run ID of the most recent run spawned by this schedule. */
43
- lastRunId?: string;
44
- /** Next scheduled execution time, computed from the cron expression and timezone. */
45
- nextRunAt?: Date;
46
- }
47
-
48
- /**
49
- * Scheduler interface.
50
- * Implement this to create custom schedulers.
51
- */
52
- export interface Scheduler {
53
- /** Start the scheduler */
54
- start(): Promise<void>;
55
-
56
- /** Stop the scheduler */
57
- stop(): Promise<void>;
58
-
59
- /** Add a schedule */
60
- addSchedule(schedule: Omit<WorkflowSchedule, 'id'>): Promise<WorkflowSchedule>;
61
-
62
- /** Remove a schedule */
63
- removeSchedule(scheduleId: string): Promise<void>;
64
-
65
- /** Update a schedule */
66
- updateSchedule(scheduleId: string, updates: Partial<WorkflowSchedule>): Promise<void>;
67
-
68
- /** Get all schedules */
69
- getSchedules(): Promise<WorkflowSchedule[]>;
70
-
71
- /** Manually trigger a scheduled workflow */
72
- triggerNow(scheduleId: string): Promise<string>;
73
- }
@@ -1,27 +0,0 @@
1
- /**
2
- * Storage module exports.
3
- */
4
-
5
- export * from './types';
6
- export * from './memory';
7
- export * from './sqlite';
8
- export * from './postgres';
9
-
10
- // Re-export specific types for convenience
11
- export type {
12
- WorkflowStorage,
13
- WorkflowRunRecord,
14
- CreateRunInput,
15
- UpdateRunInput,
16
- ListRunsOptions,
17
- PaginatedResult,
18
- StepResult,
19
- StepRecord,
20
- ExtendedWorkflowRunRecord,
21
- ExtendedRunStatus,
22
- ExtendedStepStatus,
23
- ExtendedListRunsOptions,
24
- StepflowRunsTable,
25
- StepflowStepResultsTable,
26
- StepflowDatabase,
27
- } from './types';