refactor(core): derive provider schema .zod via effect-zod walker (#23753)
This commit is contained in:
@@ -162,7 +162,7 @@ schema module with a clear domain.
|
|||||||
- [ ] `src/control-plane/schema.ts`
|
- [ ] `src/control-plane/schema.ts`
|
||||||
- [ ] `src/permission/schema.ts`
|
- [ ] `src/permission/schema.ts`
|
||||||
- [ ] `src/project/schema.ts`
|
- [ ] `src/project/schema.ts`
|
||||||
- [ ] `src/provider/schema.ts`
|
- [x] `src/provider/schema.ts`
|
||||||
- [ ] `src/pty/schema.ts`
|
- [ ] `src/pty/schema.ts`
|
||||||
- [ ] `src/question/schema.ts`
|
- [ ] `src/question/schema.ts`
|
||||||
- [ ] `src/session/schema.ts`
|
- [ ] `src/session/schema.ts`
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Schema } from "effect"
|
import { Schema } from "effect"
|
||||||
import z from "zod"
|
|
||||||
|
|
||||||
|
import { zod } from "@/util/effect-zod"
|
||||||
import { withStatics } from "@/util/schema"
|
import { withStatics } from "@/util/schema"
|
||||||
|
|
||||||
const providerIdSchema = Schema.String.pipe(Schema.brand("ProviderID"))
|
const providerIdSchema = Schema.String.pipe(Schema.brand("ProviderID"))
|
||||||
@@ -9,7 +9,7 @@ export type ProviderID = typeof providerIdSchema.Type
|
|||||||
|
|
||||||
export const ProviderID = providerIdSchema.pipe(
|
export const ProviderID = providerIdSchema.pipe(
|
||||||
withStatics((schema: typeof providerIdSchema) => ({
|
withStatics((schema: typeof providerIdSchema) => ({
|
||||||
zod: z.string().pipe(z.custom<ProviderID>()),
|
zod: zod(schema),
|
||||||
// Well-known providers
|
// Well-known providers
|
||||||
opencode: schema.make("opencode"),
|
opencode: schema.make("opencode"),
|
||||||
anthropic: schema.make("anthropic"),
|
anthropic: schema.make("anthropic"),
|
||||||
@@ -30,7 +30,7 @@ const modelIdSchema = Schema.String.pipe(Schema.brand("ModelID"))
|
|||||||
export type ModelID = typeof modelIdSchema.Type
|
export type ModelID = typeof modelIdSchema.Type
|
||||||
|
|
||||||
export const ModelID = modelIdSchema.pipe(
|
export const ModelID = modelIdSchema.pipe(
|
||||||
withStatics((_schema: typeof modelIdSchema) => ({
|
withStatics((schema: typeof modelIdSchema) => ({
|
||||||
zod: z.string().pipe(z.custom<ModelID>()),
|
zod: zod(schema),
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user