{"id":23773380,"url":"https://github.com/beenotung/gen-sql-type","last_synced_at":"2025-09-05T18:31:09.302Z","repository":{"id":57245846,"uuid":"340457532","full_name":"beenotung/gen-sql-type","owner":"beenotung","description":"Generate Typescript Types from raw SQL statements","archived":false,"fork":false,"pushed_at":"2024-10-03T05:07:25.000Z","size":90,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-09T06:47:00.929Z","etag":null,"topics":["code-generation","gen-type","sql","type-gen","typescript"],"latest_commit_sha":null,"homepage":"https://gen-sql-type.surge.sh","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/beenotung.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":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-02-19T18:35:11.000Z","updated_at":"2024-10-03T05:07:29.000Z","dependencies_parsed_at":"2024-10-23T01:55:37.097Z","dependency_job_id":null,"html_url":"https://github.com/beenotung/gen-sql-type","commit_stats":{"total_commits":65,"total_committers":1,"mean_commits":65.0,"dds":0.0,"last_synced_commit":"2ce9e353abda058f31986f0ada6e9e3fd1d04634"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/beenotung/gen-sql-type","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beenotung%2Fgen-sql-type","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beenotung%2Fgen-sql-type/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beenotung%2Fgen-sql-type/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beenotung%2Fgen-sql-type/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/beenotung","download_url":"https://codeload.github.com/beenotung/gen-sql-type/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beenotung%2Fgen-sql-type/sbom","scorecard":{"id":230254,"data":{"date":"2025-08-11","repo":{"name":"github.com/beenotung/gen-sql-type","commit":"2ce9e353abda058f31986f0ada6e9e3fd1d04634"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"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":"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":"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":"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":"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":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"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":"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":"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: BSD 2-Clause \"Simplified\" 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":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"}}]},"last_synced_at":"2025-08-17T04:43:10.484Z","repository_id":57245846,"created_at":"2025-08-17T04:43:10.484Z","updated_at":"2025-08-17T04:43:10.484Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273798996,"owners_count":25170295,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-05T02:00:09.113Z","response_time":402,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["code-generation","gen-type","sql","type-gen","typescript"],"created_at":"2025-01-01T05:39:34.013Z","updated_at":"2025-09-05T18:31:08.981Z","avatar_url":"https://github.com/beenotung.png","language":"TypeScript","readme":"# gen-sql-type\n\nGenerate Typescript Types from raw SQL statements\n\n[![npm Package Version](https://img.shields.io/npm/v/gen-sql-type)](https://www.npmjs.com/package/gen-sql-type)\n\nPlayground: https://gen-sql-type.surge.sh/\n\n## How it works\n\nThis library scan the plain sql statements then auto generate Typescript types of the result row and named parameters.\n(Also supports prepared statement)\n\n## Features\n\n- [x] Extract types from sql statement\n  - [x] Support alias column name\n  - [x] Support function call (e.g. `COUNT(*)`)\n  - [x] Support quoted column name with escape sequence (e.g. treat `'can''t'` as `\"can't\"`)\n  - [x] Support named parameters (e.g. `:id` and `@username`)\n  - [x] Supported statement types:\n    - `SELECT`\n    - `UPDATE`\n    - `DELETE`\n    - `INSERT`\n  - [x] Support select from `WITH`-clause\n- [x] Generate Typescript type for:\n  - [x] Row of select result\n  - [x] Named parameters for prepared statement\n- [x] Isomorphic, support both node.js and browser\n\n## Usage Example\n\nGiven _user-service.ts_:\n\n```typescript\nconst sqlTypeFile = SqlTypeFile.withPrefix(__filename)\n\nexport class UserService {\n  async login(parameters: LoginUserParameters): Promise\u003cLoginUserRow\u003e {\n    const sql: string = sqlTypeFile.wrapSql(\n      'LoginUser',\n      'select password_hash from user where id = :id',\n    )\n    return mockExec(sql, parameters)[0]\n  }\n\n  async logout(parameters: LogoutUserParameters) {\n    const sql: string = sqlTypeFile.wrapSql(\n      'LogoutUser',\n      'update session set active = false where token = :token',\n    )\n    return mockExec(sql, parameters)\n  }\n}\n```\n\nUpon execution, it will auto generate _user-service.types.ts_:\n\n```typescript\nexport type LoginUserParameters = {\n  id: any\n}\nexport type LoginUserRow = {\n  password_hash: any\n}\n\nexport type LogoutUserParameters = {\n  token: any\n}\n```\n\nComplete example refers to [./examples/user-service.ts](./examples/user-service.ts)\n\n## License\n\nThis is free and open-source software (FOSS) with\n[BSD-2-Clause License](./LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeenotung%2Fgen-sql-type","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeenotung%2Fgen-sql-type","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeenotung%2Fgen-sql-type/lists"}