@multiplier-labs/stepflow 0.3.4 → 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 (99) hide show
  1. package/README.md +9 -0
  2. package/dist/{chunk-U3PCVK6O.js → chunk-D5HW7VEG.js} +4 -2
  3. package/dist/chunk-D5HW7VEG.js.map +1 -0
  4. package/dist/{chunk-5XJBAPXF.js → chunk-JUPZEBR3.js} +3 -1
  5. package/dist/{chunk-5XJBAPXF.js.map → chunk-JUPZEBR3.js.map} +1 -1
  6. package/dist/events/index.d.ts +2 -0
  7. package/dist/events/index.js +1 -1
  8. package/dist/index.js +2 -2
  9. package/dist/storage/index.js +1 -1
  10. package/package.json +23 -12
  11. package/.codekin/reports/code-review/2026-04-11_code-review-daily.md +0 -146
  12. package/.codekin/reports/code-review/2026-04-13_code-review-daily.md +0 -74
  13. package/.codekin/reports/comments/2026-04-04_comment-assessment.md +0 -179
  14. package/.codekin/reports/comments/2026-04-11_comment-assessment.md +0 -161
  15. package/.codekin/reports/comments/2026-04-14_comment-assessment.md +0 -34
  16. package/.codekin/reports/complexity/2026-04-03_complexity-report.md +0 -152
  17. package/.codekin/reports/complexity/2026-04-11_complexity-report.md +0 -152
  18. package/.codekin/reports/complexity/2026-04-14_complexity-report.md +0 -34
  19. package/.codekin/reports/dependencies/2026-04-04_dependency-health.md +0 -94
  20. package/.codekin/reports/dependencies/2026-04-11_dependency-health.md +0 -93
  21. package/.codekin/reports/docs-audit/2026-04-04_docs-audit.md +0 -10
  22. package/.codekin/reports/docs-audit/2026-04-11_docs-audit.md +0 -138
  23. package/.codekin/reports/docs-audit/2026-04-13_docs-audit.md +0 -121
  24. package/.codekin/reports/security/2026-04-03_security-audit.md +0 -208
  25. package/.codekin/reports/security/2026-04-11_security-audit.md +0 -297
  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 -42
  30. package/.github/workflows/security.yml +0 -29
  31. package/CHANGELOG.md +0 -34
  32. package/SECURITY.md +0 -40
  33. package/dist/chunk-U3PCVK6O.js.map +0 -1
  34. package/docs/github-packages-setup.md +0 -97
  35. package/docs/stepflow-api-reference.md +0 -1663
  36. package/src/core/engine/concurrency.ts +0 -229
  37. package/src/core/engine/lifecycle.ts +0 -176
  38. package/src/core/engine.test.ts +0 -1435
  39. package/src/core/engine.ts +0 -598
  40. package/src/core/index.ts +0 -7
  41. package/src/core/orchestrator/persistence.ts +0 -165
  42. package/src/core/orchestrator/plan-resolution.ts +0 -140
  43. package/src/core/orchestrator/state-transitions.ts +0 -109
  44. package/src/core/orchestrator/step-runner.ts +0 -427
  45. package/src/core/orchestrator.ts +0 -252
  46. package/src/core/types.ts +0 -220
  47. package/src/events/index.ts +0 -8
  48. package/src/events/memory.test.ts +0 -107
  49. package/src/events/memory.ts +0 -92
  50. package/src/events/socketio.test.ts +0 -378
  51. package/src/events/socketio.ts +0 -262
  52. package/src/events/types.ts +0 -118
  53. package/src/events/webhook.test.ts +0 -949
  54. package/src/events/webhook.ts +0 -807
  55. package/src/index.ts +0 -270
  56. package/src/planning/evaluate-condition.test.ts +0 -153
  57. package/src/planning/evaluate-condition.ts +0 -105
  58. package/src/planning/index.ts +0 -55
  59. package/src/planning/planner.ts +0 -494
  60. package/src/planning/planning.test.ts +0 -727
  61. package/src/planning/registry.test.ts +0 -398
  62. package/src/planning/registry.ts +0 -283
  63. package/src/planning/types.ts +0 -566
  64. package/src/scheduler/cron.test.ts +0 -479
  65. package/src/scheduler/cron.ts +0 -438
  66. package/src/scheduler/index.ts +0 -8
  67. package/src/scheduler/postgres-persistence.ts +0 -530
  68. package/src/scheduler/sqlite-persistence.test.ts +0 -235
  69. package/src/scheduler/sqlite-persistence.ts +0 -286
  70. package/src/scheduler/types.ts +0 -73
  71. package/src/storage/index.ts +0 -27
  72. package/src/storage/memory.test.ts +0 -349
  73. package/src/storage/memory.ts +0 -227
  74. package/src/storage/postgres-core.ts +0 -550
  75. package/src/storage/postgres-migration.test.ts +0 -69
  76. package/src/storage/postgres-transaction-pagination.test.ts +0 -107
  77. package/src/storage/postgres.ts +0 -835
  78. package/src/storage/sqlite-core.ts +0 -151
  79. package/src/storage/sqlite.test.ts +0 -642
  80. package/src/storage/sqlite.ts +0 -717
  81. package/src/storage/types.ts +0 -343
  82. package/src/utils/errors.test.ts +0 -150
  83. package/src/utils/errors.ts +0 -161
  84. package/src/utils/id.ts +0 -21
  85. package/src/utils/index.ts +0 -10
  86. package/src/utils/logger.test.ts +0 -121
  87. package/src/utils/logger.ts +0 -96
  88. package/src/utils/pinned-fetch.test.ts +0 -84
  89. package/src/utils/pinned-fetch.ts +0 -118
  90. package/src/utils/postgres-deps.ts +0 -79
  91. package/src/utils/retry.test.ts +0 -177
  92. package/src/utils/retry.ts +0 -121
  93. package/src/utils/safe-json.test.ts +0 -166
  94. package/src/utils/safe-json.ts +0 -107
  95. package/src/utils/webhook-signature.test.ts +0 -111
  96. package/src/utils/webhook-signature.ts +0 -74
  97. package/tsconfig.json +0 -21
  98. package/tsup.config.ts +0 -14
  99. package/vitest.config.ts +0 -9
@@ -1,151 +0,0 @@
1
- /**
2
- * Shared core for the SQLite storage adapter.
3
- *
4
- * Mirrors the structure introduced for Postgres in `postgres-core.ts` (PR #50)
5
- * so all storage adapters expose row mappers and types in the same shape.
6
- *
7
- * The SQLite case is simpler than Postgres: there is only one adapter class
8
- * (`SQLiteStorageAdapter`), with no transaction-scoped twin. So this module
9
- * carries only the *pure* portion of the postgres-core split:
10
- *
11
- * - SQLite row type interfaces for the three core tables
12
- * (`workflow_runs`, `workflow_run_steps`, `workflow_events`).
13
- * - Pure row mappers (`mapRunRow`, `mapStepRow`, `mapEventRow`) that take
14
- * a `MapperContext = { component, logger }` and route every JSON-column
15
- * parse through the shared `safeParseField` / `safeParseOptionalField`
16
- * helpers. Corruption is reported via the configured logger with safe
17
- * metadata only — the raw value is never logged (audit M2 / L3, PR #52).
18
- *
19
- * No abstract base class is needed: the adapter class binds the prepared
20
- * statements + better-sqlite3 connection in one place and would gain nothing
21
- * from inheritance. The mappers and row types are extracted purely so they
22
- * are reusable, testable, and consistent with `postgres-core.ts`.
23
- */
24
-
25
- import {
26
- safeParseField as sharedSafeParseField,
27
- safeParseOptionalField as sharedSafeParseOptionalField,
28
- type MapperContext,
29
- type SafeJsonParseContext,
30
- } from '../utils/safe-json';
31
- import type {
32
- WorkflowRunRecord,
33
- WorkflowRunStepRecord,
34
- WorkflowEventRecord,
35
- } from './types';
36
- import type { RunStatus, StepStatus, WorkflowError } from '../core/types';
37
-
38
- /**
39
- * Re-export the shared `MapperContext` so callers can `import { MapperContext }`
40
- * from either storage core module.
41
- */
42
- export type { MapperContext };
43
-
44
- // ============================================================================
45
- // SQLite row types
46
- // ============================================================================
47
- //
48
- // SQLite stores everything as text/integer/real, so timestamps come back as
49
- // ISO-8601 strings (the adapter writes them via `Date.prototype.toISOString`)
50
- // and JSON columns come back as the original `JSON.stringify` output. The
51
- // mappers below convert each row back to the public record shape.
52
-
53
- /** Row shape for the `workflow_runs` table. */
54
- export interface SQLiteRunRow {
55
- id: string;
56
- kind: string;
57
- status: string;
58
- parent_run_id: string | null;
59
- input_json: string;
60
- metadata_json: string;
61
- context_json: string;
62
- completed_steps_json: string | null;
63
- error_json: string | null;
64
- created_at: string;
65
- started_at: string | null;
66
- finished_at: string | null;
67
- }
68
-
69
- /** Row shape for the `workflow_run_steps` table. */
70
- export interface SQLiteStepRow {
71
- id: string;
72
- run_id: string;
73
- step_key: string;
74
- step_name: string;
75
- status: string;
76
- attempt: number;
77
- result_json: string | null;
78
- error_json: string | null;
79
- started_at: string | null;
80
- finished_at: string | null;
81
- }
82
-
83
- /** Row shape for the `workflow_events` table. */
84
- export interface SQLiteEventRow {
85
- id: string;
86
- run_id: string;
87
- step_key: string | null;
88
- event_type: string;
89
- level: string;
90
- payload_json: string | null;
91
- timestamp: string;
92
- }
93
-
94
- // ============================================================================
95
- // Row mappers (pure)
96
- // ============================================================================
97
- //
98
- // Adapters supply a `MapperContext` ({ component, logger }); each helper
99
- // extends it with the row id and column being parsed so a structured log
100
- // emitted on corruption identifies the bad row. The raw value is never
101
- // logged — see `src/utils/safe-json.ts`.
102
-
103
- /** Map a `workflow_runs` row to the public `WorkflowRunRecord` shape. */
104
- export function mapRunRow(row: SQLiteRunRow, ctx: MapperContext): WorkflowRunRecord {
105
- const fieldCtx = (column: string): SafeJsonParseContext => ({ ...ctx, rowId: row.id, column });
106
- return {
107
- id: row.id,
108
- kind: row.kind,
109
- status: row.status as RunStatus,
110
- parentRunId: row.parent_run_id ?? undefined,
111
- input: sharedSafeParseField(row.input_json, {}, fieldCtx('input_json')) as Record<string, unknown>,
112
- metadata: sharedSafeParseField(row.metadata_json, {}, fieldCtx('metadata_json')) as Record<string, unknown>,
113
- context: sharedSafeParseField(row.context_json, {}, fieldCtx('context_json')) as Record<string, unknown>,
114
- completedSteps: sharedSafeParseOptionalField(row.completed_steps_json, fieldCtx('completed_steps_json')) as string[] | undefined,
115
- error: sharedSafeParseOptionalField(row.error_json, fieldCtx('error_json')) as WorkflowError | undefined,
116
- createdAt: new Date(row.created_at),
117
- startedAt: row.started_at ? new Date(row.started_at) : undefined,
118
- finishedAt: row.finished_at ? new Date(row.finished_at) : undefined,
119
- };
120
- }
121
-
122
- /** Map a `workflow_run_steps` row to the public `WorkflowRunStepRecord` shape. */
123
- export function mapStepRow(row: SQLiteStepRow, ctx: MapperContext): WorkflowRunStepRecord {
124
- const fieldCtx = (column: string): SafeJsonParseContext => ({ ...ctx, rowId: row.id, column });
125
- return {
126
- id: row.id,
127
- runId: row.run_id,
128
- stepKey: row.step_key,
129
- stepName: row.step_name,
130
- status: row.status as StepStatus,
131
- attempt: row.attempt,
132
- result: sharedSafeParseOptionalField(row.result_json, fieldCtx('result_json')),
133
- error: sharedSafeParseOptionalField(row.error_json, fieldCtx('error_json')) as WorkflowError | undefined,
134
- startedAt: row.started_at ? new Date(row.started_at) : undefined,
135
- finishedAt: row.finished_at ? new Date(row.finished_at) : undefined,
136
- };
137
- }
138
-
139
- /** Map a `workflow_events` row to the public `WorkflowEventRecord` shape. */
140
- export function mapEventRow(row: SQLiteEventRow, ctx: MapperContext): WorkflowEventRecord {
141
- const fieldCtx: SafeJsonParseContext = { ...ctx, rowId: row.id, column: 'payload_json' };
142
- return {
143
- id: row.id,
144
- runId: row.run_id,
145
- stepKey: row.step_key ?? undefined,
146
- eventType: row.event_type,
147
- level: row.level as 'info' | 'warn' | 'error',
148
- payload: sharedSafeParseOptionalField(row.payload_json, fieldCtx),
149
- timestamp: new Date(row.timestamp),
150
- };
151
- }