@notionhq/custom-blocks 0.3.2 → 0.3.4
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/LICENSE +21 -0
- package/README.md +13 -19
- package/dist/bridge/SandboxBridge.d.ts +0 -2
- package/dist/bridge/SandboxBridge.d.ts.map +1 -1
- package/dist/bridge/SandboxBridge.js +16 -39
- package/dist/bridge/SandboxInitialization.d.ts +1 -3
- package/dist/bridge/SandboxInitialization.d.ts.map +1 -1
- package/dist/bridge/SandboxInitialization.js +13 -15
- package/dist/bridge/appearance.d.ts +2 -10
- package/dist/bridge/appearance.d.ts.map +1 -1
- package/dist/bridge/appearance.js +2 -10
- package/dist/bridge/dataSources/query.d.ts +1 -2
- package/dist/bridge/dataSources/query.d.ts.map +1 -1
- package/dist/bridge/dataSources/query.js +15 -398
- package/dist/bridge/dataSources/queryFilter.d.ts +10 -0
- package/dist/bridge/dataSources/queryFilter.d.ts.map +1 -0
- package/dist/bridge/dataSources/queryFilter.js +123 -0
- package/dist/bridge/dataSources/resolveProperty.d.ts +1 -20
- package/dist/bridge/dataSources/resolveProperty.d.ts.map +1 -1
- package/dist/bridge/dataSources/resolveProperty.js +37 -32
- package/dist/bridge/dataSources/resolvePropertyAddress.d.ts +10 -0
- package/dist/bridge/dataSources/resolvePropertyAddress.d.ts.map +1 -0
- package/dist/bridge/dataSources/resolvePropertyAddress.js +55 -0
- package/dist/bridge/dataSources/resolveSorts.d.ts +10 -0
- package/dist/bridge/dataSources/resolveSorts.d.ts.map +1 -0
- package/dist/bridge/dataSources/resolveSorts.js +80 -0
- package/dist/bridge/hostState.d.ts +3 -7
- package/dist/bridge/hostState.d.ts.map +1 -1
- package/dist/bridge/hostState.js +0 -24
- package/dist/bridge/page.d.ts +9 -3
- package/dist/bridge/page.d.ts.map +1 -1
- package/dist/bridge/page.js +19 -2
- package/dist/bridge/readLocalManifest.d.ts +23 -0
- package/dist/bridge/readLocalManifest.d.ts.map +1 -0
- package/dist/bridge/readLocalManifest.js +46 -0
- package/dist/bridge/sandboxClient.d.ts +0 -2
- package/dist/bridge/sandboxClient.d.ts.map +1 -1
- package/dist/bridge/sandboxClient.js +50 -24
- package/dist/protocol/dataSources/dataSourcePage.d.ts +3 -4
- package/dist/protocol/dataSources/dataSourcePage.js +2 -3
- package/dist/protocol/index.d.ts +1 -0
- package/dist/protocol/index.js +1 -0
- package/dist/protocol/isLocalBlockServerUrl.d.ts +2 -0
- package/dist/protocol/isLocalBlockServerUrl.js +9 -0
- package/dist/protocol/messages/connect.d.ts +2 -2
- package/dist/protocol/messages/connect.js +2 -2
- package/dist/protocol/messages/createPage.d.ts +1 -1
- package/dist/protocol/messages/createPage.js +1 -1
- package/dist/protocol/messages/createPageResult.d.ts +3 -3
- package/dist/protocol/messages/createPageResult.js +4 -4
- package/dist/protocol/messages/getPage.d.ts +2 -2
- package/dist/protocol/messages/getPage.js +4 -4
- package/dist/protocol/messages/hostToSandbox.d.ts +3 -3
- package/dist/protocol/messages/hostToSandbox.js +10 -10
- package/dist/protocol/messages/init.d.ts +1 -1
- package/dist/protocol/messages/queryDataSource.d.ts +24 -0
- package/dist/protocol/messages/queryDataSource.js +2 -0
- package/dist/protocol/messages/queryDataSourceResult.d.ts +3 -3
- package/dist/protocol/messages/queryDataSourceResult.js +5 -5
- package/dist/protocol/messages/sandboxToHost.d.ts +8 -0
- package/dist/protocol/messages/updatePageResult.d.ts +3 -3
- package/dist/protocol/messages/updatePageResult.js +4 -4
- package/dist/protocol/pages/page.d.ts +4 -4
- package/dist/protocol/pages/page.js +2 -2
- package/dist/protocol/parent.d.ts +1 -1
- package/dist/protocol/protocolVersion.d.ts +3 -2
- package/dist/protocol/protocolVersion.js +4 -2
- package/dist/react/useDataSource.d.ts +2 -2
- package/dist/react/useDataSource.js +2 -2
- package/dist/types.d.ts +5 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/docs/block-location.md +6 -4
- package/docs/bridge-interceptors.md +4 -0
- package/docs/build-tools.md +58 -0
- package/docs/data-sources.md +24 -18
- package/docs/deployment.md +23 -36
- package/docs/errors.md +75 -52
- package/docs/lifecycle.md +10 -3
- package/docs/pages.md +84 -76
- package/docs/users.md +4 -4
- package/package.json +4 -19
- package/src/bridge/SandboxBridge.ts +18 -48
- package/src/bridge/SandboxInitialization.ts +14 -20
- package/src/bridge/appearance.ts +2 -10
- package/src/bridge/dataSources/query.ts +17 -530
- package/src/bridge/dataSources/queryFilter.ts +181 -0
- package/src/bridge/dataSources/resolveProperty.ts +48 -39
- package/src/bridge/dataSources/resolvePropertyAddress.ts +62 -0
- package/src/bridge/dataSources/resolveSorts.ts +107 -0
- package/src/bridge/hostState.ts +3 -43
- package/src/bridge/page.ts +28 -4
- package/src/bridge/readLocalManifest.ts +60 -0
- package/src/bridge/sandboxClient.ts +63 -38
- package/src/react/useDataSource.ts +2 -2
- package/src/types.ts +5 -5
- package/dist/bridge/loadManifest.d.ts +0 -21
- package/dist/bridge/loadManifest.d.ts.map +0 -1
- package/dist/bridge/loadManifest.js +0 -85
- package/src/bridge/loadManifest.ts +0 -114
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+DAA+D,CAAA;AACxG,OAAO,KAAK,EACX,kBAAkB,EAClB,YAAY,EACZ,MAAM,yCAAyC,CAAA;AAChD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,yDAAyD,CAAA;AACvG,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,+DAA+D,CAAA;AACnH,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,sDAAsD,CAAA;AACvG,OAAO,KAAK,EACX,2BAA2B,EAC3B,oBAAoB,EACpB,MAAM,sDAAsD,CAAA;AAC7D,OAAO,KAAK,EACX,6BAA6B,EAC7B,gBAA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AE,gBAAgB,CAAA;IACxB,UAAU,EAAE,0BAA0B,CAAA;IACtC,QAAQ,CAAC,EAAE,wBAAwB,CAAA;CACnC,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC7B,IAAI,EAAE,YAAY,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG,oBAAoB,CAChD,qBAAqB,EACrB,4BAA4B,CAC5B,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG,oBAAoB,CACvD,4BAA4B,EAC5B,mCAAmC,CACnC,CAAA;AAED,MAAM,MAAM,gBAAgB,GACzB;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,UAAU,CAAA;CAAE,GACvC;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,8BAA8B,CAAA;CAAE,CAAA;AAE7D,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,EAAE,MAAM,GAAG,WAAW,CAAC,CAAA;AAExE,MAAM,MAAM,eAAe,GAAG,oBAAoB,CACjD,sBAAsB,EACtB,6BAA6B,CAC7B,CAAA;AAED,MAAM,MAAM,aAAa,GAAG,oBAAoB,CAC/C,oBAAoB,EACpB,2BAA2B,CAC3B,CAAA"}
|
package/dist/version.js
CHANGED
package/docs/block-location.md
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
# Block location and appearance
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Host context includes the block's location, current user, manifest, theme, and contrast mode. These
|
|
4
|
+
APIs let your block respond to its context and match Notion's appearance. This reference covers
|
|
5
|
+
getters for current values, subscriptions for initial values and later changes, and React hooks for
|
|
6
|
+
components.
|
|
5
7
|
|
|
6
8
|
## API overview
|
|
7
9
|
|
|
@@ -51,7 +53,7 @@ console.log(customBlock.getTheme()) // Read the current theme once.
|
|
|
51
53
|
## Current user
|
|
52
54
|
|
|
53
55
|
Use `getCurrentUser()`, `subscribeToCurrentUser()`, and `useCurrentUser()` to access the viewing
|
|
54
|
-
user's `NotionUser`. See [users](
|
|
56
|
+
user's `NotionUser`. See [users](users.md#reading-the-current-user) for profile fields and user
|
|
55
57
|
APIs.
|
|
56
58
|
|
|
57
59
|
## Custom block ID
|
|
@@ -171,5 +173,5 @@ Use `getManifest()`, `subscribeToManifest()`, and `useManifest()` to access the
|
|
|
171
173
|
`CustomBlockManifest`. The manifest stays fixed for the lifetime of the running block, so each
|
|
172
174
|
subscription delivers it once. You can register before initialization without an error.
|
|
173
175
|
|
|
174
|
-
See [data sources](
|
|
176
|
+
See [data sources](data-sources.md) for manifest details and `subscribeToDataSource()` for query
|
|
175
177
|
snapshots.
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Bridge message interceptors
|
|
2
2
|
|
|
3
|
+
Bridge message interceptors inspect outgoing SDK requests or supply responses without a host round
|
|
4
|
+
trip. This reference describes registration, response matching, and cleanup for controlled bridge
|
|
5
|
+
integrations.
|
|
6
|
+
|
|
3
7
|
Import `registerMessageInterceptor` from `@notionhq/custom-blocks/bridge` to inspect or replace SDK
|
|
4
8
|
messages sent to the host. The function accepts a `MessageInterceptor` and returns a function that
|
|
5
9
|
removes it.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Build-tool reference
|
|
2
|
+
|
|
3
|
+
The `@notionhq/custom-blocks/bundle` entrypoint exposes Node.js functions for deployment tools. It
|
|
4
|
+
provides build and upload operations. Worker projects normally use `ntn workers deploy`.
|
|
5
|
+
|
|
6
|
+
The Apps CLI calls `build` and `upload` from `build-blocks` and `upload-blocks`, respectively.
|
|
7
|
+
|
|
8
|
+
```ts
|
|
9
|
+
import { build, upload } from "@notionhq/custom-blocks/bundle"
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Build bundles
|
|
13
|
+
|
|
14
|
+
`build(args: BuildArgs)` returns a `Promise<BuildOutput>`. By default, it imports the worker bundle
|
|
15
|
+
at `dist/index.js` and reads its custom block capabilities. With `manifest`, it reads an Apps SDK
|
|
16
|
+
capability manifest from a JSON file instead. That file contains a `capabilities` array. Each custom
|
|
17
|
+
block capability contains its block manifest in `config.manifest`.
|
|
18
|
+
|
|
19
|
+
`BuildArgs` contains these fields:
|
|
20
|
+
|
|
21
|
+
- `out`: Required output directory. Each block's bundle is copied to `<out>/<key>`.
|
|
22
|
+
- `cwd`: Optional project root. Defaults to the process's current directory.
|
|
23
|
+
- `manifest`: Optional path to the Apps SDK capability manifest.
|
|
24
|
+
|
|
25
|
+
Relative `out`, `manifest`, and block source paths resolve from the project root. For a project
|
|
26
|
+
source, `build` installs dependencies, runs the configured build command, and copies its output. For
|
|
27
|
+
a static source, `build` copies the source directory without a build command.
|
|
28
|
+
|
|
29
|
+
`BuildOutput.blocks` is an array of `BuiltBlock` results. Each result contains the block's `key`,
|
|
30
|
+
`bundleDir`, `checksumCrc32`, and `bundleSizeBytes`. The size is the compressed tarball's byte
|
|
31
|
+
length. When the worker or capability manifest declares no custom blocks, `blocks` is empty.
|
|
32
|
+
|
|
33
|
+
The equivalent CLI command is `notion-custom-blocks build --out <dir>`. It accepts `--cwd` and
|
|
34
|
+
`--manifest` with the same path rules. `printBuildOutput` writes a `BuildOutput` as single-line JSON
|
|
35
|
+
between `<__notion_custom_block__>` and `</__notion_custom_block__>`.
|
|
36
|
+
|
|
37
|
+
For dependency placement, see
|
|
38
|
+
[Browser and server dependencies](deployment.md#browser-and-server-dependencies).
|
|
39
|
+
|
|
40
|
+
## Upload bundles
|
|
41
|
+
|
|
42
|
+
`upload(targets: UploadsInput)` returns a `Promise<UploadOutput>`. `UploadsInput` maps block keys to
|
|
43
|
+
`UploadTarget` objects with these fields:
|
|
44
|
+
|
|
45
|
+
- `uploadUrl`: Required presigned upload URL.
|
|
46
|
+
- `bundleDir`: Required path to the bundle directory.
|
|
47
|
+
- `headers`: Optional map of headers supplied with the presigned URL, such as `Content-Length` and
|
|
48
|
+
object tags.
|
|
49
|
+
|
|
50
|
+
`upload` compresses each directory and sends the tarball with an HTTP PUT request. It forwards the
|
|
51
|
+
supplied headers and sets `Content-Type` to `application/gzip` and `x-amz-checksum-crc32` to the
|
|
52
|
+
archive's checksum. Relative `bundleDir` paths resolve from the process's current directory.
|
|
53
|
+
|
|
54
|
+
On success, `UploadOutput.uploaded` maps every uploaded block key to `true`. A failed upload throws
|
|
55
|
+
an error and stops the remaining uploads. Earlier uploads are not rolled back.
|
|
56
|
+
|
|
57
|
+
The equivalent CLI command is `notion-custom-blocks upload --uploads '<json>'`. `parseUploadsInput`
|
|
58
|
+
parses and validates that JSON as `UploadsInput`.
|
package/docs/data-sources.md
CHANGED
|
@@ -10,8 +10,8 @@ Each snapshot contains `items`, `propertyIdsByKey`, `isLoading`, and `hasMore`.
|
|
|
10
10
|
replaces the previous rows in the snapshot. Subscriptions remain independent, even when they query
|
|
11
11
|
the same data source.
|
|
12
12
|
|
|
13
|
-
Queries default to 20 rows
|
|
14
|
-
pagination, filter, and sort restrictions.
|
|
13
|
+
Queries default to 20 rows. The host enforces the maximum row limit. See
|
|
14
|
+
[Known limitations](#known-limitations) for pagination, filter, and sort restrictions.
|
|
15
15
|
|
|
16
16
|
## Bind a data source
|
|
17
17
|
|
|
@@ -161,9 +161,10 @@ time** column. Use the column's bound key or actual property ID.
|
|
|
161
161
|
|
|
162
162
|
### Row limits
|
|
163
163
|
|
|
164
|
-
`limit` defaults to 20 and must be a positive integer. The SDK
|
|
165
|
-
|
|
166
|
-
|
|
164
|
+
`limit` defaults to 20 and must be a positive safe integer. The SDK forwards the requested limit
|
|
165
|
+
without capping it. The Notion host currently supports up to 1,000 rows and rejects larger requests
|
|
166
|
+
with an error that states the maximum. Each query reads from the start of the matching rows. A
|
|
167
|
+
larger limit replaces the previous snapshot with a larger result.
|
|
167
168
|
|
|
168
169
|
`hasMore` indicates that more matching rows exist beyond the result. It does not provide a cursor or
|
|
169
170
|
guarantee that increasing the limit can retrieve every row.
|
|
@@ -242,7 +243,7 @@ the filter type, not the column.
|
|
|
242
243
|
| `multi_select` | `contains`, `contains_all`, `does_not_contain`, `is_empty`, `is_not_empty` |
|
|
243
244
|
| `date` | `equals`, `before`, `after`, `on_or_before`, `on_or_after`, relative ranges, `is_empty`, `is_not_empty` |
|
|
244
245
|
| `people` | `contains`, `does_not_contain`, `is_empty`, `is_not_empty` |
|
|
245
|
-
| `relation` | `contains`, `does_not_contain`
|
|
246
|
+
| `relation` | `contains`, `does_not_contain`, `is_empty`, `is_not_empty` |
|
|
246
247
|
| `created_by` | `contains`, `does_not_contain`, `is_empty`, `is_not_empty` |
|
|
247
248
|
|
|
248
249
|
- Select, multi-select, and status filters accept one option name or an array of option names.
|
|
@@ -257,9 +258,9 @@ the filter type, not the column.
|
|
|
257
258
|
- Creator filters accept one explicit human user reference. Groups, bots, and organization bots are
|
|
258
259
|
not supported as filter references. `does_not_contain` also matches rows with non-human or missing
|
|
259
260
|
creators. Empty checks test whether creator metadata is missing.
|
|
260
|
-
- Relation filters accept one page ID in dashed or undashed UUID format.
|
|
261
|
-
- Relation `does_not_contain`
|
|
262
|
-
unsupported.
|
|
261
|
+
- Relation membership filters accept one page ID in dashed or undashed UUID format.
|
|
262
|
+
- Relation `does_not_contain` returns rows that do not reference the specified page. Rows with no
|
|
263
|
+
related pages also match. Multiple targets are unsupported.
|
|
263
264
|
|
|
264
265
|
```ts
|
|
265
266
|
filter: {
|
|
@@ -388,7 +389,9 @@ await row.updateByKey({
|
|
|
388
389
|
Use `updateByKey` for manifest keys and `updateById` for raw property IDs. The SDK resolves manifest
|
|
389
390
|
keys before sending the request.
|
|
390
391
|
|
|
391
|
-
|
|
392
|
+
Pages returned by `dataSources.getPage`, `dataSources.query`, and `dataSources.create` support
|
|
393
|
+
property writes through `updateByKey`. Pages returned by `pages.get` and `pages.create` support
|
|
394
|
+
property writes through `updateById`.
|
|
392
395
|
|
|
393
396
|
### Archiving and unarchiving a row
|
|
394
397
|
|
|
@@ -425,7 +428,7 @@ function customBlock.getManifest(): CustomBlockManifest;
|
|
|
425
428
|
|
|
426
429
|
Framework-neutral getter for the same manifest returned by `useManifest()`.
|
|
427
430
|
`customBlock.subscribeToManifest(callback)` follows the
|
|
428
|
-
[context subscription contract](
|
|
431
|
+
[context subscription contract](block-location.md#reading-values-and-following-changes). The
|
|
429
432
|
manifest stays fixed for the lifetime of the running block, so each subscription delivers it once.
|
|
430
433
|
You can register before initialization without an error.
|
|
431
434
|
|
|
@@ -473,10 +476,10 @@ export function ScoreList() {
|
|
|
473
476
|
)
|
|
474
477
|
})}
|
|
475
478
|
</ul>
|
|
476
|
-
{hasMore && limit <
|
|
479
|
+
{hasMore && limit < 1000 ? (
|
|
477
480
|
<button
|
|
478
481
|
type="button"
|
|
479
|
-
onClick={() => setLimit(Math.min(limit + 20,
|
|
482
|
+
onClick={() => setLimit(Math.min(limit + 20, 1000))}
|
|
480
483
|
disabled={isLoading}
|
|
481
484
|
>
|
|
482
485
|
{isLoading ? "Loading…" : "Load more"}
|
|
@@ -489,9 +492,12 @@ export function ScoreList() {
|
|
|
489
492
|
|
|
490
493
|
## Known limitations
|
|
491
494
|
|
|
492
|
-
- **Row limits and pagination:**
|
|
493
|
-
|
|
494
|
-
|
|
495
|
+
- **Row limits and pagination:** Hosts enforce their own limits. The Notion app supports up to 32
|
|
496
|
+
active subscriptions per custom block, each with up to 1,000 rows. Requests that exceed either
|
|
497
|
+
limit return an error. Queries have no cursor or offset. Increasing `limit` replaces the snapshot
|
|
498
|
+
with a larger result from the start of the matching rows. If `hasMore` is true, increase `limit`
|
|
499
|
+
up to 1,000 or use filters to query smaller subsets. Unsubscribe from queries you no longer need
|
|
500
|
+
to free subscription slots.
|
|
495
501
|
- **Filter and sort rules:** Use one property condition or one `and` group with up to 25 conditions.
|
|
496
502
|
Nested groups and `or` are unsupported. You can sort by up to 10 unique properties. Empty values
|
|
497
503
|
sort last in both directions. See the table below for property support and [Filters](#filters) for
|
|
@@ -534,7 +540,7 @@ refer to the core values inside each property object. For example, “Number”
|
|
|
534
540
|
| `people` | 🟢 User or group references | 🟢 Supported | 🟢 Supported | 🟢 Native name ordering |
|
|
535
541
|
| `files` | 🟡 External files only | 🟡 File URLs only | 🔴 Unavailable | 🔴 Unavailable |
|
|
536
542
|
| `unique_id` | 🟡 Text fallback | 🔴 Unavailable | 🔴 Unavailable | 🔴 Unavailable |
|
|
537
|
-
| `relation` | 🟢 Page reference array | 🟡 Replaces value. Rejects `has_more: true`. | 🟢 Supported | 🔴 Unavailable
|
|
543
|
+
| `relation` | 🟢 Page reference array | 🟡 Replaces value. Rejects `has_more: true`. | 🟢 Supported | 🔴 Unavailable |
|
|
538
544
|
| `place` | 🟢 Place object | 🟢 Supported | 🔴 Unavailable | 🔴 Unavailable |
|
|
539
545
|
| `formula` | 🟡 Text fallback | 🔴 Unavailable | 🔴 Unavailable | 🔴 Unavailable |
|
|
540
546
|
| `rollup` | 🟡 Text fallback | 🔴 Unavailable | 🔴 Unavailable | 🔴 Unavailable for numeric targets or numeric aggregations. ⚫ Notion cannot sort other rollups. |
|
|
@@ -603,7 +609,7 @@ Other write restrictions:
|
|
|
603
609
|
- **Relations:** Supply the complete replacement list of related pages. The host rejects
|
|
604
610
|
`has_more: true`, which indicates an incomplete list.
|
|
605
611
|
|
|
606
|
-
See [Pages property support](
|
|
612
|
+
See [Pages property support](pages.md#property-support) for the page-property read shapes.
|
|
607
613
|
|
|
608
614
|
## Types
|
|
609
615
|
|
package/docs/deployment.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# Deployment and manifests
|
|
2
2
|
|
|
3
|
-
A custom block is a static web bundle
|
|
4
|
-
into a sandboxed `<iframe>`. Custom blocks ship as part of a worker
|
|
5
|
-
data source schema with `worker.customBlock(...)` in the worker's `src/index.ts
|
|
6
|
-
`ntn workers deploy
|
|
3
|
+
A custom block is a static web bundle containing an `index.html` file and optional assets. Notion
|
|
4
|
+
loads the bundle into a sandboxed `<iframe>`. Custom blocks ship as part of a worker. Declare the
|
|
5
|
+
block source and data source schema with `worker.customBlock(...)` in the worker's `src/index.ts`.
|
|
6
|
+
Deploy with `ntn workers deploy`. Notion then serves the built bundle.
|
|
7
7
|
|
|
8
8
|
A custom block manifest describes the data sources a block requires, including their semantic keys,
|
|
9
9
|
display metadata, and property schemas. The block's `worker.customBlock(...)` declaration is the
|
|
@@ -11,20 +11,30 @@ manifest's single source of truth:
|
|
|
11
11
|
|
|
12
12
|
- **Deployed** — deploying persists the manifest on the block's definition record in Notion. The
|
|
13
13
|
host reads it from there and sends it to the SDK during initialization.
|
|
14
|
-
- **Local development** —
|
|
15
|
-
|
|
14
|
+
- **Local development** — dev tooling extracts the same worker declaration and injects it into the
|
|
15
|
+
block HTML as a JSON script with ID `notion-custom-block-manifest` and type `application/json`.
|
|
16
|
+
The SDK reads the manifest from this metadata and sends it in `connect`.
|
|
16
17
|
|
|
17
18
|
Notion reconciles custom block definitions by their Worker capability keys during deployment.
|
|
18
19
|
|
|
20
|
+
## Browser and server dependencies
|
|
21
|
+
|
|
22
|
+
Put packages used only by the custom block frontend, such as React and the custom blocks SDK, in
|
|
23
|
+
`devDependencies` in the Worker's root `package.json`. The frontend build includes their code in the
|
|
24
|
+
browser assets, so their package files do not need to ship with the Worker.
|
|
25
|
+
|
|
26
|
+
Keep packages that the Worker's server code imports in `dependencies`.
|
|
27
|
+
|
|
19
28
|
## Local development
|
|
20
29
|
|
|
21
|
-
Run `ntn workers customblocks dev` from
|
|
22
|
-
|
|
23
|
-
|
|
30
|
+
Run `ntn workers customblocks dev` from your worker project. The dev shell builds the worker and
|
|
31
|
+
reads its custom block declarations. It serves the shell and blocks on one port, with a separate
|
|
32
|
+
localhost subdomain for each block. Open the shell URL printed by the command. The default port is
|
|
33
|
+
`9873`; the launcher selects another port when needed. Vite provides source transforms and hot
|
|
34
|
+
reload.
|
|
24
35
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
this fetch and relies on the host-provided manifest from `init`.
|
|
36
|
+
Worker declarations are read when the dev shell starts. Restart it after changing a declaration to
|
|
37
|
+
regenerate the injected metadata, then reload the block. Block source files hot reload.
|
|
28
38
|
|
|
29
39
|
## Types
|
|
30
40
|
|
|
@@ -33,27 +43,4 @@ this fetch and relies on the host-provided manifest from `init`.
|
|
|
33
43
|
- `ManifestProperty` — a single property declaration inside a `ManifestDataSource`.
|
|
34
44
|
- `ManifestIcon` — the icon variant accepted on a `ManifestDataSource`.
|
|
35
45
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
`notion-custom-blocks build --manifest dist/manifest.json --out <dir>` reads static Apps SDK
|
|
39
|
-
capabilities. Paths in the manifest stay relative to the project root (the current directory, or
|
|
40
|
-
`--cwd`). Without `--manifest`, the command continues to import the Workers SDK bundle at
|
|
41
|
-
`dist/index.js`.
|
|
42
|
-
|
|
43
|
-
Node build tools use one entrypoint:
|
|
44
|
-
|
|
45
|
-
```ts
|
|
46
|
-
import { build, upload } from "@notionhq/custom-blocks/bundle"
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
`build` accepts `BuildArgs` and returns `BuildOutput` containing `BuiltBlock` results. `upload`
|
|
50
|
-
accepts `UploadsInput`, a map of block keys to `UploadTarget`, and returns `UploadOutput`.
|
|
51
|
-
`printBuildOutput` writes the sentinel-wrapped build result; `parseUploadsInput` validates JSON
|
|
52
|
-
upload arguments. The Apps CLI calls these functions from `build-blocks` and `upload-blocks`.
|
|
53
|
-
|
|
54
|
-
Relative `--out` paths also resolve from `--cwd`. Build results include `bundleSizeBytes`, the exact
|
|
55
|
-
compressed tarball length, for size-bound uploads.
|
|
56
|
-
|
|
57
|
-
Upload targets may include a `headers` map containing the headers returned by the server presign,
|
|
58
|
-
including `Content-Length` and object tags. The uploader forwards these alongside the tarball
|
|
59
|
-
checksum and content type.
|
|
46
|
+
For the Node.js build and upload API, see the [build-tool reference](build-tools.md).
|
package/docs/errors.md
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
# Error handling
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
SDK operations report failures through result objects, initialization failures, or subscription
|
|
4
|
+
state. This reference describes each error surface, the error payload, and known codes so your block
|
|
5
|
+
can display failures and decide when to retry.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
Pages, Users, navigation, and asynchronous Data sources methods return a result with a `status`
|
|
8
|
+
field. Success returns `{ status: "success", ... }` with the requested data. Failure returns
|
|
9
|
+
`{ status: "error", error }`. Initialization rejects on failure. Hooks and subscriptions report
|
|
10
|
+
errors separately.
|
|
9
11
|
|
|
10
12
|
## Error format
|
|
11
13
|
|
|
@@ -19,75 +21,96 @@ type CustomBlockErrorInfo<TCode extends string = string> = {
|
|
|
19
21
|
}
|
|
20
22
|
```
|
|
21
23
|
|
|
22
|
-
- `code` is a stable identifier
|
|
23
|
-
- `message` provides
|
|
24
|
-
- `isRetryable` indicates whether
|
|
25
|
-
request or
|
|
26
|
-
|
|
24
|
+
- `code` is a stable identifier for application logic.
|
|
25
|
+
- `message` provides details for developers. Its text can change.
|
|
26
|
+
- `isRetryable` indicates whether the operation could succeed if repeated without changes to the
|
|
27
|
+
request or configuration. A `false` value does not rule out success after you fix the query,
|
|
28
|
+
schema, or bindings.
|
|
27
29
|
|
|
28
|
-
Each API
|
|
29
|
-
|
|
30
|
+
Each API defines known `code` values for autocomplete and accepts other strings. This lets older
|
|
31
|
+
SDKs receive new codes from newer hosts.
|
|
30
32
|
|
|
31
33
|
## API-specific error types
|
|
32
34
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
Each operation has an error code type and an error info type:
|
|
36
|
+
|
|
37
|
+
| Operation | Code type | Info type |
|
|
38
|
+
| ------------------- | ------------------------------------------ | ------------------------------------------ |
|
|
39
|
+
| Create page | `CustomBlockCreatePageErrorCode` | `CustomBlockCreatePageErrorInfo` |
|
|
40
|
+
| Get page | `CustomBlockGetPageErrorCode` | `CustomBlockGetPageErrorInfo` |
|
|
41
|
+
| Open page | `CustomBlockOpenPageErrorCode` | `CustomBlockOpenPageErrorInfo` |
|
|
42
|
+
| Update page | `CustomBlockUpdatePageErrorCode` | `CustomBlockUpdatePageErrorInfo` |
|
|
43
|
+
| Get user | `CustomBlockGetUserErrorCode` | `CustomBlockGetUserErrorInfo` |
|
|
44
|
+
| List users | `CustomBlockListUsersErrorCode` | `CustomBlockListUsersErrorInfo` |
|
|
45
|
+
| Open external URL | `CustomBlockOpenExternalUrlErrorCode` | `CustomBlockOpenExternalUrlErrorInfo` |
|
|
46
|
+
| Query data source | `CustomBlockQueryDataSourceErrorCode` | `CustomBlockQueryDataSourceErrorInfo` |
|
|
47
|
+
| Resolve property | `CustomBlockPropertyErrorCode` | `CustomBlockPropertyErrorInfo` |
|
|
48
|
+
| Resolve data source | `CustomBlockDataSourceResolutionErrorCode` | `CustomBlockDataSourceResolutionErrorInfo` |
|
|
49
|
+
|
|
50
|
+
## Local page update errors
|
|
51
|
+
|
|
52
|
+
The SDK validates all properties before sending an update. These local errors have
|
|
53
|
+
`isRetryable: false`:
|
|
54
|
+
|
|
55
|
+
| Code | Cause |
|
|
56
|
+
| ------------------------ | ------------------------------------------------------------------------------ |
|
|
57
|
+
| `invalid_page_update` | No properties, icon, cover, or archive change. |
|
|
58
|
+
| `invalid_property_value` | Malformed property map or value. |
|
|
59
|
+
| `unmapped_property` | Missing data source context, an invalid or unbound key, or a missing property. |
|
|
60
|
+
| `property_id_mismatch` | A supplied value ID differs from the resolved raw property ID. |
|
|
61
|
+
| `duplicate_property` | Multiple keys resolve to the same raw property ID. |
|
|
43
62
|
|
|
44
63
|
## Data source errors
|
|
45
64
|
|
|
46
|
-
- `
|
|
47
|
-
the
|
|
48
|
-
|
|
65
|
+
- `data_source_access_failed`: A page create or update operation cannot use its data source because
|
|
66
|
+
the data source is unavailable, lacks workspace information, or does not allow the operation.
|
|
67
|
+
|
|
68
|
+
- `data_source_query_invalid_limit`: The row limit is not a positive safe integer or exceeds the
|
|
69
|
+
host maximum. The error message states the maximum when the host rejects an oversized request.
|
|
70
|
+
|
|
71
|
+
- `data_source_schema_unavailable`: A query uses filters or sorts, but the host did not provide the
|
|
72
|
+
database schema. Both the SDK and the generic host use this code. Queries without filters or sorts
|
|
73
|
+
can run without a schema.
|
|
49
74
|
- `unmapped_data_source`: The data source has no database binding.
|
|
50
75
|
- `invalid_data_source_query_filter`: The host rejects a filter because its property ID or condition
|
|
51
76
|
does not match the database schema.
|
|
52
77
|
- `invalid_data_source_query_sort`: The host rejects a sort, for example, because its property ID is
|
|
53
78
|
unknown, its property type is unsupported, or the query repeats a sort property.
|
|
54
79
|
|
|
55
|
-
`useDataSource`
|
|
56
|
-
|
|
57
|
-
|
|
80
|
+
On query failure, `useDataSource` sets `error` and `isLoading: false`, keeping the last successful
|
|
81
|
+
rows for that query. A later snapshot clears the error. Framework-neutral subscriptions report
|
|
82
|
+
failures through their optional error callback.
|
|
58
83
|
|
|
59
|
-
|
|
60
|
-
|
|
84
|
+
When the host supplies a changed schema or binding, data source subscriptions repeat the query
|
|
85
|
+
regardless of `isRetryable`.
|
|
61
86
|
|
|
62
87
|
## Initialization errors
|
|
63
88
|
|
|
64
|
-
`initCustomBlock` rejects with `CustomBlockInitializationError`. Its
|
|
65
|
-
`CustomBlockInitializationErrorCode
|
|
66
|
-
|
|
89
|
+
`initCustomBlock` rejects with `CustomBlockInitializationError`. Its
|
|
90
|
+
`CustomBlockInitializationErrorCode` covers handshake failures from the SDK or host, plus local
|
|
91
|
+
iframe errors.
|
|
67
92
|
|
|
68
|
-
`CustomBlockInitializationErrorInfo`
|
|
93
|
+
`CustomBlockInitializationErrorInfo` describes the `{ code, message, isRetryable }` object.
|
|
69
94
|
|
|
70
|
-
|
|
95
|
+
The error code identifies which side failed:
|
|
71
96
|
|
|
72
|
-
- `invalid_connect_payload
|
|
73
|
-
|
|
74
|
-
- `invalid_init_payload
|
|
75
|
-
|
|
76
|
-
- `invalid_init_bindings
|
|
77
|
-
|
|
78
|
-
- `invalid_init_result_payload
|
|
79
|
-
|
|
80
|
-
- `initial_state_timeout
|
|
81
|
-
|
|
82
|
-
- `no_init_result` means that the host did not receive a valid `initResult` before its timeout.
|
|
97
|
+
- `invalid_connect_payload`: The host could not parse the SDK's `connect` message. The host sends
|
|
98
|
+
this code in `init.error` when it can read the `initializationId`.
|
|
99
|
+
- `invalid_init_payload`: The SDK could not parse the host's `init` message. The SDK sends this code
|
|
100
|
+
in `initResult.error` when it can read the expected `initializationId`.
|
|
101
|
+
- `invalid_init_bindings`: The SDK could not apply the data source bindings in the host's valid
|
|
102
|
+
`init` message. The SDK sends this code in `initResult.error`.
|
|
103
|
+
- `invalid_init_result_payload`: The host could not parse the SDK's `initResult`. Only the host
|
|
104
|
+
reports this error.
|
|
105
|
+
- `initial_state_timeout`: The host could not prepare the initial state before its timeout.
|
|
106
|
+
- `no_init_result`: The host did not receive a valid `initResult` before its timeout.
|
|
83
107
|
|
|
84
|
-
See [Lifecycle and initialization](
|
|
108
|
+
See [Lifecycle and initialization](lifecycle.md) for initialization-specific error codes.
|
|
85
109
|
|
|
86
110
|
## Handling errors
|
|
87
111
|
|
|
88
|
-
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
- Treat `isRetryable` as
|
|
92
|
-
- Use `message` for developer-facing details, not as a stable identifier.
|
|
112
|
+
- Use `code` for error handling and `message` for developer-facing details. Do not branch on
|
|
113
|
+
`message`.
|
|
114
|
+
- Keep a default branch when switching on `code` to handle codes from newer hosts.
|
|
115
|
+
- Treat `isRetryable` as advice when deciding whether to offer or schedule a retry.
|
|
93
116
|
- `"unknown_error"` means the host encountered an unexpected or unclassified failure.
|
package/docs/lifecycle.md
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
# Lifecycle
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A custom block needs context from its host before it can render content that uses Notion data. This
|
|
4
|
+
guide covers initialization, loading and error states, and iframe sizing for React and
|
|
5
|
+
framework-neutral blocks. The SDK and host initialize the block through a three-message
|
|
6
|
+
`postMessage` handshake.
|
|
4
7
|
|
|
5
8
|
This handshake can be completed with one of these APIs:
|
|
6
9
|
|
|
@@ -133,9 +136,13 @@ The `CustomBlockInitializationErrorCode` tells you where initialization failed:
|
|
|
133
136
|
- The SDK could not apply the host's state.
|
|
134
137
|
- The SDK failed before the handshake completed, such as `not_in_iframe`.
|
|
135
138
|
|
|
139
|
+
`manifest_unavailable` means the sandbox omitted its declaration or the host reported an unavailable
|
|
140
|
+
manifest. `manifest_invalid` reports a manifest validation failure. Hosts can also return errors
|
|
141
|
+
from their definition-loading code; the shared host forwards those errors unchanged.
|
|
142
|
+
|
|
136
143
|
All code types are open string unions, so keep a default branch. Use `isRetryable` to decide whether
|
|
137
144
|
offering a retry makes sense, and treat `message` as display text rather than a stable identifier.
|
|
138
|
-
See [Error handling](
|
|
145
|
+
See [Error handling](errors.md) for the shared error contract.
|
|
139
146
|
|
|
140
147
|
### `customBlock`
|
|
141
148
|
|
|
@@ -196,7 +203,7 @@ function ThemeLabel() {
|
|
|
196
203
|
}
|
|
197
204
|
```
|
|
198
205
|
|
|
199
|
-
See [Block location and appearance](
|
|
206
|
+
See [Block location and appearance](block-location.md#reading-values-and-following-changes) for
|
|
200
207
|
the available getters, subscriptions, and React hooks.
|
|
201
208
|
|
|
202
209
|
### `NotInIframeError`
|