feat!: TextBlock.make / DataBlock.make return { id, ops } and accept a stable id - #99
Merged
Merged
Conversation
…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.
Contributor
|
sorry for the delay, but need to think if we might want to have a different API |
nikgraf
approved these changes
Jul 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
From the editor tooling team's July 14 page-blocks QA (doc shared with Preston), items 2 and 5:
TextBlock.makeandDataBlock.makeminted a hidden fresh entity id on every call and returned onlyOp[]. Two consequences:createEntity,createRelation) already returns it.Change
Both helpers now return a
CreateResult({ id, ops }), consistent with the rest of the SDK, and accept an optional validatedidparam: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
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
mainbaseline: identical results plus the new tests — the onlyfailing files on both runs are the two e2e suites, which require a
PRIVATE_KEYenv and fail identically on unmodified
main.