{"_id":"@ahmedrowaihi/fn-schema-core","_rev":"3-9b57d08a7e36b51577662f7f5dc08e5b","name":"@ahmedrowaihi/fn-schema-core","dist-tags":{"latest":"0.3.0"},"versions":{"0.2.0":{"name":"@ahmedrowaihi/fn-schema-core","version":"0.2.0","keywords":["json-schema","function-signature","codegen","ir","extractor"],"author":{"name":"Ahmed Rowaihi","email":"ahmedrowaihi@gmail.com"},"license":"MIT","_id":"@ahmedrowaihi/fn-schema-core@0.2.0","maintainers":[{"name":"ahmedrowaihi","email":"ahmedrowaihi1@gmail.com"}],"homepage":"https://github.com/ahmedrowaihi/contract-kit/tree/main/packages/fn-schema/core","bugs":{"url":"https://github.com/ahmedrowaihi/contract-kit/issues"},"dist":{"shasum":"b0e123e6b8bb7064d8d9483ac6f9471bcca82e18","tarball":"https://registry.npmjs.org/@ahmedrowaihi/fn-schema-core/-/fn-schema-core-0.2.0.tgz","fileCount":51,"integrity":"sha512-qC1pkvaxYYqhvXK6xBDOQkDnXMh8c+QpJz8l4vaoC/NAss5LiiSvcuw2TaJpOTtVCVaHoP2HU7t2+t9bWuUrOg==","signatures":[{"sig":"MEYCIQDWbg/K3sgRAuKwFHnK+uiPs7Uun3m7Z4RBolde84+urAIhAIbPj0eN5xGiwlYx12/GAILNpsV4srESY0NMEAPS5t0D","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@ahmedrowaihi%2ffn-schema-core@0.2.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":78047},"main":"./dist/index.js","type":"module","_from":"file:ahmedrowaihi-fn-schema-core-0.2.0.tgz","types":"./dist/index.d.ts","engines":{"node":">=20.19.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./emit":{"types":"./dist/emit/index.d.ts","import":"./dist/emit/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/0e87974cb067ff926160cddf0d0a0a4b/ahmedrowaihi-fn-schema-core-0.2.0.tgz","_integrity":"sha512-qC1pkvaxYYqhvXK6xBDOQkDnXMh8c+QpJz8l4vaoC/NAss5LiiSvcuw2TaJpOTtVCVaHoP2HU7t2+t9bWuUrOg==","repository":{"url":"git+https://github.com/ahmedrowaihi/contract-kit.git","type":"git","directory":"packages/fn-schema/core"},"_npmVersion":"10.8.2","description":"Language-agnostic core for fn-schema: extract function input/output JSON Schemas from source code. Defines the Extractor contract and ships emitters (files, bundle, OpenAPI) that operate on the shared FunctionInfo IR.","directories":{},"sideEffects":false,"_nodeVersion":"20.20.2","dependencies":{"@types/json-schema":"^7.0.15"},"publishConfig":{"access":"public","provenance":true},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^4.0.0","@types/node":"^22","@ahmedrowaihi/tsconfig":"0.0.0"},"_npmOperationalInternal":{"tmp":"tmp/fn-schema-core_0.2.0_1777918213196_0.2062589542173756","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Moved to @ir-kit/fn-schema-core. See https://github.com/ir-kit/ir-kit for migration."},"0.3.0":{"name":"@ahmedrowaihi/fn-schema-core","version":"0.3.0","keywords":["json-schema","function-signature","codegen","ir","extractor"],"author":{"name":"Ahmed Rowaihi","email":"ahmedrowaihi@gmail.com"},"license":"MIT","_id":"@ahmedrowaihi/fn-schema-core@0.3.0","maintainers":[{"name":"ahmedrowaihi","email":"ahmedrowaihi1@gmail.com"}],"homepage":"https://github.com/ahmedrowaihi/contract-kit/tree/main/packages/fn-schema/core","bugs":{"url":"https://github.com/ahmedrowaihi/contract-kit/issues"},"dist":{"shasum":"f4416ece447c027f27cbad2e8e8368f7743840c0","tarball":"https://registry.npmjs.org/@ahmedrowaihi/fn-schema-core/-/fn-schema-core-0.3.0.tgz","fileCount":51,"integrity":"sha512-Eoa0Po+dXZ3peT1++wD8XuodOVrt+yqTu7XKqoZcbhqxxBPuF3mHPBn+qHUvBG0oqI0d6cYFV15Xw7ascvU+yg==","signatures":[{"sig":"MEUCIQDUY7RESzS5tS7/z3MNx2JewxIAV6axKRya7bIjxvejTAIgdxnBIFuHrF0XMDJvWjL8pWmnot7NwfLk2dJJBQSXIQI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@ahmedrowaihi%2ffn-schema-core@0.3.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":80898},"main":"./dist/index.js","type":"module","_from":"file:ahmedrowaihi-fn-schema-core-0.3.0.tgz","types":"./dist/index.d.ts","engines":{"node":">=20.19.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./emit":{"types":"./dist/emit/index.d.ts","import":"./dist/emit/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/1a7864fcfcf0a75f1d49eb4178ebca8a/ahmedrowaihi-fn-schema-core-0.3.0.tgz","_integrity":"sha512-Eoa0Po+dXZ3peT1++wD8XuodOVrt+yqTu7XKqoZcbhqxxBPuF3mHPBn+qHUvBG0oqI0d6cYFV15Xw7ascvU+yg==","repository":{"url":"git+https://github.com/ahmedrowaihi/contract-kit.git","type":"git","directory":"packages/fn-schema/core"},"_npmVersion":"10.8.2","description":"Language-agnostic core for fn-schema: extract function input/output JSON Schemas from source code. Defines the Extractor contract and ships emitters (files, bundle, OpenAPI) that operate on the shared FunctionInfo IR.","directories":{},"sideEffects":false,"_nodeVersion":"20.20.2","dependencies":{"@types/json-schema":"^7.0.15"},"publishConfig":{"access":"public","provenance":true},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^4.0.0","@types/node":"^22","@ahmedrowaihi/tsconfig":"0.0.0"},"_npmOperationalInternal":{"tmp":"tmp/fn-schema-core_0.3.0_1777978693349_0.5034179338819469","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Moved to @ir-kit/fn-schema-core. See https://github.com/ir-kit/ir-kit for migration."}},"time":{"created":"2026-05-04T18:10:13.135Z","modified":"2026-05-21T09:19:17.672Z","0.2.0":"2026-05-04T18:10:13.354Z","0.3.0":"2026-05-05T10:58:13.516Z"},"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/core","keywords":["json-schema","function-signature","codegen","ir","extractor"],"repository":{"url":"git+https://github.com/ahmedrowaihi/contract-kit.git","type":"git","directory":"packages/fn-schema/core"},"description":"Language-agnostic core for fn-schema: extract function input/output JSON Schemas from source code. Defines the Extractor contract and ships emitters (files, bundle, OpenAPI) that operate on the shared FunctionInfo IR.","maintainers":[{"name":"ahmedrowaihi","email":"ahmedrowaihi1@gmail.com"}],"readme":"# @ahmedrowaihi/fn-schema-core\n\nLanguage-agnostic IR + emitters for fn-schema. Defines the `Extractor` contract that language-specific packages implement, and ships the orchestration + output paths every extractor shares.\n\n## When to use this directly\n\nMost users don't import `core` — they use the [`cli`](../cli/README.md) or `@ahmedrowaihi/fn-schema-typescript` (which re-exports a pre-wired `extract`). Reach for `core` when you want to:\n\n- register multiple extractors in the same run (e.g. TS + Python, when Python lands)\n- keep a long-lived `Project` warm across many `extract()` calls\n- build your own emitter on top of the orchestrator\n\n## Quick start\n\n```ts\nimport { createProject } from \"@ahmedrowaihi/fn-schema-core\"\nimport { typescript } from \"@ahmedrowaihi/fn-schema-typescript\"\n\nconst project = createProject({\n  cwd: process.cwd(),\n  tsConfigPath: \"./tsconfig.json\",\n  extractors: [typescript()],\n})\n\nconst result = await project.extract({\n  files: [\"src/api/handlers.ts\"],\n  schema: { identity: \"x-fn-schema-ts\", transport: \"x-fn-schema-transport\" },\n})\n\nproject.dispose()\n```\n\n### Discovery without schemas\n\n`Project.discover()` walks the same files but stops at function detection — no schema generation. Use it when you only need names, locations, JSDoc tags, and the like.\n\n```ts\nconst { signatures, stats } = await project.discover({\n  files: [\"src/**/*.ts\"],\n  include: { jsDocTag: \"schema\" },\n})\nfor (const fn of signatures) console.log(fn.name, fn.file, fn.location)\n```\n\n## Emitters\n\n```ts\nimport { emit } from \"@ahmedrowaihi/fn-schema-core\"\n\nemit.toFiles(result, { dir: \"generated\", format: \"json-pretty\" })\nemit.toBundle(result, { pretty: true })\nemit.toBundleTypesModule(result, { jsonImport: \"./schemas.json\" })\nemit.toOpenAPI(result, { title: \"my-api\" })\n```\n\n- `toFiles` — one JSON per signature\n- `toBundle` — single JSON with all signatures + shared definitions\n- `toBundleTypesModule` — TS wrapper exporting the bundle under literal-typed signature ids and definition names (pair with [`loader`](../loader/README.md))\n- `toOpenAPI` — components-only OpenAPI 3.1 doc; tuples use `prefixItems`\n\n## Schema knobs\n\n```ts\nschema: {\n  dialect: \"draft-07\" | \"draft-2020-12\" | \"openapi-3.1\",\n  expose: \"all\" | \"export\" | \"none\",\n  topRef: false,\n  additionalProperties: false,\n\n  // user overrides built-in mappings (Date, File, Buffer, …)\n  typeMappers: { MyType: { type: \"string\", format: \"uuid\" } },\n\n  // off-by-default vendor extensions\n  identity: \"x-fn-schema-ts\",            // attach originating TS type name\n  transport: \"x-fn-schema-transport\",    // attach multipart/base64 hint\n  sourceLocations: \"x-fn-schema-source\", // attach file:line:col\n}\n```\n\n## Diagnostics\n\nEvery mapping decision is observable:\n\n| Code | Severity | When |\n|---|---|---|\n| `TYPE_MAPPED` | info | Well-known TS type rewritten to canonical JSON Schema |\n| `LOSSY_MAPPING` | warning | Mapping lost information (e.g. `bigint` → `integer`) |\n| `NOT_REPRESENTABLE` | error | Type can't be represented in JSON Schema (e.g. `symbol`) |\n| `GENERIC_SKIPPED` | warning | Generic function skipped (set `signature.generics: \"erase\"` to override) |\n| `DUPLICATE_ID` | warning | Definition emitted with conflicting shapes from two functions |\n| `EXTRACTOR_FAILURE` | error | Extractor threw on a function |\n| `EMPTY_RESULT` | info | No signatures matched the filter |\n| `NO_EXTRACTOR` | warning | A file's extension isn't claimed by any registered extractor |\n\nSubscribe via `extract({ onDiagnostic: (d) => ... })` or read `result.diagnostics` after.\n\n## Extractor contract\n\nOther languages plug in by implementing:\n\n```ts\ninterface Extractor {\n  readonly extensions: readonly string[]\n  readonly language: string\n  init(opts: ExtractorInitOptions): Promise<ExtractorInstance>\n}\n\ninterface ExtractorInstance {\n  discover(files: readonly string[], filter: ResolvedFilter): Promise<FunctionInfo[]>\n  toSchemas(fn: FunctionInfo, opts: ResolvedSignatureOptions & ResolvedSchemaOptions): Promise<SignaturePair>\n  refresh(files: readonly string[]): void\n  dispose(): void\n}\n```\n","readmeFilename":"README.md"}