@notionhq/custom-blocks-dev-shell 0.3.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/bindings.md CHANGED
@@ -1,11 +1,7 @@
1
1
  # Dev shell bindings
2
2
 
3
- A binding connects a data source declared by a custom block to local sample data and maps the
4
- block's property keys to source properties. This guide covers source selection, property mappings,
5
- and changes to bindings while running in the dev shell.
6
-
7
- Use launcher flags to select sample files and map properties at startup. You can also edit bindings
8
- in **Data**. The block initializes once every declared data source and property is connected.
3
+ A binding connects a block’s declared data source and properties to a sample file. Set bindings with
4
+ launcher flags or in **Bindings → Data access**.
9
5
 
10
6
  Each data source selects its file in this order:
11
7
 
@@ -56,8 +52,8 @@ already selects a file by its default filename. Flag order does not affect sourc
56
52
 
57
53
  An unknown or ambiguous target, duplicate property target, missing source, missing source property,
58
54
  or property type mismatch stops startup. Other properties can remain unmapped until you connect them
59
- in **Data**. If the data source file cannot load, its property mappings remain unvalidated until you
60
- fix and save the file.
55
+ in **Bindings → Data access**. If the data source file cannot load, its property mappings remain
56
+ unvalidated until you fix and save the file.
61
57
 
62
58
  ## Binding errors
63
59
 
@@ -89,21 +85,25 @@ Repeating a full target fails even when both values are identical. The same prop
89
85
  different slots or blocks is allowed. Multiple declared properties can share a source property when
90
86
  their types match.
91
87
 
92
- ## Edit bindings in Data
88
+ ## Edit bindings
89
+
90
+ Open **Bindings → Data access** to select files from your worker’s `data/` directory and map their
91
+ properties. See the [sample data format](data-sources.md) to define a source. **Done** applies
92
+ changes. Closing the dialog or pressing Escape discards them.
93
93
 
94
- Open **Data** in the toolbar to select a source and map properties for each declared data source
95
- slot. The modal lists your worker's `data/*.json` files. See the
96
- [sample data format](data-sources.md) to define a source.
94
+ **Page access** appears only when the manifest declares `pages`. It lists the declarations. Page
95
+ bindings are not supported yet.
97
96
 
98
97
  A property maps automatically only when exactly one source property matches its key or name and has
99
98
  the same type. If no property matches, or several properties match, the property stays unmapped.
100
- Open **Data** to select a mapping. Selecting a different source resets its property mappings.
99
+ Select a mapping manually when automatic matching leaves it unmapped. Selecting a different source
100
+ resets its property mappings.
101
101
 
102
102
  ## Initialization and refresh
103
103
 
104
- Once every slot is bound and every property mapped, the block initializes and renders. Saving
105
- binding changes restarts the block with the updated data. If initialization fails, fix the bindings
106
- and save.
104
+ Once every declared data source and property is mapped, the shell mounts the preview. Applying
105
+ binding changes with **Done** restarts the block with the updated data. If initialization fails
106
+ because of a binding error, fix the bindings and select **Done** again.
107
107
 
108
108
  The shell keeps binding selections separately for each block until you refresh the browser. Refresh
109
109
  the shell to restore each block's CLI source and property selections, with automatic matching for
@@ -111,9 +111,3 @@ properties without an override.
111
111
 
112
112
  See [live updates and local writes](data-sources.md#live-updates-and-local-writes) for state
113
113
  resets and error recovery.
114
-
115
- ## Data view
116
-
117
- Click a data source in the sidebar to inspect its schema and rows. This view is read-only. Sources
118
- connected to the selected block show a green **Bound** label. The data panel shows the file path.
119
- Use **Copy path** to copy it relative to the worker root.
@@ -4,8 +4,8 @@ The bridge protocol defines the messages exchanged by a custom block's SDK and i
4
4
  changelog records breaking contract changes and the SDK releases that introduced them. It also
5
5
  describes compatibility exceptions within a declared protocol version and their effects on blocks.
6
6
  Protocol version rules are in [Bridge protocol versioning](versioning.md). The host's
7
- [compatibility reference](../host/docs/compatibility.md) describes current support and response
8
- conversions.
7
+ [connection reference](../host/docs/compatibility.md) describes current negotiation and version
8
+ requirements.
9
9
 
10
10
  Dates refer to npm releases in Pacific time, not deployment in Notion. Planned entries show the
11
11
  expected package version and release date. Unqualified SDK versions refer to
@@ -20,20 +20,54 @@ expected package version and release date. Unqualified SDK versions refer to
20
20
  | 5 [†](#protocol-5-unavailable-containing-page-context) | `0.2.16` · 2026-09-30 | `0.1.25` · 2026-10-02 | `0.1.79` · 2026-09-30 | Query filters and sorts must address actual database properties. Filter and sort payloads reject extra fields |
21
21
  | 6 [‡](#protocol-6-richer-fallback-properties) | `0.3.0` · 2026-10-26 | `0.2.21` · 2026-10-22 | `0.1.105` · 2026-10-22 | Typed, display-name-keyed query properties and unified page responses replace the older query representation |
22
22
  | 7 | `0.3.3` · 2026-10-30 | `0.3.11` · 2026-10-30 | `0.1.115` · 2026-10-30 | Typed text fallback properties for unique ID, button, formula, location, rollup, and verification |
23
- | 8 | `0.3.4` · 2026-11-03 | `0.4.0` · 2026-11-02 | `0.1.116` · 2026-11-05 | Local manifests move from `/manifest` to HTML metadata sent in `connect`; `manifestSource` selects the initialization manifest |
24
- | 9 | — | `0.6.0` · 2026-11-05 | — | Native page icons; older protocols receive external SVG URLs |
23
+ | 8 | `0.3.4` · 2026-11-03 | `0.4.0` · 2026-11-02 | `0.1.116` · 2026-11-05 | Local manifests move from `/manifest` to HTML metadata sent in `connect`. `manifestSource` selects the initialization manifest |
24
+ | 9 | — | `0.6.0` · 2026-11-05 | — | Native page icons. Older protocols receive external SVG URLs |
25
25
  | 10 | `0.4.0` · 2026-11-11 | `0.7.0` · 2026-11-10 | `0.2.0` · 2026-11-10 | Removes `last_visited_time` from property schemas, page properties, and page metadata |
26
- | 11 | `0.5.0` · 2026-11-13 | `0.10.0` · 2026-11-13 | `0.3.1` · 2026-11-13 | Removes `location` from manifests, binding schemas, and page properties; renames data source binding fields |
26
+ | 11 | `0.5.0` · 2026-11-13 | `0.10.0` · 2026-11-13 | `0.3.1` · 2026-11-13 | Removes `location` from manifests, binding schemas, and page properties. Renames data source binding fields |
27
27
 
28
28
  `—` means no release in that package line carried that specific protocol version.
29
29
 
30
- Host compatibility depends on `connect.bridgeProtocolVersion`, not the SDK package version.
30
+ Host compatibility depends on the protocol version selected during `connect`, not the SDK package
31
+ version.
31
32
 
32
33
  Native host package pins and protocol mappings are tracked separately in
33
34
  [Notion's native host configuration](https://github.com/makenotion/notion-next/blob/main/src/cli/mobile/codegen/customBlockHost/config.ts)
34
35
  and
35
36
  [mobile shell registry](https://github.com/makenotion/notion-next/blob/main/src/cloudflare-customBlockWorker/lib/mobileShellRegistry.ts).
36
37
 
38
+ ## Protocol 12: minimal handshake and post-init reads (unreleased)
39
+
40
+ Protocol 12 negotiates a version with `connect` and `connectResult`, then sends setup-only `init`
41
+ with its own request ID, fixed `instance` identity, manifest, and
42
+ `preferences: { theme, contrastMode }`. `initResult` acknowledges setup. A separate
43
+ `ready { initialHeight }` permits reveal. Protocols 3–11 retain their handshake and eager payloads.
44
+
45
+ After acknowledgment, `parentChanged` and `pageChanged` deliver initial resolved location values and
46
+ later changes without sandbox requests. Unresolved parent and containing page values do not delay
47
+ setup. `getCurrentUser` and `getDataSource` requests load profiles and source metadata
48
+ independently. Binding refresh uses `dataSourcesInvalidated`. Raw-ID page operations remain
49
+ unchanged.
50
+
51
+ Host support is [#713](https://github.com/makenotion/custom-blocks/pull/713). SDK domains and React
52
+ states follow in [#716](https://github.com/makenotion/custom-blocks/pull/716) and
53
+ [#717](https://github.com/makenotion/custom-blocks/pull/717). Publish the SDK after host adoption.
54
+ Host-owned key resolution, grants, and pagination remain future work.
55
+
56
+ Full profiles require `name: string | null`. The `makeBridgeUser` builder supplies `null` when its
57
+ caller omits the name. Protocols 3–11 retain omitted names on the wire for deployed SDKs. Empty
58
+ strings remain unchanged.
59
+
60
+ Containing-page notifications include `displayMode`: `"full_page"`, `"side_peek"`, or
61
+ `"center_peek"`, defaulting to `"full_page"` outside peek presentation. SDK containing-page
62
+ descriptors preserve this field, and mode-only changes use the existing `pageChanged` notification.
63
+ The shared host also reports known parent/page failures through `parentError` and `pageError`. Later
64
+ value notifications recover each field.
65
+
66
+ ## Optional query limit metadata
67
+
68
+ Query results can include optional `limitClamp` metadata when a host reduces the requested limit.
69
+ Older SDKs ignore the field, so the protocol version remains 11.
70
+
37
71
  ## Protocol 11: location removal and data source binding names
38
72
 
39
73
  Current bindings use `dataSourceSchema` and `dataSourcePointer` in `init` and `dataSourcesChanged`.
@@ -41,9 +75,15 @@ Current SDK types and host APIs use the same names. The host encodes `collection
41
75
  `collectionPointer` for supported protocols 3–10 only at its outgoing boundary. Protocols 3–4 still
42
76
  receive synthetic metadata schemas there.
43
77
 
44
- Publish and deploy the updated host before adopting the new SDK. Native host generation and mobile
45
- shell registration must use the published release; the planned releases are SDK 0.5.0, host 0.10.0,
46
- and dev shell 0.3.1.
78
+ SDK 0.5.1 adds incoming compatibility for the `collectionSchema` and `collectionPointer` names sent
79
+ by older hosts such as 0.9.0. It normalizes these fields in both `init` and `dataSourcesChanged`,
80
+ while retaining the protocol 11 names in the SDK API. Current fields take precedence when both names
81
+ are present, and both encodings remain validated. This patch keeps protocol 11. It does not add
82
+ older-host operations or change Notion's persisted binding format.
83
+
84
+ SDK 0.5.0 requires host 0.10.0 or dev shell 0.3.1 for the renamed binding fields. Native host
85
+ generation and mobile shell registration must use the published host release to send the current
86
+ encoding.
47
87
 
48
88
  `location` represents the source of an item in Notion's aggregated views. Protocol 11 removes it
49
89
  from manifests, binding schemas, and page property values. Updated hosts omit it for every supported
@@ -65,13 +105,13 @@ writes share a loose shape: names and colors accept strings, color is optional,
65
105
  native icon fields are retained. Hosts resolve names and default omitted colors to gray.
66
106
 
67
107
  Protocols 3–8 receive external SVG URLs in page operation results. Protocols 6–8 receive the same
68
- fallback in query results; protocols 3–5 keep their flat query format without appearance fields. The
108
+ fallback in query results. Protocols 3–5 keep their flat query format without appearance fields. The
69
109
  released-SDK compatibility corpus exercises these conversions.
70
110
 
71
111
  ## Protocol 8: local manifest declarations
72
112
 
73
113
  The dev shell removes the `/manifest` route and embeds the local manifest in block HTML. The SDK
74
- reads that metadata and sends the declaration in `connect.manifest`; initialization no longer
114
+ reads that metadata and sends the declaration in `connect.manifest`. Initialization no longer
75
115
  fetches `/manifest`.
76
116
 
77
117
  The host option `manifestSource` selects the initialization manifest: `"sandbox"` uses the
@@ -89,7 +129,7 @@ from `connect`.
89
129
 
90
130
  Bridge NACKs (`invalidHostMessage` and `invalidSandboxMessage`) gain an optional string `requestId`.
91
131
  Updated SDKs complete the matching request immediately when a rejection can be correlated. Older
92
- readers ignore the additional field; updated readers continue to accept NACKs without an ID.
132
+ readers ignore the additional field. Updated readers continue to accept NACKs without an ID.
93
133
  Uncorrelated requests use the SDK's 60-second timeout. This additive change retains protocol 8.
94
134
 
95
135
  ### Protocol 5: unavailable containing-page context
@@ -97,8 +137,7 @@ Uncorrelated requests use the SDK's 60-second timeout. This additive change reta
97
137
  On October 2, 2026, SDK 0.2.17 added `{ type: "unavailable" }` to containing-page context while
98
138
  retaining protocol 5. SDK 0.2.16 rejects that shape. The host preserves later protocol 5 behavior
99
139
  and accepts the limitation for the older SDK, as decided on October 31, 2026. Affected blocks must
100
- upgrade and rebuild. The host's [compatibility reference](../host/docs/compatibility.md)
101
- describes current compatibility behavior.
140
+ upgrade and rebuild.
102
141
 
103
142
  ### Protocol 6: richer fallback properties
104
143
 
@@ -114,5 +153,5 @@ properties to every protocol 6 block.
114
153
  Blocks built with the later protocol 6 SDKs therefore lose those property values when their host
115
154
  updates. UI that displays the values can become empty, and code that assumes a property object is
116
155
  present can fail. Upgrade the SDK to protocol 7 or later and rebuild the block to receive the text
117
- fallback property objects. Host adapters continue returning the current page shape; the host runtime
156
+ fallback property objects. Host adapters continue returning the current page shape. The host runtime
118
157
  applies the protocol-specific conversion.
@@ -6,63 +6,133 @@ semantics for host integrators and bridge maintainers. Block authors use the SDK
6
6
 
7
7
  Messages are `postMessage` payloads defined by shared Valibot schemas, exposed through
8
8
  `@notionhq/custom-blocks-host/protocol`. The embedding application enforces permissions and record
9
- access. Version-specific formats and conversions are described in
10
- [Versioning and compatibility](versioning.md).
9
+ access. This reference describes protocol 12. See
10
+ [Connection compatibility](../host/docs/compatibility.md) for host version requirements.
11
11
 
12
12
  ## Initialization
13
13
 
14
- The handshake is:
14
+ The sandbox connects, applies setup, and reports when its first render is ready:
15
15
 
16
16
  ```text
17
- sandbox connect → host init → sandbox initResult
17
+ sandbox connect → host connectResult → host init → sandbox initResult → sandbox ready
18
18
  ```
19
19
 
20
- All three messages carry the sandbox-generated `initializationId`. A sandbox document sends
21
- `connect` once. The host sends one `init` for the accepted connection and ignores subsequent
22
- `connect` messages, including malformed ones. Live updates wait for `initResult.success`.
23
- `init.error` and `initResult.error` are terminal.
20
+ The sandbox sends `connect` with a `requestId` and `supportedProtocolVersions`, a nonempty list of
21
+ distinct positive integers. This host selects protocol 12 if offered and permitted by its configured
22
+ minimum. Otherwise, it returns `connectResult` with `status: "error"` and
23
+ `unsupported_protocol_version`.
24
24
 
25
- The sandbox waits for `init` without a timeout. If host state preparation times out, the host sends
26
- `init.error` with `initial_state_timeout` to end that wait.
25
+ The host prepares the manifest and initial appearance values, then sends `connectResult` with
26
+ `status: "success"` and `protocolVersion: 12`. Preparation errors return `connectResult` with
27
+ `status: "error"`. The host then sends `init` with a separate `requestId`. A successful `initResult`
28
+ acknowledges setup and permits data operations.
27
29
 
28
- `connect` carries connection identity, version metadata, and an optional local manifest declaration.
29
- The SDK reads that declaration from the `application/json` script with ID
30
- `notion-custom-block-manifest`, injected into the block HTML by dev tooling. It reads metadata only
31
- from supported local block server URLs. Missing metadata omits `connect.manifest`; invalid metadata
32
- sends `connect.error` with `manifest_invalid`.
30
+ After its first render, the SDK sends `ready` with `initialHeight` in CSS pixels. The embedding
31
+ application applies the height before revealing the iframe. Later `resize` notifications update
32
+ height without changing readiness. Notifications have no correlation ID and need no acknowledgment.
33
33
 
34
- The embedding application selects the manifest source. In host mode, the host uses its persisted
35
- manifest and ignores the sandbox declaration. In sandbox mode, the host uses `connect.manifest` from
36
- a permitted local sandbox; a missing declaration produces `manifest_unavailable`. The selected
37
- manifest is authoritative and is returned in `init` with context and data source bindings. Errors
38
- from the selected manifest source pass through unchanged. Host mode can initialize after a sandbox
39
- `manifest_invalid` error using its own manifest; other connect errors remain fatal. The connect
40
- parser discards unknown properties.
34
+ The host bounds connection negotiation, setup acknowledgment, and the wait for the first render.
35
+ Missing readiness fails with `ready_timeout`. The host's
36
+ [lifecycle guide](../host/docs/lifecycle.md) describes the timeouts and state callbacks.
41
37
 
42
- `initResult.success` may include `initialHeight`, the height of the sandbox's rendered content in
43
- CSS pixels. The host's [lifecycle guide](../host/docs/lifecycle.md) describes iframe sizing,
44
- reveal, and retry behavior.
38
+ `connect` also carries `sdkVersion` for analytics and an optional local manifest. The SDK reads the
39
+ manifest from the `application/json` script with ID `notion-custom-block-manifest`, injected into
40
+ block HTML by dev tooling. The SDK reads this metadata only on supported local block server URLs.
41
+ Missing metadata omits `connect.manifest`. Sandbox mode requires that declaration and reports
42
+ `manifest_unavailable` if it is missing.
45
43
 
46
- `connect.bridgeProtocolVersion` declares the sandbox's wire contract. `sdkVersion` is analytics
47
- metadata. See [versioning and compatibility](versioning.md) for supported formats and
48
- [Validation and errors](#validation-and-errors) for malformed handshake behavior.
44
+ The embedding application selects the manifest source. Host mode uses the persisted manifest.
45
+ Sandbox mode uses the declaration from a permitted local sandbox. The selected manifest is returned
46
+ in `init`. The connect parser discards unknown properties.
47
+
48
+ ### Init payload and explicit reads
49
+
50
+ The host sends the selected manifest and initial appearance values in a correlated request:
51
+
52
+ ```ts
53
+ {
54
+ type: "init",
55
+ requestId,
56
+ instance: { type: "view", viewId },
57
+ manifest,
58
+ preferences: { theme, contrastMode },
59
+ }
60
+ ```
61
+
62
+ The SDK acknowledges setup without reporting height:
63
+
64
+ ```ts
65
+ { type: "initResult", requestId, status: "success" }
66
+ ```
67
+
68
+ `ready.initialHeight` must be finite and nonnegative.
69
+
70
+ The host waits for theme and contrast mode, but does not load user profiles, page data, or source
71
+ metadata for init. `preferences` groups fields only in `init`. Later updates use `themeChanged` and
72
+ `contrastModeChanged`.
73
+
74
+ After a successful `initResult`, data operations are available regardless of render readiness. The
75
+ following requests read the current user profile and one data source binding:
76
+
77
+ | Request | Success result |
78
+ | ------------------------------------------- | ------------------------------------------------------------------------------------------------- |
79
+ | `{ type: "getCurrentUser", requestId }` | `{ type: "getCurrentUserResult", requestId, status: "success", user: BridgeUser }` |
80
+ | `{ type: "getDataSource", requestId, key }` | `{ type: "getDataSourceResult", requestId, status: "success", binding: BridgeDataSourceBinding }` |
81
+
82
+ A failure returns `{ type: "<request type>Result", requestId, status: "error", error }` and leaves
83
+ other operations available. User reads return the full profile, including email. Source reads
84
+ resolve metadata for a declared binding. Page operations and queries address raw record IDs.
85
+
86
+ Configuration refresh aborts pending operations and queries, clears source metadata, and sends
87
+ `{ type: "dataSourcesInvalidated" }`. The SDK reads replacement metadata when an operation needs it.
88
+ Results from the previous configuration cannot repopulate its cache.
89
+
90
+ `init.instance` identifies the configured instance. `customBlockInstanceSchema` accepts
91
+ `{ type: "block" | "page", blockId }` or `{ type: "view", viewId }`. `CustomBlockInstance` is the
92
+ inferred type. Block and page IDs use `NotionBlockId`. View IDs use `NotionViewId`. The identity is
93
+ fixed for the connection and does not require a change notification.
94
+
95
+ After setup acknowledgment, the host sends `parentChanged { parent }` and `pageChanged { page }`
96
+ with their current resolved values. Unresolved values are sent when available. Later parent,
97
+ containing page, theme, and contrast mode changes use their respective change messages. The host
98
+ sends notifications without sandbox requests or subscription messages. Stopping suppresses late
99
+ delivery.
100
+
101
+ `pageChanged.page` includes `displayMode: "full_page" | "side_peek" | "center_peek"` on an
102
+ accessible page. The mode describes this block's own container, not another open peek. The host
103
+ sends a complete page notification when the mode changes, even if its ID is unchanged. Hosts without
104
+ peek presentation use `full_page`. Unavailable pages expose no display metadata. This field is
105
+ separate from page content returned by page operations.
106
+
107
+ `parentError { error }` and `pageError { error }` report known location failures without failing
108
+ setup. A later `parentChanged` or `pageChanged` replaces the corresponding error. An unavailable
109
+ value is a successful access-limited result, not a load failure.
110
+
111
+ `setupInitMessageSchema` validates the setup payload.
112
+
113
+ ## Full user profiles
114
+
115
+ `BridgeUser` requires `name` and `avatar_url`. Each accepts a string or `null`. An omitted or
116
+ `undefined` name is invalid. Empty strings are preserved. The same profile shape applies to
117
+ current-user reads, user lookup, user lists, and profile updates. ID-only people references do not
118
+ promise a name or any other profile field.
49
119
 
50
120
  ## Manifests
51
121
 
52
122
  A manifest declares a block's data sources and display metadata. `manifestSchema` defines its fields
53
123
  and defaults omitted `dataSources` and each data source's omitted `properties` to `{}`.
54
124
 
55
- `isLocalBlockServerUrl(url)` accepts HTTP(S) URLs on `localhost`, `*.localhost`, or `127.0.0.1`
56
- without credentials. It checks the address only. The host also requires a sandbox-mode block to use
57
- a different origin from its embedding page.
125
+ `isLocalBlockServerUrl(url)` accepts HTTP or HTTPS URLs on `localhost`, `*.localhost`, or
126
+ `127.0.0.1` without credentials. It checks the address only. The host also requires a block in
127
+ sandbox mode to use a different origin from its embedding page.
58
128
 
59
129
  ## Message identity
60
130
 
61
- - One-shot request/result pairs use `requestId`.
62
- - `queryDataSource` is a long-lived subscription; requests and every update use its stable
131
+ - Requests and their results use `requestId`.
132
+ - `queryDataSource` starts a subscription. The request and every update use its stable
63
133
  `subscriptionId`.
64
- - The initialization lifecycle uses `initializationId`, not `requestId` or `subscriptionId`.
65
- - One-way messages, such as `resize`, have no correlation ID.
134
+ - `connect` and `init` each use their own `requestId`.
135
+ - Notifications, such as `ready` and `resize`, have no correlation ID.
66
136
  - Bridge NACKs include the rejected message's `requestId` when it is a string. The ID identifies the
67
137
  original request, including when the rejected message is its response.
68
138
 
@@ -91,32 +161,26 @@ request with `invalid_sandbox_message`. When the SDK rejects a host response, it
91
161
  matching request locally with `invalid_host_message` and includes the ID in `invalidHostMessage`.
92
162
  Both errors have `isRetryable: false`.
93
163
 
94
- One-shot SDK requests time out after 60 seconds. Missing, unreadable, or unknown IDs do not fail
95
- unrelated requests. NACK IDs are optional: older readers ignore them, and newer readers accept
96
- legacy NACKs without IDs. Those requests retain the timeout fallback.
164
+ SDK requests time out after 60 seconds. Missing, unreadable, or unknown IDs do not fail unrelated
165
+ requests. A NACK without a readable `requestId` cannot complete a pending request. That request
166
+ retains its timeout.
97
167
 
98
168
  Request completion clears its timer, removes the pending entry, and ignores duplicate or late
99
169
  results. Disposing the SDK completes pending calls locally with `request_disposed` and clears their
100
- timers. The SDK does not retry or cancel host work. A timed-out write may still complete; check its
101
- resulting state before repeating it. Data source subscriptions use a separate lifecycle.
102
-
103
- Malformed sandbox messages do not change the host's initialization state or timeout, except as
104
- follows:
170
+ timers. The SDK does not retry or cancel host work. A write may still complete after a timeout.
171
+ Check its resulting state before repeating it. Data source subscriptions use a separate lifecycle.
105
172
 
106
- - The host expects `connect` and receives a malformed `connect` with a readable `initializationId`.
107
- The host sends `init.error` instead of a NACK, then fails initialization. An invalid or
108
- unsupported numeric protocol version takes precedence over `invalid_connect_payload`.
109
- - The host expects `initResult` and receives a malformed `initResult` with the active
110
- `initializationId`. The host sends a NACK and fails initialization with
111
- `invalid_init_result_payload`. This error code describes a local host failure. The host does not
112
- send it in `initResult.error`.
173
+ A malformed `connect` with a readable `requestId` receives `connectResult.error` with
174
+ `invalid_connect_payload`, then the host fails the connection. An unsupported offer receives
175
+ `unsupported_protocol_version`.
113
176
 
114
- A malformed `initResult` with a missing or stale ID does not end initialization or reset its
115
- timeout. Malformed messages do not restart initialization after it succeeds or fails.
177
+ Other malformed sandbox messages receive a NACK without changing the host's lifecycle state or
178
+ resetting its timeout. A missing or malformed `initResult` leaves the host waiting until the setup
179
+ acknowledgment timeout. Valid results with a stale ID are ignored.
116
180
 
117
- The sandbox handles a malformed `init` differently if it can verify the `initializationId`. In that
118
- case, it sends `initResult.error` with `invalid_init_payload` instead of a NACK. Otherwise, it sends
119
- `invalidHostMessage`.
181
+ A sandbox that can read a malformed `init` message's `requestId` replies with `initResult`,
182
+ `status: "error"`, and `invalid_init_payload`. Otherwise, it sends `invalidHostMessage`. A malformed
183
+ message does not restart initialization after success or failure.
120
184
 
121
185
  `CustomBlockErrorInfo` carries `code`, `message`, and `isRetryable`. Error schemas accept any string
122
186
  for `code`, including unknown codes. TypeScript aliases list known codes for autocomplete.
@@ -125,17 +189,16 @@ for `code`, including unknown codes. TypeScript aliases list known codes for aut
125
189
 
126
190
  ### Bindings and IDs
127
191
 
128
- Hosts send `BridgeDataSourceBindings` as `dataSources: { bindings }`, keyed by the semantic data
129
- source key declared in the manifest. `dataSourceSchema` contains only actual database properties.
192
+ `getDataSourceResult` returns one `BridgeDataSourceBinding` for the requested manifest key.
193
+ `dataSourceSchema` contains only actual database properties.
130
194
 
131
195
  Sandbox-to-host object references are raw IDs. The SDK resolves semantic data source and property
132
- keys before sending query or page-operation requests. Get and update requests can carry an optional
196
+ keys before sending query or page operation requests. Get and update requests can carry an optional
133
197
  resolved `dataSourceId`.
134
198
 
135
- A binding with `inaccessible: true` marks a bound data source that the viewer can't read. The host
136
- omits its pointer, schema, and property mappings. The SDK and host still initialize the block. The
137
- SDK fails queries and page creation that use the data source with `data_source_inaccessible`,
138
- without sending a message.
199
+ If the host reports the bound data source as unavailable, `getDataSourceResult` returns
200
+ `data_source_inaccessible` without its pointer, schema, or property mappings. Other operations
201
+ remain available.
139
202
 
140
203
  ### Query requests
141
204
 
@@ -153,8 +216,7 @@ branches, operators, person references, and sort objects reject extra fields.
153
216
  #### Creator, editor, and status filters
154
217
 
155
218
  `created_by` and `last_edited_by` use People operators. Group operands match exact identities, not
156
- members of the group. Bot actors count as present for empty checks. Older hosts reject
157
- `last_edited_by` and group operands in `created_by` filters.
219
+ members of the group. Bot actors count as present for empty checks.
158
220
 
159
221
  Status filters support option operators and stored group names. Group operators accept one name or
160
222
  an array of 1–5 names. Hosts must validate each name against the bound Status property.
@@ -185,15 +247,28 @@ filter: {
185
247
  `created_time` and `last_edited_time` use Date operators without `target`: timestamps have no end
186
248
  date.
187
249
 
250
+ ### Host-applied query limits
251
+
252
+ The SDK validates `limit` as a positive safe integer and forwards it unchanged. The embedding
253
+ application owns the cap. The shared runtime does not impose one.
254
+
255
+ When the application reduces the requested limit, each successful `queryDataSourceResult` includes
256
+ `limitClamp: { requested: number, applied: number }`. Both values are positive safe integers, with
257
+ `applied < requested`.
258
+
259
+ The metadata reports the cap even when fewer rows match. `hasMore` reports whether matching rows
260
+ were omitted. A request for 1005 rows capped at 999 with 50 matches returns all 50,
261
+ `hasMore: false`, and `limitClamp: { requested: 1005, applied: 999 }`.
262
+
188
263
  ## Grants
189
264
 
190
265
  `manifest.grants` lists `{ action, resource }` declarations. `action` is an open string and
191
- `resource` is an open string or a non-empty array of them, so a newer vocabulary never makes an
192
- older receiver reject a manifest. An array applies the action to each element. Receivers never split
193
- a resource string on commas. An omitted `grants` marks a block that predates approval.
266
+ `resource` is an open string or a nonempty array of strings. An array applies the action to each
267
+ element. Receivers never split a resource string on commas. An omitted `grants` field contains no
268
+ declarations.
194
269
 
195
270
  Resources for page actions can name one manifest data source as `data_source:<key>`. The key is the
196
- semantic key from `manifest.dataSources`; hosts resolve it to the bound data source when they record
271
+ semantic key from `manifest.dataSources`. Hosts resolve it to the bound data source when they record
197
272
  and check grants. Bare `data_source` covers every declared key.
198
273
 
199
274
  The `not_granted` error code is reserved for a request that the viewer's grants do not cover, with
@@ -202,8 +277,8 @@ SDK's grants guide documents the vocabulary.
202
277
 
203
278
  ## Page context
204
279
 
205
- Containing-page context uses `CustomBlockPage`. The `init.page` and `pageChanged.page` fields
206
- contain `{ type: "page", id, parent }` for an accessible page, or `{ type: "unavailable" }` when the
280
+ The containing page uses `CustomBlockPage`. The `pageChanged.page` field contains
281
+ `{ type: "page", id, parent }` for an accessible page, or `{ type: "unavailable" }` when the
207
282
  containing page itself is inaccessible. The unavailable shape never carries a page ID. This is
208
283
  distinct from an accessible page with an inaccessible parent
209
284
  (`page.parent: { type: "unavailable" }`).
@@ -215,25 +290,19 @@ must carry the same raw property ID in its `id` field.
215
290
 
216
291
  ## Page responses
217
292
 
218
- Host handlers return unified `BridgePage` for queries and page operations. Properties use display
219
- names as keys and typed values that include their raw property IDs. Only actual schema properties
220
- are returned. Query results contain `items` and `hasMore`. `bridgePageSchema` defines the page
221
- fields, including archive state and creation, edit, and visit metadata.
293
+ Host handlers return `BridgePage` for queries and page operations. Properties use display names as
294
+ keys and typed values that include their raw property IDs. Only actual schema properties are
295
+ returned. Query success results contain `items`, `hasMore`, and optional `limitClamp`.
296
+ `bridgePageSchema` defines the page fields, including archive state and creation and edit metadata.
222
297
 
223
298
  Page reads return string values for `unique_id`, `formula`, `rollup`, `button`, and `verification`,
224
299
  preserving each property's type. These properties are read-only. Values use stored text, or `""`
225
300
  when absent. Hosts do not evaluate formulas or rollups.
226
301
 
227
- The host converts responses to the sandbox's declared protocol. See
228
- [versioning and compatibility](versioning.md) for protocol version rules. The host's
229
- [compatibility reference](../host/docs/compatibility.md) describes older response formats.
230
-
231
- ### Native page icon compatibility
302
+ ### Native page icons
232
303
 
233
- Protocol 9 and later use native icon objects. Protocols 3–8 receive external SVG URLs in page
234
- operation results. Unified query results in protocols 6–8 also use external SVG URLs; flat query
235
- results in protocols 3–5 omit icon fields. Native colors accept any string in responses and write
236
- inputs, so newer host colors do not require an SDK update.
304
+ Native icons use objects with a name and color. Icon colors accept any string in responses and write
305
+ inputs. The application validates supported names and colors before writing records.
237
306
 
238
307
  `createPage` accepts native icons, emoji, custom emoji, and URL-backed icons and covers. The
239
308
  application adapter checks submitted image URLs against the block's network permissions before
@@ -4,20 +4,27 @@ The SDK inside a block and the host in its embedding application release indepen
4
4
  protocol version identifies the wire contract they use, independently of their package versions.
5
5
  This reference defines the version identifiers, protocol format names, and rules for contract
6
6
  changes. Release boundaries and exceptions are recorded in the [changelog](changelog.md). The host's
7
- [compatibility reference](../host/docs/compatibility.md) describes runtime support and response
8
- conversions.
7
+ [connection reference](../host/docs/compatibility.md) describes negotiation and version
8
+ requirements.
9
9
 
10
10
  ## Version identifiers
11
11
 
12
- - **Bridge protocol:** `connect.bridgeProtocolVersion` declares the sandbox's wire contract.
12
+ - **Protocol:** `connect.supportedProtocolVersions` lists the SDK's implemented contracts. The host
13
+ selects the highest version that both sides implement in `connectResult.protocolVersion`.
13
14
  - **SDK package:** identifies the SDK's public API and implementation. It can change without a wire
14
15
  change.
15
16
  - **Host package:** identifies the runtime implementation. Publishing it does not deploy it to
16
17
  Notion.
17
18
 
18
- `connect.bridgeProtocolVersion` selects the wire contract. `sdkVersion` is analytics metadata.
19
+ The selected protocol version belongs to the connection. Protocol 12 `init` does not repeat it.
20
+ `sdkVersion` is analytics metadata. The
21
+ [connection reference](../host/docs/compatibility.md#supported-versions) describes the current
22
+ negotiation contract.
23
+
19
24
  `LATEST_BRIDGE_PROTOCOL_VERSION` identifies the latest contract defined by the package.
20
25
  `NATIVE_ICON_PROTOCOL_VERSION` is 9, the first protocol with native icon responses and writes.
26
+ `MINIMAL_INIT_PROTOCOL_VERSION` is 12, the first protocol with separate setup and render readiness,
27
+ location notifications after setup, and explicit current-user and source metadata reads.
21
28
 
22
29
  ## Protocol export names
23
30
 
@@ -35,5 +42,10 @@ required fields, and new response variants an older receiver rejects. Optional f
35
42
  messages need no bump only when older receivers can safely ignore or NACK them. Parsing success
36
43
  alone does not prove compatible SDK behavior.
37
44
 
45
+ Each advertised version requires a working schema, adapter, and compatibility tests. An SDK that
46
+ advertises `[13, 12]` must still implement protocol 12 when a host selects it. Optional fields must
47
+ remain safe for older readers to ignore. A receiver rejects unknown requests with a correlated NACK
48
+ when it can read their `requestId`.
49
+
38
50
  An SDK that requires a newer protocol needs a host that supports that contract. Updating the SDK
39
51
  package does not update the host in the embedding application.