-
Put the above prisma-effect-generator.ts in your root of your project.
-
Install "@prisma/generator-helper" and "@prisma/internals" as dev dependecies.
-
Add this to your schema.prisma file
generator sqlSchema {| /** | |
| * Perform left-to-right function composition. | |
| * @param value The initial value. | |
| * @param operations the list of operations to apply. | |
| * @signature R.pipe(data, op1, op2, op3) | |
| * @example | |
| * superpipe( | |
| * [1, 2, 3, 4], | |
| * R.map(x => x * 2), | |
| * arr => [arr[0] + arr[1], arr[2] + arr[3]], |
| type SyncPromiseState<T, E = unknown> = | |
| | { status: 'ok'; value: T } | |
| | { status: 'error'; error: E }; | |
| class SyncPromise<T, E = unknown> { | |
| private state: SyncPromiseState<T, E>; | |
| private constructor(state: SyncPromiseState<T, E>) { | |
| this.state = state; | |
| } |
| import { z } from "zod"; | |
| // Zod schemas with branding | |
| export const DollarsSchema = z.number().nonnegative().brand("dollars"); | |
| export const CentsSchema = z.number().int().nonnegative().brand("cents"); | |
| export type Dollars = z.infer<typeof DollarsSchema>; | |
| export type Cents = z.infer<typeof CentsSchema>; | |
| type DollarVal = Dollars | null | undefined; |