{"_id":"@ahmedrowaihi/fn-schema-typescript","_rev":"3-5cbff540371937d842bb99ea737bf430","name":"@ahmedrowaihi/fn-schema-typescript","dist-tags":{"latest":"0.2.1"},"versions":{"0.2.0":{"name":"@ahmedrowaihi/fn-schema-typescript","version":"0.2.0","keywords":["json-schema","typescript","function-signature","ts-morph","codegen"],"author":{"name":"Ahmed Rowaihi","email":"ahmedrowaihi@gmail.com"},"license":"MIT","_id":"@ahmedrowaihi/fn-schema-typescript@0.2.0","maintainers":[{"name":"ahmedrowaihi","email":"ahmedrowaihi1@gmail.com"}],"homepage":"https://github.com/ahmedrowaihi/contract-kit/tree/main/packages/fn-schema/typescript","bugs":{"url":"https://github.com/ahmedrowaihi/contract-kit/issues"},"dist":{"shasum":"3dcd15a21307869e8283ffbea0f4501ffa81d309","tarball":"https://registry.npmjs.org/@ahmedrowaihi/fn-schema-typescript/-/fn-schema-typescript-0.2.0.tgz","fileCount":31,"integrity":"sha512-WLRViZSV7L2ptNCD7J1Xf1WJtbSODi5DPket+x844q9algIsoJwIoZsrEJWVzrY0Re2l0FyW61oQLgVpc4SsRA==","signatures":[{"sig":"MEQCIEvSpXmaLmv92O272DBjdagCRKdQBjykoOnN4jKix4/xAiAFedB/3jcKLQfyV1ZiaVimfzx0njBufsaan2JhtuYioQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@ahmedrowaihi%2ffn-schema-typescript@0.2.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":106856},"main":"./dist/index.js","type":"module","_from":"file:ahmedrowaihi-fn-schema-typescript-0.2.0.tgz","types":"./dist/index.d.ts","engines":{"node":">=20.19.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./package.json":"./package.json"},"scripts":{"dev":"tsc -p tsconfig.build.json --watch","test":"vitest run --passWithNoTests","build":"tsc -p tsconfig.build.json","typecheck":"tsc --noEmit"},"_npmUser":{"name":"ahmedrowaihi","email":"ahmedrowaihi1@gmail.com"},"_resolved":"/tmp/05638641e926cb726c7223278fc50677/ahmedrowaihi-fn-schema-typescript-0.2.0.tgz","_integrity":"sha512-WLRViZSV7L2ptNCD7J1Xf1WJtbSODi5DPket+x844q9algIsoJwIoZsrEJWVzrY0Re2l0FyW61oQLgVpc4SsRA==","repository":{"url":"git+https://github.com/ahmedrowaihi/contract-kit.git","type":"git","directory":"packages/fn-schema/typescript"},"_npmVersion":"10.8.2","description":"TypeScript extractor for fn-schema. Walks source via ts-morph, synthesizes virtual type aliases for each function's parameters and return, then converts them to JSON Schema via ts-json-schema-generator. Re-exports a pre-wired `extract` for single-language","directories":{},"sideEffects":false,"_nodeVersion":"20.20.2","dependencies":{"ts-morph":"^28.0.0","ts-json-schema-generator":"^2.9.0","@ahmedrowaihi/fn-schema-core":"0.2.0"},"publishConfig":{"access":"public","provenance":true},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^4.0.0","typescript":"5.9.3","@types/node":"^22","@ahmedrowaihi/tsconfig":"0.0.0"},"peerDependencies":{"typescript":">=5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/fn-schema-typescript_0.2.0_1777918213005_0.6240936389780392","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Moved to @ir-kit/fn-schema-typescript. See https://github.com/ir-kit/ir-kit for migration."},"0.2.1":{"name":"@ahmedrowaihi/fn-schema-typescript","version":"0.2.1","keywords":["json-schema","typescript","function-signature","ts-morph","codegen"],"author":{"name":"Ahmed Rowaihi","email":"ahmedrowaihi@gmail.com"},"license":"MIT","_id":"@ahmedrowaihi/fn-schema-typescript@0.2.1","maintainers":[{"name":"ahmedrowaihi","email":"ahmedrowaihi1@gmail.com"}],"homepage":"https://github.com/ahmedrowaihi/contract-kit/tree/main/packages/fn-schema/typescript","bugs":{"url":"https://github.com/ahmedrowaihi/contract-kit/issues"},"dist":{"shasum":"f362bbdb73e5b80b6333d2676ab5e54cadaec228","tarball":"https://registry.npmjs.org/@ahmedrowaihi/fn-schema-typescript/-/fn-schema-typescript-0.2.1.tgz","fileCount":31,"integrity":"sha512-hQmVjESyUEXZ5nyUOecnv34rzu0rUx0K6ShT5ThTIU6PoAkOt5XEFhamiHwkpJ9gT6sFqGJNOg/oTey7jKp6cw==","signatures":[{"sig":"MEUCIDiGEPtbZKI3MbLxmf5OckiVN7WPqDKPtlY7l9LWzyw1AiEAyBaHyJXHLjRrS+vQYShD6luN9Rb6pZ+grzpsBeKbyE4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@ahmedrowaihi%2ffn-schema-typescript@0.2.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":106659},"main":"./dist/index.js","type":"module","_from":"file:ahmedrowaihi-fn-schema-typescript-0.2.1.tgz","types":"./dist/index.d.ts","engines":{"node":">=20.19.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./package.json":"./package.json"},"scripts":{"dev":"tsc -p tsconfig.build.json --watch","test":"vitest run --passWithNoTests","build":"tsc -p tsconfig.build.json","typecheck":"tsc --noEmit"},"_npmUser":{"name":"ahmedrowaihi","email":"ahmedrowaihi1@gmail.com"},"_resolved":"/tmp/8561ad7f1fc7ed885138e3d59846ddb8/ahmedrowaihi-fn-schema-typescript-0.2.1.tgz","_integrity":"sha512-hQmVjESyUEXZ5nyUOecnv34rzu0rUx0K6ShT5ThTIU6PoAkOt5XEFhamiHwkpJ9gT6sFqGJNOg/oTey7jKp6cw==","repository":{"url":"git+https://github.com/ahmedrowaihi/contract-kit.git","type":"git","directory":"packages/fn-schema/typescript"},"_npmVersion":"10.8.2","description":"TypeScript extractor for fn-schema. Walks source via ts-morph, synthesizes virtual type aliases for each function's parameters and return, then converts them to JSON Schema via ts-json-schema-generator. Re-exports a pre-wired `extract` for single-language","directories":{},"sideEffects":false,"_nodeVersion":"20.20.2","dependencies":{"ts-morph":"^28.0.0","ts-json-schema-generator":"^2.9.0","@ahmedrowaihi/fn-schema-core":"0.3.0"},"publishConfig":{"access":"public","provenance":true},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^4.0.0","typescript":"5.9.3","@types/node":"^22","@ahmedrowaihi/tsconfig":"0.0.0"},"peerDependencies":{"typescript":">=5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/fn-schema-typescript_0.2.1_1777978693682_0.9392746488211301","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Moved to @ir-kit/fn-schema-typescript. See https://github.com/ir-kit/ir-kit for migration."}},"time":{"created":"2026-05-04T18:10:12.916Z","modified":"2026-05-21T09:19:22.949Z","0.2.0":"2026-05-04T18:10:13.161Z","0.2.1":"2026-05-05T10:58:13.993Z"},"bugs":{"url":"https://github.com/ahmedrowaihi/contract-kit/issues"},"author":{"name":"Ahmed Rowaihi","email":"ahmedrowaihi@gmail.com"},"license":"MIT","homepage":"https://github.com/ahmedrowaihi/contract-kit/tree/main/packages/fn-schema/typescript","keywords":["json-schema","typescript","function-signature","ts-morph","codegen"],"repository":{"url":"git+https://github.com/ahmedrowaihi/contract-kit.git","type":"git","directory":"packages/fn-schema/typescript"},"description":"TypeScript extractor for fn-schema. Walks source via ts-morph, synthesizes virtual type aliases for each function's parameters and return, then converts them to JSON Schema via ts-json-schema-generator. Re-exports a pre-wired `extract` for single-language","maintainers":[{"name":"ahmedrowaihi","email":"ahmedrowaihi1@gmail.com"}],"readme":"# @ahmedrowaihi/fn-schema-typescript\n\nTypeScript extractor for fn-schema. The default TS implementation of the `Extractor` contract from `core`.\n\nMost users don't import this directly — they use the [`cli`](../cli/README.md). Reach for the programmatic API when you're building tooling on top of fn-schema.\n\n## Install\n\n```bash\npnpm add @ahmedrowaihi/fn-schema-typescript\n```\n\n## Quick start\n\n```ts\nimport { extract } from \"@ahmedrowaihi/fn-schema-typescript\"\n\nconst result = await extract({\n  files: [\"src/api/handlers.ts\"],\n  tsConfigPath: \"./tsconfig.json\",\n})\n\nfor (const sig of result.signatures) {\n  console.log(sig.id, sig.input, sig.output)\n}\n```\n\n`extract` is a one-shot helper. For repeat calls (server endpoints, dev mode, watch), use [`createProject`](../core/README.md) from `core` directly with `typescript()` as the extractor — it keeps the ts-morph project warm.\n\n## What it discovers\n\n- `function foo() {}` declarations\n- `const foo = () => {}` and `const foo = function() {}`\n- Class methods (instance + static, exported classes)\n- Object-literal members: `export const api = { create() {}, tag: () => {} }`\n- Default-export arrows: `export default (input) => {}`\n- Function and method overloads (configurable via `signature.overloads`)\n- `this` parameter is auto-skipped\n\n## What it extracts\n\n- Multi-parameter functions — `signature.parameters` controls layout (`array` / `first-only` / `object`)\n- Async returns — `Promise<T>` auto-unwrapped (toggle via `signature.unwrapPromise`)\n- Generic functions — skipped by default (set `signature.generics: \"erase\"` to coerce to `unknown`)\n- Branded types (`type X = string & { __brand: \"X\" }`) — phantom stripped, identity preserved when the keyword is on\n- Well-known types canonicalized: `Date`, `URL`, `RegExp`, `File`, `Blob`, `Buffer`, `Uint8Array`, `ArrayBuffer`, `bigint`\n- `symbol` and function-as-input → `NOT_REPRESENTABLE` diagnostic\n\n## Filters\n\n```ts\nextract({\n  files: [\"src/api/**/*.ts\"],\n  include: {\n    exported: true,\n    name: /^create/,\n    jsDocTag: \"schema\",\n    kind: [\"function\", \"method\"],\n  },\n  exclude: { name: /^_/, jsDocTag: \"internal\" },\n  filter: (fn) => fn.async,\n})\n```\n\n## How the type resolution works\n\nFor each function we synthesize a virtual TS file alongside it:\n\n```ts\n// src/__fn_schema_virtual__/handlers_createUser.virtual.ts\nimport type { CreateUserInput, User } from \"../handlers\"\n\ntype __FnSchemaMap_Date = { readonly __fn_schema_marker: \"Date\" }\n\nexport type __In_0 = CreateUserInput\nexport type __Out__ = Awaited<Promise<User>>\n```\n\nts-json-schema-generator processes this like any other source file. Sentinel object types (`__FnSchemaMap_Date`, etc.) survive union flattening because they're structurally distinct from primitives. After generation, a post-process pass swaps each sentinel for its canonical schema and (optionally) attaches identity/transport/source-location keywords.\n\nThis indirection is what lets fn-schema reuse ts-json-schema-generator without forking it — we work around its inability to resolve `Parameters<typeof X>` and `import(\"path\").Y` by emitting bare type identifiers and resolving cross-file imports ourselves.\n\n## Diagnostics\n\nSubscribe via `extract({ onDiagnostic: (d) => ... })` or read `result.diagnostics`. Codes are documented in [`core/README.md`](../core/README.md#diagnostics).\n","readmeFilename":"README.md"}