-
-
Notifications
You must be signed in to change notification settings - Fork 4k
refactor: replace zod with shapeshift #7547
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 8 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
0a599e2
refactor: replace zod with shapeshift
imranbarbhuiya ebf8cd6
Merge branch 'main' into shapeshift
imranbarbhuiya b397622
fix: merge conflicts
imranbarbhuiya 2583cf9
Merge branch 'main' into shapeshift
imranbarbhuiya ff6d025
Merge branch 'main' into shapeshift
imranbarbhuiya 1236e06
Merge branch 'main' into shapeshift
imranbarbhuiya 0f0f80b
chore: update shapeshift
imranbarbhuiya 6983191
test: update test
imranbarbhuiya 5454094
Apply suggestions from code review
imranbarbhuiya 2ab81ec
chore: fix lint
imranbarbhuiya afe1d20
Apply suggestions from code review
imranbarbhuiya b9ff1c7
Merge branch 'main' into shapeshift
imranbarbhuiya ea81536
fix: remove empty line
imranbarbhuiya a6cdde1
Merge branch 'main' into shapeshift
imranbarbhuiya 1d40f07
fix: update schema
imranbarbhuiya 6877478
Merge branch 'main' into shapeshift
imranbarbhuiya 8ff52ba
Merge branch 'main' into shapeshift
imranbarbhuiya 41de9de
Merge branch 'main' into shapeshift
imranbarbhuiya 94ecda5
fix: allow attchment: protocol
imranbarbhuiya a86fef7
fix: import order
imranbarbhuiya ab9b01d
Merge branch 'main' into shapeshift
imranbarbhuiya 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
13 changes: 6 additions & 7 deletions
13
packages/builders/src/interactions/contextMenuCommands/Assertions.ts
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
12 changes: 5 additions & 7 deletions
12
...eractions/slashCommands/mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin.ts
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
4 changes: 2 additions & 2 deletions
4
packages/builders/src/interactions/slashCommands/options/integer.ts
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
4 changes: 2 additions & 2 deletions
4
packages/builders/src/interactions/slashCommands/options/number.ts
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,43 +1,42 @@ | ||
| import type { APIEmbedField } from 'discord-api-types/v9'; | ||
| import { z } from 'zod'; | ||
| import { s } from '@sapphire/shapeshift'; | ||
|
|
||
| export const fieldNamePredicate = z.string().min(1).max(256); | ||
| export const fieldNamePredicate = s.string.lengthGe(1).lengthLe(256); | ||
|
|
||
| export const fieldValuePredicate = z.string().min(1).max(1024); | ||
| export const fieldValuePredicate = s.string.lengthGe(1).lengthLe(1024); | ||
|
|
||
| export const fieldInlinePredicate = z.boolean().optional(); | ||
| export const fieldInlinePredicate = s.boolean.optional; | ||
|
|
||
| export const embedFieldPredicate = z.object({ | ||
| export const embedFieldPredicate = s.object({ | ||
| name: fieldNamePredicate, | ||
| value: fieldValuePredicate, | ||
| inline: fieldInlinePredicate, | ||
| }); | ||
|
|
||
| export const embedFieldsArrayPredicate = embedFieldPredicate.array(); | ||
| export const embedFieldsArrayPredicate = embedFieldPredicate.array; | ||
|
|
||
| export const fieldLengthPredicate = z.number().lte(25); | ||
| export const fieldLengthPredicate = s.number.le(25); | ||
|
|
||
| export function validateFieldLength(amountAdding: number, fields?: APIEmbedField[]): void { | ||
| fieldLengthPredicate.parse((fields?.length ?? 0) + amountAdding); | ||
| } | ||
|
|
||
| export const authorNamePredicate = fieldNamePredicate.nullable(); | ||
| export const authorNamePredicate = fieldNamePredicate.nullable; | ||
|
|
||
| export const urlPredicate = z.string().url().nullish(); | ||
| export const urlPredicate = s.string.url({ | ||
| allowedProtocols: ['http:', 'https:'], | ||
| }).nullish; | ||
|
|
||
| export const RGBPredicate = z.number().int().gte(0).lte(255); | ||
| export const colorPredicate = z | ||
| .number() | ||
| .int() | ||
| .gte(0) | ||
| .lte(0xffffff) | ||
| .nullable() | ||
| .or(z.tuple([RGBPredicate, RGBPredicate, RGBPredicate])); | ||
| export const RGBPredicate = s.number.int.ge(0).le(255); | ||
| export const colorPredicate = s.number.int | ||
| .ge(0) | ||
| .le(0xffffff) | ||
| .or(s.tuple([RGBPredicate, RGBPredicate, RGBPredicate])).nullable; | ||
|
|
||
| export const descriptionPredicate = z.string().min(1).max(4096).nullable(); | ||
| export const descriptionPredicate = s.string.lengthGe(1).lengthLe(4096).nullable; | ||
|
|
||
| export const footerTextPredicate = z.string().min(1).max(2048).nullable(); | ||
| export const footerTextPredicate = s.string.lengthGe(1).lengthLe(2048).nullable; | ||
|
|
||
| export const timestampPredicate = z.union([z.number(), z.date()]).nullable(); | ||
| export const timestampPredicate = s.union(s.number, s.date).nullable; | ||
|
|
||
| export const titlePredicate = fieldNamePredicate.nullable(); | ||
| export const titlePredicate = fieldNamePredicate.nullable; |
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
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.