-
-
Notifications
You must be signed in to change notification settings - Fork 145
feat(zod): rewrite @orpc/zod #206
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
6536116
wip
dinwwwh 80e28f5
wip - converter
dinwwwh 54e58f5
wip
dinwwwh b4dd6b0
wip
dinwwwh f9dbf91
wip
dinwwwh ca6b46e
wip
dinwwwh 028a883
fix docs
dinwwwh fcabbe8
wip
dinwwwh 2050d55
sync
dinwwwh 0823e1f
lint fixed
dinwwwh d5a0dd7
fix deps
dinwwwh 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
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 |
|---|---|---|
|
|
@@ -51,6 +51,6 @@ | |
| "@orpc/standard-server-fetch": "workspace:*" | ||
| }, | ||
| "devDependencies": { | ||
| "zod": "^3.24.1" | ||
| "zod": "^3.24.2" | ||
| } | ||
| } | ||
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 |
|---|---|---|
|
|
@@ -42,6 +42,6 @@ | |
| "devDependencies": { | ||
| "arktype": "2.0.0-rc.26", | ||
| "valibot": "1.0.0-beta.9", | ||
| "zod": "^3.24.1" | ||
| "zod": "^3.24.2" | ||
| } | ||
| } | ||
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 |
|---|---|---|
|
|
@@ -77,6 +77,6 @@ | |
| "rou3": "^0.5.1" | ||
| }, | ||
| "devDependencies": { | ||
| "zod": "^3.24.1" | ||
| "zod": "^3.24.2" | ||
| } | ||
| } | ||
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
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,34 +1,30 @@ | ||
| import type { Schema } from '@orpc/contract' | ||
| import type { JSONSchema } from './schema' | ||
|
|
||
| export interface SchemaConvertOptions { | ||
| strategy: 'input' | 'output' | ||
| } | ||
| export type SchemaConvertStrategy = 'input' | 'output' | ||
|
|
||
| export interface SchemaConverter { | ||
| condition(schema: Schema, options: SchemaConvertOptions): boolean | ||
| convert(schema: Schema, strategy: SchemaConvertStrategy): [required: boolean, jsonSchema: JSONSchema] | ||
| } | ||
|
|
||
| convert(schema: Schema, options: SchemaConvertOptions): JSONSchema.JSONSchema | ||
| export interface ConditionalSchemaConverter extends SchemaConverter { | ||
| condition(schema: Schema, strategy: SchemaConvertStrategy): boolean | ||
| } | ||
|
|
||
| export class CompositeSchemaConverter implements SchemaConverter { | ||
| private readonly converters: SchemaConverter[] | ||
| private readonly converters: ConditionalSchemaConverter[] | ||
|
|
||
| constructor(converters: SchemaConverter[]) { | ||
| constructor(converters: ConditionalSchemaConverter[]) { | ||
| this.converters = converters | ||
| } | ||
|
|
||
| condition(): boolean { | ||
| return true | ||
| } | ||
|
|
||
| convert(schema: Schema, options: SchemaConvertOptions): JSONSchema.JSONSchema { | ||
| convert(schema: Schema, strategy: SchemaConvertStrategy): [required: boolean, jsonSchema: JSONSchema] { | ||
| for (const converter of this.converters) { | ||
| if (converter.condition(schema, options)) { | ||
| return converter.convert(schema, options) | ||
| if (converter.condition(schema, strategy)) { | ||
| return converter.convert(schema, strategy) | ||
| } | ||
| } | ||
|
|
||
| return {} // ANY SCHEMA | ||
| return [false, {}] | ||
| } | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
❓ Verification inconclusive
Add test coverage for this line
This line appears to be flagged by code coverage tools as not covered by tests.
🏁 Script executed:
Length of output: 101
Action Required: Add Test Coverage for Query Schema Assignment
It appears that the initialization of
querySchemaat line 91 inpackages/openapi/src/openapi-input-structure-parser.tsis currently not exercised by any existing tests. A search for test references (using patterns like"parseCompactSchema.*querySchema.*method.*GET"and a more general search for"querySchema") returned no findings in our openapi-related test files.packages/openapi/src/openapi-input-structure-parser.tsat line 91inputSchemacorrectly initializesquerySchema.inputSchemais undefined, if applicable.These changes are required to ensure full code coverage and to validate the intended behavior of the parser.
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 91-91: packages/openapi/src/openapi-input-structure-parser.ts#L91
Added line #L91 was not covered by tests