-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use string-ts library and support zod default values (#18)
* temp * a bit closer * something that seems to work * changeset * use type directly * refactor * use constantcase instead of default * revert some tsconfig changes * update package.json with npm stuff * update readme * refactor Co-authored-by: Eivind M. Skretting <[email protected]> * handle zod default values --------- Co-authored-by: Eivind M. Skretting <[email protected]>
- Loading branch information
Showing
10 changed files
with
130 additions
and
115 deletions.
There are no files selected for viewing
This file contains 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,5 @@ | ||
--- | ||
"@arundo/typed-env": minor | ||
--- | ||
|
||
Use strings-ts to simplify the package. |
This file contains 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,5 @@ | ||
--- | ||
"@arundo/typed-env": patch | ||
--- | ||
|
||
Types of the resolved environment is now the output of schema parse and not the input. |
This file contains 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,7 +1,10 @@ | ||
{ | ||
"editor.formatOnSave": true, | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll.eslint": true | ||
"source.fixAll.eslint": "explicit" | ||
}, | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"[typescript]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
} | ||
} |
This file contains 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 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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,26 @@ | ||
import { ZodError } from 'zod'; | ||
import { Replace, CamelKeys, ConstantKeys, KebabKeys, PascalKeys } from 'string-ts'; | ||
|
||
export type NamingConvention = 'camelcase' | 'pascalcase' | 'kebabcase' | 'constantcase' | 'default'; | ||
|
||
export type Options<TTransform, TPrefixRemoval> = { | ||
transform?: TTransform; | ||
formatErrorFn?: (error: ZodError) => string; | ||
excludePrefix?: TPrefixRemoval; | ||
}; | ||
|
||
export type ConditionalType<TTransform extends NamingConvention, TSchema> = 'default' extends TTransform | ||
? TSchema | ||
: 'constantcase' extends TTransform | ||
? ConstantKeys<TSchema> | ||
: 'camelcase' extends TTransform | ||
? CamelKeys<TSchema> | ||
: 'pascalcase' extends TTransform | ||
? PascalKeys<TSchema> | ||
: 'kebabcase' extends TTransform | ||
? KebabKeys<TSchema> | ||
: never; | ||
|
||
export type PrefixRemoved<TSchema, TPrefixRemoval extends string> = { | ||
[key in keyof TSchema as key extends string ? Replace<key, TPrefixRemoval, ''> : never]: TSchema[key]; | ||
} & {}; |
This file contains 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 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