@notionhq/custom-blocks-dev-shell 0.4.1 → 0.4.3
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/README.md +48 -31
- package/dist/assets/index-BlifLoaB.js +12 -0
- package/dist/index.html +1 -1
- package/dist-cli/cli/published-cli.js +10204 -19
- package/package.json +2 -8
- package/dist/assets/index-G-f2Po2-.js +0 -12
- package/docs/bridge/changelog.md +0 -165
- package/docs/bridge/protocol.md +0 -329
- package/docs/bridge/versioning.md +0 -51
- package/docs/host/README.md +0 -200
- package/docs/host/docs/compatibility.md +0 -126
- package/docs/host/docs/handlers.md +0 -119
- package/docs/host/docs/host-contract.md +0 -203
- package/docs/host/docs/lifecycle.md +0 -145
package/docs/bridge/changelog.md
DELETED
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
# Bridge protocol changelog
|
|
2
|
-
|
|
3
|
-
The bridge protocol defines the messages exchanged by a custom block's SDK and its host. This
|
|
4
|
-
changelog records breaking contract changes and the SDK releases that introduced them. It also
|
|
5
|
-
describes compatibility exceptions within a declared protocol version and their effects on blocks.
|
|
6
|
-
Protocol version rules are in [Bridge protocol versioning](versioning.md). The host's
|
|
7
|
-
[connection reference](../host/docs/compatibility.md) describes current negotiation and version
|
|
8
|
-
requirements.
|
|
9
|
-
|
|
10
|
-
Dates refer to npm releases in Pacific time, not deployment in Notion. Planned entries show the
|
|
11
|
-
expected package version and release date. Unqualified SDK versions refer to
|
|
12
|
-
`@notionhq/custom-blocks`.
|
|
13
|
-
|
|
14
|
-
| Protocol | First SDK release | First standalone host release | First dev shell release | Breaking contract changes |
|
|
15
|
-
| ------------------------------------------------------ | ----------------------------- | ----------------------------- | ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
16
|
-
| 1 | `ncblock@0.0.1` · 2026-05-11 | — | — | Initial `ready` / `init` handshake and block APIs |
|
|
17
|
-
| 2 | `ncblock@0.0.36` · 2026-06-18 | — | `0.0.1` · 2026-07-21 | Structured errors, handshake changes, and raw data-source IDs instead of manifest keys |
|
|
18
|
-
| 3 | `0.0.79` · 2026-07-22 | `0.0.1` · 2026-09-09 | `0.0.8` · 2026-07-22 | Accumulated contract changes include `connect → init → initResult`, initialization identity, subscription identity, and required structured connect errors |
|
|
19
|
-
| 4 | `0.2.0` · 2026-09-17 | `0.1.14` · 2026-09-17 | `0.1.63` · 2026-09-17 | Required `init.contrastMode` and page/query `is_archived` and `in_trash` fields |
|
|
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
|
-
| 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
|
-
| 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 |
|
|
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 |
|
|
27
|
-
| 12 | `0.6.0` · 2026-11-19 | `0.11.0` · 2026-11-18 | `0.4.0` · 2026-11-18 | Negotiates the protocol and separates setup, data reads, and render readiness |
|
|
28
|
-
|
|
29
|
-
`—` means no release in that package line carried that specific protocol version.
|
|
30
|
-
|
|
31
|
-
Host compatibility depends on the protocol version selected during `connect`, not the SDK package
|
|
32
|
-
version.
|
|
33
|
-
|
|
34
|
-
Native host package pins and protocol mappings are tracked separately in
|
|
35
|
-
[Notion's native host configuration](https://github.com/makenotion/notion-next/blob/main/src/cli/mobile/codegen/customBlockHost/config.ts)
|
|
36
|
-
and
|
|
37
|
-
[mobile shell registry](https://github.com/makenotion/notion-next/blob/main/src/cloudflare-customBlockWorker/lib/mobileShellRegistry.ts).
|
|
38
|
-
|
|
39
|
-
## Protocol 12: minimal handshake and post-init reads
|
|
40
|
-
|
|
41
|
-
Option colors, status-group colors, and page-metadata actor tables accept future string values.
|
|
42
|
-
|
|
43
|
-
Protocol 12 negotiates a version with `connect` and `connectResult`, then sends setup-only `init`
|
|
44
|
-
with its own request ID, fixed `instance` identity, manifest, and
|
|
45
|
-
`preferences: { theme, contrastMode }`. `initResult` acknowledges setup. A separate
|
|
46
|
-
`ready { initialHeight }` permits reveal. Protocols 3–11 retain their handshake and eager payloads.
|
|
47
|
-
|
|
48
|
-
`getViewer` returns a user identity or an anonymous viewer without loading a profile. Anonymous
|
|
49
|
-
viewers can initialize. `getCurrentUser` remains supported; protocols 3–11 still require a user.
|
|
50
|
-
|
|
51
|
-
After acknowledgment, `parentChanged` and `pageChanged` deliver initial resolved location values and
|
|
52
|
-
later changes without sandbox requests. Unresolved parent and containing page values do not delay
|
|
53
|
-
setup. `getCurrentUser` and `getDataSource` requests load profiles and source metadata
|
|
54
|
-
independently. Binding refresh uses `dataSourcesInvalidated`. Raw-ID page operations remain
|
|
55
|
-
unchanged.
|
|
56
|
-
|
|
57
|
-
`operation_not_allowed` reports that an operation is unavailable in the workspace.
|
|
58
|
-
`block_limit_reached` reports that the workspace's block limit prevents page creation.
|
|
59
|
-
|
|
60
|
-
Full profiles require `name: string | null`. The `makeBridgeUser` builder supplies `null` when its
|
|
61
|
-
caller omits the name. Protocols 3–11 retain omitted names on the wire for deployed SDKs. Empty
|
|
62
|
-
strings remain unchanged.
|
|
63
|
-
|
|
64
|
-
Containing-page notifications include `displayMode`: `"full_page"`, `"side_peek"`, or
|
|
65
|
-
`"center_peek"`, defaulting to `"full_page"` outside peek presentation. SDK containing-page
|
|
66
|
-
descriptors preserve this field, and mode-only changes use the existing `pageChanged` notification.
|
|
67
|
-
The shared host also reports known parent/page failures through `parentError` and `pageError`. Later
|
|
68
|
-
value notifications recover each field.
|
|
69
|
-
|
|
70
|
-
Query NACKs can include `subscriptionId`. Rejected queries and malformed responses now report an
|
|
71
|
-
error immediately when the SDK can identify the affected subscription.
|
|
72
|
-
|
|
73
|
-
Unsupported page icon types read as `null`. Icon writes still require a supported shape.
|
|
74
|
-
|
|
75
|
-
## Optional query limit metadata
|
|
76
|
-
|
|
77
|
-
Query results can include optional `limitClamp` metadata when a host reduces the requested limit.
|
|
78
|
-
The field was added in protocol 11. SDKs that do not recognize it ignore it.
|
|
79
|
-
|
|
80
|
-
## Protocol 11: location removal and data source binding names
|
|
81
|
-
|
|
82
|
-
Protocol 11 uses `dataSourceSchema` and `dataSourcePointer` in `init` and `dataSourcesChanged`. The
|
|
83
|
-
host encodes `collectionSchema` and `collectionPointer` for supported protocols 3–10 only at its
|
|
84
|
-
outgoing boundary. Protocols 3–4 still receive synthetic metadata schemas there.
|
|
85
|
-
|
|
86
|
-
SDK 0.5.1 adds incoming compatibility for the `collectionSchema` and `collectionPointer` names sent
|
|
87
|
-
by older hosts such as 0.9.0. It normalizes these fields in both `init` and `dataSourcesChanged`,
|
|
88
|
-
while retaining the protocol 11 names in the SDK API. Current fields take precedence when both names
|
|
89
|
-
are present, and both encodings remain validated. This patch keeps protocol 11. It does not add
|
|
90
|
-
older-host operations or change Notion's persisted binding format.
|
|
91
|
-
|
|
92
|
-
SDK 0.5.0 requires host 0.10.0 or dev shell 0.3.1 for the renamed binding fields. Native host
|
|
93
|
-
generation and mobile shell registration must use the published host release to send the current
|
|
94
|
-
encoding.
|
|
95
|
-
|
|
96
|
-
`location` represents the source of an item in Notion's aggregated views. Protocol 11 removes it
|
|
97
|
-
from manifests, binding schemas, and page property values. Updated hosts omit it for every supported
|
|
98
|
-
protocol version. Existing blocks that declare it in a manifest must remove that declaration and
|
|
99
|
-
rebuild. Older SDKs can still connect with manifests that use supported property types.
|
|
100
|
-
|
|
101
|
-
## Protocol 10: remove last visited time
|
|
102
|
-
|
|
103
|
-
`last_visited_time` is viewer-specific recents data, not a database property type. Protocol 10
|
|
104
|
-
removes it from manifests, binding schemas, page property values, and top-level page metadata. Older
|
|
105
|
-
SDKs can still connect, but updated hosts no longer load or return viewer visit data. Older readers
|
|
106
|
-
default the absent page field to `null`. Blocks that use this field must remove that use and
|
|
107
|
-
rebuild.
|
|
108
|
-
|
|
109
|
-
## Protocol 9: native page icons
|
|
110
|
-
|
|
111
|
-
Page operations and query results can return `{ type: "icon", icon: { name, color } }`. Reads and
|
|
112
|
-
writes share a loose shape: names and colors accept strings, color is optional, and additional
|
|
113
|
-
native icon fields are retained. Hosts resolve names and default omitted colors to gray.
|
|
114
|
-
|
|
115
|
-
Protocols 3–8 receive external SVG URLs in page operation results. Protocols 6–8 receive the same
|
|
116
|
-
fallback in query results. Protocols 3–5 keep their flat query format without appearance fields. The
|
|
117
|
-
released-SDK compatibility corpus exercises these conversions.
|
|
118
|
-
|
|
119
|
-
## Protocol 8: local manifest declarations
|
|
120
|
-
|
|
121
|
-
The dev shell removes the `/manifest` route and embeds the local manifest in block HTML. The SDK
|
|
122
|
-
reads that metadata and sends the declaration in `connect.manifest`. Initialization no longer
|
|
123
|
-
fetches `/manifest`.
|
|
124
|
-
|
|
125
|
-
The host option `manifestSource` selects the initialization manifest: `"sandbox"` uses the
|
|
126
|
-
declaration from `connect`, and `"host"` uses the persisted manifest returned by
|
|
127
|
-
`getPersistedManifest`. Only the selected source determines initialization. Deployed blocks using
|
|
128
|
-
supported earlier protocols retain their existing response formats.
|
|
129
|
-
|
|
130
|
-
The shared host runtime minimum remains 3. The dev shell uses the Worker manifest in host mode and
|
|
131
|
-
accepts supported earlier protocols. Sandbox-mode initialization uses the protocol 8 declaration
|
|
132
|
-
from `connect`.
|
|
133
|
-
|
|
134
|
-
## Changes within a declared version
|
|
135
|
-
|
|
136
|
-
### Protocol 8: correlated request rejections
|
|
137
|
-
|
|
138
|
-
Bridge NACKs (`invalidHostMessage` and `invalidSandboxMessage`) gain an optional string `requestId`.
|
|
139
|
-
Updated SDKs complete the matching request immediately when a rejection can be correlated. Older
|
|
140
|
-
readers ignore the additional field. Updated readers continue to accept NACKs without an ID.
|
|
141
|
-
Uncorrelated requests use the SDK's 60-second timeout. This additive change retains protocol 8.
|
|
142
|
-
|
|
143
|
-
### Protocol 5: unavailable containing-page context
|
|
144
|
-
|
|
145
|
-
On October 2, 2026, SDK 0.2.17 added `{ type: "unavailable" }` to containing-page context while
|
|
146
|
-
retaining protocol 5. SDK 0.2.16 rejects that shape. The host preserves later protocol 5 behavior
|
|
147
|
-
and accepts the limitation for the older SDK, as decided on October 31, 2026. Affected blocks must
|
|
148
|
-
upgrade and rebuild.
|
|
149
|
-
|
|
150
|
-
### Protocol 6: richer fallback properties
|
|
151
|
-
|
|
152
|
-
The protocol version changed in code on October 22, 2026. On October 26, the `pages` and
|
|
153
|
-
`dataSources` APIs adopted a shared page representation: data source query rows and page operation
|
|
154
|
-
results use the same page shape, with typed properties keyed by display name.
|
|
155
|
-
|
|
156
|
-
Some SDKs added text fallback property objects for unique ID, button, formula, location, rollup, and
|
|
157
|
-
verification while still reporting protocol 6. Earlier protocol 6 SDKs reject those property
|
|
158
|
-
objects. Because both groups declare the same protocol version, updated hosts send `null` for these
|
|
159
|
-
properties to every protocol 6 block.
|
|
160
|
-
|
|
161
|
-
Blocks built with the later protocol 6 SDKs therefore lose those property values when their host
|
|
162
|
-
updates. UI that displays the values can become empty, and code that assumes a property object is
|
|
163
|
-
present can fail. Upgrade the SDK to protocol 7 or later and rebuild the block to receive the text
|
|
164
|
-
fallback property objects. Host adapters continue returning the current page shape. The host runtime
|
|
165
|
-
applies the protocol-specific conversion.
|
package/docs/bridge/protocol.md
DELETED
|
@@ -1,329 +0,0 @@
|
|
|
1
|
-
# Bridge wire protocol
|
|
2
|
-
|
|
3
|
-
The bridge carries initialization, data requests, results, and live updates between a custom block's
|
|
4
|
-
SDK and its host. This reference defines the handshake, message identity, validation, and payload
|
|
5
|
-
semantics for host integrators and bridge maintainers. Block authors use the SDK's public APIs.
|
|
6
|
-
|
|
7
|
-
Messages are `postMessage` payloads defined by shared Valibot schemas, exposed through
|
|
8
|
-
`@notionhq/custom-blocks-host/protocol`. The embedding application enforces permissions and record
|
|
9
|
-
access. This reference describes protocol 12. See
|
|
10
|
-
[Connection compatibility](../host/docs/compatibility.md) for host version requirements.
|
|
11
|
-
|
|
12
|
-
## Initialization
|
|
13
|
-
|
|
14
|
-
The sandbox connects, applies setup, and reports when its first render is ready:
|
|
15
|
-
|
|
16
|
-
```text
|
|
17
|
-
sandbox connect → host connectResult → host init → sandbox initResult → sandbox ready
|
|
18
|
-
```
|
|
19
|
-
|
|
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
|
-
|
|
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.
|
|
29
|
-
|
|
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
|
-
|
|
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.
|
|
37
|
-
|
|
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.
|
|
43
|
-
|
|
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 viewer identity, the current user profile, or source metadata:
|
|
76
|
-
|
|
77
|
-
| Request | Success result |
|
|
78
|
-
| ------------------------------------------- | ------------------------------------------------------------------------------------------------- |
|
|
79
|
-
| `{ type: "getViewer", requestId }` | `{ type: "getViewerResult", requestId, status: "success", viewer: BridgeViewer }` |
|
|
80
|
-
| `{ type: "getCurrentUser", requestId }` | `{ type: "getCurrentUserResult", requestId, status: "success", user: BridgeUser }` |
|
|
81
|
-
| `{ type: "getDataSource", requestId, key }` | `{ type: "getDataSourceResult", requestId, status: "success", binding: BridgeDataSourceBinding }` |
|
|
82
|
-
|
|
83
|
-
`BridgeViewer` is `{ type: "user", userId }` or `{ type: "anonymous" }`. Identity is fixed for the
|
|
84
|
-
connection. A viewer read does not load a profile. For an anonymous viewer, `getCurrentUser` returns
|
|
85
|
-
an error with code `current_user_unavailable`. The embedding application authorizes each data
|
|
86
|
-
operation separately.
|
|
87
|
-
|
|
88
|
-
A failure returns `{ type: "<request type>Result", requestId, status: "error", error }` and leaves
|
|
89
|
-
other operations available. Profile reads return the full profile, including email. Source reads
|
|
90
|
-
resolve metadata for a declared binding. Page operations and queries address raw record IDs.
|
|
91
|
-
|
|
92
|
-
Configuration refresh aborts pending operations and queries, clears source metadata, and sends
|
|
93
|
-
`{ type: "dataSourcesInvalidated" }`. The SDK reads replacement metadata when an operation needs it.
|
|
94
|
-
Results from the previous configuration cannot repopulate its cache.
|
|
95
|
-
|
|
96
|
-
`init.instance` identifies the configured instance. `customBlockInstanceSchema` accepts
|
|
97
|
-
`{ type: "block" | "page", blockId }` or `{ type: "view", viewId }`. `CustomBlockInstance` is the
|
|
98
|
-
inferred type. Block and page IDs use `NotionBlockId`. View IDs use `NotionViewId`. The identity is
|
|
99
|
-
fixed for the connection and does not require a change notification.
|
|
100
|
-
|
|
101
|
-
After setup acknowledgment, the host sends `parentChanged { parent }` and `pageChanged { page }`
|
|
102
|
-
with their current resolved values. Unresolved values are sent when available. Later parent,
|
|
103
|
-
containing page, theme, and contrast mode changes use their respective change messages. The host
|
|
104
|
-
sends notifications without sandbox requests or subscription messages. Stopping suppresses late
|
|
105
|
-
delivery.
|
|
106
|
-
|
|
107
|
-
`pageChanged.page` includes `displayMode: "full_page" | "side_peek" | "center_peek"` on an
|
|
108
|
-
accessible page. The mode describes this block's own container, not another open peek. The host
|
|
109
|
-
sends a complete page notification when the mode changes, even if its ID is unchanged. Hosts without
|
|
110
|
-
peek presentation use `full_page`. Unavailable pages expose no display metadata. This field is
|
|
111
|
-
separate from page content returned by page operations.
|
|
112
|
-
|
|
113
|
-
`parentError { error }` and `pageError { error }` report known location failures without failing
|
|
114
|
-
setup. A later `parentChanged` or `pageChanged` replaces the corresponding error. An unavailable
|
|
115
|
-
value is a successful access-limited result, not a load failure.
|
|
116
|
-
|
|
117
|
-
`setupInitMessageSchema` validates the setup payload.
|
|
118
|
-
|
|
119
|
-
## Full user profiles
|
|
120
|
-
|
|
121
|
-
`BridgeUser` requires `name` and `avatar_url`. Each accepts a string or `null`. An omitted or
|
|
122
|
-
`undefined` name is invalid. Empty strings are preserved. The same profile shape applies to
|
|
123
|
-
current-user reads, user lookup, user lists, and profile updates. ID-only people references do not
|
|
124
|
-
promise a name or any other profile field.
|
|
125
|
-
|
|
126
|
-
## Manifests
|
|
127
|
-
|
|
128
|
-
A manifest declares a block's data sources and display metadata. `manifestSchema` defines its fields
|
|
129
|
-
and defaults omitted `dataSources` and each data source's omitted `properties` to `{}`.
|
|
130
|
-
|
|
131
|
-
`isLocalBlockServerUrl(url)` accepts HTTP or HTTPS URLs on `localhost`, `*.localhost`, or
|
|
132
|
-
`127.0.0.1` without credentials. It checks the address only. The host also requires a block in
|
|
133
|
-
sandbox mode to use a different origin from its embedding page.
|
|
134
|
-
|
|
135
|
-
## Message identity
|
|
136
|
-
|
|
137
|
-
- Requests and their results use `requestId`.
|
|
138
|
-
- `queryDataSource` starts a subscription. The request and every update use its stable
|
|
139
|
-
`subscriptionId`.
|
|
140
|
-
- `connect` and `init` each use their own `requestId`.
|
|
141
|
-
- Notifications, such as `ready` and `resize`, have no correlation ID.
|
|
142
|
-
- Bridge NACKs include the rejected message's `requestId` when it is a string. The ID identifies the
|
|
143
|
-
original request, including when the rejected message is its response.
|
|
144
|
-
|
|
145
|
-
Hosts key query state by `subscriptionId`, replace state when a request reuses one, and suppress
|
|
146
|
-
stale asynchronous results.
|
|
147
|
-
|
|
148
|
-
The sandbox can send `unsubscribeDataSourceQuery` with the same `subscriptionId` when it no longer
|
|
149
|
-
needs the subscription. An unknown or repeated unsubscribe is a no-op. Hosts stop future refreshes
|
|
150
|
-
and suppress results from work already in progress.
|
|
151
|
-
|
|
152
|
-
## Validation and errors
|
|
153
|
-
|
|
154
|
-
Each direction has a validation schema:
|
|
155
|
-
|
|
156
|
-
- Sandbox to host: `sandboxToHostMessageSchema`
|
|
157
|
-
- Host to sandbox: `hostToSandboxMessageSchema`
|
|
158
|
-
|
|
159
|
-
On parse failure, the host replies with `invalidSandboxMessage` and the sandbox replies with
|
|
160
|
-
`invalidHostMessage`, except for the handshake cases below. These replies are negative
|
|
161
|
-
acknowledgments (NACKs). Receivers do not NACK another NACK.
|
|
162
|
-
|
|
163
|
-
A sandbox request with a `requestId` expects a terminal result or correlated rejection. On parse
|
|
164
|
-
failure, read `requestId` separately from the invalid payload. The host includes a readable string
|
|
165
|
-
ID in `invalidSandboxMessage`, even for an unknown request type. The SDK completes the matching
|
|
166
|
-
request with `invalid_sandbox_message`. When the SDK rejects a host response, it completes the
|
|
167
|
-
matching request locally with `invalid_host_message` and includes the ID in `invalidHostMessage`.
|
|
168
|
-
Both errors have `isRetryable: false`.
|
|
169
|
-
|
|
170
|
-
When the host rejects a `queryDataSource` message, it includes any readable `subscriptionId` in
|
|
171
|
-
`invalidSandboxMessage`. The SDK reports `invalid_sandbox_message` to that subscription. When the
|
|
172
|
-
SDK cannot parse a query response with a readable `subscriptionId`, it reports
|
|
173
|
-
`invalid_host_message` to that subscription and includes the ID in `invalidHostMessage`. Missing or
|
|
174
|
-
unknown IDs do not affect other subscriptions. Receivers do not reply to malformed NACKs.
|
|
175
|
-
|
|
176
|
-
SDK requests time out after 30 seconds. Missing, unreadable, or unknown IDs do not fail unrelated
|
|
177
|
-
requests. A NACK without a readable `requestId` cannot complete a pending request. That request
|
|
178
|
-
retains its timeout.
|
|
179
|
-
|
|
180
|
-
Request completion clears its timer, removes the pending entry, and ignores duplicate or late
|
|
181
|
-
results. Disposing the SDK completes pending calls locally with `request_disposed` and clears their
|
|
182
|
-
timers. The SDK does not retry or cancel host work. A write may still complete after a timeout.
|
|
183
|
-
Check its resulting state before repeating it. Data source subscriptions use a separate lifecycle.
|
|
184
|
-
|
|
185
|
-
A malformed `connect` with a readable `requestId` receives `connectResult.error` with
|
|
186
|
-
`invalid_connect_payload`, then the host fails the connection. An unsupported offer receives
|
|
187
|
-
`unsupported_protocol_version`.
|
|
188
|
-
|
|
189
|
-
Other malformed sandbox messages receive a NACK without changing the host's lifecycle state or
|
|
190
|
-
resetting its timeout. A missing or malformed `initResult` leaves the host waiting until the setup
|
|
191
|
-
acknowledgment timeout. Valid results with a stale ID are ignored.
|
|
192
|
-
|
|
193
|
-
During setup, a sandbox that can read a malformed `init` message's `requestId` replies with
|
|
194
|
-
`initResult`, `status: "error"`, and `invalid_init_payload`. Without a readable request ID, setup
|
|
195
|
-
fails locally with `unsupported_protocol_version`. A malformed message does not restart
|
|
196
|
-
initialization after success or failure.
|
|
197
|
-
|
|
198
|
-
`CustomBlockErrorInfo` carries `code`, `message`, and `isRetryable`. Error schemas accept any string
|
|
199
|
-
for `code`, including unknown codes. TypeScript aliases list known codes for autocomplete.
|
|
200
|
-
|
|
201
|
-
### Workspace restrictions
|
|
202
|
-
|
|
203
|
-
`operation_not_allowed` reports a workspace restriction without disclosing private policy or billing
|
|
204
|
-
reasons. Applications keep those reasons in internal diagnostics, outside sandbox messages and
|
|
205
|
-
sandbox-visible logs. Page creation reports `block_limit_reached` when the workspace block allowance
|
|
206
|
-
prevents creation.
|
|
207
|
-
|
|
208
|
-
## Data sources
|
|
209
|
-
|
|
210
|
-
### Bindings and IDs
|
|
211
|
-
|
|
212
|
-
`getDataSourceResult` returns one `BridgeDataSourceBinding` for the requested manifest key.
|
|
213
|
-
`dataSourceSchema` contains only actual database properties.
|
|
214
|
-
|
|
215
|
-
Sandbox-to-host object references are raw IDs. The SDK resolves semantic data source and property
|
|
216
|
-
keys before sending query or page operation requests. Get and update requests can carry an optional
|
|
217
|
-
resolved `dataSourceId`.
|
|
218
|
-
|
|
219
|
-
If the host reports the bound data source as unavailable, `getDataSourceResult` returns
|
|
220
|
-
`data_source_inaccessible` without its pointer, schema, or property mappings. Other operations
|
|
221
|
-
remain available.
|
|
222
|
-
|
|
223
|
-
### Query requests
|
|
224
|
-
|
|
225
|
-
`queryDataSource.archive_status` accepts `active`, `archived`, or `all`. It defaults to `active`.
|
|
226
|
-
|
|
227
|
-
`queryDataSource` may include a resolved `filter` and an ordered `sorts` list. Each sort contains a
|
|
228
|
-
raw `propertyId` and an `ascending` or `descending` direction. Hosts apply sorts in array order. The
|
|
229
|
-
SDK and host validate that the list contains at most ten unique properties. The host rejects
|
|
230
|
-
property types without a supported sort value.
|
|
231
|
-
|
|
232
|
-
Every filter and sort property ID must exist in `dataSourceSchema.propertiesById`. Queries with
|
|
233
|
-
filters or sorts return `data_source_schema_unavailable` when the schema is unavailable. Filter
|
|
234
|
-
branches, operators, person references, and sort objects reject extra fields.
|
|
235
|
-
|
|
236
|
-
#### Creator, editor, and status filters
|
|
237
|
-
|
|
238
|
-
`created_by` and `last_edited_by` use People operators. Group operands match exact identities, not
|
|
239
|
-
members of the group. Bot actors count as present for empty checks.
|
|
240
|
-
|
|
241
|
-
Status filters support option operators and stored group names. Group operators accept one name or
|
|
242
|
-
an array of 1–5 names. Hosts must validate each name against the bound Status property.
|
|
243
|
-
|
|
244
|
-
#### Relation filters
|
|
245
|
-
|
|
246
|
-
Relation filters require an actual `relation` property in the bound schema. `contains` and
|
|
247
|
-
`does_not_contain` accept one page ID. `is_empty` and `is_not_empty` accept only `true` and require
|
|
248
|
-
no page ID. Each relation filter accepts exactly one operator. Adapters must evaluate empty checks
|
|
249
|
-
against relation values, including XLDB row IDs where supported.
|
|
250
|
-
|
|
251
|
-
#### Date filters
|
|
252
|
-
|
|
253
|
-
Date comparisons accept ISO values and relative values such as `today`. The query schema defines the
|
|
254
|
-
accepted values and range operators. Range operators require an empty object.
|
|
255
|
-
|
|
256
|
-
Date comparisons accept `target` inside `date`, beside the operator. The target is `start_date` by
|
|
257
|
-
default. For ranges, `end_date` compares the range end. For individual dates, it compares the date.
|
|
258
|
-
Empty checks accept either target, but they test the whole property.
|
|
259
|
-
|
|
260
|
-
```ts
|
|
261
|
-
filter: {
|
|
262
|
-
propertyId: "schedule-id",
|
|
263
|
-
date: { target: "end_date", on_or_after: "2026-10-08" },
|
|
264
|
-
}
|
|
265
|
-
```
|
|
266
|
-
|
|
267
|
-
`created_time` and `last_edited_time` use Date operators without `target`: timestamps have no end
|
|
268
|
-
date.
|
|
269
|
-
|
|
270
|
-
### Host-applied query limits
|
|
271
|
-
|
|
272
|
-
The SDK validates `limit` as a positive safe integer and forwards it unchanged. The embedding
|
|
273
|
-
application owns the cap. The shared runtime does not impose one.
|
|
274
|
-
|
|
275
|
-
When the application reduces the requested limit, each successful `queryDataSourceResult` includes
|
|
276
|
-
`limitClamp: { requested: number, applied: number }`. Both values are positive safe integers, with
|
|
277
|
-
`applied < requested`.
|
|
278
|
-
|
|
279
|
-
The metadata reports the cap even when fewer rows match. `hasMore` reports whether matching rows
|
|
280
|
-
were omitted. A request for 1005 rows capped at 999 with 50 matches returns all 50,
|
|
281
|
-
`hasMore: false`, and `limitClamp: { requested: 1005, applied: 999 }`.
|
|
282
|
-
|
|
283
|
-
## Grants
|
|
284
|
-
|
|
285
|
-
`manifest.grants` lists `{ action, resource }` declarations. `action` is an open string and
|
|
286
|
-
`resource` is an open string or a nonempty array of strings. An array applies the action to each
|
|
287
|
-
element. Receivers never split a resource string on commas. An omitted `grants` field contains no
|
|
288
|
-
declarations.
|
|
289
|
-
|
|
290
|
-
Resources for page actions can name one manifest data source as `data_source:<key>`. The key is the
|
|
291
|
-
semantic key from `manifest.dataSources`. Hosts resolve it to the bound data source when they record
|
|
292
|
-
and check grants. Bare `data_source` covers every declared key.
|
|
293
|
-
|
|
294
|
-
The `not_granted` error code is reserved for a request that the viewer's grants do not cover, with
|
|
295
|
-
`isRetryable: false`. No adapter sends it yet, and no receiver restricts requests by grant. The
|
|
296
|
-
SDK's grants guide documents the vocabulary.
|
|
297
|
-
|
|
298
|
-
## Page context
|
|
299
|
-
|
|
300
|
-
The containing page uses `CustomBlockPage`. The `pageChanged.page` field contains
|
|
301
|
-
`{ type: "page", id, parent }` for an accessible page, or `{ type: "unavailable" }` when the
|
|
302
|
-
containing page itself is inaccessible. The unavailable shape never carries a page ID. This is
|
|
303
|
-
distinct from an accessible page with an inaccessible parent
|
|
304
|
-
(`page.parent: { type: "unavailable" }`).
|
|
305
|
-
|
|
306
|
-
## Page writes
|
|
307
|
-
|
|
308
|
-
The `createPage` and `updatePage` messages use raw property IDs from Notion as map keys. Each value
|
|
309
|
-
must carry the same raw property ID in its `id` field.
|
|
310
|
-
|
|
311
|
-
## Page responses
|
|
312
|
-
|
|
313
|
-
Host handlers return `BridgePage` for queries and page operations. Properties use display names as
|
|
314
|
-
keys and typed values that include their raw property IDs. Only actual schema properties are
|
|
315
|
-
returned. Query success results contain `items`, `hasMore`, and optional `limitClamp`.
|
|
316
|
-
`bridgePageSchema` defines the page fields, including archive state and creation and edit metadata.
|
|
317
|
-
|
|
318
|
-
Page reads return string values for `unique_id`, `formula`, `rollup`, `button`, and `verification`,
|
|
319
|
-
preserving each property's type. These properties are read-only. Values use stored text, or `""`
|
|
320
|
-
when absent. Hosts do not evaluate formulas or rollups.
|
|
321
|
-
|
|
322
|
-
### Native page icons
|
|
323
|
-
|
|
324
|
-
Native icons use objects with a name and color. Icon colors accept any string in responses and write
|
|
325
|
-
inputs. The application validates supported names and colors before writing records.
|
|
326
|
-
|
|
327
|
-
`createPage` accepts native icons, emoji, custom emoji, and URL-backed icons and covers. The
|
|
328
|
-
application adapter checks submitted image URLs against the block's network permissions before
|
|
329
|
-
creating a page.
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
# Bridge protocol versioning
|
|
2
|
-
|
|
3
|
-
The SDK inside a block and the host in its embedding application release independently. A bridge
|
|
4
|
-
protocol version identifies the wire contract they use, independently of their package versions.
|
|
5
|
-
This reference defines the version identifiers, protocol format names, and rules for contract
|
|
6
|
-
changes. Release boundaries and exceptions are recorded in the [changelog](changelog.md). The host's
|
|
7
|
-
[connection reference](../host/docs/compatibility.md) describes negotiation and version
|
|
8
|
-
requirements.
|
|
9
|
-
|
|
10
|
-
## Version identifiers
|
|
11
|
-
|
|
12
|
-
- **Protocol:** `connect.supportedProtocolVersions` lists the SDK's implemented contracts. The host
|
|
13
|
-
selects the highest version that both sides implement in `connectResult.protocolVersion`.
|
|
14
|
-
- **SDK package:** identifies the SDK's public API and implementation. It can change without a wire
|
|
15
|
-
change.
|
|
16
|
-
- **Host package:** identifies the runtime implementation. Publishing it does not deploy it to
|
|
17
|
-
Notion.
|
|
18
|
-
|
|
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
|
-
|
|
24
|
-
`LATEST_BRIDGE_PROTOCOL_VERSION` identifies the latest contract defined by the package.
|
|
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.
|
|
28
|
-
|
|
29
|
-
## Protocol export names
|
|
30
|
-
|
|
31
|
-
The `@notionhq/custom-blocks-host/protocol` entrypoint exports wire definitions. Page formats used
|
|
32
|
-
by protocols 3–5 are named `BridgePageForProtocol3To5` and `NotionDataSourcePageForProtocol3To5`,
|
|
33
|
-
with matching `bridgePageForProtocol3To5Schema` and `notionDataSourcePageForProtocol3To5Schema`
|
|
34
|
-
validators. Message types and schemas containing `WithProtocol3To5Compatibility` accept both current
|
|
35
|
-
page formats and protocol 3–5 page formats. `UNIFIED_PAGE_PROTOCOL_VERSION` is 6, the minimum
|
|
36
|
-
protocol version that uses unified pages.
|
|
37
|
-
|
|
38
|
-
## Version changes
|
|
39
|
-
|
|
40
|
-
A breaking wire change increases the bridge protocol version. This includes changed meanings,
|
|
41
|
-
required fields, and new response variants an older receiver rejects. Optional fields and new
|
|
42
|
-
messages need no bump only when older receivers can safely ignore or NACK them. Parsing success
|
|
43
|
-
alone does not prove compatible SDK behavior.
|
|
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
|
-
|
|
50
|
-
An SDK that requires a newer protocol needs a host that supports that contract. Updating the SDK
|
|
51
|
-
package does not update the host in the embedding application.
|