alle00
alle00
Aarktype
Created by alle00 on 4/23/2025 in #questions
question about arktype => TS
I'm building OSS tooling for event-driven architecture and I have a question about ArkType, I'm currently using zod but I find it a bit cumbersome as I have to add 2 external packages to achieve what I'm doing. For some context I'm building over the wire typesafety and typegen, how I achieve this is I take in a schema, I turn that schema into a string representation of the type, then I send that over an event bus to all the other apps which listen to that event and then there I write it to the filesystem if it's local development. The current approach is this:
// you have the class initialized:
ourClass.register("user.create", z.object({ id: z.string(), name: z.string() }))
// internally i convert this to a string:
const eventType = `${ZodToTypescript.convert(schema, { name: convertSubjectNameToEventType(subject) })}`
// then I send it to all other apps via the event bus, then all the other apps get this eventType and write it to the filesystem.
// you have the class initialized:
ourClass.register("user.create", z.object({ id: z.string(), name: z.string() }))
// internally i convert this to a string:
const eventType = `${ZodToTypescript.convert(schema, { name: convertSubjectNameToEventType(subject) })}`
// then I send it to all other apps via the event bus, then all the other apps get this eventType and write it to the filesystem.
I would like to make it more "typescript-y and json-y" where you don't have to install zod into every app that consumes this class and pass in the schema, but rather for it to feel very intuitive and easy to write and I can then move this into the class itself. I think ArkType is the closest and most intuitive solution for this so I'd like to see how you guys would go about achieving this?
51 replies