-
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 {
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; |
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; | |
} |
/** | |
* 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]], |
export const getAuthHeaders = ( | |
// Whatever inputs you need | |
) => { | |
return { | |
// whatever object you need | |
["ContentType"]: "application/json" | |
} | |
} |
import { match } from 'ts-pattern'; | |
// Define a discriminated union for sub-task states | |
type SubTaskState = | |
| { type: 'loading'; subTaskId: number } | |
| { type: 'completed'; subTaskId: number; result: string } | |
| { type: 'error'; subTaskId: number; error: string }; | |
// Define a tuple union for task states | |
type TaskState = |
// Define individual animal types | |
type Dog = { | |
type: "dog"; | |
name: string; | |
sound: "bark"; | |
}; | |
type Cat = { | |
type: "cat"; | |
name: string; |
import { uniqueBy } from "remeda"; | |
import { SuperMap } from "./SuperMap.ts"; | |
export class Graph<T> { | |
adjacencyList: SuperMap<T, T[]>; | |
private serialize: (input: T) => string; | |
private deserialize: (input: string) => T; | |
private printVal: (input: T) => any; | |
constructor( |
import { piped } from "remeda"; | |
import z from "zod"; | |
const getBlocks = piped( | |
(a: string) => a.split(""), | |
(a) => | |
a.map((char, index) => { | |
const isEven = index % 2 === 0; | |
const charValue = z.number().parse(+char); |
import { buildMatrix } from "./build-matrix"; | |
describe("Build Matrix", () => { | |
it("Should turn my shit into matrix of rows", () => { | |
expect( | |
buildMatrix({ | |
// prettier-ignore | |
elements: [ | |
1/1, | |
1/3, 2/3, |