Skip to content

@sqlrooms/documents / BlockDocumentAiAdapter

Type Alias: BlockDocumentAiAdapter ​

BlockDocumentAiAdapter = object

Generic adapter for AI tools that mutate or inspect a block document.

Methods ​

setCurrentBlockDocument() ​

setCurrentBlockDocument(blockDocumentId): void

Set the current active block document, if the host tracks one.

Parameters ​

ParameterType
blockDocumentIdstring

Returns ​

void


ensureBlockDocument() ​

ensureBlockDocument(blockDocumentId): void

Ensure the target block document exists before mutation.

Parameters ​

ParameterType
blockDocumentIdstring

Returns ​

void


getBlocks() ​

getBlocks(blockDocumentId): BlockDocumentNode[] | undefined

Read the target block document nodes.

Parameters ​

ParameterType
blockDocumentIdstring

Returns ​

BlockDocumentNode[] | undefined


addBlock() ​

addBlock(blockDocumentId, block): string | Promise<string>

Append a block to the target block document and return its block ID.

Parameters ​

ParameterType
blockDocumentIdstring
block{ id: string; intent?: string; type: "heading"; level: 1 | 2 | 3; text: BlockDocumentNode[]; } | { id: string; intent?: string; type: "paragraph"; text: BlockDocumentNode[]; } | { id: string; intent?: string; type: "list"; ordered?: boolean; items: BlockDocumentNode[][]; } | { id: string; intent?: string; type: "todo"; checked: boolean; text: BlockDocumentNode[]; } | { id: string; intent?: string; type: "image"; assetId: string; caption?: string; } | { id: string; intent?: string; type: "chartImage"; assetId: string; caption?: string; } | { id: string; intent?: string; type: "chart"; tableName: string; config: unknown; selectionGroupId?: string; caption?: string; } | { id: string; intent?: string; type: "statefulBlock"; blockType: string; blockInstanceId: string; ownership?: "owned" | "shared" | "external"; caption?: string; tableName?: string; height?: number; }

Returns ​

string | Promise<string>


updateBlock()? ​

optional updateBlock(blockDocumentId, blockId, block): void | Promise<void>

Update an existing block in place, if supported by the host.

Parameters ​

ParameterType
blockDocumentIdstring
blockIdstring
block{ id: string; intent?: string; type: "heading"; level: 1 | 2 | 3; text: BlockDocumentNode[]; } | { id: string; intent?: string; type: "paragraph"; text: BlockDocumentNode[]; } | { id: string; intent?: string; type: "list"; ordered?: boolean; items: BlockDocumentNode[][]; } | { id: string; intent?: string; type: "todo"; checked: boolean; text: BlockDocumentNode[]; } | { id: string; intent?: string; type: "image"; assetId: string; caption?: string; } | { id: string; intent?: string; type: "chartImage"; assetId: string; caption?: string; } | { id: string; intent?: string; type: "chart"; tableName: string; config: unknown; selectionGroupId?: string; caption?: string; } | { id: string; intent?: string; type: "statefulBlock"; blockType: string; blockInstanceId: string; ownership?: "owned" | "shared" | "external"; caption?: string; tableName?: string; height?: number; }

Returns ​

void | Promise<void>