@notionhq/custom-blocks 0.1.17 → 0.1.19

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.
Files changed (47) hide show
  1. package/dist/bridge/SandboxBridge.d.ts +2 -1
  2. package/dist/bridge/SandboxBridge.d.ts.map +1 -1
  3. package/dist/bridge/SandboxBridge.js +41 -5
  4. package/dist/bridge/appearance.d.ts +15 -0
  5. package/dist/bridge/appearance.d.ts.map +1 -0
  6. package/dist/bridge/appearance.js +14 -0
  7. package/dist/bridge/sandboxClient.d.ts +1 -0
  8. package/dist/bridge/sandboxClient.d.ts.map +1 -1
  9. package/dist/bridge/sandboxClient.js +26 -17
  10. package/dist/init.d.ts.map +1 -1
  11. package/dist/init.js +1 -0
  12. package/dist/protocol/dataSources/dataSource.d.ts +12 -12
  13. package/dist/protocol/dataSources/dataSourcePage.d.ts +1 -1
  14. package/dist/protocol/ids.d.ts +10 -26
  15. package/dist/protocol/ids.d.ts.map +1 -1
  16. package/dist/protocol/ids.js +25 -5
  17. package/dist/protocol/messages/createPage.d.ts +8 -8
  18. package/dist/protocol/messages/createPageResult.d.ts +5 -5
  19. package/dist/protocol/messages/currentUserChanged.d.ts +1 -1
  20. package/dist/protocol/messages/dataSourcesChanged.d.ts +3 -3
  21. package/dist/protocol/messages/getPage.d.ts +6 -6
  22. package/dist/protocol/messages/getUser.d.ts +2 -2
  23. package/dist/protocol/messages/getUser.js +2 -2
  24. package/dist/protocol/messages/hostToSandbox.d.ts +45 -45
  25. package/dist/protocol/messages/init.d.ts +14 -14
  26. package/dist/protocol/messages/listUsers.d.ts +1 -1
  27. package/dist/protocol/messages/pageChanged.d.ts +5 -5
  28. package/dist/protocol/messages/parentChanged.d.ts +4 -4
  29. package/dist/protocol/messages/queryDataSource.d.ts +1 -1
  30. package/dist/protocol/messages/queryDataSourceResult.d.ts +1 -1
  31. package/dist/protocol/messages/sandboxToHost.d.ts +8 -8
  32. package/dist/protocol/messages/updatePage.d.ts +1 -1
  33. package/dist/protocol/messages/updatePageResult.d.ts +5 -5
  34. package/dist/protocol/pages/page.d.ts +10 -10
  35. package/dist/protocol/parent.d.ts +4 -4
  36. package/dist/protocol/users/user.d.ts +4 -7
  37. package/dist/protocol/users/user.d.ts.map +1 -1
  38. package/dist/protocol/users/user.js +2 -1
  39. package/dist/react/standalonePreview.d.ts.map +1 -1
  40. package/dist/react/standalonePreview.js +3 -1
  41. package/dist/version.js +1 -1
  42. package/package.json +1 -1
  43. package/src/bridge/SandboxBridge.ts +49 -6
  44. package/src/bridge/appearance.ts +14 -0
  45. package/src/bridge/sandboxClient.ts +28 -17
  46. package/src/init.ts +1 -0
  47. package/src/react/standalonePreview.ts +3 -1
@@ -28,10 +28,11 @@ export declare class SandboxBridge {
28
28
  private initializationId;
29
29
  private latestDataSourceBindings;
30
30
  private isMockState;
31
+ private isListening;
31
32
  private resolveInit;
32
33
  private rejectInit;
33
34
  private readonly initMessage;
34
- constructor();
35
+ startListening(): void;
35
36
  private static MAX_LOG_ENTRIES;
36
37
  private logMessage;
37
38
  getMessageLog(): readonly MessageLogEntry[];
@@ -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,8BAA8B,EAC9B,gCAAgC,EAChC,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,MAAM,aAAa,CAAA;AAKpB,OAAO,EACN,KAAK,oBAAoB,EAGzB,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EAAE,kBA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CAAC,QAAQ,EAAE,MAAM,IAAI;IAK9B,YAAY,IAAI,oBAAoB;IAIpC;;;;;OAKG;IACH,YAAY,CAAC,OAAO,EAAE,WAAW;IAKjC,OAAO,CAAC,SAAS;IA8EjB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,oBAAyB;IAgE/D,OAAO,CAAC,uBAAuB;IAwB/B,UAAU,CAAC,MAAM,EAAE,MAAM;IAazB,UAAU,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA8B3D,OAAO,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC;IAYrD,OAAO,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC;IAYrD,SAAS,CAAC,IAAI,GAAE,aAAkB,GAAG,OAAO,CAAC,eAAe,CAAC;IAa7D,UAAU,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA2C3D;;;;OAIG;IACH,oBAAoB,CAAC,IAAI,EAAE;QAC1B,UAAU,EAAE,gBAAgB,CAAA;QAC5B,MAAM,EAAE,YAAY,CAAA;QACpB,cAAc,EAAE,8BAA8B,CAAA;KAC9C,GAAG,OAAO,CAAC,gCAAgC,CAAC;IAuB7C;;;;OAIG;IACH,OAAO,CAAC,uBAAuB;CAkE/B"}
1
+ {"version":3,"file":"SandboxBridge.d.ts","sourceRoot":"","sources":["../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/SandboxBridge.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACX,gBAAgB,EAEhB,MAAM,4DAA4D,CAAA;AAWnE,OAAO,EAEN,KAAK,WAAW,EAEhB,MAAM,mDAAmD,CAAA;AAe1D,OAAO,KAAK,EACX,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,aAAa,EACb,eAAe,EACf,8BAA8B,EAC9B,gCAAgC,EAChC,YAAY,EACZ,YAAY,EAC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,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAwB9C,WAAW,CAAC,cAAc,EAAE,kBAAkB;IAkC9C,OAAO,CAAC,UAAU;IAMlB,OAAO,CAAC,MAAM,CAIb;IAED,OAAO,CAAC,aAAa,CA0QpB;IAED,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI;IAK9B,YAAY,IAAI,oBAAoB;IAIpC;;;;;OAKG;IACH,YAAY,CAAC,OAAO,EAAE,WAAW;IAKjC,OAAO,CAAC,SAAS;IAkFjB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,oBAAyB;IAgE/D,OAAO,CAAC,uBAAuB;IAwB/B,UAAU,CAAC,MAAM,EAAE,MAAM;IAazB,UAAU,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA8B3D,OAAO,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC;IAYrD,OAAO,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC;IAYrD,SAAS,CAAC,IAAI,GAAE,aAAkB,GAAG,OAAO,CAAC,eAAe,CAAC;IAa7D,UAAU,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA2C3D;;;;OAIG;IACH,oBAAoB,CAAC,IAAI,EAAE;QAC1B,UAAU,EAAE,gBAAgB,CAAA;QAC5B,MAAM,EAAE,YAAY,CAAA;QACpB,cAAc,EAAE,8BAA8B,CAAA;KAC9C,GAAG,OAAO,CAAC,gCAAgC,CAAC;IAuB7C;;;;OAIG;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";
@@ -30,6 +31,7 @@ export class SandboxBridge {
30
31
  this.hasReceivedInit = false;
31
32
  this.latestDataSourceBindings = {};
32
33
  this.isMockState = false;
34
+ this.isListening = false;
33
35
  this.initMessage = new Promise((resolve, reject) => {
34
36
  this.resolveInit = resolve;
35
37
  this.rejectInit = reject;
@@ -103,6 +105,10 @@ export class SandboxBridge {
103
105
  ...hostState,
104
106
  theme: message.theme,
105
107
  };
108
+ syncDocumentAppearance({
109
+ theme: message.theme,
110
+ contrastMode: hostState.contrastMode,
111
+ });
106
112
  this.notify();
107
113
  return;
108
114
  }
@@ -111,6 +117,10 @@ export class SandboxBridge {
111
117
  ...hostState,
112
118
  contrastMode: message.contrastMode,
113
119
  };
120
+ syncDocumentAppearance({
121
+ theme: hostState.theme,
122
+ contrastMode: message.contrastMode,
123
+ });
114
124
  this.notify();
115
125
  return;
116
126
  }
@@ -252,12 +262,13 @@ export class SandboxBridge {
252
262
  }
253
263
  }
254
264
  };
255
- // `connect` is sent later by `initCustomBlock` (after the manifest fetch
256
- // resolves). Top-level / no-iframe rejection is handled there too, so
257
- // the constructor just attaches the listener.
258
- if (typeof window !== "undefined") {
259
- window.addEventListener("message", this.handleMessage);
265
+ }
266
+ startListening() {
267
+ if (this.isListening || typeof window === "undefined") {
268
+ return;
260
269
  }
270
+ this.isListening = true;
271
+ window.addEventListener("message", this.handleMessage);
261
272
  }
262
273
  logMessage(direction, data) {
263
274
  if (this.messageLog.length >= SandboxBridge.MAX_LOG_ENTRIES) {
@@ -408,6 +419,10 @@ export class SandboxBridge {
408
419
  dataSources,
409
420
  dataSourceState: {},
410
421
  };
422
+ syncDocumentAppearance({
423
+ theme: message.theme,
424
+ contrastMode: message.contrastMode,
425
+ });
411
426
  this.notify();
412
427
  if (postResult) {
413
428
  const result = {
@@ -697,6 +712,27 @@ export class SandboxBridge {
697
712
  }
698
713
  }
699
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
+ }
700
736
  /**
701
737
  * `postMessage` cloning creates new objects even for bindings that did not change.
702
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";
@@ -5,6 +5,7 @@ import type { ManifestLoadResult } from "./loadManifest.js";
5
5
  import { type MessageLogEntry } from "./SandboxBridge.js";
6
6
  export type { MessageLogEntry };
7
7
  export declare const customBlockHost: {
8
+ start: () => void;
8
9
  sendConnect: (manifestResult: ManifestLoadResult) => void;
9
10
  awaitInit: (signal?: AbortSignal) => Promise<void>;
10
11
  subscribe: (listener: () => void) => () => boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"sandboxClient.d.ts","sourceRoot":"","sources":["../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/sandboxClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mDAAmD,CAAA;AACpF,OAAO,KAAK,EACX,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,aAAa,EACb,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,MAAM,aAAa,CAAA;AACpB,OAAO,EACN,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EAExB,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,EAAE,KAAK,eAAe,EAAiB,MAAM,oBAAoB,CAAA;AAExE,YAAY,EAAE,eAAe,EAAE,CAAA;AAI/B,eAAO,MAAM,eAAe;kCACG,kBAAkB;yBAI3B,WAAW,KAAG,OAAO,CAAC,IAAI,CAAC;0BAI1B,MAAM,IAAI;oBAIlB,oBAAoB;IAIlC;;;OAGG;4BACqB,WAAW;yBAId,MAAM;CAG3B,CAAA;AAED,eAAO,MAAM,sBAAsB;iBACrB,MAAM,YAAY,oBAAoB;yBAKvC,oBAAoB,OAC1B,MAAM,KACT,mBAAmB;CAKtB,CAAA;AAED,eAAO,MAAM,UAAU;uBACL,SAAS,eAAe,EAAE;0BAIrB,MAAM,IAAI;CAGhC,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,KAAK;IACjB;;OAEG;oBACa,cAAc,KAAG,OAAO,CAAC,gBAAgB,CAAC;IAI1D;;OAEG;kBACW,YAAY,KAAG,OAAO,CAAC,aAAa,CAAC;IAInD;;OAEG;oBACa,cAAc,KAAG,OAAO,CAAC,gBAAgB,CAAC;IAI1D;;OAEG;qBACc,YAAY,KAAG,OAAO,CAAC,gBAAgB,CAAC;CAGzD,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,KAAK;IACjB;;OAEG;mBACY,aAAa,KAAG,OAAO,CAAC,eAAe,CAAC;IAIvD;;OAEG;kBACW,YAAY,KAAG,OAAO,CAAC,aAAa,CAAC;CAGnD,CAAA"}
1
+ {"version":3,"file":"sandboxClient.d.ts","sourceRoot":"","sources":["../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/sandboxClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mDAAmD,CAAA;AACpF,OAAO,KAAK,EACX,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,aAAa,EACb,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,MAAM,aAAa,CAAA;AACpB,OAAO,EACN,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EAExB,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,EAAE,KAAK,eAAe,EAAiB,MAAM,oBAAoB,CAAA;AAExE,YAAY,EAAE,eAAe,EAAE,CAAA;AAW/B,eAAO,MAAM,eAAe;;kCAKG,kBAAkB;yBAI3B,WAAW,KAAG,OAAO,CAAC,IAAI,CAAC;0BAI1B,MAAM,IAAI;oBAIlB,oBAAoB;IAIlC;;;OAGG;4BACqB,WAAW;yBAId,MAAM;CAG3B,CAAA;AAED,eAAO,MAAM,sBAAsB;iBACrB,MAAM,YAAY,oBAAoB;yBAKvC,oBAAoB,OAC1B,MAAM,KACT,mBAAmB;CAKtB,CAAA;AAED,eAAO,MAAM,UAAU;uBACL,SAAS,eAAe,EAAE;0BAIrB,MAAM,IAAI;CAGhC,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,KAAK;IACjB;;OAEG;oBACa,cAAc,KAAG,OAAO,CAAC,gBAAgB,CAAC;IAI1D;;OAEG;kBACW,YAAY,KAAG,OAAO,CAAC,aAAa,CAAC;IAInD;;OAEG;oBACa,cAAc,KAAG,OAAO,CAAC,gBAAgB,CAAC;IAI1D;;OAEG;qBACc,YAAY,KAAG,OAAO,CAAC,gBAAgB,CAAC;CAGzD,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,KAAK;IACjB;;OAEG;mBACY,aAAa,KAAG,OAAO,CAAC,eAAe,CAAC;IAIvD;;OAEG;kBACW,YAAY,KAAG,OAAO,CAAC,aAAa,CAAC;CAGnD,CAAA"}
@@ -1,44 +1,53 @@
1
1
  import { getDataSourceQueryView as getDataSourceQueryViewWithBridge, } from "./hostState.js";
2
2
  import { SandboxBridge } from "./SandboxBridge.js";
3
- const bridge = new SandboxBridge();
3
+ let bridge;
4
+ function getBridge() {
5
+ if (!bridge) {
6
+ bridge = new SandboxBridge();
7
+ }
8
+ return bridge;
9
+ }
4
10
  export const customBlockHost = {
11
+ start: () => {
12
+ getBridge().startListening();
13
+ },
5
14
  sendConnect: (manifestResult) => {
6
- bridge.sendConnect(manifestResult);
15
+ getBridge().sendConnect(manifestResult);
7
16
  },
8
17
  awaitInit: (signal) => {
9
- return bridge.awaitInit(signal);
18
+ return getBridge().awaitInit(signal);
10
19
  },
11
20
  subscribe: (listener) => {
12
- return bridge.subscribe(listener);
21
+ return getBridge().subscribe(listener);
13
22
  },
14
23
  getState: () => {
15
- return bridge.getHostState();
24
+ return getBridge().getHostState();
16
25
  },
17
26
  /**
18
27
  * Apply an `init` payload directly, bypassing the postMessage handshake for
19
28
  * standalone preview state.
20
29
  */
21
30
  setMockState: (message) => {
22
- bridge.setMockState(message);
31
+ getBridge().setMockState(message);
23
32
  },
24
33
  postResize: (height) => {
25
- bridge.postResize(height);
34
+ getBridge().postResize(height);
26
35
  },
27
36
  };
28
37
  export const customBlockDataSources = {
29
38
  query: (key, options) => {
30
- bridge.queryDataSource(key, options);
39
+ getBridge().queryDataSource(key, options);
31
40
  },
32
41
  getView: (hostState, key) => {
33
- return getDataSourceQueryViewWithBridge(hostState, key, args => bridge.updateDataSourcePage(args));
42
+ return getDataSourceQueryViewWithBridge(hostState, key, args => getBridge().updateDataSourcePage(args));
34
43
  },
35
44
  };
36
45
  export const messageLog = {
37
46
  getSnapshot: () => {
38
- return bridge.getMessageLog();
47
+ return getBridge().getMessageLog();
39
48
  },
40
49
  subscribe: (listener) => {
41
- return bridge.subscribeToMessageLog(listener);
50
+ return getBridge().subscribeToMessageLog(listener);
42
51
  },
43
52
  };
44
53
  /**
@@ -49,25 +58,25 @@ export const pages = {
49
58
  * Creates a new Notion page.
50
59
  */
51
60
  create: (input) => {
52
- return bridge.createPage(input);
61
+ return getBridge().createPage(input);
53
62
  },
54
63
  /**
55
64
  * Fetches a page by id.
56
65
  */
57
66
  get: (pageId) => {
58
- return bridge.getPage(pageId);
67
+ return getBridge().getPage(pageId);
59
68
  },
60
69
  /**
61
70
  * Updates an existing page.
62
71
  */
63
72
  update: (input) => {
64
- return bridge.updatePage(input);
73
+ return getBridge().updatePage(input);
65
74
  },
66
75
  /**
67
76
  * Soft-delete a page by archiving it.
68
77
  */
69
78
  delete: (pageId) => {
70
- return bridge.updatePage({ pageId, archived: true });
79
+ return getBridge().updatePage({ pageId, archived: true });
71
80
  },
72
81
  };
73
82
  /**
@@ -78,12 +87,12 @@ export const users = {
78
87
  * Lists users visible in the current custom block workspace.
79
88
  */
80
89
  list: (input) => {
81
- return bridge.listUsers(input);
90
+ return getBridge().listUsers(input);
82
91
  },
83
92
  /**
84
93
  * Fetches a user by id.
85
94
  */
86
95
  get: (userId) => {
87
- return bridge.getUser(userId);
96
+ return getBridge().getUser(userId);
88
97
  },
89
98
  };
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/init.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,aAAa,EAAE,MAAM,yCAAyC,CAAA;AAC5E,OAAO,EAAE,8BAA8B,EAAE,MAAM,mDAAmD,CAAA;AAClG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAA;AACrF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAA;AAC9E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAA;AAC5E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gDAAgD,CAAA;AAKhF;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACpC,KAAK,EAAE,WAAW,CAAA;IAClB,YAAY,EAAE,kBAAkB,CAAA;IAChC,OAAO,EAAE,aAAa,CAAA;IACtB,MAAM,EAAE,YAAY,CAAA;IACpB,IAAI,EAAE,eAAe,CAAA;IACrB,WAAW,EAAE,UAAU,CAAA;IACvB,WAAW,EAAE,gBAAgB,EAAE,CAAA;CAC/B,CAAA;AAED;;;;;GAKG;AACH,qBAAa,gBAAiB,SAAQ,8BAA8B;gBACvD,OAAO,GAAE,MAA8B;IAS3C,IAAI,EAAE,eAAe,CAAA;CAC7B;AAED;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACpC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AASD;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC9B,IAAI,GAAE,sBAA2B,GAC/B,OAAO,CAAC,sBAAsB,CAAC,CAKjC"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/init.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,aAAa,EAAE,MAAM,yCAAyC,CAAA;AAC5E,OAAO,EAAE,8BAA8B,EAAE,MAAM,mDAAmD,CAAA;AAClG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAA;AACrF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAA;AAC9E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAA;AAC5E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gDAAgD,CAAA;AAKhF;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACpC,KAAK,EAAE,WAAW,CAAA;IAClB,YAAY,EAAE,kBAAkB,CAAA;IAChC,OAAO,EAAE,aAAa,CAAA;IACtB,MAAM,EAAE,YAAY,CAAA;IACpB,IAAI,EAAE,eAAe,CAAA;IACrB,WAAW,EAAE,UAAU,CAAA;IACvB,WAAW,EAAE,gBAAgB,EAAE,CAAA;CAC/B,CAAA;AAED;;;;;GAKG;AACH,qBAAa,gBAAiB,SAAQ,8BAA8B;gBACvD,OAAO,GAAE,MAA8B;IAS3C,IAAI,EAAE,eAAe,CAAA;CAC7B;AAED;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACpC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AASD;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC9B,IAAI,GAAE,sBAA2B,GAC/B,OAAO,CAAC,sBAAsB,CAAC,CAMjC"}
package/dist/init.js CHANGED
@@ -33,6 +33,7 @@ let initPromise;
33
33
  */
34
34
  export function initCustomBlock(opts = {}) {
35
35
  if (initPromise === undefined) {
36
+ customBlockHost.start();
36
37
  initPromise = performHandshake(opts);
37
38
  }
38
39
  return initPromise;
@@ -1,12 +1,12 @@
1
1
  import * as v from "valibot";
2
2
  declare const collectionPointerValidator: v.ObjectSchema<{
3
- readonly id: v.CustomSchema<import("../ids.js").NotionDataSourceId, v.ErrorMessage<v.CustomIssue> | undefined>;
3
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>;
4
4
  readonly table: v.StringSchema<undefined>;
5
- readonly spaceId: v.OptionalSchema<v.CustomSchema<import("../ids.js").NotionSpaceId, v.ErrorMessage<v.CustomIssue> | undefined>, undefined>;
5
+ readonly spaceId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionSpaceId">]>, undefined>;
6
6
  }, undefined>;
7
7
  export type NotionCollectionPointer = v.InferOutput<typeof collectionPointerValidator>;
8
8
  export declare const notionCollectionSchemaValidator: v.ObjectSchema<{
9
- readonly id: v.OptionalSchema<v.CustomSchema<import("../ids.js").NotionDataSourceId, v.ErrorMessage<v.CustomIssue> | undefined>, undefined>;
9
+ readonly id: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>, undefined>;
10
10
  readonly propertiesById: v.RecordSchema<v.StringSchema<undefined>, v.VariantSchema<"type", [v.ObjectSchema<{
11
11
  readonly type: v.LiteralSchema<"title", undefined>;
12
12
  readonly name: v.StringSchema<undefined>;
@@ -150,12 +150,12 @@ export type NotionCollectionSchema = v.InferOutput<typeof notionCollectionSchema
150
150
  export declare const notionDataSourceSchema: v.ObjectSchema<{
151
151
  readonly key: v.StringSchema<undefined>;
152
152
  readonly collectionPointer: v.OptionalSchema<v.ObjectSchema<{
153
- readonly id: v.CustomSchema<import("../ids.js").NotionDataSourceId, v.ErrorMessage<v.CustomIssue> | undefined>;
153
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>;
154
154
  readonly table: v.StringSchema<undefined>;
155
- readonly spaceId: v.OptionalSchema<v.CustomSchema<import("../ids.js").NotionSpaceId, v.ErrorMessage<v.CustomIssue> | undefined>, undefined>;
155
+ readonly spaceId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionSpaceId">]>, undefined>;
156
156
  }, undefined>, undefined>;
157
157
  readonly collectionSchema: v.OptionalSchema<v.ObjectSchema<{
158
- readonly id: v.OptionalSchema<v.CustomSchema<import("../ids.js").NotionDataSourceId, v.ErrorMessage<v.CustomIssue> | undefined>, undefined>;
158
+ readonly id: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>, undefined>;
159
159
  readonly propertiesById: v.RecordSchema<v.StringSchema<undefined>, v.VariantSchema<"type", [v.ObjectSchema<{
160
160
  readonly type: v.LiteralSchema<"title", undefined>;
161
161
  readonly name: v.StringSchema<undefined>;
@@ -438,12 +438,12 @@ export declare const notionDataSourceSchema: v.ObjectSchema<{
438
438
  export type NotionDataSource = v.InferOutput<typeof notionDataSourceSchema>;
439
439
  export declare const notionDataSourceBindingSchema: v.ObjectSchema<{
440
440
  readonly collectionPointer: v.OptionalSchema<v.ObjectSchema<{
441
- readonly id: v.CustomSchema<import("../ids.js").NotionDataSourceId, v.ErrorMessage<v.CustomIssue> | undefined>;
441
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>;
442
442
  readonly table: v.StringSchema<undefined>;
443
- readonly spaceId: v.OptionalSchema<v.CustomSchema<import("../ids.js").NotionSpaceId, v.ErrorMessage<v.CustomIssue> | undefined>, undefined>;
443
+ readonly spaceId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionSpaceId">]>, undefined>;
444
444
  }, undefined>, undefined>;
445
445
  readonly collectionSchema: v.OptionalSchema<v.ObjectSchema<{
446
- readonly id: v.OptionalSchema<v.CustomSchema<import("../ids.js").NotionDataSourceId, v.ErrorMessage<v.CustomIssue> | undefined>, undefined>;
446
+ readonly id: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>, undefined>;
447
447
  readonly propertiesById: v.RecordSchema<v.StringSchema<undefined>, v.VariantSchema<"type", [v.ObjectSchema<{
448
448
  readonly type: v.LiteralSchema<"title", undefined>;
449
449
  readonly name: v.StringSchema<undefined>;
@@ -584,12 +584,12 @@ export declare const notionDataSourceBindingSchema: v.ObjectSchema<{
584
584
  export type NotionDataSourceBinding = v.InferOutput<typeof notionDataSourceBindingSchema>;
585
585
  export declare const notionDataSourceBindingsSchema: v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
586
586
  readonly collectionPointer: v.OptionalSchema<v.ObjectSchema<{
587
- readonly id: v.CustomSchema<import("../ids.js").NotionDataSourceId, v.ErrorMessage<v.CustomIssue> | undefined>;
587
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>;
588
588
  readonly table: v.StringSchema<undefined>;
589
- readonly spaceId: v.OptionalSchema<v.CustomSchema<import("../ids.js").NotionSpaceId, v.ErrorMessage<v.CustomIssue> | undefined>, undefined>;
589
+ readonly spaceId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionSpaceId">]>, undefined>;
590
590
  }, undefined>, undefined>;
591
591
  readonly collectionSchema: v.OptionalSchema<v.ObjectSchema<{
592
- readonly id: v.OptionalSchema<v.CustomSchema<import("../ids.js").NotionDataSourceId, v.ErrorMessage<v.CustomIssue> | undefined>, undefined>;
592
+ readonly id: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>, undefined>;
593
593
  readonly propertiesById: v.RecordSchema<v.StringSchema<undefined>, v.VariantSchema<"type", [v.ObjectSchema<{
594
594
  readonly type: v.LiteralSchema<"title", undefined>;
595
595
  readonly name: v.StringSchema<undefined>;
@@ -5,7 +5,7 @@ import * as v from "valibot";
5
5
  * `created_by`, `last_edited_by`) are normally present, possibly with `undefined` values.
6
6
  */
7
7
  export declare const notionDataSourcePageBridgeSchema: v.ObjectSchema<{
8
- readonly id: v.CustomSchema<import("../ids.js").NotionPageId, v.ErrorMessage<v.CustomIssue> | undefined>;
8
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
9
9
  readonly propertiesById: v.RecordSchema<v.StringSchema<undefined>, v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>, v.BooleanSchema<undefined>, v.VariantSchema<"type", [v.ObjectSchema<{
10
10
  readonly type: v.LiteralSchema<"date", undefined>;
11
11
  readonly start_date: v.StringSchema<undefined>;
@@ -1,48 +1,32 @@
1
1
  import * as v from "valibot";
2
- declare const notionDataSourceIdBrand: unique symbol;
3
- declare const notionBlockIdBrand: unique symbol;
4
- declare const notionPageIdBrand: unique symbol;
5
- declare const notionAgentIdBrand: unique symbol;
6
- declare const notionSpaceIdBrand: unique symbol;
7
2
  /**
8
3
  * Branded Notion block ID. Host payloads and SDK APIs use plain strings at runtime,
9
4
  * but the brand keeps block IDs from being accidentally mixed with other IDs in TypeScript.
10
5
  */
11
- export type NotionBlockId = string & {
12
- readonly [notionBlockIdBrand]: "NotionBlockId";
13
- };
14
- export declare const notionBlockIdSchema: v.CustomSchema<NotionBlockId, v.ErrorMessage<v.CustomIssue> | undefined>;
6
+ export declare const notionBlockIdSchema: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionBlockId">]>;
7
+ export type NotionBlockId = v.InferOutput<typeof notionBlockIdSchema>;
15
8
  /**
16
9
  * Branded Notion data source ID. Host payloads and SDK APIs use plain strings at runtime,
17
10
  * but the brand keeps data source IDs from being accidentally mixed with other IDs in TypeScript.
18
11
  */
19
- export type NotionDataSourceId = string & {
20
- readonly [notionDataSourceIdBrand]: "NotionDataSourceId";
21
- };
22
- export declare const notionDataSourceIdSchema: v.CustomSchema<NotionDataSourceId, v.ErrorMessage<v.CustomIssue> | undefined>;
12
+ export declare const notionDataSourceIdSchema: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>;
13
+ export type NotionDataSourceId = v.InferOutput<typeof notionDataSourceIdSchema>;
23
14
  /**
24
15
  * Branded Notion page ID. Host payloads and SDK APIs use plain strings at runtime,
25
16
  * but the brand keeps page IDs from being accidentally mixed with other IDs in TypeScript.
26
17
  */
27
- export type NotionPageId = string & {
28
- readonly [notionPageIdBrand]: "NotionPageId";
29
- };
30
- export declare const notionPageIdSchema: v.CustomSchema<NotionPageId, v.ErrorMessage<v.CustomIssue> | undefined>;
18
+ export declare const notionPageIdSchema: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
19
+ export type NotionPageId = v.InferOutput<typeof notionPageIdSchema>;
31
20
  /**
32
21
  * Branded Notion agent ID. Agent parents identify the workflow that owns an
33
22
  * instruction page or one of its blocks.
34
23
  */
35
- export type NotionAgentId = string & {
36
- readonly [notionAgentIdBrand]: "NotionAgentId";
37
- };
38
- export declare const notionAgentIdSchema: v.CustomSchema<NotionAgentId, v.ErrorMessage<v.CustomIssue> | undefined>;
24
+ export declare const notionAgentIdSchema: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionAgentId">]>;
25
+ export type NotionAgentId = v.InferOutput<typeof notionAgentIdSchema>;
39
26
  /**
40
27
  * Branded Notion workspace/space ID. Host payloads and SDK APIs use plain strings at runtime,
41
28
  * but the brand keeps space IDs from being accidentally mixed with other IDs in TypeScript.
42
29
  */
43
- export type NotionSpaceId = string & {
44
- readonly [notionSpaceIdBrand]: "NotionSpaceId";
45
- };
46
- export declare const notionSpaceIdSchema: v.CustomSchema<NotionSpaceId, v.ErrorMessage<v.CustomIssue> | undefined>;
47
- export {};
30
+ export declare const notionSpaceIdSchema: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionSpaceId">]>;
31
+ export type NotionSpaceId = v.InferOutput<typeof notionSpaceIdSchema>;
48
32
  //# sourceMappingURL=ids.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ids.d.ts","sourceRoot":"","sources":["../../../../home/runner/work/custom-blocks/custom-blocks/protocol/src/ids.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B,OAAO,CAAC,MAAM,uBAAuB,EAAE,OAAO,MAAM,CAAA;AACpD,OAAO,CAAC,MAAM,kBAAkB,EAAE,OAAO,MAAM,CAAA;AAC/C,OAAO,CAAC,MAAM,iBAAiB,EAAE,OAAO,MAAM,CAAA;AAC9C,OAAO,CAAC,MAAM,kBAAkB,EAAE,OAAO,MAAM,CAAA;AAC/C,OAAO,CAAC,MAAM,kBAAkB,EAAE,OA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CAAC,OAAO,wBAAwB,CAAC,CAAA;AAE/E;;;GAGG;AACH,eAAO,MAAM,kBAAkB,+FAA8C,CAAA;AAC7E,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAEnE;;;GAGG;AACH,eAAO,MAAM,mBAAmB,gGAA+C,CAAA;AAC/E,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAErE;;;GAGG;AACH,eAAO,MAAM,mBAAmB,gGAA+C,CAAA;AAC/E,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,mBAAmB,CAAC,CAAA"}
@@ -1,6 +1,26 @@
1
1
  import * as v from "valibot";
2
- export const notionBlockIdSchema = v.custom(value => typeof value === "string", "Expected a Notion block ID");
3
- export const notionDataSourceIdSchema = v.custom(value => typeof value === "string", "Expected a Notion data source ID");
4
- export const notionPageIdSchema = v.custom(value => typeof value === "string", "Expected a Notion page ID");
5
- export const notionAgentIdSchema = v.custom(value => typeof value === "string", "Expected a Notion agent ID");
6
- export const notionSpaceIdSchema = v.custom(value => typeof value === "string", "Expected a Notion space ID");
2
+ /**
3
+ * Branded Notion block ID. Host payloads and SDK APIs use plain strings at runtime,
4
+ * but the brand keeps block IDs from being accidentally mixed with other IDs in TypeScript.
5
+ */
6
+ export const notionBlockIdSchema = v.pipe(v.string(), v.brand("NotionBlockId"));
7
+ /**
8
+ * Branded Notion data source ID. Host payloads and SDK APIs use plain strings at runtime,
9
+ * but the brand keeps data source IDs from being accidentally mixed with other IDs in TypeScript.
10
+ */
11
+ export const notionDataSourceIdSchema = v.pipe(v.string(), v.brand("NotionDataSourceId"));
12
+ /**
13
+ * Branded Notion page ID. Host payloads and SDK APIs use plain strings at runtime,
14
+ * but the brand keeps page IDs from being accidentally mixed with other IDs in TypeScript.
15
+ */
16
+ export const notionPageIdSchema = v.pipe(v.string(), v.brand("NotionPageId"));
17
+ /**
18
+ * Branded Notion agent ID. Agent parents identify the workflow that owns an
19
+ * instruction page or one of its blocks.
20
+ */
21
+ export const notionAgentIdSchema = v.pipe(v.string(), v.brand("NotionAgentId"));
22
+ /**
23
+ * Branded Notion workspace/space ID. Host payloads and SDK APIs use plain strings at runtime,
24
+ * but the brand keeps space IDs from being accidentally mixed with other IDs in TypeScript.
25
+ */
26
+ export const notionSpaceIdSchema = v.pipe(v.string(), v.brand("NotionSpaceId"));
@@ -13,10 +13,10 @@ export declare const notionCreatePagePositionSchema: v.VariantSchema<"type", [v.
13
13
  readonly type: v.LiteralSchema<"end", undefined>;
14
14
  }, undefined>, v.ObjectSchema<{
15
15
  readonly type: v.LiteralSchema<"before", undefined>;
16
- readonly blockId: v.CustomSchema<import("../ids.js").NotionBlockId, v.ErrorMessage<v.CustomIssue> | undefined>;
16
+ readonly blockId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionBlockId">]>;
17
17
  }, undefined>, v.ObjectSchema<{
18
18
  readonly type: v.LiteralSchema<"after", undefined>;
19
- readonly blockId: v.CustomSchema<import("../ids.js").NotionBlockId, v.ErrorMessage<v.CustomIssue> | undefined>;
19
+ readonly blockId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionBlockId">]>;
20
20
  }, undefined>], undefined>;
21
21
  export type NotionCreatePagePosition = v.InferOutput<typeof notionCreatePagePositionSchema>;
22
22
  /**
@@ -30,10 +30,10 @@ export type NotionCreatePagePosition = v.InferOutput<typeof notionCreatePagePosi
30
30
  */
31
31
  export declare const createPageParentSchema: v.VariantSchema<"type", [v.ObjectSchema<{
32
32
  readonly type: v.LiteralSchema<"page_id", undefined>;
33
- readonly page_id: v.CustomSchema<import("../ids.js").NotionPageId, v.ErrorMessage<v.CustomIssue> | undefined>;
33
+ readonly page_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
34
34
  }, undefined>, v.ObjectSchema<{
35
35
  readonly type: v.LiteralSchema<"data_source_id", undefined>;
36
- readonly data_source_id: v.CustomSchema<import("../ids.js").NotionDataSourceId, v.ErrorMessage<v.CustomIssue> | undefined>;
36
+ readonly data_source_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>;
37
37
  }, undefined>], undefined>;
38
38
  export type CreatePageMessageParent = v.InferOutput<typeof createPageParentSchema>;
39
39
  /**
@@ -45,10 +45,10 @@ export declare const createPageMessageSchema: v.ObjectSchema<{
45
45
  readonly requestId: v.StringSchema<undefined>;
46
46
  readonly parent: v.VariantSchema<"type", [v.ObjectSchema<{
47
47
  readonly type: v.LiteralSchema<"page_id", undefined>;
48
- readonly page_id: v.CustomSchema<import("../ids.js").NotionPageId, v.ErrorMessage<v.CustomIssue> | undefined>;
48
+ readonly page_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
49
49
  }, undefined>, v.ObjectSchema<{
50
50
  readonly type: v.LiteralSchema<"data_source_id", undefined>;
51
- readonly data_source_id: v.CustomSchema<import("../ids.js").NotionDataSourceId, v.ErrorMessage<v.CustomIssue> | undefined>;
51
+ readonly data_source_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>;
52
52
  }, undefined>], undefined>;
53
53
  readonly properties: v.RecordSchema<v.StringSchema<undefined>, v.VariantSchema<"type", [v.ObjectSchema<{
54
54
  readonly type: v.LiteralSchema<"title", undefined>;
@@ -181,10 +181,10 @@ export declare const createPageMessageSchema: v.ObjectSchema<{
181
181
  readonly type: v.LiteralSchema<"end", undefined>;
182
182
  }, undefined>, v.ObjectSchema<{
183
183
  readonly type: v.LiteralSchema<"before", undefined>;
184
- readonly blockId: v.CustomSchema<import("../ids.js").NotionBlockId, v.ErrorMessage<v.CustomIssue> | undefined>;
184
+ readonly blockId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionBlockId">]>;
185
185
  }, undefined>, v.ObjectSchema<{
186
186
  readonly type: v.LiteralSchema<"after", undefined>;
187
- readonly blockId: v.CustomSchema<import("../ids.js").NotionBlockId, v.ErrorMessage<v.CustomIssue> | undefined>;
187
+ readonly blockId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionBlockId">]>;
188
188
  }, undefined>], undefined>, undefined>;
189
189
  }, undefined>;
190
190
  export type CreatePageMessage = v.InferOutput<typeof createPageMessageSchema>;
@@ -18,22 +18,22 @@ export declare const createPageResultMessageSchema: v.VariantSchema<"status", [v
18
18
  /** The newly created page. */
19
19
  readonly page: v.ObjectSchema<{
20
20
  readonly object: v.LiteralSchema<"page", undefined>;
21
- readonly id: v.CustomSchema<import("../ids.js").NotionPageId, v.ErrorMessage<v.CustomIssue> | undefined>;
21
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
22
22
  readonly parent: v.VariantSchema<"type", [v.ObjectSchema<{
23
23
  readonly type: v.LiteralSchema<"page_id", undefined>;
24
- readonly page_id: v.CustomSchema<import("../ids.js").NotionPageId, v.ErrorMessage<v.CustomIssue> | undefined>;
24
+ readonly page_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
25
25
  }, undefined>, v.ObjectSchema<{
26
26
  readonly type: v.LiteralSchema<"data_source_id", undefined>;
27
- readonly data_source_id: v.CustomSchema<import("../ids.js").NotionDataSourceId, v.ErrorMessage<v.CustomIssue> | undefined>;
27
+ readonly data_source_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>;
28
28
  }, undefined>, v.ObjectSchema<{
29
29
  readonly type: v.LiteralSchema<"workspace", undefined>;
30
30
  readonly workspace: v.LiteralSchema<true, undefined>;
31
31
  }, undefined>, v.ObjectSchema<{
32
32
  readonly type: v.LiteralSchema<"block_id", undefined>;
33
- readonly block_id: v.CustomSchema<import("../ids.js").NotionBlockId, v.ErrorMessage<v.CustomIssue> | undefined>;
33
+ readonly block_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionBlockId">]>;
34
34
  }, undefined>, v.ObjectSchema<{
35
35
  readonly type: v.LiteralSchema<"agent_id", undefined>;
36
- readonly agent_id: v.CustomSchema<import("../ids.js").NotionAgentId, v.ErrorMessage<v.CustomIssue> | undefined>;
36
+ readonly agent_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionAgentId">]>;
37
37
  }, undefined>], undefined>;
38
38
  readonly properties: v.RecordSchema<v.StringSchema<undefined>, v.VariantSchema<"type", [v.ObjectSchema<{
39
39
  readonly type: v.LiteralSchema<"title", undefined>;
@@ -6,7 +6,7 @@ export declare const currentUserChangedMessageSchema: v.ObjectSchema<{
6
6
  readonly type: v.LiteralSchema<"currentUserChanged", undefined>;
7
7
  readonly currentUser: v.ObjectSchema<{
8
8
  readonly object: v.LiteralSchema<"user", undefined>;
9
- readonly id: v.StringSchema<undefined>;
9
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionUserId">]>;
10
10
  readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
11
11
  readonly avatar_url: v.NullableSchema<v.StringSchema<undefined>, undefined>;
12
12
  readonly type: v.LiteralSchema<"person", undefined>;
@@ -9,12 +9,12 @@ export declare const dataSourcesChangedMessageSchema: v.ObjectSchema<{
9
9
  readonly dataSources: v.ObjectSchema<{
10
10
  readonly bindings: v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
11
11
  readonly collectionPointer: v.OptionalSchema<v.ObjectSchema<{
12
- readonly id: v.CustomSchema<import("../ids.js").NotionDataSourceId, v.ErrorMessage<v.CustomIssue> | undefined>;
12
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>;
13
13
  readonly table: v.StringSchema<undefined>;
14
- readonly spaceId: v.OptionalSchema<v.CustomSchema<import("../ids.js").NotionSpaceId, v.ErrorMessage<v.CustomIssue> | undefined>, undefined>;
14
+ readonly spaceId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionSpaceId">]>, undefined>;
15
15
  }, undefined>, undefined>;
16
16
  readonly collectionSchema: v.OptionalSchema<v.ObjectSchema<{
17
- readonly id: v.OptionalSchema<v.CustomSchema<import("../ids.js").NotionDataSourceId, v.ErrorMessage<v.CustomIssue> | undefined>, undefined>;
17
+ readonly id: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>, undefined>;
18
18
  readonly propertiesById: v.RecordSchema<v.StringSchema<undefined>, v.VariantSchema<"type", [v.ObjectSchema<{
19
19
  readonly type: v.LiteralSchema<"title", undefined>;
20
20
  readonly name: v.StringSchema<undefined>;