Co-authored-by: Julien Valverdé <julien.valverde@mailo.com> Reviewed-on: https://git.jvalver.de/Thilawyn/schemable-class/pulls/2
This commit was merged in pull request #2.
This commit is contained in:
66
src/legacy/jsonifiable/JsonifiableSchemableClass.ts
Normal file
66
src/legacy/jsonifiable/JsonifiableSchemableClass.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
import { Effect } from "effect"
|
||||
import { Class } from "type-fest"
|
||||
import { JsonifiableObject } from "type-fest/source/jsonifiable"
|
||||
import { z } from "zod"
|
||||
import { SchemableClassConstructorParams, SchemableConfig } from ".."
|
||||
|
||||
|
||||
export type JsonifiableSchemableConfig<
|
||||
$SchemableConfig extends SchemableConfig = SchemableConfig,
|
||||
|
||||
JsonifiedValues extends JsonifiableObject = {},
|
||||
|
||||
JsonifySchemaT extends z.ZodRawShape = z.ZodRawShape,
|
||||
JsonifySchemaUnknownKeys extends z.UnknownKeysParam = z.UnknownKeysParam,
|
||||
JsonifySchemaCatchall extends z.ZodTypeAny = z.ZodTypeAny,
|
||||
|
||||
DejsonifySchemaT extends z.ZodRawShape = z.ZodRawShape,
|
||||
DejsonifySchemaUnknownKeys extends z.UnknownKeysParam = z.UnknownKeysParam,
|
||||
DejsonifySchemaCatchall extends z.ZodTypeAny = z.ZodTypeAny,
|
||||
> = {
|
||||
readonly $schemableConfig: $SchemableConfig
|
||||
|
||||
readonly jsonifiedValues: JsonifiedValues
|
||||
|
||||
readonly jsonifySchema: z.ZodObject<
|
||||
JsonifySchemaT,
|
||||
JsonifySchemaUnknownKeys,
|
||||
JsonifySchemaCatchall,
|
||||
JsonifiedValues,
|
||||
$SchemableConfig["values"]
|
||||
>
|
||||
|
||||
readonly dejsonifySchema: z.ZodObject<
|
||||
DejsonifySchemaT,
|
||||
DejsonifySchemaUnknownKeys,
|
||||
DejsonifySchemaCatchall,
|
||||
$SchemableConfig["values"],
|
||||
JsonifiedValues
|
||||
>
|
||||
}
|
||||
|
||||
|
||||
export type JsonifiableSchemableClass<
|
||||
$Config extends JsonifiableSchemableConfig
|
||||
> = (
|
||||
Class<
|
||||
JsonifiableSchemableObject<$Config>,
|
||||
SchemableClassConstructorParams<$Config["$schemableConfig"]>
|
||||
> & {
|
||||
readonly $jsonifiableSchemableConfig: $Config
|
||||
readonly jsonifySchema: $Config["jsonifySchema"]
|
||||
readonly dejsonifySchema: $Config["dejsonifySchema"]
|
||||
}
|
||||
)
|
||||
|
||||
export type JsonifiableSchemableObject<
|
||||
$Config extends JsonifiableSchemableConfig
|
||||
> = {
|
||||
readonly $jsonifiableSchemableConfig: $Config
|
||||
readonly jsonifySchema: $Config["jsonifySchema"]
|
||||
readonly dejsonifySchema: $Config["dejsonifySchema"]
|
||||
|
||||
jsonify(): $Config["jsonifiedValues"]
|
||||
jsonifyPromise(): Promise<$Config["jsonifiedValues"]>
|
||||
jsonifyEffect(): Effect.Effect<never, z.ZodError<$Config["$schemableConfig"]["values"]>, $Config["jsonifiedValues"]>
|
||||
}
|
||||
Reference in New Issue
Block a user