import { z } from 'zod'; /** * What the launcher reports about adaptation packs (main/services/patch-pack/): which patch set * the builds use, and whether a newer pack is released. */ /** The patch set that ships with the launcher, or a downloaded adaptation pack. */ export const PatchSetSourceSchema = z.enum(['bundled', 'downloaded']); export const ActivePatchSetSchema = z.object({ source: PatchSetSourceSchema, /** Pack version; null for a bundled set without one (a repository checkout). */ version: z.string().nullable(), /** Game versions with a version record in the set. */ gameVersions: z.array(z.string()), }); export const PackReleaseSchema = z.object({ version: z.string(), gameVersions: z.array(z.string()), minAppVersion: z.string(), publishedAt: z.string().nullable(), }); export const PackCheckStatusSchema = z.enum([ /** No release is newer than the active set. */ 'up_to_date', /** A newer pack this launcher can use. */ 'available', /** A newer pack needs a newer offline version (launcher) first. */ 'needs_app_update', /** The check could not be made; see `problem`. */ 'failed', ]); export const PackProblemSchema = z.enum([ /** This build of the launcher carries no signing key, so it accepts no pack. */ 'no_signing_key', /** GitHub could not be reached or answered with an error. */ 'network', /** The scan reached the page limit before confirming a newer pack release. */ 'page_limit', /** The release or the pack is malformed. */ 'contents', /** The signature does not match. */ 'signature', /** The pack is larger than allowed. */ 'size', ]); export const PackCheckSchema = z.object({ status: PackCheckStatusSchema, active: ActivePatchSetSchema, /** The newest released pack; null when none is released or the check failed. */ latest: PackReleaseSchema.nullable(), problem: PackProblemSchema.nullable(), }); export const PackApplyResultSchema = z.discriminatedUnion('ok', [ z.object({ ok: z.literal(true), active: ActivePatchSetSchema }), z.object({ ok: z.literal(false), problem: z.union([PackProblemSchema, z.enum(['needs_app_update', 'up_to_date'])]) }), ]); export type PatchSetSource = z.output; export type ActivePatchSet = z.output; export type PackRelease = z.output; export type PackCheckStatus = z.output; export type PackProblem = z.output; export type PackCheck = z.output; export type PackApplyResult = z.output;