mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-08-18 09:14:09 +00:00
upgrade to zod 4 (#1161)
## Description: updates zod to v4 closes #873 ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors ## Please put your Discord username so you can be contacted if a bug or regression is found: omrih --------- Co-authored-by: Scott Anderson <662325+scottanderson@users.noreply.github.com>
This commit is contained in:
+15
-15
@@ -1,4 +1,4 @@
|
||||
import { z } from "zod";
|
||||
import { z } from "zod/v4";
|
||||
import quickChatData from "../../resources/QuickChat.json" with { type: "json" };
|
||||
import {
|
||||
AllPlayers,
|
||||
@@ -76,14 +76,14 @@ export type ClientMessage =
|
||||
| ClientLogMessage
|
||||
| ClientHashMessage;
|
||||
export type ServerMessage =
|
||||
| ServerSyncMessage
|
||||
| ServerTurnMessage
|
||||
| ServerStartGameMessage
|
||||
| ServerPingMessage
|
||||
| ServerDesyncMessage
|
||||
| ServerPrestartMessage
|
||||
| ServerErrorMessage;
|
||||
|
||||
export type ServerSyncMessage = z.infer<typeof ServerTurnMessageSchema>;
|
||||
export type ServerTurnMessage = z.infer<typeof ServerTurnMessageSchema>;
|
||||
export type ServerStartGameMessage = z.infer<
|
||||
typeof ServerStartGameMessageSchema
|
||||
>;
|
||||
@@ -101,7 +101,7 @@ export type ClientHashMessage = z.infer<typeof ClientHashSchema>;
|
||||
export type AllPlayersStats = z.infer<typeof AllPlayersStatsSchema>;
|
||||
export type Player = z.infer<typeof PlayerSchema>;
|
||||
export type GameStartInfo = z.infer<typeof GameStartInfoSchema>;
|
||||
const PlayerTypeSchema = z.nativeEnum(PlayerType);
|
||||
const PlayerTypeSchema = z.enum(PlayerType);
|
||||
|
||||
export interface GameInfo {
|
||||
gameID: GameID;
|
||||
@@ -127,18 +127,18 @@ export enum LogSeverity {
|
||||
//
|
||||
|
||||
export const GameConfigSchema = z.object({
|
||||
gameMap: z.nativeEnum(GameMapType),
|
||||
difficulty: z.nativeEnum(Difficulty),
|
||||
gameType: z.nativeEnum(GameType),
|
||||
gameMode: z.nativeEnum(GameMode),
|
||||
gameMap: z.enum(GameMapType),
|
||||
difficulty: z.enum(Difficulty),
|
||||
gameType: z.enum(GameType),
|
||||
gameMode: z.enum(GameMode),
|
||||
disableNPCs: z.boolean(),
|
||||
bots: z.number().int().min(0).max(400),
|
||||
infiniteGold: z.boolean(),
|
||||
infiniteTroops: z.boolean(),
|
||||
instantBuild: z.boolean(),
|
||||
maxPlayers: z.number().optional(),
|
||||
disabledUnits: z.nativeEnum(UnitType).array().optional(),
|
||||
playerTeams: z.union([z.number().optional(), z.literal(Duos)]),
|
||||
disabledUnits: z.enum(UnitType).array().optional(),
|
||||
playerTeams: z.union([z.number(), z.literal(Duos)]).optional(),
|
||||
});
|
||||
|
||||
export const TeamSchema = z.string();
|
||||
@@ -150,8 +150,8 @@ const SafeString = z
|
||||
)
|
||||
.max(1000);
|
||||
|
||||
export const PersistentIdSchema = z.string().uuid();
|
||||
const JwtTokenSchema = z.string().jwt();
|
||||
export const PersistentIdSchema = z.uuid();
|
||||
const JwtTokenSchema = z.jwt();
|
||||
const TokenSchema = z
|
||||
.string()
|
||||
.refine(
|
||||
@@ -268,14 +268,14 @@ export const TargetTroopRatioIntentSchema = BaseIntentSchema.extend({
|
||||
|
||||
export const BuildUnitIntentSchema = BaseIntentSchema.extend({
|
||||
type: z.literal("build_unit"),
|
||||
unit: z.nativeEnum(UnitType),
|
||||
unit: z.enum(UnitType),
|
||||
x: z.number(),
|
||||
y: z.number(),
|
||||
});
|
||||
|
||||
export const UpgradeStructureIntentSchema = BaseIntentSchema.extend({
|
||||
type: z.literal("upgrade_structure"),
|
||||
unit: z.nativeEnum(UnitType),
|
||||
unit: z.enum(UnitType),
|
||||
unitId: z.number(),
|
||||
});
|
||||
|
||||
@@ -426,7 +426,7 @@ export const ClientHashSchema = z.object({
|
||||
|
||||
export const ClientLogMessageSchema = z.object({
|
||||
type: z.literal("log"),
|
||||
severity: z.nativeEnum(LogSeverity),
|
||||
severity: z.enum(LogSeverity),
|
||||
log: ID,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user