Share a bounded release scan across channels and compare tag versions across pages. Report uncertainty when the scan hits its limit without confirming a newer release. Verified with local release responses covering cross-page versions, truncation, and missing feeds.
72 lines
2.6 KiB
TypeScript
72 lines
2.6 KiB
TypeScript
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<typeof PatchSetSourceSchema>;
|
|
export type ActivePatchSet = z.output<typeof ActivePatchSetSchema>;
|
|
export type PackRelease = z.output<typeof PackReleaseSchema>;
|
|
export type PackCheckStatus = z.output<typeof PackCheckStatusSchema>;
|
|
export type PackProblem = z.output<typeof PackProblemSchema>;
|
|
export type PackCheck = z.output<typeof PackCheckSchema>;
|
|
export type PackApplyResult = z.output<typeof PackApplyResultSchema>;
|