Zod EVERYWHERE (#2027)
* Zod EVERYWHERE * Add no-unused-vars rule to eslint in front * Add no-unused-vars rule to eslint in pusher * Add no-unused-vars rule to eslint in back * Remove unused PlayerTexture guards * Fix data providing on room connection Co-authored-by: Alexis Faizeau <a.faizeau@workadventu.re>
This commit is contained in:
@@ -1,20 +1,19 @@
|
||||
import * as tg from "generic-type-guard";
|
||||
import { z } from "zod";
|
||||
|
||||
export const isGameStateEvent = z.object({
|
||||
roomId: z.string(),
|
||||
mapUrl: z.string(),
|
||||
nickname: z.string(),
|
||||
language: z.optional(z.string()),
|
||||
uuid: z.optional(z.string()),
|
||||
startLayerName: z.optional(z.string()),
|
||||
tags: z.array(z.string()),
|
||||
variables: z.unknown(), // Todo : Typing
|
||||
playerVariables: z.unknown(), // Todo : Typing
|
||||
userRoomToken: z.optional(z.string()),
|
||||
});
|
||||
|
||||
export const isGameStateEvent = new tg.IsInterface()
|
||||
.withProperties({
|
||||
roomId: tg.isString,
|
||||
mapUrl: tg.isString,
|
||||
nickname: tg.isString,
|
||||
language: tg.isUnion(tg.isString, tg.isUndefined),
|
||||
uuid: tg.isUnion(tg.isString, tg.isUndefined),
|
||||
startLayerName: tg.isUnion(tg.isString, tg.isNull),
|
||||
tags: tg.isArray(tg.isString),
|
||||
variables: tg.isObject,
|
||||
playerVariables: tg.isObject,
|
||||
userRoomToken: tg.isUnion(tg.isString, tg.isUndefined),
|
||||
})
|
||||
.get();
|
||||
/**
|
||||
* A message sent from the game to the iFrame when the gameState is received by the script
|
||||
*/
|
||||
export type GameStateEvent = tg.GuardedType<typeof isGameStateEvent>;
|
||||
export type GameStateEvent = z.infer<typeof isGameStateEvent>;
|
||||
|
||||
Reference in New Issue
Block a user