@notionhq/custom-blocks-host 0.1.10 → 0.1.12
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 +19 -1
- package/dist/createCustomBlockHost.d.ts +6 -1
- package/dist/createCustomBlockHost.d.ts.map +1 -1
- package/dist/createCustomBlockHost.js +5 -2
- package/dist/index.d.ts +9 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/lifecycle/initErrors.d.ts.map +1 -1
- package/dist/lifecycle/initErrors.js +6 -6
- package/dist/lifecycle/types.d.ts +4 -0
- package/dist/lifecycle/types.d.ts.map +1 -1
- package/dist/messages/types.d.ts +15 -7
- package/dist/messages/types.d.ts.map +1 -1
- package/dist/protocol/messages/connect.js +4 -3
- package/dist/protocol/messages/init.d.ts +2 -2
- package/dist/protocol/messages/initResult.js +2 -1
- package/dist/protocol/protocolVersion.d.ts +4 -4
- package/dist/protocol/protocolVersion.js +4 -4
- package/dist/protocolVersion.d.ts +8 -0
- package/dist/protocolVersion.d.ts.map +1 -0
- package/dist/protocolVersion.js +7 -0
- package/package.json +1 -1
- package/src/createCustomBlockHost.ts +12 -4
- package/src/index.ts +19 -0
- package/src/lifecycle/initErrors.ts +6 -7
- package/src/lifecycle/types.ts +4 -1
- package/src/messages/types.ts +36 -4
- package/src/protocolVersion.ts +7 -0
package/README.md
CHANGED
|
@@ -48,7 +48,6 @@ import { createCustomBlockHost } from "@notionhq/custom-blocks-host";
|
|
|
48
48
|
const host = createCustomBlockHost({
|
|
49
49
|
iframe,
|
|
50
50
|
sandboxOrigin: "https://example.com",
|
|
51
|
-
minBridgeProtocolVersion: 3,
|
|
52
51
|
initialState: {
|
|
53
52
|
theme,
|
|
54
53
|
contrastMode,
|
|
@@ -90,6 +89,10 @@ const host = createCustomBlockHost({
|
|
|
90
89
|
});
|
|
91
90
|
```
|
|
92
91
|
|
|
92
|
+
`minBridgeProtocolVersion` is optional and defaults to the oldest protocol version the host runtime supports.
|
|
93
|
+
Set a higher value to retire older SDKs. Lower values cannot enable versions the runtime no longer supports.
|
|
94
|
+
The host does not enforce a maximum protocol version.
|
|
95
|
+
|
|
93
96
|
Each host instance initializes once:
|
|
94
97
|
|
|
95
98
|
- `onManifest` provides the selected manifest as soon as it is available after
|
|
@@ -114,6 +117,21 @@ request handler may return its result synchronously or as a promise. Results
|
|
|
114
117
|
use a `status` discriminator: successful results carry their response payload,
|
|
115
118
|
while errors carry `{ code, message, isRetryable }`.
|
|
116
119
|
|
|
120
|
+
### Request types
|
|
121
|
+
|
|
122
|
+
TypeScript infers request types for handlers passed to `createCustomBlockHost()`.
|
|
123
|
+
For separately defined handlers and helpers, import the corresponding request
|
|
124
|
+
and page-property types directly from `@notionhq/custom-blocks-host`.
|
|
125
|
+
|
|
126
|
+
Request types such as `GetPageMessage` describe validated messages that handlers
|
|
127
|
+
receive. The corresponding `*MessageInput` types accept plain string IDs for
|
|
128
|
+
adapters and test fixtures that construct requests. These types do not validate
|
|
129
|
+
values at runtime. The host runtime validates incoming messages before it calls
|
|
130
|
+
handlers. Your implementation remains responsible for permissions and record
|
|
131
|
+
access.
|
|
132
|
+
|
|
133
|
+
### Query requests
|
|
134
|
+
|
|
117
135
|
The `queryDataSource` handler receives raw data source and property IDs. Its
|
|
118
136
|
optional `filter` and `sorts` fields have already been resolved by the SDK.
|
|
119
137
|
The host validates that sorts contain at most 10 unique property IDs, checks
|
|
@@ -11,7 +11,12 @@ import type { CustomBlockHostHandlers, CustomBlockHostInitializationFailure, Cus
|
|
|
11
11
|
export type CustomBlockHostOptions = {
|
|
12
12
|
iframe: HTMLIFrameElement;
|
|
13
13
|
sandboxOrigin: string;
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Minimum sandbox protocol version to accept. Defaults to the host runtime
|
|
16
|
+
* minimum. Higher values retire older SDKs; lower values cannot enable
|
|
17
|
+
* protocol versions the runtime no longer supports.
|
|
18
|
+
*/
|
|
19
|
+
minBridgeProtocolVersion?: number;
|
|
15
20
|
noConnectTimeoutMs?: number;
|
|
16
21
|
noInitResultTimeoutMs?: number;
|
|
17
22
|
initialState: CustomBlockHostInitialState;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createCustomBlockHost.d.ts","sourceRoot":"","sources":["../src/createCustomBlockHost.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,kBAAkB,EACvB,MAAM,8CAA8C,CAAA;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAA;AACjF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAA;AAavF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4DAA4D,CAAA;AAatG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAA;AACrF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAA;
|
|
1
|
+
{"version":3,"file":"createCustomBlockHost.d.ts","sourceRoot":"","sources":["../src/createCustomBlockHost.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,kBAAkB,EACvB,MAAM,8CAA8C,CAAA;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAA;AACjF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAA;AAavF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4DAA4D,CAAA;AAatG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAA;AACrF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAA;AAC9E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAA;AAC5E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gDAAgD,CAAA;AAGhF,OAAO,KAAK,EACX,iCAAiC,EACjC,2BAA2B,EAC3B,MAAM,sBAAsB,CAAA;AAE7B,OAAO,KAAK,EACX,uBAAuB,EACvB,oCAAoC,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E,iCAAiC,KAAK,IAAI,CAAA;IACxE,cAAc,EAAE,CAAC,WAAW,EAAE,UAAU,KAAK,IAAI,CAAA;IACjD,YAAY,EAAE,CAAC,IAAI,EAAE;QAAE,YAAY,EAAE,kBAAkB,CAAA;KAAE,KAAK,IAAI,CAAA;CAClE,CAAA;AAED,wBAAgB,qBAAqB,CACpC,OAAO,EAAE,sBAAsB,GAC7B,qBAAqB,CAyYvB"}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { DEFAULT_CONTRAST_MODE, } from "./protocol/contrast.js";
|
|
2
|
-
import { CUSTOM_BLOCK_BRIDGE_PROTOCOL_VERSION } from "./protocol/protocolVersion.js";
|
|
3
2
|
import { initErrorForFailureReason } from "./lifecycle/initErrors.js";
|
|
4
3
|
import { createInitializationController } from "./lifecycle/initializationController.js";
|
|
5
4
|
import { createSandboxMessageRouter } from "./messages/sandboxMessageRouter.js";
|
|
5
|
+
import { MIN_HOST_SUPPORTED_BRIDGE_PROTOCOL_VERSION } from "./protocolVersion.js";
|
|
6
6
|
import { QuerySubscriptions, } from "./queries/querySubscriptions.js";
|
|
7
7
|
import { validateQueryDataSourceFilter } from "./queries/validateQueryDataSourceFilter.js";
|
|
8
8
|
import { validateQueryDataSourceSorts } from "./queries/validateQueryDataSourceSorts.js";
|
|
9
9
|
export function createCustomBlockHost(options) {
|
|
10
10
|
const { iframe, initialState, handlers, onManifest, onInitialized, onInitializationFailure, onRestartRequired, onLog, sandboxOrigin, minBridgeProtocolVersion: configuredMinBridgeProtocolVersion, noConnectTimeoutMs, noInitResultTimeoutMs, } = options;
|
|
11
|
-
|
|
11
|
+
// Callers can retire older SDKs, but cannot restore support for protocols
|
|
12
|
+
// the runtime no longer implements. Omission uses the runtime minimum.
|
|
13
|
+
const minBridgeProtocolVersion = Math.max(configuredMinBridgeProtocolVersion ??
|
|
14
|
+
MIN_HOST_SUPPORTED_BRIDGE_PROTOCOL_VERSION, MIN_HOST_SUPPORTED_BRIDGE_PROTOCOL_VERSION);
|
|
12
15
|
let theme = initialState.theme;
|
|
13
16
|
let contrastMode = initialState.contrastMode ?? DEFAULT_CONTRAST_MODE;
|
|
14
17
|
let parent = initialState.parent;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
|
+
export type { CreatePageMessage } from "./protocol/messages/createPage.js";
|
|
2
|
+
export type { GetPageMessage } from "./protocol/messages/getPage.js";
|
|
3
|
+
export type { GetUserMessage } from "./protocol/messages/getUser.js";
|
|
4
|
+
export type { ListUsersMessage } from "./protocol/messages/listUsers.js";
|
|
5
|
+
export type { QueryDataSourceMessage } from "./protocol/messages/queryDataSource.js";
|
|
6
|
+
export type { ResizeMessage } from "./protocol/messages/resize.js";
|
|
7
|
+
export type { UpdatePageMessage } from "./protocol/messages/updatePage.js";
|
|
8
|
+
export type { NotionPagePropertyValue, NotionPagePropertyWriteMap, NotionRichTextItem, } from "./protocol/pages/page.js";
|
|
1
9
|
export { type AutoBindableProperty, getAutoBoundPropertyIdsByKey, } from "./autoBindProperties.js";
|
|
2
10
|
export { type CustomBlockHostHandle, type CustomBlockHostOptions, createCustomBlockHost, } from "./createCustomBlockHost.js";
|
|
3
11
|
export type { ConnectSuccessMessage, CustomBlockHostDataSourcesPayload, CustomBlockHostInitialDataSources, CustomBlockHostInitialState, } from "./lifecycle/types.js";
|
|
4
|
-
export type { CustomBlockHostCreatePageResult, CustomBlockHostGetPageResult, CustomBlockHostGetUserResult, CustomBlockHostHandlers, CustomBlockHostInitializationFailure, CustomBlockHostListUsersResult, CustomBlockHostLogDirection, CustomBlockHostUpdatePageResult, } from "./messages/types.js";
|
|
12
|
+
export type { CreatePageMessageInput, CustomBlockHostCreatePageResult, CustomBlockHostGetPageResult, CustomBlockHostGetUserResult, CustomBlockHostHandlers, CustomBlockHostInitializationFailure, CustomBlockHostListUsersResult, CustomBlockHostLogDirection, CustomBlockHostUpdatePageResult, GetPageMessageInput, GetUserMessageInput, ListUsersMessageInput, QueryDataSourceMessageInput, ResizeMessageInput, UpdatePageMessageInput, } from "./messages/types.js";
|
|
5
13
|
export type { CustomBlockHostQueryDataSourceResult } from "./queries/types.js";
|
|
6
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,oBAAoB,EACzB,4BAA4B,GAC5B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACN,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,qBAAqB,GACrB,MAAM,4BAA4B,CAAA;AACnC,YAAY,EACX,qBAAqB,EACrB,iCAAiC,EACjC,iCAAiC,EACjC,2BAA2B,GAC3B,MAAM,sBAAsB,CAAA;AAC7B,YAAY,EACX,+BAA+B,EAC/B,4BAA4B,EAC5B,4BAA4B,EAC5B,uBAAuB,EACvB,oCAAoC,EACpC,8BAA8B,EAC9B,2BAA2B,EAC3B,+BAA+B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAA;AAChG,YAAY,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAA;AAC1F,YAAY,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAA;AAC1F,YAAY,EAAE,gBAAgB,EAAE,MAAM,wDAAwD,CAAA;AAC9F,YAAY,EAAE,sBAAsB,EAAE,MAAM,8DAA8D,CAAA;AAC1G,YAAY,EAAE,aAAa,EAAE,MAAM,qDAAqD,CAAA;AACxF,YAAY,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAA;AAChG,YAAY,EACX,uBAAuB,EACvB,0BAA0B,EAC1B,kBAAkB,GAClB,MAAM,gDAAgD,CAAA;AACvD,OAAO,EACN,KAAK,oBAAoB,EACzB,4BAA4B,GAC5B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACN,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,qBAAqB,GACrB,MAAM,4BAA4B,CAAA;AACnC,YAAY,EACX,qBAAqB,EACrB,iCAAiC,EACjC,iCAAiC,EACjC,2BAA2B,GAC3B,MAAM,sBAAsB,CAAA;AAC7B,YAAY,EACX,sBAAsB,EACtB,+BAA+B,EAC/B,4BAA4B,EAC5B,4BAA4B,EAC5B,uBAAuB,EACvB,oCAAoC,EACpC,8BAA8B,EAC9B,2BAA2B,EAC3B,+BAA+B,EAC/B,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,2BAA2B,EAC3B,kBAAkB,EAClB,sBAAsB,GACtB,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EAAE,oCAAoC,EAAE,MAAM,oBAAoB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initErrors.d.ts","sourceRoot":"","sources":["../../src/lifecycle/initErrors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,wBAAwB,EACxB,wBAAwB,EACxB,MAAM,mDAAmD,CAAA;AAK1D;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACxC,MAAM,EAAE,wBAAwB,EAChC,IAAI,GAAE;IACL,wBAAwB,CAAC,EAAE,MAAM,CAAA;IACjC,4BAA4B,CAAC,EAAE,MAAM,CAAA;CAChC,GACJ,wBAAwB,
|
|
1
|
+
{"version":3,"file":"initErrors.d.ts","sourceRoot":"","sources":["../../src/lifecycle/initErrors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,wBAAwB,EACxB,wBAAwB,EACxB,MAAM,mDAAmD,CAAA;AAK1D;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACxC,MAAM,EAAE,wBAAwB,EAChC,IAAI,GAAE;IACL,wBAAwB,CAAC,EAAE,MAAM,CAAA;IACjC,4BAA4B,CAAC,EAAE,MAAM,CAAA;CAChC,GACJ,wBAAwB,CA+I1B"}
|
|
@@ -59,6 +59,12 @@ export function initErrorForFailureReason(reason, data = {}) {
|
|
|
59
59
|
isRetryable: false,
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
|
+
case "init_timeout":
|
|
63
|
+
return {
|
|
64
|
+
code: reason,
|
|
65
|
+
message: "Host dependencies did not finish loading before the timeout.",
|
|
66
|
+
isRetryable: true,
|
|
67
|
+
};
|
|
62
68
|
case "context_unavailable":
|
|
63
69
|
return {
|
|
64
70
|
code: reason,
|
|
@@ -127,12 +133,6 @@ export function initErrorForFailureReason(reason, data = {}) {
|
|
|
127
133
|
// The block must be embedded in an iframe.
|
|
128
134
|
isRetryable: false,
|
|
129
135
|
};
|
|
130
|
-
case "init_timeout":
|
|
131
|
-
return {
|
|
132
|
-
code: reason,
|
|
133
|
-
message: "Host did not respond to the `connect` message before the timeout.",
|
|
134
|
-
isRetryable: true,
|
|
135
|
-
};
|
|
136
136
|
case "unknown_error":
|
|
137
137
|
return {
|
|
138
138
|
code: reason,
|
|
@@ -17,6 +17,10 @@ export type CustomBlockHostDataSourcesPayload = {
|
|
|
17
17
|
export type CustomBlockHostInitialDataSources = CustomBlockHostDataSourcesPayload | ((connect: ConnectSuccessMessage) => CustomBlockHostDataSourcesPayload);
|
|
18
18
|
export type CustomBlockHostInitialState = {
|
|
19
19
|
theme: NotionTheme;
|
|
20
|
+
/**
|
|
21
|
+
* Defaults to standard for existing host integrations.
|
|
22
|
+
* TODO(custom-blocks): Make this required when MIN_HOST_SUPPORTED_BRIDGE_PROTOCOL_VERSION increases to 4.
|
|
23
|
+
*/
|
|
20
24
|
contrastMode?: NotionContrastMode;
|
|
21
25
|
blockId: NotionBlockId;
|
|
22
26
|
parent: NotionParent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lifecycle/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAA;AAC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EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAA;AAC1F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAA;AACrF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAA;AAC9E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAA;AAC5E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gDAAgD,CAAA;AAEhF,MAAM,MAAM,qBAAqB,GAAG,OAAO,CAC1C,cAAc,EACd;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,CACrB,CAAA;AAED,MAAM,MAAM,UAAU,GACnB,mBAAmB,GACnB,sBAAsB,GACtB,SAAS,GACT,OAAO,CAAA;AAEV,MAAM,MAAM,iCAAiC,GAAG;IAC/C,QAAQ,EAAE,wBAAwB,CAAA;CAClC,CAAA;AAED,MAAM,MAAM,iCAAiC,GAC1C,iCAAiC,GACjC,CAAC,CAAC,OAAO,EAAE,qBAAqB,KAAK,iCAAiC,CAAC,CAAA;AAE1E,MAAM,MAAM,2BAA2B,GAAG;IACzC,KAAK,EAAE,WAAW,CAAA;IAClB;;;OAGG;IACH,YAAY,CAAC,EAAE,kBAAkB,CAAA;IACjC,OAAO,EAAE,aAAa,CAAA;IACtB,MAAM,EAAE,YAAY,CAAA;IACpB,IAAI,EAAE,eAAe,CAAA;IACrB;;;OAGG;IACH,QAAQ,CAAC,EAAE,mBAAmB,CAAA;IAC9B,WAAW,EAAE,iCAAiC,CAAA;IAC9C,WAAW,EAAE,UAAU,CAAA;CACvB,CAAA"}
|
package/dist/messages/types.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import type { CreatePageMessage } from "../protocol/messages/createPage.js";
|
|
1
|
+
import type { CreatePageMessage, createPageMessageSchema } from "../protocol/messages/createPage.js";
|
|
2
2
|
import type { CreatePageResultMessage, CustomBlockCreatePageErrorInfo } from "../protocol/messages/createPageResult.js";
|
|
3
|
-
import type { CustomBlockGetPageErrorInfo, GetPageMessage, GetPageResultMessage } from "../protocol/messages/getPage.js";
|
|
4
|
-
import type { CustomBlockGetUserErrorInfo, GetUserMessage, GetUserResultMessage } from "../protocol/messages/getUser.js";
|
|
3
|
+
import type { CustomBlockGetPageErrorInfo, GetPageMessage, GetPageResultMessage, getPageMessageSchema } from "../protocol/messages/getPage.js";
|
|
4
|
+
import type { CustomBlockGetUserErrorInfo, GetUserMessage, GetUserResultMessage, getUserMessageSchema } from "../protocol/messages/getUser.js";
|
|
5
5
|
import type { CustomBlockInitErrorInfo } from "../protocol/messages/init.js";
|
|
6
6
|
import type { CustomBlockInitResultErrorInfo } from "../protocol/messages/initResult.js";
|
|
7
|
-
import type { CustomBlockListUsersErrorInfo, ListUsersMessage, ListUsersResultMessage } from "../protocol/messages/listUsers.js";
|
|
7
|
+
import type { CustomBlockListUsersErrorInfo, ListUsersMessage, ListUsersResultMessage, listUsersMessageSchema } from "../protocol/messages/listUsers.js";
|
|
8
8
|
import type { BridgeMessagePayload } from "../protocol/messages/messagePayload.js";
|
|
9
|
-
import type { QueryDataSourceMessage } from "../protocol/messages/queryDataSource.js";
|
|
10
|
-
import type { ResizeMessage } from "../protocol/messages/resize.js";
|
|
11
|
-
import type { UpdatePageMessage } from "../protocol/messages/updatePage.js";
|
|
9
|
+
import type { QueryDataSourceMessage, queryDataSourceMessageSchema } from "../protocol/messages/queryDataSource.js";
|
|
10
|
+
import type { ResizeMessage, resizeMessageSchema } from "../protocol/messages/resize.js";
|
|
11
|
+
import type { UpdatePageMessage, updatePageMessageSchema } from "../protocol/messages/updatePage.js";
|
|
12
12
|
import type { CustomBlockUpdatePageErrorInfo, UpdatePageResultMessage } from "../protocol/messages/updatePageResult.js";
|
|
13
|
+
import type { InferInput } from "valibot";
|
|
13
14
|
import type { CustomBlockHostQueryDataSourceResult } from "../queries/types.js";
|
|
14
15
|
type MaybePromise<T> = T | Promise<T>;
|
|
15
16
|
export type CustomBlockHostCreatePageResult = BridgeMessagePayload<CreatePageResultMessage, CustomBlockCreatePageErrorInfo>;
|
|
@@ -28,5 +29,12 @@ export type CustomBlockHostHandlers = {
|
|
|
28
29
|
};
|
|
29
30
|
export type CustomBlockHostInitializationFailure = CustomBlockInitErrorInfo | CustomBlockInitResultErrorInfo;
|
|
30
31
|
export type CustomBlockHostLogDirection = "in" | "out" | "warn";
|
|
32
|
+
export type CreatePageMessageInput = InferInput<typeof createPageMessageSchema>;
|
|
33
|
+
export type GetPageMessageInput = InferInput<typeof getPageMessageSchema>;
|
|
34
|
+
export type GetUserMessageInput = InferInput<typeof getUserMessageSchema>;
|
|
35
|
+
export type ListUsersMessageInput = InferInput<typeof listUsersMessageSchema>;
|
|
36
|
+
export type QueryDataSourceMessageInput = InferInput<typeof queryDataSourceMessageSchema>;
|
|
37
|
+
export type ResizeMessageInput = InferInput<typeof resizeMessageSchema>;
|
|
38
|
+
export type UpdatePageMessageInput = InferInput<typeof updatePageMessageSchema>;
|
|
31
39
|
export {};
|
|
32
40
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/messages/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/messages/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,iBAAiB,EACjB,uBAAuB,EACvB,MAAM,yDAAyD,CAAA;AAChE,OAAO,KAAK,EACX,uBAAuB,EACvB,8BAA8B,EAC9B,MAAM,+DAA+D,CAAA;AACtE,OAAO,KAAK,EACX,2BAA2B,EAC3B,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,MAAM,sDAAsD,CAAA;AAC7D,OAAO,KAAK,EACX,2BAA2B,EAC3B,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,MAAM,sDAAsD,CAAA;AAC7D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mDAA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),
|
|
6
6
|
initializationId: v.string(),
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* The bridge protocol version this sandbox uses to communicate with its host.
|
|
9
|
+
* Hosts control which versions they support and can support multiple versions
|
|
10
|
+
* at the same time. Support for older versions is eventually removed, so blocks
|
|
11
|
+
* may need to update their SDK to continue working.
|
|
11
12
|
*/
|
|
12
13
|
bridgeProtocolVersion: v.number(),
|
|
13
14
|
/**
|
|
@@ -2,14 +2,14 @@ import * as v from "valibot";
|
|
|
2
2
|
import type { CustomBlockErrorCode, CustomBlockErrorInfo } from "../errors.js";
|
|
3
3
|
import type { CustomBlockInitResultErrorCode } from "./initResult.js";
|
|
4
4
|
export declare const customBlockInitErrorCodeSchema: v.StringSchema<undefined>;
|
|
5
|
-
export type CustomBlockInitErrorCode = CustomBlockErrorCode<"manifest_unavailable" | "manifest_invalid" | "invalid_connect_payload" | "invalid_protocol_version" | "unsupported_protocol_version" | "context_unavailable" | "current_user_unavailable" | "missing_data_source_binding" | "data_source_unavailable" | "missing_property_binding" | "invalid_property_binding">;
|
|
5
|
+
export type CustomBlockInitErrorCode = CustomBlockErrorCode<"manifest_unavailable" | "manifest_invalid" | "invalid_connect_payload" | "invalid_protocol_version" | "unsupported_protocol_version" | "init_timeout" | "context_unavailable" | "current_user_unavailable" | "missing_data_source_binding" | "data_source_unavailable" | "missing_property_binding" | "invalid_property_binding">;
|
|
6
6
|
export type CustomBlockInitErrorInfo = CustomBlockErrorInfo<CustomBlockInitErrorCode>;
|
|
7
7
|
/**
|
|
8
8
|
* Every initialization failure visible to block code. This combines errors
|
|
9
9
|
* received in `init`, errors the sandbox reports in `initResult`, and failures
|
|
10
10
|
* detected locally while running `initCustomBlock()`.
|
|
11
11
|
*/
|
|
12
|
-
export type CustomBlockInitializationErrorCode = CustomBlockInitErrorCode | CustomBlockInitResultErrorCode | CustomBlockErrorCode<"not_in_iframe"
|
|
12
|
+
export type CustomBlockInitializationErrorCode = CustomBlockInitErrorCode | CustomBlockInitResultErrorCode | CustomBlockErrorCode<"not_in_iframe">;
|
|
13
13
|
export type CustomBlockInitializationErrorInfo = CustomBlockErrorInfo<CustomBlockInitializationErrorCode>;
|
|
14
14
|
export declare const customBlockInitErrorInfoSchema: v.ObjectSchema<{
|
|
15
15
|
readonly code: v.StringSchema<undefined>;
|
|
@@ -16,7 +16,8 @@ export const initResultMessageSchema = v.variant("status", [
|
|
|
16
16
|
initializationId: v.string(),
|
|
17
17
|
status: v.literal("success"),
|
|
18
18
|
/** Height of the initial rendered custom-block content, in CSS pixels. */
|
|
19
|
-
//
|
|
19
|
+
// Older SDKs can omit the height. Current SDKs always send it.
|
|
20
|
+
// TODO(custom-blocks): Make this required when MIN_HOST_SUPPORTED_BRIDGE_PROTOCOL_VERSION increases to 4.
|
|
20
21
|
initialHeight: v.optional(v.pipe(v.number(), v.finite(), v.minValue(0))),
|
|
21
22
|
}),
|
|
22
23
|
v.object({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* The protocol version that the current SDK sends in `connect`.
|
|
3
|
+
* Increase this value for breaking wire changes. Hosts can continue to accept
|
|
4
|
+
* older versions, so this value does not set the minimum or maximum they accept.
|
|
5
5
|
*/
|
|
6
|
-
export declare const
|
|
6
|
+
export declare const LATEST_BRIDGE_PROTOCOL_VERSION = 3;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* The protocol version that the current SDK sends in `connect`.
|
|
3
|
+
* Increase this value for breaking wire changes. Hosts can continue to accept
|
|
4
|
+
* older versions, so this value does not set the minimum or maximum they accept.
|
|
5
5
|
*/
|
|
6
|
-
export const
|
|
6
|
+
export const LATEST_BRIDGE_PROTOCOL_VERSION = 3;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The oldest bridge protocol version the host runtime supports.
|
|
3
|
+
* Used as the default and lower bound for minBridgeProtocolVersion.
|
|
4
|
+
* Increase only when retiring support for older SDKs, independently
|
|
5
|
+
* of the latest SDK protocol version.
|
|
6
|
+
*/
|
|
7
|
+
export declare const MIN_HOST_SUPPORTED_BRIDGE_PROTOCOL_VERSION = 3;
|
|
8
|
+
//# sourceMappingURL=protocolVersion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocolVersion.d.ts","sourceRoot":"","sources":["../src/protocolVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,0CAA0C,IAAI,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The oldest bridge protocol version the host runtime supports.
|
|
3
|
+
* Used as the default and lower bound for minBridgeProtocolVersion.
|
|
4
|
+
* Increase only when retiring support for older SDKs, independently
|
|
5
|
+
* of the latest SDK protocol version.
|
|
6
|
+
*/
|
|
7
|
+
export const MIN_HOST_SUPPORTED_BRIDGE_PROTOCOL_VERSION = 3;
|
package/package.json
CHANGED
|
@@ -31,7 +31,6 @@ import type { UpdatePageMessage } from "@notionhq/custom-blocks-protocol/message
|
|
|
31
31
|
import type { UpdatePageResultMessage } from "@notionhq/custom-blocks-protocol/messages/updatePageResult.js"
|
|
32
32
|
import type { CustomBlockPage } from "@notionhq/custom-blocks-protocol/pages/page.js"
|
|
33
33
|
import type { NotionParent } from "@notionhq/custom-blocks-protocol/parent.js"
|
|
34
|
-
import { CUSTOM_BLOCK_BRIDGE_PROTOCOL_VERSION } from "@notionhq/custom-blocks-protocol/protocolVersion.js"
|
|
35
34
|
import type { NotionTheme } from "@notionhq/custom-blocks-protocol/theme.js"
|
|
36
35
|
import type { NotionUser } from "@notionhq/custom-blocks-protocol/users/user.js"
|
|
37
36
|
import { initErrorForFailureReason } from "./lifecycle/initErrors.js"
|
|
@@ -46,6 +45,7 @@ import type {
|
|
|
46
45
|
CustomBlockHostInitializationFailure,
|
|
47
46
|
CustomBlockHostLogDirection,
|
|
48
47
|
} from "./messages/types.js"
|
|
48
|
+
import { MIN_HOST_SUPPORTED_BRIDGE_PROTOCOL_VERSION } from "./protocolVersion.js"
|
|
49
49
|
import {
|
|
50
50
|
QuerySubscriptions,
|
|
51
51
|
type QuerySubscriptionToken,
|
|
@@ -57,7 +57,12 @@ import { validateQueryDataSourceSorts } from "./queries/validateQueryDataSourceS
|
|
|
57
57
|
export type CustomBlockHostOptions = {
|
|
58
58
|
iframe: HTMLIFrameElement
|
|
59
59
|
sandboxOrigin: string
|
|
60
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Minimum sandbox protocol version to accept. Defaults to the host runtime
|
|
62
|
+
* minimum. Higher values retire older SDKs; lower values cannot enable
|
|
63
|
+
* protocol versions the runtime no longer supports.
|
|
64
|
+
*/
|
|
65
|
+
minBridgeProtocolVersion?: number
|
|
61
66
|
noConnectTimeoutMs?: number
|
|
62
67
|
noInitResultTimeoutMs?: number
|
|
63
68
|
initialState: CustomBlockHostInitialState
|
|
@@ -110,9 +115,12 @@ export function createCustomBlockHost(
|
|
|
110
115
|
noConnectTimeoutMs,
|
|
111
116
|
noInitResultTimeoutMs,
|
|
112
117
|
} = options
|
|
118
|
+
// Callers can retire older SDKs, but cannot restore support for protocols
|
|
119
|
+
// the runtime no longer implements. Omission uses the runtime minimum.
|
|
113
120
|
const minBridgeProtocolVersion = Math.max(
|
|
114
|
-
configuredMinBridgeProtocolVersion ??
|
|
115
|
-
|
|
121
|
+
configuredMinBridgeProtocolVersion ??
|
|
122
|
+
MIN_HOST_SUPPORTED_BRIDGE_PROTOCOL_VERSION,
|
|
123
|
+
MIN_HOST_SUPPORTED_BRIDGE_PROTOCOL_VERSION,
|
|
116
124
|
)
|
|
117
125
|
|
|
118
126
|
let theme = initialState.theme
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
export type { CreatePageMessage } from "@notionhq/custom-blocks-protocol/messages/createPage.js"
|
|
2
|
+
export type { GetPageMessage } from "@notionhq/custom-blocks-protocol/messages/getPage.js"
|
|
3
|
+
export type { GetUserMessage } from "@notionhq/custom-blocks-protocol/messages/getUser.js"
|
|
4
|
+
export type { ListUsersMessage } from "@notionhq/custom-blocks-protocol/messages/listUsers.js"
|
|
5
|
+
export type { QueryDataSourceMessage } from "@notionhq/custom-blocks-protocol/messages/queryDataSource.js"
|
|
6
|
+
export type { ResizeMessage } from "@notionhq/custom-blocks-protocol/messages/resize.js"
|
|
7
|
+
export type { UpdatePageMessage } from "@notionhq/custom-blocks-protocol/messages/updatePage.js"
|
|
8
|
+
export type {
|
|
9
|
+
NotionPagePropertyValue,
|
|
10
|
+
NotionPagePropertyWriteMap,
|
|
11
|
+
NotionRichTextItem,
|
|
12
|
+
} from "@notionhq/custom-blocks-protocol/pages/page.js"
|
|
1
13
|
export {
|
|
2
14
|
type AutoBindableProperty,
|
|
3
15
|
getAutoBoundPropertyIdsByKey,
|
|
@@ -14,6 +26,7 @@ export type {
|
|
|
14
26
|
CustomBlockHostInitialState,
|
|
15
27
|
} from "./lifecycle/types.js"
|
|
16
28
|
export type {
|
|
29
|
+
CreatePageMessageInput,
|
|
17
30
|
CustomBlockHostCreatePageResult,
|
|
18
31
|
CustomBlockHostGetPageResult,
|
|
19
32
|
CustomBlockHostGetUserResult,
|
|
@@ -22,5 +35,11 @@ export type {
|
|
|
22
35
|
CustomBlockHostListUsersResult,
|
|
23
36
|
CustomBlockHostLogDirection,
|
|
24
37
|
CustomBlockHostUpdatePageResult,
|
|
38
|
+
GetPageMessageInput,
|
|
39
|
+
GetUserMessageInput,
|
|
40
|
+
ListUsersMessageInput,
|
|
41
|
+
QueryDataSourceMessageInput,
|
|
42
|
+
ResizeMessageInput,
|
|
43
|
+
UpdatePageMessageInput,
|
|
25
44
|
} from "./messages/types.js"
|
|
26
45
|
export type { CustomBlockHostQueryDataSourceResult } from "./queries/types.js"
|
|
@@ -72,6 +72,12 @@ export function initErrorForFailureReason(
|
|
|
72
72
|
isRetryable: false,
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
+
case "init_timeout":
|
|
76
|
+
return {
|
|
77
|
+
code: reason,
|
|
78
|
+
message: "Host dependencies did not finish loading before the timeout.",
|
|
79
|
+
isRetryable: true,
|
|
80
|
+
}
|
|
75
81
|
case "context_unavailable":
|
|
76
82
|
return {
|
|
77
83
|
code: reason,
|
|
@@ -140,13 +146,6 @@ export function initErrorForFailureReason(
|
|
|
140
146
|
// The block must be embedded in an iframe.
|
|
141
147
|
isRetryable: false,
|
|
142
148
|
}
|
|
143
|
-
case "init_timeout":
|
|
144
|
-
return {
|
|
145
|
-
code: reason,
|
|
146
|
-
message:
|
|
147
|
-
"Host did not respond to the `connect` message before the timeout.",
|
|
148
|
-
isRetryable: true,
|
|
149
|
-
}
|
|
150
149
|
case "unknown_error":
|
|
151
150
|
return {
|
|
152
151
|
code: reason,
|
package/src/lifecycle/types.ts
CHANGED
|
@@ -29,7 +29,10 @@ export type CustomBlockHostInitialDataSources =
|
|
|
29
29
|
|
|
30
30
|
export type CustomBlockHostInitialState = {
|
|
31
31
|
theme: NotionTheme
|
|
32
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Defaults to standard for existing host integrations.
|
|
34
|
+
* TODO(custom-blocks): Make this required when MIN_HOST_SUPPORTED_BRIDGE_PROTOCOL_VERSION increases to 4.
|
|
35
|
+
*/
|
|
33
36
|
contrastMode?: NotionContrastMode
|
|
34
37
|
blockId: NotionBlockId
|
|
35
38
|
parent: NotionParent
|
package/src/messages/types.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
CreatePageMessage,
|
|
3
|
+
createPageMessageSchema,
|
|
4
|
+
} from "@notionhq/custom-blocks-protocol/messages/createPage.js"
|
|
2
5
|
import type {
|
|
3
6
|
CreatePageResultMessage,
|
|
4
7
|
CustomBlockCreatePageErrorInfo,
|
|
@@ -7,11 +10,13 @@ import type {
|
|
|
7
10
|
CustomBlockGetPageErrorInfo,
|
|
8
11
|
GetPageMessage,
|
|
9
12
|
GetPageResultMessage,
|
|
13
|
+
getPageMessageSchema,
|
|
10
14
|
} from "@notionhq/custom-blocks-protocol/messages/getPage.js"
|
|
11
15
|
import type {
|
|
12
16
|
CustomBlockGetUserErrorInfo,
|
|
13
17
|
GetUserMessage,
|
|
14
18
|
GetUserResultMessage,
|
|
19
|
+
getUserMessageSchema,
|
|
15
20
|
} from "@notionhq/custom-blocks-protocol/messages/getUser.js"
|
|
16
21
|
import type { CustomBlockInitErrorInfo } from "@notionhq/custom-blocks-protocol/messages/init.js"
|
|
17
22
|
import type { CustomBlockInitResultErrorInfo } from "@notionhq/custom-blocks-protocol/messages/initResult.js"
|
|
@@ -19,15 +24,26 @@ import type {
|
|
|
19
24
|
CustomBlockListUsersErrorInfo,
|
|
20
25
|
ListUsersMessage,
|
|
21
26
|
ListUsersResultMessage,
|
|
27
|
+
listUsersMessageSchema,
|
|
22
28
|
} from "@notionhq/custom-blocks-protocol/messages/listUsers.js"
|
|
23
29
|
import type { BridgeMessagePayload } from "@notionhq/custom-blocks-protocol/messages/messagePayload.js"
|
|
24
|
-
import type {
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
import type {
|
|
31
|
+
QueryDataSourceMessage,
|
|
32
|
+
queryDataSourceMessageSchema,
|
|
33
|
+
} from "@notionhq/custom-blocks-protocol/messages/queryDataSource.js"
|
|
34
|
+
import type {
|
|
35
|
+
ResizeMessage,
|
|
36
|
+
resizeMessageSchema,
|
|
37
|
+
} from "@notionhq/custom-blocks-protocol/messages/resize.js"
|
|
38
|
+
import type {
|
|
39
|
+
UpdatePageMessage,
|
|
40
|
+
updatePageMessageSchema,
|
|
41
|
+
} from "@notionhq/custom-blocks-protocol/messages/updatePage.js"
|
|
27
42
|
import type {
|
|
28
43
|
CustomBlockUpdatePageErrorInfo,
|
|
29
44
|
UpdatePageResultMessage,
|
|
30
45
|
} from "@notionhq/custom-blocks-protocol/messages/updatePageResult.js"
|
|
46
|
+
import type { InferInput } from "valibot"
|
|
31
47
|
import type { CustomBlockHostQueryDataSourceResult } from "../queries/types.js"
|
|
32
48
|
|
|
33
49
|
type MaybePromise<T> = T | Promise<T>
|
|
@@ -84,3 +100,19 @@ export type CustomBlockHostInitializationFailure =
|
|
|
84
100
|
| CustomBlockInitResultErrorInfo
|
|
85
101
|
|
|
86
102
|
export type CustomBlockHostLogDirection = "in" | "out" | "warn"
|
|
103
|
+
|
|
104
|
+
export type CreatePageMessageInput = InferInput<typeof createPageMessageSchema>
|
|
105
|
+
|
|
106
|
+
export type GetPageMessageInput = InferInput<typeof getPageMessageSchema>
|
|
107
|
+
|
|
108
|
+
export type GetUserMessageInput = InferInput<typeof getUserMessageSchema>
|
|
109
|
+
|
|
110
|
+
export type ListUsersMessageInput = InferInput<typeof listUsersMessageSchema>
|
|
111
|
+
|
|
112
|
+
export type QueryDataSourceMessageInput = InferInput<
|
|
113
|
+
typeof queryDataSourceMessageSchema
|
|
114
|
+
>
|
|
115
|
+
|
|
116
|
+
export type ResizeMessageInput = InferInput<typeof resizeMessageSchema>
|
|
117
|
+
|
|
118
|
+
export type UpdatePageMessageInput = InferInput<typeof updatePageMessageSchema>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The oldest bridge protocol version the host runtime supports.
|
|
3
|
+
* Used as the default and lower bound for minBridgeProtocolVersion.
|
|
4
|
+
* Increase only when retiring support for older SDKs, independently
|
|
5
|
+
* of the latest SDK protocol version.
|
|
6
|
+
*/
|
|
7
|
+
export const MIN_HOST_SUPPORTED_BRIDGE_PROTOCOL_VERSION = 3
|