diff options
| author | Kit Langton <[email protected]> | 2026-03-14 12:14:46 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-03-14 16:14:46 +0000 |
| commit | 66e8c57ed1077814c9a150b858a53fdd7c758c0f (patch) | |
| tree | ecc30125b17957bad50c779b85fb3e53714b84c1 | |
| parent | b698f14e5550c18ab6de1a8171ffcf3200d9653b (diff) | |
| download | opencode-66e8c57ed1077814c9a150b858a53fdd7c758c0f.tar.gz opencode-66e8c57ed1077814c9a150b858a53fdd7c758c0f.zip | |
refactor(schema): inline branded ID schemas (#17504)
| -rw-r--r-- | packages/opencode/src/session/schema.ts | 49 |
1 files changed, 23 insertions, 26 deletions
diff --git a/packages/opencode/src/session/schema.ts b/packages/opencode/src/session/schema.ts index b37fefae6..540643c49 100644 --- a/packages/opencode/src/session/schema.ts +++ b/packages/opencode/src/session/schema.ts @@ -1,41 +1,38 @@ import { Schema } from "effect" import z from "zod" -import { withStatics } from "@/util/schema" import { Identifier } from "@/id/id" +import { withStatics } from "@/util/schema" -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: Identifier.schema("session").pipe(z.custom<SessionID>()), +export const SessionID = Schema.String.pipe( + Schema.brand("SessionID"), + withStatics((s) => ({ + make: (id: string) => s.makeUnsafe(id), + descending: (id?: string) => s.makeUnsafe(Identifier.descending("session", id)), + zod: Identifier.schema("session").pipe(z.custom<Schema.Schema.Type<typeof s>>()), })), ) -const messageIdSchema = Schema.String.pipe(Schema.brand("MessageID")) +export type SessionID = Schema.Schema.Type<typeof SessionID> -export type MessageID = typeof messageIdSchema.Type - -export const MessageID = messageIdSchema.pipe( - withStatics((schema: typeof messageIdSchema) => ({ - make: (id: string) => schema.makeUnsafe(id), - ascending: (id?: string) => schema.makeUnsafe(Identifier.ascending("message", id)), - zod: Identifier.schema("message").pipe(z.custom<MessageID>()), +export const MessageID = Schema.String.pipe( + Schema.brand("MessageID"), + withStatics((s) => ({ + make: (id: string) => s.makeUnsafe(id), + ascending: (id?: string) => s.makeUnsafe(Identifier.ascending("message", id)), + zod: Identifier.schema("message").pipe(z.custom<Schema.Schema.Type<typeof s>>()), })), ) -const partIdSchema = Schema.String.pipe(Schema.brand("PartID")) - -export type PartID = typeof partIdSchema.Type +export type MessageID = Schema.Schema.Type<typeof MessageID> -export const PartID = partIdSchema.pipe( - withStatics((schema: typeof partIdSchema) => ({ - make: (id: string) => schema.makeUnsafe(id), - ascending: (id?: string) => schema.makeUnsafe(Identifier.ascending("part", id)), - zod: Identifier.schema("part").pipe(z.custom<PartID>()), +export const PartID = Schema.String.pipe( + Schema.brand("PartID"), + withStatics((s) => ({ + make: (id: string) => s.makeUnsafe(id), + ascending: (id?: string) => s.makeUnsafe(Identifier.ascending("part", id)), + zod: Identifier.schema("part").pipe(z.custom<Schema.Schema.Type<typeof s>>()), })), ) + +export type PartID = Schema.Schema.Type<typeof PartID> |
