createCommand()
function createCommand<T>(
type: T,
args: SyncCommandsMap[T],
tempId?: string): SyncCommand<T>;
Creates a strongly-typed Sync API command with an auto-generated UUID.
Type Parameters
| Type Parameter |
|---|
T extends keyof SyncCommandsMap |
Parameters
| Parameter | Type | Description |
|---|---|---|
type | T | The command type (e.g. 'item_add', 'project_update'). |
args | SyncCommandsMap[T] | The command arguments, constrained by the command type. |
tempId? | string | Optional temporary ID for referencing the created resource in subsequent commands. |
Returns
SyncCommand<T>
A fully formed SyncCommand ready to include in a sync request.
Example
const cmd = createCommand('item_add', { content: 'Buy milk', priority: 2 })
// cmd.type === 'item_add'
// cmd.args is typed as TaskAddArgs