{"id":37528556,"url":"https://github.com/andnp/type-level-schema","last_synced_at":"2026-01-16T08:27:44.089Z","repository":{"id":57383215,"uuid":"128579647","full_name":"andnp/type-level-schema","owner":"andnp","description":"Typescript types for JSON-Schemas and Schema validation","archived":false,"fork":false,"pushed_at":"2020-04-26T18:14:09.000Z","size":43,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-22T16:54:08.151Z","etag":null,"topics":["javascript","json-schema-validator","schema","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andnp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null}},"created_at":"2018-04-08T00:17:35.000Z","updated_at":"2022-12-26T07:30:58.000Z","dependencies_parsed_at":"2022-09-13T23:50:32.086Z","dependency_job_id":null,"html_url":"https://github.com/andnp/type-level-schema","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/andnp/type-level-schema","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andnp%2Ftype-level-schema","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andnp%2Ftype-level-schema/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andnp%2Ftype-level-schema/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andnp%2Ftype-level-schema/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andnp","download_url":"https://codeload.github.com/andnp/type-level-schema/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andnp%2Ftype-level-schema/sbom","scorecard":{"id":192048,"data":{"date":"2025-08-11","repo":{"name":"github.com/andnp/type-level-schema","commit":"67bfc03124bd60f953b31a023c31162a74033212"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.1,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Code-Review","score":-1,"reason":"Found no human activity in the last 14 changesets","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-16T20:55:54.836Z","repository_id":57383215,"created_at":"2025-08-16T20:55:54.836Z","updated_at":"2025-08-16T20:55:54.836Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28478047,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T06:30:42.265Z","status":"ssl_error","status_checked_at":"2026-01-16T06:30:16.248Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","json-schema-validator","schema","typescript"],"created_at":"2026-01-16T08:27:42.551Z","updated_at":"2026-01-16T08:27:44.069Z","avatar_url":"https://github.com/andnp.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# type-level-schema\n\n[![Build Status](https://travis-ci.org/andnp/type-level-schema.svg?branch=master)](https://travis-ci.org/andnp/type-level-schema)\n\n\n## This library's goal\n\nThis library tries to minimize the amount of duplication of runtime type assertions, and compile time interfaces.\nThis library will generate the appropriate interfaces for JSON schema objects.\nThis library _will not_ ship a runtime JSON schema validator, there are many of these already and most are quite good.\n\n### Example: ajv\n```typescript\nimport { Schema, Schematize } from 'type-level-schema';\nimport * as ajv from 'ajv';\n\nconst validate = \u003cS extends Schema\u003e(schema: S, thing: any): thing is Schematize\u003cS\u003e =\u003e {\n    return (new ajv()).validate(schema, thing) as boolean;\n};\n\n// this helper assures that the schema you are specifying is a valid schema using compile-time types\n// it also helps eliminate TS type widening: 'object' as 'object', 'string' as 'string', etc.\nconst asSchema = \u003cS extends Schema\u003e(schema: S) =\u003e schema;\n\nconst schema = asSchema({\n    type: 'object',\n    parameters: {\n        id: { type: 'string' },\n        page: { type: 'number' },\n    },\n});\n\nconst getData = async () =\u003e {\n    const fetchedData = await fetch('/some/api/call').then(data =\u003e data.json()) as any;\n\n    if (validate(schema, fetchedData)) return schema;\n    throw new Error('oops');\n}\n\nconst x = await getData(); // =\u003e { id: string, page: number };\n```\n\nThis library is tested using both `ajv` and `jsonschema` as these are two of the more popular JSON Schema validators.\nThis library _should_ work with any JSON Schema validator that adheres to the JSON Schema standard.\n\n## Why?\n\nTypescript adds static type safety to the internals of javascript libraries.\nUnfortunately, because typescript cannot control the type and shape of data being sent into a well-typed system, type level bugs can still occur.\nOne way to deal with this is checking types at runtime.\nFor instance:\n```typescript\nconst doThing = (x: number, y: string) =\u003e {\n    if (typeof x !== 'number') throw new Error('expected a number');\n    return parseInt(y) + x;\n};\n```\nThis example checks types of variables passed in by some consumer of this code (who apparently _isn't_ using typescript).\n\nAnother (perhaps more common) example is:\n```typescript\ninterface ApiData {\n    id: string;\n    page: number;\n    nextUri: string;\n    data: string[];\n}\nconst getDataFromSomeoneElsesAPI = (): Promise\u003cApiData\u003e =\u003e {\n    return fetch('/some/api/call').then(data =\u003e data.json()) as any;\n};\n```\n\nLet's just hope that `someoneElsesApi` doesn't decide to change their contracts..\n\nA runtime solution could look like:\n```typescript\nconst schema = {\n    type: 'object',\n    parameters: {\n        id: { type: 'string' },\n        page: { type: 'number' },\n    },\n};\n\ninterface ApiData {\n    id: string;\n    page: number;\n};\n\nconst getData = async (): Promise\u003cApiData\u003e =\u003e {\n    const fetchedData = await fetch('/some/api/call').then(data =\u003e data.json()) as any;\n\n    if (jsonSchemaValidator(schema, fetchedData)) return fetchedData;\n    throw new Error(\"Expected fetched data to match schema, but it didn't :(\");\n};\n```\n\nUnfortunately, here we are specifying the expected shape of the data twice.\nThis means twice as many places to change our contract when the api call changes.\nTwice as much code.\nTwice as many places to screw up.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandnp%2Ftype-level-schema","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandnp%2Ftype-level-schema","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandnp%2Ftype-level-schema/lists"}