Skip to main content

SyncCommand<Type>

type SyncCommand<Type> = {
args: Type extends SyncCommandType ? SyncCommandsMap[Type] : Record<string, unknown>;
tempId?: string;
type: Type;
uuid: string;
};

A strongly-typed Sync API command.

When Type is a known command type (e.g. 'item_add'), args is constrained to the corresponding argument type. For unknown command types, args falls back to Record<string, unknown>.

Example

// Strongly typed:
const cmd: SyncCommand<'item_add'> = {
type: 'item_add',
uuid: 'abc-123',
args: { content: 'Buy milk' },
}

// Untyped (backwards compatible):
const cmd2: SyncCommand = {
type: 'custom_command',
uuid: 'def-456',
args: { foo: 'bar' },
}

Type Parameters

Type ParameterDefault type
Type extends SyncCommandType | stringstring

Properties

args

args: Type extends SyncCommandType ? SyncCommandsMap[Type] : Record<string, unknown>;

tempId?

optional tempId: string;

type

type: Type;

uuid

uuid: string;