-
-
Notifications
You must be signed in to change notification settings - Fork 38
br(v28): Making zod plugin an optional peer dependency. #3313
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 21 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
b8db8a7
br(deps): Making zod plugin an optional peer dependency.
RobinTail f3175e9
upd lockfile.
RobinTail 38b28c2
add plugin to dev deps as well.
RobinTail 2b50d27
rm importing the plugin in vitest setup.
RobinTail 11e224f
fix(ez): prevent brand override.
RobinTail 848208d
fix(deep): shorter syntax.
RobinTail 451672b
fix(raw): simpler type.
RobinTail 3fd3515
fix(test): better assertion.
RobinTail 0826316
BR(plugin): Moving getBrand() to the framework.
RobinTail 1a0bdb1
fix(test): using getBrand again in deep checks test.
RobinTail 100b768
fix(test): reducing diff.
RobinTail 7dba992
Merge branch 'make-v28' into opt-zod-plugin
RobinTail eb8e12f
fix(example): mv plugin import into routing.
RobinTail 11c287c
README: reflecting the breaking change (draft, AI).
RobinTail 67d6467
Merge branch 'make-v28' into opt-zod-plugin
RobinTail 612689b
fix(docs): Plugin readme, changing 'from' to 'for'.
RobinTail 9ba1822
Changelog: reflecting on v28.
RobinTail 320c2aa
Readme: polishing zod plugin section.
RobinTail ef69524
fix(docs): Adjusting documentation section.
RobinTail 3434846
fix(docs): Adjusting the deprecation article.
RobinTail c00dfa2
fix(docs): Improving the brands handling article.
RobinTail 93f06f3
fix(docs): typo
RobinTail 2cfd4c9
fix(test): better assertion for no exports from the plugin.
RobinTail f68afc1
feat: getExamples() helper and general metadata file.
RobinTail a2566c6
ref: using getExamples by pullResponseExamples.
RobinTail 7d842e0
ref: using getExamples by defaultResultHandler.
RobinTail 17ac7e5
fix(import): consistent import of the new file.
RobinTail e3ea8e3
fix(test): rm plugin import from integration test.
RobinTail 7c51d96
fix(test): rm plugin import in documentation test.
RobinTail 924be39
fix(deps): rm the plugin from the framework devDependencies.
RobinTail 2f707a0
Revert "fix(deps): rm the plugin from the framework devDependencies."
RobinTail 88232a8
fix(docs): Add import statement for the plugin demo.
RobinTail 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
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 |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import type { brandProperty as brandProp } from "../../zod-plugin/src/brand.ts"; | ||
| import { globalRegistry, type z } from "zod"; | ||
|
|
||
| export const brandProperty = "x-brand" satisfies typeof brandProp; | ||
|
|
||
| export const getBrand = (subject: z.core.$ZodType) => { | ||
| const { [brandProperty]: brand } = globalRegistry.get(subject) || {}; | ||
| if ( | ||
| typeof brand === "symbol" || | ||
| typeof brand === "string" || | ||
| typeof brand === "number" | ||
| ) | ||
| return brand; | ||
| return undefined; | ||
| }; |
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,9 +1,10 @@ | ||
| import { z } from "zod"; | ||
| import { brandProperty } from "./brand"; | ||
|
|
||
| export const ezFormBrand = Symbol("Form"); | ||
|
|
||
| /** @desc Accepts an object shape or a custom object schema */ | ||
| export const form = <S extends z.core.$ZodShape>(base: S | z.ZodObject<S>) => | ||
| (base instanceof z.ZodObject ? base : z.object(base)).brand( | ||
| ezFormBrand as symbol, | ||
| ); | ||
| (base instanceof z.ZodObject ? base : z.object(base)).meta({ | ||
| [brandProperty]: ezFormBrand, | ||
| }); |
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,20 +1,21 @@ | ||
| import { z } from "zod"; | ||
| import { buffer } from "./buffer-schema"; | ||
| import { brandProperty } from "./brand"; | ||
|
|
||
| export const ezRawBrand = Symbol("Raw"); | ||
|
|
||
| const base = z.object({ raw: buffer() }); | ||
| type Base = ReturnType<typeof base.brand<symbol>>; | ||
| type Base = typeof base; | ||
|
|
||
| const extended = <S extends z.core.$ZodShape>(extra: S) => | ||
| base.extend(extra).brand(ezRawBrand as symbol); | ||
| base.extend(extra).meta({ [brandProperty]: ezRawBrand }); | ||
|
|
||
| export function raw(): Base; | ||
| export function raw<S extends z.core.$ZodShape>( | ||
| extra: S, | ||
| ): ReturnType<typeof extended<S>>; | ||
| export function raw(extra?: z.core.$ZodShape) { | ||
| return extra ? extended(extra) : base.brand(ezRawBrand as symbol); | ||
| return extra ? extended(extra) : base.meta({ [brandProperty]: ezRawBrand }); | ||
| } | ||
|
|
||
| export type RawSchema = Base; |
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
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.