loadam 0.2.4 → 0.4.0

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 CHANGED
@@ -1,6 +1,12 @@
1
1
  # loadam
2
2
 
3
- > Point loadam at an OpenAPI spec. Get back a working **k6 load test**, a **Schemathesis contract suite**, and an **MCP server** for agents — in one command. OSS, Apache 2.0.
3
+ [![CI](https://github.com/DesmondSanctity/loadam/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/DesmondSanctity/loadam/actions/workflows/ci.yml)
4
+ [![npm](https://img.shields.io/npm/v/loadam)](https://www.npmjs.com/package/loadam)
5
+ [![npm downloads](https://img.shields.io/npm/dm/loadam)](https://www.npmjs.com/package/loadam)
6
+ [![Node](https://img.shields.io/badge/node-%E2%89%A520.19-339933)](#install)
7
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue)](LICENSE)
8
+
9
+ > Point loadam at an OpenAPI spec. Get back a working **k6 load test**, a **Schemathesis contract suite**, a **drift check** against your live API, and an **MCP server** for agents. OSS, Apache 2.0.
4
10
 
5
11
  <p align="center">
6
12
  <img src="https://raw.githubusercontent.com/DesmondSanctity/loadam/main/.github/assets/demo.svg" alt="loadam in 30 seconds" width="720">
@@ -13,14 +19,14 @@ loadam test ./openapi.yaml --target https://api.example.com
13
19
  loadam report --open # Single-file HTML report with charts.
14
20
  ```
15
21
 
16
- That's it. One spec → three production-grade rigs **plus** a session archive and an HTML report. **One engine, two surfaces:**
22
+ That's it. One spec → a load test, a contract suite, a drift check, and an MCP server, **plus** a session archive and an HTML report. **One engine, two surfaces:**
17
23
 
18
24
  - **Test surface** — adversarial. Break the API: load, perf, contract drift.
19
25
  - **Agent surface** — cooperative. Let LLM agents use the API safely via MCP (stdio + HTTP).
20
26
 
21
27
  Both are compiled from the same **Intermediate Representation (IR)** built from your spec.
22
28
 
23
- > **What's new in 0.2.4** — branded HTML report with a per-endpoint sidebar (live p95 + status-code distribution), filter chips (All / Failed / Flaky / Passed), three-tier overall status (`passed` ≥ 99% · `flaky` ≥ 95% · `failed` < 95%), and per-op latency/status sub-metrics emitted by generated k6 scripts. See the [CHANGELOG](CHANGELOG.md#024---2026-05-02) for the full list.
29
+ > **What's new in 0.4.0**: load tests now work on APIs behind a login. loadam finds the login call in your spec, renews tokens before they expire, gives each virtual user its own account with `--users`, sends credentials only where the spec asks for them, and stops with exit code 2 when the credentials are wrong. The HTML report is redesigned: it says why a run failed and has a table of every endpoint you can filter, search and sort. See the [CHANGELOG](CHANGELOG.md#040---2026-12-05) for the full list.
24
30
 
25
31
  ---
26
32
 
@@ -38,7 +44,7 @@ npm i -D loadam && npx loadam <command>
38
44
  ```
39
45
 
40
46
  Once installed globally, all examples below work as `loadam <command>` (no `npx` prefix).
41
- Requires Node.js 20+. The generated rigs have their own runtime requirements: **k6** for load tests, **Python 3.10+** for contract tests, **Node.js 20+** for the MCP server.
47
+ Requires Node.js 20.19+ (or 22.13+). The generated rigs have their own runtime requirements: **k6** for load tests, **Python 3.10+** for contract tests, **Node.js 20+** for the MCP server.
42
48
 
43
49
  ## 30-second quickstart
44
50
 
@@ -54,9 +60,9 @@ loadam history
54
60
  loadam show latest
55
61
  loadam report latest --open
56
62
 
57
- # 4. Generate a property-based Schemathesis contract suite.
58
- loadam contract ./openapi.yaml --target https://api.example.com
59
- cd loadam-out/contract && pip install -e . && pytest
63
+ # 4. Generate and run a Schemathesis contract suite (sends writes: use staging).
64
+ pip install "schemathesis>=4,<5" pytest python-dotenv
65
+ loadam contract ./openapi.yaml --target https://staging.example.com --run
60
66
 
61
67
  # 5. Generate an MCP server. Read-only by default.
62
68
  loadam mcp ./openapi.yaml
@@ -78,7 +84,7 @@ Set `LOADAM_TARGET` once per shell to drop the `--target` flag from every invoca
78
84
  <p align="center">
79
85
  <img src="https://raw.githubusercontent.com/DesmondSanctity/loadam/main/.github/assets/report-screenshot.png" alt="loadam HTML report" width="720">
80
86
  <br>
81
- <sub><i>The single-file HTML report — branded header, per-endpoint sidebar, filter chips, threshold panel.</i></sub>
87
+ <sub><i>The single-file HTML report: the verdict and why, key numbers against their thresholds, latency percentiles, then every endpoint.</i></sub>
82
88
  </p>
83
89
 
84
90
  ## Commands
@@ -87,13 +93,13 @@ Set `LOADAM_TARGET` once per shell to drop the `--target` flag from every invoca
87
93
  | ----------------------------- | --------------------------------------------------------------------- | --------------------------------- |
88
94
  | `loadam init <spec>` | Parse spec → IR with inferred resource graph | `loadam.ir.json` |
89
95
  | `loadam test <spec>` | Compile + (optionally) run k6 smoke / load; archives the session | `loadam-out/k6/` + session |
90
- | `loadam contract <spec>` | Compile to a Schemathesis pytest project | `loadam-out/contract/` + session |
96
+ | `loadam contract <spec>` | Compile to a Schemathesis pytest project; `--run` runs it | `loadam-out/contract/` + session |
91
97
  | `loadam mcp <spec>` | Compile to a runnable MCP server (stdio + HTTP) | `loadam-out/mcp/` |
92
98
  | `loadam diff <spec>` | Probe a live API and report spec-vs-reality drift | Markdown + session |
93
99
  | `loadam history` | List archived sessions (newest first) | table or `--json` |
94
- | `loadam show <id\|latest>` | Show a session's metadata + inline k6/drift summary | text or `--json` |
100
+ | `loadam show <id\|latest>` | Show a session's metadata + inline k6/drift/contract summary | text or `--json` |
95
101
  | `loadam report <id\|latest>` | Render a single-file HTML report (charts, threshold table) | `report.html` (`--open` to view) |
96
- | `loadam clean` | Prune session archive (`--older-than 7d`, `--dry-run` by default) | text or `--json` |
102
+ | `loadam clean` | Prune session archive (`--older-than 7d`; dry run unless `--yes`) | text or `--json` |
97
103
  | `loadam auth import` | Infer an auth profile from a `curl` command | JSON / pretty |
98
104
  | `loadam update` | Check npm for a newer version of `loadam` | text or `--json` |
99
105
  | `loadam completion` | Print bash/zsh/fish completion script | stdout |
@@ -129,10 +135,53 @@ Every `loadam test`, `loadam contract`, and `loadam diff` invocation is archived
129
135
  loadam history # newest 20 sessions
130
136
  loadam show latest # inline k6 p95 / threshold pass-fail
131
137
  loadam report latest --open # one-file HTML report (charts, dark mode)
132
- loadam clean --older-than 7d --apply # prune old runs
138
+ loadam clean --older-than 7d --yes # prune old runs (dry run without --yes)
139
+ ```
140
+
141
+ The HTML report is a single self-contained file (no external CDNs, no JS dependencies) and is safe to drop into a CI artefact store, gh-pages, or Slack. It opens with the verdict and the reason a run failed (the threshold that broke, with the measured value, and the endpoints that failed), then the key numbers, latency percentiles against your p95 limit, and a table of every endpoint you can filter, search and sort, with its pass rate, p95 and status codes. It works on a phone, in light or dark.
142
+
143
+ ## How accurate is it?
144
+
145
+ Measured, not assumed. The [`bench/`](bench/) suite runs loadam against reference APIs whose ground truth is known, and exits non-zero if any number gets worse than the saved baseline:
146
+
147
+ | Metric | Result |
148
+ | --- | --- |
149
+ | Smoke test: operations that get a 2xx | 100% |
150
+ | Requests using a made-up path ID / body reference | 0% / 0% |
151
+ | Drift check: planted mismatches found, false findings | 100%, 0 |
152
+ | Contract tests: planted bugs found, false alarms on correct APIs | 6/6, 0 |
153
+ | Load test on APIs with 8-second tokens: requests rejected for auth | 0 |
154
+ | Real APIs (PokeAPI, FakeRESTApi, Petstore v3): failures caused by loadam | 0 (PokeAPI 102/102) |
155
+
156
+ ```bash
157
+ pnpm build && pnpm bench # also: pnpm bench:contract, pnpm bench:real
158
+ ```
159
+
160
+ When loadam can't tell from the spec which resource a field points at (say `Transfer.from` → `Account`), tell it once in `loadam.config.json`; every command picks it up:
161
+
162
+ ```json
163
+ { "refs": { "Transfer.from": "Account" }, "resources": { "Product": { "idField": "sku" } } }
133
164
  ```
134
165
 
135
- The HTML report is a single self-contained file (no external CDNs, no JS dependencies) and is safe to drop into a CI artefact store, gh-pages, or Slack. It includes a per-endpoint sidebar with live p95 and status-code distribution, filter chips (All / Failed / Flaky / Passed), and a three-tier overall status (passed · flaky · failed) so you can tell at a glance whether a run is genuinely broken or just noisy.
166
+ See [bench/README.md](bench/README.md) for how each metric is scored.
167
+
168
+ ## Gated endpoints
169
+
170
+ APIs behind a login work without extra setup. loadam finds the login operation in the spec, and each virtual user logs in and fetches a new token before the old one expires. Public operations get no credentials, and a wrong password stops the run before any load is sent (exit code 2).
171
+
172
+ ```bash
173
+ export API_USER=me@example.com API_PASS=…
174
+ loadam test ./openapi.yaml --mode load # logs in, renews tokens
175
+ loadam test ./openapi.yaml --mode load --users users.csv # one account per VU
176
+ ```
177
+
178
+ If loadam can't tell which operation logs in, declare it in `loadam.config.json`:
179
+
180
+ ```json
181
+ { "auth": { "login": { "operation": "POST /auth/login", "body": { "email": "${API_USER}", "password": "${API_PASS}" }, "token": "data.token" } } }
182
+ ```
183
+
184
+ See the [gated endpoints guide](https://github.com/DesmondSanctity/loadam/blob/main/website/src/content/docs/docs/guides/gated-endpoints.mdx) for cookie sessions, token expiry and user pools.
136
185
 
137
186
  ## Why loadam
138
187
 
@@ -140,7 +189,7 @@ Most teams have an OpenAPI spec sitting in a repo and **none** of the rigs that
140
189
 
141
190
  ## Privacy & telemetry
142
191
 
143
- **Zero telemetry.** No analytics, no crash reporting, no phone-home. The CLI only makes network requests when you explicitly run `loadam diff --target <url>`. Generated rigs talk only to whatever target you configure. See [SECURITY.md](SECURITY.md) for the full guarantee.
192
+ **Zero telemetry.** No analytics, no crash reporting, no phone-home. The CLI only talks to the API you point it at (`loadam diff`, and the k6 or contract runs it starts for you), plus the npm registry when you run `loadam update`. Generated rigs talk only to whatever target you configure. See [SECURITY.md](SECURITY.md) for the full guarantee.
144
193
 
145
194
  ## Shell completion
146
195
 
@@ -168,9 +217,9 @@ packages/
168
217
 
169
218
  ## Status
170
219
 
171
- V1 (this) targets **petstore-class specs** end-to-end. Stripe-class specs (polymorphism, discriminators, recursive $refs) graduate in V1.1.
220
+ loadam handles CRUD-style specs end-to-end, including nested resources, wrapped responses, and specs with 100+ operations (PokeAPI's 102 pass the smoke test). Heavy polymorphism (`oneOf`, discriminators) may still need hand edits to the generated files.
172
221
 
173
- | | V1 | V1.1 |
222
+ | | Now (0.4) | Planned |
174
223
  | ------------------------- | --------------------- | ---------------------------- |
175
224
  | OpenAPI 3.x | ✅ | |
176
225
  | Postman / HAR / curl | curl only | Postman + HAR |
@@ -178,14 +227,16 @@ V1 (this) targets **petstore-class specs** end-to-end. Stripe-class specs (polym
178
227
  | Schemathesis contract | ✅ | |
179
228
  | Drift report | ✅ | |
180
229
  | MCP server (stdio + HTTP) | ✅ read-only default | per-op `--writes` opt-in |
181
- | Auth | bearer, apiKey, basic | OAuth2 PKCE, AWS sigv4, mTLS |
182
- | Spec scale | ~10 ops | ~600 ops + polymorphism |
230
+ | Auth | bearer, apiKey, basic, OAuth2 client credentials¹, login flows² | OAuth2 PKCE, AWS sigv4, mTLS |
231
+ | Spec scale | 100+ ops | ~600 ops + polymorphism |
232
+
233
+ ¹ k6 test, contract suite, and `diff`. The generated MCP server leaves OAuth2 for you to wire up.
234
+ ² A login operation in the spec (or in `loadam.config.json`) that returns a token or a session cookie.
183
235
 
184
236
  ## Examples
185
237
 
186
238
  - [examples/basic-openapi](examples/basic-openapi/) — petstore, no auth required to generate
187
239
  - [examples/with-auth](examples/with-auth/) — bookstore with bearer auth + multi-server
188
- - [examples/demo](examples/demo/) — a real `report.html` generated against live petstore
189
240
 
190
241
  ## Development
191
242
 
@@ -193,12 +244,14 @@ V1 (this) targets **petstore-class specs** end-to-end. Stripe-class specs (polym
193
244
  pnpm install
194
245
  pnpm -r build
195
246
  pnpm -r test
247
+ pnpm lint && pnpm typecheck
248
+ pnpm bench # accuracy benchmark (needs k6)
196
249
  ```
197
250
 
198
251
  Conventions:
199
252
 
200
- - TypeScript strict + ESM; Node 20+; pnpm 9.15+.
201
- - Biome for formatting (1-space indent, single quotes). Run `pnpm fix`.
253
+ - TypeScript strict + ESM; Node 20.19+ (the website needs Node 22.23.4+); pnpm 9.15+.
254
+ - Biome for formatting and linting (2-space indent, double quotes). Run `pnpm fix`.
202
255
  - Vitest for tests. Every package ships with goldens against the petstore fixture.
203
256
 
204
257
  ## Documentation
package/dist/bin.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
 
2
- export { }
2
+ export { };