@notionhq/custom-blocks 0.1.18 → 0.1.20

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.
@@ -1,6 +1,6 @@
1
1
  import type { NotionDataSource } from "../protocol/dataSources/dataSource.js";
2
2
  import { type InitMessage } from "../protocol/messages/init.js";
3
- import type { CreatePageArgs, CreatePageResult, GetPageResult, GetUserResult, ListUsersArgs, ListUsersResult, NotionDataSourcePageUpdateArgs, NotionDataSourcePageUpdateResult, NotionPageId, NotionUserId, UpdatePageArgs, UpdatePageResult, UseDataSourceOptions } from "../types.js";
3
+ import type { CreatePageArgs, CreatePageResult, GetPageResult, GetUserResult, ListUsersArgs, ListUsersResult, NotionDataSourcePageUpdateArgs, NotionPageId, NotionUserId, UpdatePageArgs, UpdatePageResult, UseDataSourceOptions } from "../types.js";
4
4
  import { type CustomBlockHostState } from "./hostState.js";
5
5
  import type { ManifestLoadResult } from "./loadManifest.js";
6
6
  /**
@@ -69,7 +69,7 @@ export declare class SandboxBridge {
69
69
  dataSource: NotionDataSource;
70
70
  pageId: NotionPageId;
71
71
  pageUpdateArgs: NotionDataSourcePageUpdateArgs;
72
- }): Promise<NotionDataSourcePageUpdateResult>;
72
+ }): Promise<UpdatePageResult>;
73
73
  /**
74
74
  * Translates the public `CreatePageArgs["parent"]` into the bridge-native
75
75
  * `CreatePageMessageParent`. The `data_source_key` variant is resolved sandbox-side against
@@ -1 +1 @@
1
- {"version":3,"file":"SandboxBridge.d.ts","sourceRoot":"","sources":["../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/SandboxBridge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,gBAAgB,EAEhB,MAAM,4DAA4D,CAAA;AAWnE,OAAO,EAEN,KAAK,WAAW,EAEhB,MAAM,mDAAmD,CAAA;AAc1D,OAAO,KAAK,EACX,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,aAAa,EACb,eAAe,EACf,8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;IACH,OAAO,CAAC,uBAAuB;CAkE/B"}
@@ -6,6 +6,7 @@ import { CUSTOM_BLOCK_BRIDGE_PROTOCOL_VERSION } from "../protocol/protocolVersio
6
6
  import * as v from "valibot";
7
7
  import { unreachable } from "../utils.js";
8
8
  import { CUSTOM_BLOCKS_SDK_VERSION } from "../version.js";
9
+ import { NOTION_DARK_BACKGROUND_BASE, NOTION_LIGHT_BACKGROUND_BASE, } from "./appearance.js";
9
10
  import { resolveDataSources } from "./dataSources/resolve.js";
10
11
  import { resolvePropertyWriteMapForDataSource } from "./dataSources/resolveProperty.js";
11
12
  import { createEmptyDataSourceQueryState, } from "./hostState.js";
@@ -104,6 +105,10 @@ export class SandboxBridge {
104
105
  ...hostState,
105
106
  theme: message.theme,
106
107
  };
108
+ syncDocumentAppearance({
109
+ theme: message.theme,
110
+ contrastMode: hostState.contrastMode,
111
+ });
107
112
  this.notify();
108
113
  return;
109
114
  }
@@ -112,6 +117,10 @@ export class SandboxBridge {
112
117
  ...hostState,
113
118
  contrastMode: message.contrastMode,
114
119
  };
120
+ syncDocumentAppearance({
121
+ theme: hostState.theme,
122
+ contrastMode: message.contrastMode,
123
+ });
115
124
  this.notify();
116
125
  return;
117
126
  }
@@ -410,6 +419,10 @@ export class SandboxBridge {
410
419
  dataSources,
411
420
  dataSourceState: {},
412
421
  };
422
+ syncDocumentAppearance({
423
+ theme: message.theme,
424
+ contrastMode: message.contrastMode,
425
+ });
413
426
  this.notify();
414
427
  if (postResult) {
415
428
  const result = {
@@ -699,6 +712,27 @@ export class SandboxBridge {
699
712
  }
700
713
  }
701
714
  SandboxBridge.MAX_LOG_ENTRIES = 100;
715
+ /**
716
+ * Makes the document canvas match the host appearance before acknowledging init.
717
+ *
718
+ * The host reveals the iframe as soon as it receives `initResult.success`. Applying these
719
+ * attributes synchronously prevents the browser's default white canvas from flashing while React
720
+ * mounts a token scope.
721
+ */
722
+ function syncDocumentAppearance(args) {
723
+ if (typeof document === "undefined") {
724
+ return;
725
+ }
726
+ const { theme, contrastMode } = args;
727
+ const root = document.documentElement;
728
+ root.dataset.displayMode = theme;
729
+ root.dataset.contrastMode = contrastMode;
730
+ root.style.colorScheme = theme;
731
+ root.style.backgroundColor =
732
+ theme === "dark"
733
+ ? NOTION_DARK_BACKGROUND_BASE
734
+ : NOTION_LIGHT_BACKGROUND_BASE;
735
+ }
702
736
  /**
703
737
  * `postMessage` cloning creates new objects even for bindings that did not change.
704
738
  * Preserve their resolved object identity so React effects only run for changed bindings.
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Background color values used before the NDS token scope mounts.
3
+ *
4
+ * The light value matches NDS's semantic `--bg-base` token in light mode
5
+ * (`--gray-0`, white). The dark value is the existing SDK fallback canvas
6
+ * color; it is not an exact current generated NDS value. Current NDS maps
7
+ * dark `--bg-base` to `--gray-145` (approximately `#1b1b1b`), while the
8
+ * legacy notion-next gray surface is `rgba(32, 32, 32, 1)`.
9
+ *
10
+ * Keep the resolved values here because the document must be styled before the block's NDS
11
+ * stylesheet and token scope are guaranteed to be available.
12
+ */
13
+ export declare const NOTION_DARK_BACKGROUND_BASE = "#191918";
14
+ export declare const NOTION_LIGHT_BACKGROUND_BASE = "#ffffff";
15
+ //# sourceMappingURL=appearance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"appearance.d.ts","sourceRoot":"","sources":["../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/appearance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,2BAA2B,YAAY,CAAA;AACpD,eAAO,MAAM,4BAA4B,YAAY,CAAA"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Background color values used before the NDS token scope mounts.
3
+ *
4
+ * The light value matches NDS's semantic `--bg-base` token in light mode
5
+ * (`--gray-0`, white). The dark value is the existing SDK fallback canvas
6
+ * color; it is not an exact current generated NDS value. Current NDS maps
7
+ * dark `--bg-base` to `--gray-145` (approximately `#1b1b1b`), while the
8
+ * legacy notion-next gray surface is `rgba(32, 32, 32, 1)`.
9
+ *
10
+ * Keep the resolved values here because the document must be styled before the block's NDS
11
+ * stylesheet and token scope are guaranteed to be available.
12
+ */
13
+ export const NOTION_DARK_BACKGROUND_BASE = "#191918";
14
+ export const NOTION_LIGHT_BACKGROUND_BASE = "#ffffff";
@@ -9,7 +9,7 @@ import type { CustomBlockPage, NotionPageId } from "../protocol/pages/page.js";
9
9
  import type { NotionParent } from "../protocol/parent.js";
10
10
  import type { NotionTheme } from "../protocol/theme.js";
11
11
  import type { NotionUser } from "../protocol/users/user.js";
12
- import type { NotionDataSourcePage, NotionDataSourcePageUpdateArgs, NotionDataSourcePageUpdateResult } from "../types.js";
12
+ import type { NotionDataSourcePage, NotionDataSourcePageUpdateArgs, UpdatePageResult } from "../types.js";
13
13
  export type CustomBlockHostState = UninitializedHostState | InitializedHostState;
14
14
  export type UninitializedHostState = {
15
15
  status: "uninitialized";
@@ -68,6 +68,6 @@ export type UpdateDataSourcePageFn = (args: {
68
68
  dataSource: NotionDataSource;
69
69
  pageId: NotionPageId;
70
70
  pageUpdateArgs: NotionDataSourcePageUpdateArgs;
71
- }) => Promise<NotionDataSourcePageUpdateResult>;
71
+ }) => Promise<UpdatePageResult>;
72
72
  export declare function getDataSourceQueryView(hostState: CustomBlockHostState, key: string, updateDataSourcePage: UpdateDataSourcePageFn): DataSourceQueryView;
73
73
  //# sourceMappingURL=hostState.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hostState.d.ts","sourceRoot":"","sources":["../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/hostState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAA;AACtF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4DAA4D,CAAA;AAClG,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,gEAAgE,CAAA;AAEhH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gEA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,EAAE,OAAO,CAAA;IAChB,KAAK,CAAC,EAAE,mCAAmC,CAAA;IAC3C,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,WAAW,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,wBAAgB,+BAA+B,IAAI,oBAAoB,CAMtE;AAED;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG;IACjC,KAAK,EAAE,oBAAoB,EAAE,CAAA;IAC7B,gBAAgB,CAAC,EAAE,gBAAgB,CAAC,kBAAkB,CAAC,CAAA;IACvD,mBAAmB,EAAE;QAAE,CAAC,UAAU,EAAE,MAAM,GAAG,oBAAoB,CAAA;KAAE,CAAA;IACnE,gBAAgB,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;KAAE,CAAA;IACvD,oBAAoB,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,oBAAoB,GAAG,SAAS,CAAA;KAAE,CAAA;IACzE,SAAS,EAAE,OAAO,CAAA;IAClB,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,CAAC,EAAE,mCAAmC,CAAA;CAC3C,CAAA;AAWD;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG,CAAC,IAAI,EAAE;IAC3C,UAAU,EAAE,gBAAgB,CAAA;IAC5B,MAAM,EAAE,YAAY,CAAA;IACpB,cAAc,EAAE,8BAA8B,CAAA;CAC9C,KAAK,OAAO,CAAC,gCAAgC,CAAC,CAAA;AAE/C,wBAAgB,sBAAsB,CACrC,SAAS,EAAE,oBAAoB,EAC/B,GAAG,EAAE,MAAM,EACX,oBAAoB,EAAE,sBAAsB,GAC1C,mBAAmB,CAgErB"}
1
+ {"version":3,"file":"hostState.d.ts","sourceRoot":"","sources":["../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/hostState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAA;AACtF,OAAO,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./errors.js";
17
17
  export * from "./ids.js";
18
18
  export * from "./incomingType.js";
19
19
  export * from "./manifest.js";
20
+ export * from "./messagePayload.js";
20
21
  export * from "./messages/connect.js";
21
22
  export * from "./messages/contrastModeChanged.js";
22
23
  export * from "./messages/createPage.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../home/runner/work/custom-blocks/custom-blocks/protocol/src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,eAAe,CAAA;AAC7B,cAAc,6BAA6B,CAAA;AAC3C,cAAc,iCAAiC,CAAA;AAC/C,cAAc,kCAAkC,CAAA;AAChD,cAAc,4BAA4B,CAAA;AAC1C,cAAc,yBAAyB,CAAA;AACvC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,aAAa,CAAA;AAC3B,cAAc,UAAU,CAAA;AACxB,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,uBAAuB,CAAA;AACrC,cAAc,mCAAmC,CAAA;AACjD,cAAc,0BAA0B,CAAA;AACxC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,kCAAkC,CAAA;AAChD,cAAc,kCAAkC,CAAA;AAChD,cAAc,uBAAuB,CAAA;AACrC,cAAc,uBAAuB,CAAA;AACrC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,oBAAoB,CAAA;AAClC,cAAc,0BAA0B,CAAA;AACxC,cAAc,kCAAkC,CAAA;AAChD,cAAc,qCAAqC,CAAA;AACnD,cAAc,yBAAyB,CAAA;AACvC,cAAc,2BAA2B,CAAA;AACzC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,qCAAqC,CAAA;AACnD,cAAc,sBAAsB,CAAA;AACpC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,0BAA0B,CAAA;AACxC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,iBAAiB,CAAA;AAC/B,cAAc,aAAa,CAAA;AAC3B,cAAc,sBAAsB,CAAA;AACpC,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../home/runner/work/custom-blocks/custom-blocks/protocol/src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,eAAe,CAAA;AAC7B,cAAc,6BAA6B,CAAA;AAC3C,cAAc,iCAAiC,CAAA;AAC/C,cAAc,kCAAkC,CAAA;AAChD,cAAc,4BAA4B,CAAA;AAC1C,cAAc,yBAAyB,CAAA;AACvC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,aAAa,CAAA;AAC3B,cAAc,UAAU,CAAA;AACxB,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,qBAAqB,CAAA;AACnC,cAAc,uBAAuB,CAAA;AACrC,cAAc,mCAAmC,CAAA;AACjD,cAAc,0BAA0B,CAAA;AACxC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,kCAAkC,CAAA;AAChD,cAAc,kCAAkC,CAAA;AAChD,cAAc,uBAAuB,CAAA;AACrC,cAAc,uBAAuB,CAAA;AACrC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,oBAAoB,CAAA;AAClC,cAAc,0BAA0B,CAAA;AACxC,cAAc,kCAAkC,CAAA;AAChD,cAAc,qCAAqC,CAAA;AACnD,cAAc,yBAAyB,CAAA;AACvC,cAAc,2BAA2B,CAAA;AACzC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,qCAAqC,CAAA;AACnD,cAAc,sBAAsB,CAAA;AACpC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,0BAA0B,CAAA;AACxC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,iBAAiB,CAAA;AAC/B,cAAc,aAAa,CAAA;AAC3B,cAAc,sBAAsB,CAAA;AACpC,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA"}
@@ -17,6 +17,7 @@ export * from "./errors.js";
17
17
  export * from "./ids.js";
18
18
  export * from "./incomingType.js";
19
19
  export * from "./manifest.js";
20
+ export * from "./messagePayload.js";
20
21
  export * from "./messages/connect.js";
21
22
  export * from "./messages/contrastModeChanged.js";
22
23
  export * from "./messages/createPage.js";
@@ -0,0 +1,20 @@
1
+ import type { CustomBlockErrorInfo } from "./errors.js";
2
+ type WithTypedErrorInfo<T, TErrorInfo extends CustomBlockErrorInfo | undefined> = TErrorInfo extends CustomBlockErrorInfo ? T extends {
3
+ error: CustomBlockErrorInfo;
4
+ } ? Omit<T, "error"> & {
5
+ error: TErrorInfo;
6
+ } : T : T;
7
+ /**
8
+ * Removes bridge envelope fields from every member of a message union.
9
+ *
10
+ * The conditional type makes the operation distributive, preserving
11
+ * success/error-specific fields such as `page` and `error`.
12
+ *
13
+ * Pass an API-specific error-info type to preserve its known error-code
14
+ * literals while still accepting unknown string codes at runtime.
15
+ */
16
+ export type BridgeMessagePayload<T extends {
17
+ type: string;
18
+ }, TErrorInfo extends CustomBlockErrorInfo | undefined = undefined> = T extends unknown ? WithTypedErrorInfo<Omit<T, "type" | "requestId" | "subscriptionId">, TErrorInfo> : never;
19
+ export {};
20
+ //# sourceMappingURL=messagePayload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messagePayload.d.ts","sourceRoot":"","sources":["../../../../home/runner/work/custom-blocks/custom-blocks/protocol/src/messagePayload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAEvD,KAAK,kBAAkB,CACtB,CAAC,EACD,UAAU,SAAS,oBAAoB,GAAG,SAAS,IAChD,UAAU,SAAS,oBAAoB,GACxC,CAAC,SAAS;IAAE,KAAK,EAAE,oBAAoB,CAAA;CAAE,GACxC,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG;IAAE,KAAK,EAAE,UAAU,CAAA;CAAE,GACxC,CAAC,GACF,CAAC,CAAA;AAEJ;;;;;;;;GAQG;AACH,MAAM,MAAM,oBAAoB,CAC/B,CAAC,SAAS;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EAC1B,UAAU,SAAS,oBAAoB,GAAG,SAAS,GAAG,SAAS,IAC5D,CAAC,SAAS,OAAO,GAClB,kBAAkB,CAClB,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,gBAAgB,CAAC,EAChD,UAAU,CACV,GACA,KAAK,CAAA"}
@@ -0,0 +1 @@
1
+ export {};
package/dist/types.d.ts CHANGED
@@ -2,16 +2,16 @@ import type { NotionCollectionSchema } from "./protocol/dataSources/dataSource.j
2
2
  import type { NotionDataSourceValue } from "./protocol/dataSources/dataSourceValue.js";
3
3
  import type { NotionPropertySchema } from "./protocol/dataSources/propertySchema.js";
4
4
  import type { NotionDataSourceId, NotionPageId } from "./protocol/ids.js";
5
+ import type { BridgeMessagePayload } from "./protocol/messagePayload.js";
5
6
  import type { NotionCreatePagePosition } from "./protocol/messages/createPage.js";
6
- import type { CustomBlockCreatePageErrorInfo } from "./protocol/messages/createPageResult.js";
7
- import type { CustomBlockGetPageErrorInfo } from "./protocol/messages/getPage.js";
8
- import type { CustomBlockGetUserErrorInfo } from "./protocol/messages/getUser.js";
9
- import type { CustomBlockListUsersErrorInfo, ListUsersMessage } from "./protocol/messages/listUsers.js";
7
+ import type { CreatePageResultMessage, CustomBlockCreatePageErrorInfo } from "./protocol/messages/createPageResult.js";
8
+ import type { CustomBlockGetPageErrorInfo, GetPageResultMessage } from "./protocol/messages/getPage.js";
9
+ import type { CustomBlockGetUserErrorInfo, GetUserResultMessage } from "./protocol/messages/getUser.js";
10
+ import type { CustomBlockListUsersErrorInfo, ListUsersMessage, ListUsersResultMessage } from "./protocol/messages/listUsers.js";
10
11
  import type { CustomBlockQueryDataSourceErrorInfo } from "./protocol/messages/queryDataSourceResult.js";
11
12
  import type { UpdatePageMessage } from "./protocol/messages/updatePage.js";
12
- import type { CustomBlockUpdatePageErrorInfo } from "./protocol/messages/updatePageResult.js";
13
- import type { NotionPage, NotionPageCover, NotionPageIcon, NotionPagePropertyValue } from "./protocol/pages/page.js";
14
- import type { NotionUser, NotionUserList } from "./protocol/users/user.js";
13
+ import type { CustomBlockUpdatePageErrorInfo, UpdatePageResultMessage } from "./protocol/messages/updatePageResult.js";
14
+ import type { NotionPageCover, NotionPageIcon, NotionPagePropertyValue } from "./protocol/pages/page.js";
15
15
  export type { CustomBlockErrorInfo } from "./protocol/errors.js";
16
16
  export type { NotionDataSourceId, NotionPageId, NotionSpaceId, } from "./protocol/ids.js";
17
17
  export type { NotionUser, NotionUserId, NotionUserList, } from "./protocol/users/user.js";
@@ -55,7 +55,7 @@ export type NotionDataSourcePage = {
55
55
  * Updates this page using the data source's property-key bindings. The SDK resolves property
56
56
  * keys to raw property IDs before sending the bridge message to the host.
57
57
  */
58
- update: (args: NotionDataSourcePageUpdateArgs) => Promise<NotionDataSourcePageUpdateResult>;
58
+ update: (args: NotionDataSourcePageUpdateArgs) => Promise<UpdatePageResult>;
59
59
  };
60
60
  export type NotionDataSourcePageUpdateArgs = {
61
61
  properties?: NotionPagePropertyInputMap;
@@ -69,13 +69,12 @@ export type NotionDataSourcePageUpdateArgs = {
69
69
  * TODO(custom-blocks): Remove this alias when bumping the SDK version to 0.2.0.
70
70
  */
71
71
  export type NotionDataSourcePageUpdateInput = NotionDataSourcePageUpdateArgs;
72
- export type NotionDataSourcePageUpdateResult = {
73
- status: "success";
74
- page: NotionPage;
75
- } | {
76
- status: "error";
77
- error: CustomBlockUpdatePageErrorInfo;
78
- };
72
+ /**
73
+ * @deprecated Use `UpdatePageResult` instead.
74
+ *
75
+ * TODO(custom-blocks): Remove this alias when bumping the SDK version to 0.2.0.
76
+ */
77
+ export type NotionDataSourcePageUpdateResult = UpdatePageResult;
79
78
  /**
80
79
  * Return shape of `useDataSource`.
81
80
  *
@@ -162,14 +161,7 @@ export type CreatePageInput = CreatePageArgs;
162
161
  /**
163
162
  * The result of a `sdk.pages.create` API call.
164
163
  */
165
- export type CreatePageResult = {
166
- status: "success";
167
- /** The newly created page. */
168
- page: NotionPage;
169
- } | {
170
- status: "error";
171
- error: CustomBlockCreatePageErrorInfo;
172
- };
164
+ export type CreatePageResult = BridgeMessagePayload<CreatePageResultMessage, CustomBlockCreatePageErrorInfo>;
173
165
  export type UpdatePageArgs = Omit<UpdatePageMessage, "type" | "requestId">;
174
166
  /**
175
167
  * @deprecated Use `UpdatePageArgs` instead.
@@ -180,23 +172,11 @@ export type UpdatePageInput = UpdatePageArgs;
180
172
  /**
181
173
  * Result of `sdk.pages.get`.
182
174
  */
183
- export type GetPageResult = {
184
- status: "success";
185
- page: NotionPage;
186
- } | {
187
- status: "error";
188
- error: CustomBlockGetPageErrorInfo;
189
- };
175
+ export type GetPageResult = BridgeMessagePayload<GetPageResultMessage, CustomBlockGetPageErrorInfo>;
190
176
  /**
191
177
  * Result of `sdk.pages.update` / `sdk.pages.delete`.
192
178
  */
193
- export type UpdatePageResult = {
194
- status: "success";
195
- page: NotionPage;
196
- } | {
197
- status: "error";
198
- error: CustomBlockUpdatePageErrorInfo;
199
- };
179
+ export type UpdatePageResult = BridgeMessagePayload<UpdatePageResultMessage, CustomBlockUpdatePageErrorInfo>;
200
180
  export type ListUsersArgs = Omit<ListUsersMessage, "type" | "requestId">;
201
181
  /**
202
182
  * @deprecated Use `ListUsersArgs` instead.
@@ -204,18 +184,6 @@ export type ListUsersArgs = Omit<ListUsersMessage, "type" | "requestId">;
204
184
  * TODO(custom-blocks): Remove this alias when bumping the SDK version to 0.2.0.
205
185
  */
206
186
  export type ListUsersInput = ListUsersArgs;
207
- export type ListUsersResult = {
208
- status: "success";
209
- list: NotionUserList;
210
- } | {
211
- status: "error";
212
- error: CustomBlockListUsersErrorInfo;
213
- };
214
- export type GetUserResult = {
215
- status: "success";
216
- user: NotionUser;
217
- } | {
218
- status: "error";
219
- error: CustomBlockGetUserErrorInfo;
220
- };
187
+ export type ListUsersResult = BridgeMessagePayload<ListUsersResultMessage, CustomBlockListUsersErrorInfo>;
188
+ export type GetUserResult = BridgeMessagePayload<GetUserResultMessage, CustomBlockGetUserErrorInfo>;
221
189
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4DAA4D,CAAA;AACxG,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iEAAiE,CAAA;AAC5G,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gEAAgE,CAAA;AAC1G,OAAO,KAAK,EACX,kBAAkB,EAClB,YAAY,EACZ,MAAM,yCAAyC,CAAA;AAChD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,yDAAyD,CAAA;AACvG,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,+DAA+D,CAAA;AACnH,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,sDAAsD,CAAA;AACvG,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,sDAAsD,CAAA;AACvG,OAAO,KAAK,EACX,6BAA6B,EAC7B,gBAAgB,EAChB,MAAM,wDAAwD,CAAA;AAC/D,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,oEAAoE,CAAA;AAC7H,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAA;AAChG,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,+DAA+D,CAAA;AACnH,OAAO,KAAK,EACX,UAAU,EACV,eAAe,EACf,cAAc,EACd,uBAAuB,EACvB,MAAM,gDAAgD,CAAA;AACvD,OAAO,KAAK,EACX,UAAU,EACV,cAA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AC;IAAC,KAAK,EAAE,6BAA6B,CAAA;CAAE,CAAA;AAE5D,MAAM,MAAM,aAAa,GACtB;IACA,MAAM,EAAE,SAAS,CAAA;IACjB,IAAI,EAAE,UAAU,CAAA;CACf,GACD;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,2BAA2B,CAAA;CAAE,CAAA"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4DAA4D,CAAA;AACxG,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iEAAiE,CAAA;AAC5G,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gEAAgE,CAAA;AAC1G,OAAO,KAAK,EACX,kBAAkB,EAClB,YAAY,EACZ,MAAM,yCAAyC,CAAA;AAChD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oDAAoD,CAAA;AAC9F,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,yDAAyD,CAAA;AACvG,OAAO,KAAK,EACX,uBAAuB,EACvB,8BAA8B,EAC9B,MAAM,+DAA+D,CAAA;AACtE,OAAO,KAAK,EACX,2BAA2B,EAC3B,oBAAoB,EACpB,MAAM,sDAAsD,CAAA;AAC7D,OAAO,KAAK,EACX,2BAA2B,EAC3B,oBAAoB,EACpB,MAAM,sDAAsD,CAAA;AAC7D,OAAO,KAAK,EACX,6BAA6B,EAC7B,gBAAgB,EAChB,sBAAsB,EACtB,MAAM,wDAAwD,CAAA;AAC/D,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,oEAAoE,CAAA;AAC7H,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,CAAA;AAChG,OAAO,KAAK,EACX,8BAA8B,EAC9B,uBAAuB,EACvB,MAAM,+DAA+D,CAAA;AACtE,OAAO,KAAK,EACX,eAAe,EACf,cAA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,UAAU,EAAE,0BAA0B,CAAA;IAEtC,QAAQ,CAAC,EAAE,wBAAwB,CAAA;CACnC,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,cAAc,CAAA;AAE5C;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,CAClD,uBAAuB,EACvB,8BAA8B,CAC9B,CAAA;AAED,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,iBAAiB,EAAE,MAAM,GAAG,WAAW,CAAC,CAAA;AAE1E;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,cAAc,CAAA;AAE5C;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,oBAAoB,CAC/C,oBAAoB,EACpB,2BAA2B,CAC3B,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,CAClD,uBAAuB,EACvB,8BAA8B,CAC9B,CAAA;AAED,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,EAAE,MAAM,GAAG,WAAW,CAAC,CAAA;AAExE;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,aAAa,CAAA;AAE1C,MAAM,MAAM,eAAe,GAAG,oBAAoB,CACjD,sBAAsB,EACtB,6BAA6B,CAC7B,CAAA;AAED,MAAM,MAAM,aAAa,GAAG,oBAAoB,CAC/C,oBAAoB,EACpB,2BAA2B,CAC3B,CAAA"}
package/dist/version.js CHANGED
@@ -4,4 +4,4 @@
4
4
  *
5
5
  * WARNING: Generated during SDK publish. Do not edit in the published package.
6
6
  */
7
- export const CUSTOM_BLOCKS_SDK_VERSION = "0.1.18"
7
+ export const CUSTOM_BLOCKS_SDK_VERSION = "0.1.20"
@@ -158,8 +158,9 @@ export function ScoreList() {
158
158
  - `NotionDataSource` — a resolved data source: semantic key, `collectionSchema`, `propertyIdsByKey`, `propertySchemasById`.
159
159
  - `NotionDataSourcePage` — a single row exposed to app code: `{ id, propertiesById, propertiesByKey, update }`.
160
160
  - `NotionDataSourceValue` — the discriminated union of values that can appear inside `propertiesById[propertyId]`. Date values branch into the `NotionDateValue` union below.
161
- - `NotionDataSourcePageUpdateArgs` / `NotionDataSourcePageUpdateResult` — arguments and result for the per-page `update` helper.
161
+ - `NotionDataSourcePageUpdateArgs` / `UpdatePageResult` — arguments and result for the per-page `update` helper.
162
162
  - `NotionDataSourcePageUpdateInput` — deprecated alias for `NotionDataSourcePageUpdateArgs`.
163
+ - `NotionDataSourcePageUpdateResult` — deprecated alias for `UpdatePageResult`.
163
164
  - `UseDataSourceOptions` — options accepted by `useDataSource`, currently `{ limit?: number }`.
164
165
 
165
166
  ### Property schemas
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@notionhq/custom-blocks",
3
- "version": "0.1.18",
3
+ "version": "0.1.20",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -1,3 +1,4 @@
1
+ import type { NotionContrastMode } from "@notionhq/custom-blocks-protocol/contrast.js"
1
2
  import { DEFAULT_CONTRAST_MODE } from "@notionhq/custom-blocks-protocol/contrast.js"
2
3
  import type {
3
4
  NotionDataSource,
@@ -29,6 +30,7 @@ import type { CustomBlockQueryDataSourceErrorInfo } from "@notionhq/custom-block
29
30
  import type { ResizeMessage } from "@notionhq/custom-blocks-protocol/messages/resize.js"
30
31
  import type { UpdatePageMessage } from "@notionhq/custom-blocks-protocol/messages/updatePage.js"
31
32
  import { CUSTOM_BLOCK_BRIDGE_PROTOCOL_VERSION } from "@notionhq/custom-blocks-protocol/protocolVersion.js"
33
+ import type { NotionTheme } from "@notionhq/custom-blocks-protocol/theme.js"
32
34
  import type { NotionUser } from "@notionhq/custom-blocks-protocol/users/user.js"
33
35
  import * as v from "valibot"
34
36
  import type {
@@ -39,7 +41,6 @@ import type {
39
41
  ListUsersArgs,
40
42
  ListUsersResult,
41
43
  NotionDataSourcePageUpdateArgs,
42
- NotionDataSourcePageUpdateResult,
43
44
  NotionPageId,
44
45
  NotionUserId,
45
46
  UpdatePageArgs,
@@ -48,6 +49,10 @@ import type {
48
49
  } from "../types.js"
49
50
  import { unreachable } from "../utils.js"
50
51
  import { CUSTOM_BLOCKS_SDK_VERSION } from "../version.js"
52
+ import {
53
+ NOTION_DARK_BACKGROUND_BASE,
54
+ NOTION_LIGHT_BACKGROUND_BASE,
55
+ } from "./appearance.js"
51
56
  import { resolveDataSources } from "./dataSources/resolve.js"
52
57
  import { resolvePropertyWriteMapForDataSource } from "./dataSources/resolveProperty.js"
53
58
  import {
@@ -291,6 +296,10 @@ export class SandboxBridge {
291
296
  ...hostState,
292
297
  theme: message.theme,
293
298
  }
299
+ syncDocumentAppearance({
300
+ theme: message.theme,
301
+ contrastMode: hostState.contrastMode,
302
+ })
294
303
  this.notify()
295
304
  return
296
305
  }
@@ -300,6 +309,10 @@ export class SandboxBridge {
300
309
  ...hostState,
301
310
  contrastMode: message.contrastMode,
302
311
  }
312
+ syncDocumentAppearance({
313
+ theme: hostState.theme,
314
+ contrastMode: message.contrastMode,
315
+ })
303
316
  this.notify()
304
317
  return
305
318
  }
@@ -550,6 +563,10 @@ export class SandboxBridge {
550
563
  dataSources,
551
564
  dataSourceState: {},
552
565
  }
566
+ syncDocumentAppearance({
567
+ theme: message.theme,
568
+ contrastMode: message.contrastMode,
569
+ })
553
570
  this.notify()
554
571
  if (postResult) {
555
572
  const result: InitResultMessage = {
@@ -789,7 +806,7 @@ export class SandboxBridge {
789
806
  dataSource: NotionDataSource
790
807
  pageId: NotionPageId
791
808
  pageUpdateArgs: NotionDataSourcePageUpdateArgs
792
- }): Promise<NotionDataSourcePageUpdateResult> {
809
+ }): Promise<UpdatePageResult> {
793
810
  const { dataSource, pageId, pageUpdateArgs } = args
794
811
  const resolvedProperties =
795
812
  pageUpdateArgs.properties === undefined
@@ -885,6 +902,31 @@ export class SandboxBridge {
885
902
  }
886
903
  }
887
904
 
905
+ /**
906
+ * Makes the document canvas match the host appearance before acknowledging init.
907
+ *
908
+ * The host reveals the iframe as soon as it receives `initResult.success`. Applying these
909
+ * attributes synchronously prevents the browser's default white canvas from flashing while React
910
+ * mounts a token scope.
911
+ */
912
+ function syncDocumentAppearance(args: {
913
+ theme: NotionTheme
914
+ contrastMode: NotionContrastMode
915
+ }): void {
916
+ if (typeof document === "undefined") {
917
+ return
918
+ }
919
+ const { theme, contrastMode } = args
920
+ const root = document.documentElement
921
+ root.dataset.displayMode = theme
922
+ root.dataset.contrastMode = contrastMode
923
+ root.style.colorScheme = theme
924
+ root.style.backgroundColor =
925
+ theme === "dark"
926
+ ? NOTION_DARK_BACKGROUND_BASE
927
+ : NOTION_LIGHT_BACKGROUND_BASE
928
+ }
929
+
888
930
  /**
889
931
  * `postMessage` cloning creates new objects even for bindings that did not change.
890
932
  * Preserve their resolved object identity so React effects only run for changed bindings.
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Background color values used before the NDS token scope mounts.
3
+ *
4
+ * The light value matches NDS's semantic `--bg-base` token in light mode
5
+ * (`--gray-0`, white). The dark value is the existing SDK fallback canvas
6
+ * color; it is not an exact current generated NDS value. Current NDS maps
7
+ * dark `--bg-base` to `--gray-145` (approximately `#1b1b1b`), while the
8
+ * legacy notion-next gray surface is `rgba(32, 32, 32, 1)`.
9
+ *
10
+ * Keep the resolved values here because the document must be styled before the block's NDS
11
+ * stylesheet and token scope are guaranteed to be available.
12
+ */
13
+ export const NOTION_DARK_BACKGROUND_BASE = "#191918"
14
+ export const NOTION_LIGHT_BACKGROUND_BASE = "#ffffff"
@@ -16,7 +16,7 @@ import type { NotionUser } from "@notionhq/custom-blocks-protocol/users/user.js"
16
16
  import type {
17
17
  NotionDataSourcePage,
18
18
  NotionDataSourcePageUpdateArgs,
19
- NotionDataSourcePageUpdateResult,
19
+ UpdatePageResult,
20
20
  } from "../types.js"
21
21
 
22
22
  export type CustomBlockHostState = UninitializedHostState | InitializedHostState
@@ -92,7 +92,7 @@ export type UpdateDataSourcePageFn = (args: {
92
92
  dataSource: NotionDataSource
93
93
  pageId: NotionPageId
94
94
  pageUpdateArgs: NotionDataSourcePageUpdateArgs
95
- }) => Promise<NotionDataSourcePageUpdateResult>
95
+ }) => Promise<UpdatePageResult>
96
96
 
97
97
  export function getDataSourceQueryView(
98
98
  hostState: CustomBlockHostState,
package/src/types.ts CHANGED
@@ -5,27 +5,36 @@ import type {
5
5
  NotionDataSourceId,
6
6
  NotionPageId,
7
7
  } from "@notionhq/custom-blocks-protocol/ids.js"
8
+ import type { BridgeMessagePayload } from "@notionhq/custom-blocks-protocol/messagePayload.js"
8
9
  import type { NotionCreatePagePosition } from "@notionhq/custom-blocks-protocol/messages/createPage.js"
9
- import type { CustomBlockCreatePageErrorInfo } from "@notionhq/custom-blocks-protocol/messages/createPageResult.js"
10
- import type { CustomBlockGetPageErrorInfo } from "@notionhq/custom-blocks-protocol/messages/getPage.js"
11
- import type { CustomBlockGetUserErrorInfo } from "@notionhq/custom-blocks-protocol/messages/getUser.js"
10
+ import type {
11
+ CreatePageResultMessage,
12
+ CustomBlockCreatePageErrorInfo,
13
+ } from "@notionhq/custom-blocks-protocol/messages/createPageResult.js"
14
+ import type {
15
+ CustomBlockGetPageErrorInfo,
16
+ GetPageResultMessage,
17
+ } from "@notionhq/custom-blocks-protocol/messages/getPage.js"
18
+ import type {
19
+ CustomBlockGetUserErrorInfo,
20
+ GetUserResultMessage,
21
+ } from "@notionhq/custom-blocks-protocol/messages/getUser.js"
12
22
  import type {
13
23
  CustomBlockListUsersErrorInfo,
14
24
  ListUsersMessage,
25
+ ListUsersResultMessage,
15
26
  } from "@notionhq/custom-blocks-protocol/messages/listUsers.js"
16
27
  import type { CustomBlockQueryDataSourceErrorInfo } from "@notionhq/custom-blocks-protocol/messages/queryDataSourceResult.js"
17
28
  import type { UpdatePageMessage } from "@notionhq/custom-blocks-protocol/messages/updatePage.js"
18
- import type { CustomBlockUpdatePageErrorInfo } from "@notionhq/custom-blocks-protocol/messages/updatePageResult.js"
19
29
  import type {
20
- NotionPage,
30
+ CustomBlockUpdatePageErrorInfo,
31
+ UpdatePageResultMessage,
32
+ } from "@notionhq/custom-blocks-protocol/messages/updatePageResult.js"
33
+ import type {
21
34
  NotionPageCover,
22
35
  NotionPageIcon,
23
36
  NotionPagePropertyValue,
24
37
  } from "@notionhq/custom-blocks-protocol/pages/page.js"
25
- import type {
26
- NotionUser,
27
- NotionUserList,
28
- } from "@notionhq/custom-blocks-protocol/users/user.js"
29
38
 
30
39
  export type { CustomBlockErrorInfo } from "@notionhq/custom-blocks-protocol/errors.js"
31
40
  export type {
@@ -84,9 +93,7 @@ export type NotionDataSourcePage = {
84
93
  * Updates this page using the data source's property-key bindings. The SDK resolves property
85
94
  * keys to raw property IDs before sending the bridge message to the host.
86
95
  */
87
- update: (
88
- args: NotionDataSourcePageUpdateArgs,
89
- ) => Promise<NotionDataSourcePageUpdateResult>
96
+ update: (args: NotionDataSourcePageUpdateArgs) => Promise<UpdatePageResult>
90
97
  }
91
98
 
92
99
  export type NotionDataSourcePageUpdateArgs = {
@@ -103,12 +110,12 @@ export type NotionDataSourcePageUpdateArgs = {
103
110
  */
104
111
  export type NotionDataSourcePageUpdateInput = NotionDataSourcePageUpdateArgs
105
112
 
106
- export type NotionDataSourcePageUpdateResult =
107
- | {
108
- status: "success"
109
- page: NotionPage
110
- }
111
- | { status: "error"; error: CustomBlockUpdatePageErrorInfo }
113
+ /**
114
+ * @deprecated Use `UpdatePageResult` instead.
115
+ *
116
+ * TODO(custom-blocks): Remove this alias when bumping the SDK version to 0.2.0.
117
+ */
118
+ export type NotionDataSourcePageUpdateResult = UpdatePageResult
112
119
 
113
120
  /**
114
121
  * Return shape of `useDataSource`.
@@ -190,13 +197,10 @@ export type CreatePageInput = CreatePageArgs
190
197
  /**
191
198
  * The result of a `sdk.pages.create` API call.
192
199
  */
193
- export type CreatePageResult =
194
- | {
195
- status: "success"
196
- /** The newly created page. */
197
- page: NotionPage
198
- }
199
- | { status: "error"; error: CustomBlockCreatePageErrorInfo }
200
+ export type CreatePageResult = BridgeMessagePayload<
201
+ CreatePageResultMessage,
202
+ CustomBlockCreatePageErrorInfo
203
+ >
200
204
 
201
205
  export type UpdatePageArgs = Omit<UpdatePageMessage, "type" | "requestId">
202
206
 
@@ -210,22 +214,18 @@ export type UpdatePageInput = UpdatePageArgs
210
214
  /**
211
215
  * Result of `sdk.pages.get`.
212
216
  */
213
- export type GetPageResult =
214
- | {
215
- status: "success"
216
- page: NotionPage
217
- }
218
- | { status: "error"; error: CustomBlockGetPageErrorInfo }
217
+ export type GetPageResult = BridgeMessagePayload<
218
+ GetPageResultMessage,
219
+ CustomBlockGetPageErrorInfo
220
+ >
219
221
 
220
222
  /**
221
223
  * Result of `sdk.pages.update` / `sdk.pages.delete`.
222
224
  */
223
- export type UpdatePageResult =
224
- | {
225
- status: "success"
226
- page: NotionPage
227
- }
228
- | { status: "error"; error: CustomBlockUpdatePageErrorInfo }
225
+ export type UpdatePageResult = BridgeMessagePayload<
226
+ UpdatePageResultMessage,
227
+ CustomBlockUpdatePageErrorInfo
228
+ >
229
229
 
230
230
  export type ListUsersArgs = Omit<ListUsersMessage, "type" | "requestId">
231
231
 
@@ -236,16 +236,12 @@ export type ListUsersArgs = Omit<ListUsersMessage, "type" | "requestId">
236
236
  */
237
237
  export type ListUsersInput = ListUsersArgs
238
238
 
239
- export type ListUsersResult =
240
- | {
241
- status: "success"
242
- list: NotionUserList
243
- }
244
- | { status: "error"; error: CustomBlockListUsersErrorInfo }
245
-
246
- export type GetUserResult =
247
- | {
248
- status: "success"
249
- user: NotionUser
250
- }
251
- | { status: "error"; error: CustomBlockGetUserErrorInfo }
239
+ export type ListUsersResult = BridgeMessagePayload<
240
+ ListUsersResultMessage,
241
+ CustomBlockListUsersErrorInfo
242
+ >
243
+
244
+ export type GetUserResult = BridgeMessagePayload<
245
+ GetUserResultMessage,
246
+ CustomBlockGetUserErrorInfo
247
+ >