{"_id":"@alkdev/typemap","name":"@alkdev/typemap","dist-tags":{"latest":"0.10.1"},"versions":{"0.10.1":{"name":"@alkdev/typemap","version":"0.10.1","description":"Syntax Compiler and Translation System for Runtime Types","author":{"name":"alkdev"},"license":"MIT","repository":{"type":"git","url":"https://git.alk.dev/alkdev/typemap"},"scripts":{"test":"echo test"},"types":"./build/cjs/index.d.ts","main":"./build/cjs/index.js","module":"./build/esm/index.mjs","esm.sh":{"bundle":false},"exports":{".":{"require":{"types":"./build/cjs/index.d.ts","default":"./build/cjs/index.js"},"import":{"types":"./build/esm/index.d.mts","default":"./build/esm/index.mjs"}}},"peerDependencies":{"@alkdev/typebox":"^0.34.49","valibot":"^1.0.0","zod":"^3.24.1"},"_id":"@alkdev/typemap@0.10.1","_integrity":"sha512-nCrZrrxgyWr3xBXjCWhUj56rH/Yb64l96Yl8gr3fYF5JS+nfiTgLcJ0shRvSAA8nznsiPfMJgmNrTGsdyHYs2g==","_resolved":"/workspace/@alkdev/typemap/target/build/alkdev-typemap-0.10.1.tgz","_from":"file:/workspace/@alkdev/typemap/target/build/alkdev-typemap-0.10.1.tgz","_nodeVersion":"25.8.1","_npmVersion":"11.11.0","dist":{"integrity":"sha512-nCrZrrxgyWr3xBXjCWhUj56rH/Yb64l96Yl8gr3fYF5JS+nfiTgLcJ0shRvSAA8nznsiPfMJgmNrTGsdyHYs2g==","shasum":"5d2e9887822eadc7f8a57fee45cc53e540601daa","tarball":"https://registry.npmjs.org/@alkdev/typemap/-/typemap-0.10.1.tgz","fileCount":123,"unpackedSize":333709,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCG4XomOaK+iZF/oxNDY1hjpep547PSKGcffCZmpfaMlgIhANXEusyYD4VE9S1QNkCw7YGIxZU+yZZcN83Mr2Gaz9Q2"}]},"_npmUser":{"name":"alkdev","email":"admin@alk.dev"},"directories":{},"maintainers":[{"name":"alkdev","email":"admin@alk.dev"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/typemap_0.10.1_1776961146206_0.5990734626743364"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-23T16:19:06.084Z","0.10.1":"2026-04-23T16:19:06.360Z","modified":"2026-04-23T16:19:06.578Z"},"maintainers":[{"name":"alkdev","email":"admin@alk.dev"}],"description":"Syntax Compiler and Translation System for Runtime Types","repository":{"type":"git","url":"https://git.alk.dev/alkdev/typemap"},"author":{"name":"alkdev"},"license":"MIT","readme":"<div align='center'>\n\n<h1>TypeMap</h1>\n\n<p>Syntax Compiler and Translation System for Runtime Types</p>\n\n<br />\n<br />\n\n[![License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n</div>\n\n## About This Fork\n\nThis is the **@alkdev/typemap** fork — a community-maintained continuation of TypeMap 0.x. The original TypeMap project has been archived after a complete rewrite; this fork continues the 0.x API with the `@alkdev/typebox` backend.\n\n- **Supply chain security**: Published from our own infrastructure; no dependency on upstream publish access.\n- **Stability**: No breaking rewrites planned. Bug fixes and compatibility patches only.\n- **Drop-in replacement**: `@alkdev/typemap` is API-compatible with `@sinclair/typemap` 0.x, using `@alkdev/typebox` in place of `@sinclair/typebox`.\n\n## Install\n\n```bash\n$ npm install @alkdev/typemap --save\n```\n\n## Usage\n\nParse and Compile Types from TypeScript Syntax\n\n```typescript\nimport { Compile } from \"@alkdev/typemap\";\n\nconst validator = Compile(`{ a: string, b: string }`);\n\nconst result = validator[\"~standard\"].validate({\n  a: \"hello\",\n  b: \"world\",\n});\n```\n\n## Overview\n\nTypeMap is a syntax frontend and compiler backend for the [TypeBox](https://git.alk.dev/alkdev/typebox), [Valibot](https://github.com/fabian-hiller/valibot) and [Zod](https://github.com/colinhacks/zod) runtime type libraries. It offers a common TypeScript syntax for type construction, a runtime compiler for high-performance validation and type translation from one library to another.\n\n## Example\n\nUse TypeScript syntax to create types for TypeBox, Valibot and Zod\n\n```typescript\nimport { TypeBox, Valibot, Zod } from \"@alkdev/typemap\";\n\nconst S = `{\n  x: number,\n  y: number,\n  z: number\n}`;\n\nconst T = TypeBox(S);\nconst V = Valibot(S);\nconst Z = Zod(S);\n```\n\nTranslate TypeBox, Valibot and Zod types\n\n```typescript\nimport { TypeBox, Valibot, Zod } from \"@alkdev/typemap\";\n\nconst T = TypeBox(\n  Valibot(\n    Zod(`{\n  x: number,\n  y: number,\n  z: number\n}`),\n  ),\n);\n```\n\n## Mapping\n\nTypeMap is designed for runtime type translation. It provides one mapping function per library which can be used to translate remote types into types specific to that library.\n\n### Syntax\n\n```typescript\nimport { Syntax } from \"@alkdev/typemap\";\n\nconst S = Syntax(\"string[]\");\nconst T = Syntax(t.Number());\nconst V = Syntax(v.string());\nconst Z = Syntax(z.boolean());\n```\n\n### TypeBox\n\n```typescript\nimport { TypeBox } from \"@alkdev/typemap\";\n\nconst S = TypeBox(\"string[]\");\nconst T = TypeBox(t.Number());\nconst V = TypeBox(v.string());\nconst Z = TypeBox(z.boolean());\n```\n\n### Valibot\n\n```typescript\nimport { Valibot } from \"@alkdev/typemap\";\n\nconst S = Valibot(\"string[]\");\nconst T = Valibot(t.Number());\nconst V = Valibot(v.string());\nconst Z = Valibot(z.boolean());\n```\n\n### Zod\n\n```typescript\nimport { Zod } from \"@alkdev/typemap\";\n\nconst S = Zod(\"string[]\");\nconst T = Zod(t.Number());\nconst V = Zod(v.string());\nconst Z = Zod(z.boolean());\n```\n\n## Syntax\n\nTypeMap provides an optional TypeScript syntax parser that can be used to construct library types. Syntax parsing is implemented at runtime as well as in the type system.\n\n### Types\n\n```typescript\nimport { TypeBox } from \"@alkdev/typemap\";\n\nconst T = TypeBox(\"{ x: 1, y: 2 }\");\n\nconst S = TypeBox(\"!!!\");\n```\n\n### Options\n\n```typescript\nimport { TypeBox, Zod } from \"@alkdev/typemap\";\n\nconst T = TypeBox(\"string\", {\n  format: \"email\",\n});\n\nconst S = Zod(\"{ x?: number }\", {\n  additionalProperties: false,\n});\n```\n\n### Parameters\n\n```typescript\nimport { Valibot, Zod } from \"@alkdev/typemap\";\n\nconst V = Valibot(\"number\");\n\nconst Z = Zod({ V }, `{ values: V[] }`);\n```\n\n### Generics\n\n```typescript\nimport { TypeBox, Valibot, Zod } from \"@alkdev/typemap\";\n\nconst Vector = <T extends object>(T: T) =>\n  TypeBox(\n    { T },\n    `{ \n  x: T, \n  y: T, \n  z: T \n}`,\n  );\n\nconst T = Vector(Valibot(\"number\"));\n\nconst S = Vector(Zod(\"string\"));\n```\n\n## Static\n\nUse Static to infer for library and syntax types\n\n```typescript\nimport { type Static } from \"@alkdev/typemap\";\n\nconst T = t.Number();\nconst V = v.string();\nconst Z = z.boolean();\nconst S = \"string[]\";\n\ntype S = Static<typeof S>;\ntype T = Static<typeof T>;\ntype V = Static<typeof V>;\ntype Z = Static<typeof Z>;\n```\n\n## Json Schema\n\nUse `TypeBox` to transform remote library types into Json Schema\n\n```typescript\nimport { TypeBox as JsonSchema } from \"@alkdev/typemap\";\n\nconst Z = z\n  .object({\n    x: z.number(),\n    y: z.number(),\n    z: z.number(),\n  })\n  .strict();\n\nconst T = JsonSchema(Z);\n```\n\n## Tree Shake\n\nTypeMap takes on TypeBox, Valibot and Zod as peer dependencies. If bundling, it is recommended that you import specific translation functions to enable unused libraries to be omitted from the bundle.\n\n```typescript\nimport { TypeBoxFromZod } from \"@alkdev/typemap\";\n\nimport * as z from \"zod\";\n\nconst T = TypeBoxFromZod(\n  z.object({\n    x: z.number(),\n    y: z.number(),\n    z: z.number(),\n  }),\n);\n```\n\n## Compile\n\nUse the `Compile` function to compile TypeBox, Valibot and Zod on TypeBox infrastructure\n\n```typescript\nimport { Compile, Zod } from \"@alkdev/typemap\";\n\nconst validator = Compile(\n  Zod(`{\n   x: number,\n   y: number,\n   z: number\n}`),\n);\n\nconst R1 = validator.Check({ x: 1, y: 2, z: 3 });\n\nconst R2 = validator[\"~standard\"].validate({ x: 1, y: 2, z: 3 });\n```\n\n## Contribute\n\nThis project is open to community contributions. Please ensure you submit an open issue before creating a pull request.\n\nLicense: MIT\n","readmeFilename":"readme.md","_rev":"1-5e51ac5e06950dc9996c59a8e52d1ecc"}