@amritk/generate-examples 0.5.3 → 0.5.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 (2) hide show
  1. package/AI.md +37 -0
  2. package/package.json +5 -4
package/AI.md ADDED
@@ -0,0 +1,37 @@
1
+ # @amritk/generate-examples — notes for AI coding agents
2
+
3
+ Programmatic API: turn a JSON Schema into test data — a fast-check arbitrary
4
+ (`FooArbitrary`) and a concrete example value (`fooExample`) per node, plus
5
+ types. Full reference is [README.md](./README.md).
6
+
7
+ > Pre-alpha: APIs and generated output change pre-1.0.
8
+
9
+ ## Minimal example
10
+
11
+ ```ts
12
+ import { buildExampleSchema } from '@amritk/generate-examples'
13
+
14
+ const schema = {
15
+ type: 'object',
16
+ properties: { id: { type: 'string', format: 'uuid' }, age: { type: 'integer', minimum: 0 } },
17
+ required: ['id'],
18
+ } as const
19
+
20
+ const files = await buildExampleSchema(schema, 'User') // → user.ts, index.ts
21
+ ```
22
+
23
+ ## Gotchas — where agents fail
24
+
25
+ 1. **Generated arbitrary files `import * as fc from 'fast-check'`** — `fast-check`
26
+ (`>=3`) is an **optional peer dependency** consumers must install. The static
27
+ `fooExample` values have no runtime deps.
28
+ 2. **`generateArbitrary` / `generateExampleConst` return source-code STRINGS**;
29
+ **`deriveExample` returns an actual runtime VALUE.** Easy to confuse.
30
+ 3. **A static example constrained only by `pattern` may not match the pattern** —
31
+ use the arbitrary when pattern fidelity matters.
32
+ 4. **Unsupported keywords degrade silently:** `fc.anything()` in arbitraries,
33
+ `null` in static examples — no error thrown.
34
+
35
+ Exports: `buildExampleSchema`, `generateArbitrary`, `generateExampleConst`,
36
+ `deriveExample`, `serializeValue`, `GeneratedFile`. Only the `.` entry.
37
+ Install: `bun add @amritk/generate-examples`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amritk/generate-examples",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "description": "Generate fast-check arbitraries and example values from JSON Schemas.",
5
5
  "module": "./dist/index.js",
6
6
  "type": "module",
@@ -26,7 +26,8 @@
26
26
  "url": "https://github.com/amritk/mjst/issues"
27
27
  },
28
28
  "files": [
29
- "dist"
29
+ "dist",
30
+ "AI.md"
30
31
  ],
31
32
  "publishConfig": {
32
33
  "access": "public"
@@ -47,8 +48,8 @@
47
48
  },
48
49
  "dependencies": {
49
50
  "json-schema-typed": "^8.0.1",
50
- "@amritk/helpers": "0.13.3",
51
- "@amritk/runtime-validators": "0.7.3"
51
+ "@amritk/helpers": "0.13.4",
52
+ "@amritk/runtime-validators": "0.8.0"
52
53
  },
53
54
  "devDependencies": {
54
55
  "ajv": "^8.17.1"