@multiplier-labs/stepflow 0.3.4 → 0.3.8

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 (109) hide show
  1. package/README.md +9 -0
  2. package/dist/{chunk-5XJBAPXF.js → chunk-4IDPWWGS.js} +15 -4
  3. package/dist/chunk-4IDPWWGS.js.map +1 -0
  4. package/dist/{chunk-U3PCVK6O.js → chunk-T6GAZBTQ.js} +70 -38
  5. package/dist/chunk-T6GAZBTQ.js.map +1 -0
  6. package/dist/{chunk-FMPJBK2N.js → chunk-TVSADUYU.js} +3 -5
  7. package/dist/{chunk-FMPJBK2N.js.map → chunk-TVSADUYU.js.map} +1 -1
  8. package/dist/events/index.d.ts +43 -3
  9. package/dist/events/index.js +7 -3
  10. package/dist/{index-Cd0IZ40L.d.ts → index-CdXDv30T.d.ts} +10 -2
  11. package/dist/index.d.ts +5 -4
  12. package/dist/index.js +159 -46
  13. package/dist/index.js.map +1 -1
  14. package/dist/scheduler/index.d.ts +2 -2
  15. package/dist/scheduler/index.js +1 -1
  16. package/dist/storage/index.d.ts +6 -4
  17. package/dist/storage/index.js +1 -1
  18. package/dist/{types-DSEjiLMj.d.ts → types-BfWe5yP6.d.ts} +2 -0
  19. package/package.json +26 -14
  20. package/.codekin/reports/code-review/2026-04-11_code-review-daily.md +0 -146
  21. package/.codekin/reports/code-review/2026-04-13_code-review-daily.md +0 -74
  22. package/.codekin/reports/comments/2026-04-04_comment-assessment.md +0 -179
  23. package/.codekin/reports/comments/2026-04-11_comment-assessment.md +0 -161
  24. package/.codekin/reports/comments/2026-04-14_comment-assessment.md +0 -34
  25. package/.codekin/reports/complexity/2026-04-03_complexity-report.md +0 -152
  26. package/.codekin/reports/complexity/2026-04-11_complexity-report.md +0 -152
  27. package/.codekin/reports/complexity/2026-04-14_complexity-report.md +0 -34
  28. package/.codekin/reports/dependencies/2026-04-04_dependency-health.md +0 -94
  29. package/.codekin/reports/dependencies/2026-04-11_dependency-health.md +0 -93
  30. package/.codekin/reports/docs-audit/2026-04-04_docs-audit.md +0 -10
  31. package/.codekin/reports/docs-audit/2026-04-11_docs-audit.md +0 -138
  32. package/.codekin/reports/docs-audit/2026-04-13_docs-audit.md +0 -121
  33. package/.codekin/reports/security/2026-04-03_security-audit.md +0 -208
  34. package/.codekin/reports/security/2026-04-11_security-audit.md +0 -297
  35. package/.github/CODEOWNERS +0 -15
  36. package/.github/dependabot.yml +0 -23
  37. package/.github/workflows/ci.yml +0 -38
  38. package/.github/workflows/publish.yml +0 -42
  39. package/.github/workflows/security.yml +0 -29
  40. package/CHANGELOG.md +0 -34
  41. package/SECURITY.md +0 -40
  42. package/dist/chunk-5XJBAPXF.js.map +0 -1
  43. package/dist/chunk-U3PCVK6O.js.map +0 -1
  44. package/docs/github-packages-setup.md +0 -97
  45. package/docs/stepflow-api-reference.md +0 -1663
  46. package/src/core/engine/concurrency.ts +0 -229
  47. package/src/core/engine/lifecycle.ts +0 -176
  48. package/src/core/engine.test.ts +0 -1435
  49. package/src/core/engine.ts +0 -598
  50. package/src/core/index.ts +0 -7
  51. package/src/core/orchestrator/persistence.ts +0 -165
  52. package/src/core/orchestrator/plan-resolution.ts +0 -140
  53. package/src/core/orchestrator/state-transitions.ts +0 -109
  54. package/src/core/orchestrator/step-runner.ts +0 -427
  55. package/src/core/orchestrator.ts +0 -252
  56. package/src/core/types.ts +0 -220
  57. package/src/events/index.ts +0 -8
  58. package/src/events/memory.test.ts +0 -107
  59. package/src/events/memory.ts +0 -92
  60. package/src/events/socketio.test.ts +0 -378
  61. package/src/events/socketio.ts +0 -262
  62. package/src/events/types.ts +0 -118
  63. package/src/events/webhook.test.ts +0 -949
  64. package/src/events/webhook.ts +0 -807
  65. package/src/index.ts +0 -270
  66. package/src/planning/evaluate-condition.test.ts +0 -153
  67. package/src/planning/evaluate-condition.ts +0 -105
  68. package/src/planning/index.ts +0 -55
  69. package/src/planning/planner.ts +0 -494
  70. package/src/planning/planning.test.ts +0 -727
  71. package/src/planning/registry.test.ts +0 -398
  72. package/src/planning/registry.ts +0 -283
  73. package/src/planning/types.ts +0 -566
  74. package/src/scheduler/cron.test.ts +0 -479
  75. package/src/scheduler/cron.ts +0 -438
  76. package/src/scheduler/index.ts +0 -8
  77. package/src/scheduler/postgres-persistence.ts +0 -530
  78. package/src/scheduler/sqlite-persistence.test.ts +0 -235
  79. package/src/scheduler/sqlite-persistence.ts +0 -286
  80. package/src/scheduler/types.ts +0 -73
  81. package/src/storage/index.ts +0 -27
  82. package/src/storage/memory.test.ts +0 -349
  83. package/src/storage/memory.ts +0 -227
  84. package/src/storage/postgres-core.ts +0 -550
  85. package/src/storage/postgres-migration.test.ts +0 -69
  86. package/src/storage/postgres-transaction-pagination.test.ts +0 -107
  87. package/src/storage/postgres.ts +0 -835
  88. package/src/storage/sqlite-core.ts +0 -151
  89. package/src/storage/sqlite.test.ts +0 -642
  90. package/src/storage/sqlite.ts +0 -717
  91. package/src/storage/types.ts +0 -343
  92. package/src/utils/errors.test.ts +0 -150
  93. package/src/utils/errors.ts +0 -161
  94. package/src/utils/id.ts +0 -21
  95. package/src/utils/index.ts +0 -10
  96. package/src/utils/logger.test.ts +0 -121
  97. package/src/utils/logger.ts +0 -96
  98. package/src/utils/pinned-fetch.test.ts +0 -84
  99. package/src/utils/pinned-fetch.ts +0 -118
  100. package/src/utils/postgres-deps.ts +0 -79
  101. package/src/utils/retry.test.ts +0 -177
  102. package/src/utils/retry.ts +0 -121
  103. package/src/utils/safe-json.test.ts +0 -166
  104. package/src/utils/safe-json.ts +0 -107
  105. package/src/utils/webhook-signature.test.ts +0 -111
  106. package/src/utils/webhook-signature.ts +0 -74
  107. package/tsconfig.json +0 -21
  108. package/tsup.config.ts +0 -14
  109. 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
- }