@notionhq/custom-blocks-host 0.1.13 → 0.1.15
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 +1 -0
- package/dist/createCustomBlockHost.d.ts.map +1 -1
- package/dist/createCustomBlockHost.js +13 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/messages/sandboxMessageRouter.d.ts +2 -0
- package/dist/messages/sandboxMessageRouter.d.ts.map +1 -1
- package/dist/messages/sandboxMessageRouter.js +4 -1
- package/dist/messages/types.d.ts +4 -0
- package/dist/messages/types.d.ts.map +1 -1
- package/dist/protocol/dataSources/dataSourcePage.d.ts +2 -2
- package/dist/protocol/dataSources/dataSourcePage.js +2 -3
- package/dist/protocol/index.d.ts +1 -0
- package/dist/protocol/index.js +1 -0
- package/dist/protocol/messages/createPageResult.d.ts +2 -2
- package/dist/protocol/messages/getPage.d.ts +2 -2
- package/dist/protocol/messages/hostToSandbox.d.ts +24 -10
- package/dist/protocol/messages/hostToSandbox.js +2 -0
- package/dist/protocol/messages/init.d.ts +1 -1
- package/dist/protocol/messages/init.js +2 -3
- package/dist/protocol/messages/openPage.d.ts +38 -0
- package/dist/protocol/messages/openPage.js +34 -0
- package/dist/protocol/messages/queryDataSourceResult.d.ts +2 -2
- package/dist/protocol/messages/sandboxToHost.d.ts +5 -0
- package/dist/protocol/messages/sandboxToHost.js +2 -0
- package/dist/protocol/messages/updatePageResult.d.ts +2 -2
- package/dist/protocol/pages/page.d.ts +2 -2
- package/dist/protocol/pages/page.js +2 -3
- package/dist/protocol/protocolVersion.d.ts +1 -1
- package/dist/protocol/protocolVersion.js +1 -1
- package/package.json +1 -1
- package/src/createCustomBlockHost.ts +18 -0
- package/src/index.ts +3 -0
- package/src/messages/sandboxMessageRouter.ts +6 -0
- package/src/messages/types.ts +16 -0
package/README.md
CHANGED
|
@@ -66,6 +66,7 @@ const host = createCustomBlockHost({
|
|
|
66
66
|
}),
|
|
67
67
|
createPage: async (message) => createPage(message),
|
|
68
68
|
getPage: async (message) => getPage(message),
|
|
69
|
+
openPage: async (message) => openPage(message),
|
|
69
70
|
updatePage: async (message) => updatePage(message),
|
|
70
71
|
getUser: async (message) => getUser(message),
|
|
71
72
|
listUsers: async (message) => listUsers(message),
|
|
@@ -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;
|
|
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;AAiBtG,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,EACpC,2BAA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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,CAuZvB"}
|
|
@@ -130,6 +130,18 @@ export function createCustomBlockHost(options) {
|
|
|
130
130
|
};
|
|
131
131
|
post(result);
|
|
132
132
|
}
|
|
133
|
+
async function handleOpenPage(message) {
|
|
134
|
+
if (handlers.openPage === undefined) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
const response = await handlers.openPage(message);
|
|
138
|
+
const result = {
|
|
139
|
+
type: "openPageResult",
|
|
140
|
+
requestId: message.requestId,
|
|
141
|
+
...response,
|
|
142
|
+
};
|
|
143
|
+
post(result);
|
|
144
|
+
}
|
|
133
145
|
async function handleUpdatePage(message) {
|
|
134
146
|
if (handlers.updatePage === undefined) {
|
|
135
147
|
return;
|
|
@@ -235,6 +247,7 @@ export function createCustomBlockHost(options) {
|
|
|
235
247
|
onUnsubscribeDataSourceQuery: message => querySubscriptions.unsubscribe(message.subscriptionId),
|
|
236
248
|
onCreatePage: handleCreatePage,
|
|
237
249
|
onGetPage: handleGetPage,
|
|
250
|
+
onOpenPage: handleOpenPage,
|
|
238
251
|
onGetUser: handleGetUser,
|
|
239
252
|
onListUsers: handleListUsers,
|
|
240
253
|
onUpdatePage: handleUpdatePage,
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export type { CreatePageMessage } from "./protocol/messages/createPage.js";
|
|
|
2
2
|
export type { GetPageMessage } from "./protocol/messages/getPage.js";
|
|
3
3
|
export type { GetUserMessage } from "./protocol/messages/getUser.js";
|
|
4
4
|
export type { ListUsersMessage } from "./protocol/messages/listUsers.js";
|
|
5
|
+
export type { OpenPageMessage } from "./protocol/messages/openPage.js";
|
|
5
6
|
export type { QueryDataSourceMessage } from "./protocol/messages/queryDataSource.js";
|
|
6
7
|
export type { ResizeMessage } from "./protocol/messages/resize.js";
|
|
7
8
|
export type { UpdatePageMessage } from "./protocol/messages/updatePage.js";
|
|
@@ -9,6 +10,6 @@ export type { NotionPagePropertyValue, NotionPagePropertyWriteMap, NotionRichTex
|
|
|
9
10
|
export { type AutoBindableProperty, getAutoBoundPropertyIdsByKey, } from "./autoBindProperties.js";
|
|
10
11
|
export { type CustomBlockHostHandle, type CustomBlockHostOptions, createCustomBlockHost, } from "./createCustomBlockHost.js";
|
|
11
12
|
export type { ConnectSuccessMessage, CustomBlockHostDataSourcesPayload, CustomBlockHostInitialDataSources, CustomBlockHostInitialState, } from "./lifecycle/types.js";
|
|
12
|
-
export type { CreatePageMessageInput, CustomBlockHostCreatePageResult, CustomBlockHostGetPageResult, CustomBlockHostGetUserResult, CustomBlockHostHandlers, CustomBlockHostInitializationFailure, CustomBlockHostListUsersResult, CustomBlockHostLogDirection, CustomBlockHostUpdatePageResult, GetPageMessageInput, GetUserMessageInput, ListUsersMessageInput, QueryDataSourceMessageInput, ResizeMessageInput, UpdatePageMessageInput, } from "./messages/types.js";
|
|
13
|
+
export type { CreatePageMessageInput, CustomBlockHostCreatePageResult, CustomBlockHostGetPageResult, CustomBlockHostGetUserResult, CustomBlockHostHandlers, CustomBlockHostInitializationFailure, CustomBlockHostListUsersResult, CustomBlockHostLogDirection, CustomBlockHostOpenPageResult, CustomBlockHostUpdatePageResult, GetPageMessageInput, GetUserMessageInput, ListUsersMessageInput, OpenPageMessageInput, QueryDataSourceMessageInput, ResizeMessageInput, UpdatePageMessageInput, } from "./messages/types.js";
|
|
13
14
|
export type { CustomBlockHostQueryDataSourceResult } from "./queries/types.js";
|
|
14
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources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AAA;AAC1F,YAAY,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAA;AAC1F,YAAY,EAAE,gBAAgB,EAAE,MAAM,wDAAwD,CAAA;AAC9F,YAAY,EAAE,eAAe,EAAE,MAAM,uDAAuD,CAAA;AAC5F,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,6BAA6B,EAC7B,+BAA+B,EAC/B,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EAClB,sBAAsB,GACtB,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EAAE,oCAAoC,EAAE,MAAM,oBAAoB,CAAA"}
|
|
@@ -5,6 +5,7 @@ import type { GetUserMessage } from "../protocol/messages/getUser.js";
|
|
|
5
5
|
import type { HostToSandboxMessage } from "../protocol/messages/hostToSandbox.js";
|
|
6
6
|
import type { InitResultMessage } from "../protocol/messages/initResult.js";
|
|
7
7
|
import type { ListUsersMessage } from "../protocol/messages/listUsers.js";
|
|
8
|
+
import type { OpenPageMessage } from "../protocol/messages/openPage.js";
|
|
8
9
|
import type { QueryDataSourceMessage } from "../protocol/messages/queryDataSource.js";
|
|
9
10
|
import type { ResizeMessage } from "../protocol/messages/resize.js";
|
|
10
11
|
import type { UnsubscribeDataSourceQueryMessage } from "../protocol/messages/unsubscribeDataSourceQuery.js";
|
|
@@ -25,6 +26,7 @@ export type SandboxMessageRouterOptions = {
|
|
|
25
26
|
onQueryDataSource: (message: QueryDataSourceMessage) => void | Promise<void>;
|
|
26
27
|
onUnsubscribeDataSourceQuery: (message: UnsubscribeDataSourceQueryMessage) => void;
|
|
27
28
|
onCreatePage: (message: CreatePageMessage) => void | Promise<void>;
|
|
29
|
+
onOpenPage: (message: OpenPageMessage) => void | Promise<void>;
|
|
28
30
|
onGetPage: (message: GetPageMessage) => void | Promise<void>;
|
|
29
31
|
onGetUser: (message: GetUserMessage) => void | Promise<void>;
|
|
30
32
|
onListUsers: (message: ListUsersMessage) => void | Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandboxMessageRouter.d.ts","sourceRoot":"","sources":["../../src/messages/sandboxMessageRouter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAA;AAC1F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAA;AAChG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAA;AAC1F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAA;AAC1F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4DAA4D,CAAA;AACtG,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAA;AAEhG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wDAAwD,CAAA;AAC9F,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8DAA8D,CAAA;AAC1G,OAAO,KAAK,EAAE,aAA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KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAChE,YAAY,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAClE,QAAQ,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI,CAAA;CAC1C,CAAA;AAED,wBAAgB,0BAA0B,CACzC,OAAO,EAAE,2BAA2B,GAClC,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAkI/B"}
|
|
@@ -8,7 +8,7 @@ const initializationIdentitySchema = v.object({
|
|
|
8
8
|
initializationId: v.string(),
|
|
9
9
|
});
|
|
10
10
|
export function createSandboxMessageRouter(options) {
|
|
11
|
-
const { iframe, sandboxOrigin, getInitStatus, emit, post, onInvalidConnect, onInvalidInitResult, onConnect, onInitResult, onQueryDataSource, onUnsubscribeDataSourceQuery, onCreatePage, onGetPage, onGetUser, onListUsers, onUpdatePage, onResize, } = options;
|
|
11
|
+
const { iframe, sandboxOrigin, getInitStatus, emit, post, onInvalidConnect, onInvalidInitResult, onConnect, onInitResult, onQueryDataSource, onUnsubscribeDataSourceQuery, onCreatePage, onGetPage, onOpenPage, onGetUser, onListUsers, onUpdatePage, onResize, } = options;
|
|
12
12
|
function onInvalidSandboxMessage(data, issues) {
|
|
13
13
|
emit("warn", {
|
|
14
14
|
message: "Ignored unsupported sandbox message",
|
|
@@ -82,6 +82,9 @@ export function createSandboxMessageRouter(options) {
|
|
|
82
82
|
case "createPage":
|
|
83
83
|
void onCreatePage(message);
|
|
84
84
|
return;
|
|
85
|
+
case "openPage":
|
|
86
|
+
void onOpenPage(message);
|
|
87
|
+
return;
|
|
85
88
|
case "getPage":
|
|
86
89
|
void onGetPage(message);
|
|
87
90
|
return;
|
package/dist/messages/types.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type { CustomBlockInitErrorInfo } from "../protocol/messages/init.js";
|
|
|
6
6
|
import type { CustomBlockInitResultErrorInfo } from "../protocol/messages/initResult.js";
|
|
7
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 { CustomBlockOpenPageErrorInfo, OpenPageMessage, OpenPageResultMessage, openPageMessageSchema } from "../protocol/messages/openPage.js";
|
|
9
10
|
import type { QueryDataSourceMessage, queryDataSourceMessageSchema } from "../protocol/messages/queryDataSource.js";
|
|
10
11
|
import type { ResizeMessage, resizeMessageSchema } from "../protocol/messages/resize.js";
|
|
11
12
|
import type { UpdatePageMessage, updatePageMessageSchema } from "../protocol/messages/updatePage.js";
|
|
@@ -18,12 +19,14 @@ export type CustomBlockHostGetPageResult = BridgeMessagePayload<GetPageResultMes
|
|
|
18
19
|
export type CustomBlockHostUpdatePageResult = BridgeMessagePayload<UpdatePageResultMessage, CustomBlockUpdatePageErrorInfo>;
|
|
19
20
|
export type CustomBlockHostGetUserResult = BridgeMessagePayload<GetUserResultMessage, CustomBlockGetUserErrorInfo>;
|
|
20
21
|
export type CustomBlockHostListUsersResult = BridgeMessagePayload<ListUsersResultMessage, CustomBlockListUsersErrorInfo>;
|
|
22
|
+
export type CustomBlockHostOpenPageResult = BridgeMessagePayload<OpenPageResultMessage, CustomBlockOpenPageErrorInfo>;
|
|
21
23
|
export type CustomBlockHostHandlers = {
|
|
22
24
|
queryDataSource: (message: QueryDataSourceMessage) => MaybePromise<CustomBlockHostQueryDataSourceResult>;
|
|
23
25
|
createPage?: (message: CreatePageMessage) => MaybePromise<CustomBlockHostCreatePageResult>;
|
|
24
26
|
getPage?: (message: GetPageMessage) => MaybePromise<CustomBlockHostGetPageResult>;
|
|
25
27
|
getUser?: (message: GetUserMessage) => MaybePromise<CustomBlockHostGetUserResult>;
|
|
26
28
|
listUsers?: (message: ListUsersMessage) => MaybePromise<CustomBlockHostListUsersResult>;
|
|
29
|
+
openPage?: (message: OpenPageMessage) => MaybePromise<CustomBlockHostOpenPageResult>;
|
|
27
30
|
updatePage?: (message: UpdatePageMessage) => MaybePromise<CustomBlockHostUpdatePageResult>;
|
|
28
31
|
resize?: (message: ResizeMessage) => void;
|
|
29
32
|
};
|
|
@@ -33,6 +36,7 @@ export type CreatePageMessageInput = InferInput<typeof createPageMessageSchema>;
|
|
|
33
36
|
export type GetPageMessageInput = InferInput<typeof getPageMessageSchema>;
|
|
34
37
|
export type GetUserMessageInput = InferInput<typeof getUserMessageSchema>;
|
|
35
38
|
export type ListUsersMessageInput = InferInput<typeof listUsersMessageSchema>;
|
|
39
|
+
export type OpenPageMessageInput = InferInput<typeof openPageMessageSchema>;
|
|
36
40
|
export type QueryDataSourceMessageInput = InferInput<typeof queryDataSourceMessageSchema>;
|
|
37
41
|
export type ResizeMessageInput = InferInput<typeof resizeMessageSchema>;
|
|
38
42
|
export type UpdatePageMessageInput = InferInput<typeof updatePageMessageSchema>;
|
|
@@ -1 +1 @@
|
|
|
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,mDAAmD,CAAA;AACjG,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,yDAAyD,CAAA;AAC7G,OAAO,KAAK,EACX,6BAA6B,EAC7B,gBAAgB,EAChB,sBAAsB,EACtB,sBAAsB,EACtB,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BAAuB,CAAC,CAAA;AAE/E,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAEzE,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAEzE,MAAM,MAAM,qBAAqB,GAAG,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAA;AAE7E,MAAM,MAAM,oBAAoB,GAAG,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAA;AAE3E,MAAM,MAAM,2BAA2B,GAAG,UAAU,CACnD,OAAO,4BAA4B,CACnC,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAEvE,MAAM,MAAM,sBAAsB,GAAG,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAA"}
|
|
@@ -7,9 +7,9 @@ import * as v from "valibot";
|
|
|
7
7
|
export declare const notionDataSourcePageBridgeSchema: v.ObjectSchema<{
|
|
8
8
|
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
|
|
9
9
|
/** Whether the page or an ancestor is archived. */
|
|
10
|
-
readonly is_archived: v.
|
|
10
|
+
readonly is_archived: v.BooleanSchema<undefined>;
|
|
11
11
|
/** Whether the page or an ancestor is in Trash. */
|
|
12
|
-
readonly in_trash: v.
|
|
12
|
+
readonly in_trash: v.BooleanSchema<undefined>;
|
|
13
13
|
readonly propertiesById: v.RecordSchema<v.StringSchema<undefined>, v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.BooleanSchema<undefined>, v.VariantSchema<"type", [v.ObjectSchema<{
|
|
14
14
|
readonly type: v.LiteralSchema<"date", undefined>;
|
|
15
15
|
readonly start_date: v.StringSchema<undefined>;
|
|
@@ -8,10 +8,9 @@ import { notionDataSourceValueSchema } from "./dataSourceValue.js";
|
|
|
8
8
|
*/
|
|
9
9
|
export const notionDataSourcePageBridgeSchema = v.object({
|
|
10
10
|
id: notionPageIdSchema,
|
|
11
|
-
// TODO(custom-blocks): Require is_archived and in_trash in bridge protocol v4.
|
|
12
11
|
/** Whether the page or an ancestor is archived. */
|
|
13
|
-
is_archived: v.
|
|
12
|
+
is_archived: v.boolean(),
|
|
14
13
|
/** Whether the page or an ancestor is in Trash. */
|
|
15
|
-
in_trash: v.
|
|
14
|
+
in_trash: v.boolean(),
|
|
16
15
|
propertiesById: v.record(v.string(), v.optional(notionDataSourceValueSchema)),
|
|
17
16
|
});
|
package/dist/protocol/index.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ export * from "./messages/invalidSandboxMessage.js";
|
|
|
33
33
|
export * from "./messages/isInitHandshakeMessage.js";
|
|
34
34
|
export * from "./messages/listUsers.js";
|
|
35
35
|
export * from "./messages/messagePayload.js";
|
|
36
|
+
export * from "./messages/openPage.js";
|
|
36
37
|
export * from "./messages/pageChanged.js";
|
|
37
38
|
export * from "./messages/parentChanged.js";
|
|
38
39
|
export * from "./messages/queryDataSource.js";
|
package/dist/protocol/index.js
CHANGED
|
@@ -33,6 +33,7 @@ export * from "./messages/invalidSandboxMessage.js";
|
|
|
33
33
|
export * from "./messages/isInitHandshakeMessage.js";
|
|
34
34
|
export * from "./messages/listUsers.js";
|
|
35
35
|
export * from "./messages/messagePayload.js";
|
|
36
|
+
export * from "./messages/openPage.js";
|
|
36
37
|
export * from "./messages/pageChanged.js";
|
|
37
38
|
export * from "./messages/parentChanged.js";
|
|
38
39
|
export * from "./messages/queryDataSource.js";
|
|
@@ -200,8 +200,8 @@ export declare const createPageResultMessageSchema: v.VariantSchema<"status", [v
|
|
|
200
200
|
}, undefined>], undefined>, undefined>;
|
|
201
201
|
readonly url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
202
202
|
readonly public_url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
203
|
-
readonly is_archived: v.
|
|
204
|
-
readonly in_trash: v.
|
|
203
|
+
readonly is_archived: v.BooleanSchema<undefined>;
|
|
204
|
+
readonly in_trash: v.BooleanSchema<undefined>;
|
|
205
205
|
}, undefined>;
|
|
206
206
|
}, undefined>, v.ObjectSchema<{
|
|
207
207
|
readonly type: v.LiteralSchema<"createPageResult", undefined>;
|
|
@@ -205,8 +205,8 @@ export declare const getPageResultMessageSchema: v.VariantSchema<"status", [v.Ob
|
|
|
205
205
|
}, undefined>], undefined>, undefined>;
|
|
206
206
|
readonly url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
207
207
|
readonly public_url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
208
|
-
readonly is_archived: v.
|
|
209
|
-
readonly in_trash: v.
|
|
208
|
+
readonly is_archived: v.BooleanSchema<undefined>;
|
|
209
|
+
readonly in_trash: v.BooleanSchema<undefined>;
|
|
210
210
|
}, undefined>;
|
|
211
211
|
}, undefined>, v.ObjectSchema<{
|
|
212
212
|
readonly type: v.LiteralSchema<"getPageResult", undefined>;
|
|
@@ -7,7 +7,7 @@ export declare const hostToSandboxMessageSchema: v.VariantSchema<"type", [v.Vari
|
|
|
7
7
|
readonly initializationId: v.StringSchema<undefined>;
|
|
8
8
|
readonly status: v.LiteralSchema<"success", undefined>;
|
|
9
9
|
readonly theme: v.PicklistSchema<["light", "dark"], undefined>;
|
|
10
|
-
readonly contrastMode: v.
|
|
10
|
+
readonly contrastMode: v.PicklistSchema<["standard", "high"], undefined>;
|
|
11
11
|
readonly blockId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionBlockId">]>;
|
|
12
12
|
readonly parent: v.VariantSchema<"type", [v.ObjectSchema<{
|
|
13
13
|
readonly type: v.LiteralSchema<"page_id", undefined>;
|
|
@@ -449,8 +449,8 @@ export declare const hostToSandboxMessageSchema: v.VariantSchema<"type", [v.Vari
|
|
|
449
449
|
readonly status: v.LiteralSchema<"success", undefined>;
|
|
450
450
|
readonly items: v.ArraySchema<v.ObjectSchema<{
|
|
451
451
|
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
|
|
452
|
-
readonly is_archived: v.
|
|
453
|
-
readonly in_trash: v.
|
|
452
|
+
readonly is_archived: v.BooleanSchema<undefined>;
|
|
453
|
+
readonly in_trash: v.BooleanSchema<undefined>;
|
|
454
454
|
readonly propertiesById: v.RecordSchema<v.StringSchema<undefined>, v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.BooleanSchema<undefined>, v.VariantSchema<"type", [v.ObjectSchema<{
|
|
455
455
|
readonly type: v.LiteralSchema<"date", undefined>;
|
|
456
456
|
readonly start_date: v.StringSchema<undefined>;
|
|
@@ -711,8 +711,8 @@ export declare const hostToSandboxMessageSchema: v.VariantSchema<"type", [v.Vari
|
|
|
711
711
|
}, undefined>], undefined>, undefined>;
|
|
712
712
|
readonly url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
713
713
|
readonly public_url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
714
|
-
readonly is_archived: v.
|
|
715
|
-
readonly in_trash: v.
|
|
714
|
+
readonly is_archived: v.BooleanSchema<undefined>;
|
|
715
|
+
readonly in_trash: v.BooleanSchema<undefined>;
|
|
716
716
|
}, undefined>;
|
|
717
717
|
}, undefined>, v.ObjectSchema<{
|
|
718
718
|
readonly type: v.LiteralSchema<"createPageResult", undefined>;
|
|
@@ -911,8 +911,8 @@ export declare const hostToSandboxMessageSchema: v.VariantSchema<"type", [v.Vari
|
|
|
911
911
|
}, undefined>], undefined>, undefined>;
|
|
912
912
|
readonly url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
913
913
|
readonly public_url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
914
|
-
readonly is_archived: v.
|
|
915
|
-
readonly in_trash: v.
|
|
914
|
+
readonly is_archived: v.BooleanSchema<undefined>;
|
|
915
|
+
readonly in_trash: v.BooleanSchema<undefined>;
|
|
916
916
|
}, undefined>;
|
|
917
917
|
}, undefined>, v.ObjectSchema<{
|
|
918
918
|
readonly type: v.LiteralSchema<"getPageResult", undefined>;
|
|
@@ -976,6 +976,20 @@ export declare const hostToSandboxMessageSchema: v.VariantSchema<"type", [v.Vari
|
|
|
976
976
|
readonly message: v.StringSchema<undefined>;
|
|
977
977
|
readonly isRetryable: v.BooleanSchema<undefined>;
|
|
978
978
|
}, undefined>;
|
|
979
|
+
}, undefined>], undefined>, v.VariantSchema<"status", [v.ObjectSchema<{
|
|
980
|
+
readonly type: v.LiteralSchema<"openPageResult", undefined>;
|
|
981
|
+
readonly requestId: v.StringSchema<undefined>;
|
|
982
|
+
readonly status: v.LiteralSchema<"success", undefined>;
|
|
983
|
+
readonly pageId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
|
|
984
|
+
}, undefined>, v.ObjectSchema<{
|
|
985
|
+
readonly type: v.LiteralSchema<"openPageResult", undefined>;
|
|
986
|
+
readonly requestId: v.StringSchema<undefined>;
|
|
987
|
+
readonly status: v.LiteralSchema<"error", undefined>;
|
|
988
|
+
readonly error: v.ObjectSchema<{
|
|
989
|
+
readonly code: v.StringSchema<undefined>;
|
|
990
|
+
readonly message: v.StringSchema<undefined>;
|
|
991
|
+
readonly isRetryable: v.BooleanSchema<undefined>;
|
|
992
|
+
}, undefined>;
|
|
979
993
|
}, undefined>], undefined>, v.VariantSchema<"status", [v.ObjectSchema<{
|
|
980
994
|
readonly type: v.LiteralSchema<"updatePageResult", undefined>;
|
|
981
995
|
readonly requestId: v.StringSchema<undefined>;
|
|
@@ -1164,8 +1178,8 @@ export declare const hostToSandboxMessageSchema: v.VariantSchema<"type", [v.Vari
|
|
|
1164
1178
|
}, undefined>], undefined>, undefined>;
|
|
1165
1179
|
readonly url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
1166
1180
|
readonly public_url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
1167
|
-
readonly is_archived: v.
|
|
1168
|
-
readonly in_trash: v.
|
|
1181
|
+
readonly is_archived: v.BooleanSchema<undefined>;
|
|
1182
|
+
readonly in_trash: v.BooleanSchema<undefined>;
|
|
1169
1183
|
}, undefined>;
|
|
1170
1184
|
}, undefined>, v.ObjectSchema<{
|
|
1171
1185
|
readonly type: v.LiteralSchema<"updatePageResult", undefined>;
|
|
@@ -1182,5 +1196,5 @@ export declare const hostToSandboxMessageSchema: v.VariantSchema<"type", [v.Vari
|
|
|
1182
1196
|
}, undefined>], undefined>;
|
|
1183
1197
|
export type HostToSandboxMessage = v.InferOutput<typeof hostToSandboxMessageSchema>;
|
|
1184
1198
|
export type PrimeableHostToSandboxMessage = Extract<HostToSandboxMessage, {
|
|
1185
|
-
type: "getPageResult" | "createPageResult" | "updatePageResult" | "getUserResult" | "listUsersResult" | "queryDataSourceResult";
|
|
1199
|
+
type: "getPageResult" | "openPageResult" | "createPageResult" | "updatePageResult" | "getUserResult" | "listUsersResult" | "queryDataSourceResult";
|
|
1186
1200
|
}>;
|
|
@@ -8,6 +8,7 @@ import { getUserResultMessageSchema } from "./getUser.js";
|
|
|
8
8
|
import { initMessageSchema } from "./init.js";
|
|
9
9
|
import { invalidSandboxMessageSchema } from "./invalidSandboxMessage.js";
|
|
10
10
|
import { listUsersResultMessageSchema } from "./listUsers.js";
|
|
11
|
+
import { openPageResultMessageSchema } from "./openPage.js";
|
|
11
12
|
import { pageChangedMessageSchema } from "./pageChanged.js";
|
|
12
13
|
import { parentChangedMessageSchema } from "./parentChanged.js";
|
|
13
14
|
import { queryDataSourceResultMessageSchema } from "./queryDataSourceResult.js";
|
|
@@ -29,6 +30,7 @@ export const hostToSandboxMessageSchema = v.variant("type", [
|
|
|
29
30
|
getPageResultMessageSchema,
|
|
30
31
|
getUserResultMessageSchema,
|
|
31
32
|
listUsersResultMessageSchema,
|
|
33
|
+
openPageResultMessageSchema,
|
|
32
34
|
updatePageResultMessageSchema,
|
|
33
35
|
invalidSandboxMessageSchema,
|
|
34
36
|
]);
|
|
@@ -33,7 +33,7 @@ export declare const initMessageSchema: v.VariantSchema<"status", [v.ObjectSchem
|
|
|
33
33
|
readonly initializationId: v.StringSchema<undefined>;
|
|
34
34
|
readonly status: v.LiteralSchema<"success", undefined>;
|
|
35
35
|
readonly theme: v.PicklistSchema<["light", "dark"], undefined>;
|
|
36
|
-
readonly contrastMode: v.
|
|
36
|
+
readonly contrastMode: v.PicklistSchema<["standard", "high"], undefined>;
|
|
37
37
|
readonly blockId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionBlockId">]>;
|
|
38
38
|
readonly parent: v.VariantSchema<"type", [v.ObjectSchema<{
|
|
39
39
|
readonly type: v.LiteralSchema<"page_id", undefined>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
-
import {
|
|
2
|
+
import { notionContrastModeSchema } from "../contrast.js";
|
|
3
3
|
import { notionDataSourceBindingsSchema } from "../dataSources/dataSource.js";
|
|
4
4
|
import { notionBlockIdSchema } from "../ids.js";
|
|
5
5
|
import { manifestSchema } from "../manifest.js";
|
|
@@ -38,8 +38,7 @@ export const initMessageSchema = v.variant("status", [
|
|
|
38
38
|
initializationId: v.string(),
|
|
39
39
|
status: v.literal("success"),
|
|
40
40
|
theme: notionThemeSchema,
|
|
41
|
-
|
|
42
|
-
contrastMode: v.optional(notionContrastModeSchema, DEFAULT_CONTRAST_MODE),
|
|
41
|
+
contrastMode: notionContrastModeSchema,
|
|
43
42
|
blockId: notionBlockIdSchema,
|
|
44
43
|
parent: notionParentSchema,
|
|
45
44
|
page: customBlockPageSchema,
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import type { CustomBlockErrorCode, CustomBlockErrorInfo } from "../errors.js";
|
|
3
|
+
export declare const openPageModeSchema: v.PicklistSchema<["side_peek", "center_peek"], undefined>;
|
|
4
|
+
export type OpenPageMode = v.InferOutput<typeof openPageModeSchema>;
|
|
5
|
+
export declare const customBlockOpenPageErrorCodeSchema: v.StringSchema<undefined>;
|
|
6
|
+
export type CustomBlockOpenPageErrorCode = CustomBlockErrorCode<"open_page_failed" | "page_access_failed" | "navigation_unavailable">;
|
|
7
|
+
export type CustomBlockOpenPageErrorInfo = CustomBlockErrorInfo<CustomBlockOpenPageErrorCode>;
|
|
8
|
+
export declare const customBlockOpenPageErrorInfoSchema: v.ObjectSchema<{
|
|
9
|
+
readonly code: v.StringSchema<undefined>;
|
|
10
|
+
readonly message: v.StringSchema<undefined>;
|
|
11
|
+
readonly isRetryable: v.BooleanSchema<undefined>;
|
|
12
|
+
}, undefined>;
|
|
13
|
+
/**
|
|
14
|
+
* Sandbox -> host: request host-owned navigation to a readable Notion page.
|
|
15
|
+
*/
|
|
16
|
+
export declare const openPageMessageSchema: v.ObjectSchema<{
|
|
17
|
+
readonly type: v.LiteralSchema<"openPage", undefined>;
|
|
18
|
+
readonly requestId: v.StringSchema<undefined>;
|
|
19
|
+
readonly pageId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
|
|
20
|
+
readonly mode: v.PicklistSchema<["side_peek", "center_peek"], undefined>;
|
|
21
|
+
}, undefined>;
|
|
22
|
+
export type OpenPageMessage = v.InferOutput<typeof openPageMessageSchema>;
|
|
23
|
+
export declare const openPageResultMessageSchema: v.VariantSchema<"status", [v.ObjectSchema<{
|
|
24
|
+
readonly type: v.LiteralSchema<"openPageResult", undefined>;
|
|
25
|
+
readonly requestId: v.StringSchema<undefined>;
|
|
26
|
+
readonly status: v.LiteralSchema<"success", undefined>;
|
|
27
|
+
readonly pageId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
|
|
28
|
+
}, undefined>, v.ObjectSchema<{
|
|
29
|
+
readonly type: v.LiteralSchema<"openPageResult", undefined>;
|
|
30
|
+
readonly requestId: v.StringSchema<undefined>;
|
|
31
|
+
readonly status: v.LiteralSchema<"error", undefined>;
|
|
32
|
+
readonly error: v.ObjectSchema<{
|
|
33
|
+
readonly code: v.StringSchema<undefined>;
|
|
34
|
+
readonly message: v.StringSchema<undefined>;
|
|
35
|
+
readonly isRetryable: v.BooleanSchema<undefined>;
|
|
36
|
+
}, undefined>;
|
|
37
|
+
}, undefined>], undefined>;
|
|
38
|
+
export type OpenPageResultMessage = v.InferOutput<typeof openPageResultMessageSchema>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import { notionPageIdSchema } from "../ids.js";
|
|
3
|
+
export const openPageModeSchema = v.picklist(["side_peek", "center_peek"]);
|
|
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 customBlockOpenPageErrorCodeSchema = v.string();
|
|
7
|
+
export const customBlockOpenPageErrorInfoSchema = v.object({
|
|
8
|
+
code: customBlockOpenPageErrorCodeSchema,
|
|
9
|
+
message: v.string(),
|
|
10
|
+
isRetryable: v.boolean(),
|
|
11
|
+
});
|
|
12
|
+
/**
|
|
13
|
+
* Sandbox -> host: request host-owned navigation to a readable Notion page.
|
|
14
|
+
*/
|
|
15
|
+
export const openPageMessageSchema = v.object({
|
|
16
|
+
type: v.literal("openPage"),
|
|
17
|
+
requestId: v.string(),
|
|
18
|
+
pageId: notionPageIdSchema,
|
|
19
|
+
mode: openPageModeSchema,
|
|
20
|
+
});
|
|
21
|
+
export const openPageResultMessageSchema = v.variant("status", [
|
|
22
|
+
v.object({
|
|
23
|
+
type: v.literal("openPageResult"),
|
|
24
|
+
requestId: v.string(),
|
|
25
|
+
status: v.literal("success"),
|
|
26
|
+
pageId: notionPageIdSchema,
|
|
27
|
+
}),
|
|
28
|
+
v.object({
|
|
29
|
+
type: v.literal("openPageResult"),
|
|
30
|
+
requestId: v.string(),
|
|
31
|
+
status: v.literal("error"),
|
|
32
|
+
error: customBlockOpenPageErrorInfoSchema,
|
|
33
|
+
}),
|
|
34
|
+
]);
|
|
@@ -17,8 +17,8 @@ export declare const queryDataSourceResultMessageSchema: v.VariantSchema<"status
|
|
|
17
17
|
readonly status: v.LiteralSchema<"success", undefined>;
|
|
18
18
|
readonly items: v.ArraySchema<v.ObjectSchema<{
|
|
19
19
|
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
|
|
20
|
-
readonly is_archived: v.
|
|
21
|
-
readonly in_trash: v.
|
|
20
|
+
readonly is_archived: v.BooleanSchema<undefined>;
|
|
21
|
+
readonly in_trash: v.BooleanSchema<undefined>;
|
|
22
22
|
readonly propertiesById: v.RecordSchema<v.StringSchema<undefined>, v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.BooleanSchema<undefined>, v.VariantSchema<"type", [v.ObjectSchema<{
|
|
23
23
|
readonly type: v.LiteralSchema<"date", undefined>;
|
|
24
24
|
readonly start_date: v.StringSchema<undefined>;
|
|
@@ -573,6 +573,11 @@ export declare const sandboxToHostMessageSchema: v.VariantSchema<"type", [v.Vari
|
|
|
573
573
|
readonly requestId: v.StringSchema<undefined>;
|
|
574
574
|
readonly startCursor: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
575
575
|
readonly pageSize: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
576
|
+
}, undefined>, v.ObjectSchema<{
|
|
577
|
+
readonly type: v.LiteralSchema<"openPage", undefined>;
|
|
578
|
+
readonly requestId: v.StringSchema<undefined>;
|
|
579
|
+
readonly pageId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
|
|
580
|
+
readonly mode: v.PicklistSchema<["side_peek", "center_peek"], undefined>;
|
|
576
581
|
}, undefined>, v.ObjectSchema<{
|
|
577
582
|
readonly type: v.LiteralSchema<"updatePage", undefined>;
|
|
578
583
|
readonly requestId: v.StringSchema<undefined>;
|
|
@@ -6,6 +6,7 @@ import { getUserMessageSchema } from "./getUser.js";
|
|
|
6
6
|
import { initResultMessageSchema } from "./initResult.js";
|
|
7
7
|
import { invalidHostMessageSchema } from "./invalidHostMessage.js";
|
|
8
8
|
import { listUsersMessageSchema } from "./listUsers.js";
|
|
9
|
+
import { openPageMessageSchema } from "./openPage.js";
|
|
9
10
|
import { queryDataSourceMessageSchema } from "./queryDataSource.js";
|
|
10
11
|
import { resizeMessageSchema } from "./resize.js";
|
|
11
12
|
import { unsubscribeDataSourceQueryMessageSchema } from "./unsubscribeDataSourceQuery.js";
|
|
@@ -23,6 +24,7 @@ export const sandboxToHostMessageSchema = v.variant("type", [
|
|
|
23
24
|
getPageMessageSchema,
|
|
24
25
|
getUserMessageSchema,
|
|
25
26
|
listUsersMessageSchema,
|
|
27
|
+
openPageMessageSchema,
|
|
26
28
|
updatePageMessageSchema,
|
|
27
29
|
resizeMessageSchema,
|
|
28
30
|
invalidHostMessageSchema,
|
|
@@ -199,8 +199,8 @@ export declare const updatePageResultMessageSchema: v.VariantSchema<"status", [v
|
|
|
199
199
|
}, undefined>], undefined>, undefined>;
|
|
200
200
|
readonly url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
201
201
|
readonly public_url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
202
|
-
readonly is_archived: v.
|
|
203
|
-
readonly in_trash: v.
|
|
202
|
+
readonly is_archived: v.BooleanSchema<undefined>;
|
|
203
|
+
readonly in_trash: v.BooleanSchema<undefined>;
|
|
204
204
|
}, undefined>;
|
|
205
205
|
}, undefined>, v.ObjectSchema<{
|
|
206
206
|
readonly type: v.LiteralSchema<"updatePageResult", undefined>;
|
|
@@ -596,9 +596,9 @@ export declare const notionPageSchema: v.ObjectSchema<{
|
|
|
596
596
|
readonly url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
597
597
|
readonly public_url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
598
598
|
/** Whether the page or an ancestor is archived. */
|
|
599
|
-
readonly is_archived: v.
|
|
599
|
+
readonly is_archived: v.BooleanSchema<undefined>;
|
|
600
600
|
/** Whether the page or an ancestor is in Trash. */
|
|
601
|
-
readonly in_trash: v.
|
|
601
|
+
readonly in_trash: v.BooleanSchema<undefined>;
|
|
602
602
|
}, undefined>;
|
|
603
603
|
export type NotionPage = v.InferOutput<typeof notionPageSchema>;
|
|
604
604
|
export {};
|
|
@@ -207,9 +207,8 @@ export const notionPageSchema = v.object({
|
|
|
207
207
|
cover: v.optional(notionPageCoverSchema),
|
|
208
208
|
url: v.optional(v.string()),
|
|
209
209
|
public_url: v.optional(v.string()),
|
|
210
|
-
// TODO(custom-blocks): Require is_archived and in_trash in bridge protocol v4.
|
|
211
210
|
/** Whether the page or an ancestor is archived. */
|
|
212
|
-
is_archived: v.
|
|
211
|
+
is_archived: v.boolean(),
|
|
213
212
|
/** Whether the page or an ancestor is in Trash. */
|
|
214
|
-
in_trash: v.
|
|
213
|
+
in_trash: v.boolean(),
|
|
215
214
|
});
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Increase this value for breaking wire changes. Hosts can continue to accept
|
|
4
4
|
* older versions, so this value does not set the minimum or maximum they accept.
|
|
5
5
|
*/
|
|
6
|
-
export declare const LATEST_BRIDGE_PROTOCOL_VERSION =
|
|
6
|
+
export declare const LATEST_BRIDGE_PROTOCOL_VERSION = 4;
|
package/package.json
CHANGED
|
@@ -22,6 +22,10 @@ import type {
|
|
|
22
22
|
ListUsersMessage,
|
|
23
23
|
ListUsersResultMessage,
|
|
24
24
|
} from "@notionhq/custom-blocks-protocol/messages/listUsers.js"
|
|
25
|
+
import type {
|
|
26
|
+
OpenPageMessage,
|
|
27
|
+
OpenPageResultMessage,
|
|
28
|
+
} from "@notionhq/custom-blocks-protocol/messages/openPage.js"
|
|
25
29
|
import type { PageChangedMessage } from "@notionhq/custom-blocks-protocol/messages/pageChanged.js"
|
|
26
30
|
import type { ParentChangedMessage } from "@notionhq/custom-blocks-protocol/messages/parentChanged.js"
|
|
27
31
|
import type { QueryDataSourceMessage } from "@notionhq/custom-blocks-protocol/messages/queryDataSource.js"
|
|
@@ -266,6 +270,19 @@ export function createCustomBlockHost(
|
|
|
266
270
|
post(result)
|
|
267
271
|
}
|
|
268
272
|
|
|
273
|
+
async function handleOpenPage(message: OpenPageMessage) {
|
|
274
|
+
if (handlers.openPage === undefined) {
|
|
275
|
+
return
|
|
276
|
+
}
|
|
277
|
+
const response = await handlers.openPage(message)
|
|
278
|
+
const result: OpenPageResultMessage = {
|
|
279
|
+
type: "openPageResult",
|
|
280
|
+
requestId: message.requestId,
|
|
281
|
+
...response,
|
|
282
|
+
}
|
|
283
|
+
post(result)
|
|
284
|
+
}
|
|
285
|
+
|
|
269
286
|
async function handleUpdatePage(message: UpdatePageMessage) {
|
|
270
287
|
if (handlers.updatePage === undefined) {
|
|
271
288
|
return
|
|
@@ -379,6 +396,7 @@ export function createCustomBlockHost(
|
|
|
379
396
|
querySubscriptions.unsubscribe(message.subscriptionId),
|
|
380
397
|
onCreatePage: handleCreatePage,
|
|
381
398
|
onGetPage: handleGetPage,
|
|
399
|
+
onOpenPage: handleOpenPage,
|
|
382
400
|
onGetUser: handleGetUser,
|
|
383
401
|
onListUsers: handleListUsers,
|
|
384
402
|
onUpdatePage: handleUpdatePage,
|
package/src/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ export type { CreatePageMessage } from "@notionhq/custom-blocks-protocol/message
|
|
|
2
2
|
export type { GetPageMessage } from "@notionhq/custom-blocks-protocol/messages/getPage.js"
|
|
3
3
|
export type { GetUserMessage } from "@notionhq/custom-blocks-protocol/messages/getUser.js"
|
|
4
4
|
export type { ListUsersMessage } from "@notionhq/custom-blocks-protocol/messages/listUsers.js"
|
|
5
|
+
export type { OpenPageMessage } from "@notionhq/custom-blocks-protocol/messages/openPage.js"
|
|
5
6
|
export type { QueryDataSourceMessage } from "@notionhq/custom-blocks-protocol/messages/queryDataSource.js"
|
|
6
7
|
export type { ResizeMessage } from "@notionhq/custom-blocks-protocol/messages/resize.js"
|
|
7
8
|
export type { UpdatePageMessage } from "@notionhq/custom-blocks-protocol/messages/updatePage.js"
|
|
@@ -34,10 +35,12 @@ export type {
|
|
|
34
35
|
CustomBlockHostInitializationFailure,
|
|
35
36
|
CustomBlockHostListUsersResult,
|
|
36
37
|
CustomBlockHostLogDirection,
|
|
38
|
+
CustomBlockHostOpenPageResult,
|
|
37
39
|
CustomBlockHostUpdatePageResult,
|
|
38
40
|
GetPageMessageInput,
|
|
39
41
|
GetUserMessageInput,
|
|
40
42
|
ListUsersMessageInput,
|
|
43
|
+
OpenPageMessageInput,
|
|
41
44
|
QueryDataSourceMessageInput,
|
|
42
45
|
ResizeMessageInput,
|
|
43
46
|
UpdatePageMessageInput,
|
|
@@ -6,6 +6,7 @@ import type { HostToSandboxMessage } from "@notionhq/custom-blocks-protocol/mess
|
|
|
6
6
|
import type { InitResultMessage } from "@notionhq/custom-blocks-protocol/messages/initResult.js"
|
|
7
7
|
import { isInitHandshakeMessage } from "@notionhq/custom-blocks-protocol/messages/isInitHandshakeMessage.js"
|
|
8
8
|
import type { ListUsersMessage } from "@notionhq/custom-blocks-protocol/messages/listUsers.js"
|
|
9
|
+
import type { OpenPageMessage } from "@notionhq/custom-blocks-protocol/messages/openPage.js"
|
|
9
10
|
import type { QueryDataSourceMessage } from "@notionhq/custom-blocks-protocol/messages/queryDataSource.js"
|
|
10
11
|
import type { ResizeMessage } from "@notionhq/custom-blocks-protocol/messages/resize.js"
|
|
11
12
|
import { sandboxToHostMessageSchema } from "@notionhq/custom-blocks-protocol/messages/sandboxToHost.js"
|
|
@@ -38,6 +39,7 @@ export type SandboxMessageRouterOptions = {
|
|
|
38
39
|
message: UnsubscribeDataSourceQueryMessage,
|
|
39
40
|
) => void
|
|
40
41
|
onCreatePage: (message: CreatePageMessage) => void | Promise<void>
|
|
42
|
+
onOpenPage: (message: OpenPageMessage) => void | Promise<void>
|
|
41
43
|
onGetPage: (message: GetPageMessage) => void | Promise<void>
|
|
42
44
|
onGetUser: (message: GetUserMessage) => void | Promise<void>
|
|
43
45
|
onListUsers: (message: ListUsersMessage) => void | Promise<void>
|
|
@@ -62,6 +64,7 @@ export function createSandboxMessageRouter(
|
|
|
62
64
|
onUnsubscribeDataSourceQuery,
|
|
63
65
|
onCreatePage,
|
|
64
66
|
onGetPage,
|
|
67
|
+
onOpenPage,
|
|
65
68
|
onGetUser,
|
|
66
69
|
onListUsers,
|
|
67
70
|
onUpdatePage,
|
|
@@ -151,6 +154,9 @@ export function createSandboxMessageRouter(
|
|
|
151
154
|
case "createPage":
|
|
152
155
|
void onCreatePage(message)
|
|
153
156
|
return
|
|
157
|
+
case "openPage":
|
|
158
|
+
void onOpenPage(message)
|
|
159
|
+
return
|
|
154
160
|
case "getPage":
|
|
155
161
|
void onGetPage(message)
|
|
156
162
|
return
|
package/src/messages/types.ts
CHANGED
|
@@ -27,6 +27,12 @@ import type {
|
|
|
27
27
|
listUsersMessageSchema,
|
|
28
28
|
} from "@notionhq/custom-blocks-protocol/messages/listUsers.js"
|
|
29
29
|
import type { BridgeMessagePayload } from "@notionhq/custom-blocks-protocol/messages/messagePayload.js"
|
|
30
|
+
import type {
|
|
31
|
+
CustomBlockOpenPageErrorInfo,
|
|
32
|
+
OpenPageMessage,
|
|
33
|
+
OpenPageResultMessage,
|
|
34
|
+
openPageMessageSchema,
|
|
35
|
+
} from "@notionhq/custom-blocks-protocol/messages/openPage.js"
|
|
30
36
|
import type {
|
|
31
37
|
QueryDataSourceMessage,
|
|
32
38
|
queryDataSourceMessageSchema,
|
|
@@ -73,6 +79,11 @@ export type CustomBlockHostListUsersResult = BridgeMessagePayload<
|
|
|
73
79
|
CustomBlockListUsersErrorInfo
|
|
74
80
|
>
|
|
75
81
|
|
|
82
|
+
export type CustomBlockHostOpenPageResult = BridgeMessagePayload<
|
|
83
|
+
OpenPageResultMessage,
|
|
84
|
+
CustomBlockOpenPageErrorInfo
|
|
85
|
+
>
|
|
86
|
+
|
|
76
87
|
export type CustomBlockHostHandlers = {
|
|
77
88
|
queryDataSource: (
|
|
78
89
|
message: QueryDataSourceMessage,
|
|
@@ -89,6 +100,9 @@ export type CustomBlockHostHandlers = {
|
|
|
89
100
|
listUsers?: (
|
|
90
101
|
message: ListUsersMessage,
|
|
91
102
|
) => MaybePromise<CustomBlockHostListUsersResult>
|
|
103
|
+
openPage?: (
|
|
104
|
+
message: OpenPageMessage,
|
|
105
|
+
) => MaybePromise<CustomBlockHostOpenPageResult>
|
|
92
106
|
updatePage?: (
|
|
93
107
|
message: UpdatePageMessage,
|
|
94
108
|
) => MaybePromise<CustomBlockHostUpdatePageResult>
|
|
@@ -109,6 +123,8 @@ export type GetUserMessageInput = InferInput<typeof getUserMessageSchema>
|
|
|
109
123
|
|
|
110
124
|
export type ListUsersMessageInput = InferInput<typeof listUsersMessageSchema>
|
|
111
125
|
|
|
126
|
+
export type OpenPageMessageInput = InferInput<typeof openPageMessageSchema>
|
|
127
|
+
|
|
112
128
|
export type QueryDataSourceMessageInput = InferInput<
|
|
113
129
|
typeof queryDataSourceMessageSchema
|
|
114
130
|
>
|