{"id":13767553,"url":"https://github.com/owncoral/pgzod","last_synced_at":"2025-04-10T20:55:11.278Z","repository":{"id":57322746,"uuid":"421086850","full_name":"owncoral/pgzod","owner":"owncoral","description":"Transform PostgreSQL schemas into Zod validators and types","archived":false,"fork":false,"pushed_at":"2025-04-02T04:05:54.000Z","size":180,"stargazers_count":53,"open_issues_count":14,"forks_count":6,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-02T05:19:25.355Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PLpgSQL","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/owncoral.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-10-25T15:46:16.000Z","updated_at":"2025-02-01T20:13:07.000Z","dependencies_parsed_at":"2024-06-23T00:41:01.859Z","dependency_job_id":"68baa294-898a-4936-86b7-4b1518fe8e45","html_url":"https://github.com/owncoral/pgzod","commit_stats":{"total_commits":40,"total_committers":2,"mean_commits":20.0,"dds":"0.025000000000000022","last_synced_commit":"a485c1eb1b8d1c4887ab9a7f181d371bfef64e86"},"previous_names":["guzmonne/pgzod"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owncoral%2Fpgzod","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owncoral%2Fpgzod/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owncoral%2Fpgzod/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owncoral%2Fpgzod/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/owncoral","download_url":"https://codeload.github.com/owncoral/pgzod/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248298092,"owners_count":21080313,"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","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":[],"created_at":"2024-08-03T16:01:09.702Z","updated_at":"2025-04-10T20:55:11.227Z","avatar_url":"https://github.com/owncoral.png","language":"PLpgSQL","funding_links":[],"categories":["Convertors and Generators"],"sub_categories":[],"readme":"\u003cdiv id=\"top\"\u003e\u003c/div\u003e\n\n[![Contributors][contributors-shield]][contributors-url]\n[![Forks][forks-shield]][forks-url]\n[![Stargazers][stars-shield]][stars-url]\n[![Issues][issues-shield]][issues-url]\n[![MIT License][license-shield]][license-url]\n\n\n\n\u003c!-- PROJECT LOGO --\u003e\n\u003cbr /\u003e\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://github.com/owncoral/pgzod\"\u003e\n    \u003cimg src=\"https://avatars.githubusercontent.com/u/76981916?s=200\u0026v=4\" alt=\"Logo\" width=\"80\" height=\"80\"\u003e\n  \u003c/a\u003e\n\n\u003ch3 align=\"center\"\u003e\u003ccode\u003epgzod\u003c/code\u003e\u003c/h3\u003e\n\n  \u003cp align=\"center\"\u003e\n    Transform PostgreSQL schemas into Zod validators and types\n    \u003cbr /\u003e\n    \u003ca href=\"https://owncoral.github.io/pgzod\"\u003e\u003cstrong\u003eExplore the docs »\u003c/strong\u003e\u003c/a\u003e\n    \u003c!-- \u003cbr /\u003e --\u003e\n    \u003cbr /\u003e\n    \u003c!-- \u003ca href=\"https://github.com/owncoral/pgzod\"\u003eView Demo\u003c/a\u003e --\u003e\n    \u003c!-- · --\u003e\n    \u003ca href=\"https://github.com/owncoral/pgzod/issues\"\u003eReport Bug\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/owncoral/pgzod/issues\"\u003eRequest Feature\u003c/a\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\n\n\u003ch2\u003eTable of Contents\u003c/h2\u003e\n\n\u003c!-- TABLE OF CONTENTS --\u003e\n- [1. About The Project](#1-about-the-project)\n  - [1.1. Built With](#11-built-with)\n- [2. Getting Started](#2-getting-started)\n- [3. Usage](#3-usage)\n- [4. Roadmap](#4-roadmap)\n- [5. Contributing](#5-contributing)\n- [6. License](#6-license)\n- [7. Contact](#7-contact)\n\n\u003c!-- ABOUT THE PROJECT --\u003e\n## 1. About The Project\n\nKeeping Typescript types in sync with your PostgreSQL database schemas is very useful but challenging.\nWith PGZod that you can maintain all your tables in sync with Typescript through\n[\"Zod\"][zod]. Zod is, in their own words:\n\n\u003e a TypeScript-first schema declaration and validation library. You can use a Zod schema for validation or as a normal type.\n\nIt works great when you couple it with a PostgreSQL client like [slonik][slonik].\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n### 1.1. Built With\n\n* [Slonik][slonik]\n* [Typescript][typescript]\n* [Yargs][yargs]\n* [Zod][zod]\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- GETTING STARTED --\u003e\n## 2. Getting Started\n\nThe best way to run PGZod is by installing it globally or using it through `npx`.\n\n* npm\n  ```sh\n  npm install pgzod -g\n  ```\n* yarn\n  ```sh\n  yarn global add pgzod\n  ```\n\nIf you want to use `npx`, you don't have to install PGZod run:\n\n```sh\n# Shows the command help.\nnpx pgzod --help\n```\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- USAGE EXAMPLES --\u003e\n## 3. Usage\n\nYou can use PGZod from the command line. It needs the credentials and the address of the live\ndatabase from where to read the schema. You can provide this information through command options or\nenvironment variables. All the [variables from PostgreSQL][postgresql-env-vars] are supported.\n\nYour database credentials could be stored on a local `.env` file, or even better, on a secret\nmanager. You then load the credentials to your current session and run the PGZod command.\n\nFor example, you could build the following `.env` file:\n\n```ini\nPGHOST=some.postgresql.host\nPGPORT=12345\nPGDATABASE=app\nPGSSLMODE=require\nPGUSER=postgres\nPGPASSWORD=yourpassword!\n```\n\nLoad the `.env` variables, and override others through command options.\n\n```sh\nenv $(xargs \u003c .env) pgzod --pghost 127.0.0.1 --pgport 5432 --schema public\n```\n\n\u003e PGZod will not look for tables on your whole database just a single `schema`. You can\n\u003e indicate your database `schema` through the`--schema` option. If you don't provide it, PGZod\n\u003e runs against the `public` schemas.\n\n_For more examples, please refer to the [Documentation][docs]_\n\n### Strategies\n\nPGZod offers the concept of `strategies` to define how it should create the `Zod` validator files. Here\nis the current list of strategies exposed:\n\n| Value | Description |\n| ---   | ---         |\n| `write` | Creates `Zod` validators considering only writes to the table. Columns that have default values will be marked as `optional`. |\n| `readwrite` | Creates `Zod` validators for both read and write actions. PGZod will create two validators for each `table` with the `Read` and `Write` suffix to differentiate both actions. **This is probably the strategy you want to work with**. |\n\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- ROADMAP --\u003e\n## 4. Roadmap\n\n- Find a better solution to deal with dates, and currently, we treat them as strings.\n- Add support for more types.\n- Allow the user to override the current type mappings.\n- Add tests.\n\nSee the [open issues](https://github.com/owncoral/pgzod/issues) for a complete list of proposed features (and known issues).\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- CONTRIBUTING --\u003e\n## 5. Contributing\n\nYour contributions make the open-source community a fantastic place to learn, inspire, and create.\n\nTo suggest how to improve this project, please fork the repo and create a pull request.\n\nYou can also create an issue with the tag \"enhancement.\"\n\nDon't forget to give the project a star! Thanks again!\n\n1. Fork the Project\n2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the Branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- LICENSE --\u003e\n## 6. License\n\nDistributed under the MIT License. See `LICENSE.txt` for more information.\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- CONTACT --\u003e\n## 7. Contact\n\nYour Name - [@owncoral](https://twitter.com/owncoral) - support@owncoral.com\n\nProject Link: [https://github.com/owncoral/pgzod](https://github.com/owncoral/pgzod)\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!-- MARKDOWN LINKS \u0026 IMAGES --\u003e\n\u003c!-- https://www.markdownguide.org/basic-syntax/#reference-style-links --\u003e\n[contributors-shield]: https://img.shields.io/github/contributors/owncoral/pgzod.svg?style=for-the-badge\n[contributors-url]: https://github.com/owncoral/pgzod/graphs/contributors\n[docs]: https://github.com/owncoral/pgzod\n[forks-shield]: https://img.shields.io/github/forks/owncoral/pgzod.svg?style=for-the-badge\n[forks-url]: https://github.com/owncoral/pgzod/network/members\n[issues-shield]: https://img.shields.io/github/issues/owncoral/pgzod.svg?style=for-the-badge\n[issues-url]: https://github.com/owncoral/pgzod/issues\n[license-shield]: https://img.shields.io/github/license/owncoral/pgzod.svg?style=for-the-badge\n[license-url]: https://github.com/owncoral/pgzod/blob/master/LICENSE.txt\n[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge\u0026logo=linkedin\u0026colorB=555\n[postgresql-env-vars]: https://www.postgresql.org/docs/current/libpq-envars.html\n[slonik]: https://www.npmjs.com/package/slonik\n[stars-shield]: https://img.shields.io/github/stars/owncoral/pgzod.svg?style=for-the-badge\n[stars-url]: https://github.com/owncoral/pgzod/stargazers\n[typescript]: https://typescript.com\n[yargs]: https://www.npmjs.com/package/yargs\n[zod]: https://www.npmjs.com/package/zod\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fowncoral%2Fpgzod","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fowncoral%2Fpgzod","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fowncoral%2Fpgzod/lists"}