@zenera/faker 1.1.2 → 1.1.4

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 (3) hide show
  1. package/README.md +11 -10
  2. package/dist/setup.js +3 -3
  3. package/package.json +3 -3
package/README.md CHANGED
@@ -16,7 +16,7 @@ serves it — the response bodies are written, once, by a model.**
16
16
  Node.js 24+ and [podman](https://podman.io). Install it alongside the CLI:
17
17
 
18
18
  ```sh
19
- npm i -g @zenera/cli @zenera/faker openai
19
+ npm i -g @zenera/cli @zenera/faker
20
20
  zen key add openai # the keyring `zen` already uses
21
21
  ```
22
22
 
@@ -52,12 +52,12 @@ zen faker cache clear # throw it away
52
52
 
53
53
  The first time an operation is called, the faker asks a model to write a
54
54
  **Python generator** for it — one file, taking a JSON input path and a JSON
55
- output path. That file is then run against synthetic probes and judged twice:
56
- against the operation's response schema, and against the echo rule, which says
57
- that where a path or query parameter shares a name with a property in the
58
- response, the response has to carry the value that was asked for.
59
- `GET /users/12324` answering with somebody else's id validates perfectly and is
60
- still wrong.
55
+ output path. That file is then run against sample requests it makes up, and
56
+ judged twice: against the operation's response schema, and against the echo
57
+ rule, which says that where a path or query parameter shares a name with a
58
+ property in the response, the response has to carry the value that was asked
59
+ for. `GET /users/12324` answering with somebody else's id validates perfectly
60
+ and is still wrong.
61
61
 
62
62
  If it fails, the diagnostics go back to the model and it tries again, up to
63
63
  `--attempts`. If it passes, the file is cached under `~/.zenera/neo/faker` and
@@ -75,9 +75,10 @@ zen faker build <spec...> Write every generator now and exit.
75
75
  zen faker cache ls | clear What has been generated, or throw it away.
76
76
  ```
77
77
 
78
- Useful options: `--port`, `--host` (loopback by default), `--model`, `--seed`
79
- (same request, same answer), `--rebuild`, `--attempts`, `--concurrency`,
80
- `--timeout`, `--cache <dir>`, `--quiet`. `zen help faker` prints the full table.
78
+ Useful options: `--port`, `--host` (reachable only from this machine by
79
+ default), `--model`, `--seed` (same request, same answer), `--rebuild`,
80
+ `--attempts`, `--concurrency`, `--timeout`, `--cache <dir>`, `--quiet`.
81
+ `zen help faker` prints the full table.
81
82
 
82
83
  `GET /__faker/routes` lists what is being served; `GET /__faker/health` is a
83
84
  health check.
package/dist/setup.js CHANGED
@@ -1,7 +1,7 @@
1
+ import { credentialError, ensureHome, ensurePodmanReady, envNames, invalidError, KeyStore, paths, PROVIDERS, } from '@zenera/cli/lib';
2
+ import { createModel } from '@zenera/neo';
1
3
  import { mkdirSync } from 'node:fs';
2
4
  import { resolve } from 'node:path';
3
- import { credentialError, ensureHome, ensurePodmanReady, invalidError, KeyStore, paths, PROVIDERS, SHAPES, } from '@zenera/cli/lib';
4
- import { createModel } from '@zenera/neo';
5
5
  import { Box } from "./box.js";
6
6
  import { Cache } from "./cache.js";
7
7
  import { ensureImage } from "./image.js";
@@ -70,7 +70,7 @@ export async function open(opts) {
70
70
  * itself is a better test than a round trip that costs the same.
71
71
  */
72
72
  function defaultRef(keys) {
73
- const provider = PROVIDERS.find((p) => process.env[SHAPES[p].env]) ??
73
+ const provider = PROVIDERS.find((p) => envNames(p).some((name) => process.env[name])) ??
74
74
  PROVIDERS.find((p) => keys.active(p) !== undefined);
75
75
  if (!provider) {
76
76
  throw credentialError('no credentials for any provider', 'add one with: zen key add openai');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenera/faker",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "description": "Mock HTTP server for swagger/OpenAPI documents, with response bodies generated by a model.",
5
5
  "keywords": [
6
6
  "openapi",
@@ -45,7 +45,7 @@
45
45
  "@apidevtools/swagger-parser": "^12.0.0",
46
46
  "ajv": "^8.17.1",
47
47
  "ajv-formats": "^3.0.1",
48
- "@zenera/cli": "^1.1.2",
49
- "@zenera/neo": "^1.1.2"
48
+ "@zenera/cli": "^1.1.4",
49
+ "@zenera/neo": "^1.1.4"
50
50
  }
51
51
  }