{"id":16426652,"url":"https://github.com/michaelsolati/fbschema","last_synced_at":"2025-10-15T00:12:41.298Z","repository":{"id":57233711,"uuid":"320957793","full_name":"MichaelSolati/fbschema","owner":"MichaelSolati","description":"A simple library to generate TypeScript definition files as well as Firestore rules based on a JSON Schema definition.","archived":false,"fork":false,"pushed_at":"2025-08-18T17:22:50.000Z","size":269,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-17T21:05:39.047Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/MichaelSolati.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-12-13T01:08:13.000Z","updated_at":"2025-08-18T17:22:53.000Z","dependencies_parsed_at":"2025-06-13T11:01:00.689Z","dependency_job_id":"e184ef59-f52d-4312-97ce-075aa8f0798b","html_url":"https://github.com/MichaelSolati/fbschema","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/MichaelSolati/fbschema","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MichaelSolati%2Ffbschema","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MichaelSolati%2Ffbschema/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MichaelSolati%2Ffbschema/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MichaelSolati%2Ffbschema/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MichaelSolati","download_url":"https://codeload.github.com/MichaelSolati/fbschema/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MichaelSolati%2Ffbschema/sbom","scorecard":{"id":93455,"data":{"date":"2025-08-11","repo":{"name":"github.com/MichaelSolati/fbschema","commit":"3d7ef73acf3e25b67f1c97b56490c2c516d050aa"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.9,"checks":[{"name":"Maintained","score":4,"reason":"5 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 4","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":"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":"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/deploy.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/MichaelSolati/fbschema/deploy.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/deploy.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/MichaelSolati/fbschema/deploy.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/lint-and-test.yml:9: update your workflow using https://app.stepsecurity.io/secureworkflow/MichaelSolati/fbschema/lint-and-test.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/lint-and-test.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/MichaelSolati/fbschema/lint-and-test.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/lint-and-test.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/MichaelSolati/fbschema/lint-and-test.yml/main?enable=pin","Info:   0 out of   5 GitHub-owned GitHubAction dependencies pinned","Info:   2 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":"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":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Info: topLevel 'contents' permission set to 'read': .github/workflows/deploy.yml:5","Warn: no topLevel permission defined: .github/workflows/lint-and-test.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":"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":"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.md:0","Info: FSF or OSI recognized license: MIT License: LICENSE.md: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":"Packaging","score":10,"reason":"packaging workflow detected","details":["Info: Project packages its releases by way of GitHub Actions.: .github/workflows/deploy.yml:8"],"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":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"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":"Vulnerabilities","score":6,"reason":"4 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-76c9-3jph-rj3q","Warn: Project is vulnerable to: GHSA-52f5-9888-hmc6"],"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-15T08:21:56.039Z","repository_id":57233711,"created_at":"2025-08-15T08:21:56.039Z","updated_at":"2025-08-15T08:21:56.039Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279031194,"owners_count":26089256,"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-10-14T02:00:06.444Z","response_time":60,"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":[],"created_at":"2024-10-11T08:09:53.808Z","updated_at":"2025-10-15T00:12:41.271Z","avatar_url":"https://github.com/MichaelSolati.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fbschema\n\n[![npm](https://img.shields.io/npm/v/fbschema)](https://www.npmjs.com/package/fbschema)\n[![npm bundle size](https://img.shields.io/bundlephobia/minzip/fbschema)](https://bundlephobia.com/result?p=fbschema)\n[![Deploy CI](https://github.com/MichaelSolati/fbschema/workflows/Deploy%20CI/badge.svg)](https://github.com/MichaelSolati/fbschema/actions?query=workflow%3A%22Deploy+CI%22)\n[![Lint and Test](https://github.com/MichaelSolati/fbschema/workflows/Lint%20and%20Test/badge.svg)](https://github.com/MichaelSolati/fbschema/actions?query=workflow%3A%22Lint+and+Test%22)\n[![GitHub stars](https://img.shields.io/github/stars/MichaelSolati/fbschema)](https://github.com/MichaelSolati/fbschema/stargazers)\n[![GitHub forks](https://img.shields.io/github/forks/MichaelSolati/fbschema)](https://github.com/MichaelSolati/fbschema/network/members)\n\n✨ A simple library to generate **TypeScript definition files** as well as **Firestore rules** based on a [JSON Schema](https://json-schema.org/) definition.  \n\n## ✨ Features  \n\n- Generates **TypeScript interfaces** from JSON Schema files  \n- Generates **Firestore rules** from JSON Schema files with support for:\n  - Type validation (`string`, `number`, `integer`, `boolean`, `array`, `object`)\n  - Required field validation\n  - Enum value validation\n  - Number range validation (min/max, exclusive min/max)\n  - Multiple of validation for integers\n  - String length validation\n  - Collection-level access control (`read`, get, `list`, `write`,`create`, `update`, `delete`)\n  - Property-level validation for `create` and `update` operations based on the JSON Schema file object\n\n## 📦 Installation  \n\n```bash\nnpm install fbschema\n```\n\n## 🚀 Usage  \n\n### 🛠 CLI  \n\n```bash\nnpx fbschema\n```\n\nThe CLI will:  \n1️⃣ Take the current working directory and look for JSON Schema files in the `fbschema` subdirectory 📂  \n2️⃣ Generate TypeScript interfaces in a `types/fbschema` subdirectory ✍️  \n3️⃣ Generate Firestore rules in `firestore.rules` 🔒  \n4️⃣ Show detailed progress logs 📜  \n\n### 🏗 Programmatic Usage  \n\n```typescript\nimport fbschema from 'fbschema';\n\n// ✅ Basic usage\nawait fbschema();\n\n// 📂 With custom working directory\nawait fbschema({\n  path: './your-project',\n});\n\n// 📢 With logging options\nawait fbschema({\n  logs: true, // Enable logging\n});\n```\n\n## 📁 Directory Structure  \n\nBy default, the tool expects the following structure:  \n\n```txt\nyour-project/\n├── fbschema/          # 📁 Your JSON Schema directory\n│   └── *.json         # 📜 Your JSON Schema files\n├── types/\n│   └── fbschema/      # 🏗 Generated TypeScript interfaces\n│       ├── index.ts   # 📌 Main entry point for the generated types\n│       └── *.ts       # 🔧 Generated TypeScript files\n└── firestore.rules    # 🔒 Generated Firestore security rules\n```\n\n## 🔒 Firestore Rules Generation\n\nThe library generates Firestore security rules based on your JSON Schema definitions. Here's an example of how to define rules in your schema:\n\n```json\n{\n  \"title\": \"User\",\n  \"type\": \"object\",\n  \"properties\": {\n    \"name\": {\n      \"type\": \"string\",\n      \"minLength\": 2,\n      \"maxLength\": 50\n    },\n    \"age\": {\n      \"type\": \"integer\",\n      \"minimum\": 0,\n      \"maximum\": 120\n    },\n    \"role\": {\n      \"type\": \"string\",\n      \"enum\": [\"admin\", \"user\", \"guest\"]\n    }\n  },\n  \"required\": [\"name\", \"age\"],\n  \"fbschema\": {\n    \"read\": \"request.auth != null\",\n    \"write\": \"request.auth != null \u0026\u0026 request.auth.token.admin == true\",\n    \"create\": \"request.auth != null\",\n    \"update\": \"request.auth != null \u0026\u0026 request.auth.uid == resource.data.userId\"\n  }\n}\n```\n\nThis will generate rules that:\n\n- Validate the data types and constraints\n- Ensure required fields are present\n- Enforce enum values\n- Apply collection-level access control\n- Handle create and update operations differently\n\n\u003e [!NOTE]\n\u003e The `fbschema` property is a custom extension to the JSON Schema specification. It's not part of the standard JSON Schema but is used by this library to define Firestore-specific security rules. All other properties in the schema follow the standard JSON Schema specification.\n\u003e\n\u003e Each rule in `fbschema` is a string containing any valid Firestore security rule expression. You can write any condition you want, and it will be directly inserted into the generated rules. If a rule is not specified, it defaults to `false` for security.\n\u003e\n\u003e The following rules are supported:\n\u003e\n\u003e - `read`: Controls read access to the collection (combines get and list)\n\u003e - `get`: Controls access to individual document reads\n\u003e - `list`: Controls access to collection queries\n\u003e - `write`: Controls write access to the collection (combines create, update, and delete)\n\u003e - `create`: Controls document creation\n\u003e - `update`: Controls document updates\n\u003e - `delete`: Controls document deletion\n\u003e\n\u003e Note that `read` and `write` are convenience rules that can be used to control multiple operations at once. If you specify both `read` and `get`/`list`, the more specific rule takes precedence. The same applies to `write` and `create`/`update`/`delete`.\n\n## 📖 fbschema Meta-Schema\n\nThis project includes a meta-schema that you can use to validate your `fbschema` files and get autocompletion in supported editors like VS Code. The meta-schema ensures that your schema files adhere to the required structure, including the custom `fbschema` property.\n\nTo use the meta-schema, add the `$schema` property to your JSON schema files:\n\n```json\n{\n  \"$schema\": \"https://raw.githubusercontent.com/MichaelSolati/fbschema/main/fbschema.json\",\n  \"title\": \"YourSchema\",\n  \"type\": \"object\",\n  \"properties\": {\n    \"...\": \"...\"\n  },\n  \"fbschema\": {\n    \"read\": true,\n    \"write\": false\n  }\n}\n```\n\nBy adding the `$schema` property, your editor will provide autocompletion and validation for all standard JSON Schema properties as well as the custom `fbschema` rules, making it easier to write valid and secure Firestore rules.\n\n## 🤝 Contributing  \n\n🛠 All code should pass tests and be well documented. Also, check out the [Commit Message Guidelines](CONTRIBUTING.md) before submitting your PR.  \n\n## ⚖️ License  \n\n📜 [MIT](LICENSE.md)  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaelsolati%2Ffbschema","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichaelsolati%2Ffbschema","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaelsolati%2Ffbschema/lists"}