@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.
- package/README.md +9 -0
- package/dist/{chunk-U3PCVK6O.js → chunk-D5HW7VEG.js} +4 -2
- package/dist/chunk-D5HW7VEG.js.map +1 -0
- package/dist/{chunk-5XJBAPXF.js → chunk-JUPZEBR3.js} +3 -1
- package/dist/{chunk-5XJBAPXF.js.map → chunk-JUPZEBR3.js.map} +1 -1
- package/dist/events/index.d.ts +2 -0
- package/dist/events/index.js +1 -1
- package/dist/index.js +2 -2
- package/dist/storage/index.js +1 -1
- package/package.json +23 -12
- package/.codekin/reports/code-review/2026-04-11_code-review-daily.md +0 -146
- package/.codekin/reports/code-review/2026-04-13_code-review-daily.md +0 -74
- package/.codekin/reports/comments/2026-04-04_comment-assessment.md +0 -179
- package/.codekin/reports/comments/2026-04-11_comment-assessment.md +0 -161
- package/.codekin/reports/comments/2026-04-14_comment-assessment.md +0 -34
- package/.codekin/reports/complexity/2026-04-03_complexity-report.md +0 -152
- package/.codekin/reports/complexity/2026-04-11_complexity-report.md +0 -152
- package/.codekin/reports/complexity/2026-04-14_complexity-report.md +0 -34
- package/.codekin/reports/dependencies/2026-04-04_dependency-health.md +0 -94
- package/.codekin/reports/dependencies/2026-04-11_dependency-health.md +0 -93
- package/.codekin/reports/docs-audit/2026-04-04_docs-audit.md +0 -10
- package/.codekin/reports/docs-audit/2026-04-11_docs-audit.md +0 -138
- package/.codekin/reports/docs-audit/2026-04-13_docs-audit.md +0 -121
- package/.codekin/reports/security/2026-04-03_security-audit.md +0 -208
- package/.codekin/reports/security/2026-04-11_security-audit.md +0 -297
- package/.github/CODEOWNERS +0 -15
- package/.github/dependabot.yml +0 -23
- package/.github/workflows/ci.yml +0 -38
- package/.github/workflows/publish.yml +0 -42
- package/.github/workflows/security.yml +0 -29
- package/CHANGELOG.md +0 -34
- package/SECURITY.md +0 -40
- package/dist/chunk-U3PCVK6O.js.map +0 -1
- package/docs/github-packages-setup.md +0 -97
- package/docs/stepflow-api-reference.md +0 -1663
- package/src/core/engine/concurrency.ts +0 -229
- package/src/core/engine/lifecycle.ts +0 -176
- package/src/core/engine.test.ts +0 -1435
- package/src/core/engine.ts +0 -598
- package/src/core/index.ts +0 -7
- package/src/core/orchestrator/persistence.ts +0 -165
- package/src/core/orchestrator/plan-resolution.ts +0 -140
- package/src/core/orchestrator/state-transitions.ts +0 -109
- package/src/core/orchestrator/step-runner.ts +0 -427
- package/src/core/orchestrator.ts +0 -252
- package/src/core/types.ts +0 -220
- package/src/events/index.ts +0 -8
- package/src/events/memory.test.ts +0 -107
- package/src/events/memory.ts +0 -92
- package/src/events/socketio.test.ts +0 -378
- package/src/events/socketio.ts +0 -262
- package/src/events/types.ts +0 -118
- package/src/events/webhook.test.ts +0 -949
- package/src/events/webhook.ts +0 -807
- package/src/index.ts +0 -270
- package/src/planning/evaluate-condition.test.ts +0 -153
- package/src/planning/evaluate-condition.ts +0 -105
- package/src/planning/index.ts +0 -55
- package/src/planning/planner.ts +0 -494
- package/src/planning/planning.test.ts +0 -727
- package/src/planning/registry.test.ts +0 -398
- package/src/planning/registry.ts +0 -283
- package/src/planning/types.ts +0 -566
- package/src/scheduler/cron.test.ts +0 -479
- package/src/scheduler/cron.ts +0 -438
- package/src/scheduler/index.ts +0 -8
- package/src/scheduler/postgres-persistence.ts +0 -530
- package/src/scheduler/sqlite-persistence.test.ts +0 -235
- package/src/scheduler/sqlite-persistence.ts +0 -286
- package/src/scheduler/types.ts +0 -73
- package/src/storage/index.ts +0 -27
- package/src/storage/memory.test.ts +0 -349
- package/src/storage/memory.ts +0 -227
- package/src/storage/postgres-core.ts +0 -550
- package/src/storage/postgres-migration.test.ts +0 -69
- package/src/storage/postgres-transaction-pagination.test.ts +0 -107
- package/src/storage/postgres.ts +0 -835
- package/src/storage/sqlite-core.ts +0 -151
- package/src/storage/sqlite.test.ts +0 -642
- package/src/storage/sqlite.ts +0 -717
- package/src/storage/types.ts +0 -343
- package/src/utils/errors.test.ts +0 -150
- package/src/utils/errors.ts +0 -161
- package/src/utils/id.ts +0 -21
- package/src/utils/index.ts +0 -10
- package/src/utils/logger.test.ts +0 -121
- package/src/utils/logger.ts +0 -96
- package/src/utils/pinned-fetch.test.ts +0 -84
- package/src/utils/pinned-fetch.ts +0 -118
- package/src/utils/postgres-deps.ts +0 -79
- package/src/utils/retry.test.ts +0 -177
- package/src/utils/retry.ts +0 -121
- package/src/utils/safe-json.test.ts +0 -166
- package/src/utils/safe-json.ts +0 -107
- package/src/utils/webhook-signature.test.ts +0 -111
- package/src/utils/webhook-signature.ts +0 -74
- package/tsconfig.json +0 -21
- package/tsup.config.ts +0 -14
- package/vitest.config.ts +0 -9
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Regression test for PostgresTransactionAdapter.listRuns pagination total.
|
|
3
|
-
* See audit 2026-04-27 finding C2: when listRuns is called inside a
|
|
4
|
-
* transaction, the returned `total` must reflect the rows visible to that
|
|
5
|
-
* transaction (via COUNT(*) on the same connection), not the size of the
|
|
6
|
-
* returned page.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { describe, it, expect, beforeAll } from 'vitest';
|
|
10
|
-
import { PostgresStorageAdapter, PostgresTransactionAdapter } from './postgres';
|
|
11
|
-
|
|
12
|
-
beforeAll(async () => {
|
|
13
|
-
// PostgresTransactionAdapter.listRuns uses the module-level `sql` template
|
|
14
|
-
// tag from postgres.ts, which is only populated when a PostgresStorageAdapter
|
|
15
|
-
// is initialized. Initialize one with a no-op fake pool so the module state
|
|
16
|
-
// is ready for the direct unit test below.
|
|
17
|
-
const noopPool = {
|
|
18
|
-
connect: async () => ({
|
|
19
|
-
query: async () => ({ command: 'SELECT', rowCount: 0, rows: [] }),
|
|
20
|
-
release: () => {},
|
|
21
|
-
}),
|
|
22
|
-
end: async () => {},
|
|
23
|
-
on: () => noopPool,
|
|
24
|
-
off: () => noopPool,
|
|
25
|
-
};
|
|
26
|
-
const bootstrap = new PostgresStorageAdapter({
|
|
27
|
-
pool: noopPool as unknown as import('pg').Pool,
|
|
28
|
-
});
|
|
29
|
-
await bootstrap.initialize();
|
|
30
|
-
await bootstrap.close();
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Build a Kysely-transaction-shaped stub backed by an in-memory row list.
|
|
35
|
-
* It distinguishes the COUNT(*) query (started with `selectFrom().select()`)
|
|
36
|
-
* from the data query (started with `selectFrom().selectAll()`) and replies
|
|
37
|
-
* with the right shape for each.
|
|
38
|
-
*/
|
|
39
|
-
function buildFakeTrx<T extends Record<string, unknown>>(rows: T[]) {
|
|
40
|
-
function buildCountChain() {
|
|
41
|
-
const chain: any = {};
|
|
42
|
-
chain.where = () => chain;
|
|
43
|
-
chain.executeTakeFirst = async () => ({ count: rows.length });
|
|
44
|
-
return chain;
|
|
45
|
-
}
|
|
46
|
-
function buildDataChain() {
|
|
47
|
-
const chain: any = {};
|
|
48
|
-
let limit: number | undefined;
|
|
49
|
-
let offset = 0;
|
|
50
|
-
chain.where = () => chain;
|
|
51
|
-
chain.orderBy = () => chain;
|
|
52
|
-
chain.limit = (n: number) => { limit = n; return chain; };
|
|
53
|
-
chain.offset = (n: number) => { offset = n; return chain; };
|
|
54
|
-
chain.execute = async () => {
|
|
55
|
-
const sliced = rows.slice(offset, limit !== undefined ? offset + limit : undefined);
|
|
56
|
-
return sliced;
|
|
57
|
-
};
|
|
58
|
-
return chain;
|
|
59
|
-
}
|
|
60
|
-
const qb = {
|
|
61
|
-
selectFrom: () => ({
|
|
62
|
-
select: () => buildCountChain(),
|
|
63
|
-
selectAll: () => buildDataChain(),
|
|
64
|
-
}),
|
|
65
|
-
};
|
|
66
|
-
return { withSchema: () => qb } as any;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
describe('PostgresTransactionAdapter — listRuns pagination total', () => {
|
|
70
|
-
it('reports total from COUNT(*) on the same transaction, not the page size', async () => {
|
|
71
|
-
// Simulate 7 rows visible in the transaction; ask for a page of 3.
|
|
72
|
-
const fakeRow = {
|
|
73
|
-
id: 'r', kind: 'k', status: 'queued', parent_run_id: null,
|
|
74
|
-
input_json: '{}', metadata_json: '{}', context_json: '{}',
|
|
75
|
-
output_json: null, error_json: null, priority: 0, timeout_ms: null,
|
|
76
|
-
created_at: new Date(), started_at: null, finished_at: null,
|
|
77
|
-
};
|
|
78
|
-
const rows = Array.from({ length: 7 }, (_, i) => ({ ...fakeRow, id: `r${i}` }));
|
|
79
|
-
const trx = buildFakeTrx(rows);
|
|
80
|
-
|
|
81
|
-
const adapter = new PostgresTransactionAdapter(trx, 'public');
|
|
82
|
-
const result = await adapter.listRuns({ limit: 3 });
|
|
83
|
-
|
|
84
|
-
// Page contains only 3 rows...
|
|
85
|
-
expect(result.items).toHaveLength(3);
|
|
86
|
-
// ...but total reflects all 7 rows visible in the transaction.
|
|
87
|
-
// Pre-fix this returned 3 (rows.length).
|
|
88
|
-
expect(result.total).toBe(7);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it('total reflects all created rows even when limit exceeds page size', async () => {
|
|
92
|
-
const fakeRow = {
|
|
93
|
-
id: 'r', kind: 'k', status: 'queued', parent_run_id: null,
|
|
94
|
-
input_json: '{}', metadata_json: '{}', context_json: '{}',
|
|
95
|
-
output_json: null, error_json: null, priority: 0, timeout_ms: null,
|
|
96
|
-
created_at: new Date(), started_at: null, finished_at: null,
|
|
97
|
-
};
|
|
98
|
-
const rows = Array.from({ length: 5 }, (_, i) => ({ ...fakeRow, id: `r${i}` }));
|
|
99
|
-
const trx = buildFakeTrx(rows);
|
|
100
|
-
|
|
101
|
-
const adapter = new PostgresTransactionAdapter(trx, 'public');
|
|
102
|
-
const result = await adapter.listRuns({ limit: 100 });
|
|
103
|
-
|
|
104
|
-
expect(result.items).toHaveLength(5);
|
|
105
|
-
expect(result.total).toBe(5);
|
|
106
|
-
});
|
|
107
|
-
});
|