{"_id":"@boostpack/joi-extract-type","_rev":"2-fd4fb2e62d16ef1a7d43a07be49216f3","name":"@boostpack/joi-extract-type","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@boostpack/joi-extract-type","version":"1.0.0","keywords":["boostpack","joi","typescript","type-safe","type-extraction","module-augmentation","validation"],"license":"MIT","_id":"@boostpack/joi-extract-type@1.0.0","maintainers":[{"name":"timur2915","email":"timur2915@gmail.com"}],"contributors":[{"name":"Timur Popov","email":"timur2915@gmail.com"}],"homepage":"https://github.com/boostpack/boostpack#readme","bugs":{"url":"https://github.com/boostpack/boostpack/issues"},"nx":{"tags":["scope:shared"]},"dist":{"shasum":"3b2b0e7e9e418f905d410fbcfa0bacad64d4b422","tarball":"https://registry.npmjs.org/@boostpack/joi-extract-type/-/joi-extract-type-1.0.0.tgz","fileCount":9,"integrity":"sha512-KwMvUTKP3FlS26AlGrWhQWJWh/wnqU4JaWGerFcjdzOBxb5NdEklNiTDgGN6GJ26Cu304YTmF1TXLNy3N0cFig==","signatures":[{"sig":"MEYCIQCMNSCKon2bStzCLjk0odVtR04Y71UA6agUfVj8nKlwfwIhAIKktmgWcvW4AsIbhD+GEoo3MfNs3H1SdhFvb8fDZZv9","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":33655},"main":"./dist/index.cjs.js","types":"./dist/index.esm.d.ts","module":"./dist/index.esm.js","exports":{".":{"types":"./dist/index.esm.d.ts","import":"./dist/index.esm.js","default":"./dist/index.esm.js","require":"./dist/index.cjs.js","@boostpack/source":"./src/index.ts"},"./package.json":"./package.json"},"gitHead":"14be53d346c7c81977f2f4e9fc23c6d687ebc9fd","_npmUser":{"name":"timur2915","email":"timur2915@gmail.com"},"repository":{"url":"git+https://github.com/boostpack/boostpack.git","type":"git","directory":"packages/shared/joi-extract-type"},"_npmVersion":"11.6.2","description":"TypeScript type extraction for Joi schemas via module augmentation","directories":{},"_nodeVersion":"24.13.0","_hasShrinkwrap":false,"peerDependencies":{"joi":">=17.0.0"},"_npmOperationalInternal":{"tmp":"tmp/joi-extract-type_1.0.0_1771623173126_0.33793448265526416","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@boostpack/joi-extract-type","version":"1.0.1","description":"TypeScript type extraction for Joi schemas via module augmentation","license":"MIT","contributors":[{"name":"Timur Popov","email":"timur2915@gmail.com"}],"repository":{"type":"git","url":"git+https://github.com/boostpack/boostpack.git","directory":"packages/shared/joi-extract-type"},"main":"./dist/index.cjs.js","module":"./dist/index.esm.js","types":"./dist/index.d.ts","exports":{"./package.json":"./package.json",".":{"@boostpack/source":"./src/index.ts","types":"./dist/index.d.ts","import":"./dist/index.esm.js","require":"./dist/index.cjs.js","default":"./dist/index.esm.js"}},"keywords":["boostpack","joi","typescript","type-safe","type-extraction","module-augmentation","validation"],"nx":{"tags":["scope:shared"]},"peerDependencies":{"joi":">=17.0.0"},"gitHead":"6f4103b16e89152312fa1f989c0141ecee863cb1","_id":"@boostpack/joi-extract-type@1.0.1","bugs":{"url":"https://github.com/boostpack/boostpack/issues"},"homepage":"https://github.com/boostpack/boostpack#readme","_nodeVersion":"24.13.0","_npmVersion":"11.6.2","dist":{"integrity":"sha512-CLhMKzG9E1L84sn7E04lp9X7lmPqD/R70nfJAdv6YQeaMs0VUeYcwExpdShPkGBOKA9FJTnCOylZor+luXEIVg==","shasum":"324a6caaaf99ee5ed546530ad07df952bb038aed","tarball":"https://registry.npmjs.org/@boostpack/joi-extract-type/-/joi-extract-type-1.0.1.tgz","fileCount":9,"unpackedSize":33647,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQC/f9ySvQOcoe5rN31JyJOvtsPYXvMjKKGep5103R9eBgIgOs1BpAHERhF1yLqBnnD0EoOV+6lJZtRfrZln0vDPSGo="}]},"_npmUser":{"name":"timur2915","email":"timur2915@gmail.com"},"directories":{},"maintainers":[{"name":"timur2915","email":"timur2915@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/joi-extract-type_1.0.1_1772004690382_0.4146152090374806"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-20T21:32:53.013Z","modified":"2026-02-25T07:31:30.662Z","1.0.0":"2026-02-20T21:32:53.270Z","1.0.1":"2026-02-25T07:31:30.537Z"},"bugs":{"url":"https://github.com/boostpack/boostpack/issues"},"license":"MIT","homepage":"https://github.com/boostpack/boostpack#readme","keywords":["boostpack","joi","typescript","type-safe","type-extraction","module-augmentation","validation"],"repository":{"type":"git","url":"git+https://github.com/boostpack/boostpack.git","directory":"packages/shared/joi-extract-type"},"description":"TypeScript type extraction for Joi schemas via module augmentation","contributors":[{"name":"Timur Popov","email":"timur2915@gmail.com"}],"maintainers":[{"name":"timur2915","email":"timur2915@gmail.com"}],"readme":"# @boostpack/joi-extract-type\n\nTypeScript type extraction for Joi schemas via module augmentation.\n\n## Problem\n\nJoi validates data at runtime, but doesn't provide compile-time types for validated values. You end up duplicating your schema as a TypeScript interface:\n\n```typescript\nconst schema = Joi.object({ name: Joi.string().required(), age: Joi.number() });\n\n// manual duplication\ninterface Config {\n  name: string;\n  age?: number;\n}\n```\n\nThis package augments Joi's type definitions so TypeScript can infer the type directly from the schema — no duplication needed.\n\n## Installation\n\n```bash\nnpm install @boostpack/joi-extract-type\n```\n\n`joi` >= 17 is required as a peer dependency.\n\n## Usage\n\nImport the package once (side-effect import) to activate the type augmentation:\n\n```typescript\nimport '@boostpack/joi-extract-type';\nimport Joi from 'joi';\n\nconst schema = Joi.object({\n  host: Joi.string().required(),\n  port: Joi.number().default(3000),\n  debug: Joi.boolean().optional(),\n});\n\ntype Config = Joi.extractType<typeof schema>;\n// { host: string; port: number; debug?: boolean | undefined }\n```\n\n### Required vs optional\n\nFields are optional by default. Use `.required()` or `.default()` to make them required:\n\n```typescript\nconst schema = Joi.object({\n  name: Joi.string().required(),  // required — always string\n  age: Joi.number(),              // optional — number | undefined\n  role: Joi.string().default('user'),  // has default — always string\n});\n```\n\n### Arrays\n\n```typescript\nconst schema = Joi.object({\n  tags: Joi.array().items(Joi.string()).required(),\n});\n\ntype Result = Joi.extractType<typeof schema>;\n// { tags: string[] }\n```\n\n### Alternatives\n\n```typescript\nconst schema = Joi.alternatives(Joi.string(), Joi.number());\n\ntype Result = Joi.extractType<typeof schema>;\n// string | number\n```\n\n## Acknowledgements\n\nBased on the original [joi-extract-type](https://github.com/TCMiranda/joi-extract-type) by [Tiago de Carvalho Miranda](https://github.com/TCMiranda), with fixes from [panzelva](https://gist.github.com/panzelva/b0e565870c950c4cfd77188d69a3064a) and [dp-franklin](https://gist.github.com/panzelva/b0e565870c950c4cfd77188d69a3064a?permalink_comment_id=4446197#gistcomment-4446197).\n\n## License\n\nMIT\n","readmeFilename":"README.md"}