Something went wrong

Thank you for being patient! We're working hard on resolving the issue

API Reference - Lona Docs Log in

API Reference

Compact reference for the Lona SDK.

LonaSdk.Client

import { LonaSdk } from "@tento-lona";

const client = new LonaSdk.Client(config: ClientConfig);
MemberReturnsDescription
client.open(key)Promise<SheetHandle>Open a sheet by key
client.open({ ephemeral })Promise<SheetHandle>Create local sheet
client.setCurrentUser(userId)voidBind the active user for user-scoped row and sheet lookups
client.sheets.list()Promise<UserSheet[]>List all sheets
client.sheets.get(key)Promise<UserSheetWithRows>Get sheet with rows
client.sheets.create(attrs)Promise<UserSheetWithRows>Create a sheet
client.sheets.update(key, attrs)voidUpdate sheet metadata (debounced)
client.sheets.reorder(key, body)PromiseReorder sheet position
client.sheets.delete(key)Promise<void>Delete a sheet
client.sheets.getAcl(key)Promise<AccessEntry[]>List access control
client.sheets.grantAccess(key, acl)Promise<void>Grant access
client.sheets.revokeAccess(key, userId)Promise<void>Revoke access
client.rows.open(key)Promise<Row | null>Open a row by key (supports cross-user)
client.eventsEventsStoreReactive event index and mutations
client.calendarsCalendarClientConnected calendar management
client.tasksTasksClientTask CRUD operations
client.userUserClientUser profile operations
client.preferencesPreferencesClientUser preferences
client.themesThemeStoreTheme management

ClientConfig

FieldTypeRequiredDescription
storagePreferencesStorageyesPersistence backend (localStorage or in-memory)
platformSheetPlatformyesLayout queries and infrastructure (SheetPlatform.TEST for headless)
feedbackFeedbackDelegatenoUI feedback callbacks (defaults to FeedbackDelegate.NOOP)
invalidationInvalidationSinknoChange event sink (defaults to InvalidationSink.NOOP)
baseUrlstringnoAPI base URL (defaults to https://lona.so)
accessTokenstringnoPersonal access token

SheetHandle

Returned by client.open().

MemberReturnsDescription
sheet.idstringSheet ID
sheet.titlestring | nullSheet title
sheet.numFrozenRowsnumberNumber of frozen rows
sheet.rowsRowsAccessorFluent row operations
sheet.row(query)Row | nullFind row by query
sheet.row(query, variant)Row<V> | nullFind row with type-safe variant narrowing
sheet.tree()RowNode.TreeResolved row tree
sheet.cellsCellAccessorCell data access and subscriptions
sheet.cells.fetch(range)Promise<void>Fetch cells for all rows in NaiveDate.Range
sheet.cells.getRange(rowId)CellEntry[]Read cached cells (populated by fetch)
sheet.cells.onChange(cb)() => voidSubscribe to cell changes; returns unsubscribe
sheet.promote()Promise<void>Persist an ephemeral sheet
sheet.serialize()UserSheetWithRowsSerialize to wire format

RowQuery

Used by sheet.row(query) and sheet.rows.get(query):

FormExampleDescription
string"r_a1b2..."Match by row ID
{ id }{ id: "r_a1b2..." }Match by row ID
{ label }{ label: "Weight" }Match by label
{ type }{ type: "number" }Match by type
{ lookupKey }{ lookupKey: ":~calendar" }Match by lookup key

RowsAccessor

Accessed via sheet.rows.

MemberReturnsDescription
rows.listRow[]All rows in sheet
rows.get(query)Row | nullFind row by query
rows.add(attrs)Promise<Row>Add a row
rows.delete(rowId)Promise<void>Delete a row (with undo)
rows.move(rowId, opts)Promise<void>Move/reparent a row

NewRowBody (for rows.add)

FieldTypeRequiredDescription
typestringyesRow type
labelstringnoDisplay label
formulastringnoLisp formula
timeScalestringnoTime scale
attributesobjectnoType-specific attributes

RowClient

Accessed via client.rows. Provides standalone row access without sheet context, including cross-user rows.

MethodReturnsDescription
client.rows.open(key)Promise<Row | null>Open a row by key
client.rows.linkRow(sheetId, lookupKey, position?)Promise<void>Link a reserved or persisted lookup-key row to a sheet
client.rows.listLinkable()Promise<LinkableRow[]>List linkable reserved rows and user-owned lookup-key rows
client.rows.update(rowKey, patch)Promise<PatchRowResponse>Update a row's properties
client.rows.updateDebounced(rowKey, patch)voidUpdate with debouncing (fire-and-forget)
client.rows.checkLookupKeyExists(rowKey, excludeRowId?)Promise<LookupKeyExistsResponse>Check if a lookup key is in use

Row key formats:

FormatExampleDescription
:lookupKey:~weatherReserved/provider row (current user)
[user@email]:lookupKey[alice@x.com]:~weatherCross-user row (requires ACL)
r_<hex>r_a1b2c3d4...Row by UUID

Row

Represents a row in sheet.rows.list or returned by client.rows.open().

PropertyTypeDescription
idstringRow ID
typestringRow type identifier
labelstring | nullDisplay label
lookupKeystring | nullLookup key
formulastring | nullLisp formula
timeScaleTimeScaleCustomTime scale
attributesUntypedJson | nullType-specific attributes
isReadOnlybooleanWhether cells can be set
iconstring | nullRow icon
heightPxnumber | nullRow height in pixels

Methods

MethodReturnsDescription
row.is(type)booleanCheck if row is of a specific type
row.update(patch, actor?)Promise<void>Update row. Emits typed invalidation events per field
row.cells(range)Promise<CellEntry[]>Fetch cells for date range
row.cell(date)CellHandleProgressive cell handle for NaiveDate.Partial (awaitable)
row.setCell(date, data)Promise<void>Create or overwrite a cell
row.variantSheetRow.VariantLazy-cached, type-specific derived data. See Row variants

CellEntry

PropertyTypeDescription
datestringCell date ("YYYY-MM-DD")
endDatestring | undefinedEnd date for range cells
dataunknownCell value

CellHandle

Returned by row.cell(date). Implements PromiseLike so it can be awaited directly, and provides progressive callbacks for sync-aware loading.

MethodReturnsDescription
cell.onLoading(cb)thisCalled when no data is cached and fetch is pending
cell.onData(cb)thisCalled when data arrives (may re-fire on sync updates)
cell.onDataFull(cb)thisCalled only when sync is fully complete
cell.dispose()voidCancel all subscriptions
await cellCellEntry | nullResolves on first onDataFull

Callbacks are chainable and re-fire on every data/sync change.

SyncState

PropertyTypeDescription
statusstring"pending", "running", "complete", or "failed"
keysMap<string, SyncKeyStatus>Per-provider sync status

SheetPlatform

Injected via ClientConfig.platform. Provides layout queries and infrastructure.

CallbackRequiredDescription
installDebounce(baseUrl, accessCode)yesInstall TypedApi debounce backend
getMaxHeight()yesViewport height for layout
getMaxWidth()noSidebar width calculation
onFrozenRowOverflow(tried, max, maxHeight)noFrozen rows exceed viewport
onFrozenRowFit()noFrozen rows fit again
themeBackendnoTheme CSS application

FeedbackDelegate

Injected via ClientConfig.feedback. UI feedback for row operations.

CallbackReturnsDescription
confirmDelete(message)Promise<boolean>Confirm destructive action
warn(message, description?)voidShow a warning
showUndo(message, undo)voidShow undo notification with restore callback

InvalidationSink

Injected via ClientConfig.invalidation. Change event bus.

MethodReturnsDescription
emit(event)voidEmit an invalidation event
subscribe(cb)() => voidSubscribe to all events; returns unsubscribe

See Invalidation for event types and patterns.

Row types

header, text, number, group, formula, checkmark, graph, calendar, calendar-list, timeline, calendar-month, weather, timezone, block, logs, timeline, sticker, task, journal, data, data-canvas, data-series, data-renderer, ai-report

Rational

Fractional positions used for ordering sheets and rows.

MethodReturnsDescription
Rational.midpoint(upper?, lower?)RationalPosition between two bounds
Rational.nth(n)RationalInitial position for index n
rational.nnumberNumerator
rational.dnumberDenominator

midpoint computes the mediant: (a.n + b.n) / (a.d + b.d). With one bound, it positions just before/after. With no bounds, returns 1/1.

RowKey

Stable row reference. Use when you need a durable or serializable identifier.

MethodReturnsDescription
RowKey.parse(raw)RowKeyParse any format
RowKey.user(hex)RowKey.UserUser row
RowKey.lookup(key)RowKey.LookupLookup key
RowKey.reserved(key)RowKey.ReservedBuiltin or reserved key
RowKey.virtual(hex, preset)RowKey.VirtualVirtual child
RowKey.system(name, param?)RowKey.SystemSystem row
RowKey.pending(uuid?)RowKey.PendingLocal pending row
key.resolve()RowLocalIdResolve through the global registry

Guards

MethodNarrows to
key.isUser()RowKey.User
key.isLookup()RowKey.Lookup
key.isReserved()RowKey.Reserved
key.isVirtual()RowKey.Virtual
key.isSystem()RowKey.System
key.isPending()RowKey.Pending

Extractors

MethodReturnsDescription
key.toHex()Option<string>Hex string (user rows)
key.toUuid()Option<string>UUID string (user rows)
key.asLookup()Option<string>Lookup key string
key.asVirtual()Option<VirtualInfo>{ parentHex, preset }
key.asSystem()Option<SystemInfo>{ name }

RowLocalId

Interned row identity. Created through RowLocalId.Registry.

RowLocalId.Registry

MethodReturnsDescription
RowLocalId.Registry.instanceRegistryGlobal session registry
registry.resolve(key)RowLocalIdResolve or create
registry.alias(from, to)voidRegister alias
registry.get(key)Option<RowLocalId>Look up without creating
registry.setCurrentUser(userId)voidSet the active user scope
registry.currentUserOption<string>Current user scope
registry.promoteAnonymous(userId)voidRebind anonymous keys to a logged-in user