import { MutationCtx } from '../_generated/server'; import { Id } from '../_generated/dataModel'; import { engineInsertInput } from '../engine/abstractGame'; import { InputNames, InputArgs } from './inputs'; export async function insertInput( ctx: MutationCtx, worldId: Id<'worlds'>, name: Name, args: InputArgs, ): Promise> { const worldStatus = await ctx.db .query('worldStatus') .withIndex('worldId', (q) => q.eq('worldId', worldId)) .unique(); if (!worldStatus) { throw new Error(`World for engine ${worldId} not found`); } return await engineInsertInput(ctx, worldStatus.engineId, name, args); }