0.1.1 #2

Merged
Thilawyn merged 47 commits from next into master 2024-01-17 20:47:13 +01:00
Showing only changes of commit af84a7ef2a - Show all commits

View File

@@ -1,7 +1,6 @@
import { extendsAndExpresses } from "@thilawyn/thilatrait"
import { z } from "zod" import { z } from "zod"
import { makeSchemableClass, newSchemable } from "." import { makeSchemableClass, newSchemable } from "."
import { JsonifiableSchemable } from "./jsonifiable" import { makeJsonifiableSchemableClass } from "./jsonifiable"
import { dejsonifyBigIntSchema, jsonifyBigIntSchema } from "./legacy/jsonifiable" import { dejsonifyBigIntSchema, jsonifyBigIntSchema } from "./legacy/jsonifiable"
@@ -19,12 +18,21 @@ const UserProto = makeSchemableClass(z.object({
UserProto.defaultValues UserProto.defaultValues
class User extends extendsAndExpresses(UserProto, const JsonifiableUserProto = makeJsonifiableSchemableClass({
JsonifiableSchemable( extend: UserProto,
UserProto.schema.extend({ id: jsonifyBigIntSchema(z.bigint()) }),
UserProto.schema.extend({ id: dejsonifyBigIntSchema(z.bigint()) }), jsonifySchema: ({ schema, shape }) => schema.extend({
) id: jsonifyBigIntSchema(shape.id)
) {} }),
dejsonifySchema: ({ schema, shape }) => schema.extend({
id: dejsonifyBigIntSchema(shape.id)
}),
})
class User extends JsonifiableUserProto {}
const user1 = newSchemable(User, { id: 1n, name: "User" }) const user1 = newSchemable(User, { id: 1n, name: "User" })
user1.jsonify()