-
Notifications
You must be signed in to change notification settings - Fork 14
feat: add plugin configuration validation to lint #426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
19f3bff
feat: add plugin configuration validation to lint
jarvis9443 85598d7
fix: resolve CI failures - typecheck path type and unused ajv dep
jarvis9443 ec31ac2
chore: remove out-tsc build artifacts and fix .gitignore
jarvis9443 da8d4ee
fix: remove ajv deps from root package.json
jarvis9443 95738f8
fix: gate FetchPluginSchemasTask with --no-lint flag in diff/sync
jarvis9443 5e6a6db
fix: prevent env vars from implicitly activating backend in lint
jarvis9443 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ | |
| # compiled output | ||
| dist | ||
| tmp | ||
| /out-tsc | ||
| out-tsc | ||
|
|
||
| # dependencies | ||
| node_modules | ||
|
|
||
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,51 @@ | ||
| import { Configuration } from '@api7/adc-sdk'; | ||
| import { ConfigurationSchema } from '@api7/adc-sdk/schema'; | ||
| import { z } from 'zod'; | ||
|
|
||
| export const check = (config: Configuration) => { | ||
| return ConfigurationSchema.safeParse(config); | ||
| import { validatePlugins } from './plugin-validator'; | ||
| import type { LintError, LintOptions, LintResult } from './types'; | ||
|
|
||
| export type { LintError, LintOptions, LintResult } from './types'; | ||
|
|
||
| const zodIssuesToLintErrors = (issues: z.ZodIssue[]): LintError[] => | ||
| issues.map(({ path, message, code, ...rest }) => ({ | ||
| path, | ||
| message, | ||
| code, | ||
| ...rest, | ||
| })); | ||
|
|
||
| export const check = ( | ||
| config: Configuration, | ||
| opts?: LintOptions, | ||
| ): LintResult => { | ||
| // Phase 1: core resource structure validation (local, no network) | ||
| const result = ConfigurationSchema.safeParse(config); | ||
| if (!result.success) { | ||
| return { | ||
| success: false, | ||
| errors: zodIssuesToLintErrors(result.error.issues), | ||
| }; | ||
| } | ||
|
|
||
| // Phase 2: plugin config validation (requires plugin schemas from backend) | ||
| if (opts?.pluginSchemas) { | ||
| const pluginErrors = validatePlugins( | ||
| result.data as Configuration, | ||
| opts.pluginSchemas, | ||
| ); | ||
| if (pluginErrors.length > 0) { | ||
| return { | ||
| success: false, | ||
| errors: pluginErrors, | ||
| data: result.data, | ||
| }; | ||
| } | ||
| } | ||
|
|
||
| return { | ||
| success: true, | ||
| errors: [], | ||
| data: result.data, | ||
| }; | ||
| }; | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.