@notionhq/custom-blocks 0.2.23 → 0.3.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.
Files changed (77) hide show
  1. package/README.md +8 -5
  2. package/dist/bridge/SandboxBridge.d.ts +15 -14
  3. package/dist/bridge/SandboxBridge.d.ts.map +1 -1
  4. package/dist/bridge/SandboxBridge.js +117 -35
  5. package/dist/bridge/dataSources/resolve.d.ts +1 -3
  6. package/dist/bridge/dataSources/resolve.d.ts.map +1 -1
  7. package/dist/bridge/dataSources/resolve.js +1 -11
  8. package/dist/bridge/dataSources/resolveProperty.d.ts +3 -3
  9. package/dist/bridge/dataSources/resolveProperty.d.ts.map +1 -1
  10. package/dist/bridge/dataSources/resolveProperty.js +1 -1
  11. package/dist/bridge/dataSources/subscribe.d.ts +2 -1
  12. package/dist/bridge/dataSources/subscribe.d.ts.map +1 -1
  13. package/dist/bridge/dataSources/subscribe.js +6 -1
  14. package/dist/bridge/hostState.d.ts +11 -39
  15. package/dist/bridge/hostState.d.ts.map +1 -1
  16. package/dist/bridge/hostState.js +5 -50
  17. package/dist/bridge/page.d.ts +14 -0
  18. package/dist/bridge/page.d.ts.map +1 -0
  19. package/dist/bridge/page.js +59 -0
  20. package/dist/bridge/sandboxClient.d.ts +8 -14
  21. package/dist/bridge/sandboxClient.d.ts.map +1 -1
  22. package/dist/bridge/sandboxClient.js +13 -21
  23. package/dist/dataSources.d.ts +8 -0
  24. package/dist/dataSources.d.ts.map +1 -0
  25. package/dist/dataSources.js +103 -0
  26. package/dist/index.d.ts +6 -6
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +3 -2
  29. package/dist/protocol/dataSources/dataSourcePage.d.ts +3 -5
  30. package/dist/protocol/dataSources/dataSourcePage.js +2 -3
  31. package/dist/protocol/dataSources/propertySchema.d.ts +1 -0
  32. package/dist/protocol/index.d.ts +1 -0
  33. package/dist/protocol/index.js +1 -0
  34. package/dist/protocol/messages/createPage.d.ts +28 -0
  35. package/dist/protocol/messages/createPageResult.d.ts +496 -1
  36. package/dist/protocol/messages/createPageResult.js +17 -2
  37. package/dist/protocol/messages/getPage.d.ts +496 -1
  38. package/dist/protocol/messages/getPage.js +18 -3
  39. package/dist/protocol/messages/hostToSandbox.d.ts +2647 -154
  40. package/dist/protocol/messages/hostToSandbox.js +24 -12
  41. package/dist/protocol/messages/openExternalUrl.d.ts +32 -0
  42. package/dist/protocol/messages/openExternalUrl.js +26 -0
  43. package/dist/protocol/messages/queryDataSourceResult.d.ts +468 -1
  44. package/dist/protocol/messages/queryDataSourceResult.js +18 -2
  45. package/dist/protocol/messages/sandboxToHost.d.ts +62 -0
  46. package/dist/protocol/messages/sandboxToHost.js +2 -0
  47. package/dist/protocol/messages/updatePage.d.ts +29 -0
  48. package/dist/protocol/messages/updatePage.js +2 -1
  49. package/dist/protocol/messages/updatePageResult.d.ts +495 -1
  50. package/dist/protocol/messages/updatePageResult.js +16 -2
  51. package/dist/protocol/pages/page.d.ts +470 -3
  52. package/dist/protocol/pages/page.js +53 -1
  53. package/dist/protocol/protocolVersion.d.ts +2 -1
  54. package/dist/protocol/protocolVersion.js +4 -1
  55. package/dist/react/useDataSource.d.ts +1 -1
  56. package/dist/react/useDataSource.d.ts.map +1 -1
  57. package/dist/react/useDataSource.js +1 -3
  58. package/dist/types.d.ts +55 -96
  59. package/dist/types.d.ts.map +1 -1
  60. package/dist/version.js +1 -1
  61. package/docs/block-location.md +3 -3
  62. package/docs/data-sources.md +159 -122
  63. package/docs/errors.md +9 -9
  64. package/docs/links.md +44 -0
  65. package/docs/pages.md +121 -191
  66. package/package.json +1 -1
  67. package/src/bridge/SandboxBridge.ts +189 -62
  68. package/src/bridge/dataSources/resolve.ts +1 -20
  69. package/src/bridge/dataSources/resolveProperty.ts +4 -4
  70. package/src/bridge/dataSources/subscribe.ts +10 -5
  71. package/src/bridge/hostState.ts +21 -100
  72. package/src/bridge/page.ts +90 -0
  73. package/src/bridge/sandboxClient.ts +15 -25
  74. package/src/dataSources.ts +140 -0
  75. package/src/index.ts +9 -19
  76. package/src/react/useDataSource.ts +1 -3
  77. package/src/types.ts +61 -109
@@ -1,23 +1,17 @@
1
1
  import type { NotionContrastMode } from "@notionhq/custom-blocks-protocol/contrast.js"
2
2
  import type { NotionDataSource } from "@notionhq/custom-blocks-protocol/dataSources/dataSource.js"
3
- import type { NotionDataSourcePageBridge } from "@notionhq/custom-blocks-protocol/dataSources/dataSourcePage.js"
4
- import type { NotionDataSourceValue } from "@notionhq/custom-blocks-protocol/dataSources/dataSourceValue.js"
5
- import type { NotionPropertySchema } from "@notionhq/custom-blocks-protocol/dataSources/propertySchema.js"
6
- import type {
7
- NotionBlockId,
8
- NotionPageId,
9
- } from "@notionhq/custom-blocks-protocol/ids.js"
3
+ import type { NotionBlockId } from "@notionhq/custom-blocks-protocol/ids.js"
10
4
  import type { CustomBlockManifest } from "@notionhq/custom-blocks-protocol/manifest.js"
11
5
  import type { CustomBlockQueryDataSourceErrorInfo } from "@notionhq/custom-blocks-protocol/messages/queryDataSourceResult.js"
12
- import type { CustomBlockPage } from "@notionhq/custom-blocks-protocol/pages/page.js"
6
+ import type {
7
+ CustomBlockPage,
8
+ notionPageDataSchema,
9
+ } from "@notionhq/custom-blocks-protocol/pages/page.js"
13
10
  import type { NotionParent } from "@notionhq/custom-blocks-protocol/parent.js"
14
11
  import type { NotionTheme } from "@notionhq/custom-blocks-protocol/theme.js"
15
12
  import type { NotionUser } from "@notionhq/custom-blocks-protocol/users/user.js"
16
- import type {
17
- NotionDataSourcePage,
18
- NotionDataSourcePageUpdateArgs,
19
- UpdatePageResult,
20
- } from "../types.js"
13
+ import type { InferOutput } from "valibot"
14
+ import type { DataSourceSnapshot, NotionPage } from "../types.js"
21
15
 
22
16
  export type CustomBlockHostState = UninitializedHostState | InitializedHostState
23
17
 
@@ -42,8 +36,8 @@ export type InitializedHostState = {
42
36
 
43
37
  export type DataSourceQueryState = {
44
38
  dataSourceKey: string
45
- /** Latest pages from the host as parsed from the bridge. `propertiesByKey` is derived lazily. */
46
- items: NotionDataSourcePageBridge[]
39
+ /** Latest pages from the host as parsed from the bridge. */
40
+ items: InferOutput<typeof notionPageDataSchema>[]
47
41
  isLoading: boolean
48
42
  hasMore: boolean
49
43
  error?: CustomBlockQueryDataSourceErrorInfo
@@ -62,47 +56,23 @@ export function createEmptyDataSourceQueryState(
62
56
  }
63
57
  }
64
58
 
65
- /**
66
- * Resolved page + schema views for a single data source, keyed by raw property
67
- * ID and by user-defined key. Re-derived from `propertyIdsByKey` on every read so
68
- * renames don't require a re-query.
69
- */
70
- export type DataSourceQueryView = {
71
- items: NotionDataSourcePage[]
72
- collectionSchema?: NotionDataSource["collectionSchema"]
73
- propertySchemasById: { [propertyId: string]: NotionPropertySchema }
74
- propertyIdsByKey: { [key: string]: string | undefined }
75
- propertySchemasByKey: { [key: string]: NotionPropertySchema | undefined }
76
- isLoading: boolean
77
- hasMore: boolean
78
- error?: CustomBlockQueryDataSourceErrorInfo
79
- }
59
+ export type DataSourceQueryView = DataSourceSnapshot
80
60
 
81
61
  const EMPTY_QUERY_VIEW: DataSourceQueryView = {
82
62
  items: [],
83
- propertySchemasById: {},
84
63
  propertyIdsByKey: {},
85
- propertySchemasByKey: {},
86
64
  isLoading: false,
87
65
  hasMore: false,
88
66
  }
89
67
 
90
- /**
91
- * Per-row callback that resolves property keys against the data source and forwards the
92
- * resulting write to the bridge. Injected by callers (typically the SDK singleton in `init.ts`)
93
- * so this module stays free of bridge-instance dependencies.
94
- */
95
- export type UpdateDataSourcePageFn = (args: {
96
- dataSource: NotionDataSource
97
- pageId: NotionPageId
98
- pageUpdateArgs: NotionDataSourcePageUpdateArgs
99
- }) => Promise<UpdatePageResult>
100
-
101
68
  export function getDataSourceQueryView(
102
69
  hostState: CustomBlockHostState,
103
70
  key: string,
104
71
  subscriptionId: string,
105
- updateDataSourcePage: UpdateDataSourcePageFn,
72
+ createNotionPage: (args: {
73
+ page: InferOutput<typeof notionPageDataSchema>
74
+ dataSource: NotionDataSource | undefined
75
+ }) => NotionPage,
106
76
  ): DataSourceQueryView {
107
77
  if (hostState.status !== "initialized") {
108
78
  return EMPTY_QUERY_VIEW
@@ -115,64 +85,15 @@ export function getDataSourceQueryView(
115
85
  ? subscriptionState
116
86
  : createEmptyDataSourceQueryState(key)
117
87
 
118
- if (dataSource === undefined) {
119
- return {
120
- items: [],
121
- collectionSchema: undefined,
122
- propertySchemasById: {},
123
- propertyIdsByKey: {},
124
- propertySchemasByKey: {},
125
- isLoading: queryState.isLoading,
126
- hasMore: queryState.hasMore,
127
- error: queryState.error,
128
- }
129
- }
130
-
131
- const propertyIdsByKey = dataSource.propertyIdsByKey
132
- const propertySchemasById = dataSource.propertySchemasById
133
-
134
- const resolvedItems: NotionDataSourcePage[] = queryState.items.map(entry => {
135
- const propertiesByKey: {
136
- [key: string]: NotionDataSourceValue | undefined
137
- } = {}
138
- for (const [key, propertyId] of Object.entries(propertyIdsByKey)) {
139
- propertiesByKey[key] =
140
- propertyId === undefined ? undefined : entry.propertiesById[propertyId]
141
- }
142
- const update = (args: NotionDataSourcePageUpdateArgs) =>
143
- updateDataSourcePage({
144
- dataSource,
145
- pageId: entry.id,
146
- pageUpdateArgs: args,
147
- })
148
- return {
149
- id: entry.id,
150
- is_archived: entry.is_archived,
151
- in_trash: entry.in_trash,
152
- propertiesById: entry.propertiesById,
153
- propertiesByKey,
154
- update,
155
- archive: () => update({ is_archived: true }),
156
- unarchive: () => update({ is_archived: false }),
157
- }
158
- })
159
-
160
- const propertySchemasByKey: {
161
- [key: string]: NotionPropertySchema | undefined
162
- } = {}
163
- for (const [key, propertyId] of Object.entries(propertyIdsByKey)) {
164
- propertySchemasByKey[key] =
165
- propertyId === undefined ? undefined : propertySchemasById[propertyId]
166
- }
167
-
168
88
  return {
169
- items: resolvedItems,
170
- collectionSchema: dataSource.collectionSchema,
171
- propertySchemasById,
172
- propertyIdsByKey,
173
- propertySchemasByKey,
89
+ items:
90
+ dataSource === undefined
91
+ ? []
92
+ : queryState.items.map(entry =>
93
+ createNotionPage({ page: entry, dataSource }),
94
+ ),
95
+ propertyIdsByKey: dataSource?.propertyIdsByKey ?? {},
174
96
  isLoading: queryState.isLoading,
175
97
  hasMore: queryState.hasMore,
176
- error: queryState.error,
177
98
  }
178
99
  }
@@ -0,0 +1,90 @@
1
+ import type { NotionDataSource } from "@notionhq/custom-blocks-protocol/dataSources/dataSource.js"
2
+ import type { NotionDataSourceId } from "@notionhq/custom-blocks-protocol/ids.js"
3
+ import type { BridgeMessagePayload } from "@notionhq/custom-blocks-protocol/messages/messagePayload.js"
4
+ import type { UpdatePageResultMessage } from "@notionhq/custom-blocks-protocol/messages/updatePageResult.js"
5
+ import type { notionPageDataSchema } from "@notionhq/custom-blocks-protocol/pages/page.js"
6
+ import type { InferOutput } from "valibot"
7
+ import type {
8
+ NotionPage,
9
+ PageUpdatePayload,
10
+ UpdatePageResult,
11
+ } from "../types.js"
12
+
13
+ export function toNotionPageFromNotionPageData(args: {
14
+ page: InferOutput<typeof notionPageDataSchema>
15
+ dataSource: NotionDataSource | undefined
16
+ getDataSource: () => NotionDataSource | undefined
17
+ update: (
18
+ payload: PageUpdatePayload,
19
+ dataSourceId: NotionDataSourceId | undefined,
20
+ ) => Promise<BridgeMessagePayload<UpdatePageResultMessage>>
21
+ }): NotionPage {
22
+ const { page: bridgePage, dataSource } = args
23
+ const getPropertyById = (id: string) =>
24
+ Object.values(sdkPage.properties).find(value => value?.id === id) ?? null
25
+ let pending: Promise<void> | undefined
26
+ const updatePage = (
27
+ payload: PageUpdatePayload,
28
+ dataSourceId: NotionDataSourceId | undefined,
29
+ ): Promise<UpdatePageResult> => {
30
+ const operation = async (): Promise<UpdatePageResult> => {
31
+ const result = await args.update(payload, dataSourceId)
32
+ if (result.status === "error") {
33
+ return result
34
+ }
35
+ Object.assign(sdkPage, result.page)
36
+ return { status: "success", page: sdkPage }
37
+ }
38
+ const result = pending ? pending.then(operation) : operation()
39
+ const finished = result.then(
40
+ () => undefined,
41
+ () => undefined,
42
+ )
43
+ pending = finished
44
+ void finished.then(() => {
45
+ if (pending === finished) {
46
+ pending = undefined
47
+ }
48
+ })
49
+ return result
50
+ }
51
+ const updateById = (payload: PageUpdatePayload) =>
52
+ updatePage(payload, undefined)
53
+ const updateByKey = (
54
+ payload: PageUpdatePayload,
55
+ ): Promise<UpdatePageResult> => {
56
+ const dataSourceId = dataSource?.collectionPointer?.id
57
+ if (dataSourceId === undefined) {
58
+ return Promise.resolve({
59
+ status: "error",
60
+ error: {
61
+ code: "unmapped_data_source",
62
+ message: "This page has no bound data source context.",
63
+ isRetryable: false,
64
+ },
65
+ })
66
+ }
67
+ return updatePage(payload, dataSourceId)
68
+ }
69
+ const methods = {
70
+ getPropertyById,
71
+ getPropertyByKey: (key: string) => {
72
+ const source = args.getDataSource()
73
+ const id =
74
+ source && Object.hasOwn(source.propertyIdsByKey, key)
75
+ ? source.propertyIdsByKey[key]
76
+ : undefined
77
+ return id === undefined ? null : getPropertyById(id)
78
+ },
79
+ updateById,
80
+ updateByKey,
81
+ archive: () => updateById({ is_archived: true }),
82
+ unarchive: () => updateById({ is_archived: false }),
83
+ }
84
+ const sdkPage: NotionPage = {
85
+ ...bridgePage,
86
+ dataSourceKey: dataSource?.key ?? null,
87
+ ...methods,
88
+ }
89
+ return sdkPage
90
+ }
@@ -8,10 +8,9 @@ import type {
8
8
  ListUsersArgs,
9
9
  ListUsersResult,
10
10
  NotionUserId,
11
+ OpenExternalUrlResult,
11
12
  OpenPageOptions,
12
13
  OpenPageResult,
13
- UpdatePageArgs,
14
- UpdatePageResult,
15
14
  } from "../types.js"
16
15
  import {
17
16
  type CustomBlockHostState,
@@ -28,7 +27,7 @@ import {
28
27
 
29
28
  let bridge: SandboxBridge | undefined
30
29
 
31
- function getBridge(): SandboxBridge {
30
+ export function getBridge(): SandboxBridge {
32
31
  if (!bridge) {
33
32
  bridge = new SandboxBridge()
34
33
  }
@@ -95,7 +94,11 @@ export const customBlockDataSources = {
95
94
  hostState,
96
95
  key,
97
96
  subscriptionId,
98
- args => getBridge().updateDataSourcePage(args),
97
+ ({ page, dataSource }) =>
98
+ getBridge().buildNotionPage({
99
+ page,
100
+ dataSourceId: dataSource?.collectionPointer?.id,
101
+ }),
99
102
  )
100
103
  },
101
104
  }
@@ -118,14 +121,14 @@ export const pages = {
118
121
  * Creates a new Notion page.
119
122
  */
120
123
  create: (input: CreatePageArgs): Promise<CreatePageResult> => {
121
- return getBridge().createPage(input)
124
+ return getBridge().createPage(input, undefined)
122
125
  },
123
126
 
124
127
  /**
125
128
  * Fetches a page by id.
126
129
  */
127
130
  get: (pageId: NotionPageId): Promise<GetPageResult> => {
128
- return getBridge().getPage(pageId)
131
+ return getBridge().getPage(pageId, undefined)
129
132
  },
130
133
 
131
134
  /**
@@ -137,26 +140,13 @@ export const pages = {
137
140
  ): Promise<OpenPageResult> => {
138
141
  return getBridge().openPage(pageId, options)
139
142
  },
143
+ }
140
144
 
141
- /**
142
- * Updates an existing page.
143
- */
144
- update: (input: UpdatePageArgs): Promise<UpdatePageResult> => {
145
- return getBridge().updatePage(input)
146
- },
147
-
148
- /**
149
- * Archives a page.
150
- */
151
- archive: (pageId: NotionPageId): Promise<UpdatePageResult> => {
152
- return getBridge().updatePage({ pageId, is_archived: true })
153
- },
154
-
155
- /**
156
- * Unarchives a page.
157
- */
158
- unarchive: (pageId: NotionPageId): Promise<UpdatePageResult> => {
159
- return getBridge().updatePage({ pageId, is_archived: false })
145
+ /** External-link APIs exposed under `sdk.links.*`. */
146
+ export const links = {
147
+ /** Requests host-owned approval before opening an HTTPS URL. */
148
+ open: (url: string): Promise<OpenExternalUrlResult> => {
149
+ return getBridge().openExternalUrl(url)
160
150
  },
161
151
  }
162
152
 
@@ -0,0 +1,140 @@
1
+ import type { NotionDataSource } from "@notionhq/custom-blocks-protocol/dataSources/dataSource.js"
2
+ import type {
3
+ NotionDataSourceId,
4
+ NotionPageId,
5
+ } from "@notionhq/custom-blocks-protocol/ids.js"
6
+ import { CustomBlockInitializationError } from "@notionhq/custom-blocks-protocol/messages/init.js"
7
+ import { subscribeToDataSource } from "./bridge/dataSources/subscribe.js"
8
+ import { getBridge } from "./bridge/sandboxClient.js"
9
+ import type {
10
+ CreatePageArgs,
11
+ CustomBlockGetPageErrorInfo,
12
+ DataSourceQueryOptions,
13
+ DataSourcesPageResult,
14
+ DataSourcesQueryResult,
15
+ } from "./types.js"
16
+
17
+ export const dataSources = {
18
+ async getPage(
19
+ key: string,
20
+ pageId: NotionPageId,
21
+ ): Promise<DataSourcesPageResult> {
22
+ const resolved = resolvePageDataSource(key)
23
+ if (resolved.status === "error") {
24
+ return resolved
25
+ }
26
+ const { dataSource, dataSourceId } = resolved
27
+ const result = await getBridge().getPage(pageId, dataSourceId)
28
+ return result.status === "error"
29
+ ? result
30
+ : { ...result, propertyIdsByKey: dataSource.propertyIdsByKey }
31
+ },
32
+ async create(
33
+ key: string,
34
+ payload: Omit<CreatePageArgs, "parent" | "position">,
35
+ ): Promise<DataSourcesPageResult> {
36
+ const resolved = resolvePageDataSource(key)
37
+ if (resolved.status === "error") {
38
+ return resolved
39
+ }
40
+ const { dataSource, dataSourceId } = resolved
41
+ const result = await getBridge().createPage(
42
+ {
43
+ ...payload,
44
+ parent: { type: "data_source_id", data_source_id: dataSourceId },
45
+ },
46
+ dataSourceId,
47
+ )
48
+ return result.status === "error"
49
+ ? result
50
+ : { ...result, propertyIdsByKey: dataSource.propertyIdsByKey }
51
+ },
52
+ async query(
53
+ key: string,
54
+ options?: DataSourceQueryOptions,
55
+ ): Promise<DataSourcesQueryResult> {
56
+ const bridge = getBridge()
57
+ if (bridge.getHostState().status !== "initialized") {
58
+ try {
59
+ await bridge.initialize()
60
+ } catch (error) {
61
+ if (bridge.getHostState().status !== "initialized") {
62
+ return {
63
+ status: "error",
64
+ error:
65
+ error instanceof CustomBlockInitializationError
66
+ ? {
67
+ code: error.code,
68
+ message: error.message,
69
+ isRetryable: error.isRetryable,
70
+ }
71
+ : {
72
+ code: "unknown_error",
73
+ message:
74
+ error instanceof Error ? error.message : String(error),
75
+ isRetryable: false,
76
+ },
77
+ }
78
+ }
79
+ }
80
+ }
81
+ return new Promise(resolve => {
82
+ let completed = false
83
+ let unsubscribe = () => {}
84
+ unsubscribe = subscribeToDataSource(
85
+ {
86
+ key,
87
+ options,
88
+ onSnapshot: snapshot => {
89
+ if (snapshot.isLoading || completed) {
90
+ return
91
+ }
92
+ completed = true
93
+ unsubscribe()
94
+ resolve({ status: "success", ...snapshot })
95
+ },
96
+ },
97
+ error => {
98
+ if (completed) {
99
+ return
100
+ }
101
+ completed = true
102
+ unsubscribe()
103
+ resolve({ status: "error", error })
104
+ },
105
+ )
106
+ if (completed) {
107
+ unsubscribe()
108
+ }
109
+ })
110
+ },
111
+ }
112
+
113
+ function resolvePageDataSource(key: string):
114
+ | {
115
+ status: "success"
116
+ dataSource: NotionDataSource
117
+ dataSourceId: NotionDataSourceId
118
+ }
119
+ | { status: "error"; error: CustomBlockGetPageErrorInfo } {
120
+ const hostState = getBridge().getHostState()
121
+ const dataSource =
122
+ hostState.status === "initialized"
123
+ ? hostState.dataSources.find(source => source.key === key)
124
+ : undefined
125
+ if (!dataSource?.collectionPointer) {
126
+ return {
127
+ status: "error",
128
+ error: {
129
+ code: dataSource ? "unmapped_data_source" : "unknown_data_source_key",
130
+ message: `No bound data source for "${key}".`,
131
+ isRetryable: false,
132
+ },
133
+ }
134
+ }
135
+ return {
136
+ status: "success",
137
+ dataSource,
138
+ dataSourceId: dataSource.collectionPointer.id,
139
+ }
140
+ }
package/src/index.ts CHANGED
@@ -12,18 +12,6 @@ export type {
12
12
  NotionCollectionSchema,
13
13
  NotionDataSource,
14
14
  } from "@notionhq/custom-blocks-protocol/dataSources/dataSource.js"
15
- export type { NotionDataSourceValue } from "@notionhq/custom-blocks-protocol/dataSources/dataSourceValue.js"
16
- export type {
17
- NotionDate,
18
- NotionDateRange,
19
- NotionDateReminder,
20
- NotionDateTime,
21
- NotionDateTimeRange,
22
- NotionDateTimeReminder,
23
- NotionDateValue,
24
- NotionNoReminder,
25
- NotionTimeReminder,
26
- } from "@notionhq/custom-blocks-protocol/dataSources/dateValue.js"
27
15
  export type {
28
16
  CustomBlockDataSourceResolutionErrorCode,
29
17
  CustomBlockDataSourceResolutionErrorInfo,
@@ -31,7 +19,6 @@ export type {
31
19
  CustomBlockPropertyErrorInfo,
32
20
  } from "@notionhq/custom-blocks-protocol/dataSources/errors.js"
33
21
  export type {
34
- NotionBuiltinPropertyId,
35
22
  NotionDualProperty,
36
23
  NotionPropertyColor,
37
24
  NotionPropertyOption,
@@ -39,10 +26,7 @@ export type {
39
26
  NotionPropertyType,
40
27
  NotionStatusGroup,
41
28
  } from "@notionhq/custom-blocks-protocol/dataSources/propertySchema.js"
42
- export {
43
- NOTION_BUILTIN_PROPERTY_IDS,
44
- NOTION_PROPERTY_TYPES,
45
- } from "@notionhq/custom-blocks-protocol/dataSources/propertySchema.js"
29
+ export { NOTION_PROPERTY_TYPES } from "@notionhq/custom-blocks-protocol/dataSources/propertySchema.js"
46
30
  export type { NotionRecordPointer } from "@notionhq/custom-blocks-protocol/dataSources/recordPointer.js"
47
31
  export type { NotionSortDirection } from "@notionhq/custom-blocks-protocol/dataSources/sortDirection.js"
48
32
  export type { CustomBlockErrorInfo } from "@notionhq/custom-blocks-protocol/errors.js"
@@ -81,6 +65,10 @@ export type {
81
65
  CustomBlockListUsersErrorCode,
82
66
  CustomBlockListUsersErrorInfo,
83
67
  } from "@notionhq/custom-blocks-protocol/messages/listUsers.js"
68
+ export type {
69
+ CustomBlockOpenExternalUrlErrorCode,
70
+ CustomBlockOpenExternalUrlErrorInfo,
71
+ } from "@notionhq/custom-blocks-protocol/messages/openExternalUrl.js"
84
72
  export type {
85
73
  CustomBlockOpenPageErrorCode,
86
74
  CustomBlockOpenPageErrorInfo,
@@ -96,16 +84,18 @@ export type {
96
84
  } from "@notionhq/custom-blocks-protocol/messages/updatePageResult.js"
97
85
  export type {
98
86
  CustomBlockPage,
99
- NotionPage,
87
+ NotionDateInput,
100
88
  NotionPageCover,
101
89
  NotionPageIcon,
90
+ NotionPagePropertyReadMap,
102
91
  NotionPagePropertyValue,
103
92
  NotionPagePropertyWriteMap,
104
93
  } from "@notionhq/custom-blocks-protocol/pages/page.js"
105
94
  export type { NotionParent } from "@notionhq/custom-blocks-protocol/parent.js"
106
95
  export type { NotionTheme } from "@notionhq/custom-blocks-protocol/theme.js"
107
- export { pages, users } from "./bridge/sandboxClient.js"
96
+ export { links, pages, users } from "./bridge/sandboxClient.js"
108
97
  export { customBlock } from "./customBlock.js"
98
+ export { dataSources } from "./dataSources.js"
109
99
  export {
110
100
  type CustomBlockInitPayload,
111
101
  initCustomBlock,
@@ -5,9 +5,7 @@ import type { UseDataSourceOptions, UseDataSourceResult } from "../types.js"
5
5
 
6
6
  const EMPTY_DATA_SOURCE_RESULT: UseDataSourceResult = {
7
7
  items: [],
8
- propertySchemasById: {},
9
8
  propertyIdsByKey: {},
10
- propertySchemasByKey: {},
11
9
  isLoading: false,
12
10
  hasMore: false,
13
11
  }
@@ -26,7 +24,7 @@ type DataSourceHookState = {
26
24
  * is capped at 999. `sorts` are applied in array order.
27
25
  *
28
26
  * @example
29
- * const { items, isLoading, hasMore, error } = useDataSource("default", { limit: 25 })
27
+ * const { items, propertyIdsByKey, isLoading, hasMore } = useDataSource("default", { limit: 25 })
30
28
  */
31
29
  export function useDataSource(
32
30
  key: string,