Skip to content

Types and schema/config#684

Draft
yesoreyeram wants to merge 3 commits intomainfrom
types-and-schema/config
Draft

Types and schema/config#684
yesoreyeram wants to merge 3 commits intomainfrom
types-and-schema/config

Conversation

@yesoreyeram
Copy link
Copy Markdown
Contributor

No description provided.

…ll (#685)

Generate JSON Schema from the Zod config schemas in
`src/types/config.ts` and serve it via a backend `/schema/config`
resource 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
- Export `GitHubDataSourceOptionsSchema` and
`GitHubSecureJsonDataSchema` from `src/types/config.ts`
- All Zod schema fields include `.describe()` calls so that
human-readable descriptions (plan types, auth types, URLs, app IDs,
tokens, keys) are propagated into the generated JSON Schema
- Add `scripts/generate-config-schema.ts` — uses Zod v4's built-in
`z.toJSONSchema()` to produce JSON Schema for both `jsonData` and
`secureJsonData`
- Outputs to `pkg/schema/config.json` (Go embed)
- New npm script: `yarn generate:config-schema`

### Backend resource endpoint
- `pkg/schema/config.go` — embeds the generated JSON schema via
`//go:embed`
- `pkg/plugin/instance.go` — `CallResource` intercepts `schema/config`
path and returns the embedded schema; all other paths delegate to
`SchemaDatasource` as before

```go
if req.Path == "schema/config" {
    return sender.Send(&backend.CallResourceResponse{
        Status:  http.StatusOK,
        Headers: map[string][]string{"Content-Type": {"application/json"}},
        Body:    schema.ConfigSchemaJSON,
    })
}
```

### Local import guard (ESLint)
- Added an ESLint `no-restricted-imports` rule in `eslint.config.mjs`
scoped to `src/types/config.ts` that blocks any relative imports
(`'./*'`, `'../*'`), ensuring all config types remain self-contained in
a single file
- The CI workflow runs `yarn lint` against `src/types/config.ts` to
enforce this guard

### CI workflow
- `.github/workflows/check-config-schema.yml` — triggers on changes to
`src/types/config.ts` or the generation script, lints config types for
import violations, regenerates the schema, and fails if the committed
version is stale

### Pre-commit hook
- `scripts/pre-commit` — auto-regenerates and stages the schema file
when `src/types/config.ts` is modified
- Install: `cp scripts/pre-commit .git/hooks/pre-commit && chmod +x
.git/hooks/pre-commit`

<!-- START COPILOT CODING AGENT TIPS -->
---

📍 Connect Copilot coding agent with [Jira](https://gh.io/cca-jira-docs),
[Azure Boards](https://gh.io/cca-azure-boards-docs) or
[Linear](https://gh.io/cca-linear-docs) to delegate work to Copilot in
one click without leaving your project management tool.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: yesoreyeram <153843+yesoreyeram@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

2 participants