Skip to content

feat!: TextBlock.make / DataBlock.make return { id, ops } and accept a stable id - #99

Merged
nikgraf merged 2 commits into
geobrowser:mainfrom
0xTaneja:feat/block-make-returns-id
Jul 30, 2026
Merged

nikgraf merged 2 commits into
geobrowser:mainfrom
0xTaneja:feat/block-make-returns-id

Conversation

@0xTaneja

Copy link
Copy Markdown
Contributor

What

From the editor tooling team's July 14 page-blocks QA (doc shared with Preston), items 2 and 5: TextBlock.make and DataBlock.make minted a hidden fresh entity id on every call and returned only Op[]. Two consequences:

  • You cannot reference the block you just made - setting a view, choosing columns, or building idempotent re-runs all need the block's id, and every other op builder (createEntity, createRelation) already returns it.
  • Re-running the same publish duplicates every block (five text blocks become ten): each run mints new ids, and nothing platform-side deduplicates.

Change

Both helpers now return a CreateResult ({ id, ops }), consistent with the rest of the SDK, and accept an optional validated id param:

const { id, ops } = TextBlock.make({
  fromId: pageId,
  text: '# Heading',
  id: blockId, // optional and will be generated if not provided
});

Passing a stable, deterministically derived id makes re-publishes detectable: a script can check whether the block already exists and skip it instead of minting a duplicate on every run. This is the script-side discipline the QA doc describes as the current workaround - this API makes it possible without reimplementing the helpers.

BREAKING CHANGE

// before
const ops = TextBlock.make({ ... });
// after
const { ops } = TextBlock.make({ ... });

No in-repo call sites were affected. Changeset included (minor, with migration note).

Tests

7 new tests across both helpers: returned id matches the ids inside the ops,
provided id is honored and deterministic across calls, invalid ids throw, and a
dashed UUID encodes to the same bytes as its dashless form. Full suite verified
against a clean main baseline: identical results plus the new tests — the only
failing files on both runs are the two e2e suites, which require a PRIVATE_KEY
env and fail identically on unmodified main.

…t a stable id

The block helpers minted a hidden fresh entity id on every call and
returned only Op[], so callers could not reference the block they just
created (views, columns) and every re-run of the same publish minted a
duplicate block. Return a CreateResult ({ id, ops }) like createEntity
and createRelation, and accept an optional validated id param: a script
that derives the block id deterministically can check for the block's
existence and skip re-publishing instead of duplicating content.

BREAKING CHANGE: const ops = TextBlock.make(...) becomes
const { ops } = TextBlock.make(...); same for DataBlock.make.
@0xTaneja
0xTaneja requested a review from nikgraf July 22, 2026 14:46
@nikgraf

nikgraf commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

sorry for the delay, but need to think if we might want to have a different API

@nikgraf
nikgraf merged commit d2eb23d into geobrowser:main Jul 30, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants