Drop unused opencode Zod statics (#26935)
This commit is contained in:
@@ -2,12 +2,10 @@ export * as ConfigParse from "./parse"
|
||||
|
||||
import { type ParseError as JsoncParseError, parse as parseJsoncImpl, printParseErrorCode } from "jsonc-parser"
|
||||
import { Cause, Exit, Schema as EffectSchema, SchemaIssue } from "effect"
|
||||
import z from "zod"
|
||||
import type z from "zod"
|
||||
import type { DeepMutable } from "@opencode-ai/core/schema"
|
||||
import { InvalidError, JsonError } from "./error"
|
||||
|
||||
type ZodSchema<T> = z.ZodType<T>
|
||||
|
||||
export function jsonc(text: string, filepath: string): unknown {
|
||||
const errors: JsoncParseError[] = []
|
||||
const data = parseJsoncImpl(text, errors, { allowTrailingComma: true })
|
||||
@@ -35,17 +33,7 @@ export function jsonc(text: string, filepath: string): unknown {
|
||||
return data
|
||||
}
|
||||
|
||||
export function schema<T>(schema: ZodSchema<T>, data: unknown, source: string): T {
|
||||
const parsed = schema.safeParse(data)
|
||||
if (parsed.success) return parsed.data
|
||||
|
||||
throw new InvalidError({
|
||||
path: source,
|
||||
issues: parsed.error.issues,
|
||||
})
|
||||
}
|
||||
|
||||
export function effectSchema<S extends EffectSchema.Decoder<unknown, never>>(
|
||||
export function schema<S extends EffectSchema.Decoder<unknown, never>>(
|
||||
schema: S,
|
||||
data: unknown,
|
||||
source: string,
|
||||
|
||||
Reference in New Issue
Block a user