{"id":19592291,"url":"https://github.com/smikhalevski/jtdc","last_synced_at":"2026-05-15T22:35:11.609Z","repository":{"id":46898543,"uuid":"383124092","full_name":"smikhalevski/jtdc","owner":"smikhalevski","description":"JSON Type Definition to TypeScript compiler.","archived":false,"fork":false,"pushed_at":"2021-12-03T15:28:43.000Z","size":788,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-01T12:14:14.263Z","etag":null,"topics":["compile","guard","json-schema","jtd","narrowing","ts","typescript","validator"],"latest_commit_sha":null,"homepage":"https://smikhalevski.github.io/jtdc/","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/smikhalevski.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-07-05T11:54:15.000Z","updated_at":"2021-10-08T19:44:19.000Z","dependencies_parsed_at":"2022-08-27T01:20:56.387Z","dependency_job_id":null,"html_url":"https://github.com/smikhalevski/jtdc","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/smikhalevski/jtdc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smikhalevski%2Fjtdc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smikhalevski%2Fjtdc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smikhalevski%2Fjtdc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smikhalevski%2Fjtdc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smikhalevski","download_url":"https://codeload.github.com/smikhalevski/jtdc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smikhalevski%2Fjtdc/sbom","scorecard":{"id":833361,"data":{"date":"2025-08-11","repo":{"name":"github.com/smikhalevski/jtdc","commit":"05229bf9f583820f55d8921ef8253c80d26bdb77"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"checks":[{"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":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","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":"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":"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":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","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":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/master.yml:1","Info: no jobLevel write permissions found"],"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":"Pinned-Dependencies","score":2,"reason":"dependency not pinned by hash detected -- score normalized to 2","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/master.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/smikhalevski/jtdc/master.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/master.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/smikhalevski/jtdc/master.yml/master?enable=pin","Warn: npmCommand not pinned by hash: .github/workflows/master.yml:23","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   1 out of   2 npmCommand dependencies pinned"],"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":"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":"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":"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":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.txt:0","Info: FSF or OSI recognized license: MIT License: LICENSE.txt: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":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"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 2 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"}},{"name":"Vulnerabilities","score":0,"reason":"18 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-5v2h-r2cx-5xgj","Warn: Project is vulnerable to: GHSA-rrrm-qjm4-v8hf","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-23T18:20:00.074Z","repository_id":46898543,"created_at":"2025-08-23T18:20:00.075Z","updated_at":"2025-08-23T18:20:00.075Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33082068,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-15T20:25:35.270Z","status":"ssl_error","status_checked_at":"2026-05-15T20:25:34.732Z","response_time":103,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["compile","guard","json-schema","jtd","narrowing","ts","typescript","validator"],"created_at":"2024-11-11T08:34:29.538Z","updated_at":"2026-05-15T22:35:11.592Z","avatar_url":"https://github.com/smikhalevski.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JTDc\n\n[JSON Type Definition (RFC8927)](https://jsontypedef.com/) to TypeScript compiler.\n\n- Compile enums, interface and types;\n- Modify naming of enums, enum keys and values, interfaces, types, properties and any other rendered entities;\n- Compile validator functions that produce an array of detected validation errors;\n- Validators support recursive structures and shallow checks;\n- Compile [type narrowing functions](https://www.typescriptlang.org/docs/handbook/2/narrowing.html) aka type guards;\n- Create custom validator dialect and have explicit control over every aspect of code generation;\n- CLI and programmatic usage;\n\n[Full API documentation.](https://smikhalevski.github.io/jtdc/)\n\n```shell\nnpm install --save-dev @jtdc/cli\n```\n\nBy default, validators and type guards use a `@jtdc/jtd-dialect` runtime dependency. You can alter validator compiler\ndialect by providing `validatorDialectFactory` option to the compiler.\n\n```shell\nnpm install --save-prod @jtdc/jtd-dialect\n```\n\n## CLI usage\n\nLet's assume you have user and account type definitions in separate files under `./src` folder:\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003e./src/user.json\u003c/code\u003e\u003c/summary\u003e\n\u003cp\u003e\n\n```json\n{\n  \"user\": {\n    \"properties\": {\n      \"email\": {\"type\": \"string\"},\n      \"friends\": {\n        \"elements\": {\"ref\": \"user\"}\n      }\n    },\n    \"optionalProperties\": {\n      \"name\": {\"type\": \"string\"},\n      \"age\": {\"type\": \"int8\"}\n    }\n  }\n}\n```\n\n\u003c/p\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003e./src/account.json\u003c/code\u003e\u003c/summary\u003e\n\u003cp\u003e\n\n```json\n{\n  \"account\": {\n    \"properties\": {\n      \"user\": {\"ref\": \"./user.json#user\"},\n      \"stats\": {\n        \"properties\": {\n          \"visitCount\": {\"type\": \"int32\"}\n        }\n      }\n    },\n    \"optionalProperties\": {\n      \"roles\": {\n        \"metadata\": {\n          \"comment\": \"The default role is guest\"\n        },\n        \"elements\": {\"ref\": \"role\"}\n      }\n    }\n  },\n  \"role\": {\n    \"enum\": [\"admin\", \"guest\"]\n  }\n}\n```\n\n\u003c/p\u003e\n\u003c/details\u003e\n\nTo compile these definitions to TypeScript use this command:\n\n```sh\nnpx jtdc --package @jtdc/cli --rootDir ./src --includes '*.json' --outDir ./src/gen --typeGuards\n```\n\nThe result would be output to `./src/gen` folder:\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003e./src/gen/user.ts\u003c/code\u003e\u003c/summary\u003e\n\u003cp\u003e\n\n```ts\nimport * as runtime from '@jtdc/jtd-dialect/lib/runtime';\n\nexport interface User {\n  email: string;\n  friends: Array\u003cUser\u003e;\n  name?: string;\n  age?: number;\n}\n\nexport let validateUser: runtime.Validator = (a, b, c) =\u003e {\n  let d, e, f, g, h;\n  b = b || {};\n  c = c || '';\n  if (runtime.checkObject(a, b, c)) {\n    runtime.checkString(a.email, b, c + '/email');\n    d = a.friends;\n    e = c + '/friends';\n    if (runtime.checkArray(d, b, e)) {\n      for (f = 0; f \u003c d.length; f++) {\n        validateUser(d[f], b, e + runtime.JSON_POINTER_SEPARATOR + f);\n      }\n    }\n    g = a.name;\n    if (runtime.isDefined(g)) {\n      runtime.checkString(g, b, c + '/name');\n    }\n    h = a.age;\n    if (runtime.isDefined(h)) {\n      runtime.checkInteger(h, b, c + '/age');\n    }\n  }\n  return b.errors;\n};\n\nexport let isUser = (value: unknown): value is User =\u003e !validateUser(value, {shallow: true});\n```\n\n\u003c/p\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003e./src/gen/account.ts\u003c/code\u003e\u003c/summary\u003e\n\u003cp\u003e\n\n```ts\nimport * as runtime from '@jtdc/jtd-dialect/lib/runtime';\nimport {User, validateUser} from './user';\n\nexport interface Account {\n  user: User;\n  stats: { visitCount: number; };\n  \n  /**\n   * The default role is guest\n   */\n  roles?: Array\u003cRole\u003e;\n}\n\nexport enum Role {\n  ADMIN = 'admin',\n  GUEST = 'guest',\n}\n\nexport let validateAccount: runtime.Validator = (a, b, c) =\u003e {\n  let d, e, f, g, h;\n  b = b || {};\n  c = c || '';\n  if (runtime.checkObject(a, b, c)) {\n    validateUser(a.user, b, c + '/user');\n    d = a.stats;\n    e = c + '/stats';\n    if (runtime.checkObject(d, b, e)) {\n      runtime.checkInteger(d.visitCount, b, e + '/visitCount');\n    }\n    f = a.roles;\n    if (runtime.isDefined(f)) {\n      g = c + '/roles';\n      if (runtime.checkArray(f, b, g)) {\n        for (h = 0; h \u003c f.length; h++) {\n          validateRole(f[h], b, g + runtime.JSON_POINTER_SEPARATOR + h);\n        }\n      }\n    }\n  }\n  return b.errors;\n};\n\nexport let isAccount = (value: unknown): value is Account =\u003e !validateAccount(value, {shallow: true});\n\nexport let validateRole: runtime.Validator = (a, b, c) =\u003e {\n  b = b || {};\n  runtime.checkEnum(a, (validateRole.cache ||= {}).a ||= ['admin', 'guest'], b, c || '');\n  return b.errors;\n};\n\nexport let isRole = (value: unknown): value is Role =\u003e !validateRole(value, {shallow: true});\n```\n\n\u003c/p\u003e\n\u003c/details\u003e\n\nYou can find [the source code of this example here](./example).\n\n## Programmatic usage\n\n[Full API documentation.](https://smikhalevski.github.io/jtdc/)\n\n```ts\nimport {compileModules} from '@jtdc/compiler';\nimport userJson from './src/user.json';\nimport accountJson from './src/account.json';\n\ncompileModules({\n  './user': userJson,\n  './account': accountJson,\n});\n// → {'./user': 'import …', './account': 'import …'}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmikhalevski%2Fjtdc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmikhalevski%2Fjtdc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmikhalevski%2Fjtdc/lists"}