{"_id":"runtimekit","_rev":"4-e42ad6a8942d957e3a703b8c26db8f34","name":"runtimekit","dist-tags":{"latest":"1.0.5"},"versions":{"1.0.1":{"name":"runtimekit","version":"1.0.1","keywords":["runtime","validation","typescript","schema","codec","type-guard","runtimekit"],"author":{"name":"yuliahrabets"},"license":"MIT","_id":"runtimekit@1.0.1","maintainers":[{"name":"yuliahrabets","email":"yuliahrabets@gmail.com"}],"homepage":"https://github.com/yuliahrabets/runtimekit#readme","bugs":{"url":"https://github.com/yuliahrabets/runtimekit/issues"},"dist":{"shasum":"f0a6353fe21e33ff0917bd8fca9b26999585da68","tarball":"https://registry.npmjs.org/runtimekit/-/runtimekit-1.0.1.tgz","fileCount":10,"integrity":"sha512-AofEF+ZNsDuTgpCKqJYgVxQDHUlvHB09xbC0xDCc1CxDk0PsSgN5g+eAYnXISZnpoQAZ+1zEClvSqoV/fIiT9A==","signatures":[{"sig":"MEYCIQDNiXXXoac5wKYZIiOy8S7QHG+rTBdMdn8CywS6ivkX6gIhAO4YXypTCP8oX22FNMlrwtsq1jCgRijHux9L9Ignru9x","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":108388},"main":"./lib/index.cjs","type":"module","types":"./lib/index.d.ts","module":"./lib/index.mjs","engines":{"node":">=18"},"exports":{".":{"types":"./lib/index.d.ts","import":"./lib/index.mjs","default":"./lib/index.mjs","require":"./lib/index.cjs"},"./readonly":{"types":"./lib/readonly.d.ts","import":"./lib/readonly.mjs","default":"./lib/readonly.mjs","require":"./lib/readonly.cjs"}},"scripts":{"test":"rollup -c && jest","build":"tsc --noEmit && rollup -c && api-extractor run --local && node scripts/finalize-build.js && node scripts/minify.js","format":"node scripts/format.js","test:ci":"rollup -c && jest --coverage","typecheck":"tsc --noEmit","test:watch":"rollup -c && jest --watch","test:import":"node scripts/test-import.js","prepublishOnly":"npm run build"},"_npmUser":{"name":"yuliahrabets","email":"yuliahrabets@gmail.com"},"repository":{"url":"git+https://github.com/yuliahrabets/runtimekit.git","type":"git"},"_npmVersion":"11.13.0","description":"Composable runtime validation for TypeScript — define schemas once, infer static types automatically.","directories":{},"sideEffects":false,"_nodeVersion":"24.16.0","publishConfig":{"provenance":true},"typesVersions":{"*":{"readonly":["lib/readonly.d.ts"]}},"_hasShrinkwrap":false,"packageManager":"npm@11.7.0+sha512.c22099a6fff8d5b2286c2a09df5352b4858a7c0c716320f58989d60ad8b29ecf2ce6fdfe97ccb41c23ffb1272e1fa079f868487dd6b81d02a2a9e199c095a117","devDependencies":{"jest":"^29.7.0","rollup":"^2.26.11","terser":"^5.46.0","ts-jest":"^29.4.6","prettier":"^3.8.0","jest-util":"^29.7.0","typescript":"^5.9.3","@types/jest":"^29.5.14","@babel/parser":"^7.17.8","type-assertions":"^1.1.0","rollup-plugin-prettier":"^4.1.2","@microsoft/api-extractor":"^7.47.9","rollup-plugin-typescript2":"^0.27.2"},"_npmOperationalInternal":{"tmp":"tmp/runtimekit_1.0.1_1781541811855_0.1666259295942678","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"runtimekit","version":"1.0.2","keywords":["runtime","validation","typescript","schema","codec","type-guard","runtimekit"],"author":{"name":"yuliahrabets"},"license":"MIT","_id":"runtimekit@1.0.2","maintainers":[{"name":"yuliahrabets","email":"yuliahrabets@gmail.com"}],"homepage":"https://github.com/yuliahrabets/runtimekit#readme","bugs":{"url":"https://github.com/yuliahrabets/runtimekit/issues"},"dist":{"shasum":"4920ab1cbdeb9dfd2abe54aeb8023e8a144f9424","tarball":"https://registry.npmjs.org/runtimekit/-/runtimekit-1.0.2.tgz","fileCount":10,"integrity":"sha512-Z8nMhwRKK3msxEEL78yYjS+3UDiWep2wOs5RAto7wW2DPXibe45cgZKUc0aX80riMMlFs5Bi7e0/t2sMKsuF5Q==","signatures":[{"sig":"MEUCICbWNM/IcBjy35a9yPGu1SSurlNZzLyHMKDY8x0I4Nr/AiEAxnJgLsLEXIrA80GG6Z6op9jNqk3qnWwxWXupfvjahPY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":99836},"main":"./lib/index.cjs","type":"module","types":"./lib/index.d.ts","module":"./lib/index.mjs","engines":{"node":">=18"},"exports":{".":{"types":"./lib/index.d.ts","import":"./lib/index.mjs","default":"./lib/index.mjs","require":"./lib/index.cjs"},"./readonly":{"types":"./lib/readonly.d.ts","import":"./lib/readonly.mjs","default":"./lib/readonly.mjs","require":"./lib/readonly.cjs"}},"gitHead":"dee75bc8a466690e49b9d05cb91bad05e1dad978","scripts":{"test":"rollup -c && jest","build":"tsc --noEmit && rollup -c && api-extractor run --local && node scripts/finalize-build.js && node scripts/minify.js","format":"node scripts/format.js","test:ci":"rollup -c && jest --coverage","typecheck":"tsc --noEmit","test:watch":"rollup -c && jest --watch","test:import":"node scripts/test-import.js","prepublishOnly":"npm run build"},"_npmUser":{"name":"yuliahrabets","email":"yuliahrabets@gmail.com"},"repository":{"url":"git+https://github.com/yuliahrabets/runtimekit.git","type":"git"},"_npmVersion":"11.13.0","description":"Composable runtime validation for TypeScript — define schemas once, infer static types automatically.","directories":{},"sideEffects":["./src/types/bootstrap.js"],"_nodeVersion":"24.16.0","publishConfig":{"provenance":true},"typesVersions":{"*":{"readonly":["lib/readonly.d.ts"]}},"_hasShrinkwrap":false,"packageManager":"npm@11.7.0+sha512.c22099a6fff8d5b2286c2a09df5352b4858a7c0c716320f58989d60ad8b29ecf2ce6fdfe97ccb41c23ffb1272e1fa079f868487dd6b81d02a2a9e199c095a117","devDependencies":{"jest":"^29.7.0","rollup":"^2.26.11","terser":"^5.46.0","ts-jest":"^29.4.6","prettier":"^3.8.0","jest-util":"^29.7.0","typescript":"^5.9.3","@types/jest":"^29.5.14","@babel/parser":"^7.17.8","type-assertions":"^1.1.0","rollup-plugin-prettier":"^4.1.2","@microsoft/api-extractor":"^7.47.9","rollup-plugin-typescript2":"^0.27.2"},"_npmOperationalInternal":{"tmp":"tmp/runtimekit_1.0.2_1781720735708_0.47344233325274043","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"runtimekit","version":"1.0.3","keywords":["runtime","validation","typescript","schema","codec","type-guard","runtimekit"],"author":{"name":"yuliahrabets"},"license":"MIT","_id":"runtimekit@1.0.3","maintainers":[{"name":"yuliahrabets","email":"yuliahrabets@gmail.com"}],"homepage":"https://github.com/yuliahrabets/runtimekit#readme","bugs":{"url":"https://github.com/yuliahrabets/runtimekit/issues"},"dist":{"shasum":"d59190e3ca0b41073a012617a5e10403ba1a20b9","tarball":"https://registry.npmjs.org/runtimekit/-/runtimekit-1.0.3.tgz","fileCount":10,"integrity":"sha512-fiMZ98gA32q/nWbSIjb+cQCY0zCTwtJxTwgYrIcxwr6l76j1p/XHKYbhcnsYtmzH3Kf9IFdsu2eMFX83kwSjmw==","signatures":[{"sig":"MEQCIF/oA6Yggi1O5Harck5dTxiOfbBh5GB4KimzpipqUgxNAiBpgZnpfTiy5TIXtrCw9gSSqRMXfGYFRdtAWWT/y5F4rQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":99836},"main":"./lib/index.cjs","type":"module","types":"./lib/index.d.ts","module":"./lib/index.mjs","engines":{"node":">=18"},"exports":{".":{"types":"./lib/index.d.ts","import":"./lib/index.mjs","default":"./lib/index.mjs","require":"./lib/index.cjs"},"./readonly":{"types":"./lib/readonly.d.ts","import":"./lib/readonly.mjs","default":"./lib/readonly.mjs","require":"./lib/readonly.cjs"}},"gitHead":"dee75bc8a466690e49b9d05cb91bad05e1dad978","scripts":{"test":"rollup -c && jest","build":"tsc --noEmit && rollup -c && api-extractor run --local && node scripts/finalize-build.js && node scripts/minify.js","format":"node scripts/format.js","test:ci":"rollup -c && jest --coverage","typecheck":"tsc --noEmit","test:watch":"rollup -c && jest --watch","test:import":"node scripts/test-import.js","prepublishOnly":"npm run build"},"_npmUser":{"name":"yuliahrabets","email":"yuliahrabets@gmail.com"},"repository":{"url":"git+https://github.com/yuliahrabets/runtimekit.git","type":"git"},"_npmVersion":"11.13.0","description":"Composable runtime validation for TypeScript — define schemas once, infer static types automatically.","directories":{},"sideEffects":["./src/types/bootstrap.js"],"_nodeVersion":"24.16.0","publishConfig":{"provenance":true},"typesVersions":{"*":{"readonly":["lib/readonly.d.ts"]}},"_hasShrinkwrap":false,"packageManager":"npm@11.7.0+sha512.c22099a6fff8d5b2286c2a09df5352b4858a7c0c716320f58989d60ad8b29ecf2ce6fdfe97ccb41c23ffb1272e1fa079f868487dd6b81d02a2a9e199c095a117","devDependencies":{"jest":"^29.7.0","rollup":"^2.26.11","terser":"^5.46.0","ts-jest":"^29.4.6","prettier":"^3.8.0","jest-util":"^29.7.0","typescript":"^5.9.3","@types/jest":"^29.5.14","@babel/parser":"^7.17.8","type-assertions":"^1.1.0","rollup-plugin-prettier":"^4.1.2","@microsoft/api-extractor":"^7.47.9","rollup-plugin-typescript2":"^0.27.2"},"_npmOperationalInternal":{"tmp":"tmp/runtimekit_1.0.3_1781721252360_0.05584073184709859","host":"s3://npm-registry-packages-npm-production"}},"1.0.5":{"name":"runtimekit","version":"1.0.5","description":"Composable runtime validation for TypeScript — define schemas once, infer static types automatically.","main":"./lib/index.cjs","module":"./lib/index.mjs","types":"./lib/index.d.ts","type":"module","sideEffects":true,"exports":{".":{"types":"./lib/index.d.ts","import":"./lib/index.mjs","require":"./lib/index.cjs","default":"./lib/index.mjs"},"./readonly":{"types":"./lib/readonly.d.ts","import":"./lib/readonly.mjs","require":"./lib/readonly.cjs","default":"./lib/readonly.mjs"}},"typesVersions":{"*":{"readonly":["lib/readonly.d.ts"]}},"scripts":{"build":"tsc --noEmit && rollup -c && api-extractor run --local && node scripts/finalize-build.js && node scripts/minify.js","format":"node scripts/format.js","test":"rollup -c && jest","test:watch":"rollup -c && jest --watch","test:ci":"rollup -c && jest --coverage","test:import":"node scripts/test-import.js","typecheck":"tsc --noEmit","prepublishOnly":"npm run build"},"author":{"name":"yuliahrabets"},"license":"MIT","keywords":["runtime","validation","typescript","schema","codec","type-guard","runtimekit"],"repository":{"type":"git","url":"git+https://github.com/yuliahrabets/runtimekit.git"},"engines":{"node":">=18"},"devDependencies":{"@babel/parser":"^7.17.8","@microsoft/api-extractor":"^7.47.9","@types/jest":"^29.5.14","jest":"^29.7.0","jest-util":"^29.7.0","prettier":"^3.8.0","rollup":"^2.26.11","rollup-plugin-prettier":"^4.1.2","rollup-plugin-typescript2":"^0.27.2","terser":"^5.46.0","ts-jest":"^29.4.6","type-assertions":"^1.1.0","typescript":"^5.9.3"},"publishConfig":{"access":"public"},"packageManager":"npm@11.7.0+sha512.c22099a6fff8d5b2286c2a09df5352b4858a7c0c716320f58989d60ad8b29ecf2ce6fdfe97ccb41c23ffb1272e1fa079f868487dd6b81d02a2a9e199c095a117","gitHead":"dee75bc8a466690e49b9d05cb91bad05e1dad978","_id":"runtimekit@1.0.5","bugs":{"url":"https://github.com/yuliahrabets/runtimekit/issues"},"homepage":"https://github.com/yuliahrabets/runtimekit#readme","_nodeVersion":"24.16.0","_npmVersion":"11.13.0","dist":{"integrity":"sha512-gRSoXVHSe8ADWaqfzhcYoYQDRjk71nbtUX9x2oftTD5pdqGvFhA1igAQKwoR4NFUGaA5+n0Z2pGfyZ3sU9C8GQ==","shasum":"0cd9751b95672c8189e797c42ab08d8556285218","tarball":"https://registry.npmjs.org/runtimekit/-/runtimekit-1.0.5.tgz","fileCount":10,"unpackedSize":108354,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDibrL2sB/og7p/0KL5K5xDfIJKT2qbh+DMlyyF/BliuwIhAJZDL6xrvJo1DbEFjxfKofeEtTKaI2F3Ts1pjXjDzeZz"}]},"_npmUser":{"name":"yuliahrabets","email":"yuliahrabets@gmail.com"},"directories":{},"maintainers":[{"name":"yuliahrabets","email":"yuliahrabets@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/runtimekit_1.0.5_1781799112024_0.0008965656342156958"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-15T16:43:31.721Z","modified":"2026-06-18T16:11:52.271Z","1.0.1":"2026-06-15T16:43:32.025Z","1.0.2":"2026-06-17T18:25:35.956Z","1.0.3":"2026-06-17T18:34:12.504Z","1.0.5":"2026-06-18T16:11:52.158Z"},"bugs":{"url":"https://github.com/yuliahrabets/runtimekit/issues"},"author":{"name":"yuliahrabets"},"license":"MIT","homepage":"https://github.com/yuliahrabets/runtimekit#readme","keywords":["runtime","validation","typescript","schema","codec","type-guard","runtimekit"],"repository":{"type":"git","url":"git+https://github.com/yuliahrabets/runtimekit.git"},"description":"Composable runtime validation for TypeScript — define schemas once, infer static types automatically.","maintainers":[{"name":"yuliahrabets","email":"yuliahrabets@gmail.com"}],"readme":"# runtimekit\r\n\r\n**Composable runtime validation for TypeScript.**\r\n\r\nruntimekit lets you define schemas as values, validate untrusted data at runtime, and derive static TypeScript types from those same definitions — no duplication required.\r\n\r\n---\r\n\r\n## Install\r\n\r\n```bash\r\nnpm install runtimekit\r\n```\r\n\r\nRequires Node.js 18 or later. Works with both ESM (`import`) and CommonJS (`require`).\r\n\r\n---\r\n\r\n## Quick start\r\n\r\nDefine a schema, parse unknown input, and get a typed result:\r\n\r\n```ts\r\nimport { Object, String, Number, Literal, Array, Static } from 'runtimekit';\r\n\r\nconst User = Object({\r\n  id: Number,\r\n  name: String,\r\n  role: Literal('admin', 'member', 'guest'),\r\n});\r\n\r\ntype User = Static<typeof User>;\r\n\r\nconst user = User.parse({ id: 1, name: 'Ada', role: 'admin' });\r\n//    ^? User\r\n```\r\n\r\nIf validation fails, `parse` throws a `ValidationError` with a readable message.\r\n\r\n---\r\n\r\n## Core API\r\n\r\n| Method | Behavior |\r\n|--------|----------|\r\n| `parse(value)` | Validate and return the typed value, or throw |\r\n| `safeParse(value)` | Return `{ success: true, value }` or `{ success: false, error }` |\r\n| `test(value)` | Type guard — returns `true` when the value matches |\r\n| `assert(value)` | Like `parse`, but accepts `unknown` and narrows the type |\r\n| `serialize(value)` | Validate and serialize to a plain JSON-safe value |\r\n\r\n---\r\n\r\n## Building schemas\r\n\r\nSchemas compose from primitives and combinators:\r\n\r\n```ts\r\nimport {\r\n  Boolean,\r\n  Number,\r\n  String,\r\n  Literal,\r\n  Union,\r\n  Array,\r\n  Tuple,\r\n  Object,\r\n  Intersect,\r\n  Partial,\r\n  Constraint,\r\n} from 'runtimekit';\r\n\r\nconst Vector = Tuple(Number, Number, Number);\r\n\r\nconst Planet = Object({\r\n  type: Literal('planet'),\r\n  location: Vector,\r\n  mass: Number,\r\n  population: Number,\r\n  habitable: Boolean,\r\n});\r\n\r\nconst Positive = Constraint(Number, n => n > 0 || `${n} is not positive`);\r\n\r\nconst Fleet = Object({\r\n  name: String,\r\n  ships: Array(\r\n    Object({\r\n      name: String,\r\n      crew: Number,\r\n      position: Vector,\r\n    }),\r\n  ),\r\n});\r\n```\r\n\r\n### Unions and intersections\r\n\r\n```ts\r\nconst Rank = Union(\r\n  Literal('captain'),\r\n  Literal('officer'),\r\n  Literal('ensign'),\r\n);\r\n\r\nconst RegisteredShip = Intersect(\r\n  Fleet,\r\n  Object({ isRegistered: Literal(true) }),\r\n  Partial({ classification: Union(Literal('military'), Literal('civilian')) }),\r\n);\r\n```\r\n\r\n### Optional and nullable fields\r\n\r\n```ts\r\nimport { Union, Undefined, Null, Nullable } from 'runtimekit';\r\n\r\nconst MaybeString = Union(String, Undefined);   // string | undefined\r\nconst NullableString = Nullable(String);          // string | null\r\n\r\nconst Profile = Object({ bio: String }).And(\r\n  Partial({ website: Union(String, Undefined) }),\r\n);\r\n```\r\n\r\n---\r\n\r\n## Type inference\r\n\r\nUse `Static<typeof Schema>` to derive a TypeScript type from any schema:\r\n\r\n```ts\r\nimport { Static } from 'runtimekit';\r\n\r\ntype Planet = Static<typeof Planet>;\r\n// { type: 'planet'; location: [number, number, number]; mass: number; ... }\r\n```\r\n\r\n---\r\n\r\n## Type guards\r\n\r\nUse schemas as runtime type guards:\r\n\r\n```ts\r\nfunction handle(input: unknown) {\r\n  if (Planet.test(input)) {\r\n    // input is narrowed to Planet\r\n    console.log(input.population);\r\n  }\r\n}\r\n```\r\n\r\n---\r\n\r\n## Constraints and custom validators\r\n\r\nAdd arbitrary runtime checks with `Constraint`:\r\n\r\n```ts\r\nconst Email = Constraint<string, `${string}@${string}`>(\r\n  String,\r\n  value => value.includes('@') || 'Invalid email address',\r\n  { name: 'Email' },\r\n);\r\n```\r\n\r\nFor custom types backed by a type guard:\r\n\r\n```ts\r\nimport { Guard } from 'runtimekit';\r\n\r\nconst BufferSchema = Guard(Buffer.isBuffer, { name: 'Buffer' });\r\n```\r\n\r\n---\r\n\r\n## Readonly schemas\r\n\r\nWrap any schema with `Readonly` to produce immutable inferred types:\r\n\r\n```ts\r\nimport { Readonly, ReadonlyArray } from 'runtimekit';\r\n\r\nconst ImmutablePlanet = Readonly(Planet);\r\ntype ImmutablePlanet = Static<typeof ImmutablePlanet>;\r\n// { readonly type: 'planet'; readonly location: readonly [number, number, number]; ... }\r\n```\r\n\r\nImport from `runtimekit/readonly` to default all collection helpers to their readonly variants:\r\n\r\n```ts\r\nimport { Object, Array, Tuple } from 'runtimekit/readonly';\r\n// Object, Array, and Tuple produce readonly types by default\r\n```\r\n\r\n---\r\n\r\n## Object utilities\r\n\r\nMirror TypeScript's built-in object utilities:\r\n\r\n```ts\r\nimport { Partial, Pick, Omit } from 'runtimekit';\r\n\r\nconst PartialPlanet = Partial(Planet);\r\nconst PlanetMass = Pick(Planet, ['mass']);\r\nconst PlanetWithoutMass = Omit(Planet, ['mass']);\r\n```\r\n\r\n---\r\n\r\n## Safe parsing\r\n\r\nPrefer non-throwing validation at API boundaries:\r\n\r\n```ts\r\nconst result = User.safeParse(untrusted);\r\n\r\nif (result.success) {\r\n  console.log(result.value.name);\r\n} else {\r\n  console.error(result.error);\r\n}\r\n```\r\n\r\n---\r\n\r\n## License\r\n\r\nMIT © yuliahrabets\r\n","readmeFilename":"README.md"}