@notionhq/custom-blocks 0.1.48 → 0.1.49

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/version.js CHANGED
@@ -4,4 +4,4 @@
4
4
  *
5
5
  * WARNING: Generated during SDK publish. Do not edit in the published package.
6
6
  */
7
- export const CUSTOM_BLOCKS_SDK_VERSION = "0.1.48"
7
+ export const CUSTOM_BLOCKS_SDK_VERSION = "0.1.49"
@@ -145,16 +145,19 @@ The SDK reports invalid keys, types, operators, and values through the snapshot'
145
145
  <details>
146
146
  <summary>Filter operators and values</summary>
147
147
 
148
- | Property types | Filter operators |
149
- | --- | --- |
150
- | `title`, `rich_text`, `url`, `email`, `phone_number` | `equals`, `does_not_equal`, `contains`, `does_not_contain`, `starts_with`, `ends_with`, `is_empty`, `is_not_empty` |
151
- | `number` | `equals`, `does_not_equal`, `greater_than`, `less_than`, `greater_than_or_equal_to`, `less_than_or_equal_to`, `is_empty`, `is_not_empty` |
152
- | `checkbox` | `equals`, `does_not_equal` |
153
- | `select`, `status` | `equals`, `does_not_equal`, `is_empty`, `is_not_empty` |
154
- | `multi_select` | `contains`, `contains_all`, `does_not_contain`, `is_empty`, `is_not_empty` |
155
- | `date` | `equals`, `before`, `after`, `on_or_before`, `on_or_after`, `is_empty`, `is_not_empty` |
156
-
157
- Select, multi-select, and status values can be one option name or an array of option names. For multi-select properties, `contains` matches any supplied option and `contains_all` requires every supplied option. Empty checks use `{ is_empty: true }` or `{ is_not_empty: true }`. Date comparisons accept ISO dates or ISO timestamps.
148
+ | Property types | Filter operators |
149
+ | ---------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
150
+ | `title`, `rich_text`, `url`, `email`, `phone_number` | `equals`, `does_not_equal`, `contains`, `does_not_contain`, `starts_with`, `ends_with`, `is_empty`, `is_not_empty` |
151
+ | `number` | `equals`, `does_not_equal`, `greater_than`, `less_than`, `greater_than_or_equal_to`, `less_than_or_equal_to`, `is_empty`, `is_not_empty` |
152
+ | `checkbox` | `equals`, `does_not_equal` |
153
+ | `select`, `status` | `equals`, `does_not_equal`, `is_empty`, `is_not_empty` |
154
+ | `multi_select` | `contains`, `contains_all`, `does_not_contain`, `is_empty`, `is_not_empty` |
155
+ | `date` | `equals`, `before`, `after`, `on_or_before`, `on_or_after`, `is_empty`, `is_not_empty` |
156
+
157
+ - Select, multi-select, and status filters accept one option name or an array of option names.
158
+ - For multi-select filters, `contains` matches **any** supplied option. `contains_all` requires **every** supplied option.
159
+ - Empty checks use `{ is_empty: true }` or `{ is_not_empty: true }`.
160
+ - Date comparisons accept ISO date strings or timestamps. Notion evaluates timestamps at minute precision.
158
161
 
159
162
  </details>
160
163
 
@@ -168,13 +171,13 @@ This example sorts tasks by due date, with the earliest first. Tasks with the sa
168
171
  const query = useDataSource("tasks", {
169
172
  sorts: [
170
173
  { key: "due", direction: "ascending" },
171
- { propertyId: "created_time", direction: "descending" },
174
+ { key: "createdAt", direction: "descending" },
172
175
  ],
173
176
  limit: 50,
174
177
  });
175
178
  ```
176
179
 
177
- Here, `due` is a declared date property key and `created_time` is a built-in property ID. Sorts apply in array order, with the first property taking priority. Empty values sort last in both directions.
180
+ Here, `due` is a declared date property key and `createdAt` is a declared key bound to a created-time property in the data source schema. Sorts apply in array order, with the first property taking priority. Empty values sort last in both directions.
178
181
 
179
182
  You can sort by up to 10 unique properties. Both APIs accept the same sort shape, and you can combine `sorts` with `filter`.
180
183
 
@@ -265,9 +268,7 @@ export function ScoreList() {
265
268
 
266
269
  const displayItems = items.filter(isComplete);
267
270
  if (displayItems.length === 0) {
268
- return (
269
- <div>No rows have both a text name and a finite score.</div>
270
- );
271
+ return <div>No rows have both a text name and a finite score.</div>;
271
272
  }
272
273
 
273
274
  return (
@@ -297,46 +298,93 @@ export function ScoreList() {
297
298
  ## Known limitations
298
299
 
299
300
  - **Row limits and pagination:** `limit` defaults to 20 and is capped at 999. Queries have no cursor or offset. Increasing the limit repeats the query from the start and replaces the snapshot. `hasMore` can remain true at the cap, so use filters to narrow larger data sources.
300
- - **Filter and sort rules:** Use one property condition or one `and` group with up to 25 conditions. Nested groups and `or` are unsupported. Sort by up to 10 unique properties. Empty values sort last in both directions. See the table below for property support and [Filters](#filters) for operators.
301
+ - **Filter and sort rules:** Use one property condition or one `and` group with up to 25 conditions. Nested groups and `or` are unsupported. You can sort by up to 10 unique properties. Empty values sort last in both directions. See the table below for property support and [Filters](#filters) for operators.
301
302
  - **Changing a query:** TypeScript subscriptions copy their options when they start. To change them, unsubscribe and create a new subscription. React replaces the subscription when the key or options change. Previous rows are cleared while the new query loads.
302
303
  - **Updates:** Callbacks receive complete snapshots, not individual row changes. A new result can trigger a callback even when its row values are unchanged.
303
304
 
304
- ### Property support
305
-
306
- The table shows the values returned by the Notion host and whether each property type supports filtering and sorting. means supported. ❌ means unsupported. ⚠️ marks a text fallback that does not preserve the property's structured value. Missing values can be `undefined`.
307
-
308
- | Property type | Query result | Filter | Sort |
309
- | --- | --- | :---: | :---: |
310
- | `title` | Plain text | ✅ | ✅ |
311
- | `rich_text` | Plain text | ✅ | ✅ |
312
- | `number` | Number | | |
313
- | `checkbox` | Boolean | | |
314
- | `url` | String | | |
315
- | `email` | String | | |
316
- | `phone_number` | String | ✅ | ✅ |
317
- | `select` | Option name | | |
318
- | `multi_select` | Array of option names | | |
319
- | `status` | Option name | | |
320
- | `date` | `NotionDateValue` | | |
321
- | `people` | Array of record pointers | | |
322
- | `files` | ⚠️ Text fallback | | |
323
- | `unique_id` | ⚠️ Text fallback | | |
324
- | `relation` | Array of record pointers | | |
325
- | `place` | ⚠️ Text fallback | | |
326
- | `formula` | ⚠️ Text fallback | | |
327
- | `rollup` | ⚠️ Text fallback | | |
328
- | `button` | ⚠️ Text fallback | | |
329
- | `verification` | ⚠️ Text fallback | | |
330
- | `last_visited_time` | ⚠️ Text fallback | | |
331
- | `location` | ⚠️ Text fallback | | |
332
- | `created_time` | `NotionDateTime` in UTC | | |
333
- | `last_edited_time` | `NotionDateTime` in UTC | | |
334
- | `created_by` | Array of record pointers | | |
335
- | `last_edited_by` | Array of record pointers | | |
336
-
337
- Text values omit formatting, mention tokens, and annotations. Record pointers contain a table name and a record ID.
338
-
339
- Use `propertyId: "created_time"` or `propertyId: "last_edited_time"` to sort by these built-in timestamps.
305
+ ## Property support
306
+
307
+ This table shows property support for custom blocks running in Notion.
308
+
309
+ - **Query result** shows values in `propertiesById` and `propertiesByKey` from `useDataSource` and `customBlock.subscribeToDataSource`. Missing values can be `undefined`.
310
+ - **Update row** covers writes through `item.update({ properties: ... })`.
311
+ - **Filter** and **Sort** cover query options.
312
+
313
+ - 🟢 **Supported:** The SDK supports this operation in Notion.
314
+ - 🟡 **Limited:** The SDK supports this operation with the restrictions shown in the cell.
315
+ - 🔴 **Unavailable:** The SDK does not expose this operation.
316
+ - **Not supported in Notion:** Notion itself does not support this operation in the stated case.
317
+
318
+ | Property type | Query result | Update row | Filter | Sort |
319
+ | --- | --- | --- | --- | --- |
320
+ | `title` | 🟢 Plain text | 🟡 Plain text only | 🟢 Supported | 🟢 Supported |
321
+ | `rich_text` | 🟢 Plain text | 🟡 Plain text only | 🟢 Supported | 🟢 Supported |
322
+ | `number` | 🟢 Number | 🟢 Supported | 🟢 Supported | 🟢 Supported |
323
+ | `checkbox` | 🟢 Boolean | 🟢 Supported | 🟢 Supported | 🟢 Supported |
324
+ | `url` | 🟢 String | 🟢 Supported | 🟢 Supported | 🟢 Supported |
325
+ | `email` | 🟢 String | 🟢 Supported | 🟢 Supported | 🟢 Supported |
326
+ | `phone_number` | 🟢 String | 🟢 Supported | 🟢 Supported | 🟢 Supported |
327
+ | `select` | 🟢 Option name | 🟡 Set value only | 🟢 Supported | 🔴 Unavailable |
328
+ | `multi_select` | 🟢 Array of option names | 🟡 Set values only | 🟢 Supported | 🔴 Unavailable |
329
+ | `status` | 🟢 Option name | 🟡 Set value only | 🟡 Option names or empty checks, without groups | 🔴 Unavailable |
330
+ | `date` | 🟢 `NotionDateValue` | 🟡 Minute precision | 🟡 Fixed start-date comparisons or empty checks, at minute precision | 🟢 Supported |
331
+ | `people` | 🟢 Array of record pointers | 🟢 Supported | 🔴 Unavailable | 🔴 Unavailable |
332
+ | `files` | 🟡 Text fallback | 🟡 File URLs only | 🔴 Unavailable | 🔴 Unavailable |
333
+ | `unique_id` | 🟡 Text fallback | 🔴 Unavailable | 🔴 Unavailable | 🔴 Unavailable |
334
+ | `relation` | 🟢 Array of record pointers | 🟡 Replaces value. Rejects `has_more: true`. | 🔴 Unavailable | 🔴 Unavailable for standard relations. ⚫ Notion cannot sort XLDB targets. |
335
+ | `place` | 🟡 Text fallback | 🟢 Supported | 🔴 Unavailable | 🔴 Unavailable |
336
+ | `formula` | 🟡 Text fallback | 🔴 Unavailable | 🔴 Unavailable | 🔴 Unavailable |
337
+ | `rollup` | 🟡 Text fallback | 🔴 Unavailable | 🔴 Unavailable | 🔴 Unavailable for numeric targets or numeric aggregations. ⚫ Notion cannot sort other rollups. |
338
+ | `button` | 🟡 Text fallback | 🔴 Unavailable | Not supported in Notion | Not supported in Notion |
339
+ | `verification` | 🟡 Text fallback | 🔴 Unavailable | 🔴 Unavailable | 🔴 Unavailable |
340
+ | `last_visited_time` | 🟡 Text fallback | 🔴 Unavailable | 🔴 Unavailable | 🔴 Unavailable |
341
+ | `location` | 🟡 Text fallback | 🔴 Unavailable | 🔴 Unavailable elsewhere. ⚫ Notion disables filters in My Meetings and Library system collections. | 🔴 Unavailable elsewhere. ⚫ Notion disables sorts in Library system collections. |
342
+ | `created_time` | 🟢 `NotionDateTime` in UTC | 🔴 Unavailable | 🔴 Unavailable | 🟡 Schema property only |
343
+ | `last_edited_time` | 🟢 `NotionDateTime` in UTC | 🔴 Unavailable | 🔴 Unavailable | 🟡 Schema property only |
344
+ | `created_by` | 🟢 Array of record pointers | 🔴 Unavailable | 🔴 Unavailable | 🔴 Unavailable |
345
+ | `last_edited_by` | 🟢 Array of record pointers | 🔴 Unavailable | 🔴 Unavailable | 🔴 Unavailable |
346
+
347
+ ### Notes
348
+
349
+ - Text values omit formatting, mention tokens, and annotations. A text fallback can be empty and does not preserve the property's structured value. It does not provide structured formula or rollup results.
350
+ - Record pointers contain a table name and a record ID.
351
+ - Every row includes four built-in properties in `propertiesById`: `created_time`, `last_edited_time`, `created_by`, and `last_edited_by`. The data source does not need matching schema properties. These values are read-only. Timestamps use `NotionDateTime` in UTC. Creator and editor values use arrays of record pointers.
352
+ - The SDK accepts timestamp sorts, but the current Notion host requires a property ID in the data source's actual schema. Sort using a configured created-time or last-edited-time property. The synthetic IDs `created_time` and `last_edited_time` alone are not sufficient.
353
+ - You can sort by up to 10 unique properties.
354
+ - Date-time filter values may include seconds or milliseconds, but the Notion host currently evaluates them at minute precision. Date filters do not expose relative dates or end-date targeting.
355
+ - Status filters accept option names and empty checks, but not status groups.
356
+ - Filters accept one condition or an `and` group of up to 25 conditions. The SDK does not support `or` or nested groups.
357
+ - Select, multi-select, and status query values contain option names. Their schemas provide option IDs and colors separately. Writes set the selected values. They do not edit option definitions or colors.
358
+
359
+ ### Writing values
360
+
361
+ The value you read has a different shape from the value you write. For example, a query returns a status as a string:
362
+
363
+ ```ts
364
+ item.propertiesByKey.status // "Done"
365
+ ```
366
+
367
+ To update it, wrap the string in a property object. Here, `status` is a declared property key:
368
+
369
+ ```ts
370
+ const result = await item.update({
371
+ properties: {
372
+ status: { type: "status", status: { name: "Done" } },
373
+ },
374
+ });
375
+
376
+ if (result.status === "error") {
377
+ console.error(result.error.message);
378
+ }
379
+ ```
380
+
381
+ Other write restrictions:
382
+
383
+ - **Text:** Title and rich text writes preserve plain text, but not formatting or mentions.
384
+ - **Files:** Supply external or existing hosted file URLs. The host stores them as links and does not support upload references.
385
+ - **Relations:** Supply the complete replacement list of related pages. The host rejects `has_more: true`, which indicates an incomplete list.
386
+
387
+ See [Pages property support](./pages.md#property-support) for the page-property read shapes.
340
388
 
341
389
  ## Types
342
390
 
package/docs/pages.md CHANGED
@@ -149,6 +149,61 @@ File-upload references aren't enabled for custom blocks yet. When updating icons
149
149
 
150
150
  Do **not** send `{ type: "file_upload", file_upload: { id } }`; the host will reject it.
151
151
 
152
+ ## Property support
153
+
154
+ This table shows property support for custom blocks running in Notion.
155
+
156
+ - **Read value** shows `page.properties` in responses from `pages.get`, `pages.create`, and `pages.update`. The table identifies top-level fields separately. Unavailable values are absent from `page.properties`.
157
+ - **Create** covers property writes through `pages.create`.
158
+ - **Update** covers property writes through `pages.update`.
159
+
160
+ Pages outside a data source support only `title`. Other property writes require a data source row and a property in its schema.
161
+
162
+ - 🟢 **Supported:** The SDK supports this operation in Notion.
163
+ - 🟡 **Limited:** The SDK supports this operation with the restrictions shown in the cell.
164
+ - 🔴 **Unavailable:** The SDK does not expose this operation.
165
+ - ⚫ **Not supported in Notion:** Notion itself does not support this operation in the stated case.
166
+
167
+ | Property type | Read value (`pages.get`) | Create (`pages.create`) | Update (`pages.update`) |
168
+ | --- | --- | --- | --- |
169
+ | `title` | 🟡 Text array with plain text only | 🟡 Plain text only | 🟡 Plain text only |
170
+ | `rich_text` | 🟡 Text array with plain text only | 🟡 Plain text only | 🟡 Plain text only |
171
+ | `number` | 🟢 Number or `null` | 🟢 Supported | 🟢 Supported |
172
+ | `checkbox` | 🟢 Boolean | 🟢 Supported | 🟢 Supported |
173
+ | `url` | 🟢 String or `null` | 🟢 Supported | 🟢 Supported |
174
+ | `email` | 🟢 String or `null` | 🟢 Supported | 🟢 Supported |
175
+ | `phone_number` | 🟢 String or `null` | 🟢 Supported | 🟢 Supported |
176
+ | `select` | 🟡 Option ID/name object or `null` | 🟡 Set value only | 🟡 Set value only |
177
+ | `multi_select` | 🟡 Array of option ID/name objects | 🟡 Set value only | 🟡 Set value only |
178
+ | `status` | 🟡 Option ID/name object or `null` | 🟡 Set value only | 🟡 Set value only |
179
+ | `date` | 🟢 `start` and optional `end` strings, or `null` | 🟡 Minute precision | 🟡 Minute precision |
180
+ | `people` | 🟢 Array of user/group ID objects | 🟢 Supported | 🟢 Supported |
181
+ | `files` | 🟡 External file links only | 🟡 File URLs only | 🟡 File URLs only |
182
+ | `unique_id` | 🔴 Unavailable | 🔴 Unavailable | 🔴 Unavailable |
183
+ | `relation` | 🟢 Array of page ID objects | 🟡 Replaces value. Rejects `has_more: true`. | 🟡 Replaces value. Rejects `has_more: true`. |
184
+ | `place` | 🟢 Coordinates and optional place details, or `null` | 🟢 Supported | 🟢 Supported |
185
+ | `formula` | 🔴 Unavailable | 🔴 Unavailable | 🔴 Unavailable |
186
+ | `rollup` | 🔴 Unavailable | 🔴 Unavailable | 🔴 Unavailable |
187
+ | `button` | 🔴 Unavailable | 🔴 Unavailable | 🔴 Unavailable |
188
+ | `verification` | 🔴 Unavailable | 🔴 Unavailable | 🔴 Unavailable |
189
+ | `last_visited_time` | 🔴 Unavailable | 🔴 Unavailable | 🔴 Unavailable |
190
+ | `location` | 🔴 Unavailable | 🔴 Unavailable | 🔴 Unavailable |
191
+ | `created_time` | 🟡 Top-level ISO timestamp only | 🔴 Unavailable | 🔴 Unavailable |
192
+ | `last_edited_time` | 🟡 Top-level ISO timestamp only | 🔴 Unavailable | 🔴 Unavailable |
193
+ | `created_by` | 🔴 Unavailable | 🔴 Unavailable | 🔴 Unavailable |
194
+ | `last_edited_by` | 🔴 Unavailable | 🔴 Unavailable | 🔴 Unavailable |
195
+
196
+ ### Notes
197
+
198
+ - Select, multi-select, and status reads return option names. They also return IDs when the options match the schema, but they omit colors. Writes accept an existing option ID or a name and set the selected value. They do not edit option definitions or colors. If you supply both an ID and a name, the host uses the ID. The host rejects unknown IDs.
199
+ - Date-time writes preserve hours and minutes but discard seconds and milliseconds.
200
+ - Title and rich text use text arrays, but reads and writes preserve only plain text. Reads and writes do not preserve formatting, links, mentions, or equations as structured rich text.
201
+ - File reads include link items only. File writes accept `external` URLs and existing `file` URLs and store them as links. Upload references (`file_upload`) are unsupported.
202
+ - Relation writes replace the value and reject `has_more: true`.
203
+ - `created_time` and `last_edited_time` are read-only top-level fields on `page`, when available. The host omits them from `page.properties`. The host does not return `created_by` or `last_edited_by`, even as top-level fields. The host does not return structured page values for formula, rollup, unique ID, or the other omitted types.
204
+
205
+ For flattened query values, filters, and sorts, see [Data source property support](./data-sources.md#property-support).
206
+
152
207
  ## Types
153
208
 
154
209
  - `NotionPage` — the page record returned by every successful call.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@notionhq/custom-blocks",
3
- "version": "0.1.48",
3
+ "version": "0.1.49",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "publishConfig": {