@notionhq/custom-blocks-dev-shell 0.3.1 → 0.4.1
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 +43 -18
- package/data/customers.json +286 -0
- package/data/meetings.json +519 -0
- package/data/people.json +171 -47
- package/data/projects.json +338 -0
- package/data/tasks.json +828 -38
- package/dist/assets/index-CohEBjwO.css +2 -0
- package/dist/assets/index-G-f2Po2-.js +12 -0
- package/dist/index.html +3 -3
- package/dist-cli/cli/published-cli.js +1276 -722
- package/docs/bindings.md +17 -22
- package/docs/bridge/changelog.md +66 -19
- package/docs/bridge/protocol.md +172 -83
- package/docs/bridge/versioning.md +16 -4
- package/docs/data-sources.md +44 -31
- package/docs/host/README.md +35 -40
- package/docs/host/docs/compatibility.md +71 -31
- package/docs/host/docs/handlers.md +31 -15
- package/docs/host/docs/host-contract.md +83 -76
- package/docs/host/docs/lifecycle.md +76 -53
- package/package.json +1 -1
- package/data/radar.json +0 -87
- package/dist/assets/index-Do-x8yIt.css +0 -2
- package/dist/assets/index-Jy9OWV_k.js +0 -12
package/docs/bindings.md
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
# Dev shell bindings
|
|
2
2
|
|
|
3
|
-
A binding connects a
|
|
4
|
-
|
|
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
|
|
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,26 @@ 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
|
|
88
|
+
## Edit bindings
|
|
89
|
+
|
|
90
|
+
Open **Bindings → Data access** to select files from your worker’s `data/` directory and map their
|
|
91
|
+
properties. Changes apply as you make them. See the [sample data format](data-sources.md) to
|
|
92
|
+
define a source.
|
|
93
93
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
**Page access** appears when the manifest declares at least one page slot. Select a page from your
|
|
95
|
+
loaded sample data to apply the selection immediately. Named page selections are available in the
|
|
96
|
+
shell UI. Blocks can use the SDK to read sample pages by ID.
|
|
97
97
|
|
|
98
98
|
A property maps automatically only when exactly one source property matches its key or name and has
|
|
99
99
|
the same type. If no property matches, or several properties match, the property stays unmapped.
|
|
100
|
-
|
|
100
|
+
Select a mapping manually when automatic matching leaves it unmapped. Selecting a different source
|
|
101
|
+
resets its property mappings.
|
|
101
102
|
|
|
102
103
|
## Initialization and refresh
|
|
103
104
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
The shell mounts the preview once every declared data source and property is mapped. Changing a data
|
|
106
|
+
source or property mapping restarts the preview once the bindings are complete. You can finish
|
|
107
|
+
mapping properties while the dialog is open.
|
|
107
108
|
|
|
108
109
|
The shell keeps binding selections separately for each block until you refresh the browser. Refresh
|
|
109
110
|
the shell to restore each block's CLI source and property selections, with automatic matching for
|
|
@@ -111,9 +112,3 @@ properties without an override.
|
|
|
111
112
|
|
|
112
113
|
See [live updates and local writes](data-sources.md#live-updates-and-local-writes) for state
|
|
113
114
|
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.
|
package/docs/bridge/changelog.md
CHANGED
|
@@ -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
|
-
[
|
|
8
|
-
|
|
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,30 +20,78 @@ 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
|
|
24
|
-
| 9 | — | `0.6.0` · 2026-11-05 | — | Native page icons
|
|
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
|
|
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 |
|
|
27
28
|
|
|
28
29
|
`—` means no release in that package line carried that specific protocol version.
|
|
29
30
|
|
|
30
|
-
Host compatibility depends on `connect
|
|
31
|
+
Host compatibility depends on the protocol version selected during `connect`, not the SDK package
|
|
32
|
+
version.
|
|
31
33
|
|
|
32
34
|
Native host package pins and protocol mappings are tracked separately in
|
|
33
35
|
[Notion's native host configuration](https://github.com/makenotion/notion-next/blob/main/src/cli/mobile/codegen/customBlockHost/config.ts)
|
|
34
36
|
and
|
|
35
37
|
[mobile shell registry](https://github.com/makenotion/notion-next/blob/main/src/cloudflare-customBlockWorker/lib/mobileShellRegistry.ts).
|
|
36
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
|
+
|
|
37
80
|
## Protocol 11: location removal and data source binding names
|
|
38
81
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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.
|
|
43
91
|
|
|
44
|
-
|
|
45
|
-
shell registration must use the published release
|
|
46
|
-
|
|
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.
|
|
47
95
|
|
|
48
96
|
`location` represents the source of an item in Notion's aggregated views. Protocol 11 removes it
|
|
49
97
|
from manifests, binding schemas, and page property values. Updated hosts omit it for every supported
|
|
@@ -65,13 +113,13 @@ writes share a loose shape: names and colors accept strings, color is optional,
|
|
|
65
113
|
native icon fields are retained. Hosts resolve names and default omitted colors to gray.
|
|
66
114
|
|
|
67
115
|
Protocols 3–8 receive external SVG URLs in page operation results. Protocols 6–8 receive the same
|
|
68
|
-
fallback in query results
|
|
116
|
+
fallback in query results. Protocols 3–5 keep their flat query format without appearance fields. The
|
|
69
117
|
released-SDK compatibility corpus exercises these conversions.
|
|
70
118
|
|
|
71
119
|
## Protocol 8: local manifest declarations
|
|
72
120
|
|
|
73
121
|
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
|
|
122
|
+
reads that metadata and sends the declaration in `connect.manifest`. Initialization no longer
|
|
75
123
|
fetches `/manifest`.
|
|
76
124
|
|
|
77
125
|
The host option `manifestSource` selects the initialization manifest: `"sandbox"` uses the
|
|
@@ -89,7 +137,7 @@ from `connect`.
|
|
|
89
137
|
|
|
90
138
|
Bridge NACKs (`invalidHostMessage` and `invalidSandboxMessage`) gain an optional string `requestId`.
|
|
91
139
|
Updated SDKs complete the matching request immediately when a rejection can be correlated. Older
|
|
92
|
-
readers ignore the additional field
|
|
140
|
+
readers ignore the additional field. Updated readers continue to accept NACKs without an ID.
|
|
93
141
|
Uncorrelated requests use the SDK's 60-second timeout. This additive change retains protocol 8.
|
|
94
142
|
|
|
95
143
|
### Protocol 5: unavailable containing-page context
|
|
@@ -97,8 +145,7 @@ Uncorrelated requests use the SDK's 60-second timeout. This additive change reta
|
|
|
97
145
|
On October 2, 2026, SDK 0.2.17 added `{ type: "unavailable" }` to containing-page context while
|
|
98
146
|
retaining protocol 5. SDK 0.2.16 rejects that shape. The host preserves later protocol 5 behavior
|
|
99
147
|
and accepts the limitation for the older SDK, as decided on October 31, 2026. Affected blocks must
|
|
100
|
-
upgrade and rebuild.
|
|
101
|
-
describes current compatibility behavior.
|
|
148
|
+
upgrade and rebuild.
|
|
102
149
|
|
|
103
150
|
### Protocol 6: richer fallback properties
|
|
104
151
|
|
|
@@ -114,5 +161,5 @@ properties to every protocol 6 block.
|
|
|
114
161
|
Blocks built with the later protocol 6 SDKs therefore lose those property values when their host
|
|
115
162
|
updates. UI that displays the values can become empty, and code that assumes a property object is
|
|
116
163
|
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
|
|
164
|
+
fallback property objects. Host adapters continue returning the current page shape. The host runtime
|
|
118
165
|
applies the protocol-specific conversion.
|
package/docs/bridge/protocol.md
CHANGED
|
@@ -6,63 +6,139 @@ 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.
|
|
10
|
-
[
|
|
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
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
`
|
|
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
|
|
26
|
-
`
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
`
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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.
|
|
49
125
|
|
|
50
126
|
## Manifests
|
|
51
127
|
|
|
52
128
|
A manifest declares a block's data sources and display metadata. `manifestSchema` defines its fields
|
|
53
129
|
and defaults omitted `dataSources` and each data source's omitted `properties` to `{}`.
|
|
54
130
|
|
|
55
|
-
`isLocalBlockServerUrl(url)` accepts HTTP
|
|
56
|
-
without credentials. It checks the address only. The host also requires a
|
|
57
|
-
a different origin from its embedding page.
|
|
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.
|
|
58
134
|
|
|
59
135
|
## Message identity
|
|
60
136
|
|
|
61
|
-
-
|
|
62
|
-
- `queryDataSource`
|
|
137
|
+
- Requests and their results use `requestId`.
|
|
138
|
+
- `queryDataSource` starts a subscription. The request and every update use its stable
|
|
63
139
|
`subscriptionId`.
|
|
64
|
-
-
|
|
65
|
-
-
|
|
140
|
+
- `connect` and `init` each use their own `requestId`.
|
|
141
|
+
- Notifications, such as `ready` and `resize`, have no correlation ID.
|
|
66
142
|
- Bridge NACKs include the rejected message's `requestId` when it is a string. The ID identifies the
|
|
67
143
|
original request, including when the rejected message is its response.
|
|
68
144
|
|
|
@@ -91,51 +167,58 @@ request with `invalid_sandbox_message`. When the SDK rejects a host response, it
|
|
|
91
167
|
matching request locally with `invalid_host_message` and includes the ID in `invalidHostMessage`.
|
|
92
168
|
Both errors have `isRetryable: false`.
|
|
93
169
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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.
|
|
97
179
|
|
|
98
180
|
Request completion clears its timer, removes the pending entry, and ignores duplicate or late
|
|
99
181
|
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
|
|
101
|
-
resulting state before repeating it. Data source subscriptions use a separate lifecycle.
|
|
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.
|
|
102
184
|
|
|
103
|
-
|
|
104
|
-
|
|
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`.
|
|
105
188
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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`.
|
|
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.
|
|
113
192
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
case, it sends `initResult.error` with `invalid_init_payload` instead of a NACK. Otherwise, it sends
|
|
119
|
-
`invalidHostMessage`.
|
|
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.
|
|
120
197
|
|
|
121
198
|
`CustomBlockErrorInfo` carries `code`, `message`, and `isRetryable`. Error schemas accept any string
|
|
122
199
|
for `code`, including unknown codes. TypeScript aliases list known codes for autocomplete.
|
|
123
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
|
+
|
|
124
208
|
## Data sources
|
|
125
209
|
|
|
126
210
|
### Bindings and IDs
|
|
127
211
|
|
|
128
|
-
|
|
129
|
-
|
|
212
|
+
`getDataSourceResult` returns one `BridgeDataSourceBinding` for the requested manifest key.
|
|
213
|
+
`dataSourceSchema` contains only actual database properties.
|
|
130
214
|
|
|
131
215
|
Sandbox-to-host object references are raw IDs. The SDK resolves semantic data source and property
|
|
132
|
-
keys before sending query or page
|
|
216
|
+
keys before sending query or page operation requests. Get and update requests can carry an optional
|
|
133
217
|
resolved `dataSourceId`.
|
|
134
218
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
without sending a message.
|
|
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.
|
|
139
222
|
|
|
140
223
|
### Query requests
|
|
141
224
|
|
|
@@ -153,8 +236,7 @@ branches, operators, person references, and sort objects reject extra fields.
|
|
|
153
236
|
#### Creator, editor, and status filters
|
|
154
237
|
|
|
155
238
|
`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.
|
|
157
|
-
`last_edited_by` and group operands in `created_by` filters.
|
|
239
|
+
members of the group. Bot actors count as present for empty checks.
|
|
158
240
|
|
|
159
241
|
Status filters support option operators and stored group names. Group operators accept one name or
|
|
160
242
|
an array of 1–5 names. Hosts must validate each name against the bound Status property.
|
|
@@ -185,15 +267,28 @@ filter: {
|
|
|
185
267
|
`created_time` and `last_edited_time` use Date operators without `target`: timestamps have no end
|
|
186
268
|
date.
|
|
187
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
|
+
|
|
188
283
|
## Grants
|
|
189
284
|
|
|
190
285
|
`manifest.grants` lists `{ action, resource }` declarations. `action` is an open string and
|
|
191
|
-
`resource` is an open string or a
|
|
192
|
-
|
|
193
|
-
|
|
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.
|
|
194
289
|
|
|
195
290
|
Resources for page actions can name one manifest data source as `data_source:<key>`. The key is the
|
|
196
|
-
semantic key from `manifest.dataSources
|
|
291
|
+
semantic key from `manifest.dataSources`. Hosts resolve it to the bound data source when they record
|
|
197
292
|
and check grants. Bare `data_source` covers every declared key.
|
|
198
293
|
|
|
199
294
|
The `not_granted` error code is reserved for a request that the viewer's grants do not cover, with
|
|
@@ -202,8 +297,8 @@ SDK's grants guide documents the vocabulary.
|
|
|
202
297
|
|
|
203
298
|
## Page context
|
|
204
299
|
|
|
205
|
-
|
|
206
|
-
|
|
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
|
|
207
302
|
containing page itself is inaccessible. The unavailable shape never carries a page ID. This is
|
|
208
303
|
distinct from an accessible page with an inaccessible parent
|
|
209
304
|
(`page.parent: { type: "unavailable" }`).
|
|
@@ -215,25 +310,19 @@ must carry the same raw property ID in its `id` field.
|
|
|
215
310
|
|
|
216
311
|
## Page responses
|
|
217
312
|
|
|
218
|
-
Host handlers return
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
fields, including archive state and creation
|
|
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.
|
|
222
317
|
|
|
223
318
|
Page reads return string values for `unique_id`, `formula`, `rollup`, `button`, and `verification`,
|
|
224
319
|
preserving each property's type. These properties are read-only. Values use stored text, or `""`
|
|
225
320
|
when absent. Hosts do not evaluate formulas or rollups.
|
|
226
321
|
|
|
227
|
-
|
|
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
|
|
322
|
+
### Native page icons
|
|
232
323
|
|
|
233
|
-
|
|
234
|
-
|
|
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.
|
|
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.
|
|
237
326
|
|
|
238
327
|
`createPage` accepts native icons, emoji, custom emoji, and URL-backed icons and covers. The
|
|
239
328
|
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
|
-
[
|
|
8
|
-
|
|
7
|
+
[connection reference](../host/docs/compatibility.md) describes negotiation and version
|
|
8
|
+
requirements.
|
|
9
9
|
|
|
10
10
|
## Version identifiers
|
|
11
11
|
|
|
12
|
-
- **
|
|
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
|
-
|
|
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.
|