@notionhq/custom-blocks 0.2.15 → 0.2.17
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/dist/bridge/SandboxBridge.d.ts +7 -8
- package/dist/bridge/SandboxBridge.d.ts.map +1 -1
- package/dist/bridge/SandboxBridge.js +49 -44
- package/dist/bridge/dataSources/query.d.ts +2 -1
- package/dist/bridge/dataSources/query.d.ts.map +1 -1
- package/dist/bridge/dataSources/query.js +39 -8
- package/dist/bridge/dataSources/resolve.d.ts +10 -10
- package/dist/bridge/dataSources/resolve.d.ts.map +1 -1
- package/dist/bridge/dataSources/resolve.js +17 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/protocol/dataSources/dataSource.d.ts +61 -6
- package/dist/protocol/dataSources/dataSource.js +35 -6
- package/dist/protocol/dataSources/propertySchema.d.ts +2 -0
- package/dist/protocol/dataSources/propertySchema.js +7 -0
- package/dist/protocol/messages/createPageResult.d.ts +1 -1
- package/dist/protocol/messages/getPage.d.ts +1 -1
- package/dist/protocol/messages/hostToSandbox.d.ts +10 -4
- package/dist/protocol/messages/init.d.ts +5 -2
- package/dist/protocol/messages/openPage.d.ts +1 -1
- package/dist/protocol/messages/pageChanged.d.ts +5 -2
- package/dist/protocol/messages/queryDataSource.d.ts +485 -485
- package/dist/protocol/messages/queryDataSource.js +43 -43
- package/dist/protocol/messages/queryDataSourceResult.d.ts +1 -1
- package/dist/protocol/messages/sandboxToHost.d.ts +178 -178
- package/dist/protocol/messages/updatePageResult.d.ts +1 -1
- package/dist/protocol/pages/page.d.ts +5 -2
- package/dist/protocol/pages/page.js +15 -9
- package/dist/protocol/protocolVersion.d.ts +1 -1
- package/dist/protocol/protocolVersion.js +1 -1
- package/dist/react/standalonePreview.d.ts.map +1 -1
- package/dist/react/standalonePreview.js +5 -1
- package/dist/typeUtils.d.ts +10 -0
- package/dist/typeUtils.d.ts.map +1 -0
- package/dist/typeUtils.js +1 -0
- package/dist/types.d.ts +18 -15
- package/dist/types.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/docs/block-location.md +28 -15
- package/docs/data-sources.md +60 -35
- package/docs/errors.md +17 -1
- package/package.json +1 -1
- package/src/bridge/SandboxBridge.ts +62 -50
- package/src/bridge/dataSources/query.ts +47 -9
- package/src/bridge/dataSources/resolve.ts +30 -13
- package/src/index.ts +1 -0
- package/src/react/standalonePreview.ts +5 -1
- package/src/typeUtils.ts +10 -0
- package/src/types.ts +22 -16
|
@@ -10,15 +10,21 @@ import { notionParentSchema } from "../parent.js";
|
|
|
10
10
|
/**
|
|
11
11
|
* The custom block's nearest enclosing page ancestor, carried in `init.page` and `pageChanged`.
|
|
12
12
|
*/
|
|
13
|
-
export const customBlockPageSchema = v.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
export const customBlockPageSchema = v.variant("type", [
|
|
14
|
+
/** The viewer cannot access the containing page; its ID and parent are not exposed. */
|
|
15
|
+
v.object({ type: v.literal("unavailable") }),
|
|
16
|
+
/** The viewer can access the containing page; includes its ID and parent location. */
|
|
17
|
+
v.object({
|
|
18
|
+
type: v.literal("page"),
|
|
19
|
+
id: notionPageIdSchema,
|
|
20
|
+
/**
|
|
21
|
+
* The containing page's own parent. It lets a block distinguish a freestanding page from a
|
|
22
|
+
* database row without a round trip. Not to be confused with the top-level `parent` runtime
|
|
23
|
+
* value, which is the custom block's own parent.
|
|
24
|
+
*/
|
|
25
|
+
parent: notionParentSchema,
|
|
26
|
+
}),
|
|
27
|
+
]);
|
|
22
28
|
export const notionEmojiIconSchema = v.object({
|
|
23
29
|
type: v.literal("emoji"),
|
|
24
30
|
emoji: v.string(),
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Increase this value for breaking wire changes. Hosts can continue to accept
|
|
4
4
|
* older versions, so this value does not set the minimum or maximum they accept.
|
|
5
5
|
*/
|
|
6
|
-
export declare const LATEST_BRIDGE_PROTOCOL_VERSION =
|
|
6
|
+
export declare const LATEST_BRIDGE_PROTOCOL_VERSION = 5;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standalonePreview.d.ts","sourceRoot":"","sources":["../../src/react/standalonePreview.ts"],"names":[],"mappings":"AAaA,wBAAgB,0BAA0B,
|
|
1
|
+
{"version":3,"file":"standalonePreview.d.ts","sourceRoot":"","sources":["../../src/react/standalonePreview.ts"],"names":[],"mappings":"AAaA,wBAAgB,0BAA0B,SA2BzC"}
|
|
@@ -15,7 +15,11 @@ export function seedStandalonePreviewState() {
|
|
|
15
15
|
contrastMode: DEFAULT_CONTRAST_MODE,
|
|
16
16
|
blockId: previewBlockId,
|
|
17
17
|
parent: { type: "page_id", page_id: previewPageId },
|
|
18
|
-
page: {
|
|
18
|
+
page: {
|
|
19
|
+
type: "page",
|
|
20
|
+
id: previewPageId,
|
|
21
|
+
parent: { type: "workspace", workspace: true },
|
|
22
|
+
},
|
|
19
23
|
manifest: { version: 1, dataSources: {} },
|
|
20
24
|
dataSources: { bindings: {} },
|
|
21
25
|
currentUser: {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a union of the keys from every member of `T`. Includes keys that only one union member
|
|
3
|
+
* defines.
|
|
4
|
+
*/
|
|
5
|
+
export type UnionKeys<T> = T extends unknown ? keyof T : never;
|
|
6
|
+
/** Allows one union member and prohibits fields from the other members. */
|
|
7
|
+
export type ExclusiveUnion<T, Whole = T> = T extends unknown ? T & {
|
|
8
|
+
[K in Exclude<UnionKeys<Whole>, keyof T>]?: never;
|
|
9
|
+
} : never;
|
|
10
|
+
//# sourceMappingURL=typeUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeUtils.d.ts","sourceRoot":"","sources":["../src/typeUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,OAAO,GAAG,MAAM,CAAC,GAAG,KAAK,CAAA;AAE9D,2EAA2E;AAC3E,MAAM,MAAM,cAAc,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,IAAI,CAAC,SAAS,OAAO,GACzD,CAAC,GAAG;KAAG,CAAC,IAAI,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK;CAAE,GACzD,KAAK,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ import type { CustomBlockQueryDataSourceErrorInfo } from "./protocol/messages/qu
|
|
|
14
14
|
import type { UpdatePageMessage } from "./protocol/messages/updatePage.js";
|
|
15
15
|
import type { CustomBlockUpdatePageErrorInfo, UpdatePageResultMessage } from "./protocol/messages/updatePageResult.js";
|
|
16
16
|
import type { NotionPageCover, NotionPageIcon, NotionPagePropertyValue } from "./protocol/pages/page.js";
|
|
17
|
+
import type { ExclusiveUnion } from "./typeUtils.js";
|
|
17
18
|
export type { CustomBlockErrorInfo } from "./protocol/errors.js";
|
|
18
19
|
export type { NotionDataSourceId, NotionSpaceId, } from "./protocol/ids.js";
|
|
19
20
|
export type { NotionUser, NotionUserId, NotionUserList, } from "./protocol/users/user.js";
|
|
@@ -73,14 +74,14 @@ export type NotionDataSourcePageUpdateArgs = {
|
|
|
73
74
|
/** Whether to archive this page. */
|
|
74
75
|
is_archived?: boolean;
|
|
75
76
|
};
|
|
76
|
-
export type NotionDataSourceTextFilterOperator = CustomBlockTextFilterOperator
|
|
77
|
-
export type NotionDataSourceNumberFilterOperator = CustomBlockNumberFilterOperator
|
|
78
|
-
export type NotionDataSourceCheckboxFilterOperator = CustomBlockCheckboxFilterOperator
|
|
79
|
-
export type NotionDataSourceOptionFilterOperator = CustomBlockOptionFilterOperator
|
|
80
|
-
export type NotionDataSourceContainsFilterOperator = CustomBlockContainsFilterOperator
|
|
81
|
-
export type NotionDataSourceDateFilterOperator = CustomBlockDateFilterOperator
|
|
77
|
+
export type NotionDataSourceTextFilterOperator = ExclusiveUnion<CustomBlockTextFilterOperator>;
|
|
78
|
+
export type NotionDataSourceNumberFilterOperator = ExclusiveUnion<CustomBlockNumberFilterOperator>;
|
|
79
|
+
export type NotionDataSourceCheckboxFilterOperator = ExclusiveUnion<CustomBlockCheckboxFilterOperator>;
|
|
80
|
+
export type NotionDataSourceOptionFilterOperator = ExclusiveUnion<CustomBlockOptionFilterOperator>;
|
|
81
|
+
export type NotionDataSourceContainsFilterOperator = ExclusiveUnion<CustomBlockContainsFilterOperator>;
|
|
82
|
+
export type NotionDataSourceDateFilterOperator = ExclusiveUnion<CustomBlockDateFilterOperator>;
|
|
82
83
|
export type NotionDataSourcePersonFilterValue = CustomBlockPersonFilterValue;
|
|
83
|
-
export type NotionDataSourcePeopleFilterOperator = CustomBlockPeopleFilterOperator
|
|
84
|
+
export type NotionDataSourcePeopleFilterOperator = ExclusiveUnion<CustomBlockPeopleFilterOperator>;
|
|
84
85
|
export type NotionDataSourcePropertyAddress = {
|
|
85
86
|
key: string;
|
|
86
87
|
propertyId?: never;
|
|
@@ -88,7 +89,7 @@ export type NotionDataSourcePropertyAddress = {
|
|
|
88
89
|
propertyId: string;
|
|
89
90
|
key?: never;
|
|
90
91
|
};
|
|
91
|
-
export type NotionDataSourcePropertyFilter = NotionDataSourcePropertyAddress &
|
|
92
|
+
export type NotionDataSourcePropertyFilter = NotionDataSourcePropertyAddress & ExclusiveUnion<{
|
|
92
93
|
title: NotionDataSourceTextFilterOperator;
|
|
93
94
|
} | {
|
|
94
95
|
rich_text: NotionDataSourceTextFilterOperator;
|
|
@@ -112,13 +113,13 @@ export type NotionDataSourcePropertyFilter = NotionDataSourcePropertyAddress & (
|
|
|
112
113
|
date: NotionDataSourceDateFilterOperator;
|
|
113
114
|
} | {
|
|
114
115
|
people: NotionDataSourcePeopleFilterOperator;
|
|
115
|
-
}
|
|
116
|
+
}>;
|
|
116
117
|
export type NotionDataSourceSort = NotionDataSourcePropertyAddress & {
|
|
117
118
|
direction: "ascending" | "descending";
|
|
118
119
|
};
|
|
119
|
-
export type NotionDataSourceFilter = NotionDataSourcePropertyFilter | {
|
|
120
|
+
export type NotionDataSourceFilter = ExclusiveUnion<NotionDataSourcePropertyFilter | {
|
|
120
121
|
and: NotionDataSourcePropertyFilter[];
|
|
121
|
-
}
|
|
122
|
+
}>;
|
|
122
123
|
/**
|
|
123
124
|
* Latest live snapshot of a data source query.
|
|
124
125
|
*
|
|
@@ -130,13 +131,15 @@ export type NotionDataSourceFilter = NotionDataSourcePropertyFilter | {
|
|
|
130
131
|
export type DataSourceSnapshot = {
|
|
131
132
|
items: NotionDataSourcePage[];
|
|
132
133
|
/**
|
|
133
|
-
*
|
|
134
|
-
*
|
|
134
|
+
* Contains only properties in the database schema.
|
|
135
|
+
* Use this map to resolve property bindings and validate filter and sort references.
|
|
136
|
+
* Undefined when the host does not provide a schema.
|
|
135
137
|
*/
|
|
136
138
|
collectionSchema?: NotionCollectionSchema;
|
|
137
139
|
/**
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
+
* Contains database properties and four synthetic metadata fields.
|
|
141
|
+
* Use this map to describe values in query snapshots.
|
|
142
|
+
* Synthetic entries do not establish filter or sort support.
|
|
140
143
|
*/
|
|
141
144
|
propertySchemasById: {
|
|
142
145
|
[propertyId: string]: NotionPropertySchema;
|
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,sBAAsB,EAAE,MAAM,4DAA4D,CAAA;AACxG,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iEAAiE,CAAA;AAC5G,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gEAAgE,CAAA;AAC1G,OAAO,KAAK,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A;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,oBAAoB,CAC/C,oBAAoB,EACpB,2BAA2B,CAC3B,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;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,CAClD,uBAAuB,EACvB,8BAA8B,CAC9B,CAAA;AAED,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
|
@@ -65,14 +65,14 @@ before initialization. You can register before initialization without an error.
|
|
|
65
65
|
## Parent
|
|
66
66
|
|
|
67
67
|
Use `getParent()`, `subscribeToParent()`, and `useParent()` to access the block's `NotionParent` in
|
|
68
|
-
the document tree. For a custom
|
|
69
|
-
|
|
68
|
+
the document tree. For a custom database view, the parent identifies the data source associated with
|
|
69
|
+
the view.
|
|
70
70
|
|
|
71
71
|
```ts
|
|
72
72
|
type NotionParent =
|
|
73
73
|
| { type: "page_id"; page_id: string } // inline custom block under a page
|
|
74
74
|
| { type: "block_id"; block_id: NotionBlockId } // inline custom block under a toggle/column/callout/...
|
|
75
|
-
| { type: "data_source_id"; data_source_id: string } // custom block backing a custom
|
|
75
|
+
| { type: "data_source_id"; data_source_id: string } // custom block backing a custom database view
|
|
76
76
|
| { type: "workspace"; workspace: true } // top-level block parented by a team / workspace
|
|
77
77
|
| { type: "agent_id"; agent_id: NotionAgentId } // agent-owned instruction content
|
|
78
78
|
| { type: "unavailable" } // access denied; no parent ID or kind
|
|
@@ -97,13 +97,17 @@ export function AgentInstructionBadge() {
|
|
|
97
97
|
## Containing page
|
|
98
98
|
|
|
99
99
|
Use `getPage()`, `subscribeToPage()`, and `usePage()` to access the nearest enclosing page or
|
|
100
|
-
|
|
100
|
+
database view page. The page's parent can change even when its ID stays the same.
|
|
101
101
|
|
|
102
102
|
```ts
|
|
103
|
-
type CustomBlockPage =
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
103
|
+
type CustomBlockPage =
|
|
104
|
+
| {
|
|
105
|
+
type: "page"
|
|
106
|
+
id: NotionPageId
|
|
107
|
+
// The containing page's own parent.
|
|
108
|
+
parent: NotionParent
|
|
109
|
+
}
|
|
110
|
+
| { type: "unavailable" } // access denied; no ID or parent
|
|
107
111
|
```
|
|
108
112
|
|
|
109
113
|
`page.parent` allows determining if the custom block is in a freestanding page or part of a
|
|
@@ -111,14 +115,19 @@ database. Don't confuse it with `useParent()`, which is the custom block's own p
|
|
|
111
115
|
|
|
112
116
|
A containing page whose parent has `type: "data_source_id"` belongs to a data source.
|
|
113
117
|
|
|
114
|
-
For anything beyond location — title, icon, properties — fetch
|
|
115
|
-
`pages.get(page.id)`.
|
|
118
|
+
For anything beyond location — title, icon, properties — fetch an accessible page through the pages
|
|
119
|
+
API: `if (page.type === "page") pages.get(page.id)`. When the containing page itself is
|
|
120
|
+
inaccessible, `customBlock.getPage()` and `usePage()` return `{ type: "unavailable" }` without an
|
|
121
|
+
ID. These location APIs read host-provided context; they do not fetch page content. In contrast,
|
|
122
|
+
`pages.get(pageId)` sends a `getPage` request to fetch a specific page and returns a success or
|
|
123
|
+
error result. An unavailable containing page does not prevent the custom block from using its
|
|
124
|
+
accessible data sources.
|
|
116
125
|
|
|
117
126
|
When the viewer cannot access the parent resource, the host returns `{ type: "unavailable" }`,
|
|
118
|
-
including on `
|
|
119
|
-
when the readable child identifies the parent. Neither the parent's ID nor its
|
|
120
|
-
unavailable parent does not prevent initialization when the block and containing
|
|
121
|
-
other initialization requirements still apply.
|
|
127
|
+
including on `page.parent` when `page.type === "page"`. This applies to every parent kind, including
|
|
128
|
+
data sources, even when the readable child identifies the parent. Neither the parent's ID nor its
|
|
129
|
+
kind is exposed. An unavailable parent does not prevent initialization when the block and containing
|
|
130
|
+
page are readable; other initialization requirements still apply.
|
|
122
131
|
|
|
123
132
|
Treat `unavailable` as unknown when branching on location: it does not establish whether the
|
|
124
133
|
containing page is a database row. A parent that is still loading is not reported as access denied.
|
|
@@ -141,7 +150,11 @@ import { usePage, useTheme } from "@notionhq/custom-blocks/react"
|
|
|
141
150
|
export function Header() {
|
|
142
151
|
const page = usePage()
|
|
143
152
|
const theme = useTheme()
|
|
144
|
-
return
|
|
153
|
+
return (
|
|
154
|
+
<header data-display-mode={theme}>
|
|
155
|
+
Page: {page.type === "page" ? page.id : "Unavailable"}
|
|
156
|
+
</header>
|
|
157
|
+
)
|
|
145
158
|
}
|
|
146
159
|
```
|
|
147
160
|
|
package/docs/data-sources.md
CHANGED
|
@@ -132,6 +132,23 @@ Query failures follow the SDK's [error-handling contract](./errors.md).
|
|
|
132
132
|
|
|
133
133
|
Both subscription APIs accept `limit`, `filter`, and `sorts`.
|
|
134
134
|
|
|
135
|
+
The SDK types prohibit:
|
|
136
|
+
|
|
137
|
+
- Multiple filter types in one property condition, such as
|
|
138
|
+
`{ key: "name", title: { equals: "A" }, number: { equals: 1 } }`.
|
|
139
|
+
- Both `key` and `propertyId` in one filter or sort, such as
|
|
140
|
+
`{ key: "name", propertyId: "title", direction: "ascending" }`.
|
|
141
|
+
- Multiple operators in one property condition, such as
|
|
142
|
+
`{ key: "name", title: { equals: "A", does_not_equal: "B" } }`.
|
|
143
|
+
- A property condition combined with an `and` group, such as
|
|
144
|
+
`{ key: "name", title: { equals: "A" }, and: [] }`.
|
|
145
|
+
|
|
146
|
+
Runtime validation also rejects extra fields. Filters and sorts can reference only actual database
|
|
147
|
+
properties of a supported type.
|
|
148
|
+
|
|
149
|
+
Synthetic metadata IDs such as `created_by` cannot be used in filters or sorts. Add a **Last edited
|
|
150
|
+
time** column to the database. Use its bound key or property ID instead.
|
|
151
|
+
|
|
135
152
|
### Row limits
|
|
136
153
|
|
|
137
154
|
`limit` defaults to 20 and must be a positive integer. The SDK caps values above 999. Each query
|
|
@@ -235,9 +252,16 @@ either of the two views:
|
|
|
235
252
|
- `propertiesById[propertyId]` — keyed by the raw Notion property ID.
|
|
236
253
|
|
|
237
254
|
The four built-ins (`created_time`, `last_edited_time`, `created_by`, `last_edited_by`) are always
|
|
238
|
-
present in `propertiesById` and `
|
|
255
|
+
present in row `propertiesById` and snapshot `propertySchemasById`. They have no semantic keys, so
|
|
239
256
|
they do not appear in the `*ByKey` views.
|
|
240
257
|
|
|
258
|
+
`collectionSchema.propertiesById` contains only actual database properties. The SDK uses this map to
|
|
259
|
+
resolve bindings and validate every filter and sort reference. Synthetic metadata in
|
|
260
|
+
`propertySchemasById` does not make a property available for filters or sorts.
|
|
261
|
+
|
|
262
|
+
Property queries fail when the host does not provide a database schema. Queries without filters or
|
|
263
|
+
sorts can continue.
|
|
264
|
+
|
|
241
265
|
### Updating a row
|
|
242
266
|
|
|
243
267
|
Each page carries its own `update` helper:
|
|
@@ -381,34 +405,34 @@ This table shows property support for custom blocks running in Notion.
|
|
|
381
405
|
- 🔴 **Unavailable:** The SDK does not expose this operation.
|
|
382
406
|
- ⚫ **Not supported in Notion:** Notion itself does not support this operation in the stated case.
|
|
383
407
|
|
|
384
|
-
| Property type | Query result | Update row | Filter
|
|
385
|
-
| ------------------- | --------------------------- | -------------------------------------------- |
|
|
386
|
-
| `title` | 🟢 Plain text | 🟡 Plain text only | 🟢 Supported
|
|
387
|
-
| `rich_text` | 🟢 Plain text | 🟡 Plain text only | 🟢 Supported
|
|
388
|
-
| `number` | 🟢 Number | 🟢 Supported | 🟢 Supported
|
|
389
|
-
| `checkbox` | 🟢 Boolean | 🟢 Supported | 🟢 Supported
|
|
390
|
-
| `url` | 🟢 String | 🟢 Supported | 🟢 Supported
|
|
391
|
-
| `email` | 🟢 String | 🟢 Supported | 🟢 Supported
|
|
392
|
-
| `phone_number` | 🟢 String | 🟢 Supported | 🟢 Supported
|
|
393
|
-
| `select` | 🟢 Option name | 🟡 Set value only | 🟢 Supported
|
|
394
|
-
| `multi_select` | 🟢 Array of option names | 🟡 Set values only | 🟢 Supported
|
|
395
|
-
| `status` | 🟢 Option name | 🟡 Set value only | 🟡 Option names or empty checks, without groups
|
|
396
|
-
| `date` | 🟢 `NotionDateValue` | 🟡 Minute precision | 🟡 Fixed start-date comparisons or empty checks, at minute precision
|
|
397
|
-
| `people` | 🟢 Array of record pointers | 🟢 Supported | 🟢 Supported
|
|
398
|
-
| `files` | 🟡 Text fallback | 🟡 File URLs only | 🔴 Unavailable
|
|
399
|
-
| `unique_id` | 🟡 Text fallback | 🔴 Unavailable | 🔴 Unavailable
|
|
400
|
-
| `relation` | 🟢 Array of record pointers | 🟡 Replaces value. Rejects `has_more: true`. | 🔴 Unavailable
|
|
401
|
-
| `place` | 🟡 Text fallback | 🟢 Supported | 🔴 Unavailable
|
|
402
|
-
| `formula` | 🟡 Text fallback | 🔴 Unavailable | 🔴 Unavailable
|
|
403
|
-
| `rollup` | 🟡 Text fallback | 🔴 Unavailable | 🔴 Unavailable
|
|
404
|
-
| `button` | 🟡 Text fallback | 🔴 Unavailable | ⚫ Not supported in Notion
|
|
405
|
-
| `verification` | 🟡 Text fallback | 🔴 Unavailable | 🔴 Unavailable
|
|
406
|
-
| `last_visited_time` | 🟡 Text fallback | 🔴 Unavailable | 🔴 Unavailable
|
|
407
|
-
| `location` | 🟡 Text fallback | 🔴 Unavailable | 🔴 Unavailable elsewhere. ⚫ Notion disables filters in My Meetings and Library system
|
|
408
|
-
| `created_time` | 🟢 `NotionDateTime` in UTC | 🔴 Unavailable | 🔴 Unavailable
|
|
409
|
-
| `last_edited_time` | 🟢 `NotionDateTime` in UTC | 🔴 Unavailable | 🔴 Unavailable
|
|
410
|
-
| `created_by` | 🟢 Array of record pointers | 🔴 Unavailable | 🔴 Unavailable
|
|
411
|
-
| `last_edited_by` | 🟢 Array of record pointers | 🔴 Unavailable | 🔴 Unavailable
|
|
408
|
+
| Property type | Query result | Update row | Filter | Sort |
|
|
409
|
+
| ------------------- | --------------------------- | -------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
|
|
410
|
+
| `title` | 🟢 Plain text | 🟡 Plain text only | 🟢 Supported | 🟢 Supported |
|
|
411
|
+
| `rich_text` | 🟢 Plain text | 🟡 Plain text only | 🟢 Supported | 🟢 Supported |
|
|
412
|
+
| `number` | 🟢 Number | 🟢 Supported | 🟢 Supported | 🟢 Supported |
|
|
413
|
+
| `checkbox` | 🟢 Boolean | 🟢 Supported | 🟢 Supported | 🟢 Supported |
|
|
414
|
+
| `url` | 🟢 String | 🟢 Supported | 🟢 Supported | 🟢 Supported |
|
|
415
|
+
| `email` | 🟢 String | 🟢 Supported | 🟢 Supported | 🟢 Supported |
|
|
416
|
+
| `phone_number` | 🟢 String | 🟢 Supported | 🟢 Supported | 🟢 Supported |
|
|
417
|
+
| `select` | 🟢 Option name | 🟡 Set value only | 🟢 Supported | 🔴 Unavailable |
|
|
418
|
+
| `multi_select` | 🟢 Array of option names | 🟡 Set values only | 🟢 Supported | 🔴 Unavailable |
|
|
419
|
+
| `status` | 🟢 Option name | 🟡 Set value only | 🟡 Option names or empty checks, without groups | 🔴 Unavailable |
|
|
420
|
+
| `date` | 🟢 `NotionDateValue` | 🟡 Minute precision | 🟡 Fixed start-date comparisons or empty checks, at minute precision | 🟢 Supported |
|
|
421
|
+
| `people` | 🟢 Array of record pointers | 🟢 Supported | 🟢 Supported | 🔴 Unavailable |
|
|
422
|
+
| `files` | 🟡 Text fallback | 🟡 File URLs only | 🔴 Unavailable | 🔴 Unavailable |
|
|
423
|
+
| `unique_id` | 🟡 Text fallback | 🔴 Unavailable | 🔴 Unavailable | 🔴 Unavailable |
|
|
424
|
+
| `relation` | 🟢 Array of record pointers | 🟡 Replaces value. Rejects `has_more: true`. | 🔴 Unavailable | 🔴 Unavailable for standard relations. ⚫ Notion cannot sort XLDB targets. |
|
|
425
|
+
| `place` | 🟡 Text fallback | 🟢 Supported | 🔴 Unavailable | 🔴 Unavailable |
|
|
426
|
+
| `formula` | 🟡 Text fallback | 🔴 Unavailable | 🔴 Unavailable | 🔴 Unavailable |
|
|
427
|
+
| `rollup` | 🟡 Text fallback | 🔴 Unavailable | 🔴 Unavailable | 🔴 Unavailable for numeric targets or numeric aggregations. ⚫ Notion cannot sort other rollups. |
|
|
428
|
+
| `button` | 🟡 Text fallback | 🔴 Unavailable | ⚫ Not supported in Notion | ⚫ Not supported in Notion |
|
|
429
|
+
| `verification` | 🟡 Text fallback | 🔴 Unavailable | 🔴 Unavailable | 🔴 Unavailable |
|
|
430
|
+
| `last_visited_time` | 🟡 Text fallback | 🔴 Unavailable | 🔴 Unavailable | 🔴 Unavailable |
|
|
431
|
+
| `location` | 🟡 Text fallback | 🔴 Unavailable | 🔴 Unavailable elsewhere. ⚫ Notion disables filters in My Meetings and Library system databases. | 🔴 Unavailable elsewhere. ⚫ Notion disables sorts in Library system databases. |
|
|
432
|
+
| `created_time` | 🟢 `NotionDateTime` in UTC | 🔴 Unavailable | 🔴 Unavailable | 🟡 Schema property only |
|
|
433
|
+
| `last_edited_time` | 🟢 `NotionDateTime` in UTC | 🔴 Unavailable | 🔴 Unavailable | 🟡 Schema property only |
|
|
434
|
+
| `created_by` | 🟢 Array of record pointers | 🔴 Unavailable | 🔴 Unavailable | 🔴 Unavailable |
|
|
435
|
+
| `last_edited_by` | 🟢 Array of record pointers | 🔴 Unavailable | 🔴 Unavailable | 🔴 Unavailable |
|
|
412
436
|
|
|
413
437
|
### Notes
|
|
414
438
|
|
|
@@ -420,9 +444,10 @@ This table shows property support for custom blocks running in Notion.
|
|
|
420
444
|
`last_edited_time`, `created_by`, and `last_edited_by`. The data source does not need matching
|
|
421
445
|
schema properties. These values are read-only. Timestamps use `NotionDateTime` in UTC. Creator and
|
|
422
446
|
editor values use arrays of record pointers.
|
|
423
|
-
-
|
|
424
|
-
|
|
425
|
-
synthetic
|
|
447
|
+
- Filters and sorts can only reference properties defined in the database schema. For example, to
|
|
448
|
+
sort by creation time, you must first add a **Created time** property to the database and
|
|
449
|
+
reference that property's ID. The synthetic `created_time` field returned with every row is
|
|
450
|
+
read-only metadata and cannot be used when querying.
|
|
426
451
|
- You can sort by up to 10 unique properties.
|
|
427
452
|
- Date-time filter values may include seconds or milliseconds, but the Notion host currently
|
|
428
453
|
evaluates them at minute precision. Date filters do not expose relative dates or end-date
|
|
@@ -516,12 +541,12 @@ See [Pages property support](./pages.md#property-support) for the page-property
|
|
|
516
541
|
(`created_time`, `last_edited_time`, `created_by`, `last_edited_by`).
|
|
517
542
|
- `NOTION_BUILTIN_PROPERTY_IDS` — runtime list of the four built-in IDs.
|
|
518
543
|
|
|
519
|
-
###
|
|
544
|
+
### Database schema & pointers
|
|
520
545
|
|
|
521
|
-
- `NotionCollectionSchema` — host-supplied schema for the bound
|
|
546
|
+
- `NotionCollectionSchema` — host-supplied schema for the bound database, including raw property
|
|
522
547
|
schemas.
|
|
523
548
|
- `NotionRecordPointer` — `{ id, table }`. Generic reference to any Notion record (page, block,
|
|
524
|
-
|
|
549
|
+
database row). Exported for convenience; `useDataSource` and the `pages` API don't take one as
|
|
525
550
|
input.
|
|
526
551
|
|
|
527
552
|
### IDs
|
package/docs/errors.md
CHANGED
|
@@ -22,7 +22,9 @@ type CustomBlockErrorInfo<TCode extends string = string> = {
|
|
|
22
22
|
|
|
23
23
|
- `code` is a stable identifier intended for application logic.
|
|
24
24
|
- `message` provides developer-facing details and is not a stable identifier.
|
|
25
|
-
- `isRetryable` indicates whether
|
|
25
|
+
- `isRetryable` indicates whether repeating the operation could succeed without changes to the
|
|
26
|
+
request or its configuration. A `false` value does not prevent recovery after you correct the
|
|
27
|
+
query, schema, or bindings.
|
|
26
28
|
|
|
27
29
|
Each API narrows `code` to its own open string union. The known literals provide autocomplete, but
|
|
28
30
|
newer hosts may send codes that an older SDK does not list.
|
|
@@ -39,6 +41,20 @@ newer hosts may send codes that an older SDK does not list.
|
|
|
39
41
|
- Shared resolution failures: `CustomBlockPropertyErrorCode` / `CustomBlockPropertyErrorInfo` and
|
|
40
42
|
`CustomBlockDataSourceResolutionErrorCode` / `CustomBlockDataSourceResolutionErrorInfo`.
|
|
41
43
|
|
|
44
|
+
## Data source errors
|
|
45
|
+
|
|
46
|
+
- `data_source_schema_unavailable`: The query uses filters or sorts, but the host did not provide
|
|
47
|
+
the database schema. SDK and generic host validation use this code. Queries without filters or
|
|
48
|
+
sorts can continue without a schema.
|
|
49
|
+
- `unmapped_data_source`: The data source has no database binding.
|
|
50
|
+
- `invalid_data_source_query_filter`: The host rejects a filter because its property ID or condition
|
|
51
|
+
does not match the database schema.
|
|
52
|
+
- `invalid_data_source_query_sort`: The host rejects a sort, for example, because its property ID is
|
|
53
|
+
unknown, its property type is unsupported, or the query repeats a sort property.
|
|
54
|
+
|
|
55
|
+
Data source subscriptions repeat the query when the host supplies a changed schema or binding. This
|
|
56
|
+
recovery does not depend on `isRetryable`.
|
|
57
|
+
|
|
42
58
|
## Initialization errors
|
|
43
59
|
|
|
44
60
|
Unlike request helpers, `initCustomBlock` rejects with `CustomBlockInitializationError`. Its `code`
|