import type { GameModelAPI } from '../domains/gameModel.js'; import type { Scalars } from '../generated/graphql.js'; import { type KitOwnerIdKind } from './blueprints/index.js'; import { type KitInvokeResult } from './shared.js'; /** Options for {@link InventoryKit}. Must match the deployed blueprint's options. */ export interface InventoryKitOptions { /** The `typePrefix` the inventory blueprint was deployed with. */ typePrefix?: string; /** Must match inventoryBlueprint.ownerIdKind. Defaults to `int`. */ ownerIdKind?: KitOwnerIdKind; } /** A parsed view of one item stack. */ export interface KitItemStack { containerId: string; displayName: string; ownerUserId: string | null; itemId: string; quantity: number; slot: number; } /** * Runtime helpers for the {@link inventoryBlueprint} conventions: find or * create the player's inventory, list stacks, and mutate them through the * owner-gated model functions. All state lives server-side; every mutation is * authority-checked and atomic. * * Obtained via `client.kit(appId).inventory`. */ export declare class InventoryKit { private readonly appId; private readonly gameModel; private readonly names; private readonly typePrefix; private readonly ownerIdKind; constructor(appId: Scalars['BigInt']['input'], gameModel: GameModelAPI, options?: InventoryKitOptions); /** * Find the caller's inventory container, creating it when absent. The * server assigns ownership to the caller (the type is member-instantiable * and `ownerUserId` is omitted on create). * * @param ownerUserId - The calling player's user id (a decimal string, e.g. * from `client.users.me()`), used to recognize an existing inventory. */ ensure(ownerUserId: Scalars['BigInt']['input'], options?: { displayName?: string; sessionId?: string; }): Promise<{ __typename?: "GmContainer"; containerId: string; appId: string; sessionId: string | null; typeName: string; displayName: string; description: string | null; ownerUserId: string | null; metadataJson: string; }>; /** * List a player's item stacks with parsed properties (`itemId`, `quantity`, * `slot`). Fetches each stack's visible state in parallel. */ stacks(ownerUserId: Scalars['BigInt']['input']): Promise; /** * Create a new stack owned by the caller (server-assigned ownership). * Use {@link grant} afterwards for authority-checked increments; the initial * quantity here is a seed value on a container the caller owns anyway. * * Pass `ownerUserId` (the caller's own user id) to also set the * `owner_user_id` mirror property that cross-container guards (economy * trades / market listings) verify. */ createStack(input: { itemId: string; quantity?: number; slot?: number; displayName?: string; sessionId?: string; ownerUserId?: Scalars['BigInt']['input']; }): Promise<{ __typename?: "GmContainer"; containerId: string; appId: string; sessionId: string | null; typeName: string; displayName: string; description: string | null; ownerUserId: string | null; metadataJson: string; }>; /** Add items to a stack the caller owns. Resolves with the new quantity. */ grant(stackId: string, amount: number): Promise>; /** * Spend items from a stack the caller owns. The server refuses to overdraw * (`success: false`, nothing written). Resolves with the new quantity. */ consume(stackId: string, amount: number): Promise>; /** Move a stack to another slot. Resolves with the new (clamped) slot. */ move(stackId: string, toSlot: number): Promise>; /** * Atomically move items between two stacks of the same item type — both * writes commit or neither does. The caller must own the source stack. * Resolves with the source stack's remaining quantity. */ transfer(fromStackId: string, toStackId: string, amount: number): Promise>; /** * Atomically craft a recipe generated by inventoryBlueprint: every input * decrement and the output grant commit together. A failed guard writes * nothing. `inputStackIds` must follow the recipe input order. */ craft(inventoryId: string, recipeId: string, inputStackIds: string[], outputStackId: string): Promise>; /** Atomically execute a generated item-for-item barter offer. */ barter(inventoryId: string, barterId: string, payStackId: string, receiveStackId: string): Promise>; /** * Record that a stack belongs to an inventory with an * `inventory_contains` edge, so {@link contents} can read the whole bag in * one traversal. */ linkStack(inventoryId: string, stackId: string): Promise<{ __typename?: "GmEdge"; edgeId: string; fromContainerId: string; toContainerId: string; relationshipType: string; weight: number | null; }>; /** Read every stack linked to an inventory (via `inventory_contains` edges). */ contents(inventoryId: string): Promise; } //# sourceMappingURL=inventory.d.ts.map