Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/oviva-ag/spicegen
SpiceDB Client Generator for Java
https://github.com/oviva-ag/spicegen
generator spicedb spicedb-client type-safe
Last synced: about 1 month ago
JSON representation
SpiceDB Client Generator for Java
- Host: GitHub
- URL: https://github.com/oviva-ag/spicegen
- Owner: oviva-ag
- License: apache-2.0
- Created: 2024-05-15T08:01:09.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-05-21T14:24:42.000Z (7 months ago)
- Last Synced: 2024-05-22T12:22:07.615Z (7 months ago)
- Topics: generator, spicedb, spicedb-client, type-safe
- Language: Java
- Homepage:
- Size: 4.97 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
- awesome-spicedb - oviva-ag/spicegen - type-safe client generator from a schema (Clients / Third-party Libraries)
README
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=oviva-ag_spicegen&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=oviva-ag_spicegen)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=oviva-ag_spicegen&metric=coverage)](https://sonarcloud.io/summary/new_code?id=oviva-ag_spicegen)
# SpiceDB Client Generator- Bored of copy & pasting strings from your SpiceDB schema into your client code?
- Had enough bugs or downtimes due to client library bugs due to typing and typo mistakes?*Look no further!*
This is a Java generator for SpiceDB schemas which generates:
- **constants** - generates `string` constants for object definitions, permissions and relations
- **type-safe references** - generates type-safe object references
- **type-safe relationship updates** - provides factory methods to assemble type-safe relationship updates## Getting Started
**Prerequistes:**
- [GitHub packages for Maven](https://docs.github.com/de/packages/working-with-a-github-packages-registry/working-with-the-apache-maven-registry)
1. Add the `com.oviva.spicegen:api` dependency
2. Add the `com.oviva.spicegen:spicegen-maven-plugin` pluginExample `pom.xml`
```xml
...
...
com.oviva.spicegen
api
${spicegen.version}
...
com.oviva.spicegen
spicegen-maven-plugin
${spicegen.version}
${project.basedir}/src/main/resources/schema.zed
${project.groupId}.permissions
${project.basedir}/target/generated-sources/src/main/java
spicegen
```
## Implementation Overview
```mermaid
graph LR
schema[/schema.zed/] -- " pre-process to AST (go) " --> ast[Abstract Syntax Tree]
ast -- " read and map (java) " --> model[Schema Model]
model -- generate --> source[/TypeDefs & Schema Constants/]
```The generator work in multiple stages that could be re-used for other generators, namely:
1. The SpiceDB schema is parsed (`*.zed`) into an AST by the official lexer and parser. See [parser](./parser).
2. The AST is serialized to JSON, which in turn is picked up by the Java generator and transformed
into a nice model. See [model](./model).
3. The schema model is transformed into Java sources. See [generator](./generator)To make this easy to use, all the above is bundled in the [maven plugin](./generator-maven-plugin).
## Useful Links
- [SpiceDB API Docs](https://buf.build/authzed/api/docs/main/authzed.api.v1)
## Wishlist
- type-safe IDs, needs additional metadata in the schema
- generate caveats
- permission check boilerplate, might need additional schema metadata