@postman/postman-plugin 0.3.0 → 0.4.1-rc.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.
Files changed (48) hide show
  1. package/README.md +46 -9
  2. package/dist/hosts/antigravity.js +47 -0
  3. package/dist/hosts/codex-hooks.js +68 -0
  4. package/dist/hosts/codex.js +87 -8
  5. package/dist/hosts/copilot.js +60 -0
  6. package/dist/hosts/index.js +3 -1
  7. package/dist/json-rpc.js +113 -0
  8. package/dist/system.js +40 -3
  9. package/mcp.pi.json +2 -2
  10. package/package.json +1 -1
  11. package/skills/ai-readiness/SKILL.md +40 -44
  12. package/skills/api-discovery/SKILL.md +64 -145
  13. package/skills/api-discovery/reference/orbit.md +17 -5
  14. package/skills/api-documentation/SKILL.md +41 -46
  15. package/skills/api-engineer/SKILL.md +78 -23
  16. package/skills/api-mocking/SKILL.md +117 -163
  17. package/skills/api-monitoring/SKILL.md +52 -129
  18. package/skills/api-simulation/SKILL.md +130 -178
  19. package/skills/api-simulation/reference/sim_yaml_schema.md +41 -103
  20. package/skills/api-testing/SKILL.md +48 -95
  21. package/skills/bootstrap/SKILL.md +123 -224
  22. package/skills/ci-integration/SKILL.md +53 -113
  23. package/skills/collection-schema-v3/SKILL.md +43 -204
  24. package/skills/collection-schema-v3/reference/http.md +150 -0
  25. package/skills/datasets/SKILL.md +89 -315
  26. package/skills/datasets/reference/spreadsheets.md +25 -0
  27. package/skills/flows/SKILL.md +57 -206
  28. package/skills/flows/reference/flow_cli_flags.md +3 -2
  29. package/skills/performance-testing/SKILL.md +46 -62
  30. package/skills/performance-testing/references/jmeter-import/README.md +82 -0
  31. package/skills/performance-testing/references/jmeter-import/import-report.md +52 -0
  32. package/skills/performance-testing/references/jmeter-import/mapping-table.md +95 -0
  33. package/skills/performance-testing/references/jmeter-import/postman-perf-capabilities.md +56 -0
  34. package/skills/performance-testing/references/jmeter-import/script-translation.md +97 -0
  35. package/skills/postman-mcp-server/SKILL.md +53 -59
  36. package/skills/postman-mcp-server/references/docs.md +0 -1
  37. package/skills/postman-mcp-server/references/learn.md +10 -9
  38. package/skills/postman-mcp-server/references/mock.md +0 -1
  39. package/skills/postman-mcp-server/references/search.md +0 -1
  40. package/skills/postman-mcp-server/references/security.md +0 -1
  41. package/skills/postman-mcp-server/references/setup.md +0 -1
  42. package/skills/postman-mcp-server/references/sync.md +0 -1
  43. package/skills/postman-mcp-server/references/test.md +0 -1
  44. package/skills/variables/SKILL.md +44 -87
  45. package/skills/webhook-testing/SKILL.md +103 -0
  46. package/skills/webhook-testing/reference/forwarding.md +10 -0
  47. package/skills/webhook-testing/reference/outbound_webhooks.md +25 -0
  48. package/skills/webhook-testing/reference/webhook_scripts.md +163 -0
@@ -1,186 +1,138 @@
1
1
  ---
2
2
  name: api-simulation
3
- description: The local development loop for a service that calls other APIs — find its dependencies in the code and the Context Graph, give each one a mock (the owning team's, or one generated from its contract), serve them together from one `.sim.yaml` on one port, run the real service against it, read the simulation's log to see what each dependency served, and ship it with the simulation in the PR. Can also inject latency, error, rate-limit or chaos per dependency. Use when the user is building or changing an endpoint that calls other services, or asks to "simulate my dependencies," "mock everything this service calls," or "run this end to end locally." Covers `postman simulation`. Builds on api-discovery for finding dependencies and their owners' mocks, and on api-mocking for the rest.
3
+ description: Runs your code for real against stand-ins for the HTTP services it calls, served together as one environment on one local port or one deployed URL, whether that code is a service you're changing, a frontend, a test suite or a demo. Use when you add or change code that calls other services and need to run it, test it, prove a fix or reproduce an upstream failure (timeouts, 5xx, 409, 429) end to end, locally or in CI, without the real services because they're unreachable, need credentials, cost money, have side effects or don't exist yet. Also answers what happens to a request, or to the data it writes, when a service it calls goes down, is slow or returns errors ("what happens to a booking if the email service is down?"), by running each failure instead of reading the code. Applies even when nobody says mock or simulation. To give a frontend or another team a stand-in for an API, use api-mocking. Covers `postman simulation`.
4
4
  ---
5
5
 
6
6
  # API Simulation
7
7
 
8
- ## Overview
9
-
10
- A simulation serves several mocks on one local port. Each member has a
11
- **routeKey**, its address: with `routing: path` (the default) a dependency
12
- lives at `http://localhost:<port>/<routeKey>`, and the routeKey is stripped
13
- before the mock sees the request. The service under test runs for real and is
14
- never a member.
15
-
16
- ```yaml
17
- # postman/simulations/feeds-dev.sim.yaml
18
- simulation: feeds-dev
19
- routing: path
20
- mocks:
21
- - routeKey: acs
22
- path: ../mocks/acs/config.yaml
23
- - routeKey: workspaces
24
- path: ../.dependencies/mocks/workspace-service/config.yaml
8
+ A simulation serves several mocks as one environment, each reached by its
9
+ routeKey: as a path prefix by default, or as an `x-mock-slug` header when the
10
+ caller's paths can't change.
11
+
12
+ Run your code against it rather than stubbing its HTTP client in tests or
13
+ calling the real services. A stub skips the client, config, timeouts and
14
+ error handling that will run in production; the real services need
15
+ credentials and leave side effects. A simulation runs that code over real
16
+ HTTP, the same way in CI, and its log shows what each dependency was asked.
17
+
18
+ Do only what the task needs. If a `.sim.yaml` in `postman/simulations/`
19
+ already covers it, run that one. One request through the changed path proves
20
+ a change; build failure variants only when asked how the code fails or when
21
+ it must survive a failure.
22
+
23
+ `postman simulation` needs CLI 1.70.0 or later (`postman --version`; an older
24
+ CLI answers `postman simulation -h` with its general help).
25
+
26
+ ## Building it
27
+
28
+ - **Members are the code's HTTP dependencies.** Databases, queues and caches
29
+ aren't; run them locally. **api-discovery** can find calls made through
30
+ shared code; ask about the repo by its `git remote` name, because a close
31
+ name matches another repo.
32
+ - **Each member needs a mock: see `api-mocking`,** which looks for the owning
33
+ team's published mock before building one. For a question, one built from
34
+ the contract will do; one that invents responses can send the caller down a
35
+ path the real service never would. In a mock you build, answer `501` for calls this path
36
+ doesn't make: a `404` reads to the caller like a real "not found".
37
+ - **Prefix each mock's `pm.state` keys with its name.** As of CLI 1.73.0,
38
+ members of a local run read each other's keys, so two mocks storing
39
+ `orders` overwrite each other.
40
+
41
+ ## Running it
42
+
43
+ The run is a server that never exits, so a foreground command never returns.
44
+ Start it in the background with an explicit port, its log in a file:
45
+
46
+ ```bash
47
+ postman simulation run postman/simulations/checkout-dev.sim.yaml --port 4900 --output ndjson > sim.ndjson 2> sim.err &
25
48
  ```
26
49
 
27
- Running a local `.sim.yaml` works signed out. Running one by id, the Context
28
- Graph, `search`, `dependency` and anything in a workspace need `postman login`.
29
- `postman simulation` needs Postman CLI 1.70.0 or later (`postman update`);
30
- earlier releases have only the older `postman simulate run`.
31
-
32
- ## Commands
33
-
34
- Most commands work either on a local `.sim.yaml` or on a simulation in a
35
- workspace:
36
-
37
- | Command | With a `.sim.yaml` path | With a simulation id |
38
- | --- | --- | --- |
39
- | `create -n <name> --mock <ref>=<routeKey>` | Writes `postman/simulations/<name>.sim.yaml` from mock paths | Creates one in the workspace from mock ids (`-w`). Don't mix the two |
40
- | `list` | Lists `postman/simulations/` | `-w <workspaceId>` lists the workspace's |
41
- | `get <pathOrId>` | Reads the file | Fetches it |
42
- | `run <pathOrId>` | Serves the members on one port | Fetches the members, then serves them locally |
43
- | `push <path>` | Uploads each member mock, then the simulation, to the linked workspace. A member pulled with `dependency add` goes up as a copy | — |
44
- | `deploy <id>` | — | Serves it at a URL, **public by default** (rule 7). `--private` requires an API key |
45
- | `delete <pathOrId>` | Deletes the file, not its mocks | Deletes it and takes its URL down |
46
-
47
- ## Process
48
-
49
- 1. **Find what the change calls.** If a `.sim.yaml` in `postman/simulations/`
50
- already covers the change, skip to step 4. Otherwise read the code path
51
- you're changing: its HTTP clients, their base-URL settings, and any call
52
- the change adds. Only HTTP dependencies become members; queues, databases
53
- and caches run as real local instances. When signed in, check that list
54
- against the Context Graph, which also sees calls made through shared code
55
- and other repositories:
56
- `postman context-graph ask "What services and APIs does <repo-name> call?" --wait`.
57
- Use the repository's name from `git remote get-url origin`, not the
58
- folder's: a wrong name answers "no dependencies", not an error. A call the
59
- change adds isn't in the graph yet.
60
-
61
- 2. **Get each dependency's mock from its owner first.** This needs
62
- `postman login`; signed out, ask the user to sign in rather than writing
63
- mocks (rule 5). For every dependency, in this order:
64
- 1. Find the owner's workspace:
65
- `postman context-graph ask "Which Postman workspace holds the collections and mocks for <service>?" --wait`.
66
- If the workspace it names has neither, find the owner's with
67
- `postman search workspaces "<service>"`.
68
- 2. List that workspace's mocks:
69
- `postman search mocks --filter "workspaceId=<id>"`. A name match in
70
- another workspace is not ownership.
71
- 3. If the owner has one, pull it with `postman dependency add mock <mockId>`
72
- and use the copy as it is, even if the owner also deployed it.
73
- 4. Only if the owner has none, make one: pull their collection with
74
- `postman dependency add collection <id>` and run `postman mock generate`
75
- on it (see `api-mocking`). Keep the endpoints this path calls and answer
76
- `501` for the rest, so a missed call fails loudly. Make it stateful when
77
- the change writes something and reads it back.
78
-
79
- 3. **Compose the simulation.**
80
-
81
- ```bash
82
- postman simulation create -n feeds-dev \
83
- --mock ./postman/mocks/acs=acs \
84
- --mock ./postman/.dependencies/mocks/workspace-service=workspaces
85
- ```
86
-
87
- Each `=<routeKey>` names a member: lowercase letters, digits, `-` and `_`.
88
- Schema: [reference/sim_yaml_schema.md](reference/sim_yaml_schema.md).
89
-
90
- 4. **Run it and point the service at it.**
91
-
92
- ```bash
93
- postman simulation run postman/simulations/feeds-dev.sim.yaml --port 4900 --output ndjson > sim.ndjson 2> sim.err &
94
- ```
95
-
96
- Keep stderr out of `sim.ndjson` so every line parses; start-up errors land
97
- in `sim.err`. It's up when the `listening` event lists each member's
98
- address. Set each upstream base URL to `http://localhost:4900/<routeKey>`,
99
- never to a mock server's URL.
100
-
101
- Stop it with
102
- `pkill -INT -f "simulation run postman/simulations/feeds-dev.sim.yaml"`:
103
- every member stops, and the closing `summary` event counts the requests
104
- served and failed. `kill $!` reaches only the `postman` launcher, which
105
- ignores it, so the simulation keeps serving. In a terminal of its own,
106
- Ctrl+C works too.
107
-
108
- 5. **Develop and test, reading the simulation log after each call.** Call
109
- the changed route on the real service with `postman request` or its
110
- collection (see `api-testing`). Every request a member served is a
111
- `request` event in `sim.ndjson`, with its `routeKey`, `method`, `path`,
112
- `statusCode`, `duration` in milliseconds, and both bodies. Check that each
113
- upstream call you expect is there, on the right member, with the status you
114
- expect. Restart the service after a code change, and the simulation after a
115
- mock edit. A response from the simulation itself means wiring, not code:
116
- - `404 Unknown simulation member`: the path has no valid routeKey. The body
117
- lists the valid ones. It isn't logged.
118
- - `501`: an upstream call you haven't modelled yet. Add it to your own
119
- mock. For a pulled one, fork it into `postman/mocks/` first.
120
- - `502 Proxy error`: the member's handler crashed. See `sim.ndjson`.
121
-
122
- 6. **Optionally, fail a dependency.** Worth doing when the change has to
123
- survive an upstream that errors or is slow, but not required. Copy the
124
- baseline `.sim.yaml`, give that member a condition, run the service
125
- against it, and report what it did.
126
-
127
- ```yaml
128
- - routeKey: workspaces
129
- path: ../.dependencies/mocks/workspace-service/config.yaml
130
- scenarios:
131
- - overrides:
132
- conditions:
133
- error: { status_code: 503 }
134
- ```
135
-
136
- The conditions are `latency`, `error`, `rate_limit` and `chaos`; the schema
137
- has all four. Each applies to every route on that member, and the first to
138
- fail a request ends it, so fail a dependency one way at a time. An injected
139
- error, `429` or chaos failure never reaches the mock and isn't logged, so
140
- judge it by what the service returned.
141
-
142
- 7. **Ship.** Commit your mocks, the `.sim.yaml` files and
143
- `.postman/resources.yaml`, but not `sim.ndjson`: it records request
144
- headers and bodies, tokens included. After a clone,
145
- `postman dependency install` restores the pulled mocks. Running the
146
- simulation in CI is optional: start it as in step 4 before the test step,
147
- and stop it after.
148
-
149
- ## Critical Rules
150
-
151
- 1. **The service under test is never a member.** If nothing real runs, use
152
- `api-mocking`.
153
- 2. **Unique routeKeys and an explicit `--port`.** A member's own `port:` is
154
- ignored. Without `--port`, a busy 3000 silently moves to a random port.
155
- 3. **Members share one `pm.state` store.** Two stateful mocks that use the
156
- same key read and overwrite each other's records, so give each its own keys.
157
- 4. **Only `overrides.conditions` inject faults.** A bare
158
- `scenarios: - path: …/default.js` entry, as the Postman app writes, adds
159
- none. `overrides.bypass` is ignored.
160
- 5. **Never write or generate a mock for a dependency before searching its
161
- owner's workspace.** A mock you write encodes your assumptions; the
162
- owner's encodes their contract and their state.
163
- 6. **Pull an owner's mock even when it's deployed.** Only members take faults
164
- and log requests, and a private mock server needs an `x-api-key` your
165
- service won't send. Never edit `postman/.dependencies/`:
166
- `dependency update` overwrites it. To change a pulled mock, copy it into
167
- `postman/mocks/` and call it a fork.
168
- 7. **Confirm before a public deploy.** `simulation deploy` without
169
- `--private`, or with `-y`, serves every member's mock to anyone with the
170
- URL. Ask the user first; a local `run` needs no deploy at all.
171
-
172
- ## Verification
173
-
174
- Starting is not the same as being used. Before you report, read the whole
175
- log: every member on the path should have `request` events with the statuses
176
- you expect. A member with none isn't wired or isn't on this path.
177
-
178
- Report:
179
-
180
- - **How the simulation performed:** for each member, the requests it served
181
- and their statuses, and anything unexpected, such as a `501`, a `502` or a
182
- member that was never called.
183
- - **Where each mock came from:** for each dependency, the owner workspace you
184
- searched, what you found there, and whether its mock was pulled, forked or
185
- generated here.
186
- - **What ran for real.**
50
+ Without `--port`, a busy 3000 silently becomes a random port and every base
51
+ URL points at nothing. It's up when `sim.ndjson` has a `listening` event; a
52
+ start-up error is in `sim.err`. It listens on 127.0.0.1 only, so a caller in
53
+ a container or VM can't reach it. Stop it with
54
+ `pkill -INT -f "simulation run <file>"`; `kill $!` leaves it running,
55
+ because the `postman` launcher ignores the signal. Nothing reloads: restart
56
+ it after a mock edit.
57
+
58
+ Point the caller at it without changing what the code does once deployed.
59
+ Under path routing, swap only the host and keep the path:
60
+ `https://catalog.internal.example.com/v2` becomes
61
+ `http://127.0.0.1:4900/catalog/v2`; a dropped `/v2` is the usual cause of a
62
+ `404`. A hard-coded base URL should read an environment variable with
63
+ today's value as the default. If the code mustn't change at all,
64
+ `simulation run --proxy` reaches the members through `HTTPS_PROXY` instead;
65
+ it applies no conditions, and passes any other host through to the real
66
+ service.
67
+
68
+ ## Reading the log
69
+
70
+ A passing test command doesn't show the dependency path ran: read
71
+ `sim.ndjson`. A member with no `request` events isn't wired or isn't on this
72
+ path. Some answers come from the simulation itself and mean wiring, not code:
73
+
74
+ - `404 Unknown simulation member`: a base URL lost its routeKey, or a client
75
+ sent the wrong `x-mock-slug`.
76
+ - `501`, or a generated mock's `404 Endpoint not defined`: a call the mock
77
+ doesn't model yet.
78
+ - `502 Proxy error`: the member's process died, usually an async throw in a
79
+ mock without `interceptRequests: true`. It stays down and logs nothing
80
+ until you restart; run that mock alone with `postman mock run` to see why.
81
+
82
+ ## When a dependency goes down
83
+
84
+ Run it rather than reason from the code: each way of going down takes a
85
+ different path through the caller, and a stub skips the client code that
86
+ picks the path. Fail the one dependency in each shape that matters, a run
87
+ each, with the others answering normally:
88
+
89
+ - **Unreachable:** point its base URL at a port nothing listens on.
90
+ - **Hanging:** give its member a `latency` condition longer than the
91
+ client's timeout. If the client sets none, that is the finding: Node's
92
+ `fetch` waits about five minutes, so say so rather than wait it out.
93
+ - **An error with a JSON body:** the `error` condition.
94
+ - **An error with an HTML body,** as proxies send: a copy of its mock whose
95
+ default handler answers `500` with HTML. No condition can do this.
96
+
97
+ Only `overrides.conditions` on a member change it. Members always serve
98
+ their default handler and ignore `x-mock-scenario`, and a `scenarios` entry
99
+ with just a `path`, as the Postman app writes, does nothing. Fields and the
100
+ other conditions are in [reference/sim_yaml_schema.md](reference/sim_yaml_schema.md). An injected
101
+ failure never reaches the mock and isn't logged, so judge it by what the
102
+ caller did, and check the other members' logs for side effects, such as
103
+ stock reserved and never released.
104
+
105
+ ## Keeping it
106
+
107
+ Commit your own mocks, the `.sim.yaml` and what `postman dependency add`
108
+ changed, so the next session or CI reruns it in one command. Don't commit
109
+ `postman/.dependencies/`: a copy goes stale when its owner updates theirs,
110
+ and `postman dependency install` restores it. Don't commit `sim.ndjson`: the
111
+ CLI redacts common auth headers and fields, but other headers and bodies are
112
+ logged as sent. In CI, `postman dependency install` needs `POSTMAN_API_KEY`,
113
+ and `postman collection run <collection> --simulation <file> --port <n>`
114
+ starts and stops the simulation around a collection run.
115
+
116
+ `postman simulation push` uploads every member to the workspace, so ask
117
+ first. It fails on a pulled member, which keeps its owner's `id:`; copy it to
118
+ `postman/mocks/` and delete that line.
119
+
120
+ ## Rules
121
+
122
+ 1. **What you're testing is never a member.** It must run for real, or the
123
+ test only proves the mock.
124
+ 2. **Pull the owner's mock even if it's deployed.** Only members take
125
+ conditions and appear in the log, and a private mock server wants a key
126
+ your code won't send.
127
+ 3. **`simulation deploy` is public by default,** unlike `mock deploy`. Ask
128
+ before deploying without `--private`; a local run needs no deploy.
129
+
130
+ ## Before you say it works
131
+
132
+ Claim nothing until what you're testing actually ran: a service printed
133
+ that it's listening and answered your request, or the frontend or test
134
+ suite finished, and its calls are in the log. If its start command exited
135
+ or hung, the run proved nothing; say so and why. Say what a pass proves,
136
+ your code against these stand-ins rather than the real services, what still
137
+ needs the real service before release, and where each mock came from,
138
+ including when you skipped the owner's.
@@ -1,112 +1,50 @@
1
- # `.sim.yaml` schema
1
+ # `.sim.yaml` reference
2
2
 
3
- The file `postman simulation run <filepath>` reads. It lives in
4
- `postman/simulations/NAME.sim.yaml`, beside the `postman/mocks/` folders it
5
- composes. `postman simulation create` writes one; the Postman app writes the
6
- same shape with `id:` fields added.
3
+ Read this when writing or debugging a `.sim.yaml` by hand.
4
+ `postman simulation create` writes the same shape; the Postman app adds
5
+ `id:` fields, which a local run ignores.
7
6
 
8
7
  ```yaml
9
- id: 01a110fc-e3f5-77eb-af59-0a711a509960 # written by the Postman app
10
- simulation: checkout-dev
11
- routing: path
12
- mocks:
13
- - id: 01a110fc-e344-72ca-9d0c-1bb83b99ec2a # written by the Postman app
14
- routeKey: products
15
- path: ../mocks/products/config.yaml
16
- scenarios:
17
- - path: ../mocks/products/default.js
18
- - routeKey: shopping-cart
19
- path: ../mocks/shopping-cart/config.yaml
8
+ simulation: checkout-dev # required: the name
9
+ routing: path # path (default) or header
10
+ mocks: # required: one entry per member
11
+ - routeKey: catalog # lowercase letters, digits, - and _
12
+ path: ../mocks/catalog/config.yaml # a mock's config.yaml, or a .js handler
13
+ scenarios: # optional: conditions, below
14
+ - overrides:
15
+ conditions:
16
+ latency: { delay_ms: 250 }
20
17
  ```
21
18
 
22
- ## Root
19
+ Run the `.sim.yaml` rather than a simulation id: a run by id drops every
20
+ member's conditions (CLI 1.70.0–1.73.0).
23
21
 
24
- | Key | Required | Notes |
25
- | --- | --- | --- |
26
- | `simulation` | Yes | The simulation's name. |
27
- | `mocks` | Yes | Non-empty list of members. |
28
- | `routing` | No | `path` (default) or `header`. Any other value means `path`. |
29
- | `id` | No | The simulation's id in its workspace. A local run ignores it; leave it as written. |
30
-
31
- ## Member
32
-
33
- | Key | Required | Notes |
34
- | --- | --- | --- |
35
- | `path` | Yes | The mock's `config.yaml`, or a `.js` handler. Relative paths resolve from the `.sim.yaml`'s folder, then from the working directory. `file` is a legacy alias. |
36
- | `routeKey` | No | The member's address. Lowercase letters, digits, `-` and `_`, at most 64 characters, unique per simulation. Defaults to the kebab-cased name. |
37
- | `name` | No | Display name. Defaults to the mock's folder name for a `config.yaml`, else the file name. Must be unique. |
38
- | `scenarios` | No | Fault conditions, below. |
39
- | `id` | No | The mock's id in its workspace. A local run ignores it. |
40
- | `port` | No | Ignored by `simulation run`, which gives each member an internal port. |
41
-
42
- ## Routing
43
-
44
- - **`path`**: a member is at `http://localhost:<port>/<routeKey>`. The first
45
- path segment selects the member and is stripped, so `/payments/cart` reaches
46
- the `payments` member as `/cart`. Point the service's base URL for that
47
- dependency at `http://localhost:<port>/<routeKey>`.
48
- - **`header`**: every member shares `http://localhost:<port>`, and the caller
49
- picks one with an `x-mock-slug: <routeKey>` header. Use it only when the
50
- caller can send that header.
51
-
52
- The router answers on its own, without reaching a member:
53
-
54
- | Response | Cause |
55
- | --- | --- |
56
- | `400 {"error":"Prefix the request path with the member routing token, e.g. /<routeKey>/path."}` | No routeKey under `path` routing: the path was `/`. Under `header` routing the error asks for the `x-mock-slug` header instead. |
57
- | `404 {"error":"Unknown simulation member '<x>'.","available":[...]}` | `<x>` isn't a routeKey. Under `path` routing this is often a client that dropped the base URL's path, so `<x>` is the endpoint's own first segment. |
58
-
59
- ## `scenarios`
60
-
61
- Each entry is a selection, and only its `overrides.conditions` inject faults:
62
-
63
- ```yaml
64
- scenarios:
65
- - overrides:
66
- conditions:
67
- latency:
68
- delay_ms: 250 # hold each request 250 ms, then go on
69
- error:
70
- status_code: 503 # every request fails with 503
71
- rate_limit:
72
- requests_per_minute: 30 # the 31st request in a minute gets 429
73
- chaos:
74
- failure_rate: 10 # 10% of requests fail with 500
75
- ```
76
-
77
- This example sets all four to show their fields. They run in a fixed order,
78
- `latency`, `error`, `rate_limit`, `chaos`, whatever order you write them in,
79
- and the first to fail a request ends it: with `error` set, `rate_limit` and
80
- `chaos` never fire. Set one failure at a time, optionally with `latency`.
81
-
82
- The mock's default handler always serves, and conditions run in front of it.
83
- An entry with only `path` or `id`, as the Postman app writes, injects nothing.
84
- Unknown condition names are ignored, so a misspelled one fails silently.
85
- `overrides.bypass` prints a warning and is ignored.
86
-
87
- The legacy form `- type: error` with `config: { status_code: 503 }` is still
88
- accepted and validated strictly: an unknown `type` is an error.
22
+ ## Conditions
89
23
 
90
24
  | Condition | Field | Effect |
91
25
  | --- | --- | --- |
92
- | `latency` | `delay_ms` (positive number) | Holds each request that long, then serves it normally. |
93
- | `error` | `status_code` (integer 400–599) | Every request returns that status with `{"error":{...},"scenario":"error"}`. |
94
- | `rate_limit` | `requests_per_minute` (positive integer) | Requests over the limit return `429` with a `Retry-After` header and `"scenario":"rate_limit"`. |
95
- | `chaos` | `failure_rate` (0–100) | That percentage of requests, chosen at random, return `500` with `"scenario":"chaos"`. |
96
-
97
- A condition applies to every route on its member. To fail one endpoint while
98
- its siblings succeed, split that endpoint into its own mock.
99
-
100
- ## `simulation run`
101
-
102
- | Flag | Notes |
103
- | --- | --- |
104
- | `-p, --port <n\|auto>` | Port to serve on. Defaults to 3000, and silently falls back to a free port if 3000 is busy. An explicit port fails instead. |
105
- | `--output ndjson` | One JSON event per line on stdout, instead of the default readable log; messages go to stderr: `listening` (port, url, each member's `routeKey` and `address`); `request`, one per request a member served (`routeKey`, `method`, `path`, `statusCode`, `duration` in ms, headers and bodies); and `summary` on shutdown (`requestsServed`, `requestsFailed`). The router's own `400` and `404`, and injected faults, aren't logged. |
106
- | `-e`, `-g`, `--dataset` | Environment, globals and datasets for every member, as for `mock run`. |
107
- | `--no-history` | Record nothing. A `.sim.yaml` linked to a workspace otherwise records each start there; an unlinked one records only with `-w` and `--simulation`. |
108
-
109
- The argument can also be a simulation id from a workspace: the members are
110
- fetched and served locally. All members start before the port opens, so one
111
- `listening` event means the whole simulation is up. A member that fails to
112
- start stops the run with `Error: ...` and exit code 1. Ctrl+C stops everything.
26
+ | `latency` | `delay_ms` | Holds each request that long, then serves it. |
27
+ | `error` | `status_code` (400–599) | Every request gets that status as JSON, with `"scenario":"error"`. |
28
+ | `rate_limit` | `requests_per_minute` | Requests over the limit get `429` and `Retry-After`. |
29
+ | `chaos` | `failure_rate` (0–100), optional `status_code` | That share of requests, at random, get `500` or that status. |
30
+
31
+ - A condition covers every route on its member. To fail one endpoint while
32
+ its siblings succeed, give that endpoint a mock of its own.
33
+ - They run in a fixed order (`latency`, `error`, `rate_limit`, `chaos`), and
34
+ the first to fail a request ends it, so set one failure at a time,
35
+ optionally with `latency`.
36
+ - An unknown condition name is ignored silently, so a misspelling injects
37
+ nothing. `overrides.bypass` prints a warning and is ignored.
38
+ - A `latency` request is served and logged, with a `duration` that leaves
39
+ out the delay.
40
+
41
+ ## The log (`--output ndjson`)
42
+
43
+ One JSON event per line on stdout; notices go to stderr, so keep them apart.
44
+
45
+ - `listening`: every member has started; a member that fails to start
46
+ stops the run with `Error: …` and exit code 1.
47
+ - `request`: one per request a member served.
48
+ - `summary`, on stop: `requestsServed` (under 400), `requestsFailed` (400
49
+ and up), `uptimeMs` and `signal`. Injected failures and the simulation's
50
+ own `400`, `404` and `502` aren't counted.