chore: generate

This commit is contained in:
opencode-agent[bot]
2026-04-17 20:47:05 +00:00
parent e7686dbd64
commit dc16013b4f
2 changed files with 17 additions and 25 deletions
+12 -12
View File
@@ -25,18 +25,18 @@ export const Entry = Schema.Union([
* client knows which files the server should attach to. Builtin server IDs and * client knows which files the server should attach to. Builtin server IDs and
* explicitly disabled entries are exempt. * explicitly disabled entries are exempt.
*/ */
export const requiresExtensionsForCustomServers = Schema.makeFilter<boolean | Record<string, Schema.Schema.Type<typeof Entry>>>( export const requiresExtensionsForCustomServers = Schema.makeFilter<
(data) => { boolean | Record<string, Schema.Schema.Type<typeof Entry>>
if (typeof data === "boolean") return undefined >((data) => {
const serverIds = new Set(Object.values(LSPServer).map((server) => server.id)) if (typeof data === "boolean") return undefined
const ok = Object.entries(data).every(([id, config]) => { const serverIds = new Set(Object.values(LSPServer).map((server) => server.id))
if ("disabled" in config && config.disabled) return true const ok = Object.entries(data).every(([id, config]) => {
if (serverIds.has(id)) return true if ("disabled" in config && config.disabled) return true
return "extensions" in config && Boolean(config.extensions) if (serverIds.has(id)) return true
}) return "extensions" in config && Boolean(config.extensions)
return ok ? undefined : "For custom LSP servers, 'extensions' array is required." })
}, return ok ? undefined : "For custom LSP servers, 'extensions' array is required."
) })
export const Info = Schema.Union([Schema.Boolean, Schema.Record(Schema.String, Entry)]) export const Info = Schema.Union([Schema.Boolean, Schema.Record(Schema.String, Entry)])
.check(requiresExtensionsForCustomServers) .check(requiresExtensionsForCustomServers)
+5 -13
View File
@@ -189,9 +189,7 @@ describe("util.effect-zod", () => {
describe("Schema.check translation", () => { describe("Schema.check translation", () => {
test("filter returning string triggers refinement with that message", () => { test("filter returning string triggers refinement with that message", () => {
const isEven = Schema.makeFilter((n: number) => const isEven = Schema.makeFilter((n: number) => (n % 2 === 0 ? undefined : "expected an even number"))
n % 2 === 0 ? undefined : "expected an even number",
)
const schema = zod(Schema.Number.check(isEven)) const schema = zod(Schema.Number.check(isEven))
expect(schema.parse(4)).toBe(4) expect(schema.parse(4)).toBe(4)
@@ -218,10 +216,7 @@ describe("util.effect-zod", () => {
}) })
test("annotations.message on the filter is used when filter returns false", () => { test("annotations.message on the filter is used when filter returns false", () => {
const positive = Schema.makeFilter( const positive = Schema.makeFilter((n: number) => n > 0, { message: "must be positive" })
(n: number) => n > 0,
{ message: "must be positive" },
)
const schema = zod(Schema.Number.check(positive)) const schema = zod(Schema.Number.check(positive))
const result = schema.safeParse(-1) const result = schema.safeParse(-1)
@@ -230,13 +225,10 @@ describe("util.effect-zod", () => {
}) })
test("cross-field check on a record flags missing key", () => { test("cross-field check on a record flags missing key", () => {
const hasKey = Schema.makeFilter( const hasKey = Schema.makeFilter((data: Record<string, { enabled: boolean }>) =>
(data: Record<string, { enabled: boolean }>) => "required" in data ? undefined : "missing 'required' key",
"required" in data ? undefined : "missing 'required' key",
)
const schema = zod(
Schema.Record(Schema.String, Schema.Struct({ enabled: Schema.Boolean })).check(hasKey),
) )
const schema = zod(Schema.Record(Schema.String, Schema.Struct({ enabled: Schema.Boolean })).check(hasKey))
expect(schema.parse({ required: { enabled: true } })).toEqual({ expect(schema.parse({ required: { enabled: true } })).toEqual({
required: { enabled: true }, required: { enabled: true },