This commit is contained in:
@@ -29,7 +29,7 @@ extends TraitExpressionBuilder<Superclass, Traits> {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
schema<
|
schema<
|
||||||
Superclass extends AbstractClass<object> & { schema?: never, defaultValues?: never },
|
Superclass extends AbstractClass<object, []> & { schema?: never, defaultValues?: never },
|
||||||
|
|
||||||
SchemaT extends z.ZodRawShape,
|
SchemaT extends z.ZodRawShape,
|
||||||
SchemaUnknownKeys extends z.UnknownKeysParam,
|
SchemaUnknownKeys extends z.UnknownKeysParam,
|
||||||
@@ -58,11 +58,7 @@ extends TraitExpressionBuilder<Superclass, Traits> {
|
|||||||
return new ZodSchemaClassBuilder(
|
return new ZodSchemaClassBuilder(
|
||||||
Schemas as unknown as (
|
Schemas as unknown as (
|
||||||
AbstractClass<
|
AbstractClass<
|
||||||
InstanceType<Superclass> &
|
InstanceType<Superclass> & Values,
|
||||||
Simplify<
|
|
||||||
Extend<[Schemas, Values]>
|
|
||||||
>,
|
|
||||||
|
|
||||||
ConstructorParameters<typeof Schemas>
|
ConstructorParameters<typeof Schemas>
|
||||||
> &
|
> &
|
||||||
Simplify<
|
Simplify<
|
||||||
@@ -109,40 +105,14 @@ extends TraitExpressionBuilder<Superclass, Traits> {
|
|||||||
|
|
||||||
props: {
|
props: {
|
||||||
jsonifySchema: (props: {
|
jsonifySchema: (props: {
|
||||||
schema: z.ZodObject<
|
schema: z.ZodObject<SchemaT, SchemaUnknownKeys, SchemaCatchall, Values, Values>
|
||||||
SchemaT,
|
shape: SchemaT
|
||||||
SchemaUnknownKeys,
|
}) => z.ZodObject<JsonifySchemaT, JsonifySchemaUnknownKeys, JsonifySchemaCatchall, JsonifiedValues, Values>
|
||||||
SchemaCatchall,
|
|
||||||
Values,
|
|
||||||
Values
|
|
||||||
>
|
|
||||||
|
|
||||||
shape: SchemaT
|
|
||||||
}) => z.ZodObject<
|
|
||||||
JsonifySchemaT,
|
|
||||||
JsonifySchemaUnknownKeys,
|
|
||||||
JsonifySchemaCatchall,
|
|
||||||
JsonifiedValues,
|
|
||||||
Values
|
|
||||||
>
|
|
||||||
|
|
||||||
dejsonifySchema: (props: {
|
dejsonifySchema: (props: {
|
||||||
schema: z.ZodObject<
|
schema: z.ZodObject<SchemaT, SchemaUnknownKeys, SchemaCatchall, Values, Values>
|
||||||
SchemaT,
|
shape: SchemaT
|
||||||
SchemaUnknownKeys,
|
}) => z.ZodObject<DejsonifySchemaT, DejsonifySchemaUnknownKeys, DejsonifySchemaCatchall, Values, JsonifiedValues>
|
||||||
SchemaCatchall,
|
|
||||||
Values,
|
|
||||||
Values
|
|
||||||
>
|
|
||||||
|
|
||||||
shape: SchemaT
|
|
||||||
}) => z.ZodObject<
|
|
||||||
DejsonifySchemaT,
|
|
||||||
DejsonifySchemaUnknownKeys,
|
|
||||||
DejsonifySchemaCatchall,
|
|
||||||
Values,
|
|
||||||
JsonifiedValues
|
|
||||||
>
|
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
const jsonifySchema = props.jsonifySchema({
|
const jsonifySchema = props.jsonifySchema({
|
||||||
@@ -154,25 +124,21 @@ extends TraitExpressionBuilder<Superclass, Traits> {
|
|||||||
shape: this.expressionSuperclass.schema.shape,
|
shape: this.expressionSuperclass.schema.shape,
|
||||||
})
|
})
|
||||||
|
|
||||||
class Schemas extends this.expressionSuperclass {
|
class JsonifiableSchemas extends (this.expressionSuperclass as AbstractClass<object>) {
|
||||||
static readonly jsonifySchema = jsonifySchema
|
static readonly jsonifySchema = jsonifySchema
|
||||||
static readonly dejsonifySchema = dejsonifySchema
|
static readonly dejsonifySchema = dejsonifySchema
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ZodSchemaClassBuilder(
|
return new ZodSchemaClassBuilder(
|
||||||
Schemas as unknown as (
|
JsonifiableSchemas as unknown as (
|
||||||
AbstractClass<
|
AbstractClass<
|
||||||
InstanceType<Superclass> &
|
InstanceType<Superclass>,
|
||||||
Simplify<
|
ConstructorParameters<Superclass>
|
||||||
Extend<[Schemas, Values]>
|
|
||||||
>,
|
|
||||||
|
|
||||||
ConstructorParameters<typeof Schemas>
|
|
||||||
> &
|
> &
|
||||||
Simplify<
|
Simplify<
|
||||||
Extend<[
|
Extend<[
|
||||||
StaticMembers<Superclass>,
|
StaticMembers<Superclass>,
|
||||||
StaticMembers<typeof Schemas>,
|
StaticMembers<typeof JsonifiableSchemas>,
|
||||||
]>
|
]>
|
||||||
>
|
>
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user