{"id":13469560,"url":"https://github.com/unjs/untyped","last_synced_at":"2025-06-10T22:42:00.863Z","repository":{"id":37391881,"uuid":"349742856","full_name":"unjs/untyped","owner":"unjs","description":"Generate types and markdown from a config object.","archived":false,"fork":false,"pushed_at":"2025-04-08T01:12:30.000Z","size":1647,"stargazers_count":486,"open_issues_count":22,"forks_count":21,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-17T12:38:06.694Z","etag":null,"topics":["config","generator","markdown","typescript"],"latest_commit_sha":null,"homepage":"https://untyped.unjs.io/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/unjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-20T14:10:37.000Z","updated_at":"2025-04-08T03:38:01.000Z","dependencies_parsed_at":"2024-01-26T09:27:16.002Z","dependency_job_id":"ae451ad3-8cce-4bc9-8376-0a4f7581ec05","html_url":"https://github.com/unjs/untyped","commit_stats":{"total_commits":179,"total_committers":9,"mean_commits":19.88888888888889,"dds":0.4860335195530726,"last_synced_commit":"b4c13a3a5710d62568b1a23aa9635b216548d9d5"},"previous_names":["unjs/magic-schema"],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unjs%2Funtyped","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unjs%2Funtyped/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unjs%2Funtyped/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unjs%2Funtyped/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/unjs","download_url":"https://codeload.github.com/unjs/untyped/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unjs%2Funtyped/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259165995,"owners_count":22815544,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["config","generator","markdown","typescript"],"created_at":"2024-07-31T15:01:44.890Z","updated_at":"2025-06-10T22:42:00.820Z","avatar_url":"https://github.com/unjs.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","typescript"],"sub_categories":[],"readme":"# untyped\n\n\u003c!-- automd:badges bundlejs --\u003e\n\n[![npm version](https://img.shields.io/npm/v/untyped)](https://npmjs.com/package/untyped)\n[![npm downloads](https://img.shields.io/npm/dm/untyped)](https://npm.chart.dev/untyped)\n[![bundle size](https://img.shields.io/bundlejs/size/untyped)](https://bundlejs.com/?q=untyped)\n\n\u003c!-- /automd --\u003e\n\n**▶️ Check [online playground](https://untyped.unjs.io)**\n\n## Install\n\n\u003c!-- automd:pm-i --\u003e\n\n```sh\n# ✨ Auto-detect\nnpx nypm install untyped\n\n# npm\nnpm install untyped\n\n# yarn\nyarn add untyped\n\n# pnpm\npnpm install untyped\n\n# bun\nbun install untyped\n\n# deno\ndeno install untyped\n```\n\n\u003c!-- /automd --\u003e\n\n## Usage\n\nFirst we have to define a reference object that describes types, defaults, and a `$resolve` method (normalizer).\n\n```js\nconst defaultPlanet = {\n  name: \"earth\",\n  specs: {\n    gravity: {\n      $resolve: (val) =\u003e Number.parseFloat(val),\n      $default: \"9.8\",\n    },\n    moons: {\n      $resolve: (val = [\"moon\"]) =\u003e [val].flat(),\n      $schema: {\n        title: \"planet moons\",\n      },\n    },\n  },\n};\n```\n\n## API\n\n### `resolveSchema`\n\n```js\nimport { resolveSchema } from \"untyped\";\n\nconst schema = await resolveSchema(defaultPlanet);\n```\n\nOutput:\n\n```json\n{\n  \"properties\": {\n    \"name\": {\n      \"type\": \"string\",\n      \"default\": \"earth\"\n    },\n    \"specs\": {\n      \"properties\": {\n        \"gravity\": {\n          \"default\": 9.8,\n          \"type\": \"number\"\n        },\n        \"moons\": {\n          \"title\": \"planet moons\",\n          \"default\": [\"moon\"],\n          \"type\": \"array\",\n          \"items\": [\n            {\n              \"type\": \"string\"\n            }\n          ]\n        }\n      },\n      \"type\": \"object\"\n    }\n  },\n  \"type\": \"object\"\n}\n```\n\n### `generateTypes`\n\n```js\nimport { resolveSchema, generateTypes } from \"untyped\";\n\nconst types = generateTypes(await resolveSchema(defaultPlanet));\n```\n\nOutput:\n\n```ts\ninterface Untyped {\n  /** @default \"earth\" */\n  name: string;\n\n  specs: {\n    /** @default 9.8 */\n    gravity: number;\n\n    /**\n     * planet moons\n     * @default [\"moon\"]\n     */\n    moons: string[];\n  };\n}\n```\n\n### `generateMarkdown`\n\n```js\nimport { resolveSchema, generateMarkdown } from \"untyped\";\n\nconst markdown = generateMarkdown(await resolveSchema(defaultPlanet));\n```\n\nOutput:\n\n```markdown\n# `name`\n\n- **Type**: `string`\n- **Default**: `\"earth\"`\n\n# `specs`\n\n## `gravity`\n\n- **Type**: `number`\n- **Default**: `9.8`\n\n## `moons`\n\n- **Type**: `array`\n- **Default**: `[\"moon\"]`\n```\n\n## 💻 Development\n\n- Clone this repository\n- Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable` (use `npm i -g corepack` for Node.js \u003c 16.10)\n- Install dependencies using `pnpm install`\n- Run interactive tests using `pnpm dev`\n- Use `pnpm web` to start playground website\n- Use `pnpm test` before push to ensure all tests and lint checks passing\n\n## License\n\n[MIT](./LICENSE)\n\nThanks to [@dominikschreiber](https://github.com/dominikschreiber) for donating package name.\n\n\u003c!-- Badges --\u003e\n\n[npm-version-src]: https://img.shields.io/npm/v/untyped?style=flat-square\n[npm-version-href]: https://npmjs.com/package/untyped\n[npm-downloads-src]: https://img.shields.io/npm/dm/untyped?style=flat-square\n[npm-downloads-href]: https://npmjs.com/package/untyped\n[github-actions-src]: https://img.shields.io/github/actions/workflow/status/unjs/untyped/ci.yml?branch-main\u0026style=flat-square\n[github-actions-href]: https://github.com/unjs/untyped/actions?query=workflow%3Aci\n[codecov-src]: https://img.shields.io/codecov/c/gh/unjs/untyped/main?style=flat-square\n[codecov-href]: https://codecov.io/gh/unjs/untyped\n[bundle-src]: https://img.shields.io/bundlephobia/minzip/untyped?style=flat-square\n[bundle-href]: https://bundlephobia.com/result?p=untyped\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funjs%2Funtyped","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funjs%2Funtyped","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funjs%2Funtyped/lists"}