0.1.2 #3
@@ -7,6 +7,7 @@ import { DejsonifiableZodSchemaObject } from "../traits/DejsonifiableZodSchemaOb
|
|||||||
import { ExtendableZodSchemaObject } from "../traits/ExtendableZodSchemaObject"
|
import { ExtendableZodSchemaObject } from "../traits/ExtendableZodSchemaObject"
|
||||||
import { InstantiableZodSchemaObject } from "../traits/InstantiableZodSchemaObject"
|
import { InstantiableZodSchemaObject } from "../traits/InstantiableZodSchemaObject"
|
||||||
import { JsonifiableZodSchemaObject } from "../traits/JsonifiableZodSchemaObject"
|
import { JsonifiableZodSchemaObject } from "../traits/JsonifiableZodSchemaObject"
|
||||||
|
import { ZodSchemaObjectInstantiationSchemas } from "../traits/ZodSchemaObjectInstantiationSchemas"
|
||||||
import { StaticMembers } from "../util"
|
import { StaticMembers } from "../util"
|
||||||
|
|
||||||
|
|
||||||
@@ -63,7 +64,7 @@ extends TraitExpressionBuilder<Superclass, Traits> {
|
|||||||
|
|
||||||
[
|
[
|
||||||
...this.expressionTraits,
|
...this.expressionTraits,
|
||||||
// ZodSchemaObjectInstantiationSchemas,
|
ZodSchemaObjectInstantiationSchemas,
|
||||||
InstantiableZodSchemaObject,
|
InstantiableZodSchemaObject,
|
||||||
ExtendableZodSchemaObject,
|
ExtendableZodSchemaObject,
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ const test = User.schema.extend({
|
|||||||
)
|
)
|
||||||
|
|
||||||
const inst = User.create({ id: 1n, name: "" })
|
const inst = User.create({ id: 1n, name: "" })
|
||||||
|
const instEffect = User.createEffect({ id: 1n, name: "" })
|
||||||
|
|
||||||
// console.log(inst)
|
// console.log(inst)
|
||||||
const jsonifiedUser = await inst.jsonifyPromise()
|
const jsonifiedUser = await inst.jsonifyPromise()
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { TraitStaticMembers, expression } from "@thilawyn/traitify-ts"
|
import { TraitStaticMembers, trait } from "@thilawyn/traitify-ts"
|
||||||
import { HasRequiredKeys } from "type-fest"
|
import { HasRequiredKeys } from "type-fest"
|
||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
import { ZodSchemaClass } from "../shapes/ZodSchemaClass"
|
import { ZodSchemaClass } from "../shapes/ZodSchemaClass"
|
||||||
@@ -6,6 +6,8 @@ import { parseZodTypeEffect } from "../util"
|
|||||||
import { ZodSchemaObjectInstantiationSchemas } from "./ZodSchemaObjectInstantiationSchemas"
|
import { ZodSchemaObjectInstantiationSchemas } from "./ZodSchemaObjectInstantiationSchemas"
|
||||||
|
|
||||||
|
|
||||||
|
type ZodSchemaObjectInstantiationSchemasStaticMembers = TraitStaticMembers<typeof ZodSchemaObjectInstantiationSchemas>
|
||||||
|
|
||||||
type NewZodSchemaInstanceInput<
|
type NewZodSchemaInstanceInput<
|
||||||
Values extends object,
|
Values extends object,
|
||||||
DefaultValues extends Partial<Values>,
|
DefaultValues extends Partial<Values>,
|
||||||
@@ -26,10 +28,7 @@ type NewZodSchemaInstanceArgs<Input extends object> = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
export const InstantiableZodSchemaObject = expression
|
export const InstantiableZodSchemaObject = trait
|
||||||
.expresses(ZodSchemaObjectInstantiationSchemas)
|
|
||||||
.build()
|
|
||||||
.subtrait()
|
|
||||||
.implement(Super => class InstantiableZodSchemaObject extends Super {
|
.implement(Super => class InstantiableZodSchemaObject extends Super {
|
||||||
static create<
|
static create<
|
||||||
Instance extends Values,
|
Instance extends Values,
|
||||||
@@ -43,7 +42,7 @@ export const InstantiableZodSchemaObject = expression
|
|||||||
>(
|
>(
|
||||||
this: (
|
this: (
|
||||||
ZodSchemaClass<Instance, any, any, any, SchemaWithDefaultValuesT, SchemaWithDefaultValuesUnknownKeys, SchemaWithDefaultValuesCatchall, Values, PartialValues> &
|
ZodSchemaClass<Instance, any, any, any, SchemaWithDefaultValuesT, SchemaWithDefaultValuesUnknownKeys, SchemaWithDefaultValuesCatchall, Values, PartialValues> &
|
||||||
TraitStaticMembers<typeof ZodSchemaObjectInstantiationSchemas>
|
ZodSchemaObjectInstantiationSchemasStaticMembers
|
||||||
),
|
),
|
||||||
...[values, params]: NewZodSchemaInstanceArgs<PartialValues>
|
...[values, params]: NewZodSchemaInstanceArgs<PartialValues>
|
||||||
) {
|
) {
|
||||||
@@ -62,7 +61,7 @@ export const InstantiableZodSchemaObject = expression
|
|||||||
>(
|
>(
|
||||||
this: (
|
this: (
|
||||||
ZodSchemaClass<Instance, any, any, any, SchemaWithDefaultValuesT, SchemaWithDefaultValuesUnknownKeys, SchemaWithDefaultValuesCatchall, Values, PartialValues> &
|
ZodSchemaClass<Instance, any, any, any, SchemaWithDefaultValuesT, SchemaWithDefaultValuesUnknownKeys, SchemaWithDefaultValuesCatchall, Values, PartialValues> &
|
||||||
TraitStaticMembers<typeof ZodSchemaObjectInstantiationSchemas>
|
ZodSchemaObjectInstantiationSchemasStaticMembers
|
||||||
),
|
),
|
||||||
...[values, params]: NewZodSchemaInstanceArgs<PartialValues>
|
...[values, params]: NewZodSchemaInstanceArgs<PartialValues>
|
||||||
) {
|
) {
|
||||||
@@ -81,7 +80,7 @@ export const InstantiableZodSchemaObject = expression
|
|||||||
>(
|
>(
|
||||||
this: (
|
this: (
|
||||||
ZodSchemaClass<Instance, any, any, any, SchemaWithDefaultValuesT, SchemaWithDefaultValuesUnknownKeys, SchemaWithDefaultValuesCatchall, Values, PartialValues> &
|
ZodSchemaClass<Instance, any, any, any, SchemaWithDefaultValuesT, SchemaWithDefaultValuesUnknownKeys, SchemaWithDefaultValuesCatchall, Values, PartialValues> &
|
||||||
TraitStaticMembers<typeof ZodSchemaObjectInstantiationSchemas>
|
ZodSchemaObjectInstantiationSchemasStaticMembers
|
||||||
),
|
),
|
||||||
...[values, params]: NewZodSchemaInstanceArgs<PartialValues>
|
...[values, params]: NewZodSchemaInstanceArgs<PartialValues>
|
||||||
) {
|
) {
|
||||||
|
|||||||
Reference in New Issue
Block a user