mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-05 00:23:10 +00:00
feat(id): brand SessionID through Drizzle and Zod schemas (#16953)
This commit is contained in:
17
packages/opencode/src/session/schema.ts
Normal file
17
packages/opencode/src/session/schema.ts
Normal 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>()),
|
||||
})),
|
||||
)
|
||||
Reference in New Issue
Block a user