@notionhq/custom-blocks 0.2.22 β†’ 0.2.24

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.
Files changed (36) hide show
  1. package/dist/bridge/dataSources/query.d.ts.map +1 -1
  2. package/dist/bridge/dataSources/query.js +10 -1
  3. package/dist/bridge/dataSources/resolveProperty.d.ts +3 -3
  4. package/dist/bridge/dataSources/resolveProperty.d.ts.map +1 -1
  5. package/dist/bridge/dataSources/resolveProperty.js +1 -1
  6. package/dist/index.d.ts +1 -1
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/protocol/manifest.d.ts +10 -3
  9. package/dist/protocol/manifest.js +5 -1
  10. package/dist/protocol/messages/connect.d.ts +9 -2
  11. package/dist/protocol/messages/createPage.d.ts +28 -0
  12. package/dist/protocol/messages/createPage.js +2 -2
  13. package/dist/protocol/messages/createPageResult.d.ts +28 -0
  14. package/dist/protocol/messages/getPage.d.ts +28 -0
  15. package/dist/protocol/messages/hostToSandbox.d.ts +93 -2
  16. package/dist/protocol/messages/init.d.ts +9 -2
  17. package/dist/protocol/messages/queryDataSource.d.ts +41 -0
  18. package/dist/protocol/messages/queryDataSource.js +13 -1
  19. package/dist/protocol/messages/sandboxToHost.d.ts +79 -2
  20. package/dist/protocol/messages/updatePage.d.ts +28 -0
  21. package/dist/protocol/messages/updatePage.js +2 -2
  22. package/dist/protocol/messages/updatePageResult.d.ts +28 -0
  23. package/dist/protocol/pages/page.d.ts +89 -2
  24. package/dist/protocol/pages/page.js +33 -2
  25. package/dist/types.d.ts +6 -3
  26. package/dist/types.d.ts.map +1 -1
  27. package/dist/version.js +1 -1
  28. package/docs/data-sources.md +46 -30
  29. package/docs/errors.md +1 -2
  30. package/docs/lifecycle.md +1 -1
  31. package/docs/pages.md +10 -11
  32. package/package.json +1 -1
  33. package/src/bridge/dataSources/query.ts +13 -0
  34. package/src/bridge/dataSources/resolveProperty.ts +4 -4
  35. package/src/index.ts +1 -0
  36. package/src/types.ts +7 -2
package/docs/lifecycle.md CHANGED
@@ -30,7 +30,7 @@ The initialization promise resolves after the SDK applies the host state. Await
30
30
  code that reads initialized state. The SDK sends `initResult` after the initial render.
31
31
 
32
32
  - The SDK waits for the host to respond with `init` or `init.error`, without an SDK-local timeout.
33
- Host-owned timeout errors such as `init_timeout` reject the promise with
33
+ Host-owned timeout errors such as `initial_state_timeout` reject the promise with
34
34
  `CustomBlockInitializationError`.
35
35
  - If a matching `init` is malformed, the SDK sends `initResult.error` with code
36
36
  `invalid_init_payload` and rejects with the same structured error.
package/docs/pages.md CHANGED
@@ -193,8 +193,7 @@ Do **not** send `{ type: "file_upload", file_upload: { id } }`; the host will re
193
193
  This table shows property support for custom blocks running in Notion.
194
194
 
195
195
  - **Read value** shows `page.properties` in responses from `pages.get`, `pages.create`, and
196
- `pages.update`. The table identifies top-level fields separately. Unavailable values are absent
197
- from `page.properties`.
196
+ `pages.update`. Unsupported property types are omitted from `page.properties`.
198
197
  - **Create** covers property writes through `pages.create`.
199
198
  - **Update** covers property writes through `pages.update`.
200
199
 
@@ -228,12 +227,12 @@ and a property in its schema.
228
227
  | `rollup` | πŸ”΄ Unavailable | πŸ”΄ Unavailable | πŸ”΄ Unavailable |
229
228
  | `button` | πŸ”΄ Unavailable | πŸ”΄ Unavailable | πŸ”΄ Unavailable |
230
229
  | `verification` | πŸ”΄ Unavailable | πŸ”΄ Unavailable | πŸ”΄ Unavailable |
231
- | `last_visited_time` | πŸ”΄ Unavailable | πŸ”΄ Unavailable | πŸ”΄ Unavailable |
230
+ | `last_visited_time` | 🟑 Current viewer’s ISO timestamp | πŸ”΄ Unavailable | πŸ”΄ Unavailable |
232
231
  | `location` | πŸ”΄ Unavailable | πŸ”΄ Unavailable | πŸ”΄ Unavailable |
233
- | `created_time` | 🟑 Top-level ISO timestamp only | πŸ”΄ Unavailable | πŸ”΄ Unavailable |
234
- | `last_edited_time` | 🟑 Top-level ISO timestamp only | πŸ”΄ Unavailable | πŸ”΄ Unavailable |
235
- | `created_by` | πŸ”΄ Unavailable | πŸ”΄ Unavailable | πŸ”΄ Unavailable |
236
- | `last_edited_by` | πŸ”΄ Unavailable | πŸ”΄ Unavailable | πŸ”΄ Unavailable |
232
+ | `created_time` | 🟒 ISO timestamp in UTC | πŸ”΄ Unavailable | πŸ”΄ Unavailable |
233
+ | `last_edited_time` | 🟒 ISO timestamp in UTC | πŸ”΄ Unavailable | πŸ”΄ Unavailable |
234
+ | `created_by` | 🟒 Actor record pointer | πŸ”΄ Unavailable | πŸ”΄ Unavailable |
235
+ | `last_edited_by` | 🟒 Actor record pointer | πŸ”΄ Unavailable | πŸ”΄ Unavailable |
237
236
 
238
237
  ### Notes
239
238
 
@@ -248,10 +247,9 @@ and a property in its schema.
248
247
  source. Create/update responses include link items only. File writes accept `external` URLs and
249
248
  existing `file` URLs and store them as links. Upload references (`file_upload`) are unsupported.
250
249
  - Relation writes replace the value and reject `has_more: true`.
251
- - `created_time` and `last_edited_time` are read-only top-level fields on `page`, when available.
252
- The host omits them from `page.properties`. The host does not return `created_by` or
253
- `last_edited_by`, even as top-level fields. The host does not return structured page values for
254
- formula, rollup, unique ID, or the other omitted types.
250
+ - Top-level `created_time` and `last_edited_time` remain available independently of schema
251
+ properties.
252
+ - Formula, rollup, unique ID, and other omitted types do not return structured page values.
255
253
 
256
254
  For flattened query values, filters, and sorts, see
257
255
  [Data source property support](./data-sources.md#property-support).
@@ -269,6 +267,7 @@ For flattened query values, filters, and sorts, see
269
267
  `pages.update` (may omit `id` for `create`).
270
268
  - `NotionPagePropertyInputMap` β€” input map for `pages.create` (keys can be raw property IDs, or
271
269
  semantic keys when creating into a mapped data source).
270
+ - `NotionPagePropertyReadMap`: maps property IDs to returned property values.
272
271
  - `NotionPagePropertyWriteMap` β€” input map for `pages.update` (raw property IDs only).
273
272
  - `NotionCreatePagePosition` β€” `start` / `end` / `before` / `after` insertion variants.
274
273
  - `OpenPageMode` β€” `"side_peek"` / `"center_peek"`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@notionhq/custom-blocks",
3
- "version": "0.2.22",
3
+ "version": "0.2.24",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -11,6 +11,7 @@ import {
11
11
  customBlockNumberFilterOperatorSchema,
12
12
  customBlockOptionFilterOperatorSchema,
13
13
  customBlockPeopleFilterOperatorSchema,
14
+ customBlockRelationFilterOperatorSchema,
14
15
  customBlockRelativeDateValueSchema,
15
16
  customBlockStatusFilterOperatorSchema,
16
17
  customBlockTextFilterOperatorSchema,
@@ -479,6 +480,18 @@ function resolvePropertyFilterBranch(args: {
479
480
  return resolveDatePropertyFilter(args.propertyId, args.value)
480
481
  case "created_by":
481
482
  return resolveCreatedByPropertyFilter(args.propertyId, args.value)
483
+ case "relation": {
484
+ const parsed = v.safeParse(
485
+ customBlockRelationFilterOperatorSchema,
486
+ args.value,
487
+ )
488
+ return parsed.success
489
+ ? {
490
+ status: "ok",
491
+ filter: { propertyId: args.propertyId, relation: parsed.output },
492
+ }
493
+ : invalidOperator("relation")
494
+ }
482
495
  case "people":
483
496
  return resolvePeoplePropertyFilter(args.propertyId, args.value)
484
497
  default:
@@ -3,13 +3,13 @@ import type {
3
3
  CustomBlockPropertyErrorCode,
4
4
  CustomBlockPropertyErrorInfo,
5
5
  } from "@notionhq/custom-blocks-protocol/dataSources/errors.js"
6
- import type { NotionPagePropertyWriteMap } from "@notionhq/custom-blocks-protocol/pages/page.js"
6
+ import type { CreatePageMessage } from "@notionhq/custom-blocks-protocol/messages/createPage.js"
7
7
  import { notionPagePropertyValueSchema } from "@notionhq/custom-blocks-protocol/pages/page.js"
8
8
  import * as v from "valibot"
9
9
  import type { NotionPagePropertyInputMap } from "../../types.js"
10
10
 
11
11
  export type PropertyWriteMapResolutionResult =
12
- | { status: "success"; properties: NotionPagePropertyWriteMap }
12
+ | { status: "success"; properties: CreatePageMessage["properties"] }
13
13
  | { status: "error"; error: CustomBlockPropertyErrorInfo }
14
14
 
15
15
  function makePropertyError(
@@ -24,7 +24,7 @@ function makePropertyError(
24
24
  *
25
25
  * Identifiers in `properties` may be raw property IDs or data source property keys; the latter
26
26
  * are looked up in the `dataSource`'s `propertyIdsByKey`. Each value is re-parsed through
27
- * `notionPagePropertyValueSchema` with its `id` rewritten to the resolved property ID.
27
+ * the page property value schema with its `id` rewritten to the resolved property ID.
28
28
  */
29
29
  export function resolvePropertyWriteMapForDataSource(args: {
30
30
  dataSource: NotionDataSource | undefined
@@ -33,7 +33,7 @@ export function resolvePropertyWriteMapForDataSource(args: {
33
33
  }): PropertyWriteMapResolutionResult {
34
34
  const { dataSource, properties, operationName } = args
35
35
 
36
- const resolvedProperties: NotionPagePropertyWriteMap = {}
36
+ const resolvedProperties: CreatePageMessage["properties"] = {}
37
37
  for (const [identifier, value] of Object.entries(properties)) {
38
38
  const propertyIdResult = resolvePropertyIdentifierForDataSource({
39
39
  dataSource,
package/src/index.ts CHANGED
@@ -99,6 +99,7 @@ export type {
99
99
  NotionPage,
100
100
  NotionPageCover,
101
101
  NotionPageIcon,
102
+ NotionPagePropertyReadMap,
102
103
  NotionPagePropertyValue,
103
104
  NotionPagePropertyWriteMap,
104
105
  } from "@notionhq/custom-blocks-protocol/pages/page.js"
package/src/types.ts CHANGED
@@ -39,6 +39,7 @@ import type {
39
39
  CustomBlockOptionFilterOperator,
40
40
  CustomBlockPeopleFilterOperator,
41
41
  CustomBlockPersonFilterValue,
42
+ CustomBlockRelationFilterOperator,
42
43
  CustomBlockStatusFilterOperator,
43
44
  CustomBlockTextFilterOperator,
44
45
  } from "@notionhq/custom-blocks-protocol/messages/queryDataSource.js"
@@ -51,7 +52,7 @@ import type {
51
52
  import type {
52
53
  NotionPageCover,
53
54
  NotionPageIcon,
54
- NotionPagePropertyValue,
55
+ NotionPagePropertyWriteMap,
55
56
  } from "@notionhq/custom-blocks-protocol/pages/page.js"
56
57
 
57
58
  import type { ExclusiveUnion } from "./typeUtils.js"
@@ -82,7 +83,7 @@ export type {
82
83
  * from the map key before sending the bridge message.
83
84
  */
84
85
  export type NotionPagePropertyInputValue =
85
- NotionPagePropertyValue extends infer PropertyValue
86
+ NotionPagePropertyWriteMap[string] extends infer PropertyValue
86
87
  ? PropertyValue extends { id: string }
87
88
  ? Omit<PropertyValue, "id"> & { id?: string }
88
89
  : never
@@ -152,6 +153,9 @@ export type NotionDataSourcePersonFilterValue = CustomBlockPersonFilterValue
152
153
  export type NotionDataSourcePeopleFilterOperator =
153
154
  ExclusiveUnion<CustomBlockPeopleFilterOperator>
154
155
 
156
+ export type NotionDataSourceRelationFilterOperator =
157
+ ExclusiveUnion<CustomBlockRelationFilterOperator>
158
+
155
159
  export type NotionDataSourcePropertyAddress =
156
160
  | { key: string; propertyId?: never }
157
161
  | { propertyId: string; key?: never }
@@ -170,6 +174,7 @@ export type NotionDataSourcePropertyFilter = NotionDataSourcePropertyAddress &
170
174
  | { status: NotionDataSourceStatusFilterOperator }
171
175
  | { date: NotionDataSourceDateFilterOperator }
172
176
  | { people: NotionDataSourcePeopleFilterOperator }
177
+ | { relation: NotionDataSourceRelationFilterOperator }
173
178
  | { created_by: NotionDataSourceCreatedByFilterOperator }
174
179
  >
175
180