API data types rework

This commit is contained in:
aronmal 2023-04-25 22:27:03 +02:00
parent 207cf47c10
commit 4af85bb572
Signed by: aronmal
GPG key ID: 816B7707426FC612
16 changed files with 342 additions and 245 deletions

View file

@ -7,18 +7,20 @@ function LobbyFrame({ openSettings }: { openSettings: () => void }) {
const { gameProps } = useGameState()
const [dots, setDots] = useState(1)
const { gamePin, player1, player2 } = gameProps.payload
useEffect(() => {
if (gameProps.enemy) return
if (player2) return
const interval = setInterval(() => setDots((e) => (e % 3) + 1), 1000)
return () => clearInterval(interval)
}, [gameProps.enemy])
}, [player2])
return (
<div className="mx-32 flex flex-col self-stretch rounded-3xl bg-gray-400">
<div className="flex items-center justify-between border-b-2 border-slate-900">
<Icon src="speech_bubble.png">Chat</Icon>
<h1 className="font-farro text-5xl font-medium">
Game-PIN: <span className="underline">{gameProps.pin}</span>
Game-PIN: <span className="underline">{gamePin?.pin}</span>
</h1>
<Icon src="gear.png" onClick={openSettings}>
Settings
@ -27,16 +29,13 @@ function LobbyFrame({ openSettings }: { openSettings: () => void }) {
<div className="flex items-center justify-around">
<Player
src="player_blue.png"
text={gameProps.player?.name ?? "Spieler 1 (Du)"}
text={player1?.name ?? "Spieler 1 (Du)"}
primary={true}
edit={true}
/>
<p className="font-farro m-4 text-6xl font-semibold">VS</p>
{gameProps.enemy ? (
<Player
src="player_red.png"
text={gameProps.enemy.name ?? "Spieler 2"}
/>
{player2 ? (
<Player src="player_red.png" text={player2.name ?? "Spieler 2"} />
) : (
<p className="font-farro w-96 text-center text-4xl font-medium">
Warte auf Spieler 2 {Array.from(Array(dots), () => ".").join("")}

View file

@ -1,23 +1,24 @@
import sendError from "./sendError"
import { NextApiRequest, NextApiResponse } from "next"
import { z } from "zod"
const pinBodySchema = z.object({
pin: z.string(),
})
async function getPinFromBody<T>(req: NextApiRequest, res: NextApiResponse<T>) {
const body = JSON.parse(req.body)
if (
typeof body !== "object" ||
!body ||
!("pin" in body) ||
typeof body.pin !== "string"
)
throw sendError(req, res, {
try {
const body = JSON.parse(req.body)
const { pin } = pinBodySchema.parse(body)
return pin
} catch (err: any) {
sendError(req, res, {
message: "No pin in request body!",
statusCode: 401,
solved: true,
type: ["warn"],
})
const { pin } = body
return pin
}
}
export default getPinFromBody

View file

@ -10,7 +10,6 @@ import {
Target,
Position,
} from "../../interfaces/frontend"
import { gameContext } from "../../pages/_app"
import {
hitReducer,
initlialLastLeftTile,
@ -18,7 +17,7 @@ import {
initlialTargetPreview,
initlialMouseCursor,
} from "../utils/helpers"
import { useCallback, useContext, useEffect, useReducer, useState } from "react"
import { useCallback, useEffect, useReducer, useState } from "react"
const modes: Mode[] = [
{
@ -40,7 +39,6 @@ const modes: Mode[] = [
]
function useGameEvent(count: number) {
const [gameProps, setGameProps] = useContext(gameContext)
const [lastLeftTile, setLastLeftTile] =
useState<Position>(initlialLastLeftTile)
const [target, setTarget] = useState<Target>(initlialTarget)

View file

@ -1,10 +1,12 @@
import { gameContext } from "../../pages/_app"
import { GamePropsSchema } from "@lib/zodSchemas"
import { useSession } from "next-auth/react"
import { useContext, useEffect } from "react"
import { useEffect, useState } from "react"
import { toast } from "react-toastify"
function useGameState() {
const [gameProps, setGameProps] = useContext(gameContext)
function useGameState(initial?: GamePropsSchema) {
const [gameProps, setGameProps] = useState<GamePropsSchema>(
initial ?? { payload: {}, hash: "" }
)
const { data: session, status } = useSession()
useEffect(() => {
@ -22,10 +24,11 @@ function useGameState() {
<img
style={{ transform: "scale(1.5)", borderRadius: "100%" }}
src={session.user.image}
alt="profile picture"
/>
) : undefined,
})
}, [session])
}, [session, status])
return {
gameProps,

View file

@ -1,19 +1,29 @@
import { GameSchema } from "../prisma/generated/zod"
import {
GameSchema,
GamepinSchema,
User_GameSchema,
} from "../prisma/generated/zod"
import { z } from "zod"
export const CreateSchema = z.object({
game: GameSchema.strict(),
pin: z.string().optional(),
player: z.object({
id: z.string(),
name: z.string().optional(),
isOwner: z.boolean().optional(),
}),
enemy: z
.object({
id: z.string(),
username: z.string().optional(),
isOwner: z.boolean().optional(),
})
.optional(),
export const PlayerSchema = z
.object({
email: z.string().nullable(),
name: z.string().nullable(),
})
.and(User_GameSchema)
export const CreateSchema = z
.object({
game: GameSchema.nullish(),
gamePin: GamepinSchema.nullish(),
player1: PlayerSchema.nullish(),
player2: PlayerSchema.nullish(),
})
.strict()
export const GamePropsSchema = z.object({
payload: CreateSchema,
hash: z.string(),
})
export type GamePropsSchema = z.infer<typeof GamePropsSchema>

View file

@ -2,43 +2,20 @@ import "../styles/App.scss"
import "../styles/globals.scss"
import "../styles/grid2.scss"
import "../styles/grid.scss"
import { CreateSchema } from "@lib/zodSchemas"
import { SessionProvider } from "next-auth/react"
import type { AppProps } from "next/app"
import { Dispatch, SetStateAction, createContext, useState } from "react"
import { ToastContainer } from "react-toastify"
import "react-toastify/dist/ReactToastify.css"
interface gameContext {
pin?: string
game?: {
id: string
}
player?: {
id: string
name?: string
isOwner?: boolean
}
enemy?: {
id: string
name?: string
}
}
export const gameContext = createContext<
[gameContext, Dispatch<SetStateAction<gameContext>>]
>([{}, () => {}])
export default function App({
Component,
pageProps: { session, ...pageProps },
}: AppProps) {
const gameProps = useState<gameContext>({})
return (
<SessionProvider session={session}>
<gameContext.Provider value={gameProps}>
<Component {...pageProps} />
<ToastContainer />
</gameContext.Provider>
<Component {...pageProps} />
<ToastContainer />
</SessionProvider>
)
}

View file

@ -1,25 +1,22 @@
import { authOptions } from "../auth/[...nextauth]"
import { getAnyRunningGame } from "./running"
import { composeBody, gameIncludes, getAnyRunningGame } from "./running"
import sendResponse from "@backend/sendResponse"
import { rejectionErrors } from "@lib/backend/errors"
import prisma from "@lib/prisma"
import { CreateSchema } from "@lib/zodSchemas"
import { GamePropsSchema } from "@lib/zodSchemas"
import type { NextApiRequest, NextApiResponse } from "next"
import { getServerSession } from "next-auth"
import { z } from "zod"
type Data = z.infer<typeof CreateSchema>
export default async function create(
req: NextApiRequest,
res: NextApiResponse<Data>
res: NextApiResponse<GamePropsSchema>
) {
const session = await getServerSession(req, res, authOptions)
if (!session?.user) {
return sendResponse(req, res, rejectionErrors.unauthorized)
}
const { email, id, name } = session.user
const { email, id } = session.user
// Generate a random 4-digit code
const pin = Math.floor(Math.random() * 10000)
@ -28,10 +25,10 @@ export default async function create(
let created = false
let gameDB = await getAnyRunningGame(id)
if (!gameDB) {
let game = await getAnyRunningGame(id)
if (!game) {
created = true
gameDB = await prisma.game.create({
game = await prisma.game.create({
data: {
gamePin: {
create: {
@ -40,32 +37,21 @@ export default async function create(
},
users: {
create: {
isOwner: true,
userId: id,
index: "player1",
},
},
},
include: {
gamePin: true,
users: true,
},
...gameIncludes,
})
}
const { users, gamePin, ...game } = gameDB
const body = composeBody(game)
return sendResponse(req, res, {
message: `User <${email}> created game: ${game.id}`,
statusCode: created ? 201 : 200,
body: {
game,
pin: gamePin?.pin,
player: {
id,
name: name ?? undefined,
isOwner: true,
},
},
body,
type: ["debug", "infoCyan"],
})
}

View file

@ -1,20 +1,17 @@
import { authOptions } from "../auth/[...nextauth]"
import { composeBody, gameIncludes } from "./running"
import sendError from "@backend/sendError"
import sendResponse from "@backend/sendResponse"
import { rejectionErrors } from "@lib/backend/errors"
import getPinFromBody from "@lib/backend/getPinFromBody"
import prisma from "@lib/prisma"
import type { Game } from "@prisma/client"
import { GamePropsSchema } from "@lib/zodSchemas"
import type { NextApiRequest, NextApiResponse } from "next"
import { getServerSession } from "next-auth"
interface Data {
game: Game
}
export default async function join(
req: NextApiRequest,
res: NextApiResponse<Data>
res: NextApiResponse<GamePropsSchema>
) {
const session = await getServerSession(req, res, authOptions)
const pin = await getPinFromBody(req, res)
@ -23,7 +20,7 @@ export default async function join(
return sendResponse(req, res, rejectionErrors.unauthorized)
}
const { name, email, id } = session.user
const { email, id } = session.user
try {
const game = await prisma.game.findFirst({
@ -32,13 +29,6 @@ export default async function join(
pin,
},
},
include: {
users: {
include: {
user: true,
},
},
},
})
if (!game) {
return sendResponse(req, res, {
@ -48,35 +38,22 @@ export default async function join(
})
}
const player = game.users.find(({ user }) => user.id === id)?.user
const enemy = game.users.find(({ user }) => user.id !== id)?.user
const user_Game = await prisma.user_Game.create({
data: {
gameId: game.id,
userId: id,
index: "player2",
},
include: {
game: gameIncludes,
},
})
if (!player) {
await prisma.user_Game.create({
data: {
isOwner: false,
gameId: game.id,
userId: id,
},
})
}
const body = composeBody(user_Game.game)
return sendResponse(req, res, {
message: `User <${email}> joined game: ${game.id}`,
body: {
game,
pin,
player: {
id,
name,
isOwner: true,
},
enemy: {
id: enemy?.id,
name: enemy?.name,
isOwner: false,
},
},
body,
type: ["debug", "infoCyan"],
})
} catch (err: any) {

View file

@ -1,15 +1,30 @@
import { authOptions } from "../auth/[...nextauth]"
import sendResponse from "@backend/sendResponse"
import { rejectionErrors } from "@lib/backend/errors"
import { getObjectChecksum } from "@lib/getObjectChecksum"
import prisma from "@lib/prisma"
import { Game } from "@prisma/client"
import { GamePropsSchema } from "@lib/zodSchemas"
import type { NextApiRequest, NextApiResponse } from "next"
import { getServerSession } from "next-auth"
type Data = { game: Game }
export const gameIncludes = {
include: {
gamePin: true,
users: {
include: {
user: {
select: {
name: true,
email: true,
},
},
},
},
},
}
export const getAnyRunningGame = (id: string) =>
prisma.game.findFirst({
export const getAnyRunningGame = (id: string) => {
const game = prisma.game.findFirst({
where: {
NOT: {
state: "ended",
@ -20,15 +35,34 @@ export const getAnyRunningGame = (id: string) =>
},
},
},
include: {
gamePin: true,
users: true,
},
...gameIncludes,
})
return game
}
export function composeBody(
gameDB: NonNullable<Awaited<ReturnType<typeof getAnyRunningGame>>>
) {
const { gamePin, ...game } = gameDB
const users = gameDB.users.map(({ user, ...props }) => ({
...props,
...user,
}))
const player1 = users.find((user) => user.index === "player1")
const player2 = users.find((user) => user.index === "player2")
const payload = {
game,
gamePin,
player1,
player2,
}
const hash = getObjectChecksum(payload)
return { payload, hash }
}
export default async function create(
req: NextApiRequest,
res: NextApiResponse<Data>
res: NextApiResponse<GamePropsSchema>
) {
const session = await getServerSession(req, res, authOptions)
@ -38,23 +72,21 @@ export default async function create(
const { email, id } = session.user
const gameDB = await getAnyRunningGame(id)
const game = await getAnyRunningGame(id)
if (!gameDB)
if (!game)
return sendResponse(req, res, {
message: `User <${email}> is in no game.`,
statusCode: 204,
type: ["debug", "infoCyan"],
})
const { users, gamePin, ...game } = gameDB
const body = composeBody(game)
return sendResponse(req, res, {
message: `User <${email}> asked for game: ${game.id}`,
statusCode: 200,
body: {
game,
},
body,
type: ["debug", "infoCyan"],
})
}

View file

@ -53,7 +53,7 @@ export const getServerSideProps: GetServerSideProps<Props> = async (
let gameId = ""
if (session?.user.id) {
const game = await getAnyRunningGame(session?.user.id)
if (game && game.id) gameId = game?.id
if (game && game.state === "running") gameId = game?.id
}
return { props: { gameId, session } }

View file

@ -1,32 +0,0 @@
import BurgerMenu from "../components/BurgerMenu"
import LobbyFrame from "../components/Lobby/LobbyFrame"
import Settings from "../components/Lobby/SettingsFrame/Settings"
import Logo from "../components/Logo"
import classNames from "classnames"
import Head from "next/head"
import { useState } from "react"
export default function Home() {
const [settings, setSettings] = useState(false)
return (
<div className="h-full bg-theme">
<Head>
<title>Create Next App</title>
<meta name="description" content="Generated by create next app" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" href="/favicon.ico" />
</Head>
<div
className={classNames(
"mx-auto flex h-full max-w-screen-2xl flex-col items-center justify-evenly",
{ "blur-sm": settings }
)}
>
<Logo small={true} />
<LobbyFrame openSettings={() => setSettings(true)} />
</div>
<BurgerMenu blur={settings} />
{settings ? <Settings closeSettings={() => setSettings(false)} /> : <></>}
</div>
)
}

View file

@ -0,0 +1,54 @@
import BurgerMenu from "../../components/BurgerMenu"
import LobbyFrame from "../../components/Lobby/LobbyFrame"
import Settings from "../../components/Lobby/SettingsFrame/Settings"
import Logo from "../../components/Logo"
import { Data, composeBody, getAnyRunningGame } from "../api/game/running"
import useGameState from "@lib/hooks/useGameState"
import classNames from "classnames"
import { GetServerSideProps } from "next"
import Head from "next/head"
import { useState } from "react"
export default function Home(props: Data) {
const [settings, setSettings] = useState(false)
const { gameProps, setGameProps } = useGameState(props)
return (
<div className="h-full bg-theme">
<Head>
<title>Lobby</title>
<meta name="description" content="Generated by create next app" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" href="/favicon.ico" />
</Head>
<div
className={classNames(
"mx-auto flex h-full max-w-screen-2xl flex-col items-center justify-evenly",
{ "blur-sm": settings }
)}
>
<Logo small={true} />
<LobbyFrame openSettings={() => setSettings(true)} />
</div>
<BurgerMenu blur={settings} />
{settings ? <Settings closeSettings={() => setSettings(false)} /> : <></>}
</div>
)
}
export const getServerSideProps: GetServerSideProps<Data> = async (context) => {
const { gameId } = context.query
const gameIdString = Array.isArray(gameId) ? gameId[0] : gameId
const game = await getAnyRunningGame(gameIdString ?? "")
if (!game)
return {
redirect: {
destination: "/start",
permanent: false,
},
}
const body = composeBody(game)
return { props: body }
}

View file

@ -0,0 +1,60 @@
import { authOptions } from "../api/auth/[...nextauth]"
import { getAnyRunningGame } from "../api/game/running"
import { GetServerSideProps } from "next"
import { Session, getServerSession } from "next-auth"
import { useRouter } from "next/router"
import React, { useEffect } from "react"
import { toast } from "react-toastify"
interface Props {
gameId: string
session: Session | null
}
export default function Lobby({ gameId, session }: Props) {
const router = useRouter()
useEffect(() => {
const path = gameId ? "/lobby/" + gameId : "/start"
toast.promise(router.push(path), {
pending: {
render: "Wird weitergeleitet...",
toastId: "redirect",
},
success: {
render: gameId
? "Spiel gefunden!"
: session?.user
? "Kein laufendes Spiel."
: "Kein laufendes Spiel. Bitte anmelden.",
toastId: session?.user ? "postRedirect" : "user",
theme: session?.user ? "dark" : undefined,
type: gameId ? "success" : "info",
},
error: {
render: "Es ist ein Fehler aufgetreten 🤯",
type: "error",
theme: "colored",
},
})
})
return (
<div className="h-full bg-theme">
<div className="mx-auto flex h-full max-w-screen-md flex-col items-center justify-evenly"></div>
</div>
)
}
export const getServerSideProps: GetServerSideProps<Props> = async (
context
) => {
const session = await getServerSession(context.req, context.res, authOptions)
let gameId = ""
if (session?.user.id) {
const game = await getAnyRunningGame(session?.user.id)
if (game && game.state === "launching") gameId = game?.id
}
return { props: { gameId, session } }
}

View file

@ -5,7 +5,7 @@ import { faEye, faLeftLong } from "@fortawesome/pro-regular-svg-icons"
import { faPlus, faUserPlus } from "@fortawesome/pro-solid-svg-icons"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
import useGameState from "@lib/hooks/useGameState"
import { CreateSchema } from "@lib/zodSchemas"
import { GamePropsSchema } from "@lib/zodSchemas"
import status from "http-status"
import { GetServerSideProps } from "next"
import { useRouter } from "next/router"
@ -16,6 +16,7 @@ import { toast } from "react-toastify"
interface Props {
q: string | string[] | undefined
}
function isInputOnlyNumbers(input: string) {
return /^\d+$/.test(input)
}
@ -32,7 +33,6 @@ export function isAuthenticated(res: Response) {
type: "error",
theme: "colored",
})
return Promise.reject()
}
const handleConfirmation = () => {
@ -48,7 +48,7 @@ const handleConfirmation = () => {
)
}
export default function Home({ q }: Props) {
export default function Start({ q }: Props) {
const [otp, setOtp] = useState("")
const { gameProps, setGameProps } = useGameState()
const router = useRouter()
@ -61,7 +61,7 @@ export default function Home({ q }: Props) {
body: JSON.stringify({ pin }),
})
.then(isAuthenticated)
.then((game) => CreateSchema.parse(game))
.then((game) => GamePropsSchema.parse(game))
const res = await toast.promise(gamePromise, {
pending: {
@ -170,5 +170,5 @@ export const getServerSideProps: GetServerSideProps<Props> = async (
) => {
const { q } = context.query
return { props: { q: q ? q : "" } }
return { props: { q } }
}

View file

@ -28,7 +28,7 @@ export const TransactionIsolationLevelSchema = z.enum(['ReadUncommitted','ReadCo
export const UserScalarFieldEnumSchema = z.enum(['id','name','email','emailVerified','image','createdAt','updatedAt']);
export const User_GameScalarFieldEnumSchema = z.enum(['id','createdAt','gameId','userId','isOwner']);
export const User_GameScalarFieldEnumSchema = z.enum(['id','createdAt','gameId','userId','index']);
export const VerificationTokenScalarFieldEnumSchema = z.enum(['identifier','token','expires']);
@ -36,6 +36,10 @@ export const GameStateSchema = z.enum(['launching','running','ended']);
export type GameStateType = `${z.infer<typeof GameStateSchema>}`
export const PlayerNSchema = z.enum(['player1','player2']);
export type PlayerNType = `${z.infer<typeof PlayerNSchema>}`
/////////////////////////////////////////
// MODELS
/////////////////////////////////////////
@ -136,11 +140,11 @@ export type Gamepin = z.infer<typeof GamepinSchema>
/////////////////////////////////////////
export const User_GameSchema = z.object({
index: PlayerNSchema,
id: z.string().cuid(),
createdAt: z.coerce.date(),
gameId: z.string(),
userId: z.string(),
isOwner: z.boolean(),
})
export type User_Game = z.infer<typeof User_GameSchema>
@ -357,7 +361,7 @@ export const User_GameSelectSchema: z.ZodType<Prisma.User_GameSelect> = z.object
createdAt: z.boolean().optional(),
gameId: z.boolean().optional(),
userId: z.boolean().optional(),
isOwner: z.boolean().optional(),
index: z.boolean().optional(),
moves: z.union([z.boolean(),z.lazy(() => MoveFindManyArgsSchema)]).optional(),
chats: z.union([z.boolean(),z.lazy(() => ChatFindManyArgsSchema)]).optional(),
game: z.union([z.boolean(),z.lazy(() => GameArgsSchema)]).optional(),
@ -741,7 +745,7 @@ export const User_GameWhereInputSchema: z.ZodType<Prisma.User_GameWhereInput> =
createdAt: z.union([ z.lazy(() => DateTimeFilterSchema),z.coerce.date() ]).optional(),
gameId: z.union([ z.lazy(() => StringFilterSchema),z.string() ]).optional(),
userId: z.union([ z.lazy(() => StringFilterSchema),z.string() ]).optional(),
isOwner: z.union([ z.lazy(() => BoolFilterSchema),z.boolean() ]).optional(),
index: z.union([ z.lazy(() => EnumPlayerNFilterSchema),z.lazy(() => PlayerNSchema) ]).optional(),
moves: z.lazy(() => MoveListRelationFilterSchema).optional(),
chats: z.lazy(() => ChatListRelationFilterSchema).optional(),
game: z.union([ z.lazy(() => GameRelationFilterSchema),z.lazy(() => GameWhereInputSchema) ]).optional(),
@ -753,7 +757,7 @@ export const User_GameOrderByWithRelationInputSchema: z.ZodType<Prisma.User_Game
createdAt: z.lazy(() => SortOrderSchema).optional(),
gameId: z.lazy(() => SortOrderSchema).optional(),
userId: z.lazy(() => SortOrderSchema).optional(),
isOwner: z.lazy(() => SortOrderSchema).optional(),
index: z.lazy(() => SortOrderSchema).optional(),
moves: z.lazy(() => MoveOrderByRelationAggregateInputSchema).optional(),
chats: z.lazy(() => ChatOrderByRelationAggregateInputSchema).optional(),
game: z.lazy(() => GameOrderByWithRelationInputSchema).optional(),
@ -762,6 +766,7 @@ export const User_GameOrderByWithRelationInputSchema: z.ZodType<Prisma.User_Game
export const User_GameWhereUniqueInputSchema: z.ZodType<Prisma.User_GameWhereUniqueInput> = z.object({
id: z.string().cuid().optional(),
gameId_index: z.lazy(() => User_GameGameIdIndexCompoundUniqueInputSchema).optional(),
gameId_userId: z.lazy(() => User_GameGameIdUserIdCompoundUniqueInputSchema).optional()
}).strict();
@ -770,7 +775,7 @@ export const User_GameOrderByWithAggregationInputSchema: z.ZodType<Prisma.User_G
createdAt: z.lazy(() => SortOrderSchema).optional(),
gameId: z.lazy(() => SortOrderSchema).optional(),
userId: z.lazy(() => SortOrderSchema).optional(),
isOwner: z.lazy(() => SortOrderSchema).optional(),
index: z.lazy(() => SortOrderSchema).optional(),
_count: z.lazy(() => User_GameCountOrderByAggregateInputSchema).optional(),
_max: z.lazy(() => User_GameMaxOrderByAggregateInputSchema).optional(),
_min: z.lazy(() => User_GameMinOrderByAggregateInputSchema).optional()
@ -784,7 +789,7 @@ export const User_GameScalarWhereWithAggregatesInputSchema: z.ZodType<Prisma.Use
createdAt: z.union([ z.lazy(() => DateTimeWithAggregatesFilterSchema),z.coerce.date() ]).optional(),
gameId: z.union([ z.lazy(() => StringWithAggregatesFilterSchema),z.string() ]).optional(),
userId: z.union([ z.lazy(() => StringWithAggregatesFilterSchema),z.string() ]).optional(),
isOwner: z.union([ z.lazy(() => BoolWithAggregatesFilterSchema),z.boolean() ]).optional(),
index: z.union([ z.lazy(() => EnumPlayerNWithAggregatesFilterSchema),z.lazy(() => PlayerNSchema) ]).optional(),
}).strict();
export const MoveWhereInputSchema: z.ZodType<Prisma.MoveWhereInput> = z.object({
@ -807,7 +812,8 @@ export const MoveOrderByWithRelationInputSchema: z.ZodType<Prisma.MoveOrderByWit
}).strict();
export const MoveWhereUniqueInputSchema: z.ZodType<Prisma.MoveWhereUniqueInput> = z.object({
id: z.string().cuid().optional()
id: z.string().cuid().optional(),
user_game_id_index: z.lazy(() => MoveUser_game_idIndexCompoundUniqueInputSchema).optional()
}).strict();
export const MoveOrderByWithAggregationInputSchema: z.ZodType<Prisma.MoveOrderByWithAggregationInput> = z.object({
@ -1284,7 +1290,7 @@ export const GamepinUncheckedUpdateManyInputSchema: z.ZodType<Prisma.GamepinUnch
export const User_GameCreateInputSchema: z.ZodType<Prisma.User_GameCreateInput> = z.object({
id: z.string().cuid().optional(),
createdAt: z.coerce.date().optional(),
isOwner: z.boolean(),
index: z.lazy(() => PlayerNSchema),
moves: z.lazy(() => MoveCreateNestedManyWithoutUser_gameInputSchema).optional(),
chats: z.lazy(() => ChatCreateNestedManyWithoutUser_gameInputSchema).optional(),
game: z.lazy(() => GameCreateNestedOneWithoutUsersInputSchema),
@ -1296,7 +1302,7 @@ export const User_GameUncheckedCreateInputSchema: z.ZodType<Prisma.User_GameUnch
createdAt: z.coerce.date().optional(),
gameId: z.string(),
userId: z.string(),
isOwner: z.boolean(),
index: z.lazy(() => PlayerNSchema),
moves: z.lazy(() => MoveUncheckedCreateNestedManyWithoutUser_gameInputSchema).optional(),
chats: z.lazy(() => ChatUncheckedCreateNestedManyWithoutUser_gameInputSchema).optional()
}).strict();
@ -1304,7 +1310,7 @@ export const User_GameUncheckedCreateInputSchema: z.ZodType<Prisma.User_GameUnch
export const User_GameUpdateInputSchema: z.ZodType<Prisma.User_GameUpdateInput> = z.object({
id: z.union([ z.string().cuid(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
createdAt: z.union([ z.coerce.date(),z.lazy(() => DateTimeFieldUpdateOperationsInputSchema) ]).optional(),
isOwner: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
index: z.union([ z.lazy(() => PlayerNSchema),z.lazy(() => EnumPlayerNFieldUpdateOperationsInputSchema) ]).optional(),
moves: z.lazy(() => MoveUpdateManyWithoutUser_gameNestedInputSchema).optional(),
chats: z.lazy(() => ChatUpdateManyWithoutUser_gameNestedInputSchema).optional(),
game: z.lazy(() => GameUpdateOneRequiredWithoutUsersNestedInputSchema).optional(),
@ -1316,7 +1322,7 @@ export const User_GameUncheckedUpdateInputSchema: z.ZodType<Prisma.User_GameUnch
createdAt: z.union([ z.coerce.date(),z.lazy(() => DateTimeFieldUpdateOperationsInputSchema) ]).optional(),
gameId: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
userId: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
isOwner: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
index: z.union([ z.lazy(() => PlayerNSchema),z.lazy(() => EnumPlayerNFieldUpdateOperationsInputSchema) ]).optional(),
moves: z.lazy(() => MoveUncheckedUpdateManyWithoutUser_gameNestedInputSchema).optional(),
chats: z.lazy(() => ChatUncheckedUpdateManyWithoutUser_gameNestedInputSchema).optional()
}).strict();
@ -1326,13 +1332,13 @@ export const User_GameCreateManyInputSchema: z.ZodType<Prisma.User_GameCreateMan
createdAt: z.coerce.date().optional(),
gameId: z.string(),
userId: z.string(),
isOwner: z.boolean()
index: z.lazy(() => PlayerNSchema)
}).strict();
export const User_GameUpdateManyMutationInputSchema: z.ZodType<Prisma.User_GameUpdateManyMutationInput> = z.object({
id: z.union([ z.string().cuid(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
createdAt: z.union([ z.coerce.date(),z.lazy(() => DateTimeFieldUpdateOperationsInputSchema) ]).optional(),
isOwner: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
index: z.union([ z.lazy(() => PlayerNSchema),z.lazy(() => EnumPlayerNFieldUpdateOperationsInputSchema) ]).optional(),
}).strict();
export const User_GameUncheckedUpdateManyInputSchema: z.ZodType<Prisma.User_GameUncheckedUpdateManyInput> = z.object({
@ -1340,7 +1346,7 @@ export const User_GameUncheckedUpdateManyInputSchema: z.ZodType<Prisma.User_Game
createdAt: z.union([ z.coerce.date(),z.lazy(() => DateTimeFieldUpdateOperationsInputSchema) ]).optional(),
gameId: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
userId: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
isOwner: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
index: z.union([ z.lazy(() => PlayerNSchema),z.lazy(() => EnumPlayerNFieldUpdateOperationsInputSchema) ]).optional(),
}).strict();
export const MoveCreateInputSchema: z.ZodType<Prisma.MoveCreateInput> = z.object({
@ -1832,9 +1838,11 @@ export const GamepinMinOrderByAggregateInputSchema: z.ZodType<Prisma.GamepinMinO
gameId: z.lazy(() => SortOrderSchema).optional()
}).strict();
export const BoolFilterSchema: z.ZodType<Prisma.BoolFilter> = z.object({
equals: z.boolean().optional(),
not: z.union([ z.boolean(),z.lazy(() => NestedBoolFilterSchema) ]).optional(),
export const EnumPlayerNFilterSchema: z.ZodType<Prisma.EnumPlayerNFilter> = z.object({
equals: z.lazy(() => PlayerNSchema).optional(),
in: z.lazy(() => PlayerNSchema).array().optional(),
notIn: z.lazy(() => PlayerNSchema).array().optional(),
not: z.union([ z.lazy(() => PlayerNSchema),z.lazy(() => NestedEnumPlayerNFilterSchema) ]).optional(),
}).strict();
export const MoveListRelationFilterSchema: z.ZodType<Prisma.MoveListRelationFilter> = z.object({
@ -1857,6 +1865,11 @@ export const ChatOrderByRelationAggregateInputSchema: z.ZodType<Prisma.ChatOrder
_count: z.lazy(() => SortOrderSchema).optional()
}).strict();
export const User_GameGameIdIndexCompoundUniqueInputSchema: z.ZodType<Prisma.User_GameGameIdIndexCompoundUniqueInput> = z.object({
gameId: z.string(),
index: z.lazy(() => PlayerNSchema)
}).strict();
export const User_GameGameIdUserIdCompoundUniqueInputSchema: z.ZodType<Prisma.User_GameGameIdUserIdCompoundUniqueInput> = z.object({
gameId: z.string(),
userId: z.string()
@ -1867,7 +1880,7 @@ export const User_GameCountOrderByAggregateInputSchema: z.ZodType<Prisma.User_Ga
createdAt: z.lazy(() => SortOrderSchema).optional(),
gameId: z.lazy(() => SortOrderSchema).optional(),
userId: z.lazy(() => SortOrderSchema).optional(),
isOwner: z.lazy(() => SortOrderSchema).optional()
index: z.lazy(() => SortOrderSchema).optional()
}).strict();
export const User_GameMaxOrderByAggregateInputSchema: z.ZodType<Prisma.User_GameMaxOrderByAggregateInput> = z.object({
@ -1875,7 +1888,7 @@ export const User_GameMaxOrderByAggregateInputSchema: z.ZodType<Prisma.User_Game
createdAt: z.lazy(() => SortOrderSchema).optional(),
gameId: z.lazy(() => SortOrderSchema).optional(),
userId: z.lazy(() => SortOrderSchema).optional(),
isOwner: z.lazy(() => SortOrderSchema).optional()
index: z.lazy(() => SortOrderSchema).optional()
}).strict();
export const User_GameMinOrderByAggregateInputSchema: z.ZodType<Prisma.User_GameMinOrderByAggregateInput> = z.object({
@ -1883,15 +1896,17 @@ export const User_GameMinOrderByAggregateInputSchema: z.ZodType<Prisma.User_Game
createdAt: z.lazy(() => SortOrderSchema).optional(),
gameId: z.lazy(() => SortOrderSchema).optional(),
userId: z.lazy(() => SortOrderSchema).optional(),
isOwner: z.lazy(() => SortOrderSchema).optional()
index: z.lazy(() => SortOrderSchema).optional()
}).strict();
export const BoolWithAggregatesFilterSchema: z.ZodType<Prisma.BoolWithAggregatesFilter> = z.object({
equals: z.boolean().optional(),
not: z.union([ z.boolean(),z.lazy(() => NestedBoolWithAggregatesFilterSchema) ]).optional(),
export const EnumPlayerNWithAggregatesFilterSchema: z.ZodType<Prisma.EnumPlayerNWithAggregatesFilter> = z.object({
equals: z.lazy(() => PlayerNSchema).optional(),
in: z.lazy(() => PlayerNSchema).array().optional(),
notIn: z.lazy(() => PlayerNSchema).array().optional(),
not: z.union([ z.lazy(() => PlayerNSchema),z.lazy(() => NestedEnumPlayerNWithAggregatesFilterSchema) ]).optional(),
_count: z.lazy(() => NestedIntFilterSchema).optional(),
_min: z.lazy(() => NestedBoolFilterSchema).optional(),
_max: z.lazy(() => NestedBoolFilterSchema).optional()
_min: z.lazy(() => NestedEnumPlayerNFilterSchema).optional(),
_max: z.lazy(() => NestedEnumPlayerNFilterSchema).optional()
}).strict();
export const IntFilterSchema: z.ZodType<Prisma.IntFilter> = z.object({
@ -1910,6 +1925,11 @@ export const User_GameRelationFilterSchema: z.ZodType<Prisma.User_GameRelationFi
isNot: z.lazy(() => User_GameWhereInputSchema).optional()
}).strict();
export const MoveUser_game_idIndexCompoundUniqueInputSchema: z.ZodType<Prisma.MoveUser_game_idIndexCompoundUniqueInput> = z.object({
user_game_id: z.string(),
index: z.number()
}).strict();
export const MoveCountOrderByAggregateInputSchema: z.ZodType<Prisma.MoveCountOrderByAggregateInput> = z.object({
id: z.lazy(() => SortOrderSchema).optional(),
createdAt: z.lazy(() => SortOrderSchema).optional(),
@ -2289,8 +2309,8 @@ export const ChatUncheckedCreateNestedManyWithoutUser_gameInputSchema: z.ZodType
connect: z.union([ z.lazy(() => ChatWhereUniqueInputSchema),z.lazy(() => ChatWhereUniqueInputSchema).array() ]).optional(),
}).strict();
export const BoolFieldUpdateOperationsInputSchema: z.ZodType<Prisma.BoolFieldUpdateOperationsInput> = z.object({
set: z.boolean().optional()
export const EnumPlayerNFieldUpdateOperationsInputSchema: z.ZodType<Prisma.EnumPlayerNFieldUpdateOperationsInput> = z.object({
set: z.lazy(() => PlayerNSchema).optional()
}).strict();
export const MoveUpdateManyWithoutUser_gameNestedInputSchema: z.ZodType<Prisma.MoveUpdateManyWithoutUser_gameNestedInput> = z.object({
@ -2579,17 +2599,21 @@ export const NestedEnumGameStateWithAggregatesFilterSchema: z.ZodType<Prisma.Nes
_max: z.lazy(() => NestedEnumGameStateFilterSchema).optional()
}).strict();
export const NestedBoolFilterSchema: z.ZodType<Prisma.NestedBoolFilter> = z.object({
equals: z.boolean().optional(),
not: z.union([ z.boolean(),z.lazy(() => NestedBoolFilterSchema) ]).optional(),
export const NestedEnumPlayerNFilterSchema: z.ZodType<Prisma.NestedEnumPlayerNFilter> = z.object({
equals: z.lazy(() => PlayerNSchema).optional(),
in: z.lazy(() => PlayerNSchema).array().optional(),
notIn: z.lazy(() => PlayerNSchema).array().optional(),
not: z.union([ z.lazy(() => PlayerNSchema),z.lazy(() => NestedEnumPlayerNFilterSchema) ]).optional(),
}).strict();
export const NestedBoolWithAggregatesFilterSchema: z.ZodType<Prisma.NestedBoolWithAggregatesFilter> = z.object({
equals: z.boolean().optional(),
not: z.union([ z.boolean(),z.lazy(() => NestedBoolWithAggregatesFilterSchema) ]).optional(),
export const NestedEnumPlayerNWithAggregatesFilterSchema: z.ZodType<Prisma.NestedEnumPlayerNWithAggregatesFilter> = z.object({
equals: z.lazy(() => PlayerNSchema).optional(),
in: z.lazy(() => PlayerNSchema).array().optional(),
notIn: z.lazy(() => PlayerNSchema).array().optional(),
not: z.union([ z.lazy(() => PlayerNSchema),z.lazy(() => NestedEnumPlayerNWithAggregatesFilterSchema) ]).optional(),
_count: z.lazy(() => NestedIntFilterSchema).optional(),
_min: z.lazy(() => NestedBoolFilterSchema).optional(),
_max: z.lazy(() => NestedBoolFilterSchema).optional()
_min: z.lazy(() => NestedEnumPlayerNFilterSchema).optional(),
_max: z.lazy(() => NestedEnumPlayerNFilterSchema).optional()
}).strict();
export const NestedIntWithAggregatesFilterSchema: z.ZodType<Prisma.NestedIntWithAggregatesFilter> = z.object({
@ -2738,7 +2762,7 @@ export const UserUncheckedUpdateWithoutSessionsInputSchema: z.ZodType<Prisma.Use
export const User_GameCreateWithoutUserInputSchema: z.ZodType<Prisma.User_GameCreateWithoutUserInput> = z.object({
id: z.string().optional(),
createdAt: z.coerce.date().optional(),
isOwner: z.boolean(),
index: z.lazy(() => PlayerNSchema),
moves: z.lazy(() => MoveCreateNestedManyWithoutUser_gameInputSchema).optional(),
chats: z.lazy(() => ChatCreateNestedManyWithoutUser_gameInputSchema).optional(),
game: z.lazy(() => GameCreateNestedOneWithoutUsersInputSchema)
@ -2748,7 +2772,7 @@ export const User_GameUncheckedCreateWithoutUserInputSchema: z.ZodType<Prisma.Us
id: z.string().optional(),
createdAt: z.coerce.date().optional(),
gameId: z.string(),
isOwner: z.boolean(),
index: z.lazy(() => PlayerNSchema),
moves: z.lazy(() => MoveUncheckedCreateNestedManyWithoutUser_gameInputSchema).optional(),
chats: z.lazy(() => ChatUncheckedCreateNestedManyWithoutUser_gameInputSchema).optional()
}).strict();
@ -2853,7 +2877,7 @@ export const User_GameScalarWhereInputSchema: z.ZodType<Prisma.User_GameScalarWh
createdAt: z.union([ z.lazy(() => DateTimeFilterSchema),z.coerce.date() ]).optional(),
gameId: z.union([ z.lazy(() => StringFilterSchema),z.string() ]).optional(),
userId: z.union([ z.lazy(() => StringFilterSchema),z.string() ]).optional(),
isOwner: z.union([ z.lazy(() => BoolFilterSchema),z.boolean() ]).optional(),
index: z.union([ z.lazy(() => EnumPlayerNFilterSchema),z.lazy(() => PlayerNSchema) ]).optional(),
}).strict();
export const AccountUpsertWithWhereUniqueWithoutUserInputSchema: z.ZodType<Prisma.AccountUpsertWithWhereUniqueWithoutUserInput> = z.object({
@ -2939,7 +2963,7 @@ export const GamepinCreateOrConnectWithoutGameInputSchema: z.ZodType<Prisma.Game
export const User_GameCreateWithoutGameInputSchema: z.ZodType<Prisma.User_GameCreateWithoutGameInput> = z.object({
id: z.string().optional(),
createdAt: z.coerce.date().optional(),
isOwner: z.boolean(),
index: z.lazy(() => PlayerNSchema),
moves: z.lazy(() => MoveCreateNestedManyWithoutUser_gameInputSchema).optional(),
chats: z.lazy(() => ChatCreateNestedManyWithoutUser_gameInputSchema).optional(),
user: z.lazy(() => UserCreateNestedOneWithoutGamesInputSchema)
@ -2949,7 +2973,7 @@ export const User_GameUncheckedCreateWithoutGameInputSchema: z.ZodType<Prisma.Us
id: z.string().optional(),
createdAt: z.coerce.date().optional(),
userId: z.string(),
isOwner: z.boolean(),
index: z.lazy(() => PlayerNSchema),
moves: z.lazy(() => MoveUncheckedCreateNestedManyWithoutUser_gameInputSchema).optional(),
chats: z.lazy(() => ChatUncheckedCreateNestedManyWithoutUser_gameInputSchema).optional()
}).strict();
@ -3241,7 +3265,7 @@ export const UserUncheckedUpdateWithoutGamesInputSchema: z.ZodType<Prisma.UserUn
export const User_GameCreateWithoutMovesInputSchema: z.ZodType<Prisma.User_GameCreateWithoutMovesInput> = z.object({
id: z.string().optional(),
createdAt: z.coerce.date().optional(),
isOwner: z.boolean(),
index: z.lazy(() => PlayerNSchema),
chats: z.lazy(() => ChatCreateNestedManyWithoutUser_gameInputSchema).optional(),
game: z.lazy(() => GameCreateNestedOneWithoutUsersInputSchema),
user: z.lazy(() => UserCreateNestedOneWithoutGamesInputSchema)
@ -3252,7 +3276,7 @@ export const User_GameUncheckedCreateWithoutMovesInputSchema: z.ZodType<Prisma.U
createdAt: z.coerce.date().optional(),
gameId: z.string(),
userId: z.string(),
isOwner: z.boolean(),
index: z.lazy(() => PlayerNSchema),
chats: z.lazy(() => ChatUncheckedCreateNestedManyWithoutUser_gameInputSchema).optional()
}).strict();
@ -3269,7 +3293,7 @@ export const User_GameUpsertWithoutMovesInputSchema: z.ZodType<Prisma.User_GameU
export const User_GameUpdateWithoutMovesInputSchema: z.ZodType<Prisma.User_GameUpdateWithoutMovesInput> = z.object({
id: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
createdAt: z.union([ z.coerce.date(),z.lazy(() => DateTimeFieldUpdateOperationsInputSchema) ]).optional(),
isOwner: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
index: z.union([ z.lazy(() => PlayerNSchema),z.lazy(() => EnumPlayerNFieldUpdateOperationsInputSchema) ]).optional(),
chats: z.lazy(() => ChatUpdateManyWithoutUser_gameNestedInputSchema).optional(),
game: z.lazy(() => GameUpdateOneRequiredWithoutUsersNestedInputSchema).optional(),
user: z.lazy(() => UserUpdateOneRequiredWithoutGamesNestedInputSchema).optional()
@ -3280,14 +3304,14 @@ export const User_GameUncheckedUpdateWithoutMovesInputSchema: z.ZodType<Prisma.U
createdAt: z.union([ z.coerce.date(),z.lazy(() => DateTimeFieldUpdateOperationsInputSchema) ]).optional(),
gameId: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
userId: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
isOwner: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
index: z.union([ z.lazy(() => PlayerNSchema),z.lazy(() => EnumPlayerNFieldUpdateOperationsInputSchema) ]).optional(),
chats: z.lazy(() => ChatUncheckedUpdateManyWithoutUser_gameNestedInputSchema).optional()
}).strict();
export const User_GameCreateWithoutChatsInputSchema: z.ZodType<Prisma.User_GameCreateWithoutChatsInput> = z.object({
id: z.string().optional(),
createdAt: z.coerce.date().optional(),
isOwner: z.boolean(),
index: z.lazy(() => PlayerNSchema),
moves: z.lazy(() => MoveCreateNestedManyWithoutUser_gameInputSchema).optional(),
game: z.lazy(() => GameCreateNestedOneWithoutUsersInputSchema),
user: z.lazy(() => UserCreateNestedOneWithoutGamesInputSchema)
@ -3298,7 +3322,7 @@ export const User_GameUncheckedCreateWithoutChatsInputSchema: z.ZodType<Prisma.U
createdAt: z.coerce.date().optional(),
gameId: z.string(),
userId: z.string(),
isOwner: z.boolean(),
index: z.lazy(() => PlayerNSchema),
moves: z.lazy(() => MoveUncheckedCreateNestedManyWithoutUser_gameInputSchema).optional()
}).strict();
@ -3315,7 +3339,7 @@ export const User_GameUpsertWithoutChatsInputSchema: z.ZodType<Prisma.User_GameU
export const User_GameUpdateWithoutChatsInputSchema: z.ZodType<Prisma.User_GameUpdateWithoutChatsInput> = z.object({
id: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
createdAt: z.union([ z.coerce.date(),z.lazy(() => DateTimeFieldUpdateOperationsInputSchema) ]).optional(),
isOwner: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
index: z.union([ z.lazy(() => PlayerNSchema),z.lazy(() => EnumPlayerNFieldUpdateOperationsInputSchema) ]).optional(),
moves: z.lazy(() => MoveUpdateManyWithoutUser_gameNestedInputSchema).optional(),
game: z.lazy(() => GameUpdateOneRequiredWithoutUsersNestedInputSchema).optional(),
user: z.lazy(() => UserUpdateOneRequiredWithoutGamesNestedInputSchema).optional()
@ -3326,7 +3350,7 @@ export const User_GameUncheckedUpdateWithoutChatsInputSchema: z.ZodType<Prisma.U
createdAt: z.union([ z.coerce.date(),z.lazy(() => DateTimeFieldUpdateOperationsInputSchema) ]).optional(),
gameId: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
userId: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
isOwner: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
index: z.union([ z.lazy(() => PlayerNSchema),z.lazy(() => EnumPlayerNFieldUpdateOperationsInputSchema) ]).optional(),
moves: z.lazy(() => MoveUncheckedUpdateManyWithoutUser_gameNestedInputSchema).optional()
}).strict();
@ -3334,7 +3358,7 @@ export const User_GameCreateManyUserInputSchema: z.ZodType<Prisma.User_GameCreat
id: z.string().cuid().optional(),
createdAt: z.coerce.date().optional(),
gameId: z.string(),
isOwner: z.boolean()
index: z.lazy(() => PlayerNSchema)
}).strict();
export const AccountCreateManyUserInputSchema: z.ZodType<Prisma.AccountCreateManyUserInput> = z.object({
@ -3363,7 +3387,7 @@ export const SessionCreateManyUserInputSchema: z.ZodType<Prisma.SessionCreateMan
export const User_GameUpdateWithoutUserInputSchema: z.ZodType<Prisma.User_GameUpdateWithoutUserInput> = z.object({
id: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
createdAt: z.union([ z.coerce.date(),z.lazy(() => DateTimeFieldUpdateOperationsInputSchema) ]).optional(),
isOwner: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
index: z.union([ z.lazy(() => PlayerNSchema),z.lazy(() => EnumPlayerNFieldUpdateOperationsInputSchema) ]).optional(),
moves: z.lazy(() => MoveUpdateManyWithoutUser_gameNestedInputSchema).optional(),
chats: z.lazy(() => ChatUpdateManyWithoutUser_gameNestedInputSchema).optional(),
game: z.lazy(() => GameUpdateOneRequiredWithoutUsersNestedInputSchema).optional()
@ -3373,7 +3397,7 @@ export const User_GameUncheckedUpdateWithoutUserInputSchema: z.ZodType<Prisma.Us
id: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
createdAt: z.union([ z.coerce.date(),z.lazy(() => DateTimeFieldUpdateOperationsInputSchema) ]).optional(),
gameId: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
isOwner: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
index: z.union([ z.lazy(() => PlayerNSchema),z.lazy(() => EnumPlayerNFieldUpdateOperationsInputSchema) ]).optional(),
moves: z.lazy(() => MoveUncheckedUpdateManyWithoutUser_gameNestedInputSchema).optional(),
chats: z.lazy(() => ChatUncheckedUpdateManyWithoutUser_gameNestedInputSchema).optional()
}).strict();
@ -3382,7 +3406,7 @@ export const User_GameUncheckedUpdateManyWithoutGamesInputSchema: z.ZodType<Pris
id: z.union([ z.string().cuid(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
createdAt: z.union([ z.coerce.date(),z.lazy(() => DateTimeFieldUpdateOperationsInputSchema) ]).optional(),
gameId: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
isOwner: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
index: z.union([ z.lazy(() => PlayerNSchema),z.lazy(() => EnumPlayerNFieldUpdateOperationsInputSchema) ]).optional(),
}).strict();
export const AccountUpdateWithoutUserInputSchema: z.ZodType<Prisma.AccountUpdateWithoutUserInput> = z.object({
@ -3458,13 +3482,13 @@ export const User_GameCreateManyGameInputSchema: z.ZodType<Prisma.User_GameCreat
id: z.string().cuid().optional(),
createdAt: z.coerce.date().optional(),
userId: z.string(),
isOwner: z.boolean()
index: z.lazy(() => PlayerNSchema)
}).strict();
export const User_GameUpdateWithoutGameInputSchema: z.ZodType<Prisma.User_GameUpdateWithoutGameInput> = z.object({
id: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
createdAt: z.union([ z.coerce.date(),z.lazy(() => DateTimeFieldUpdateOperationsInputSchema) ]).optional(),
isOwner: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
index: z.union([ z.lazy(() => PlayerNSchema),z.lazy(() => EnumPlayerNFieldUpdateOperationsInputSchema) ]).optional(),
moves: z.lazy(() => MoveUpdateManyWithoutUser_gameNestedInputSchema).optional(),
chats: z.lazy(() => ChatUpdateManyWithoutUser_gameNestedInputSchema).optional(),
user: z.lazy(() => UserUpdateOneRequiredWithoutGamesNestedInputSchema).optional()
@ -3474,7 +3498,7 @@ export const User_GameUncheckedUpdateWithoutGameInputSchema: z.ZodType<Prisma.Us
id: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
createdAt: z.union([ z.coerce.date(),z.lazy(() => DateTimeFieldUpdateOperationsInputSchema) ]).optional(),
userId: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
isOwner: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
index: z.union([ z.lazy(() => PlayerNSchema),z.lazy(() => EnumPlayerNFieldUpdateOperationsInputSchema) ]).optional(),
moves: z.lazy(() => MoveUncheckedUpdateManyWithoutUser_gameNestedInputSchema).optional(),
chats: z.lazy(() => ChatUncheckedUpdateManyWithoutUser_gameNestedInputSchema).optional()
}).strict();
@ -3483,7 +3507,7 @@ export const User_GameUncheckedUpdateManyWithoutUsersInputSchema: z.ZodType<Pris
id: z.union([ z.string().cuid(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
createdAt: z.union([ z.coerce.date(),z.lazy(() => DateTimeFieldUpdateOperationsInputSchema) ]).optional(),
userId: z.union([ z.string(),z.lazy(() => StringFieldUpdateOperationsInputSchema) ]).optional(),
isOwner: z.union([ z.boolean(),z.lazy(() => BoolFieldUpdateOperationsInputSchema) ]).optional(),
index: z.union([ z.lazy(() => PlayerNSchema),z.lazy(() => EnumPlayerNFieldUpdateOperationsInputSchema) ]).optional(),
}).strict();
export const MoveCreateManyUser_gameInputSchema: z.ZodType<Prisma.MoveCreateManyUser_gameInput> = z.object({

View file

@ -91,17 +91,23 @@ model Gamepin {
game Game @relation(fields: [gameId], references: [id], onDelete: Cascade)
}
enum PlayerN {
player1
player2
}
model User_Game {
id String @id @default(cuid())
createdAt DateTime @default(now())
gameId String
userId String
isOwner Boolean
index PlayerN
moves Move[]
chats Chat[]
game Game @relation(fields: [gameId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id])
@@unique([gameId, index])
@@unique([gameId, userId])
}
@ -111,6 +117,8 @@ model Move {
index Int
user_game_id String
user_game User_Game @relation(fields: [user_game_id], references: [id], onDelete: Cascade)
@@unique([user_game_id, index])
}
model Chat {