@notionhq/custom-blocks 0.1.38 → 0.1.40

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 (45) hide show
  1. package/bin/notion-custom-blocks/upload.test.js +4 -7
  2. package/dist/bridge/SandboxBridge.d.ts.map +1 -1
  3. package/dist/bridge/SandboxBridge.js +40 -39
  4. package/dist/bridge/dataSources/query.js +9 -9
  5. package/dist/bridge/pendingRequests.d.ts.map +1 -1
  6. package/dist/bridge/pendingRequests.js +3 -2
  7. package/dist/bridge/sandboxClient.d.ts.map +1 -1
  8. package/dist/init.d.ts.map +1 -1
  9. package/dist/init.js +1 -1
  10. package/dist/protocol/dataSources/dataSource.d.ts +135 -135
  11. package/dist/protocol/dataSources/propertySchema.d.ts +27 -27
  12. package/dist/protocol/messages/createPage.d.ts +15 -15
  13. package/dist/protocol/messages/createPageResult.d.ts +17 -15
  14. package/dist/protocol/messages/dataSourcesChanged.d.ts +27 -27
  15. package/dist/protocol/messages/getPage.d.ts +17 -15
  16. package/dist/protocol/messages/hostToSandbox.d.ts +114 -100
  17. package/dist/protocol/messages/init.d.ts +32 -28
  18. package/dist/protocol/messages/init.js +2 -0
  19. package/dist/protocol/messages/pageChanged.d.ts +2 -0
  20. package/dist/protocol/messages/parentChanged.d.ts +2 -0
  21. package/dist/protocol/messages/sandboxToHost.d.ts +30 -30
  22. package/dist/protocol/messages/updatePage.d.ts +15 -15
  23. package/dist/protocol/messages/updatePageResult.d.ts +17 -15
  24. package/dist/protocol/pages/page.d.ts +49 -45
  25. package/dist/protocol/parent.d.ts +5 -1
  26. package/dist/protocol/parent.js +1 -0
  27. package/dist/react/DebugMessageLog.d.ts +1 -1
  28. package/dist/react/DebugMessageLog.d.ts.map +1 -1
  29. package/dist/react/NotionCustomBlock.d.ts +1 -1
  30. package/dist/react/NotionCustomBlock.d.ts.map +1 -1
  31. package/dist/react/NotionCustomBlock.js +1 -1
  32. package/dist/react/NotionTokenScope.d.ts +1 -1
  33. package/dist/react/NotionTokenScope.d.ts.map +1 -1
  34. package/dist/react/useCustomBlockInit.d.ts.map +1 -1
  35. package/dist/react/useCustomBlockInit.js +1 -3
  36. package/dist/react/useDataSource.d.ts.map +1 -1
  37. package/dist/react/useDataSource.js +3 -0
  38. package/dist/version.js +1 -1
  39. package/docs/block-location.md +13 -1
  40. package/docs/pages.md +1 -1
  41. package/package.json +12 -12
  42. package/src/bridge/SandboxBridge.ts +1 -1
  43. package/src/bridge/dataSources/query.ts +9 -22
  44. package/src/react/useCustomBlockInit.ts +1 -3
  45. package/src/react/useDataSource.ts +3 -0
package/docs/pages.md CHANGED
@@ -132,7 +132,7 @@ Do **not** send `{ type: "file_upload", file_upload: { id } }`; the host will re
132
132
  - `NotionPage` — the page record returned by every successful call.
133
133
  - `NotionPageId` — branded string ID for a page.
134
134
  - `NotionPageIcon` / `NotionPageCover` — icon and cover variants Notion supports.
135
- - `NotionParent` — a block's parent reference (`page_id` / `block_id` / `data_source_id` / `workspace`), as returned on `NotionPage.parent` and by `useParent()`.
135
+ - `NotionParent` — a block's parent reference (`page_id` / `block_id` / `data_source_id` / `workspace` / `agent_id` / `unavailable`), as returned on `NotionPage.parent` and by `useParent()`.
136
136
  - `NotionPagePropertyValue` — a single property value as returned on a `NotionPage`.
137
137
  - `NotionPagePropertyInputValue` — a single property value as accepted by `pages.create` / `pages.update` (may omit `id` for `create`).
138
138
  - `NotionPagePropertyInputMap` — input map for `pages.create` (keys can be raw property IDs, or semantic keys when creating into a mapped data source).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@notionhq/custom-blocks",
3
- "version": "0.1.38",
3
+ "version": "0.1.40",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -47,7 +47,7 @@
47
47
  "dist"
48
48
  ],
49
49
  "peerDependencies": {
50
- "react": "^19.2.5"
50
+ "react": "^19.2.8"
51
51
  },
52
52
  "peerDependenciesMeta": {
53
53
  "react": {
@@ -55,17 +55,17 @@
55
55
  }
56
56
  },
57
57
  "devDependencies": {
58
- "@testing-library/react": "^16.3.2",
59
- "@types/node": "^25.6.0",
60
- "@types/react": "^19.2.14",
61
- "@types/react-dom": "^19.2.3",
62
- "@vitest/coverage-v8": "^4.1.11",
63
- "jsdom": "^29.1.0",
64
- "react": "^19.2.5",
65
- "react-dom": "^19.2.5",
66
- "vitest": "^4.1.11"
58
+ "@testing-library/react": "^16.3.3",
59
+ "@types/node": "^26.5.0",
60
+ "@types/react": "^19.2.18",
61
+ "@types/react-dom": "^19.2.7",
62
+ "@vitest/coverage-v8": "^5.0.0",
63
+ "jsdom": "^30.0.1",
64
+ "react": "^19.2.8",
65
+ "react-dom": "^19.2.8",
66
+ "vitest": "^5.0.0"
67
67
  },
68
68
  "dependencies": {
69
- "valibot": "^1.3.1"
69
+ "valibot": "^1.4.2"
70
70
  }
71
71
  }
@@ -16,7 +16,7 @@ import type { CustomBlockCreatePageErrorInfo } from "@notionhq/custom-blocks-pro
16
16
  import type { GetUserMessage } from "@notionhq/custom-blocks-protocol/messages/getUser.js"
17
17
  import {
18
18
  hostToSandboxMessageSchema,
19
- PrimeableHostToSandboxMessage,
19
+ type PrimeableHostToSandboxMessage,
20
20
  } from "@notionhq/custom-blocks-protocol/messages/hostToSandbox.js"
21
21
  import {
22
22
  CustomBlockInitializationError,
@@ -147,13 +147,13 @@ function resolveDataSourceQueryOptions(
147
147
  return {
148
148
  status: "ok",
149
149
  options: {
150
- limit: Object.prototype.hasOwnProperty.call(optionsObject, "limit")
150
+ limit: Object.hasOwn(optionsObject, "limit")
151
151
  ? optionsObject.limit
152
152
  : undefined,
153
- filter: Object.prototype.hasOwnProperty.call(optionsObject, "filter")
153
+ filter: Object.hasOwn(optionsObject, "filter")
154
154
  ? optionsObject.filter
155
155
  : undefined,
156
- sorts: Object.prototype.hasOwnProperty.call(optionsObject, "sorts")
156
+ sorts: Object.hasOwn(optionsObject, "sorts")
157
157
  ? optionsObject.sorts
158
158
  : undefined,
159
159
  },
@@ -217,7 +217,7 @@ function resolveFilter(
217
217
  }
218
218
  }
219
219
  const filterObject = filter as Record<string, unknown>
220
- if (Object.prototype.hasOwnProperty.call(filterObject, "and")) {
220
+ if (Object.hasOwn(filterObject, "and")) {
221
221
  if (
222
222
  Object.keys(filterObject).length !== 1 ||
223
223
  !Array.isArray(filterObject.and)
@@ -325,7 +325,7 @@ function resolveSort(
325
325
  }
326
326
  const direction = sortObject.direction
327
327
  if (
328
- !Object.prototype.hasOwnProperty.call(sortObject, "direction") ||
328
+ !Object.hasOwn(sortObject, "direction") ||
329
329
  (direction !== "ascending" && direction !== "descending")
330
330
  ) {
331
331
  return {
@@ -557,11 +557,8 @@ function resolvePropertyAddress(
557
557
  ):
558
558
  | { status: "ok"; propertyId: string; propertyType: string }
559
559
  | { status: "error"; error: string } {
560
- const hasKey = Object.prototype.hasOwnProperty.call(value, "key")
561
- const hasPropertyId = Object.prototype.hasOwnProperty.call(
562
- value,
563
- "propertyId",
564
- )
560
+ const hasKey = Object.hasOwn(value, "key")
561
+ const hasPropertyId = Object.hasOwn(value, "propertyId")
565
562
  if (hasKey === hasPropertyId) {
566
563
  return {
567
564
  status: "error",
@@ -577,12 +574,7 @@ function resolvePropertyAddress(
577
574
  error: "Data source query property key must be a string.",
578
575
  }
579
576
  }
580
- if (
581
- !Object.prototype.hasOwnProperty.call(
582
- dataSource.propertyIdsByKey,
583
- value.key,
584
- )
585
- ) {
577
+ if (!Object.hasOwn(dataSource.propertyIdsByKey, value.key)) {
586
578
  return {
587
579
  status: "error",
588
580
  error: `Unknown property key "${value.key}" for data source "${dataSource.key}".`,
@@ -605,12 +597,7 @@ function resolvePropertyAddress(
605
597
  }
606
598
  propertyId = value.propertyId
607
599
  }
608
- if (
609
- !Object.prototype.hasOwnProperty.call(
610
- dataSource.propertySchemasById,
611
- propertyId,
612
- )
613
- ) {
600
+ if (!Object.hasOwn(dataSource.propertySchemasById, propertyId)) {
614
601
  return {
615
602
  status: "error",
616
603
  error: `Unknown property ID "${propertyId}" for data source "${dataSource.key}".`,
@@ -45,6 +45,7 @@ export function useCustomBlockInit(
45
45
  isLoaded: false,
46
46
  error: undefined,
47
47
  })
48
+ // biome-ignore lint/correctness/useExhaustiveDependencies(opts): Initialization caches its first options and promise. Later options are ignored, so changes should not resubscribe to the same promise.
48
49
  useEffect(() => {
49
50
  let cancelled = false
50
51
  initCustomBlock(opts).then(
@@ -62,9 +63,6 @@ export function useCustomBlockInit(
62
63
  return () => {
63
64
  cancelled = true
64
65
  }
65
- // `initCustomBlock` caches its result, so options after the first call
66
- // are ignored — re-running on opts changes would be misleading.
67
- // eslint-disable-next-line react-hooks/exhaustive-deps
68
66
  }, [])
69
67
  return state
70
68
  }
@@ -29,6 +29,9 @@ export function useDataSource(
29
29
  : undefined
30
30
 
31
31
  const isInitialized = host.status === "initialized"
32
+ // biome-ignore lint/correctness/useExhaustiveDependencies(options): Compare options by value through optionsIdentity. Object identity alone must not trigger queries.
33
+ // biome-ignore lint/correctness/useExhaustiveDependencies(optionsIdentity): Changes to the serialized options must trigger a query even though the callback reads options.
34
+ // biome-ignore lint/correctness/useExhaustiveDependencies(matchingDataSource): Requery when the matching data source changes, even when the key and options are unchanged.
32
35
  useEffect(() => {
33
36
  if (!isInitialized) {
34
37
  return