Zod(POC): Initial jenny for schema generation#1111
Draft
kristinademeshchik wants to merge 5 commits into
Draft
Conversation
|
Note: the diff show code changes that would be introduced by this PR to the output of the Grafana Foundation SDK codegen pipeline.
|
There was a problem hiding this comment.
Pull request overview
Adds an initial “zod” output language to the codegen pipeline, generating Zod v4 schemas from the CUE-derived AST for runtime validation and JSON Schema export.
Changes:
- Extend pipeline output configuration to support a new
zodlanguage (config + wiring). - Introduce a Zod jenny that emits
schemas.gen.tsfiles with Zod schemas for AST types. - Add Zod-specific output options (layout/filename/defaults/object unknown-key behavior).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| schemas/pipeline.json | Adds zod to the pipeline output schema and defines ZodConfig. |
| internal/jennies/zod/jennies.go | Defines Zod language/config and compiler passes used for Zod emission. |
| internal/jennies/zod/rawtypes.go | Implements the core Zod schema emitter (structs/scalars/refs/enums/unions/etc.). |
| internal/jennies/zod/tools.go | Adds helpers for output paths, TS literal formatting, field quoting, and descriptions. |
| internal/codegen/pipeline.go | Wires zod into language selection in the pipeline. |
| internal/codegen/output.go | Adds zod to the YAML output-language struct and parameter interpolation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
7bbdfcc to
64d6446
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a Zod jenny that generates Zod v4 schemas from CUE kinds. Output is intended for runtime validation of payloads (e.g. Grafana's dashboard mutation API) and for LLM tool-call schemas via
z.toJSONSchema().Known issues
uint*doesn't add.nonnegative(); bit widths don't add.gte/.lteconstraints;z.number()acceptsNaN/Infinity. Affects e.g.revision: uint16in v2beta1.// @ts-nocheckfor now; proper fix is explicitz.ZodType<X>annotations on cycle members via SCC detection.Generated dashboards zod schemas - grafana/grafana#125222