@notionhq/custom-blocks 0.1.6 → 0.1.8
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/README.md +14 -1
- package/bin/notion-custom-blocks/cli.js +6 -0
- package/dist/bridge/SandboxBridge.d.ts +3 -9
- package/dist/bridge/SandboxBridge.d.ts.map +1 -1
- package/dist/bridge/SandboxBridge.js +5 -10
- package/dist/bridge/dataSources/resolve.d.ts +3 -3
- package/dist/bridge/dataSources/resolve.d.ts.map +1 -1
- package/dist/bridge/dataSources/resolve.js +1 -1
- package/dist/bridge/dataSources/resolveProperty.d.ts +6 -9
- package/dist/bridge/dataSources/resolveProperty.d.ts.map +1 -1
- package/dist/bridge/dataSources/resolveProperty.js +3 -6
- package/dist/bridge/hostState.d.ts +11 -11
- package/dist/bridge/hostState.d.ts.map +1 -1
- package/dist/bridge/loadManifest.d.ts +2 -2
- package/dist/bridge/loadManifest.d.ts.map +1 -1
- package/dist/bridge/loadManifest.js +1 -1
- package/dist/bridge/sandboxClient.d.ts +1 -1
- package/dist/bridge/sandboxClient.d.ts.map +1 -1
- package/dist/customBlock.d.ts +8 -8
- package/dist/customBlock.d.ts.map +1 -1
- package/dist/index.d.ts +24 -25
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/init.d.ts +8 -8
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +1 -1
- package/dist/protocol/contrast.d.ts.map +1 -0
- package/dist/protocol/dataSources/dataSource.d.ts.map +1 -0
- package/dist/protocol/dataSources/dataSourcePage.d.ts.map +1 -0
- package/dist/protocol/dataSources/dataSourceValue.d.ts.map +1 -0
- package/dist/protocol/dataSources/dateValue.d.ts.map +1 -0
- package/dist/{bridge → protocol}/dataSources/errors.d.ts +3 -0
- package/dist/protocol/dataSources/errors.d.ts.map +1 -0
- package/dist/{bridge → protocol}/dataSources/errors.js +3 -0
- package/dist/protocol/dataSources/propertySchema.d.ts.map +1 -0
- package/dist/protocol/dataSources/recordPointer.d.ts.map +1 -0
- package/dist/protocol/errors.d.ts.map +1 -0
- package/dist/protocol/ids.d.ts.map +1 -0
- package/dist/protocol/incomingType.d.ts.map +1 -0
- package/dist/protocol/index.d.ts +48 -0
- package/dist/protocol/index.d.ts.map +1 -0
- package/dist/protocol/index.js +47 -0
- package/dist/protocol/manifest.d.ts.map +1 -0
- package/dist/protocol/messages/connect.d.ts.map +1 -0
- package/dist/protocol/messages/contrastModeChanged.d.ts.map +1 -0
- package/dist/protocol/messages/createPage.d.ts.map +1 -0
- package/dist/protocol/messages/createPageResult.d.ts.map +1 -0
- package/dist/protocol/messages/currentUserChanged.d.ts.map +1 -0
- package/dist/{bridge → protocol}/messages/dataSourcesChanged.d.ts +1 -1
- package/dist/protocol/messages/dataSourcesChanged.d.ts.map +1 -0
- package/dist/{bridge → protocol}/messages/dataSourcesChanged.js +1 -1
- package/dist/protocol/messages/getPage.d.ts.map +1 -0
- package/dist/protocol/messages/getUser.d.ts.map +1 -0
- package/dist/{bridge → protocol}/messages/hostToSandbox.d.ts.map +1 -1
- package/dist/protocol/messages/init.d.ts.map +1 -0
- package/dist/protocol/messages/initResult.d.ts.map +1 -0
- package/dist/protocol/messages/invalidHostMessage.d.ts.map +1 -0
- package/dist/protocol/messages/invalidSandboxMessage.d.ts.map +1 -0
- package/dist/protocol/messages/listUsers.d.ts.map +1 -0
- package/dist/protocol/messages/pageChanged.d.ts.map +1 -0
- package/dist/protocol/messages/parentChanged.d.ts.map +1 -0
- package/dist/protocol/messages/queryDataSource.d.ts.map +1 -0
- package/dist/protocol/messages/queryDataSourceResult.d.ts.map +1 -0
- package/dist/protocol/messages/resize.d.ts.map +1 -0
- package/dist/{bridge → protocol}/messages/sandboxToHost.d.ts.map +1 -1
- package/dist/protocol/messages/themeChanged.d.ts.map +1 -0
- package/dist/protocol/messages/updatePage.d.ts.map +1 -0
- package/dist/protocol/messages/updatePageResult.d.ts.map +1 -0
- package/dist/{bridge → protocol}/pages/page.d.ts +1 -1
- package/dist/protocol/pages/page.d.ts.map +1 -0
- package/dist/protocol/parent.d.ts.map +1 -0
- package/dist/protocol/protocolVersion.d.ts +7 -0
- package/dist/protocol/protocolVersion.d.ts.map +1 -0
- package/dist/protocol/protocolVersion.js +6 -0
- package/dist/protocol/theme.d.ts.map +1 -0
- package/dist/protocol/users/user.d.ts.map +1 -0
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/standalonePreview.d.ts.map +1 -1
- package/dist/react/standalonePreview.js +2 -2
- package/dist/react/useCustomBlockInit.d.ts +1 -1
- package/dist/react/useCustomBlockInit.d.ts.map +1 -1
- package/dist/react/useDataSource.d.ts +1 -1
- package/dist/react/useDataSource.js +1 -1
- package/dist/react/useRuntimeState.d.ts +9 -9
- package/dist/react/useRuntimeState.d.ts.map +1 -1
- package/dist/react/useRuntimeState.js +2 -2
- package/dist/types.d.ts +19 -18
- package/dist/types.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/docs/block-location.md +1 -1
- package/docs/data-sources.md +1 -1
- package/docs/deployment.md +1 -1
- package/docs/errors.md +0 -2
- package/docs/lifecycle.md +5 -5
- package/docs/pages.md +4 -4
- package/package.json +3 -7
- package/src/bridge/SandboxBridge.ts +36 -42
- package/src/bridge/dataSources/resolve.ts +3 -3
- package/src/bridge/dataSources/resolveProperty.ts +14 -20
- package/src/bridge/hostState.ts +15 -12
- package/src/bridge/loadManifest.ts +5 -2
- package/src/bridge/sandboxClient.ts +1 -1
- package/src/customBlock.ts +8 -8
- package/src/index.ts +26 -30
- package/src/init.ts +8 -8
- package/src/react/index.ts +1 -1
- package/src/react/standalonePreview.ts +5 -2
- package/src/react/useCustomBlockInit.ts +1 -1
- package/src/react/useDataSource.ts +1 -1
- package/src/react/useRuntimeState.ts +9 -9
- package/src/types.ts +27 -24
- package/HOST.md +0 -224
- package/dist/bridge/contrast.d.ts.map +0 -1
- package/dist/bridge/dataSources/dataSource.d.ts.map +0 -1
- package/dist/bridge/dataSources/dataSourcePage.d.ts.map +0 -1
- package/dist/bridge/dataSources/dataSourceValue.d.ts.map +0 -1
- package/dist/bridge/dataSources/dateValue.d.ts.map +0 -1
- package/dist/bridge/dataSources/errors.d.ts.map +0 -1
- package/dist/bridge/dataSources/propertySchema.d.ts.map +0 -1
- package/dist/bridge/dataSources/recordPointer.d.ts.map +0 -1
- package/dist/bridge/errors.d.ts.map +0 -1
- package/dist/bridge/ids.d.ts.map +0 -1
- package/dist/bridge/incomingType.d.ts.map +0 -1
- package/dist/bridge/manifest.d.ts.map +0 -1
- package/dist/bridge/messages/connect.d.ts.map +0 -1
- package/dist/bridge/messages/contrastModeChanged.d.ts.map +0 -1
- package/dist/bridge/messages/createPage.d.ts.map +0 -1
- package/dist/bridge/messages/createPageResult.d.ts.map +0 -1
- package/dist/bridge/messages/currentUserChanged.d.ts.map +0 -1
- package/dist/bridge/messages/dataSourcesChanged.d.ts.map +0 -1
- package/dist/bridge/messages/getPage.d.ts.map +0 -1
- package/dist/bridge/messages/getUser.d.ts.map +0 -1
- package/dist/bridge/messages/init.d.ts.map +0 -1
- package/dist/bridge/messages/initResult.d.ts.map +0 -1
- package/dist/bridge/messages/invalidHostMessage.d.ts.map +0 -1
- package/dist/bridge/messages/invalidSandboxMessage.d.ts.map +0 -1
- package/dist/bridge/messages/listUsers.d.ts.map +0 -1
- package/dist/bridge/messages/pageChanged.d.ts.map +0 -1
- package/dist/bridge/messages/parentChanged.d.ts.map +0 -1
- package/dist/bridge/messages/queryDataSource.d.ts.map +0 -1
- package/dist/bridge/messages/queryDataSourceResult.d.ts.map +0 -1
- package/dist/bridge/messages/resize.d.ts.map +0 -1
- package/dist/bridge/messages/themeChanged.d.ts.map +0 -1
- package/dist/bridge/messages/updatePage.d.ts.map +0 -1
- package/dist/bridge/messages/updatePageResult.d.ts.map +0 -1
- package/dist/bridge/pages/page.d.ts.map +0 -1
- package/dist/bridge/parent.d.ts.map +0 -1
- package/dist/bridge/theme.d.ts.map +0 -1
- package/dist/bridge/users/user.d.ts.map +0 -1
- package/dist/host/createCustomBlockHost.d.ts +0 -39
- package/dist/host/createCustomBlockHost.d.ts.map +0 -1
- package/dist/host/createCustomBlockHost.js +0 -495
- package/dist/host/lifecycle/initErrors.d.ts +0 -13
- package/dist/host/lifecycle/initErrors.d.ts.map +0 -1
- package/dist/host/lifecycle/initErrors.js +0 -152
- package/dist/host/lifecycle/protocolVersion.d.ts +0 -2
- package/dist/host/lifecycle/protocolVersion.d.ts.map +0 -1
- package/dist/host/lifecycle/protocolVersion.js +0 -3
- package/dist/host/lifecycle/types.d.ts +0 -28
- package/dist/host/lifecycle/types.d.ts.map +0 -1
- package/dist/host/lifecycle/types.js +0 -1
- package/dist/host/messages/invalidSandboxMessage.d.ts +0 -7
- package/dist/host/messages/invalidSandboxMessage.d.ts.map +0 -1
- package/dist/host/messages/invalidSandboxMessage.js +0 -21
- package/dist/host/messages/types.d.ts +0 -60
- package/dist/host/messages/types.d.ts.map +0 -1
- package/dist/host/messages/types.js +0 -1
- package/dist/host/queries/querySubscriptions.d.ts +0 -20
- package/dist/host/queries/querySubscriptions.d.ts.map +0 -1
- package/dist/host/queries/querySubscriptions.js +0 -45
- package/dist/host/queries/types.d.ts +0 -11
- package/dist/host/queries/types.d.ts.map +0 -1
- package/dist/host/queries/types.js +0 -1
- package/dist/host.d.ts +0 -79
- package/dist/host.d.ts.map +0 -1
- package/dist/host.js +0 -45
- package/src/bridge/contrast.ts +0 -6
- package/src/bridge/dataSources/dataSource.ts +0 -63
- package/src/bridge/dataSources/dataSourcePage.ts +0 -71
- package/src/bridge/dataSources/dataSourceValue.ts +0 -19
- package/src/bridge/dataSources/dateValue.ts +0 -96
- package/src/bridge/dataSources/errors.ts +0 -14
- package/src/bridge/dataSources/propertySchema.ts +0 -186
- package/src/bridge/dataSources/recordPointer.ts +0 -13
- package/src/bridge/errors.ts +0 -21
- package/src/bridge/ids.ts +0 -72
- package/src/bridge/incomingType.ts +0 -19
- package/src/bridge/manifest.ts +0 -47
- package/src/bridge/messages/connect.ts +0 -42
- package/src/bridge/messages/contrastModeChanged.ts +0 -12
- package/src/bridge/messages/createPage.ts +0 -62
- package/src/bridge/messages/createPageResult.ts +0 -52
- package/src/bridge/messages/currentUserChanged.ts +0 -14
- package/src/bridge/messages/dataSourcesChanged.ts +0 -18
- package/src/bridge/messages/getPage.ts +0 -51
- package/src/bridge/messages/getUser.ts +0 -49
- package/src/bridge/messages/hostToSandbox.ts +0 -39
- package/src/bridge/messages/init.ts +0 -99
- package/src/bridge/messages/initResult.ts +0 -37
- package/src/bridge/messages/invalidHostMessage.ts +0 -16
- package/src/bridge/messages/invalidSandboxMessage.ts +0 -18
- package/src/bridge/messages/listUsers.ts +0 -50
- package/src/bridge/messages/pageChanged.ts +0 -12
- package/src/bridge/messages/parentChanged.ts +0 -14
- package/src/bridge/messages/queryDataSource.ts +0 -20
- package/src/bridge/messages/queryDataSourceResult.ts +0 -45
- package/src/bridge/messages/resize.ts +0 -13
- package/src/bridge/messages/sandboxToHost.ts +0 -32
- package/src/bridge/messages/themeChanged.ts +0 -15
- package/src/bridge/messages/updatePage.ts +0 -22
- package/src/bridge/messages/updatePageResult.ts +0 -49
- package/src/bridge/pages/page.ts +0 -290
- package/src/bridge/parent.ts +0 -30
- package/src/bridge/theme.ts +0 -5
- package/src/bridge/users/user.ts +0 -31
- package/src/host/createCustomBlockHost.ts +0 -662
- package/src/host/lifecycle/initErrors.ts +0 -165
- package/src/host/lifecycle/protocolVersion.ts +0 -3
- package/src/host/lifecycle/types.ts +0 -40
- package/src/host/messages/invalidSandboxMessage.ts +0 -35
- package/src/host/messages/types.ts +0 -67
- package/src/host/queries/querySubscriptions.ts +0 -71
- package/src/host/queries/types.ts +0 -13
- package/src/host.ts +0 -182
- /package/dist/{bridge → protocol}/contrast.d.ts +0 -0
- /package/dist/{bridge → protocol}/contrast.js +0 -0
- /package/dist/{bridge → protocol}/dataSources/dataSource.d.ts +0 -0
- /package/dist/{bridge → protocol}/dataSources/dataSource.js +0 -0
- /package/dist/{bridge → protocol}/dataSources/dataSourcePage.d.ts +0 -0
- /package/dist/{bridge → protocol}/dataSources/dataSourcePage.js +0 -0
- /package/dist/{bridge → protocol}/dataSources/dataSourceValue.d.ts +0 -0
- /package/dist/{bridge → protocol}/dataSources/dataSourceValue.js +0 -0
- /package/dist/{bridge → protocol}/dataSources/dateValue.d.ts +0 -0
- /package/dist/{bridge → protocol}/dataSources/dateValue.js +0 -0
- /package/dist/{bridge → protocol}/dataSources/propertySchema.d.ts +0 -0
- /package/dist/{bridge → protocol}/dataSources/propertySchema.js +0 -0
- /package/dist/{bridge → protocol}/dataSources/recordPointer.d.ts +0 -0
- /package/dist/{bridge → protocol}/dataSources/recordPointer.js +0 -0
- /package/dist/{bridge → protocol}/errors.d.ts +0 -0
- /package/dist/{bridge → protocol}/errors.js +0 -0
- /package/dist/{bridge → protocol}/ids.d.ts +0 -0
- /package/dist/{bridge → protocol}/ids.js +0 -0
- /package/dist/{bridge → protocol}/incomingType.d.ts +0 -0
- /package/dist/{bridge → protocol}/incomingType.js +0 -0
- /package/dist/{bridge → protocol}/manifest.d.ts +0 -0
- /package/dist/{bridge → protocol}/manifest.js +0 -0
- /package/dist/{bridge → protocol}/messages/connect.d.ts +0 -0
- /package/dist/{bridge → protocol}/messages/connect.js +0 -0
- /package/dist/{bridge → protocol}/messages/contrastModeChanged.d.ts +0 -0
- /package/dist/{bridge → protocol}/messages/contrastModeChanged.js +0 -0
- /package/dist/{bridge → protocol}/messages/createPage.d.ts +0 -0
- /package/dist/{bridge → protocol}/messages/createPage.js +0 -0
- /package/dist/{bridge → protocol}/messages/createPageResult.d.ts +0 -0
- /package/dist/{bridge → protocol}/messages/createPageResult.js +0 -0
- /package/dist/{bridge → protocol}/messages/currentUserChanged.d.ts +0 -0
- /package/dist/{bridge → protocol}/messages/currentUserChanged.js +0 -0
- /package/dist/{bridge → protocol}/messages/getPage.d.ts +0 -0
- /package/dist/{bridge → protocol}/messages/getPage.js +0 -0
- /package/dist/{bridge → protocol}/messages/getUser.d.ts +0 -0
- /package/dist/{bridge → protocol}/messages/getUser.js +0 -0
- /package/dist/{bridge → protocol}/messages/hostToSandbox.d.ts +0 -0
- /package/dist/{bridge → protocol}/messages/hostToSandbox.js +0 -0
- /package/dist/{bridge → protocol}/messages/init.d.ts +0 -0
- /package/dist/{bridge → protocol}/messages/init.js +0 -0
- /package/dist/{bridge → protocol}/messages/initResult.d.ts +0 -0
- /package/dist/{bridge → protocol}/messages/initResult.js +0 -0
- /package/dist/{bridge → protocol}/messages/invalidHostMessage.d.ts +0 -0
- /package/dist/{bridge → protocol}/messages/invalidHostMessage.js +0 -0
- /package/dist/{bridge → protocol}/messages/invalidSandboxMessage.d.ts +0 -0
- /package/dist/{bridge → protocol}/messages/invalidSandboxMessage.js +0 -0
- /package/dist/{bridge → protocol}/messages/listUsers.d.ts +0 -0
- /package/dist/{bridge → protocol}/messages/listUsers.js +0 -0
- /package/dist/{bridge → protocol}/messages/pageChanged.d.ts +0 -0
- /package/dist/{bridge → protocol}/messages/pageChanged.js +0 -0
- /package/dist/{bridge → protocol}/messages/parentChanged.d.ts +0 -0
- /package/dist/{bridge → protocol}/messages/parentChanged.js +0 -0
- /package/dist/{bridge → protocol}/messages/queryDataSource.d.ts +0 -0
- /package/dist/{bridge → protocol}/messages/queryDataSource.js +0 -0
- /package/dist/{bridge → protocol}/messages/queryDataSourceResult.d.ts +0 -0
- /package/dist/{bridge → protocol}/messages/queryDataSourceResult.js +0 -0
- /package/dist/{bridge → protocol}/messages/resize.d.ts +0 -0
- /package/dist/{bridge → protocol}/messages/resize.js +0 -0
- /package/dist/{bridge → protocol}/messages/sandboxToHost.d.ts +0 -0
- /package/dist/{bridge → protocol}/messages/sandboxToHost.js +0 -0
- /package/dist/{bridge → protocol}/messages/themeChanged.d.ts +0 -0
- /package/dist/{bridge → protocol}/messages/themeChanged.js +0 -0
- /package/dist/{bridge → protocol}/messages/updatePage.d.ts +0 -0
- /package/dist/{bridge → protocol}/messages/updatePage.js +0 -0
- /package/dist/{bridge → protocol}/messages/updatePageResult.d.ts +0 -0
- /package/dist/{bridge → protocol}/messages/updatePageResult.js +0 -0
- /package/dist/{bridge → protocol}/pages/page.js +0 -0
- /package/dist/{bridge → protocol}/parent.d.ts +0 -0
- /package/dist/{bridge → protocol}/parent.js +0 -0
- /package/dist/{bridge → protocol}/theme.d.ts +0 -0
- /package/dist/{bridge → protocol}/theme.js +0 -0
- /package/dist/{bridge → protocol}/users/user.d.ts +0 -0
- /package/dist/{bridge → protocol}/users/user.js +0 -0
|
@@ -1,3 +1,39 @@
|
|
|
1
|
+
import { DEFAULT_CONTRAST_MODE } from "@notionhq/custom-blocks-protocol/contrast.js"
|
|
2
|
+
import type {
|
|
3
|
+
NotionDataSource,
|
|
4
|
+
NotionDataSourceBindings,
|
|
5
|
+
} from "@notionhq/custom-blocks-protocol/dataSources/dataSource.js"
|
|
6
|
+
import type {
|
|
7
|
+
NotionDataSourcePageUpdateInput,
|
|
8
|
+
NotionDataSourcePageUpdateResult,
|
|
9
|
+
} from "@notionhq/custom-blocks-protocol/dataSources/dataSourcePage.js"
|
|
10
|
+
import { readIncomingType } from "@notionhq/custom-blocks-protocol/incomingType.js"
|
|
11
|
+
import type { CustomBlockManifest } from "@notionhq/custom-blocks-protocol/manifest.js"
|
|
12
|
+
import type { ConnectMessage } from "@notionhq/custom-blocks-protocol/messages/connect.js"
|
|
13
|
+
import type {
|
|
14
|
+
CreatePageMessage,
|
|
15
|
+
CreatePageMessageParent,
|
|
16
|
+
} from "@notionhq/custom-blocks-protocol/messages/createPage.js"
|
|
17
|
+
import type { CustomBlockCreatePageErrorInfo } from "@notionhq/custom-blocks-protocol/messages/createPageResult.js"
|
|
18
|
+
import type { GetUserMessage } from "@notionhq/custom-blocks-protocol/messages/getUser.js"
|
|
19
|
+
import { hostToSandboxMessageSchema } from "@notionhq/custom-blocks-protocol/messages/hostToSandbox.js"
|
|
20
|
+
import {
|
|
21
|
+
CustomBlockInitializationError,
|
|
22
|
+
type InitMessage,
|
|
23
|
+
initMessageSchema,
|
|
24
|
+
} from "@notionhq/custom-blocks-protocol/messages/init.js"
|
|
25
|
+
import type {
|
|
26
|
+
CustomBlockInitResultErrorInfo,
|
|
27
|
+
InitResultMessage,
|
|
28
|
+
} from "@notionhq/custom-blocks-protocol/messages/initResult.js"
|
|
29
|
+
import type { InvalidHostMessage } from "@notionhq/custom-blocks-protocol/messages/invalidHostMessage.js"
|
|
30
|
+
import type { ListUsersMessage } from "@notionhq/custom-blocks-protocol/messages/listUsers.js"
|
|
31
|
+
import type { QueryDataSourceMessage } from "@notionhq/custom-blocks-protocol/messages/queryDataSource.js"
|
|
32
|
+
import type { CustomBlockQueryDataSourceErrorInfo } from "@notionhq/custom-blocks-protocol/messages/queryDataSourceResult.js"
|
|
33
|
+
import type { ResizeMessage } from "@notionhq/custom-blocks-protocol/messages/resize.js"
|
|
34
|
+
import type { UpdatePageMessage } from "@notionhq/custom-blocks-protocol/messages/updatePage.js"
|
|
35
|
+
import { CUSTOM_BLOCK_BRIDGE_PROTOCOL_VERSION } from "@notionhq/custom-blocks-protocol/protocolVersion.js"
|
|
36
|
+
import type { NotionUser } from "@notionhq/custom-blocks-protocol/users/user.js"
|
|
1
37
|
import * as v from "valibot"
|
|
2
38
|
import type {
|
|
3
39
|
CreatePageInput,
|
|
@@ -14,15 +50,6 @@ import type {
|
|
|
14
50
|
} from "../types.js"
|
|
15
51
|
import { unreachable } from "../utils.js"
|
|
16
52
|
import { CUSTOM_BLOCKS_SDK_VERSION } from "../version.js"
|
|
17
|
-
import { DEFAULT_CONTRAST_MODE } from "./contrast.js"
|
|
18
|
-
import type {
|
|
19
|
-
NotionDataSource,
|
|
20
|
-
NotionDataSourceBindings,
|
|
21
|
-
} from "./dataSources/dataSource.js"
|
|
22
|
-
import type {
|
|
23
|
-
NotionDataSourcePageUpdateInput,
|
|
24
|
-
NotionDataSourcePageUpdateResult,
|
|
25
|
-
} from "./dataSources/dataSourcePage.js"
|
|
26
53
|
import { resolveDataSources } from "./dataSources/resolve.js"
|
|
27
54
|
import { resolvePropertyWriteMapForDataSource } from "./dataSources/resolveProperty.js"
|
|
28
55
|
import {
|
|
@@ -30,41 +57,8 @@ import {
|
|
|
30
57
|
createEmptyDataSourceQueryState,
|
|
31
58
|
type DataSourceQueryState,
|
|
32
59
|
} from "./hostState.js"
|
|
33
|
-
import { readIncomingType } from "./incomingType.js"
|
|
34
60
|
import type { ManifestLoadResult } from "./loadManifest.js"
|
|
35
|
-
import type { CustomBlockManifest } from "./manifest.js"
|
|
36
|
-
import type { ConnectMessage } from "./messages/connect.js"
|
|
37
|
-
import type {
|
|
38
|
-
CreatePageMessage,
|
|
39
|
-
CreatePageMessageParent,
|
|
40
|
-
} from "./messages/createPage.js"
|
|
41
|
-
import type { CustomBlockCreatePageErrorInfo } from "./messages/createPageResult.js"
|
|
42
|
-
import type { GetUserMessage } from "./messages/getUser.js"
|
|
43
|
-
import { hostToSandboxMessageSchema } from "./messages/hostToSandbox.js"
|
|
44
|
-
import {
|
|
45
|
-
CustomBlockInitializationError,
|
|
46
|
-
type InitMessage,
|
|
47
|
-
initMessageSchema,
|
|
48
|
-
} from "./messages/init.js"
|
|
49
|
-
import type {
|
|
50
|
-
CustomBlockInitResultErrorInfo,
|
|
51
|
-
InitResultMessage,
|
|
52
|
-
} from "./messages/initResult.js"
|
|
53
|
-
import type { InvalidHostMessage } from "./messages/invalidHostMessage.js"
|
|
54
|
-
import type { ListUsersMessage } from "./messages/listUsers.js"
|
|
55
|
-
import type { QueryDataSourceMessage } from "./messages/queryDataSource.js"
|
|
56
|
-
import type { CustomBlockQueryDataSourceErrorInfo } from "./messages/queryDataSourceResult.js"
|
|
57
|
-
import type { ResizeMessage } from "./messages/resize.js"
|
|
58
|
-
import type { UpdatePageMessage } from "./messages/updatePage.js"
|
|
59
61
|
import { PendingRequests } from "./pendingRequests.js"
|
|
60
|
-
import type { NotionUser } from "./users/user.js"
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Used to ensure that the host and client are using the same version of the bridge protocol. A
|
|
64
|
-
* single host needs to support multiple custom blocks built with different versions of the bridge
|
|
65
|
-
* protocol. Increment this number any time a breaking change is made to the bridge protocol.
|
|
66
|
-
*/
|
|
67
|
-
export const CUSTOM_BLOCK_BRIDGE_PROTOCOL_VERSION = 3
|
|
68
62
|
|
|
69
63
|
/**
|
|
70
64
|
* A single entry in the bridge message log. Kept intentionally plain so the log
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { CustomBlockManifest } from "../manifest.js"
|
|
2
1
|
import type {
|
|
3
2
|
NotionDataSource,
|
|
4
3
|
NotionDataSourceBindings,
|
|
5
|
-
} from "
|
|
4
|
+
} from "@notionhq/custom-blocks-protocol/dataSources/dataSource.js"
|
|
5
|
+
import type { CustomBlockManifest } from "@notionhq/custom-blocks-protocol/manifest.js"
|
|
6
6
|
|
|
7
7
|
type ResolveDataSourcesArgs = {
|
|
8
8
|
manifest: CustomBlockManifest
|
|
@@ -13,7 +13,7 @@ type ResolveDataSourcesArgs = {
|
|
|
13
13
|
* Builds the public {@link NotionDataSource} list the SDK exposes to consumers.
|
|
14
14
|
*
|
|
15
15
|
* Combines the host-supplied bindings (collection pointers + schemas) with the
|
|
16
|
-
* manifest's declared data
|
|
16
|
+
* manifest's declared data source keys. The host owns every mapping; the SDK
|
|
17
17
|
* validates supplied IDs but never infers omitted bindings.
|
|
18
18
|
*/
|
|
19
19
|
export function resolveDataSources(
|
|
@@ -1,25 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
1
|
+
import type { NotionDataSource } from "@notionhq/custom-blocks-protocol/dataSources/dataSource.js"
|
|
2
|
+
import type {
|
|
3
|
+
CustomBlockPropertyErrorCode,
|
|
4
|
+
CustomBlockPropertyErrorInfo,
|
|
5
|
+
} from "@notionhq/custom-blocks-protocol/dataSources/errors.js"
|
|
3
6
|
import type {
|
|
4
7
|
NotionPagePropertyInputMap,
|
|
5
8
|
NotionPagePropertyWriteMap,
|
|
6
|
-
} from "
|
|
7
|
-
import { notionPagePropertyValueSchema } from "
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
// The schema accepts any string code. The type lists known codes for
|
|
11
|
-
// autocomplete, with an open string fallback for newer senders.
|
|
12
|
-
export const customBlockPropertyErrorCodeSchema = v.string()
|
|
13
|
-
|
|
14
|
-
export type CustomBlockPropertyErrorCode =
|
|
15
|
-
| "unmapped_property"
|
|
16
|
-
| "property_id_mismatch"
|
|
17
|
-
| "duplicate_property"
|
|
18
|
-
| "invalid_property_value"
|
|
19
|
-
| (string & {})
|
|
9
|
+
} from "@notionhq/custom-blocks-protocol/pages/page.js"
|
|
10
|
+
import { notionPagePropertyValueSchema } from "@notionhq/custom-blocks-protocol/pages/page.js"
|
|
11
|
+
import * as v from "valibot"
|
|
20
12
|
|
|
21
|
-
export type
|
|
22
|
-
|
|
13
|
+
export type {
|
|
14
|
+
CustomBlockPropertyErrorCode,
|
|
15
|
+
CustomBlockPropertyErrorInfo,
|
|
16
|
+
} from "@notionhq/custom-blocks-protocol/dataSources/errors.js"
|
|
23
17
|
|
|
24
18
|
export type PropertyWriteMapResolutionResult =
|
|
25
19
|
| { status: "success"; properties: NotionPagePropertyWriteMap }
|
|
@@ -35,7 +29,7 @@ function makePropertyError(
|
|
|
35
29
|
/**
|
|
36
30
|
* Resolves a public SDK property write map into the ID-keyed bridge shape.
|
|
37
31
|
*
|
|
38
|
-
* Identifiers in `properties` may be raw property IDs or data
|
|
32
|
+
* Identifiers in `properties` may be raw property IDs or data source property keys; the latter
|
|
39
33
|
* are looked up in the `dataSource`'s `propertyIdsByKey`. Each value is re-parsed through
|
|
40
34
|
* `notionPagePropertyValueSchema` with its `id` rewritten to the resolved property ID.
|
|
41
35
|
*/
|
|
@@ -102,7 +96,7 @@ export function resolvePropertyWriteMapForDataSource(args: {
|
|
|
102
96
|
}
|
|
103
97
|
|
|
104
98
|
/**
|
|
105
|
-
* Treats bound data
|
|
99
|
+
* Treats bound data source keys as aliases for property IDs. An unbound key may still be used as
|
|
106
100
|
* a raw ID when it exactly matches a property in the data source schema.
|
|
107
101
|
*/
|
|
108
102
|
export function resolvePropertyIdentifierForDataSource(args: {
|
package/src/bridge/hostState.ts
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
import type { NotionContrastMode } from "
|
|
2
|
-
import type { NotionDataSource } from "
|
|
1
|
+
import type { NotionContrastMode } from "@notionhq/custom-blocks-protocol/contrast.js"
|
|
2
|
+
import type { NotionDataSource } from "@notionhq/custom-blocks-protocol/dataSources/dataSource.js"
|
|
3
3
|
import type {
|
|
4
4
|
NotionDataSourcePage,
|
|
5
5
|
NotionDataSourcePageBridge,
|
|
6
6
|
NotionDataSourcePageUpdateInput,
|
|
7
7
|
NotionDataSourcePageUpdateResult,
|
|
8
|
-
} from "
|
|
9
|
-
import type { NotionDataSourceValue } from "
|
|
10
|
-
import type { NotionPropertySchema } from "
|
|
11
|
-
import type { NotionBlockId } from "
|
|
12
|
-
import type { CustomBlockManifest } from "
|
|
13
|
-
import type { CustomBlockQueryDataSourceErrorInfo } from "
|
|
14
|
-
import type {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
} from "@notionhq/custom-blocks-protocol/dataSources/dataSourcePage.js"
|
|
9
|
+
import type { NotionDataSourceValue } from "@notionhq/custom-blocks-protocol/dataSources/dataSourceValue.js"
|
|
10
|
+
import type { NotionPropertySchema } from "@notionhq/custom-blocks-protocol/dataSources/propertySchema.js"
|
|
11
|
+
import type { NotionBlockId } from "@notionhq/custom-blocks-protocol/ids.js"
|
|
12
|
+
import type { CustomBlockManifest } from "@notionhq/custom-blocks-protocol/manifest.js"
|
|
13
|
+
import type { CustomBlockQueryDataSourceErrorInfo } from "@notionhq/custom-blocks-protocol/messages/queryDataSourceResult.js"
|
|
14
|
+
import type {
|
|
15
|
+
CustomBlockPage,
|
|
16
|
+
NotionPageId,
|
|
17
|
+
} from "@notionhq/custom-blocks-protocol/pages/page.js"
|
|
18
|
+
import type { NotionParent } from "@notionhq/custom-blocks-protocol/parent.js"
|
|
19
|
+
import type { NotionTheme } from "@notionhq/custom-blocks-protocol/theme.js"
|
|
20
|
+
import type { NotionUser } from "@notionhq/custom-blocks-protocol/users/user.js"
|
|
18
21
|
|
|
19
22
|
export type CustomBlockHostState = UninitializedHostState | InitializedHostState
|
|
20
23
|
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import type { CustomBlockErrorInfo } from "@notionhq/custom-blocks-protocol/errors.js"
|
|
2
|
+
import {
|
|
3
|
+
type CustomBlockManifest,
|
|
4
|
+
manifestSchema,
|
|
5
|
+
} from "@notionhq/custom-blocks-protocol/manifest.js"
|
|
1
6
|
import * as v from "valibot"
|
|
2
|
-
import type { CustomBlockErrorInfo } from "./errors.js"
|
|
3
|
-
import { type CustomBlockManifest, manifestSchema } from "./manifest.js"
|
|
4
7
|
|
|
5
8
|
const MANIFEST_URL = "custom_blocks.json"
|
|
6
9
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { InitMessage } from "@notionhq/custom-blocks-protocol/messages/init.js"
|
|
1
2
|
import type {
|
|
2
3
|
CreatePageInput,
|
|
3
4
|
CreatePageResult,
|
|
@@ -17,7 +18,6 @@ import {
|
|
|
17
18
|
getDataSourceQueryView as getDataSourceQueryViewWithBridge,
|
|
18
19
|
} from "./hostState.js"
|
|
19
20
|
import type { ManifestLoadResult } from "./loadManifest.js"
|
|
20
|
-
import type { InitMessage } from "./messages/init.js"
|
|
21
21
|
import { type MessageLogEntry, SandboxBridge } from "./SandboxBridge.js"
|
|
22
22
|
|
|
23
23
|
export type { MessageLogEntry }
|
package/src/customBlock.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
+
import type { NotionContrastMode } from "@notionhq/custom-blocks-protocol/contrast.js"
|
|
2
|
+
import type { NotionDataSource } from "@notionhq/custom-blocks-protocol/dataSources/dataSource.js"
|
|
3
|
+
import type { NotionBlockId } from "@notionhq/custom-blocks-protocol/ids.js"
|
|
4
|
+
import type { CustomBlockManifest } from "@notionhq/custom-blocks-protocol/manifest.js"
|
|
5
|
+
import type { CustomBlockPage } from "@notionhq/custom-blocks-protocol/pages/page.js"
|
|
6
|
+
import type { NotionParent } from "@notionhq/custom-blocks-protocol/parent.js"
|
|
7
|
+
import type { NotionTheme } from "@notionhq/custom-blocks-protocol/theme.js"
|
|
8
|
+
import type { NotionUser } from "@notionhq/custom-blocks-protocol/users/user.js"
|
|
1
9
|
import { autoResize } from "./autoResize.js"
|
|
2
|
-
import type { NotionContrastMode } from "./bridge/contrast.js"
|
|
3
|
-
import type { NotionDataSource } from "./bridge/dataSources/dataSource.js"
|
|
4
10
|
import type {
|
|
5
11
|
CustomBlockHostState,
|
|
6
12
|
InitializedHostState,
|
|
7
13
|
} from "./bridge/hostState.js"
|
|
8
|
-
import type { NotionBlockId } from "./bridge/ids.js"
|
|
9
|
-
import type { CustomBlockManifest } from "./bridge/manifest.js"
|
|
10
|
-
import type { CustomBlockPage } from "./bridge/pages/page.js"
|
|
11
|
-
import type { NotionParent } from "./bridge/parent.js"
|
|
12
14
|
import { customBlockHost } from "./bridge/sandboxClient.js"
|
|
13
|
-
import type { NotionTheme } from "./bridge/theme.js"
|
|
14
|
-
import type { NotionUser } from "./bridge/users/user.js"
|
|
15
15
|
|
|
16
16
|
export type CustomBlockState =
|
|
17
17
|
| {
|
package/src/index.ts
CHANGED
|
@@ -7,17 +7,17 @@
|
|
|
7
7
|
* should import hooks and components from `@notionhq/custom-blocks/react`.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
export type { NotionContrastMode } from "
|
|
10
|
+
export type { NotionContrastMode } from "@notionhq/custom-blocks-protocol/contrast.js"
|
|
11
11
|
export type {
|
|
12
12
|
NotionCollectionSchema,
|
|
13
13
|
NotionDataSource,
|
|
14
|
-
} from "
|
|
14
|
+
} from "@notionhq/custom-blocks-protocol/dataSources/dataSource.js"
|
|
15
15
|
export type {
|
|
16
16
|
NotionDataSourcePage,
|
|
17
17
|
NotionDataSourcePageUpdateInput,
|
|
18
18
|
NotionDataSourcePageUpdateResult,
|
|
19
|
-
} from "
|
|
20
|
-
export type { NotionDataSourceValue } from "
|
|
19
|
+
} from "@notionhq/custom-blocks-protocol/dataSources/dataSourcePage.js"
|
|
20
|
+
export type { NotionDataSourceValue } from "@notionhq/custom-blocks-protocol/dataSources/dataSourceValue.js"
|
|
21
21
|
export type {
|
|
22
22
|
NotionDate,
|
|
23
23
|
NotionDateRange,
|
|
@@ -28,11 +28,13 @@ export type {
|
|
|
28
28
|
NotionDateValue,
|
|
29
29
|
NotionNoReminder,
|
|
30
30
|
NotionTimeReminder,
|
|
31
|
-
} from "
|
|
31
|
+
} from "@notionhq/custom-blocks-protocol/dataSources/dateValue.js"
|
|
32
32
|
export type {
|
|
33
33
|
CustomBlockDataSourceResolutionErrorCode,
|
|
34
34
|
CustomBlockDataSourceResolutionErrorInfo,
|
|
35
|
-
|
|
35
|
+
CustomBlockPropertyErrorCode,
|
|
36
|
+
CustomBlockPropertyErrorInfo,
|
|
37
|
+
} from "@notionhq/custom-blocks-protocol/dataSources/errors.js"
|
|
36
38
|
export type {
|
|
37
39
|
NotionBuiltinPropertyId,
|
|
38
40
|
NotionDualProperty,
|
|
@@ -41,61 +43,55 @@ export type {
|
|
|
41
43
|
NotionPropertySchema,
|
|
42
44
|
NotionPropertyType,
|
|
43
45
|
NotionStatusGroup,
|
|
44
|
-
} from "
|
|
46
|
+
} from "@notionhq/custom-blocks-protocol/dataSources/propertySchema.js"
|
|
45
47
|
export {
|
|
46
48
|
NOTION_BUILTIN_PROPERTY_IDS,
|
|
47
49
|
NOTION_PROPERTY_TYPES,
|
|
48
|
-
} from "
|
|
49
|
-
export type { NotionRecordPointer } from "
|
|
50
|
-
export type {
|
|
51
|
-
CustomBlockPropertyErrorCode,
|
|
52
|
-
CustomBlockPropertyErrorInfo,
|
|
53
|
-
} from "./bridge/dataSources/resolveProperty.js"
|
|
54
|
-
export type { CustomBlockErrorInfo } from "./bridge/errors.js"
|
|
50
|
+
} from "@notionhq/custom-blocks-protocol/dataSources/propertySchema.js"
|
|
51
|
+
export type { NotionRecordPointer } from "@notionhq/custom-blocks-protocol/dataSources/recordPointer.js"
|
|
52
|
+
export type { CustomBlockErrorInfo } from "@notionhq/custom-blocks-protocol/errors.js"
|
|
55
53
|
export type {
|
|
56
54
|
NotionAgentId,
|
|
57
55
|
NotionBlockId,
|
|
58
56
|
NotionDataSourceId,
|
|
59
57
|
NotionSpaceId,
|
|
60
|
-
} from "
|
|
58
|
+
} from "@notionhq/custom-blocks-protocol/ids.js"
|
|
61
59
|
export type {
|
|
62
60
|
CustomBlockManifest,
|
|
63
61
|
ManifestDataSource,
|
|
64
62
|
ManifestIcon,
|
|
65
63
|
ManifestProperty,
|
|
66
|
-
} from "
|
|
67
|
-
export type { NotionCreatePagePosition } from "
|
|
64
|
+
} from "@notionhq/custom-blocks-protocol/manifest.js"
|
|
65
|
+
export type { NotionCreatePagePosition } from "@notionhq/custom-blocks-protocol/messages/createPage.js"
|
|
68
66
|
export type {
|
|
69
67
|
CustomBlockCreatePageErrorCode,
|
|
70
68
|
CustomBlockCreatePageErrorInfo,
|
|
71
|
-
} from "
|
|
69
|
+
} from "@notionhq/custom-blocks-protocol/messages/createPageResult.js"
|
|
72
70
|
export type {
|
|
73
71
|
CustomBlockGetPageErrorCode,
|
|
74
72
|
CustomBlockGetPageErrorInfo,
|
|
75
|
-
} from "
|
|
73
|
+
} from "@notionhq/custom-blocks-protocol/messages/getPage.js"
|
|
76
74
|
export type {
|
|
77
75
|
CustomBlockGetUserErrorCode,
|
|
78
76
|
CustomBlockGetUserErrorInfo,
|
|
79
|
-
} from "
|
|
77
|
+
} from "@notionhq/custom-blocks-protocol/messages/getUser.js"
|
|
80
78
|
export type {
|
|
81
|
-
CustomBlockInitErrorCode,
|
|
82
|
-
CustomBlockInitErrorInfo,
|
|
83
79
|
CustomBlockInitializationErrorCode,
|
|
84
80
|
CustomBlockInitializationErrorInfo,
|
|
85
|
-
} from "
|
|
86
|
-
export { CustomBlockInitializationError } from "
|
|
81
|
+
} from "@notionhq/custom-blocks-protocol/messages/init.js"
|
|
82
|
+
export { CustomBlockInitializationError } from "@notionhq/custom-blocks-protocol/messages/init.js"
|
|
87
83
|
export type {
|
|
88
84
|
CustomBlockListUsersErrorCode,
|
|
89
85
|
CustomBlockListUsersErrorInfo,
|
|
90
|
-
} from "
|
|
86
|
+
} from "@notionhq/custom-blocks-protocol/messages/listUsers.js"
|
|
91
87
|
export type {
|
|
92
88
|
CustomBlockQueryDataSourceErrorCode,
|
|
93
89
|
CustomBlockQueryDataSourceErrorInfo,
|
|
94
|
-
} from "
|
|
90
|
+
} from "@notionhq/custom-blocks-protocol/messages/queryDataSourceResult.js"
|
|
95
91
|
export type {
|
|
96
92
|
CustomBlockUpdatePageErrorCode,
|
|
97
93
|
CustomBlockUpdatePageErrorInfo,
|
|
98
|
-
} from "
|
|
94
|
+
} from "@notionhq/custom-blocks-protocol/messages/updatePageResult.js"
|
|
99
95
|
export type {
|
|
100
96
|
NotionPage,
|
|
101
97
|
NotionPageCover,
|
|
@@ -105,10 +101,10 @@ export type {
|
|
|
105
101
|
NotionPagePropertyInputValue,
|
|
106
102
|
NotionPagePropertyValue,
|
|
107
103
|
NotionPagePropertyWriteMap,
|
|
108
|
-
} from "
|
|
109
|
-
export type { NotionParent } from "
|
|
104
|
+
} from "@notionhq/custom-blocks-protocol/pages/page.js"
|
|
105
|
+
export type { NotionParent } from "@notionhq/custom-blocks-protocol/parent.js"
|
|
106
|
+
export type { NotionTheme } from "@notionhq/custom-blocks-protocol/theme.js"
|
|
110
107
|
export { pages, users } from "./bridge/sandboxClient.js"
|
|
111
|
-
export type { NotionTheme } from "./bridge/theme.js"
|
|
112
108
|
export { type CustomBlockState, customBlock } from "./customBlock.js"
|
|
113
109
|
export {
|
|
114
110
|
type CustomBlockInitPayload,
|
package/src/init.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type { NotionContrastMode } from "
|
|
2
|
-
import type { NotionDataSource } from "
|
|
3
|
-
import type { NotionBlockId } from "
|
|
1
|
+
import type { NotionContrastMode } from "@notionhq/custom-blocks-protocol/contrast.js"
|
|
2
|
+
import type { NotionDataSource } from "@notionhq/custom-blocks-protocol/dataSources/dataSource.js"
|
|
3
|
+
import type { NotionBlockId } from "@notionhq/custom-blocks-protocol/ids.js"
|
|
4
|
+
import { CustomBlockInitializationError } from "@notionhq/custom-blocks-protocol/messages/init.js"
|
|
5
|
+
import type { CustomBlockPage } from "@notionhq/custom-blocks-protocol/pages/page.js"
|
|
6
|
+
import type { NotionParent } from "@notionhq/custom-blocks-protocol/parent.js"
|
|
7
|
+
import type { NotionTheme } from "@notionhq/custom-blocks-protocol/theme.js"
|
|
8
|
+
import type { NotionUser } from "@notionhq/custom-blocks-protocol/users/user.js"
|
|
4
9
|
import { attemptToLoadSelfHostedManifest } from "./bridge/loadManifest.js"
|
|
5
|
-
import { CustomBlockInitializationError } from "./bridge/messages/init.js"
|
|
6
|
-
import type { CustomBlockPage } from "./bridge/pages/page.js"
|
|
7
|
-
import type { NotionParent } from "./bridge/parent.js"
|
|
8
10
|
import { customBlockHost } from "./bridge/sandboxClient.js"
|
|
9
|
-
import type { NotionTheme } from "./bridge/theme.js"
|
|
10
|
-
import type { NotionUser } from "./bridge/users/user.js"
|
|
11
11
|
import { unreachable } from "./utils.js"
|
|
12
12
|
|
|
13
13
|
/**
|
package/src/react/index.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* React entrypoint for `@notionhq/custom-blocks/react`.
|
|
3
3
|
*
|
|
4
4
|
* Exposes only the React surface — components and hooks. Framework-neutral
|
|
5
|
-
* values and types (clients, manifest/data
|
|
5
|
+
* values and types (clients, manifest/data source types, etc.) live on the
|
|
6
6
|
* `@notionhq/custom-blocks` entrypoint and are intentionally NOT re-exported
|
|
7
7
|
* here, so the two public surfaces stay disjoint.
|
|
8
8
|
*/
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { DEFAULT_CONTRAST_MODE } from "@notionhq/custom-blocks-protocol/contrast.js"
|
|
2
|
+
import {
|
|
3
|
+
notionBlockIdSchema,
|
|
4
|
+
notionPageIdSchema,
|
|
5
|
+
} from "@notionhq/custom-blocks-protocol/ids.js"
|
|
1
6
|
import * as v from "valibot"
|
|
2
|
-
import { DEFAULT_CONTRAST_MODE } from "../bridge/contrast.js"
|
|
3
|
-
import { notionBlockIdSchema, notionPageIdSchema } from "../bridge/ids.js"
|
|
4
7
|
import { customBlockHost } from "../bridge/sandboxClient.js"
|
|
5
8
|
|
|
6
9
|
const previewBlockId = v.parse(notionBlockIdSchema, "")
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { CustomBlockInitializationError } from "@notionhq/custom-blocks-protocol/messages/init.js"
|
|
1
2
|
import { useEffect, useState } from "react"
|
|
2
|
-
import type { CustomBlockInitializationError } from "../bridge/messages/init.js"
|
|
3
3
|
import {
|
|
4
4
|
type CustomBlockInitPayload,
|
|
5
5
|
type InitCustomBlockOptions,
|
|
@@ -6,7 +6,7 @@ import { useCustomBlockHost } from "./useHostState.js"
|
|
|
6
6
|
/**
|
|
7
7
|
* Reads from the data source mapped to the given semantic `key`.
|
|
8
8
|
*
|
|
9
|
-
* @param key - The semantic data
|
|
9
|
+
* @param key - The semantic data source key the block is wired to (e.g. `"people"`).
|
|
10
10
|
* @param options - Optional live snapshot options. `limit` defaults to 20 and
|
|
11
11
|
* is capped at 999.
|
|
12
12
|
*
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import type { NotionContrastMode } from "@notionhq/custom-blocks-protocol/contrast.js"
|
|
2
|
+
import type { NotionBlockId } from "@notionhq/custom-blocks-protocol/ids.js"
|
|
3
|
+
import type { CustomBlockManifest } from "@notionhq/custom-blocks-protocol/manifest.js"
|
|
4
|
+
import type { CustomBlockPage } from "@notionhq/custom-blocks-protocol/pages/page.js"
|
|
5
|
+
import type { NotionParent } from "@notionhq/custom-blocks-protocol/parent.js"
|
|
6
|
+
import type { NotionTheme } from "@notionhq/custom-blocks-protocol/theme.js"
|
|
7
|
+
import type { NotionUser } from "@notionhq/custom-blocks-protocol/users/user.js"
|
|
1
8
|
import { useSyncExternalStore } from "react"
|
|
2
|
-
import type { NotionContrastMode } from "../bridge/contrast.js"
|
|
3
|
-
import type { NotionBlockId } from "../bridge/ids.js"
|
|
4
|
-
import type { CustomBlockManifest } from "../bridge/manifest.js"
|
|
5
|
-
import type { CustomBlockPage } from "../bridge/pages/page.js"
|
|
6
|
-
import type { NotionParent } from "../bridge/parent.js"
|
|
7
|
-
import type { NotionTheme } from "../bridge/theme.js"
|
|
8
|
-
import type { NotionUser } from "../bridge/users/user.js"
|
|
9
9
|
import { customBlock } from "../customBlock.js"
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -90,13 +90,13 @@ export function useCurrentUser(): NotionUser {
|
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
92
|
* Returns the authoritative manifest received from the host — the semantic
|
|
93
|
-
* data
|
|
93
|
+
* data source keys plus their declared `name`, `description`, and property declarations.
|
|
94
94
|
*
|
|
95
95
|
* Throws if called before `initCustomBlock` has resolved.
|
|
96
96
|
*
|
|
97
97
|
* This is the configuration the block declared, not host-resolved bindings: use
|
|
98
98
|
* `useDataSource(key)` for rows and resolved schema. Handy for enumerating the declared
|
|
99
|
-
* data
|
|
99
|
+
* data source keys (e.g. picking a default key, or rendering a key switcher).
|
|
100
100
|
*/
|
|
101
101
|
export function useManifest(): CustomBlockManifest {
|
|
102
102
|
return useSyncExternalStore(customBlock.subscribe, customBlock.getManifest)
|
package/src/types.ts
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
import type { NotionCollectionSchema } from "
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from "
|
|
7
|
-
import type {
|
|
8
|
-
import type {
|
|
9
|
-
import type {
|
|
10
|
-
import type {
|
|
11
|
-
import type {
|
|
12
|
-
import type { CustomBlockGetPageErrorInfo } from "./bridge/messages/getPage.js"
|
|
13
|
-
import type { CustomBlockGetUserErrorInfo } from "./bridge/messages/getUser.js"
|
|
14
|
-
import type { CustomBlockListUsersErrorInfo } from "./bridge/messages/listUsers.js"
|
|
15
|
-
import type { CustomBlockQueryDataSourceErrorInfo } from "./bridge/messages/queryDataSourceResult.js"
|
|
16
|
-
import type { CustomBlockUpdatePageErrorInfo } from "./bridge/messages/updatePageResult.js"
|
|
1
|
+
import type { NotionCollectionSchema } from "@notionhq/custom-blocks-protocol/dataSources/dataSource.js"
|
|
2
|
+
import type { NotionDataSourcePage } from "@notionhq/custom-blocks-protocol/dataSources/dataSourcePage.js"
|
|
3
|
+
import type { NotionPropertySchema } from "@notionhq/custom-blocks-protocol/dataSources/propertySchema.js"
|
|
4
|
+
import type { NotionDataSourceId } from "@notionhq/custom-blocks-protocol/ids.js"
|
|
5
|
+
import type { NotionCreatePagePosition } from "@notionhq/custom-blocks-protocol/messages/createPage.js"
|
|
6
|
+
import type { CustomBlockCreatePageErrorInfo } from "@notionhq/custom-blocks-protocol/messages/createPageResult.js"
|
|
7
|
+
import type { CustomBlockGetPageErrorInfo } from "@notionhq/custom-blocks-protocol/messages/getPage.js"
|
|
8
|
+
import type { CustomBlockGetUserErrorInfo } from "@notionhq/custom-blocks-protocol/messages/getUser.js"
|
|
9
|
+
import type { CustomBlockListUsersErrorInfo } from "@notionhq/custom-blocks-protocol/messages/listUsers.js"
|
|
10
|
+
import type { CustomBlockQueryDataSourceErrorInfo } from "@notionhq/custom-blocks-protocol/messages/queryDataSourceResult.js"
|
|
11
|
+
import type { CustomBlockUpdatePageErrorInfo } from "@notionhq/custom-blocks-protocol/messages/updatePageResult.js"
|
|
17
12
|
import type {
|
|
18
13
|
NotionPage,
|
|
19
14
|
NotionPageCover,
|
|
@@ -21,26 +16,34 @@ import type {
|
|
|
21
16
|
NotionPageId,
|
|
22
17
|
NotionPagePropertyInputMap,
|
|
23
18
|
NotionPagePropertyWriteMap,
|
|
24
|
-
} from "
|
|
25
|
-
import type {
|
|
19
|
+
} from "@notionhq/custom-blocks-protocol/pages/page.js"
|
|
20
|
+
import type {
|
|
21
|
+
NotionUser,
|
|
22
|
+
NotionUserList,
|
|
23
|
+
} from "@notionhq/custom-blocks-protocol/users/user.js"
|
|
26
24
|
|
|
27
|
-
export type {
|
|
28
|
-
|
|
25
|
+
export type {
|
|
26
|
+
NotionDataSourcePageUpdateInput,
|
|
27
|
+
NotionDataSourcePageUpdateResult,
|
|
28
|
+
} from "@notionhq/custom-blocks-protocol/dataSources/dataSourcePage.js"
|
|
29
|
+
export type { CustomBlockErrorInfo } from "@notionhq/custom-blocks-protocol/errors.js"
|
|
30
|
+
export type {
|
|
31
|
+
NotionDataSourceId,
|
|
32
|
+
NotionSpaceId,
|
|
33
|
+
} from "@notionhq/custom-blocks-protocol/ids.js"
|
|
34
|
+
export type { NotionPageId } from "@notionhq/custom-blocks-protocol/pages/page.js"
|
|
29
35
|
export type {
|
|
30
36
|
NotionUser,
|
|
31
37
|
NotionUserId,
|
|
32
38
|
NotionUserList,
|
|
33
|
-
} from "
|
|
39
|
+
} from "@notionhq/custom-blocks-protocol/users/user.js"
|
|
34
40
|
export type {
|
|
35
41
|
CustomBlockCreatePageErrorInfo,
|
|
36
|
-
CustomBlockErrorInfo,
|
|
37
42
|
CustomBlockGetPageErrorInfo,
|
|
38
43
|
CustomBlockGetUserErrorInfo,
|
|
39
44
|
CustomBlockListUsersErrorInfo,
|
|
40
45
|
CustomBlockQueryDataSourceErrorInfo,
|
|
41
46
|
CustomBlockUpdatePageErrorInfo,
|
|
42
|
-
NotionDataSourcePageUpdateInput,
|
|
43
|
-
NotionDataSourcePageUpdateResult,
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
/**
|