@notionhq/custom-blocks 0.3.5 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/bridge/SandboxBridge.d.ts +4 -39
- package/dist/bridge/SandboxBridge.d.ts.map +1 -1
- package/dist/bridge/SandboxBridge.js +36 -142
- package/dist/bridge/requests.d.ts +35 -0
- package/dist/bridge/requests.d.ts.map +1 -0
- package/dist/bridge/requests.js +97 -0
- package/dist/dataSources/bridge/resolveDataSourceQuery.d.ts.map +1 -1
- package/dist/dataSources/bridge/resolveDataSourceQuery.js +18 -4
- package/dist/dataSources/bridge/resolveDataSources.js +4 -4
- package/dist/dataSources/createDataSourcePage.d.ts.map +1 -1
- package/dist/dataSources/createDataSourcePage.js +5 -1
- package/dist/dataSources/filters/resolveFilter.d.ts.map +1 -1
- package/dist/dataSources/filters/resolveFilter.js +13 -3
- package/dist/dataSources/filters/types.d.ts +9 -3
- package/dist/dataSources/filters/types.d.ts.map +1 -1
- package/dist/dataSources/properties/resolvePropertyAddress.js +1 -1
- package/dist/dataSources/properties/resolvePropertyWriteMapForDataSource.js +1 -1
- package/dist/dataSources/resolvePageDataSource.js +2 -2
- package/dist/dataSources/subscribeToDataSource.d.ts +1 -4
- package/dist/dataSources/subscribeToDataSource.d.ts.map +1 -1
- package/dist/dataSources/subscribeToDataSource.js +2 -3
- package/dist/dataSources/types.d.ts +2 -0
- package/dist/dataSources/types.d.ts.map +1 -1
- package/dist/files/files.d.ts +2 -0
- package/dist/files/files.d.ts.map +1 -0
- package/dist/files/files.js +1 -0
- package/dist/files/icons.d.ts +2 -0
- package/dist/files/icons.d.ts.map +1 -0
- package/dist/files/icons.js +1 -0
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/initialization/getInitBindingError.js +2 -2
- package/dist/manifest/types.d.ts +5 -4
- package/dist/manifest/types.d.ts.map +1 -1
- package/dist/navigation/openExternalUrl.d.ts.map +1 -1
- package/dist/navigation/openExternalUrl.js +2 -1
- package/dist/pages/bridge/getPageForDataSource.d.ts.map +1 -1
- package/dist/pages/bridge/getPageForDataSource.js +3 -2
- package/dist/pages/bridge/sendCreatePageRequest.d.ts.map +1 -1
- package/dist/pages/bridge/sendCreatePageRequest.js +2 -1
- package/dist/pages/bridge/toNotionPageFieldsFromBridgePage.d.ts +14 -2
- package/dist/pages/bridge/toNotionPageFieldsFromBridgePage.d.ts.map +1 -1
- package/dist/pages/bridge/toNotionPageFieldsFromBridgePage.js +0 -1
- package/dist/pages/bridge/toNotionPagePropertyFromBridgeProperty.d.ts.map +1 -1
- package/dist/pages/bridge/toNotionPagePropertyFromBridgeProperty.js +0 -8
- package/dist/pages/bridge/updatePage.d.ts.map +1 -1
- package/dist/pages/bridge/updatePage.js +20 -5
- package/dist/pages/createPage.d.ts.map +1 -1
- package/dist/pages/createPage.js +5 -1
- package/dist/pages/openPage.d.ts.map +1 -1
- package/dist/pages/openPage.js +2 -1
- package/dist/pages/properties/getPropertyByKey.js +2 -2
- package/dist/pages/types.d.ts +10 -14
- package/dist/pages/types.d.ts.map +1 -1
- package/dist/protocol/compatibility/protocol3To10/dataSourceBindings.d.ts +530 -0
- package/dist/protocol/compatibility/protocol3To10/dataSourceBindings.js +25 -0
- package/dist/protocol/compatibility/protocol3To5/bridgePage.d.ts +12 -11
- package/dist/protocol/compatibility/protocol3To5/bridgePage.js +3 -3
- package/dist/protocol/context/containingPage.d.ts +3 -0
- package/dist/protocol/context/messages/pageChanged.d.ts +3 -0
- package/dist/protocol/context/messages/parentChanged.d.ts +3 -0
- package/dist/protocol/context/parent.d.ts +5 -0
- package/dist/protocol/context/parent.js +6 -1
- package/dist/protocol/dataSources/bridgeArchiveStatus.d.ts +3 -0
- package/dist/protocol/dataSources/bridgeArchiveStatus.js +6 -0
- package/dist/protocol/dataSources/bridgeDataSourceBinding.d.ts +3 -11
- package/dist/protocol/dataSources/bridgeDataSourceBinding.js +5 -5
- package/dist/protocol/dataSources/bridgeDataSourceBindings.d.ts +2 -10
- package/dist/protocol/dataSources/{collectionPointer.d.ts → dataSourcePointer.d.ts} +2 -2
- package/dist/protocol/dataSources/{collectionPointer.js → dataSourcePointer.js} +1 -1
- package/dist/protocol/dataSources/{collectionSchema.d.ts → dataSourceSchema.d.ts} +2 -10
- package/dist/protocol/dataSources/{collectionSchema.js → dataSourceSchema.js} +1 -1
- package/dist/protocol/dataSources/filters/bridgeDataSourceFilter.d.ts +1458 -12
- package/dist/protocol/dataSources/filters/bridgeDataSourceFilterCondition.d.ts +729 -6
- package/dist/protocol/dataSources/filters/bridgeDataSourceFilterCondition.js +14 -2
- package/dist/protocol/dataSources/filters/peopleFilterOperator.d.ts +3 -3
- package/dist/protocol/dataSources/filters/peopleFilterOperator.js +1 -1
- package/dist/protocol/dataSources/filters/timestampFilterOperator.d.ts +354 -0
- package/dist/protocol/dataSources/filters/timestampFilterOperator.js +4 -0
- package/dist/protocol/dataSources/messages/dataSourcesChanged.d.ts +2 -10
- package/dist/protocol/dataSources/messages/queryDataSource.d.ts +1485 -38
- package/dist/protocol/dataSources/messages/queryDataSource.js +2 -0
- package/dist/protocol/dataSources/notionDataSource.d.ts +3 -19
- package/dist/protocol/dataSources/notionDataSource.js +5 -5
- package/dist/protocol/dataSources/properties/propertySchema.d.ts +4 -13
- package/dist/protocol/dataSources/properties/propertySchema.js +2 -6
- package/dist/protocol/dataSources/resolveDataSourceBinding.d.ts +4 -4
- package/dist/protocol/dataSources/resolveDataSourceBinding.js +2 -2
- package/dist/protocol/files.d.ts +32 -0
- package/dist/protocol/files.js +17 -0
- package/dist/protocol/handshake/connect.d.ts +15 -4
- package/dist/protocol/handshake/init.d.ts +23 -14
- package/dist/protocol/icons.d.ts +32 -0
- package/dist/protocol/icons.js +39 -0
- package/dist/protocol/index.d.ts +25 -19
- package/dist/protocol/index.js +15 -9
- package/dist/protocol/manifest/grants.d.ts +48 -0
- package/dist/protocol/manifest/grants.js +19 -0
- package/dist/protocol/manifest/manifest.d.ts +39 -16
- package/dist/protocol/manifest/manifest.js +17 -11
- package/dist/protocol/messages/hostToSandbox.d.ts +196 -177
- package/dist/protocol/messages/invalidHostMessage.d.ts +2 -0
- package/dist/protocol/messages/invalidHostMessage.js +2 -0
- package/dist/protocol/messages/invalidSandboxMessage.d.ts +2 -0
- package/dist/protocol/messages/invalidSandboxMessage.js +2 -0
- package/dist/protocol/messages/sandboxToHost.d.ts +1571 -50
- package/dist/protocol/navigation/openExternalUrl.d.ts +2 -2
- package/dist/protocol/pages/bridgePage.d.ts +12 -12
- package/dist/protocol/pages/bridgePage.js +3 -4
- package/dist/protocol/pages/makeBridgePage.d.ts +3 -1
- package/dist/protocol/pages/messages/createPage.d.ts +645 -62
- package/dist/protocol/pages/messages/createPage.js +27 -13
- package/dist/protocol/pages/messages/getPage.d.ts +38 -37
- package/dist/protocol/pages/messages/openPage.d.ts +2 -2
- package/dist/protocol/pages/messages/updatePage.d.ts +47 -48
- package/dist/protocol/pages/messages/updatePage.js +3 -3
- package/dist/protocol/pages/pageAppearance.d.ts +9 -28
- package/dist/protocol/pages/pageAppearance.js +11 -31
- package/dist/protocol/pages/properties/bridgePagePropertyMaps.d.ts +4 -20
- package/dist/protocol/pages/properties/bridgePagePropertyValue.d.ts +2 -10
- package/dist/protocol/pages/properties/bridgePagePropertyValue.js +2 -12
- package/dist/protocol/users/makeBridgeUser.d.ts +3 -1
- package/dist/protocol/users/messages/getUser.d.ts +2 -2
- package/dist/protocol/users/messages/listUsers.d.ts +2 -2
- package/dist/protocol/utils/errors.d.ts +6 -4
- package/dist/protocol/utils/errors.js +3 -3
- package/dist/protocol/utils/ids.d.ts +2 -0
- package/dist/protocol/utils/ids.js +1 -0
- package/dist/protocol/utils/protocolVersion.d.ts +3 -1
- package/dist/protocol/utils/protocolVersion.js +5 -1
- package/dist/protocol/utils/readRequestId.d.ts +2 -0
- package/dist/protocol/utils/readRequestId.js +7 -0
- package/dist/react/NotionCustomBlock.d.ts.map +1 -1
- package/dist/react/NotionCustomBlock.js +1 -15
- package/dist/users/getUser.d.ts.map +1 -1
- package/dist/users/getUser.js +2 -1
- package/dist/users/listUsers.d.ts.map +1 -1
- package/dist/users/listUsers.js +4 -2
- package/dist/utils/version.js +1 -1
- package/docs/data-sources.md +85 -83
- package/docs/deployment.md +4 -5
- package/docs/errors.md +47 -5
- package/docs/grants.md +127 -0
- package/docs/pages.md +105 -56
- package/docs/users.md +2 -2
- package/package.json +1 -1
- package/src/bridge/SandboxBridge.ts +44 -243
- package/src/bridge/requests.ts +138 -0
- package/src/dataSources/bridge/resolveDataSourceQuery.ts +24 -4
- package/src/dataSources/bridge/resolveDataSources.ts +4 -4
- package/src/dataSources/createDataSourcePage.ts +5 -1
- package/src/dataSources/filters/resolveFilter.ts +12 -3
- package/src/dataSources/filters/types.ts +7 -4
- package/src/dataSources/properties/resolvePropertyAddress.ts +1 -1
- package/src/dataSources/properties/resolvePropertyWriteMapForDataSource.ts +1 -1
- package/src/dataSources/resolvePageDataSource.ts +2 -2
- package/src/dataSources/subscribeToDataSource.ts +7 -19
- package/src/dataSources/types.ts +3 -0
- package/src/files/files.ts +5 -0
- package/src/files/icons.ts +9 -0
- package/src/index.ts +10 -11
- package/src/initialization/getInitBindingError.ts +2 -2
- package/src/manifest/types.ts +10 -4
- package/src/navigation/openExternalUrl.ts +5 -1
- package/src/pages/bridge/getPageForDataSource.ts +6 -2
- package/src/pages/bridge/sendCreatePageRequest.ts +5 -1
- package/src/pages/bridge/toNotionPageFieldsFromBridgePage.ts +0 -1
- package/src/pages/bridge/toNotionPagePropertyFromBridgeProperty.ts +0 -8
- package/src/pages/bridge/updatePage.ts +29 -9
- package/src/pages/createPage.ts +5 -1
- package/src/pages/openPage.ts +5 -1
- package/src/pages/properties/getPropertyByKey.ts +2 -2
- package/src/pages/types.ts +14 -16
- package/src/react/NotionCustomBlock.tsx +1 -16
- package/src/users/getUser.ts +5 -1
- package/src/users/listUsers.ts +9 -4
- package/dist/bridge/pendingRequests.d.ts +0 -14
- package/dist/bridge/pendingRequests.d.ts.map +0 -1
- package/dist/bridge/pendingRequests.js +0 -28
- package/dist/protocol/dataSources/filters/createdByFilterOperator.d.ts +0 -17
- package/dist/protocol/dataSources/filters/createdByFilterOperator.js +0 -11
- package/dist/protocol/manifest/capabilities.d.ts +0 -37
- package/dist/protocol/manifest/capabilities.js +0 -13
- package/dist/protocol/pages/properties/fileInput.d.ts +0 -16
- package/dist/protocol/pages/properties/fileInput.js +0 -16
- package/dist/react/DebugMessageLog.d.ts +0 -2
- package/dist/react/DebugMessageLog.d.ts.map +0 -1
- package/dist/react/DebugMessageLog.js +0 -23
- package/docs/capabilities.md +0 -111
- package/src/bridge/pendingRequests.ts +0 -28
- package/src/react/DebugMessageLog.tsx +0 -34
package/docs/data-sources.md
CHANGED
|
@@ -26,12 +26,12 @@ Use the shared `propertyIdsByKey` map to resolve declared keys to raw property I
|
|
|
26
26
|
to read values by ID or key. Read each property object from `properties[name]`. `properties` maps
|
|
27
27
|
database property names to property objects.
|
|
28
28
|
|
|
29
|
-
Use `
|
|
30
|
-
declared keys, use `useManifest()` in React or `customBlock.getManifest()` in
|
|
31
|
-
are useful for a data source switcher.
|
|
29
|
+
Use `NotionManifestDataSource`, `NotionManifestProperty`, and `NotionManifestIcon` for declaration
|
|
30
|
+
metadata. To list declared keys, use `useManifest()` in React or `customBlock.getManifest()` in
|
|
31
|
+
TypeScript. These APIs are useful for a data source switcher.
|
|
32
32
|
|
|
33
33
|
A viewer who can't read a bound data source still sees the block. That data source has
|
|
34
|
-
`inaccessible: true` and no `
|
|
34
|
+
`inaccessible: true` and no `dataSourcePointer`. Queries and page creation that use it fail with
|
|
35
35
|
`data_source_inaccessible`, so show a fallback for that error.
|
|
36
36
|
|
|
37
37
|
## Subscribe to rows
|
|
@@ -61,6 +61,7 @@ type DataSourceQueryOptions = {
|
|
|
61
61
|
limit?: number;
|
|
62
62
|
filter?: NotionDataSourceFilter;
|
|
63
63
|
sorts?: NotionDataSourceSort[];
|
|
64
|
+
archiveStatus?: NotionArchiveStatus;
|
|
64
65
|
};
|
|
65
66
|
```
|
|
66
67
|
|
|
@@ -111,6 +112,7 @@ function useDataSource(
|
|
|
111
112
|
limit?: number
|
|
112
113
|
filter?: NotionDataSourceFilter
|
|
113
114
|
sorts?: NotionDataSourceSort[]
|
|
115
|
+
archiveStatus?: NotionArchiveStatus
|
|
114
116
|
},
|
|
115
117
|
): UseDataSourceResult
|
|
116
118
|
|
|
@@ -130,7 +132,7 @@ pass it to `useDataSource` again.
|
|
|
130
132
|
`undefined`. The snapshot does not expose schemas.
|
|
131
133
|
|
|
132
134
|
`useDataSource` uses `customBlock.subscribeToDataSource` and returns its latest snapshot. A change
|
|
133
|
-
to the key, limit, filter, or
|
|
135
|
+
to the key, limit, filter, sorts, or archive behavior replaces the subscription.
|
|
134
136
|
|
|
135
137
|
Each consumer has its own host subscription. On unmount, the SDK removes its local query state and
|
|
136
138
|
sends an unsubscribe message. The host stops future refreshes and ignores pending results. Other
|
|
@@ -143,7 +145,8 @@ error.
|
|
|
143
145
|
|
|
144
146
|
## Query options
|
|
145
147
|
|
|
146
|
-
Both subscription APIs accept `limit`, `filter`, and `
|
|
148
|
+
Both subscription APIs accept `limit`, `filter`, `sorts`, and `archiveStatus`. Queries default to
|
|
149
|
+
`archiveStatus: "active"`. Set `"archived"` for archived rows only, or `"all"` for both states.
|
|
147
150
|
|
|
148
151
|
The SDK types prohibit:
|
|
149
152
|
|
|
@@ -246,9 +249,8 @@ the filter type, not the column.
|
|
|
246
249
|
| `status` | `equals`, `does_not_equal`, `group_equals`, `group_does_not_equal`, `is_empty`, `is_not_empty` |
|
|
247
250
|
| `multi_select` | `contains`, `contains_all`, `does_not_contain`, `is_empty`, `is_not_empty` |
|
|
248
251
|
| `date` | `equals`, `before`, `after`, `on_or_before`, `on_or_after`, relative ranges, `is_empty`, `is_not_empty` |
|
|
249
|
-
| `people`
|
|
252
|
+
| `people`, `created_by`, `last_edited_by` | `contains`, `does_not_contain`, `is_empty`, `is_not_empty` |
|
|
250
253
|
| `relation` | `contains`, `does_not_contain`, `is_empty`, `is_not_empty` |
|
|
251
|
-
| `created_by` | `contains`, `does_not_contain`, `is_empty`, `is_not_empty` |
|
|
252
254
|
|
|
253
255
|
- Select, multi-select, and status filters accept one option name or an array of option names.
|
|
254
256
|
- Status group filters accept one stored group name or an array of 1–5 names. Inclusion matches any
|
|
@@ -259,9 +261,8 @@ the filter type, not the column.
|
|
|
259
261
|
`{ object: "user", id: "..." }` or `{ object: "group", id: "..." }`. Group filters match exact
|
|
260
262
|
group mentions. They do not expand group membership. Using bot or organization bot pointers as
|
|
261
263
|
filter references is not supported.
|
|
262
|
-
-
|
|
263
|
-
|
|
264
|
-
creators. Empty checks test whether creator metadata is missing.
|
|
264
|
+
- Created by and Last edited by use the People operators. Group operands do not match their
|
|
265
|
+
individual actors. Bot actors count as present for empty checks.
|
|
265
266
|
- Relation membership filters accept one page ID in dashed or undashed UUID format.
|
|
266
267
|
- Relation `does_not_contain` returns rows that do not reference the specified page. Rows with no
|
|
267
268
|
related pages also match. Multiple targets are unsupported.
|
|
@@ -323,6 +324,11 @@ const query = useDataSource("tasks", {
|
|
|
323
324
|
})
|
|
324
325
|
```
|
|
325
326
|
|
|
327
|
+
### Timestamp filters
|
|
328
|
+
|
|
329
|
+
`created_time` and `last_edited_time` use `NotionDataSourceTimestampFilterOperator`: Date operators
|
|
330
|
+
without `target`, because timestamps have no end date.
|
|
331
|
+
|
|
326
332
|
### Sorts
|
|
327
333
|
|
|
328
334
|
Use `sorts` to order matching rows. Sorts do not support every property type yet, including some
|
|
@@ -368,8 +374,7 @@ Rows include metadata properties only when the database schema defines matching
|
|
|
368
374
|
properties use the column's configured name and raw property ID.
|
|
369
375
|
|
|
370
376
|
Matching metadata columns also appear under their schema display names. Page getters resolve IDs and
|
|
371
|
-
bound manifest keys.
|
|
372
|
-
current viewer’s visit.
|
|
377
|
+
bound manifest keys.
|
|
373
378
|
|
|
374
379
|
The bridge keeps database schemas internally to validate filter and sort references. Query results
|
|
375
380
|
do not expose those schemas.
|
|
@@ -514,73 +519,76 @@ export function ScoreList() {
|
|
|
514
519
|
|
|
515
520
|
## Property support
|
|
516
521
|
|
|
517
|
-
This table shows property support for custom blocks running in Notion.
|
|
518
|
-
|
|
519
|
-
`property.number` in `{ id, type: "number", number: 8 }`.
|
|
522
|
+
This table shows property support for custom blocks running in Notion. Each queried page is a
|
|
523
|
+
`NotionPage`. For create and update support, see the [Pages table](pages.md#property-support).
|
|
520
524
|
|
|
521
|
-
- **
|
|
522
|
-
|
|
523
|
-
- **Update row** covers writes through `item.updateByKey({ properties: ... })`.
|
|
525
|
+
- **Queried page** shows values in each page’s `properties`. Property getters return `null` for
|
|
526
|
+
missing properties.
|
|
524
527
|
- **Filter** and **Sort** cover query options.
|
|
525
528
|
|
|
529
|
+
Property values can be `null` when empty or unavailable.
|
|
530
|
+
|
|
526
531
|
- 🟢 **Supported:** The SDK supports this operation in Notion.
|
|
527
|
-
- 🟡 **Limited:** The SDK supports this operation with the restrictions shown in the
|
|
528
|
-
|
|
532
|
+
- 🟡 **Limited:** The SDK supports this operation with the restrictions shown in the table and
|
|
533
|
+
notes.
|
|
534
|
+
- 🔴 **Unavailable:** The SDK does not support this operation.
|
|
529
535
|
- ⚫ **Not supported in Notion:** Notion itself does not support this operation in the stated case.
|
|
530
536
|
|
|
531
|
-
| Property type
|
|
532
|
-
|
|
|
533
|
-
| `title`
|
|
534
|
-
| `rich_text`
|
|
535
|
-
| `number`
|
|
536
|
-
| `checkbox`
|
|
537
|
-
| `url`
|
|
538
|
-
| `email`
|
|
539
|
-
| `phone_number`
|
|
540
|
-
| `select`
|
|
541
|
-
| `multi_select`
|
|
542
|
-
| `status`
|
|
543
|
-
| `date`
|
|
544
|
-
| `people`
|
|
545
|
-
| `files`
|
|
546
|
-
| `unique_id`
|
|
547
|
-
| `relation`
|
|
548
|
-
| `place`
|
|
549
|
-
| `formula`
|
|
550
|
-
| `rollup`
|
|
551
|
-
| `button`
|
|
552
|
-
| `verification`
|
|
553
|
-
| `
|
|
554
|
-
| `
|
|
555
|
-
| `
|
|
556
|
-
| `
|
|
557
|
-
| `created_by` | 🟢 Actor reference or null | 🔴 Unavailable | 🟡 Schema-backed creator filters | 🟡 Schema property only |
|
|
558
|
-
| `last_edited_by` | 🟢 Actor reference or null | 🔴 Unavailable | 🔴 Unavailable | 🔴 Unavailable |
|
|
537
|
+
| Property type | Queried page | Filter | Sort |
|
|
538
|
+
| ------------------ | ----------------------------------------- | -------------------------- | -------------------------- |
|
|
539
|
+
| `title` | 🟡 Plain text array | 🟢 Supported | 🟢 Supported |
|
|
540
|
+
| `rich_text` | 🟡 Plain text array | 🟢 Supported | 🟢 Supported |
|
|
541
|
+
| `number` | 🟢 Number | 🟢 Supported | 🟢 Supported |
|
|
542
|
+
| `checkbox` | 🟢 Boolean | 🟢 Supported | 🟢 Supported |
|
|
543
|
+
| `url` | 🟢 String | 🟢 Supported | 🟢 Supported |
|
|
544
|
+
| `email` | 🟢 String | 🟢 Supported | 🟢 Supported |
|
|
545
|
+
| `phone_number` | 🟢 String | 🟢 Supported | 🟢 Supported |
|
|
546
|
+
| `select` | 🟢 Selected option | 🟢 Supported | 🔴 Unavailable |
|
|
547
|
+
| `multi_select` | 🟢 Selected options | 🟢 Supported | 🔴 Unavailable |
|
|
548
|
+
| `status` | 🟢 Selected option | 🟢 Supported | 🔴 Unavailable |
|
|
549
|
+
| `date` | 🟢 `start` and optional `end` strings | 🟡 Minute precision | 🟢 Supported |
|
|
550
|
+
| `people` | 🟢 Array of user or group ID objects | 🟢 Supported | 🟢 Supported |
|
|
551
|
+
| `files` | 🟢 External links and hosted files | 🔴 Unavailable | 🔴 Unavailable |
|
|
552
|
+
| `unique_id` | 🟡 Formatted ID | 🔴 Unavailable | 🔴 Unavailable |
|
|
553
|
+
| `relation` | 🟢 Array of page ID objects | 🟢 Supported | 🔴 Unavailable |
|
|
554
|
+
| `place` | 🟢 Coordinates and optional place details | 🔴 Unavailable | 🔴 Unavailable |
|
|
555
|
+
| `formula` | 🟡 Stored text | 🔴 Unavailable | 🔴 Unavailable |
|
|
556
|
+
| `rollup` | 🟡 Stored text | 🔴 Unavailable | 🔴 Unavailable |
|
|
557
|
+
| `button` | 🟡 Button label | ⚫ Not supported in Notion | ⚫ Not supported in Notion |
|
|
558
|
+
| `verification` | 🟡 Status text | 🔴 Unavailable | 🔴 Unavailable |
|
|
559
|
+
| `created_time` | 🟢 Timestamp | 🟢 Supported | 🟢 Supported |
|
|
560
|
+
| `last_edited_time` | 🟢 Timestamp | 🟢 Supported | 🟢 Supported |
|
|
561
|
+
| `created_by` | 🟢 Actor reference | 🟢 Supported | 🟢 Supported |
|
|
562
|
+
| `last_edited_by` | 🟢 Actor reference | 🟢 Supported | 🟢 Supported |
|
|
559
563
|
|
|
560
564
|
### Notes
|
|
561
565
|
|
|
562
|
-
-
|
|
563
|
-
|
|
564
|
-
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
-
|
|
572
|
-
|
|
566
|
+
- Timestamps are ISO 8601 strings in UTC.
|
|
567
|
+
- Actor references identify who created or last edited the page.
|
|
568
|
+
- Unique IDs return a formatted string, including the data source prefix when available. Missing
|
|
569
|
+
values return `""`.
|
|
570
|
+
- Formula and rollup reads return stored plain text. They do not evaluate formulas or aggregations.
|
|
571
|
+
Missing values return `""`.
|
|
572
|
+
- Button reads return the automation name when readable, or the property name as a fallback.
|
|
573
|
+
- Verification reads return a localized status label, such as "Verified" or "Expired". Missing or
|
|
574
|
+
invalid values return `""`.
|
|
575
|
+
- Files query results include external links and signed URLs for Notion-hosted files.
|
|
576
|
+
- Text values omit formatting, mention tokens, and annotations.
|
|
577
|
+
- People properties return references with `object: "user"` or `object: "group"` and an `id`. Group
|
|
578
|
+
IDs use the composite form `groupId|workspaceId`.
|
|
579
|
+
- Date filters support comparisons, relative ranges, and start or end dates. They accept seconds and
|
|
580
|
+
milliseconds but compare values at minute precision.
|
|
581
|
+
- Select, multi-select, and status query values contain option names and colors when available, and
|
|
582
|
+
IDs when matched to the schema.
|
|
583
|
+
- Query results use typed property objects. Narrow each object by its `type` field.
|
|
584
|
+
- Filters and sorts reference properties in the data source schema. Top-level metadata IDs do not
|
|
585
|
+
identify schema properties.
|
|
586
|
+
- You can sort by up to 10 unique properties. People sorts use native name ordering.
|
|
573
587
|
- Status group filters use stored English group names. The SDK does not normalize localized names.
|
|
574
588
|
- `group_equals` matches any listed group. `group_does_not_equal` excludes all listed groups.
|
|
575
589
|
- Empty group arrays and unknown group names return a nonretryable query error.
|
|
576
|
-
- People properties contain arrays of user or group references in `people`. Group IDs use
|
|
577
|
-
`groupId|workspaceId`.
|
|
578
|
-
- Creator filters require an actual **Created by** column. Use its bound key or property ID, not the
|
|
579
|
-
synthetic `created_by` metadata ID.
|
|
580
590
|
- Filters accept one condition or an `and` group of up to 25 conditions. The SDK does not support
|
|
581
591
|
`or` or nested groups.
|
|
582
|
-
- Select, multi-select, and status values contain option objects. Writes do not edit option
|
|
583
|
-
definitions or colors.
|
|
584
592
|
|
|
585
593
|
### Writing values
|
|
586
594
|
|
|
@@ -591,7 +599,7 @@ const property = item.getPropertyByKey("status")
|
|
|
591
599
|
const name = property?.type === "status" ? property.status?.name : undefined
|
|
592
600
|
```
|
|
593
601
|
|
|
594
|
-
|
|
602
|
+
Use a declared property key to update a value:
|
|
595
603
|
|
|
596
604
|
```ts
|
|
597
605
|
const result = await item.updateByKey({
|
|
@@ -605,15 +613,7 @@ if (result.status === "error") {
|
|
|
605
613
|
}
|
|
606
614
|
```
|
|
607
615
|
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
- **Text:** Title and rich text writes preserve plain text, but not formatting or mentions.
|
|
611
|
-
- **Files:** Supply external or existing hosted file URLs. The host stores them as links and does
|
|
612
|
-
not support upload references.
|
|
613
|
-
- **Relations:** Supply the complete replacement list of related pages. The host rejects
|
|
614
|
-
`has_more: true`, which indicates an incomplete list.
|
|
615
|
-
|
|
616
|
-
See [Pages property support](pages.md#property-support) for the page-property read shapes.
|
|
616
|
+
See [Pages property support](pages.md#property-support) for write support and restrictions.
|
|
617
617
|
|
|
618
618
|
## Types
|
|
619
619
|
|
|
@@ -626,7 +626,9 @@ See [Pages property support](pages.md#property-support) for the page-property re
|
|
|
626
626
|
- `NotionPagePropertyValue` — the typed property values exposed by unified pages.
|
|
627
627
|
- `PageUpdatePayload` / `UpdatePageResult` — arguments and result for the page mutation methods.
|
|
628
628
|
- `UseDataSourceOptions` — options accepted by `useDataSource`: `limit?: number`,
|
|
629
|
-
`filter?: NotionDataSourceFilter`,
|
|
629
|
+
`filter?: NotionDataSourceFilter`, `sorts?: NotionDataSourceSort[]`, and
|
|
630
|
+
`archiveStatus?: NotionArchiveStatus`.
|
|
631
|
+
- `NotionArchiveStatus` — `"active"`, `"archived"`, or `"all"` for selecting query rows.
|
|
630
632
|
- `NotionDataSourceFilter` — one property condition or one shallow `and` group.
|
|
631
633
|
- `NotionDataSourcePropertyFilter` — one property address combined with a type-specific operator.
|
|
632
634
|
- `NotionDataSourcePropertyAddress` — either a semantic property `key` or a raw `propertyId`.
|
|
@@ -635,13 +637,13 @@ See [Pages property support](pages.md#property-support) for the page-property re
|
|
|
635
637
|
- `NotionDataSourceTextFilterOperator`, `NotionDataSourceNumberFilterOperator`,
|
|
636
638
|
`NotionDataSourceCheckboxFilterOperator`, `NotionDataSourceOptionFilterOperator`,
|
|
637
639
|
`NotionDataSourceStatusFilterOperator`, `NotionDataSourceContainsFilterOperator`,
|
|
638
|
-
`NotionDataSourceDateFilterOperator`, `NotionDataSourcePeopleFilterOperator`,
|
|
639
|
-
`NotionDataSourceRelationFilterOperator
|
|
640
|
-
operators accepted for each property type.
|
|
640
|
+
`NotionDataSourceDateFilterOperator`, `NotionDataSourcePeopleFilterOperator`, and
|
|
641
|
+
`NotionDataSourceRelationFilterOperator` — the operators accepted for each property type.
|
|
641
642
|
- `NotionDataSourcePersonFilterValue` — an explicit `{ object: "user" | "group", id }` reference
|
|
642
643
|
used by a people filter.
|
|
643
|
-
- `DataSourceSnapshot` — current rows, schema, and status for one live data
|
|
644
|
-
- `DataSourceQueryOptions` — the row limit, filter, and
|
|
644
|
+
- `DataSourceSnapshot` — current rows, schema, and status for one live data source query.
|
|
645
|
+
- `DataSourceQueryOptions` — the row limit, filter, sorts, and archive behavior shared by both query
|
|
646
|
+
APIs.
|
|
645
647
|
- `SubscribeToDataSourceArgs` — the key, `onSnapshot` listener, and optional query options for
|
|
646
648
|
`customBlock.subscribeToDataSource`.
|
|
647
649
|
|
|
@@ -661,7 +663,7 @@ See [Pages property support](pages.md#property-support) for the page-property re
|
|
|
661
663
|
|
|
662
664
|
### Database schema & pointers
|
|
663
665
|
|
|
664
|
-
- `
|
|
666
|
+
- `NotionDataSourceSchema` — host-supplied schema for the bound database, including raw property
|
|
665
667
|
schemas.
|
|
666
668
|
- `NotionRecordPointer` — `{ id, table }`. Generic reference to any Notion record (page, block,
|
|
667
669
|
database row). Exported for convenience; `useDataSource` and the `pages` API don't take one as
|
package/docs/deployment.md
CHANGED
|
@@ -38,10 +38,9 @@ regenerate the injected metadata, then reload the block. Block source files hot
|
|
|
38
38
|
|
|
39
39
|
## Types
|
|
40
40
|
|
|
41
|
-
- `NotionCustomBlockManifest` — the parsed shape of a block manifest.
|
|
42
|
-
|
|
43
|
-
- `
|
|
44
|
-
- `
|
|
45
|
-
- `ManifestIcon` — the icon variant accepted on a `ManifestDataSource`.
|
|
41
|
+
- `NotionCustomBlockManifest` — the parsed shape of a block manifest.
|
|
42
|
+
- `NotionManifestDataSource` — a single entry in `dataSources`.
|
|
43
|
+
- `NotionManifestProperty` — a single property declaration inside a `NotionManifestDataSource`.
|
|
44
|
+
- `NotionManifestIcon` — the icon variant accepted on a `NotionManifestDataSource`.
|
|
46
45
|
|
|
47
46
|
For the Node.js build and upload API, see the [build-tool reference](build-tools.md).
|
package/docs/errors.md
CHANGED
|
@@ -60,6 +60,48 @@ The SDK validates all properties before sending an update. These local errors ha
|
|
|
60
60
|
| `property_id_mismatch` | A supplied value ID differs from the resolved raw property ID. |
|
|
61
61
|
| `duplicate_property` | Multiple keys resolve to the same raw property ID. |
|
|
62
62
|
|
|
63
|
+
## Page icon errors
|
|
64
|
+
|
|
65
|
+
Page creation and updates can also return these host errors with `isRetryable: false`:
|
|
66
|
+
|
|
67
|
+
- `invalid_icon_name`: The host cannot resolve the requested native icon name.
|
|
68
|
+
- `invalid_icon_color`: A native color is not a string, or the host does not support the color.
|
|
69
|
+
|
|
70
|
+
The wire schema accepts any string color for forward compatibility. An embedding host can still
|
|
71
|
+
reject names or colors it does not support.
|
|
72
|
+
|
|
73
|
+
## Request completion
|
|
74
|
+
|
|
75
|
+
One-shot requests, including external navigation, share these failure codes:
|
|
76
|
+
|
|
77
|
+
- `request_timeout`: no result arrived within 60 seconds of the SDK call.
|
|
78
|
+
- `request_disposed`: the SDK bridge was disposed before the request completed.
|
|
79
|
+
- `request_send_failed`: the SDK could not post the request.
|
|
80
|
+
- `invalid_host_message`: the SDK received a malformed response with the request's ID.
|
|
81
|
+
- `invalid_sandbox_message`: the host rejected the request and returned a NACK with its ID.
|
|
82
|
+
- `unsupported_operation`: the shared host has no handler for the operation.
|
|
83
|
+
|
|
84
|
+
These failures resolve with `status: "error"` and `isRetryable: false`. The SDK removes the pending
|
|
85
|
+
request and ignores late results. It does not retry requests or cancel work already running on the
|
|
86
|
+
host. A timed-out write may still complete. Check the resulting state before repeating a write.
|
|
87
|
+
|
|
88
|
+
The shared host converts thrown handler failures to `unknown_error`. It keeps exception details in
|
|
89
|
+
the host log and returns a generic message to the SDK. Handlers can still return specific error
|
|
90
|
+
results, including unknown codes.
|
|
91
|
+
|
|
92
|
+
Disposing the SDK completes pending requests with `request_disposed`, clears their timers, and
|
|
93
|
+
prevents new requests from being posted. It does not cancel work already running on the host.
|
|
94
|
+
|
|
95
|
+
Messages with missing, unreadable, or unknown request IDs do not fail other requests. Older hosts
|
|
96
|
+
may send NACKs without IDs; those requests retain the timeout fallback.
|
|
97
|
+
|
|
98
|
+
If a page update times out, updates already queued behind it for the same page complete with
|
|
99
|
+
`previous_write_incomplete` and are not sent. A late response does not restart those updates. This
|
|
100
|
+
applies across page objects sharing the same SDK bridge. Once the queue drains, new explicit updates
|
|
101
|
+
can be sent; they are not protected from a previous write that is still running on the host.
|
|
102
|
+
|
|
103
|
+
Data source subscriptions use a separate lifecycle and do not use this timeout.
|
|
104
|
+
|
|
63
105
|
## Data source errors
|
|
64
106
|
|
|
65
107
|
- `data_source_access_failed`: A page create or update operation cannot use its data source because
|
|
@@ -86,12 +128,12 @@ failures through their optional error callback.
|
|
|
86
128
|
When the host supplies a changed schema or binding, data source subscriptions repeat the query
|
|
87
129
|
regardless of `isRetryable`.
|
|
88
130
|
|
|
89
|
-
##
|
|
131
|
+
## Grant errors
|
|
90
132
|
|
|
91
|
-
- `
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
133
|
+
- `not_granted`: Reserved for a request that needs a grant that the block manifest does not declare,
|
|
134
|
+
or that the viewer did not approve. No host sends it yet. When a host does, `isRetryable` will be
|
|
135
|
+
`false`, and a data source query that fails with it will end its subscription. See
|
|
136
|
+
[grants](grants.md).
|
|
95
137
|
|
|
96
138
|
## Initialization errors
|
|
97
139
|
|
package/docs/grants.md
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# Grants
|
|
2
|
+
|
|
3
|
+
The block manifest's `grants` lists what a custom block needs to do. Notion asks each viewer to
|
|
4
|
+
approve the declared grants before it loads the block.
|
|
5
|
+
|
|
6
|
+
Hosts do not restrict bridge requests by grant yet. A request that the approved grants do not cover
|
|
7
|
+
still runs. Declare what the block uses anyway, so viewers see it before approving.
|
|
8
|
+
|
|
9
|
+
Each grant pairs an `action` with a `resource`. The action names what the block does, and the
|
|
10
|
+
resource names what it acts on:
|
|
11
|
+
|
|
12
|
+
```json
|
|
13
|
+
{
|
|
14
|
+
"version": 1,
|
|
15
|
+
"dataSources": {
|
|
16
|
+
"tasks": { "name": "Tasks" },
|
|
17
|
+
"projects": { "name": "Projects" }
|
|
18
|
+
},
|
|
19
|
+
"grants": [
|
|
20
|
+
{ "action": "page", "resource": "data_source:tasks" },
|
|
21
|
+
{ "action": "page.read", "resource": ["data_source:tasks", "data_source:projects"] },
|
|
22
|
+
{ "action": "user.read", "resource": "workspace" }
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
`resource` is one resource or a non-empty array of resources. An array applies the action to each
|
|
28
|
+
resource, so the second entry above declares `page.read` on `data_source:tasks` and on
|
|
29
|
+
`data_source:projects`. `action` is always one action: declare one entry per action. A resource
|
|
30
|
+
string is never split on commas, so `"data_source:tasks,projects"` names one key.
|
|
31
|
+
|
|
32
|
+
## Vocabulary
|
|
33
|
+
|
|
34
|
+
| Action | Resource | Covers |
|
|
35
|
+
| ----------------- | ------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
|
|
36
|
+
| `user.read` | `current_user` | `users.get` for the viewer. |
|
|
37
|
+
| `user.read` | `workspace` | `users.get` for any user and `users.list`. |
|
|
38
|
+
| `user.read_email` | `current_user` | The viewer's `person.email` in `users.get` results. |
|
|
39
|
+
| `user.read_email` | `workspace` | Every user's `person.email` in `users.get` and `users.list` results. Requires `user.read` at `workspace`. |
|
|
40
|
+
| `user` | any user resource | Shorthand for `user.read` and `user.read_email` on the same resource. |
|
|
41
|
+
| `page.read` | `containing_page` | `pages.get` and `pages.open` for the page that contains the block. |
|
|
42
|
+
| `page.read` | `data_source:<key>` | Queries of the bound data source, plus `pages.get` and `pages.open` for its rows. |
|
|
43
|
+
| `page.read` | `workspace` | Reads of any page or data source that the viewer can access. |
|
|
44
|
+
| `page.insert` | `containing_page` | `pages.create` under the containing page. |
|
|
45
|
+
| `page.insert` | `data_source:<key>` | `pages.create` in the bound data source. |
|
|
46
|
+
| `page.insert` | `workspace` | `pages.create` under any page or in any data source that the viewer can edit. |
|
|
47
|
+
| `page.update` | `containing_page` | `page.updateById()` and `page.updateByKey()` for the containing page. |
|
|
48
|
+
| `page.update` | `data_source:<key>` | `row.updateById()`, `row.updateByKey()`, `page.updateById()`, and `page.updateByKey()` for rows of the bound data source. |
|
|
49
|
+
| `page.update` | `workspace` | `page.updateById()` and `page.updateByKey()` for any page that the viewer can edit. |
|
|
50
|
+
| `page.archive` | `containing_page` | Archiving or unarchiving the containing page. See [Archive](#archive). |
|
|
51
|
+
| `page.archive` | `data_source:<key>` | Archiving or unarchiving rows of the bound data source. |
|
|
52
|
+
| `page.archive` | `workspace` | Archiving or unarchiving any page that the viewer can edit. |
|
|
53
|
+
| any page action | `data_source` | The same action on `data_source:<key>` for every key in `dataSources`. |
|
|
54
|
+
| `page` | any page resource | Shorthand for `page.read`, `page.insert`, `page.update`, and `page.archive` on the same resource. |
|
|
55
|
+
| `network.fetch` | an HTTPS origin | Loading content from and connecting to that origin, such as `https://api.example.com`. See [Network access](#network-access). |
|
|
56
|
+
|
|
57
|
+
For user actions, `workspace` is every member of the workspace. For page actions, it's every page
|
|
58
|
+
the viewer can access. Either way it covers every narrower resource of the same action. A
|
|
59
|
+
`containing_page` resource applies to the page that the block instance sits on, so viewers approve
|
|
60
|
+
it again after the block moves to another page.
|
|
61
|
+
|
|
62
|
+
`data_source:<key>` applies to the data source bound to that key of the manifest's `dataSources`,
|
|
63
|
+
such as `data_source:tasks`. Viewers approve each bound data source separately, and an approval
|
|
64
|
+
stays with that data source: after a key is bound to a different data source, viewers approve it
|
|
65
|
+
again. A bound data source that the viewer hasn't approved stays unbound for them. If two keys are
|
|
66
|
+
bound to the same data source, the block holds the grants of both keys on it.
|
|
67
|
+
|
|
68
|
+
A bare `data_source` resource is shorthand for every declared key. Prefer explicit keys, so each
|
|
69
|
+
data source gets only the actions the block uses on it. User actions do not take data source
|
|
70
|
+
resources. The `private` page resource is reserved and not accepted yet.
|
|
71
|
+
|
|
72
|
+
Deploys reject unknown actions, unknown resources, pairs that the table does not list, empty
|
|
73
|
+
`resource` arrays, and `data_source:<key>` resources whose key is not in `dataSources`. In an array,
|
|
74
|
+
every resource must be valid for the action.
|
|
75
|
+
|
|
76
|
+
Every key in `dataSources` needs a page grant that covers it: one on `data_source:<key>`, on
|
|
77
|
+
`data_source`, or on `workspace`, such as `{ action: "page.read", resource: "data_source:tasks" }`.
|
|
78
|
+
Otherwise the deploy fails.
|
|
79
|
+
|
|
80
|
+
## Archive
|
|
81
|
+
|
|
82
|
+
`page.update` does not cover archiving or unarchiving a page. Declare `page.archive`, or the `page`
|
|
83
|
+
shorthand, on the same resource.
|
|
84
|
+
|
|
85
|
+
`page.archive` covers updates that set `is_archived`: `page.archive()`, `page.unarchive()`,
|
|
86
|
+
`row.archive()`, `row.unarchive()`, and any update that passes `is_archived`. An update that sets
|
|
87
|
+
`is_archived` and other fields needs both `page.archive` and `page.update`.
|
|
88
|
+
|
|
89
|
+
`page.trash` is reserved for a future call that moves pages to Trash. Deploys do not accept it yet.
|
|
90
|
+
|
|
91
|
+
## Network access
|
|
92
|
+
|
|
93
|
+
`network.fetch` takes a bare HTTPS origin as its resource and lets the block load content from and
|
|
94
|
+
connect to that origin, for example
|
|
95
|
+
`{ action: "network.fetch", resource: "https://api.example.com" }`. It covers `fetch` and other
|
|
96
|
+
connections, plus images, media, fonts, stylesheets, and frames loaded from the origin. An
|
|
97
|
+
`https://*.example.com` resource covers subdomains. Deploys reject resources that are not bare HTTPS
|
|
98
|
+
origins. Notion allows an approved origin only while it is also on the workspace's custom block
|
|
99
|
+
network allowlist. The dev shell does not limit network access.
|
|
100
|
+
|
|
101
|
+
The declared origins, written as a JSON array such as `["https://api.example.com"]`, can use at most
|
|
102
|
+
2,048 characters. Deploys reject longer lists. Combine origins that share a domain into one
|
|
103
|
+
wildcard, such as `https://*.example.com`, to stay under the limit. The workspace allowlist has the
|
|
104
|
+
same limit.
|
|
105
|
+
|
|
106
|
+
## Blocks without grants
|
|
107
|
+
|
|
108
|
+
A manifest that omits `grants` loads without an approval step. Notion may require `grants` in a
|
|
109
|
+
future release. An empty `grants` array declares nothing.
|
|
110
|
+
|
|
111
|
+
## Grant errors
|
|
112
|
+
|
|
113
|
+
The protocol defines the `not_granted` error code for requests that the approved grants do not
|
|
114
|
+
cover. No host sends it yet. When a host does, the result will resolve with `status: "error"` and
|
|
115
|
+
`isRetryable: false`. See [error handling](errors.md).
|
|
116
|
+
|
|
117
|
+
## Dev shell
|
|
118
|
+
|
|
119
|
+
The dev shell does not ask for approval. It loads every block as if its grants were approved.
|
|
120
|
+
|
|
121
|
+
## Types
|
|
122
|
+
|
|
123
|
+
- `CustomBlockGrant`: one `{ action, resource }` entry. `action` is a string and `resource` is a
|
|
124
|
+
string or a non-empty array of strings, so newer names do not break older SDKs.
|
|
125
|
+
- `CustomBlockGrantAction`: the actions in the vocabulary table.
|
|
126
|
+
- `CustomBlockGrantResourceName`: the resource names in the vocabulary table, including
|
|
127
|
+
`data_source:${string}`.
|