feat(id): brand SessionID through Drizzle and Zod schemas (#16953)

This commit is contained in:
Kit Langton
2026-03-11 19:16:56 -04:00
committed by GitHub
parent 4e73473119
commit cb67465675
44 changed files with 226 additions and 158 deletions

View File

@@ -0,0 +1,17 @@
import { Schema } from "effect"
import z from "zod"
import { withStatics } from "@/util/schema"
import { Identifier } from "@/id/id"
const sessionIdSchema = Schema.String.pipe(Schema.brand("SessionId"))
export type SessionID = typeof sessionIdSchema.Type
export const SessionID = sessionIdSchema.pipe(
withStatics((schema: typeof sessionIdSchema) => ({
make: (id: string) => schema.makeUnsafe(id),
descending: (id?: string) => schema.makeUnsafe(Identifier.descending("session", id)),
zod: z.string().startsWith("ses").pipe(z.custom<SessionID>()),
})),
)