Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement include and select magic schema generation
- Loading branch information
1 parent
3950788
commit 1eace8f
Showing
7 changed files
with
196 additions
and
79 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
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,31 @@ | ||
import { SchemaType, TypeSchema, input, output } from "ts-to-zod"; | ||
import { | ||
IncludableInput, | ||
IncludableOutput, | ||
SelectableInput, | ||
SelectableOutput, | ||
} from "./z"; | ||
import { IncludablePaths } from "./includes"; | ||
import { SelectTree } from "./parseSelect"; | ||
|
||
export class Includable<T extends TypeSchema<any>> extends SchemaType< | ||
IncludableInput<input<T>>, | ||
IncludableOutput<output<T>> | ||
> {} | ||
|
||
type IncludesIO<T, Depth extends 0 | 1 | 2 | 3 | 4 | 5> = IncludablePaths<output<T>, Depth>[]; | ||
|
||
export class Includes< | ||
T extends TypeSchema<any>, | ||
Depth extends 0 | 1 | 2 | 3 | 4 | 5 = 3 | ||
> extends SchemaType<IncludesIO<T, Depth>, IncludesIO<T, Depth>> {} | ||
|
||
export class Selectable<T extends TypeSchema<any>> extends SchemaType< | ||
SelectableInput<input<T>>, | ||
SelectableOutput<output<T>> | ||
> {} | ||
|
||
export class Selects< | ||
T extends TypeSchema<object>, | ||
Depth extends 0 | 1 | 2 | 3 | 4 | 5 = 3 | ||
> extends SchemaType<string, SelectTree | null | undefined> {} |
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
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
Oops, something went wrong.