{
  "schema": "leumas.docs.page/1",
  "id": "adapter:domain/api-mocker",
  "slug": "adapters/domain/api-mocker",
  "kind": "capabilities",
  "bucket": "package",
  "title": "api-mocker",
  "name": "API Mocker",
  "eyebrow": null,
  "chip": null,
  "summary": "Intelligent API mocking & fake-data microservice: turn a JSON Schema into realistic example instances (mockFromSchema), stand up a mock REST endpoint response envelope with N seeded rows...",
  "keywords": [
    "api-mocker",
    "mocking",
    "fake-data",
    "realistic",
    "mockfromschema",
    "api mocker api",
    "mockendpoint",
    "field-"
  ],
  "audience": "both",
  "funnel": {
    "product": null,
    "cta": null
  },
  "body": "# api-mocker\n\nIntelligent API mocking & fake-data microservice. Turn a JSON Schema or a `{ field: type }` spec into\nrealistic example data, mock REST response envelopes, seed datasets/fixtures, and canonical HTTP\nstatus scenarios (200 / 4xx / 5xx bodies). Deterministic and seedable — great for prototyping\nfrontends, stubbing backends, contract tests, and demo data.\n\n## Tools\n\n| Tool | Purpose |\n|---|---|\n| `mockFromSchema` | JSON Schema → one realistic example instance (or N with `count`). Optional LLM enrichment via `options.enrich`. |\n| `mockEndpoint` | A full mock REST response: N seeded rows from a schema wrapped with pagination `meta` + self link. |\n| `fakeRecord` | One fake record from a `{ field: type }` spec. |\n| `generateDataset` | A whole seed dataset / fixture table (rows + summary; optional CSV via `options.format:'csv'`). |\n| `statusScenarios` | Canonical HTTP status responses with realistic JSON bodies for error-handling tests. |\n\n### Field-type tokens (for `fields`)\n\n`name`, `firstName`, `lastName`, `username`, `email`, `phone`, `uuid`, `id`, `url`, `image`, `ip`,\n`city`, `address`, `company`, `country`, `zip`, `role`, `status`, `tag`, `color`, `bool`, `date`,\n`datetime`, `price`, `currency`, `int:18-90`, `float:0-1`, `enum:admin|user|guest`, `string:12`,\n`sentence`, `paragraph`, `slug`, `word`. Nested objects and `[elementType, count]` arrays are supported.\n\n## Usage\n\n```js\nimport mocker from './index.js';\n\n// Fake records from a spec\nmocker.adapters.fakeRecord({ fields: { id: 'uuid', name: 'name', email: 'email', role: 'enum:admin|user', age: 'int:18-90' }, seed: 1 });\n\n// Seed dataset (10 rows) + CSV\nmocker.adapters.generateDataset({ fields: { id: 'id', title: 'sentence', price: 'price' }, count: 10, seed: 2, options: { format: 'csv' } });\n\n// Mock endpoint from a JSON Schema\nmocker.adapters.mockEndpoint({ schema: { type: 'object', properties: { id: { type: 'integer' }, name: { type: 'string' } }, required: ['id', 'name'] }, count: 3, resource: 'users' });\n\n// HTTP status scenarios\nmocker.adapters.statusScenarios({ statuses: [200, 404, 422, 500], resource: 'user' });\n```\n\n## Hybrid intelligence\n\nEvery tool has a deterministic, offline heuristic core (seedable PRNG + field-type faker). `mockFromSchema`\nadditionally supports an optional LLM path (`options.enrich: true`) that asks a reachable model to fill\ndomain-plausible values; if no model is configured/reachable it silently falls back to the heuristic.\nResults are tagged `{ mode: 'heuristic' | 'llm' }`. No tool ever requires a model.\n\n## DRY boundaries\n\n- **`schema`** owns real JSON-Schema authoring/validation/diff/merge/TS-emit. This pack reuses the\n  schema→instance *concept* with a compact self-contained generator; it does not import `schema`.\n- **`lorem`** owns themed placeholder prose and simple fake people. This pack has its own small faker\n  banks tuned for API fixtures (roles, statuses, prices, endpoints); it does not import `lorem`.\n\nOnly cross-pack import: `../_shared/llm.js`.\n",
  "source": {
    "path": "shared/engines/adapters/domain/api-mocker/README.md",
    "blobSha": "",
    "commit": "",
    "committedAt": "",
    "provenance": "no-git",
    "bytes": 3230,
    "hash": "e31954c7a150b55977aa70a423dccc56dc5856e2"
  },
  "urls": {
    "html": "/p/adapters/domain/api-mocker",
    "json": "/docs/adapters/domain/api-mocker.json",
    "md": "/docs/adapters/domain/api-mocker.md"
  },
  "links": {
    "composes": [],
    "usedBy": [],
    "product": [],
    "howTo": [],
    "skills": []
  }
}
