@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,39 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot"
|
|
2
|
-
import { contrastModeChangedMessageSchema } from "./contrastModeChanged.js"
|
|
3
|
-
import { createPageResultMessageSchema } from "./createPageResult.js"
|
|
4
|
-
import { currentUserChangedMessageSchema } from "./currentUserChanged.js"
|
|
5
|
-
import { dataSourcesChangedMessageSchema } from "./dataSourcesChanged.js"
|
|
6
|
-
import { getPageResultMessageSchema } from "./getPage.js"
|
|
7
|
-
import { getUserResultMessageSchema } from "./getUser.js"
|
|
8
|
-
import { initMessageSchema } from "./init.js"
|
|
9
|
-
import { invalidSandboxMessageSchema } from "./invalidSandboxMessage.js"
|
|
10
|
-
import { listUsersResultMessageSchema } from "./listUsers.js"
|
|
11
|
-
import { pageChangedMessageSchema } from "./pageChanged.js"
|
|
12
|
-
import { parentChangedMessageSchema } from "./parentChanged.js"
|
|
13
|
-
import { queryDataSourceResultMessageSchema } from "./queryDataSourceResult.js"
|
|
14
|
-
import { themeChangedMessageSchema } from "./themeChanged.js"
|
|
15
|
-
import { updatePageResultMessageSchema } from "./updatePageResult.js"
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Discriminated union of every message the host is allowed to send the sandbox.
|
|
19
|
-
*/
|
|
20
|
-
export const hostToSandboxMessageSchema = v.variant("type", [
|
|
21
|
-
initMessageSchema,
|
|
22
|
-
themeChangedMessageSchema,
|
|
23
|
-
contrastModeChangedMessageSchema,
|
|
24
|
-
parentChangedMessageSchema,
|
|
25
|
-
pageChangedMessageSchema,
|
|
26
|
-
currentUserChangedMessageSchema,
|
|
27
|
-
dataSourcesChangedMessageSchema,
|
|
28
|
-
queryDataSourceResultMessageSchema,
|
|
29
|
-
createPageResultMessageSchema,
|
|
30
|
-
getPageResultMessageSchema,
|
|
31
|
-
getUserResultMessageSchema,
|
|
32
|
-
listUsersResultMessageSchema,
|
|
33
|
-
updatePageResultMessageSchema,
|
|
34
|
-
invalidSandboxMessageSchema,
|
|
35
|
-
])
|
|
36
|
-
|
|
37
|
-
export type HostToSandboxMessage = v.InferOutput<
|
|
38
|
-
typeof hostToSandboxMessageSchema
|
|
39
|
-
>
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot"
|
|
2
|
-
import { DEFAULT_CONTRAST_MODE, notionContrastModeSchema } from "../contrast.js"
|
|
3
|
-
import { notionDataSourceBindingsSchema } from "../dataSources/dataSource.js"
|
|
4
|
-
import type { CustomBlockErrorCode, CustomBlockErrorInfo } from "../errors.js"
|
|
5
|
-
import { notionBlockIdSchema } from "../ids.js"
|
|
6
|
-
import { manifestSchema } from "../manifest.js"
|
|
7
|
-
import { customBlockPageSchema } from "../pages/page.js"
|
|
8
|
-
import { notionParentSchema } from "../parent.js"
|
|
9
|
-
import { notionThemeSchema } from "../theme.js"
|
|
10
|
-
import { notionUserSchema } from "../users/user.js"
|
|
11
|
-
import type { CustomBlockInitResultErrorCode } from "./initResult.js"
|
|
12
|
-
|
|
13
|
-
// The schema accepts any string code. The type lists known codes for
|
|
14
|
-
// autocomplete, with an open string fallback for newer senders.
|
|
15
|
-
export const customBlockInitErrorCodeSchema = v.string()
|
|
16
|
-
|
|
17
|
-
export type CustomBlockInitErrorCode = CustomBlockErrorCode<
|
|
18
|
-
| "manifest_unavailable"
|
|
19
|
-
| "manifest_invalid"
|
|
20
|
-
| "invalid_protocol_version"
|
|
21
|
-
| "unsupported_protocol_version"
|
|
22
|
-
| "context_unavailable"
|
|
23
|
-
| "current_user_unavailable"
|
|
24
|
-
| "missing_data_source_binding"
|
|
25
|
-
| "data_source_unavailable"
|
|
26
|
-
| "missing_property_binding"
|
|
27
|
-
| "invalid_property_binding"
|
|
28
|
-
>
|
|
29
|
-
|
|
30
|
-
export type CustomBlockInitErrorInfo =
|
|
31
|
-
CustomBlockErrorInfo<CustomBlockInitErrorCode>
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Every initialization failure visible to block code. This combines errors
|
|
35
|
-
* received in `init`, errors the sandbox reports in `initResult`, and failures
|
|
36
|
-
* detected locally while running `initCustomBlock()`.
|
|
37
|
-
*/
|
|
38
|
-
export type CustomBlockInitializationErrorCode =
|
|
39
|
-
| CustomBlockInitErrorCode
|
|
40
|
-
| CustomBlockInitResultErrorCode
|
|
41
|
-
| CustomBlockErrorCode<"not_in_iframe" | "init_timeout">
|
|
42
|
-
|
|
43
|
-
export type CustomBlockInitializationErrorInfo =
|
|
44
|
-
CustomBlockErrorInfo<CustomBlockInitializationErrorCode>
|
|
45
|
-
|
|
46
|
-
export const customBlockInitErrorInfoSchema = v.object({
|
|
47
|
-
code: customBlockInitErrorCodeSchema,
|
|
48
|
-
message: v.string(),
|
|
49
|
-
isRetryable: v.boolean(),
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
export class CustomBlockInitializationError
|
|
53
|
-
extends Error
|
|
54
|
-
implements CustomBlockErrorInfo
|
|
55
|
-
{
|
|
56
|
-
constructor(error: CustomBlockInitializationErrorInfo) {
|
|
57
|
-
super(error.message)
|
|
58
|
-
this.name = "CustomBlockInitializationError"
|
|
59
|
-
this.code = error.code
|
|
60
|
-
this.isRetryable = error.isRetryable
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
code: CustomBlockInitializationErrorCode
|
|
64
|
-
isRetryable: boolean
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Initialization message sent by the host to the sandbox exactly once, in response to the
|
|
69
|
-
* sandbox's `connect` message. The sandbox echoes `initializationId` in `initResult`. After
|
|
70
|
-
* successful initialization, live updates flow through narrower messages
|
|
71
|
-
* (`themeChanged`, `contrastModeChanged`, `parentChanged`, `pageChanged`,
|
|
72
|
-
* `dataSourcesChanged`).
|
|
73
|
-
*/
|
|
74
|
-
export const initMessageSchema = v.variant("status", [
|
|
75
|
-
v.object({
|
|
76
|
-
type: v.literal("init"),
|
|
77
|
-
initializationId: v.string(),
|
|
78
|
-
status: v.literal("success"),
|
|
79
|
-
theme: notionThemeSchema,
|
|
80
|
-
// TODO(custom-blocks): Make this required when next bumping the protocol version.
|
|
81
|
-
contrastMode: v.optional(notionContrastModeSchema, DEFAULT_CONTRAST_MODE),
|
|
82
|
-
blockId: notionBlockIdSchema,
|
|
83
|
-
parent: notionParentSchema,
|
|
84
|
-
page: customBlockPageSchema,
|
|
85
|
-
manifest: manifestSchema,
|
|
86
|
-
dataSources: v.object({
|
|
87
|
-
bindings: notionDataSourceBindingsSchema,
|
|
88
|
-
}),
|
|
89
|
-
currentUser: notionUserSchema,
|
|
90
|
-
}),
|
|
91
|
-
v.object({
|
|
92
|
-
type: v.literal("init"),
|
|
93
|
-
initializationId: v.string(),
|
|
94
|
-
status: v.literal("error"),
|
|
95
|
-
error: customBlockInitErrorInfoSchema,
|
|
96
|
-
}),
|
|
97
|
-
])
|
|
98
|
-
|
|
99
|
-
export type InitMessage = v.InferOutput<typeof initMessageSchema>
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot"
|
|
2
|
-
import type { CustomBlockErrorCode, CustomBlockErrorInfo } from "../errors.js"
|
|
3
|
-
|
|
4
|
-
// The schema accepts any string code. The type lists known codes for
|
|
5
|
-
// autocomplete, with an open string fallback for newer senders.
|
|
6
|
-
export const customBlockInitResultErrorCodeSchema = v.string()
|
|
7
|
-
|
|
8
|
-
export type CustomBlockInitResultErrorCode =
|
|
9
|
-
CustomBlockErrorCode<"invalid_init_bindings">
|
|
10
|
-
|
|
11
|
-
export type CustomBlockInitResultErrorInfo =
|
|
12
|
-
CustomBlockErrorInfo<CustomBlockInitResultErrorCode>
|
|
13
|
-
|
|
14
|
-
export const customBlockInitResultErrorInfoSchema = v.object({
|
|
15
|
-
code: customBlockInitResultErrorCodeSchema,
|
|
16
|
-
message: v.string(),
|
|
17
|
-
isRetryable: v.boolean(),
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Acknowledges whether the sandbox successfully applied the host's `init` response.
|
|
22
|
-
*/
|
|
23
|
-
export const initResultMessageSchema = v.variant("status", [
|
|
24
|
-
v.object({
|
|
25
|
-
type: v.literal("initResult"),
|
|
26
|
-
initializationId: v.string(),
|
|
27
|
-
status: v.literal("success"),
|
|
28
|
-
}),
|
|
29
|
-
v.object({
|
|
30
|
-
type: v.literal("initResult"),
|
|
31
|
-
initializationId: v.string(),
|
|
32
|
-
status: v.literal("error"),
|
|
33
|
-
error: customBlockInitResultErrorInfoSchema,
|
|
34
|
-
}),
|
|
35
|
-
])
|
|
36
|
-
|
|
37
|
-
export type InitResultMessage = v.InferOutput<typeof initResultMessageSchema>
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot"
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Sent by the sandbox back to the host when an inbound host-to-sandbox message could not be parsed
|
|
5
|
-
* (unknown `type`, schema mismatch, etc.). The host should never reply to an `invalidHostMessage`
|
|
6
|
-
* with another bridge error message.
|
|
7
|
-
*/
|
|
8
|
-
export const invalidHostMessageSchema = v.object({
|
|
9
|
-
type: v.literal("invalidHostMessage"),
|
|
10
|
-
/**
|
|
11
|
-
* A human-readable string intended for sandbox-side logging. It has no structured contract.
|
|
12
|
-
*/
|
|
13
|
-
reason: v.string(),
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
export type InvalidHostMessage = v.InferOutput<typeof invalidHostMessageSchema>
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot"
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Sent by the host back to the sandbox when an inbound sandbox-to-host message could not be parsed
|
|
5
|
-
* (unknown `type`, schema mismatch, etc.). The sandbox should never reply to an
|
|
6
|
-
* `invalidSandboxMessage` with another bridge error message.
|
|
7
|
-
*/
|
|
8
|
-
export const invalidSandboxMessageSchema = v.object({
|
|
9
|
-
type: v.literal("invalidSandboxMessage"),
|
|
10
|
-
/**
|
|
11
|
-
* A human-readable string intended for sandbox-side logging. It has no structured contract.
|
|
12
|
-
*/
|
|
13
|
-
reason: v.string(),
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
export type InvalidSandboxMessage = v.InferOutput<
|
|
17
|
-
typeof invalidSandboxMessageSchema
|
|
18
|
-
>
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot"
|
|
2
|
-
import type { CustomBlockErrorCode, CustomBlockErrorInfo } from "../errors.js"
|
|
3
|
-
import { notionUserListSchema } from "../users/user.js"
|
|
4
|
-
|
|
5
|
-
// The schema accepts any string code. The type lists known codes for
|
|
6
|
-
// autocomplete, with an open string fallback for newer senders.
|
|
7
|
-
export const customBlockListUsersErrorCodeSchema = v.string()
|
|
8
|
-
|
|
9
|
-
export type CustomBlockListUsersErrorCode =
|
|
10
|
-
CustomBlockErrorCode<"list_users_failed">
|
|
11
|
-
|
|
12
|
-
export type CustomBlockListUsersErrorInfo =
|
|
13
|
-
CustomBlockErrorInfo<CustomBlockListUsersErrorCode>
|
|
14
|
-
|
|
15
|
-
export const customBlockListUsersErrorInfoSchema = v.object({
|
|
16
|
-
code: customBlockListUsersErrorCodeSchema,
|
|
17
|
-
message: v.string(),
|
|
18
|
-
isRetryable: v.boolean(),
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Sandbox -> host: list users visible in the custom block's workspace.
|
|
23
|
-
*/
|
|
24
|
-
export const listUsersMessageSchema = v.object({
|
|
25
|
-
type: v.literal("listUsers"),
|
|
26
|
-
requestId: v.string(),
|
|
27
|
-
startCursor: v.optional(v.string()),
|
|
28
|
-
pageSize: v.optional(v.number()),
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
export type ListUsersMessage = v.InferOutput<typeof listUsersMessageSchema>
|
|
32
|
-
|
|
33
|
-
export const listUsersResultMessageSchema = v.variant("status", [
|
|
34
|
-
v.object({
|
|
35
|
-
type: v.literal("listUsersResult"),
|
|
36
|
-
requestId: v.string(),
|
|
37
|
-
status: v.literal("success"),
|
|
38
|
-
list: notionUserListSchema,
|
|
39
|
-
}),
|
|
40
|
-
v.object({
|
|
41
|
-
type: v.literal("listUsersResult"),
|
|
42
|
-
requestId: v.string(),
|
|
43
|
-
status: v.literal("error"),
|
|
44
|
-
error: customBlockListUsersErrorInfoSchema,
|
|
45
|
-
}),
|
|
46
|
-
])
|
|
47
|
-
|
|
48
|
-
export type ListUsersResultMessage = v.InferOutput<
|
|
49
|
-
typeof listUsersResultMessageSchema
|
|
50
|
-
>
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot"
|
|
2
|
-
import { customBlockPageSchema } from "../pages/page.js"
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Message sent by the host whenever the custom block's nearest page ancestor changes.
|
|
6
|
-
*/
|
|
7
|
-
export const pageChangedMessageSchema = v.object({
|
|
8
|
-
type: v.literal("pageChanged"),
|
|
9
|
-
page: customBlockPageSchema,
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
export type PageChangedMessage = v.InferOutput<typeof pageChangedMessageSchema>
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot"
|
|
2
|
-
import { notionParentSchema } from "../parent.js"
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Message sent by the host whenever the custom block's parent changes.
|
|
6
|
-
*/
|
|
7
|
-
export const parentChangedMessageSchema = v.object({
|
|
8
|
-
type: v.literal("parentChanged"),
|
|
9
|
-
parent: notionParentSchema,
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
export type ParentChangedMessage = v.InferOutput<
|
|
13
|
-
typeof parentChangedMessageSchema
|
|
14
|
-
>
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot"
|
|
2
|
-
import { notionDataSourceIdSchema } from "../ids.js"
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Message sent by the sandbox to ask the host for the current rows in a resolved
|
|
6
|
-
* Notion data source.
|
|
7
|
-
*/
|
|
8
|
-
export const queryDataSourceMessageSchema = v.object({
|
|
9
|
-
type: v.literal("queryDataSource"),
|
|
10
|
-
/** Stable for the lifetime of this query subscription. */
|
|
11
|
-
subscriptionId: v.string(),
|
|
12
|
-
/** The raw Notion data source ID to read from. */
|
|
13
|
-
dataSourceId: notionDataSourceIdSchema,
|
|
14
|
-
/** The number of items to return in each subscription update. */
|
|
15
|
-
limit: v.number(),
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
export type QueryDataSourceMessage = v.InferOutput<
|
|
19
|
-
typeof queryDataSourceMessageSchema
|
|
20
|
-
>
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot"
|
|
2
|
-
import { notionDataSourcePageBridgeSchema } from "../dataSources/dataSourcePage.js"
|
|
3
|
-
import type { CustomBlockErrorCode, CustomBlockErrorInfo } from "../errors.js"
|
|
4
|
-
|
|
5
|
-
// The schema accepts any string code. The type lists known codes for
|
|
6
|
-
// autocomplete, with an open string fallback for newer senders.
|
|
7
|
-
export const customBlockQueryDataSourceErrorCodeSchema = v.string()
|
|
8
|
-
|
|
9
|
-
export type CustomBlockQueryDataSourceErrorCode = CustomBlockErrorCode<
|
|
10
|
-
| "query_data_source_failed"
|
|
11
|
-
| "unknown_data_source_key"
|
|
12
|
-
| "unmapped_data_source"
|
|
13
|
-
>
|
|
14
|
-
|
|
15
|
-
export type CustomBlockQueryDataSourceErrorInfo =
|
|
16
|
-
CustomBlockErrorInfo<CustomBlockQueryDataSourceErrorCode>
|
|
17
|
-
|
|
18
|
-
export const customBlockQueryDataSourceErrorInfoSchema = v.object({
|
|
19
|
-
code: customBlockQueryDataSourceErrorCodeSchema,
|
|
20
|
-
message: v.string(),
|
|
21
|
-
isRetryable: v.boolean(),
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Message sent by the host to update a `queryDataSource` subscription.
|
|
26
|
-
*/
|
|
27
|
-
export const queryDataSourceResultMessageSchema = v.variant("status", [
|
|
28
|
-
v.object({
|
|
29
|
-
type: v.literal("queryDataSourceResult"),
|
|
30
|
-
subscriptionId: v.string(),
|
|
31
|
-
status: v.literal("success"),
|
|
32
|
-
items: v.array(notionDataSourcePageBridgeSchema),
|
|
33
|
-
hasMore: v.boolean(),
|
|
34
|
-
}),
|
|
35
|
-
v.object({
|
|
36
|
-
type: v.literal("queryDataSourceResult"),
|
|
37
|
-
subscriptionId: v.string(),
|
|
38
|
-
status: v.literal("error"),
|
|
39
|
-
error: customBlockQueryDataSourceErrorInfoSchema,
|
|
40
|
-
}),
|
|
41
|
-
])
|
|
42
|
-
|
|
43
|
-
export type QueryDataSourceResultMessage = v.InferOutput<
|
|
44
|
-
typeof queryDataSourceResultMessageSchema
|
|
45
|
-
>
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot"
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Message sent by the sandbox whenever its measured content height changes, so the host can resize
|
|
5
|
-
* the surrounding iframe to match. The host is free to clamp the value or ignore it. The sandbox
|
|
6
|
-
* always reports the most recent measurement.
|
|
7
|
-
*/
|
|
8
|
-
export const resizeMessageSchema = v.object({
|
|
9
|
-
type: v.literal("resize"),
|
|
10
|
-
height: v.pipe(v.number(), v.finite(), v.minValue(0)),
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
export type ResizeMessage = v.InferOutput<typeof resizeMessageSchema>
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot"
|
|
2
|
-
import { connectMessageSchema } from "./connect.js"
|
|
3
|
-
import { createPageMessageSchema } from "./createPage.js"
|
|
4
|
-
import { getPageMessageSchema } from "./getPage.js"
|
|
5
|
-
import { getUserMessageSchema } from "./getUser.js"
|
|
6
|
-
import { initResultMessageSchema } from "./initResult.js"
|
|
7
|
-
import { invalidHostMessageSchema } from "./invalidHostMessage.js"
|
|
8
|
-
import { listUsersMessageSchema } from "./listUsers.js"
|
|
9
|
-
import { queryDataSourceMessageSchema } from "./queryDataSource.js"
|
|
10
|
-
import { resizeMessageSchema } from "./resize.js"
|
|
11
|
-
import { updatePageMessageSchema } from "./updatePage.js"
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Union of every message the sandbox is allowed to send the host. Useful for hosts to validate
|
|
15
|
-
* inbound traffic from sandboxes without re-implementing validation logic.
|
|
16
|
-
*/
|
|
17
|
-
export const sandboxToHostMessageSchema = v.union([
|
|
18
|
-
connectMessageSchema,
|
|
19
|
-
initResultMessageSchema,
|
|
20
|
-
queryDataSourceMessageSchema,
|
|
21
|
-
createPageMessageSchema,
|
|
22
|
-
getPageMessageSchema,
|
|
23
|
-
getUserMessageSchema,
|
|
24
|
-
listUsersMessageSchema,
|
|
25
|
-
updatePageMessageSchema,
|
|
26
|
-
resizeMessageSchema,
|
|
27
|
-
invalidHostMessageSchema,
|
|
28
|
-
])
|
|
29
|
-
|
|
30
|
-
export type SandboxToHostMessage = v.InferOutput<
|
|
31
|
-
typeof sandboxToHostMessageSchema
|
|
32
|
-
>
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot"
|
|
2
|
-
import { notionThemeSchema } from "../theme.js"
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Message sent by the host every time the theme changes after the initial
|
|
6
|
-
* `init` handshake.
|
|
7
|
-
*/
|
|
8
|
-
export const themeChangedMessageSchema = v.object({
|
|
9
|
-
type: v.literal("themeChanged"),
|
|
10
|
-
theme: notionThemeSchema,
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
export type ThemeChangedMessage = v.InferOutput<
|
|
14
|
-
typeof themeChangedMessageSchema
|
|
15
|
-
>
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot"
|
|
2
|
-
import { notionPageIdSchema } from "../ids.js"
|
|
3
|
-
import {
|
|
4
|
-
notionPageCoverSchema,
|
|
5
|
-
notionPageIconSchema,
|
|
6
|
-
notionPagePropertyWriteMapSchema,
|
|
7
|
-
} from "../pages/page.js"
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Sandbox -> host: patch an existing page.
|
|
11
|
-
*/
|
|
12
|
-
export const updatePageMessageSchema = v.object({
|
|
13
|
-
type: v.literal("updatePage"),
|
|
14
|
-
requestId: v.string(),
|
|
15
|
-
pageId: notionPageIdSchema,
|
|
16
|
-
properties: v.optional(notionPagePropertyWriteMapSchema),
|
|
17
|
-
icon: v.optional(notionPageIconSchema),
|
|
18
|
-
cover: v.optional(notionPageCoverSchema),
|
|
19
|
-
archived: v.optional(v.boolean()),
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
export type UpdatePageMessage = v.InferOutput<typeof updatePageMessageSchema>
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import * as v from "valibot"
|
|
2
|
-
import type { CustomBlockErrorCode, CustomBlockErrorInfo } from "../errors.js"
|
|
3
|
-
import { notionPageSchema } from "../pages/page.js"
|
|
4
|
-
|
|
5
|
-
// The schema accepts any string code. The type lists known codes for
|
|
6
|
-
// autocomplete, with an open string fallback for newer senders.
|
|
7
|
-
export const customBlockUpdatePageErrorCodeSchema = v.string()
|
|
8
|
-
|
|
9
|
-
export type CustomBlockUpdatePageErrorCode = CustomBlockErrorCode<
|
|
10
|
-
| "update_page_failed"
|
|
11
|
-
| "invalid_page_update"
|
|
12
|
-
| "page_access_failed"
|
|
13
|
-
| "collection_access_failed"
|
|
14
|
-
| "unmapped_property"
|
|
15
|
-
| "property_id_mismatch"
|
|
16
|
-
| "duplicate_property"
|
|
17
|
-
| "invalid_property_value"
|
|
18
|
-
>
|
|
19
|
-
|
|
20
|
-
export type CustomBlockUpdatePageErrorInfo =
|
|
21
|
-
CustomBlockErrorInfo<CustomBlockUpdatePageErrorCode>
|
|
22
|
-
|
|
23
|
-
export const customBlockUpdatePageErrorInfoSchema = v.object({
|
|
24
|
-
code: customBlockUpdatePageErrorCodeSchema,
|
|
25
|
-
message: v.string(),
|
|
26
|
-
isRetryable: v.boolean(),
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Host -> sandbox: result for a page update request.
|
|
31
|
-
*/
|
|
32
|
-
export const updatePageResultMessageSchema = v.variant("status", [
|
|
33
|
-
v.object({
|
|
34
|
-
type: v.literal("updatePageResult"),
|
|
35
|
-
requestId: v.string(),
|
|
36
|
-
status: v.literal("success"),
|
|
37
|
-
page: notionPageSchema,
|
|
38
|
-
}),
|
|
39
|
-
v.object({
|
|
40
|
-
type: v.literal("updatePageResult"),
|
|
41
|
-
requestId: v.string(),
|
|
42
|
-
status: v.literal("error"),
|
|
43
|
-
error: customBlockUpdatePageErrorInfoSchema,
|
|
44
|
-
}),
|
|
45
|
-
])
|
|
46
|
-
|
|
47
|
-
export type UpdatePageResultMessage = v.InferOutput<
|
|
48
|
-
typeof updatePageResultMessageSchema
|
|
49
|
-
>
|