Skip to content

fusky-labs/mylo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mylo DSL

A cross-languge schema/type generator and transformer, akin to Prisma but general purpose for generating types or schema from JSON and Zod, and from static-typed languages from TypeScript, Python, Go, Rust, etc.

Example

The gist is you take this:

union Role : string {
  Officer
  Chief
  Mafia
}

schema ZPDCitizen {
  name: string
  nickname: string?
  role: Role | nil
}

Then you instantly generate to Zod or whatever language you prefer to target:

From MyloZod

const zpdCitizen = z.object({
  name: z.string(),
  nickname: z.string().optional(),
  role: z.union([Role, z.null()])
})

From MyloTypeScript

type Role = "Officer" | "Chief" | "Mafia"

interface ZPDCitizen {
  name: string
  nickname?: string
  role: Role | null
}

From MyloTyped Python

from typing import TypedDict, Optional, NotRequired

Role = Literal["Officer", "Chief", "Mafia"]

class ZPDCitizen(TypedDict):
  name: str
  nickname: NotRequired[str]
  role: Optional[Role]

Ideal for generating shared types but is in a different language. Note that it only generates the infered types and not the actual code itself.

Contributing

TBA

About

Cross-language schema type generator

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Contributors

Languages