Add config JSON schema generation from Zod and expose via resource call#685
Conversation
- Export Zod schemas from src/types/config.ts - Create scripts/generate-config-schema.ts to generate JSON schema - Add generate:config-schema npm script - Generate config-schema.json for frontend and backend - Create pkg/configschema package with embedded JSON schema - Add /config-schema resource call endpoint in CallResource Co-authored-by: yesoreyeram <153843+yesoreyeram@users.noreply.github.com>
…idation - Add .github/workflows/check-config-schema.yml to verify schema freshness - Add scripts/pre-commit hook to auto-update schema on config type changes Co-authored-by: yesoreyeram <153843+yesoreyeram@users.noreply.github.com>
Co-authored-by: yesoreyeram <153843+yesoreyeram@users.noreply.github.com>
|
@copilot remove unnecessary/irrelevant golden file changes. Use schema/config as path for schema file. Use the same for resource call path. Is there any guard we can put in such a way that all the config types lives in a same file and no imports from local files? This is to make sure no other changes affect the schema. |
…l import guard - Revert all irrelevant golden file changes - Rename schema file path to schema/config (src/schema/config.json, pkg/configschema/config.json) - Use schema/config as the resource call path - Add guard in generate script to reject local file imports in config.ts - Add guard step in CI workflow to catch local imports early Co-authored-by: yesoreyeram <153843+yesoreyeram@users.noreply.github.com>
Done in a141114:
|
|
@copilot - why still there are duplicate json files? We don't want json schema files inside src folder. Instead we want inside pkg folder with proper naming convention. Also wondering if there is any eslint rule we can put as a import guardrail instead of custom script? |
…uard - Remove src/schema/config.json — schema only lives in pkg/configschema/config.json - Replace custom import guard script with ESLint no-restricted-imports rule in eslint.config.mjs, scoped to src/types/config.ts - CI workflow uses yarn lint to enforce the import guard - Simplify generate script to single output location - Update pre-commit hook to only stage pkg/configschema/config.json Co-authored-by: yesoreyeram <153843+yesoreyeram@users.noreply.github.com>
Done in d22ba25:
|
|
@copilot - Still I see irrelevant golden jsonc files.
|
- Rename pkg/configschema/ to pkg/schema/ (configschema.go → config.go) - Update all references in instance.go, generate script, CI workflow, pre-commit - Revert all golden jsonc file changes to match base branch Co-authored-by: yesoreyeram <153843+yesoreyeram@users.noreply.github.com>
Done in 731551b:
|
|
@copilot - Add description for each field to config typescript schema so that they will be generated in the JSON schema. |
…ration Co-authored-by: yesoreyeram <153843+yesoreyeram@users.noreply.github.com>
Done in bb1726d. Added |
Generate JSON Schema from the Zod config schemas in
src/types/config.tsand serve it via a backend/schema/configresource endpoint. Includes CI validation, a pre-commit hook to keep the schema in sync, and an ESLint guard to ensure config types remain self-contained.Schema generation
GitHubDataSourceOptionsSchemaandGitHubSecureJsonDataSchemafromsrc/types/config.ts.describe()calls so that human-readable descriptions (plan types, auth types, URLs, app IDs, tokens, keys) are propagated into the generated JSON Schemascripts/generate-config-schema.ts— uses Zod v4's built-inz.toJSONSchema()to produce JSON Schema for bothjsonDataandsecureJsonDatapkg/schema/config.json(Go embed)yarn generate:config-schemaBackend resource endpoint
pkg/schema/config.go— embeds the generated JSON schema via//go:embedpkg/plugin/instance.go—CallResourceinterceptsschema/configpath and returns the embedded schema; all other paths delegate toSchemaDatasourceas beforeLocal import guard (ESLint)
no-restricted-importsrule ineslint.config.mjsscoped tosrc/types/config.tsthat blocks any relative imports ('./*','../*'), ensuring all config types remain self-contained in a single fileyarn lintagainstsrc/types/config.tsto enforce this guardCI workflow
.github/workflows/check-config-schema.yml— triggers on changes tosrc/types/config.tsor the generation script, lints config types for import violations, regenerates the schema, and fails if the committed version is stalePre-commit hook
scripts/pre-commit— auto-regenerates and stages the schema file whensrc/types/config.tsis modifiedcp scripts/pre-commit .git/hooks/pre-commit && chmod +x .git/hooks/pre-commit📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.