Thank you for being patient! We're working hard on resolving the issue
A complete walkthrough: connect to Lona and read sheet data.
export LONA_ACCESS_TOKEN="lona_pat_..."
import { LonaSdk, SheetPlatform } from "@tento-lona";
const client = new LonaSdk.Client({
accessToken: process.env.LONA_ACCESS_TOKEN,
storage: localStorage,
platform: SheetPlatform.TEST,
});
const sheets = await client.sheets.list();
for (const sheet of sheets) {
console.log(`${sheet.id} — ${sheet.title}`);
}
const handle = await client.open(sheets[0].id.toString());
console.log(`Opened: ${handle.title}`);
Every sheet has a tree of rows. Use handle.tree() to get the resolved tree
(with virtual children expanded):
const tree = handle.tree();
// Pretty-print the tree
console.log(tree.print(node => {
const row = handle.row(node.id.toString());
const type = row?.type ?? "?";
const label = row?.label ? ` "${row.label}"` : "";
return `[${type}]${label}`;
}));
Example output:
├── [header] "Header"
├── [calendar] "Work"
│ ├── [calendar-list]
│ └── [timeline]
├── [weather] "Weather"
│ ├── [data-canvas]
│ └── [data-series]
└── [text] "Notes"
for (const row of handle.rows.list) {
console.log(`${row.type}: ${row.label ?? "(no label)"}`);
console.log(` timescale: ${row.timeScale}`);
console.log(` lookupKey: ${row.lookupKey}`);
}
const tree = handle.tree();
// Get children of a specific node
const firstNode = tree.nodes[0];
const children = tree.children(firstNode.id);
console.log(`${firstNode.id} has ${children.length} children`);
// Find a node's parent
for (const child of children) {
const parentId = tree.parent(child.id);
console.log(` ${child.id} → parent: ${parentId}`);
}
const data = handle.serialize();
console.log(JSON.stringify(data, null, 2));
import { LonaSdk, SheetPlatform } from "@tento-lona";
const client = new LonaSdk.Client({
accessToken: process.env.LONA_ACCESS_TOKEN,
storage: localStorage,
platform: SheetPlatform.TEST,
});
const sheets = await client.sheets.list();
for (const s of sheets) {
const handle = await client.open(s.id.toString());
const tree = handle.tree();
console.log(`\n=== ${handle.title ?? s.id} ===`);
console.log(tree.print(node => {
const row = handle.row(node.id.toString());
const lookupKey = row?.lookupKey ? ` (${row.lookupKey})` : "";
return `[${row?.type}]${lookupKey}`;
}));
}