Files
orca/mobile/src/session/github-pr-mutation-reply-schema.ts
T
Kelvin Amoaba bd88cdeca8 perf(mobile): trim the page bundle back under its old budget (#39182)
* perf(mobile): trim the page bundle back under its old budget

* build(mobile): simplify the route entry anchors and zod table guard

* fix(mobile): import zod as a type in the RPC result reader
2026-11-07 03:28:04 +00:00

29 lines
1.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import * as z from 'zod'
// No ok member means the host’s legacy unstructured success.
export type GitHubPrMutationStatus =
| { readonly structured: false }
| { readonly structured: true; readonly ok: unknown; readonly error: unknown }
// Require presence of ok, not its type: callers compare it to true and safely inspect string/object errors.
const mutationStatusEnvelopeSchema = z
.looseObject({ ok: z.unknown(), error: z.unknown().optional() })
.transform((reply): GitHubPrMutationStatus => ({
structured: true,
ok: reply.ok,
error: reply.error
}))
// Keep the envelope arm first; other payloads, including void, retain legacy unstructured-success semantics.
const mutationVoidSchema = z
.unknown()
.transform((): GitHubPrMutationStatus => ({ structured: false }))
export const githubPrMutationStatusSchemas = [
mutationStatusEnvelopeSchema,
mutationVoidSchema
] as const
// Require a boolean so protocol drift cannot look like an ordinary declined mutation.
export const githubPrMutationConfirmationSchema = z.boolean()