@notionhq/custom-blocks-host 0.2.1 → 0.2.3

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 CHANGED
@@ -155,6 +155,12 @@ TypeScript infers request types for handlers passed to `createCustomBlockHost()`
155
155
  defined handlers and helpers, import the corresponding request and page-property types directly from
156
156
  `@notionhq/custom-blocks-host`.
157
157
 
158
+ Adapters can pass plain string IDs in initial state, live-state setters, and handler results such as
159
+ `CustomBlockHostGetPageResult`. The host validates these values before using or sending them.
160
+ Parsing assigns protocol ID brands for internal type checking and applies schema defaults, such as
161
+ an empty manifest data source `properties` map. Brands distinguish ID kinds in TypeScript. They do
162
+ not check record existence or access.
163
+
158
164
  Request types such as `GetPageMessage` describe validated messages that handlers receive. The
159
165
  corresponding `*MessageInput` types accept plain string IDs for adapters and test fixtures that
160
166
  construct requests. These types do not validate values at runtime. The host runtime validates
@@ -182,7 +188,7 @@ Derive bindings from the successful `connect` message inside `getInitialState` a
182
188
 
183
189
  Set `sandboxOrigin` to the iframe's exact origin. The runtime targets outbound messages to that
184
190
  origin and accepts inbound messages only from that iframe and origin. The runtime accepts
185
- `noConnectTimeoutMs`, `initialStateTimeoutMs`, and `noInitResultTimeoutMs`; all default to five
191
+ `noConnectTimeoutMs`, `initialStateTimeoutMs`, and `noInitResultTimeoutMs`. All default to five
186
192
  seconds.
187
193
 
188
194
  ### Initialization and malformed messages
@@ -1,10 +1,11 @@
1
- import type { NotionContrastMode } from "./protocol/contrast.js";
2
- import type { NotionDataSourceId } from "./protocol/ids.js";
1
+ import type { notionContrastModeSchema } from "./protocol/contrast.js";
2
+ import { notionDataSourceIdSchema } from "./protocol/ids.js";
3
3
  import type { CustomBlockManifest } from "./protocol/manifest.js";
4
- import type { CustomBlockPage } from "./protocol/pages/page.js";
5
- import type { NotionParent } from "./protocol/parent.js";
6
- import type { NotionTheme } from "./protocol/theme.js";
7
- import type { NotionUser } from "./protocol/users/user.js";
4
+ import type { customBlockPageSchema } from "./protocol/pages/page.js";
5
+ import type { notionParentSchema } from "./protocol/parent.js";
6
+ import type { notionThemeSchema } from "./protocol/theme.js";
7
+ import type { notionUserSchema } from "./protocol/users/user.js";
8
+ import type { InferInput } from "valibot";
8
9
  import type { CustomBlockHostDataSourcesPayload, CustomBlockHostGetInitialState } from "./lifecycle/types.js";
9
10
  import type { CustomBlockHostFailure, CustomBlockHostHandlers, CustomBlockHostLogDirection } from "./messages/types.js";
10
11
  export type CustomBlockHostOptions = {
@@ -39,14 +40,14 @@ export type CustomBlockHostOptions = {
39
40
  };
40
41
  export type CustomBlockHostHandle = {
41
42
  stop: () => void;
42
- setTheme: (theme: NotionTheme) => void;
43
- setContrastMode: (contrastMode: NotionContrastMode) => void;
44
- setParent: (parent: NotionParent) => void;
45
- setPage: (page: CustomBlockPage) => void;
43
+ setTheme: (theme: InferInput<typeof notionThemeSchema>) => void;
44
+ setContrastMode: (contrastMode: InferInput<typeof notionContrastModeSchema>) => void;
45
+ setParent: (parent: InferInput<typeof notionParentSchema>) => void;
46
+ setPage: (page: InferInput<typeof customBlockPageSchema>) => void;
46
47
  setDataSources: (dataSources: CustomBlockHostDataSourcesPayload) => void;
47
- setCurrentUser: (currentUser: NotionUser) => void;
48
+ setCurrentUser: (currentUser: InferInput<typeof notionUserSchema>) => void;
48
49
  refreshQuery: (args: {
49
- dataSourceId: NotionDataSourceId;
50
+ dataSourceId: InferInput<typeof notionDataSourceIdSchema>;
50
51
  }) => void;
51
52
  };
52
53
  export declare function createCustomBlockHost(options: CustomBlockHostOptions): CustomBlockHostHandle;
@@ -1 +1 @@
1
- {"version":3,"file":"createCustomBlockHost.d.ts","sourceRoot":"","sources":["../src/createCustomBlockHost.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAA;AAEtF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAA;AACjF,OAAO,KAAK,EAAE,mBA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E,cAAc,EAAE,CAAC,WAAW,EAAE,iCAAiC,KAAK,IAAI,CAAA;IACxE,cAAc,EAAE,CAAC,WAAW,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,KAAK,IAAI,CAAA;IAC1E,YAAY,EAAE,CAAC,IAAI,EAAE;QACpB,YAAY,EAAE,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAA;KACzD,KAAK,IAAI,CAAA;CACV,CAAA;AAQD,wBAAgB,qBAAqB,CACpC,OAAO,EAAE,sBAAsB,GAC7B,qBAAqB,CAgYvB"}
@@ -1,7 +1,14 @@
1
+ import { notionDataSourceBindingsSchema } from "./protocol/dataSources/dataSource.js";
2
+ import { notionDataSourceIdSchema } from "./protocol/ids.js";
3
+ import { manifestSchema } from "./protocol/manifest.js";
4
+ import { hostToSandboxMessageSchema, } from "./protocol/messages/hostToSandbox.js";
5
+ import { initMessageSchema, } from "./protocol/messages/init.js";
1
6
  import { LATEST_BRIDGE_PROTOCOL_VERSION } from "./protocol/protocolVersion.js";
7
+ import * as v from "valibot";
2
8
  import { initErrorForFailureReason } from "./lifecycle/initErrors.js";
3
9
  import { createInitializationController } from "./lifecycle/initializationController.js";
4
10
  import { normalizeHostToSandboxMessage } from "./lifecycle/normalizeHostToSandboxMessage.js";
11
+ import { customBlockHostInitialStateSchema } from "./lifecycle/types.js";
5
12
  import { createSandboxMessageRouter } from "./messages/sandboxMessageRouter.js";
6
13
  import { MIN_HOST_SUPPORTED_BRIDGE_PROTOCOL_VERSION } from "./protocolVersion.js";
7
14
  import { QuerySubscriptions, } from "./queries/querySubscriptions.js";
@@ -47,7 +54,7 @@ export function createCustomBlockHost(options) {
47
54
  iframe.contentWindow?.postMessage(sandboxMessage, sandboxOrigin);
48
55
  }
49
56
  function sendInitMessage(message) {
50
- postToSandbox(message);
57
+ postToSandbox(v.parse(initMessageSchema, message));
51
58
  }
52
59
  function sendNack(message) {
53
60
  postToSandbox(message);
@@ -56,7 +63,7 @@ export function createCustomBlockHost(options) {
56
63
  const status = initializationController.status;
57
64
  switch (status) {
58
65
  case "initialized":
59
- postToSandbox(message);
66
+ postToSandbox(v.parse(hostToSandboxMessageSchema, message));
60
67
  return;
61
68
  // Send state updates and handler results only after initialization succeeds.
62
69
  case "waitingForConnect":
@@ -78,12 +85,11 @@ export function createCustomBlockHost(options) {
78
85
  return;
79
86
  }
80
87
  const response = await handler(message);
81
- const result = {
88
+ sendInitializedMessage({
82
89
  type: `${message.type}Result`,
83
90
  requestId: message.requestId,
84
91
  ...response,
85
- };
86
- sendInitializedMessage(result);
92
+ });
87
93
  }
88
94
  function postQueryDataSourceResult(args) {
89
95
  const message = args.response.status === "error"
@@ -195,10 +201,17 @@ export function createCustomBlockHost(options) {
195
201
  if (result.status === "error") {
196
202
  return result;
197
203
  }
198
- manifest = result.initialState.manifest;
204
+ manifest = v.parse(manifestSchema, result.initialState.manifest);
199
205
  onManifest?.(manifest);
200
- const initialState = { ...result.initialState, ...pendingState };
206
+ const initialStateInput = {
207
+ ...result.initialState,
208
+ ...pendingState,
209
+ };
201
210
  pendingState = {};
211
+ const initialState = {
212
+ ...v.parse(v.omit(customBlockHostInitialStateSchema, ["manifest"]), initialStateInput),
213
+ manifest,
214
+ };
202
215
  if (sandboxBridgeProtocolVersion <
203
216
  BRIDGE_PROTOCOL_VERSION_INTRODUCING_UNAVAILABLE_PAGE &&
204
217
  initialState.page.type === "unavailable") {
@@ -279,23 +292,27 @@ export function createCustomBlockHost(options) {
279
292
  updateHostState({ currentUser });
280
293
  },
281
294
  setDataSources(dataSources) {
295
+ const normalizedDataSources = {
296
+ bindings: v.parse(notionDataSourceBindingsSchema, dataSources.bindings),
297
+ };
282
298
  if (initializationController.hasConnectedSandbox &&
283
299
  manifest !== undefined &&
284
- getBindingErrorCode(manifest, dataSources) !== undefined) {
300
+ getBindingErrorCode(manifest, normalizedDataSources) !== undefined) {
285
301
  emit("warn", {
286
302
  message: "Ignored invalid data source bindings update",
287
- payload: dataSources,
303
+ payload: normalizedDataSources,
288
304
  });
289
305
  return;
290
306
  }
291
- activeDataSources = dataSources;
292
- updateHostState({ dataSources });
307
+ activeDataSources = normalizedDataSources;
308
+ updateHostState({ dataSources: normalizedDataSources });
293
309
  },
294
310
  refreshQuery({ dataSourceId }) {
295
311
  if (initializationController.status !== "initialized") {
296
312
  return;
297
313
  }
298
- const refreshes = querySubscriptions.refresh(dataSourceId);
314
+ const normalizedDataSourceId = v.parse(notionDataSourceIdSchema, dataSourceId);
315
+ const refreshes = querySubscriptions.refresh(normalizedDataSourceId);
299
316
  if (refreshes.length === 0) {
300
317
  emit("warn", `No active query exists for data source "${dataSourceId}"`);
301
318
  return;
@@ -1,11 +1,12 @@
1
1
  import type { ConnectMessage } from "../protocol/messages/connect.js";
2
- import type { CustomBlockInitErrorInfo, InitMessage } from "../protocol/messages/init.js";
2
+ import type { CustomBlockInitErrorInfo, initMessageSchema } from "../protocol/messages/init.js";
3
3
  import type { InitResultMessage } from "../protocol/messages/initResult.js";
4
+ import type { InferInput } from "valibot";
4
5
  import type { CustomBlockHostFailure } from "../messages/types.js";
5
6
  import type { ConnectSuccessMessage, CustomBlockHostInitialStateResult, InitStatus } from "./types.js";
6
7
  export type InitializationControllerOptions = {
7
8
  prepareInit: (connect: ConnectSuccessMessage) => Promise<CustomBlockHostInitialStateResult>;
8
- sendInitMessage: (message: InitMessage) => void;
9
+ sendInitMessage: (message: InferInput<typeof initMessageSchema>) => void;
9
10
  warn: (payload: unknown) => void;
10
11
  flushPendingHostStateChanges: () => void;
11
12
  minBridgeProtocolVersion: number;
@@ -1 +1 @@
1
- {"version":3,"file":"initializationController.d.ts","sourceRoot":"","sources":["../../src/lifecycle/initializationController.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAA;AAC1F,OAAO,KAAK,EACX,wBAAwB,EACxB,WAAW,EACX,MAAM,mDAAmD,CAAA;AAC1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yDA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MAAM,CAAA;IACxB,uBAAuB,EAAE,CAAC,IAAI,EAAE;QAC/B,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAA;QACpC,KAAK,EAAE,wBAAwB,CAAA;KAC/B,KAAK,IAAI,CAAA;IACV,YAAY,EAAE,MAAM,IAAI,CAAA;IACxB,IAAI,EAAE,MAAM,IAAI,CAAA;CAChB,CAAA;AAED,wBAAgB,8BAA8B,CAC7C,OAAO,EAAE,+BAA+B,GACtC,wBAAwB,CAiU1B"}
1
+ {"version":3,"file":"initializationController.d.ts","sourceRoot":"","sources":["../../src/lifecycle/initializationController.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAA;AAC1F,OAAO,KAAK,EACX,wBAAwB,EACxB,iBAAiB,EACjB,MAAM,mDAAmD,CAAA;AAC1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAA;AAChG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAIlE,OAAO,KAAK,EACX,qBAAqB,EACrB,iCAAiC,EACjC,UAAU,EACV,MAAM,YAAY,CAAA;AAMnB,MAAM,MAAM,+BAA+B,GAAG;IAC7C,WAAW,EAAE,CACZ,OAAO,EAAE,qBAAqB,KAC1B,OAAO,CAAC,iCAAiC,CAAC,CAAA;IAC/C,eAAe,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,KAAK,IAAI,CAAA;IACxE,IAAI,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;IAChC,4BAA4B,EAAE,MAAM,IAAI,CAAA;IACxC,wBAAwB,EAAE,MAAM,CAAA;IAChC,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,mBAAmB,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,IAAI,CAAA;IAC5D,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,IAAI,CAAA;IACnD,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,IAAI,CAAA;CACnD,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG;IACtC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAA;IAC3B,QAAQ,CAAC,mBAAmB,EAAE,OAAO,CAAA;IACrC,aAAa,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,CAAA;IAChD,gBAAgB,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,IAAI,CAAA;IACtD,oBAAoB,EAAE,CAAC,IAAI,EAAE;QAC5B,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAA;QACpC,KAAK,EAAE,wBAAwB,CAAA;QAC/B,qBAAqB,EAAE,MAAM,GAAG,SAAS,CAAA;KACzC,KAAK,SAAS,GAAG,MAAM,CAAA;IACxB,uBAAuB,EAAE,CAAC,IAAI,EAAE;QAC/B,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAA;QACpC,KAAK,EAAE,wBAAwB,CAAA;KAC/B,KAAK,IAAI,CAAA;IACV,YAAY,EAAE,MAAM,IAAI,CAAA;IACxB,IAAI,EAAE,MAAM,IAAI,CAAA;CAChB,CAAA;AAED,wBAAgB,8BAA8B,CAC7C,OAAO,EAAE,+BAA+B,GACtC,wBAAwB,CAiU1B"}
@@ -1,13 +1,7 @@
1
- import type { NotionContrastMode } from "../protocol/contrast.js";
2
- import type { NotionDataSourceBindings } from "../protocol/dataSources/dataSource.js";
3
- import type { NotionBlockId } from "../protocol/ids.js";
4
- import type { CustomBlockManifest } from "../protocol/manifest.js";
1
+ import { notionDataSourceBindingsSchema } from "../protocol/dataSources/dataSource.js";
5
2
  import type { ConnectMessage } from "../protocol/messages/connect.js";
6
3
  import type { CustomBlockInitErrorInfo } from "../protocol/messages/init.js";
7
- import type { CustomBlockPage } from "../protocol/pages/page.js";
8
- import type { NotionParent } from "../protocol/parent.js";
9
- import type { NotionTheme } from "../protocol/theme.js";
10
- import type { NotionUser } from "../protocol/users/user.js";
4
+ import * as v from "valibot";
11
5
  export type ConnectSuccessMessage = Extract<ConnectMessage, {
12
6
  status: "success";
13
7
  }>;
@@ -26,22 +20,239 @@ export type InitStatus =
26
20
  /** The host is stopped and no longer sends or accepts sandbox messages. */
27
21
  | "stopped";
28
22
  export type CustomBlockHostDataSourcesPayload = {
29
- bindings: NotionDataSourceBindings;
23
+ bindings: v.InferInput<typeof notionDataSourceBindingsSchema>;
30
24
  };
31
- export type CustomBlockHostInitialState = {
32
- theme: NotionTheme;
25
+ export type CustomBlockHostNormalizedDataSourcesPayload = {
26
+ bindings: v.InferOutput<typeof notionDataSourceBindingsSchema>;
27
+ };
28
+ export declare const customBlockHostInitialStateSchema: v.ObjectSchema<{
29
+ readonly theme: v.PicklistSchema<["light", "dark"], undefined>;
33
30
  /**
34
31
  * Defaults to standard for existing host integrations.
35
32
  * TODO(custom-blocks): Make this required when MIN_HOST_SUPPORTED_BRIDGE_PROTOCOL_VERSION increases to 4.
36
33
  */
37
- contrastMode?: NotionContrastMode;
38
- blockId: NotionBlockId;
39
- parent: NotionParent;
40
- page: CustomBlockPage;
41
- manifest: CustomBlockManifest;
42
- dataSources: CustomBlockHostDataSourcesPayload;
43
- currentUser: NotionUser;
44
- };
34
+ readonly contrastMode: v.OptionalSchema<v.PicklistSchema<["standard", "high"], undefined>, undefined>;
35
+ readonly blockId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionBlockId">]>;
36
+ readonly parent: v.VariantSchema<"type", [v.ObjectSchema<{
37
+ readonly type: v.LiteralSchema<"page_id", undefined>;
38
+ readonly page_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
39
+ }, undefined>, v.ObjectSchema<{
40
+ readonly type: v.LiteralSchema<"data_source_id", undefined>;
41
+ readonly data_source_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>;
42
+ }, undefined>, v.ObjectSchema<{
43
+ readonly type: v.LiteralSchema<"workspace", undefined>;
44
+ readonly workspace: v.LiteralSchema<true, undefined>;
45
+ }, undefined>, v.ObjectSchema<{
46
+ readonly type: v.LiteralSchema<"block_id", undefined>;
47
+ readonly block_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionBlockId">]>;
48
+ }, undefined>, v.ObjectSchema<{
49
+ readonly type: v.LiteralSchema<"agent_id", undefined>;
50
+ readonly agent_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionAgentId">]>;
51
+ }, undefined>, v.ObjectSchema<{
52
+ readonly type: v.LiteralSchema<"unavailable", undefined>;
53
+ }, undefined>], undefined>;
54
+ readonly page: v.VariantSchema<"type", [v.ObjectSchema<{
55
+ readonly type: v.LiteralSchema<"unavailable", undefined>;
56
+ }, undefined>, v.ObjectSchema<{
57
+ readonly type: v.LiteralSchema<"page", undefined>;
58
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
59
+ readonly parent: v.VariantSchema<"type", [v.ObjectSchema<{
60
+ readonly type: v.LiteralSchema<"page_id", undefined>;
61
+ readonly page_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
62
+ }, undefined>, v.ObjectSchema<{
63
+ readonly type: v.LiteralSchema<"data_source_id", undefined>;
64
+ readonly data_source_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>;
65
+ }, undefined>, v.ObjectSchema<{
66
+ readonly type: v.LiteralSchema<"workspace", undefined>;
67
+ readonly workspace: v.LiteralSchema<true, undefined>;
68
+ }, undefined>, v.ObjectSchema<{
69
+ readonly type: v.LiteralSchema<"block_id", undefined>;
70
+ readonly block_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionBlockId">]>;
71
+ }, undefined>, v.ObjectSchema<{
72
+ readonly type: v.LiteralSchema<"agent_id", undefined>;
73
+ readonly agent_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionAgentId">]>;
74
+ }, undefined>, v.ObjectSchema<{
75
+ readonly type: v.LiteralSchema<"unavailable", undefined>;
76
+ }, undefined>], undefined>;
77
+ }, undefined>], undefined>;
78
+ readonly manifest: v.ObjectSchema<{
79
+ readonly version: v.LiteralSchema<1, undefined>;
80
+ readonly dataSources: v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
81
+ readonly name: v.StringSchema<undefined>;
82
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
83
+ readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
84
+ readonly type: v.LiteralSchema<"emoji", undefined>;
85
+ readonly emoji: v.StringSchema<undefined>;
86
+ }, undefined>, v.ObjectSchema<{
87
+ readonly type: v.LiteralSchema<"external", undefined>;
88
+ readonly url: v.StringSchema<undefined>;
89
+ }, undefined>], undefined>, undefined>;
90
+ readonly properties: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
91
+ readonly name: v.StringSchema<undefined>;
92
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
93
+ readonly type: v.PicklistSchema<readonly ["title", "rich_text", "number", "checkbox", "url", "email", "phone_number", "select", "multi_select", "status", "date", "people", "files", "unique_id", "relation", "place", "formula", "rollup", "button", "verification", "last_visited_time", "location", "created_time", "last_edited_time", "created_by", "last_edited_by"], undefined>;
94
+ }, undefined>, undefined>, {}>;
95
+ }, undefined>, undefined>;
96
+ }, undefined>;
97
+ readonly dataSources: v.ObjectSchema<{
98
+ readonly bindings: v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
99
+ readonly collectionPointer: v.OptionalSchema<v.ObjectSchema<{
100
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>;
101
+ readonly table: v.StringSchema<undefined>;
102
+ readonly spaceId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionSpaceId">]>, undefined>;
103
+ }, undefined>, undefined>;
104
+ readonly collectionSchema: v.OptionalSchema<v.ObjectSchema<{
105
+ readonly id: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>, undefined>;
106
+ readonly propertiesById: v.RecordSchema<v.StringSchema<undefined>, v.VariantSchema<"type", [v.ObjectSchema<{
107
+ readonly name: v.StringSchema<undefined>;
108
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
109
+ readonly type: v.LiteralSchema<"title", undefined>;
110
+ }, undefined>, v.ObjectSchema<{
111
+ readonly name: v.StringSchema<undefined>;
112
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
113
+ readonly type: v.LiteralSchema<"rich_text", undefined>;
114
+ }, undefined>, v.ObjectSchema<{
115
+ readonly name: v.StringSchema<undefined>;
116
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
117
+ readonly type: v.LiteralSchema<"number", undefined>;
118
+ }, undefined>, v.ObjectSchema<{
119
+ readonly name: v.StringSchema<undefined>;
120
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
121
+ readonly type: v.LiteralSchema<"checkbox", undefined>;
122
+ }, undefined>, v.ObjectSchema<{
123
+ readonly name: v.StringSchema<undefined>;
124
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
125
+ readonly type: v.LiteralSchema<"url", undefined>;
126
+ }, undefined>, v.ObjectSchema<{
127
+ readonly name: v.StringSchema<undefined>;
128
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
129
+ readonly type: v.LiteralSchema<"email", undefined>;
130
+ }, undefined>, v.ObjectSchema<{
131
+ readonly name: v.StringSchema<undefined>;
132
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
133
+ readonly type: v.LiteralSchema<"phone_number", undefined>;
134
+ }, undefined>, v.ObjectSchema<{
135
+ readonly name: v.StringSchema<undefined>;
136
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
137
+ readonly type: v.LiteralSchema<"select", undefined>;
138
+ readonly options: v.ArraySchema<v.ObjectSchema<{
139
+ readonly id: v.StringSchema<undefined>;
140
+ readonly name: v.StringSchema<undefined>;
141
+ readonly color: v.OptionalSchema<v.PicklistSchema<["default", "gray", "brown", "orange", "yellow", "green", "blue", "purple", "pink", "red", "gray_background", "brown_background", "orange_background", "yellow_background", "green_background", "blue_background", "purple_background", "pink_background", "red_background", "default_background"], undefined>, undefined>;
142
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
143
+ }, undefined>, undefined>;
144
+ }, undefined>, v.ObjectSchema<{
145
+ readonly name: v.StringSchema<undefined>;
146
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
147
+ readonly type: v.LiteralSchema<"multi_select", undefined>;
148
+ readonly options: v.ArraySchema<v.ObjectSchema<{
149
+ readonly id: v.StringSchema<undefined>;
150
+ readonly name: v.StringSchema<undefined>;
151
+ readonly color: v.OptionalSchema<v.PicklistSchema<["default", "gray", "brown", "orange", "yellow", "green", "blue", "purple", "pink", "red", "gray_background", "brown_background", "orange_background", "yellow_background", "green_background", "blue_background", "purple_background", "pink_background", "red_background", "default_background"], undefined>, undefined>;
152
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
153
+ }, undefined>, undefined>;
154
+ }, undefined>, v.ObjectSchema<{
155
+ readonly name: v.StringSchema<undefined>;
156
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
157
+ readonly type: v.LiteralSchema<"status", undefined>;
158
+ readonly options: v.ArraySchema<v.ObjectSchema<{
159
+ readonly id: v.StringSchema<undefined>;
160
+ readonly name: v.StringSchema<undefined>;
161
+ readonly color: v.OptionalSchema<v.PicklistSchema<["default", "gray", "brown", "orange", "yellow", "green", "blue", "purple", "pink", "red", "gray_background", "brown_background", "orange_background", "yellow_background", "green_background", "blue_background", "purple_background", "pink_background", "red_background", "default_background"], undefined>, undefined>;
162
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
163
+ }, undefined>, undefined>;
164
+ readonly groups: v.ArraySchema<v.ObjectSchema<{
165
+ readonly id: v.StringSchema<undefined>;
166
+ readonly name: v.StringSchema<undefined>;
167
+ readonly color: v.OptionalSchema<v.PicklistSchema<["default", "gray", "brown", "orange", "yellow", "green", "blue", "purple", "pink", "red", "gray_background", "brown_background", "orange_background", "yellow_background", "green_background", "blue_background", "purple_background", "pink_background", "red_background", "default_background"], undefined>, undefined>;
168
+ readonly option_ids: v.ArraySchema<v.StringSchema<undefined>, undefined>;
169
+ }, undefined>, undefined>;
170
+ }, undefined>, v.ObjectSchema<{
171
+ readonly name: v.StringSchema<undefined>;
172
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
173
+ readonly type: v.LiteralSchema<"date", undefined>;
174
+ }, undefined>, v.ObjectSchema<{
175
+ readonly name: v.StringSchema<undefined>;
176
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
177
+ readonly type: v.LiteralSchema<"people", undefined>;
178
+ }, undefined>, v.ObjectSchema<{
179
+ readonly name: v.StringSchema<undefined>;
180
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
181
+ readonly type: v.LiteralSchema<"files", undefined>;
182
+ }, undefined>, v.ObjectSchema<{
183
+ readonly name: v.StringSchema<undefined>;
184
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
185
+ readonly type: v.LiteralSchema<"unique_id", undefined>;
186
+ }, undefined>, v.ObjectSchema<{
187
+ readonly name: v.StringSchema<undefined>;
188
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
189
+ readonly type: v.LiteralSchema<"relation", undefined>;
190
+ readonly data_source_id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
191
+ readonly dual_property: v.OptionalSchema<v.ObjectSchema<{
192
+ readonly synced_property_id: v.StringSchema<undefined>;
193
+ readonly synced_property_name: v.StringSchema<undefined>;
194
+ }, undefined>, undefined>;
195
+ }, undefined>, v.ObjectSchema<{
196
+ readonly name: v.StringSchema<undefined>;
197
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
198
+ readonly type: v.LiteralSchema<"place", undefined>;
199
+ }, undefined>, v.ObjectSchema<{
200
+ readonly name: v.StringSchema<undefined>;
201
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
202
+ readonly type: v.LiteralSchema<"formula", undefined>;
203
+ }, undefined>, v.ObjectSchema<{
204
+ readonly name: v.StringSchema<undefined>;
205
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
206
+ readonly type: v.LiteralSchema<"rollup", undefined>;
207
+ }, undefined>, v.ObjectSchema<{
208
+ readonly name: v.StringSchema<undefined>;
209
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
210
+ readonly type: v.LiteralSchema<"button", undefined>;
211
+ }, undefined>, v.ObjectSchema<{
212
+ readonly name: v.StringSchema<undefined>;
213
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
214
+ readonly type: v.LiteralSchema<"verification", undefined>;
215
+ }, undefined>, v.ObjectSchema<{
216
+ readonly name: v.StringSchema<undefined>;
217
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
218
+ readonly type: v.LiteralSchema<"last_visited_time", undefined>;
219
+ }, undefined>, v.ObjectSchema<{
220
+ readonly name: v.StringSchema<undefined>;
221
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
222
+ readonly type: v.LiteralSchema<"location", undefined>;
223
+ }, undefined>, v.ObjectSchema<{
224
+ readonly name: v.StringSchema<undefined>;
225
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
226
+ readonly type: v.LiteralSchema<"created_time", undefined>;
227
+ }, undefined>, v.ObjectSchema<{
228
+ readonly name: v.StringSchema<undefined>;
229
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
230
+ readonly type: v.LiteralSchema<"last_edited_time", undefined>;
231
+ }, undefined>, v.ObjectSchema<{
232
+ readonly name: v.StringSchema<undefined>;
233
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
234
+ readonly type: v.LiteralSchema<"created_by", undefined>;
235
+ }, undefined>, v.ObjectSchema<{
236
+ readonly name: v.StringSchema<undefined>;
237
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
238
+ readonly type: v.LiteralSchema<"last_edited_by", undefined>;
239
+ }, undefined>], undefined>, undefined>;
240
+ }, undefined>, undefined>;
241
+ readonly propertyIdsByKey: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.OptionalSchema<v.StringSchema<undefined>, undefined>, undefined>, undefined>;
242
+ }, undefined>, undefined>;
243
+ }, undefined>;
244
+ readonly currentUser: v.ObjectSchema<{
245
+ readonly object: v.LiteralSchema<"user", undefined>;
246
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionUserId">]>;
247
+ readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
248
+ readonly avatar_url: v.NullableSchema<v.StringSchema<undefined>, undefined>;
249
+ readonly type: v.LiteralSchema<"person", undefined>;
250
+ readonly person: v.ObjectSchema<{
251
+ readonly email: v.StringSchema<undefined>;
252
+ }, undefined>;
253
+ }, undefined>;
254
+ }, undefined>;
255
+ export type CustomBlockHostInitialState = v.InferInput<typeof customBlockHostInitialStateSchema>;
45
256
  export type CustomBlockHostInitialStateResult = {
46
257
  status: "success";
47
258
  initialState: CustomBlockHostInitialState;
@@ -1 +1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;CAC9D,CAAA;AAED,eAAO,MAAM,iCAAiC;;IAE7C;;;OAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAQF,CAAA;AAEF,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,UAAU,CACrD,OAAO,iCAAiC,CACxC,CAAA;AAED,MAAM,MAAM,iCAAiC,GAC1C;IACA,MAAM,EAAE,SAAS,CAAA;IACjB,YAAY,EAAE,2BAA2B,CAAA;CACxC,GACD;IACA,MAAM,EAAE,OAAO,CAAA;IACf,KAAK,EAAE,wBAAwB,CAAA;CAC9B,CAAA;AAEJ,MAAM,MAAM,8BAA8B,GAAG,CAC5C,OAAO,EAAE,qBAAqB,KAC1B,OAAO,CAAC,iCAAiC,CAAC,CAAA"}
@@ -1 +1,23 @@
1
- export {};
1
+ import { notionContrastModeSchema } from "../protocol/contrast.js";
2
+ import { notionDataSourceBindingsSchema } from "../protocol/dataSources/dataSource.js";
3
+ import { notionBlockIdSchema } from "../protocol/ids.js";
4
+ import { manifestSchema } from "../protocol/manifest.js";
5
+ import { customBlockPageSchema } from "../protocol/pages/page.js";
6
+ import { notionParentSchema } from "../protocol/parent.js";
7
+ import { notionThemeSchema } from "../protocol/theme.js";
8
+ import { notionUserSchema } from "../protocol/users/user.js";
9
+ import * as v from "valibot";
10
+ export const customBlockHostInitialStateSchema = v.object({
11
+ theme: notionThemeSchema,
12
+ /**
13
+ * Defaults to standard for existing host integrations.
14
+ * TODO(custom-blocks): Make this required when MIN_HOST_SUPPORTED_BRIDGE_PROTOCOL_VERSION increases to 4.
15
+ */
16
+ contrastMode: v.optional(notionContrastModeSchema),
17
+ blockId: notionBlockIdSchema,
18
+ parent: notionParentSchema,
19
+ page: customBlockPageSchema,
20
+ manifest: manifestSchema,
21
+ dataSources: v.object({ bindings: notionDataSourceBindingsSchema }),
22
+ currentUser: notionUserSchema,
23
+ });
@@ -1,25 +1,30 @@
1
1
  import type { CreatePageMessage, createPageMessageSchema } from "../protocol/messages/createPage.js";
2
- import type { CreatePageResultMessage, CustomBlockCreatePageErrorInfo } from "../protocol/messages/createPageResult.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";
2
+ import type { CustomBlockCreatePageErrorInfo, createPageResultMessageSchema } from "../protocol/messages/createPageResult.js";
3
+ import type { CustomBlockGetPageErrorInfo, GetPageMessage, getPageMessageSchema, getPageResultMessageSchema } from "../protocol/messages/getPage.js";
4
+ import type { CustomBlockGetUserErrorInfo, GetUserMessage, getUserMessageSchema, getUserResultMessageSchema } 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, listUsersMessageSchema } from "../protocol/messages/listUsers.js";
7
+ import type { CustomBlockListUsersErrorInfo, ListUsersMessage, listUsersMessageSchema, listUsersResultMessageSchema } 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
+ import type { CustomBlockOpenPageErrorInfo, OpenPageMessage, openPageMessageSchema, openPageResultMessageSchema } from "../protocol/messages/openPage.js";
10
10
  import type { QueryDataSourceMessage, queryDataSourceMessageSchema } from "../protocol/messages/queryDataSource.js";
11
11
  import type { ResizeMessage, resizeMessageSchema } from "../protocol/messages/resize.js";
12
12
  import type { UpdatePageMessage, updatePageMessageSchema } from "../protocol/messages/updatePage.js";
13
- import type { CustomBlockUpdatePageErrorInfo, UpdatePageResultMessage } from "../protocol/messages/updatePageResult.js";
13
+ import type { CustomBlockUpdatePageErrorInfo, updatePageResultMessageSchema } from "../protocol/messages/updatePageResult.js";
14
14
  import type { InferInput } from "valibot";
15
15
  import type { CustomBlockHostQueryDataSourceResult } from "../queries/types.js";
16
16
  type MaybePromise<T> = T | Promise<T>;
17
- export type CustomBlockHostCreatePageResult = BridgeMessagePayload<CreatePageResultMessage, CustomBlockCreatePageErrorInfo>;
18
- export type CustomBlockHostGetPageResult = BridgeMessagePayload<GetPageResultMessage, CustomBlockGetPageErrorInfo>;
19
- export type CustomBlockHostUpdatePageResult = BridgeMessagePayload<UpdatePageResultMessage, CustomBlockUpdatePageErrorInfo>;
20
- export type CustomBlockHostGetUserResult = BridgeMessagePayload<GetUserResultMessage, CustomBlockGetUserErrorInfo>;
21
- export type CustomBlockHostListUsersResult = BridgeMessagePayload<ListUsersResultMessage, CustomBlockListUsersErrorInfo>;
22
- export type CustomBlockHostOpenPageResult = BridgeMessagePayload<OpenPageResultMessage, CustomBlockOpenPageErrorInfo>;
17
+ /**
18
+ * Host results use InferInput so adapters can return plain string IDs.
19
+ * The runtime validates results before sending them and assigns protocol ID brands.
20
+ * Handler requests use parsed protocol types, whose IDs are already branded.
21
+ */
22
+ export type CustomBlockHostCreatePageResult = BridgeMessagePayload<InferInput<typeof createPageResultMessageSchema>, CustomBlockCreatePageErrorInfo>;
23
+ export type CustomBlockHostGetPageResult = BridgeMessagePayload<InferInput<typeof getPageResultMessageSchema>, CustomBlockGetPageErrorInfo>;
24
+ export type CustomBlockHostUpdatePageResult = BridgeMessagePayload<InferInput<typeof updatePageResultMessageSchema>, CustomBlockUpdatePageErrorInfo>;
25
+ export type CustomBlockHostGetUserResult = BridgeMessagePayload<InferInput<typeof getUserResultMessageSchema>, CustomBlockGetUserErrorInfo>;
26
+ export type CustomBlockHostListUsersResult = BridgeMessagePayload<InferInput<typeof listUsersResultMessageSchema>, CustomBlockListUsersErrorInfo>;
27
+ export type CustomBlockHostOpenPageResult = BridgeMessagePayload<InferInput<typeof openPageResultMessageSchema>, CustomBlockOpenPageErrorInfo>;
23
28
  export type CustomBlockHostHandlers = {
24
29
  queryDataSource: (message: QueryDataSourceMessage) => MaybePromise<CustomBlockHostQueryDataSourceResult>;
25
30
  createPage?: (message: CreatePageMessage) => MaybePromise<CustomBlockHostCreatePageResult>;
@@ -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,MAAM,wDAAwD,CAAA;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6DAA6D,CAAA;AACvG,OAAO,KAAK,EACX,4BAA4B,EAC5B,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACrB,MAAM,uDAAuD,CAAA;AAC9D,OAAO,KAAK,EACX,sBAAsB,EACt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,CAAC,+BAA+B,CAAC,CAAA;IAClD,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI,CAAA;CACzC,CAAA;AAED,MAAM,MAAM,sBAAsB,GAC/B,wBAAwB,GACxB,8BAA8B,CAAA;AAEjC,MAAM,MAAM,2BAA2B,GAAG,IAAI,GAAG,KAAK,GAAG,MAAM,CAAA;AAE/D,MAAM,MAAM,sBAAsB,GAAG,UAAU,CAAC,OAAO,uBAAuB,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"}
@@ -1201,6 +1201,3 @@ export declare const hostToSandboxMessageSchema: v.VariantSchema<"type", [v.Vari
1201
1201
  readonly reason: v.StringSchema<undefined>;
1202
1202
  }, undefined>], undefined>;
1203
1203
  export type HostToSandboxMessage = v.InferOutput<typeof hostToSandboxMessageSchema>;
1204
- export type PrimeableHostToSandboxMessage = Extract<HostToSandboxMessage, {
1205
- type: "getPageResult" | "openPageResult" | "createPageResult" | "updatePageResult" | "getUserResult" | "listUsersResult" | "queryDataSourceResult";
1206
- }>;
@@ -1,4 +1,5 @@
1
1
  import type { BridgeMessagePayload } from "../protocol/messages/messagePayload.js";
2
- import type { CustomBlockQueryDataSourceErrorInfo, QueryDataSourceResultMessage } from "../protocol/messages/queryDataSourceResult.js";
3
- export type CustomBlockHostQueryDataSourceResult = BridgeMessagePayload<QueryDataSourceResultMessage, CustomBlockQueryDataSourceErrorInfo>;
2
+ import type { CustomBlockQueryDataSourceErrorInfo, queryDataSourceResultMessageSchema } from "../protocol/messages/queryDataSourceResult.js";
3
+ import type { InferInput } from "valibot";
4
+ export type CustomBlockHostQueryDataSourceResult = BridgeMessagePayload<InferInput<typeof queryDataSourceResultMessageSchema>, CustomBlockQueryDataSourceErrorInfo>;
4
5
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/queries/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6DAA6D,CAAA;AACvG,OAAO,KAAK,EACX,mCAAmC,EACnC,4BAA4B,EAC5B,MAAM,oEAAoE,CAAA;AAE3E,MAAM,MAAM,oCAAoC,GAAG,oBAAoB,CACtE,4BAA4B,EAC5B,mCAAmC,CACnC,CAAA"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/queries/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6DAA6D,CAAA;AACvG,OAAO,KAAK,EACX,mCAAmC,EACnC,kCAAkC,EAClC,MAAM,oEAAoE,CAAA;AAC3E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC,MAAM,MAAM,oCAAoC,GAAG,oBAAoB,CACtE,UAAU,CAAC,OAAO,kCAAkC,CAAC,EACrD,mCAAmC,CACnC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@notionhq/custom-blocks-host",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Reusable host runtime for Notion custom blocks.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -12,7 +12,8 @@
12
12
  "exports": {
13
13
  ".": {
14
14
  "import": "./dist/index.js",
15
- "types": "./dist/index.d.ts"
15
+ "types": "./dist/index.d.ts",
16
+ "default": "./dist/index.js"
16
17
  }
17
18
  },
18
19
  "dependencies": {
@@ -1,25 +1,32 @@
1
- import type { NotionContrastMode } from "@notionhq/custom-blocks-protocol/contrast.js"
1
+ import type { notionContrastModeSchema } from "@notionhq/custom-blocks-protocol/contrast.js"
2
2
  import type { NotionCollectionSchema } from "@notionhq/custom-blocks-protocol/dataSources/dataSource.js"
3
+ import { notionDataSourceBindingsSchema } from "@notionhq/custom-blocks-protocol/dataSources/dataSource.js"
3
4
  import type { NotionDataSourceId } from "@notionhq/custom-blocks-protocol/ids.js"
5
+ import { notionDataSourceIdSchema } from "@notionhq/custom-blocks-protocol/ids.js"
4
6
  import type { CustomBlockManifest } from "@notionhq/custom-blocks-protocol/manifest.js"
5
- import type { HostToSandboxMessage } from "@notionhq/custom-blocks-protocol/messages/hostToSandbox.js"
6
- import type {
7
- CustomBlockInitErrorCode,
8
- InitMessage,
7
+ import { manifestSchema } from "@notionhq/custom-blocks-protocol/manifest.js"
8
+ import {
9
+ type HostToSandboxMessage,
10
+ hostToSandboxMessageSchema,
11
+ } from "@notionhq/custom-blocks-protocol/messages/hostToSandbox.js"
12
+ import {
13
+ type CustomBlockInitErrorCode,
14
+ initMessageSchema,
9
15
  } from "@notionhq/custom-blocks-protocol/messages/init.js"
10
16
  import type { InvalidSandboxMessage } from "@notionhq/custom-blocks-protocol/messages/invalidSandboxMessage.js"
11
- import type { BridgeMessagePayload } from "@notionhq/custom-blocks-protocol/messages/messagePayload.js"
12
17
  import type { QueryDataSourceMessage } from "@notionhq/custom-blocks-protocol/messages/queryDataSource.js"
13
18
  import type {
14
19
  CustomBlockQueryDataSourceErrorInfo,
15
- QueryDataSourceResultMessage,
20
+ queryDataSourceResultMessageSchema,
16
21
  } from "@notionhq/custom-blocks-protocol/messages/queryDataSourceResult.js"
17
22
  import type { SandboxToHostMessage } from "@notionhq/custom-blocks-protocol/messages/sandboxToHost.js"
18
- import type { CustomBlockPage } from "@notionhq/custom-blocks-protocol/pages/page.js"
19
- import type { NotionParent } from "@notionhq/custom-blocks-protocol/parent.js"
23
+ import type { customBlockPageSchema } from "@notionhq/custom-blocks-protocol/pages/page.js"
24
+ import type { notionParentSchema } from "@notionhq/custom-blocks-protocol/parent.js"
20
25
  import { LATEST_BRIDGE_PROTOCOL_VERSION } from "@notionhq/custom-blocks-protocol/protocolVersion.js"
21
- import type { NotionTheme } from "@notionhq/custom-blocks-protocol/theme.js"
22
- import type { NotionUser } from "@notionhq/custom-blocks-protocol/users/user.js"
26
+ import type { notionThemeSchema } from "@notionhq/custom-blocks-protocol/theme.js"
27
+ import type { notionUserSchema } from "@notionhq/custom-blocks-protocol/users/user.js"
28
+ import type { InferInput } from "valibot"
29
+ import * as v from "valibot"
23
30
  import { initErrorForFailureReason } from "./lifecycle/initErrors.js"
24
31
  import { createInitializationController } from "./lifecycle/initializationController.js"
25
32
  import { normalizeHostToSandboxMessage } from "./lifecycle/normalizeHostToSandboxMessage.js"
@@ -28,7 +35,9 @@ import type {
28
35
  CustomBlockHostGetInitialState,
29
36
  CustomBlockHostInitialState,
30
37
  CustomBlockHostInitialStateResult,
38
+ CustomBlockHostNormalizedDataSourcesPayload,
31
39
  } from "./lifecycle/types.js"
40
+ import { customBlockHostInitialStateSchema } from "./lifecycle/types.js"
32
41
  import { createSandboxMessageRouter } from "./messages/sandboxMessageRouter.js"
33
42
  import type {
34
43
  CustomBlockHostFailure,
@@ -82,13 +91,17 @@ export type CustomBlockHostOptions = {
82
91
 
83
92
  export type CustomBlockHostHandle = {
84
93
  stop: () => void
85
- setTheme: (theme: NotionTheme) => void
86
- setContrastMode: (contrastMode: NotionContrastMode) => void
87
- setParent: (parent: NotionParent) => void
88
- setPage: (page: CustomBlockPage) => void
94
+ setTheme: (theme: InferInput<typeof notionThemeSchema>) => void
95
+ setContrastMode: (
96
+ contrastMode: InferInput<typeof notionContrastModeSchema>,
97
+ ) => void
98
+ setParent: (parent: InferInput<typeof notionParentSchema>) => void
99
+ setPage: (page: InferInput<typeof customBlockPageSchema>) => void
89
100
  setDataSources: (dataSources: CustomBlockHostDataSourcesPayload) => void
90
- setCurrentUser: (currentUser: NotionUser) => void
91
- refreshQuery: (args: { dataSourceId: NotionDataSourceId }) => void
101
+ setCurrentUser: (currentUser: InferInput<typeof notionUserSchema>) => void
102
+ refreshQuery: (args: {
103
+ dataSourceId: InferInput<typeof notionDataSourceIdSchema>
104
+ }) => void
92
105
  }
93
106
 
94
107
  /**
@@ -97,23 +110,6 @@ export type CustomBlockHostHandle = {
97
110
  */
98
111
  type OneShotRequest = Extract<SandboxToHostMessage, { requestId: string }>
99
112
 
100
- /** The matching host result message, named `<request type>Result` by the protocol. */
101
- type ResultForRequest<Request extends OneShotRequest> = Extract<
102
- HostToSandboxMessage,
103
- { type: `${Request["type"]}Result` }
104
- >
105
-
106
- /** The result's success or error payload, without the bridge envelope fields. */
107
- type ResultPayloadForRequest<Request extends OneShotRequest> =
108
- BridgeMessagePayload<ResultForRequest<Request>>
109
-
110
- /** Returns one result payload. `respondToRequest` adds the message type and request ID. */
111
- type OneShotHandler<Request extends OneShotRequest> = (
112
- message: Request,
113
- ) =>
114
- | ResultPayloadForRequest<Request>
115
- | Promise<ResultPayloadForRequest<Request>>
116
-
117
113
  export function createCustomBlockHost(
118
114
  options: CustomBlockHostOptions,
119
115
  ): CustomBlockHostHandle {
@@ -145,7 +141,7 @@ export function createCustomBlockHost(
145
141
  let pendingState: HostStateUpdates = {}
146
142
  let hasPreparedInitialState = false
147
143
  let manifest: CustomBlockManifest | undefined
148
- let activeDataSources: CustomBlockHostDataSourcesPayload | undefined
144
+ let activeDataSources: CustomBlockHostNormalizedDataSourcesPayload | undefined
149
145
  let sandboxBridgeProtocolVersion = LATEST_BRIDGE_PROTOCOL_VERSION
150
146
  const querySubscriptions = new QuerySubscriptions()
151
147
 
@@ -177,24 +173,19 @@ export function createCustomBlockHost(
177
173
  iframe.contentWindow?.postMessage(sandboxMessage, sandboxOrigin)
178
174
  }
179
175
 
180
- function sendInitMessage(message: InitMessage) {
181
- postToSandbox(message)
176
+ function sendInitMessage(message: InferInput<typeof initMessageSchema>) {
177
+ postToSandbox(v.parse(initMessageSchema, message))
182
178
  }
183
179
 
184
180
  function sendNack(message: InvalidSandboxMessage) {
185
181
  postToSandbox(message)
186
182
  }
187
183
 
188
- function sendInitializedMessage(
189
- message: Exclude<
190
- HostToSandboxMessage,
191
- { type: "init" | "invalidSandboxMessage" }
192
- >,
193
- ) {
184
+ function sendInitializedMessage(message: unknown) {
194
185
  const status = initializationController.status
195
186
  switch (status) {
196
187
  case "initialized":
197
- postToSandbox(message)
188
+ postToSandbox(v.parse(hostToSandboxMessageSchema, message))
198
189
  return
199
190
  // Send state updates and handler results only after initialization succeeds.
200
191
  case "waitingForConnect":
@@ -212,27 +203,29 @@ export function createCustomBlockHost(
212
203
  * Invokes a one-shot handler and posts its result with the request's ID.
213
204
  * Each result type is named `<request type>Result` by the bridge protocol.
214
205
  */
215
- async function respondToRequest<Request extends OneShotRequest>(
206
+ async function respondToRequest<
207
+ Request extends OneShotRequest,
208
+ Response extends object,
209
+ >(
216
210
  message: Request,
217
- handler: OneShotHandler<Request> | undefined,
211
+ handler: ((message: Request) => Response | Promise<Response>) | undefined,
218
212
  ) {
219
213
  if (handler === undefined) {
220
214
  return
221
215
  }
222
216
  const response = await handler(message)
223
- const result = {
217
+ sendInitializedMessage({
224
218
  type: `${message.type}Result` as const,
225
219
  requestId: message.requestId,
226
220
  ...response,
227
- } as ResultForRequest<OneShotRequest>
228
- sendInitializedMessage(result)
221
+ })
229
222
  }
230
223
 
231
224
  function postQueryDataSourceResult(args: {
232
225
  subscriptionId: string
233
226
  response: CustomBlockHostQueryDataSourceResult
234
227
  }) {
235
- const message: QueryDataSourceResultMessage =
228
+ const message: InferInput<typeof queryDataSourceResultMessageSchema> =
236
229
  args.response.status === "error"
237
230
  ? {
238
231
  type: "queryDataSourceResult",
@@ -357,10 +350,20 @@ export function createCustomBlockHost(
357
350
  if (result.status === "error") {
358
351
  return result
359
352
  }
360
- manifest = result.initialState.manifest
353
+ manifest = v.parse(manifestSchema, result.initialState.manifest)
361
354
  onManifest?.(manifest)
362
- const initialState = { ...result.initialState, ...pendingState }
355
+ const initialStateInput = {
356
+ ...result.initialState,
357
+ ...pendingState,
358
+ }
363
359
  pendingState = {}
360
+ const initialState = {
361
+ ...v.parse(
362
+ v.omit(customBlockHostInitialStateSchema, ["manifest"]),
363
+ initialStateInput,
364
+ ),
365
+ manifest,
366
+ }
364
367
  if (
365
368
  sandboxBridgeProtocolVersion <
366
369
  BRIDGE_PROTOCOL_VERSION_INTRODUCING_UNAVAILABLE_PAGE &&
@@ -454,25 +457,36 @@ export function createCustomBlockHost(
454
457
  updateHostState({ currentUser })
455
458
  },
456
459
  setDataSources(dataSources) {
460
+ const normalizedDataSources: CustomBlockHostNormalizedDataSourcesPayload =
461
+ {
462
+ bindings: v.parse(
463
+ notionDataSourceBindingsSchema,
464
+ dataSources.bindings,
465
+ ),
466
+ }
457
467
  if (
458
468
  initializationController.hasConnectedSandbox &&
459
469
  manifest !== undefined &&
460
- getBindingErrorCode(manifest, dataSources) !== undefined
470
+ getBindingErrorCode(manifest, normalizedDataSources) !== undefined
461
471
  ) {
462
472
  emit("warn", {
463
473
  message: "Ignored invalid data source bindings update",
464
- payload: dataSources,
474
+ payload: normalizedDataSources,
465
475
  })
466
476
  return
467
477
  }
468
- activeDataSources = dataSources
469
- updateHostState({ dataSources })
478
+ activeDataSources = normalizedDataSources
479
+ updateHostState({ dataSources: normalizedDataSources })
470
480
  },
471
481
  refreshQuery({ dataSourceId }) {
472
482
  if (initializationController.status !== "initialized") {
473
483
  return
474
484
  }
475
- const refreshes = querySubscriptions.refresh(dataSourceId)
485
+ const normalizedDataSourceId = v.parse(
486
+ notionDataSourceIdSchema,
487
+ dataSourceId,
488
+ )
489
+ const refreshes = querySubscriptions.refresh(normalizedDataSourceId)
476
490
  if (refreshes.length === 0) {
477
491
  emit("warn", `No active query exists for data source "${dataSourceId}"`)
478
492
  return
@@ -485,7 +499,7 @@ export function createCustomBlockHost(
485
499
  }
486
500
 
487
501
  function getCollectionSchema(
488
- dataSources: CustomBlockHostDataSourcesPayload | undefined,
502
+ dataSources: CustomBlockHostNormalizedDataSourcesPayload | undefined,
489
503
  dataSourceId: NotionDataSourceId,
490
504
  ) {
491
505
  return Object.values(dataSources?.bindings ?? {}).find(
@@ -494,7 +508,7 @@ function getCollectionSchema(
494
508
  }
495
509
 
496
510
  function getBindingErrorCode(
497
- manifest: CustomBlockManifest,
511
+ manifest: InferInput<typeof manifestSchema>,
498
512
  dataSources: CustomBlockHostDataSourcesPayload,
499
513
  ): CustomBlockInitErrorCode | undefined {
500
514
  for (const [dataSourceKey, manifestDataSource] of Object.entries(
@@ -2,9 +2,10 @@ import { DEFAULT_CONTRAST_MODE } from "@notionhq/custom-blocks-protocol/contrast
2
2
  import type { ConnectMessage } from "@notionhq/custom-blocks-protocol/messages/connect.js"
3
3
  import type {
4
4
  CustomBlockInitErrorInfo,
5
- InitMessage,
5
+ initMessageSchema,
6
6
  } from "@notionhq/custom-blocks-protocol/messages/init.js"
7
7
  import type { InitResultMessage } from "@notionhq/custom-blocks-protocol/messages/initResult.js"
8
+ import type { InferInput } from "valibot"
8
9
  import type { CustomBlockHostFailure } from "../messages/types.js"
9
10
  import { unreachable } from "../utils.js"
10
11
  import { initErrorForFailureReason } from "./initErrors.js"
@@ -23,7 +24,7 @@ export type InitializationControllerOptions = {
23
24
  prepareInit: (
24
25
  connect: ConnectSuccessMessage,
25
26
  ) => Promise<CustomBlockHostInitialStateResult>
26
- sendInitMessage: (message: InitMessage) => void
27
+ sendInitMessage: (message: InferInput<typeof initMessageSchema>) => void
27
28
  warn: (payload: unknown) => void
28
29
  flushPendingHostStateChanges: () => void
29
30
  minBridgeProtocolVersion: number
@@ -162,7 +163,7 @@ export function createInitializationController(
162
163
  return
163
164
  }
164
165
  initStatus = "waitingForInitResult"
165
- const message: InitMessage = {
166
+ const message: InferInput<typeof initMessageSchema> = {
166
167
  type: "init",
167
168
  initializationId: connect.initializationId,
168
169
  status: "success",
@@ -1,13 +1,14 @@
1
- import type { NotionContrastMode } from "@notionhq/custom-blocks-protocol/contrast.js"
2
- import type { NotionDataSourceBindings } from "@notionhq/custom-blocks-protocol/dataSources/dataSource.js"
3
- import type { NotionBlockId } from "@notionhq/custom-blocks-protocol/ids.js"
4
- import type { CustomBlockManifest } from "@notionhq/custom-blocks-protocol/manifest.js"
1
+ import { notionContrastModeSchema } from "@notionhq/custom-blocks-protocol/contrast.js"
2
+ import { notionDataSourceBindingsSchema } from "@notionhq/custom-blocks-protocol/dataSources/dataSource.js"
3
+ import { notionBlockIdSchema } from "@notionhq/custom-blocks-protocol/ids.js"
4
+ import { manifestSchema } from "@notionhq/custom-blocks-protocol/manifest.js"
5
5
  import type { ConnectMessage } from "@notionhq/custom-blocks-protocol/messages/connect.js"
6
6
  import type { CustomBlockInitErrorInfo } from "@notionhq/custom-blocks-protocol/messages/init.js"
7
- import type { CustomBlockPage } from "@notionhq/custom-blocks-protocol/pages/page.js"
8
- import type { NotionParent } from "@notionhq/custom-blocks-protocol/parent.js"
9
- import type { NotionTheme } from "@notionhq/custom-blocks-protocol/theme.js"
10
- import type { NotionUser } from "@notionhq/custom-blocks-protocol/users/user.js"
7
+ import { customBlockPageSchema } from "@notionhq/custom-blocks-protocol/pages/page.js"
8
+ import { notionParentSchema } from "@notionhq/custom-blocks-protocol/parent.js"
9
+ import { notionThemeSchema } from "@notionhq/custom-blocks-protocol/theme.js"
10
+ import { notionUserSchema } from "@notionhq/custom-blocks-protocol/users/user.js"
11
+ import * as v from "valibot"
11
12
 
12
13
  export type ConnectSuccessMessage = Extract<
13
14
  ConnectMessage,
@@ -30,23 +31,31 @@ export type InitStatus =
30
31
  | "stopped"
31
32
 
32
33
  export type CustomBlockHostDataSourcesPayload = {
33
- bindings: NotionDataSourceBindings
34
+ bindings: v.InferInput<typeof notionDataSourceBindingsSchema>
34
35
  }
35
36
 
36
- export type CustomBlockHostInitialState = {
37
- theme: NotionTheme
37
+ export type CustomBlockHostNormalizedDataSourcesPayload = {
38
+ bindings: v.InferOutput<typeof notionDataSourceBindingsSchema>
39
+ }
40
+
41
+ export const customBlockHostInitialStateSchema = v.object({
42
+ theme: notionThemeSchema,
38
43
  /**
39
44
  * Defaults to standard for existing host integrations.
40
45
  * TODO(custom-blocks): Make this required when MIN_HOST_SUPPORTED_BRIDGE_PROTOCOL_VERSION increases to 4.
41
46
  */
42
- contrastMode?: NotionContrastMode
43
- blockId: NotionBlockId
44
- parent: NotionParent
45
- page: CustomBlockPage
46
- manifest: CustomBlockManifest
47
- dataSources: CustomBlockHostDataSourcesPayload
48
- currentUser: NotionUser
49
- }
47
+ contrastMode: v.optional(notionContrastModeSchema),
48
+ blockId: notionBlockIdSchema,
49
+ parent: notionParentSchema,
50
+ page: customBlockPageSchema,
51
+ manifest: manifestSchema,
52
+ dataSources: v.object({ bindings: notionDataSourceBindingsSchema }),
53
+ currentUser: notionUserSchema,
54
+ })
55
+
56
+ export type CustomBlockHostInitialState = v.InferInput<
57
+ typeof customBlockHostInitialStateSchema
58
+ >
50
59
 
51
60
  export type CustomBlockHostInitialStateResult =
52
61
  | {
@@ -3,35 +3,35 @@ import type {
3
3
  createPageMessageSchema,
4
4
  } from "@notionhq/custom-blocks-protocol/messages/createPage.js"
5
5
  import type {
6
- CreatePageResultMessage,
7
6
  CustomBlockCreatePageErrorInfo,
7
+ createPageResultMessageSchema,
8
8
  } from "@notionhq/custom-blocks-protocol/messages/createPageResult.js"
9
9
  import type {
10
10
  CustomBlockGetPageErrorInfo,
11
11
  GetPageMessage,
12
- GetPageResultMessage,
13
12
  getPageMessageSchema,
13
+ getPageResultMessageSchema,
14
14
  } from "@notionhq/custom-blocks-protocol/messages/getPage.js"
15
15
  import type {
16
16
  CustomBlockGetUserErrorInfo,
17
17
  GetUserMessage,
18
- GetUserResultMessage,
19
18
  getUserMessageSchema,
19
+ getUserResultMessageSchema,
20
20
  } from "@notionhq/custom-blocks-protocol/messages/getUser.js"
21
21
  import type { CustomBlockInitErrorInfo } from "@notionhq/custom-blocks-protocol/messages/init.js"
22
22
  import type { CustomBlockInitResultErrorInfo } from "@notionhq/custom-blocks-protocol/messages/initResult.js"
23
23
  import type {
24
24
  CustomBlockListUsersErrorInfo,
25
25
  ListUsersMessage,
26
- ListUsersResultMessage,
27
26
  listUsersMessageSchema,
27
+ listUsersResultMessageSchema,
28
28
  } from "@notionhq/custom-blocks-protocol/messages/listUsers.js"
29
29
  import type { BridgeMessagePayload } from "@notionhq/custom-blocks-protocol/messages/messagePayload.js"
30
30
  import type {
31
31
  CustomBlockOpenPageErrorInfo,
32
32
  OpenPageMessage,
33
- OpenPageResultMessage,
34
33
  openPageMessageSchema,
34
+ openPageResultMessageSchema,
35
35
  } from "@notionhq/custom-blocks-protocol/messages/openPage.js"
36
36
  import type {
37
37
  QueryDataSourceMessage,
@@ -47,40 +47,45 @@ import type {
47
47
  } from "@notionhq/custom-blocks-protocol/messages/updatePage.js"
48
48
  import type {
49
49
  CustomBlockUpdatePageErrorInfo,
50
- UpdatePageResultMessage,
50
+ updatePageResultMessageSchema,
51
51
  } from "@notionhq/custom-blocks-protocol/messages/updatePageResult.js"
52
52
  import type { InferInput } from "valibot"
53
53
  import type { CustomBlockHostQueryDataSourceResult } from "../queries/types.js"
54
54
 
55
55
  type MaybePromise<T> = T | Promise<T>
56
56
 
57
+ /**
58
+ * Host results use InferInput so adapters can return plain string IDs.
59
+ * The runtime validates results before sending them and assigns protocol ID brands.
60
+ * Handler requests use parsed protocol types, whose IDs are already branded.
61
+ */
57
62
  export type CustomBlockHostCreatePageResult = BridgeMessagePayload<
58
- CreatePageResultMessage,
63
+ InferInput<typeof createPageResultMessageSchema>,
59
64
  CustomBlockCreatePageErrorInfo
60
65
  >
61
66
 
62
67
  export type CustomBlockHostGetPageResult = BridgeMessagePayload<
63
- GetPageResultMessage,
68
+ InferInput<typeof getPageResultMessageSchema>,
64
69
  CustomBlockGetPageErrorInfo
65
70
  >
66
71
 
67
72
  export type CustomBlockHostUpdatePageResult = BridgeMessagePayload<
68
- UpdatePageResultMessage,
73
+ InferInput<typeof updatePageResultMessageSchema>,
69
74
  CustomBlockUpdatePageErrorInfo
70
75
  >
71
76
 
72
77
  export type CustomBlockHostGetUserResult = BridgeMessagePayload<
73
- GetUserResultMessage,
78
+ InferInput<typeof getUserResultMessageSchema>,
74
79
  CustomBlockGetUserErrorInfo
75
80
  >
76
81
 
77
82
  export type CustomBlockHostListUsersResult = BridgeMessagePayload<
78
- ListUsersResultMessage,
83
+ InferInput<typeof listUsersResultMessageSchema>,
79
84
  CustomBlockListUsersErrorInfo
80
85
  >
81
86
 
82
87
  export type CustomBlockHostOpenPageResult = BridgeMessagePayload<
83
- OpenPageResultMessage,
88
+ InferInput<typeof openPageResultMessageSchema>,
84
89
  CustomBlockOpenPageErrorInfo
85
90
  >
86
91
 
@@ -1,10 +1,11 @@
1
1
  import type { BridgeMessagePayload } from "@notionhq/custom-blocks-protocol/messages/messagePayload.js"
2
2
  import type {
3
3
  CustomBlockQueryDataSourceErrorInfo,
4
- QueryDataSourceResultMessage,
4
+ queryDataSourceResultMessageSchema,
5
5
  } from "@notionhq/custom-blocks-protocol/messages/queryDataSourceResult.js"
6
+ import type { InferInput } from "valibot"
6
7
 
7
8
  export type CustomBlockHostQueryDataSourceResult = BridgeMessagePayload<
8
- QueryDataSourceResultMessage,
9
+ InferInput<typeof queryDataSourceResultMessageSchema>,
9
10
  CustomBlockQueryDataSourceErrorInfo
10
11
  >