@notionhq/custom-blocks-host 0.3.11 → 0.4.0

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 (123) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +143 -236
  3. package/THIRD_PARTY_LICENSES.md +9 -0
  4. package/dist/autoBindProperties.d.ts +5 -2
  5. package/dist/autoBindProperties.d.ts.map +1 -1
  6. package/dist/autoBindProperties.js +5 -2
  7. package/dist/browser.js +1 -1
  8. package/dist/compatibility/addMetadataReadSchemasForProtocol3To4.d.ts +1215 -0
  9. package/dist/compatibility/addMetadataReadSchemasForProtocol3To4.d.ts.map +1 -0
  10. package/dist/compatibility/addMetadataReadSchemasForProtocol3To4.js +27 -0
  11. package/dist/compatibility/normalizeHostToSandboxMessage.d.ts +8 -0
  12. package/dist/compatibility/normalizeHostToSandboxMessage.d.ts.map +1 -0
  13. package/dist/compatibility/normalizeHostToSandboxMessage.js +39 -0
  14. package/dist/compatibility/normalizePageResultsForProtocol3To5.d.ts +11 -0
  15. package/dist/compatibility/normalizePageResultsForProtocol3To5.d.ts.map +1 -0
  16. package/dist/compatibility/normalizePageResultsForProtocol3To5.js +18 -0
  17. package/dist/compatibility/normalizePageResultsForProtocol6.d.ts +9 -0
  18. package/dist/compatibility/normalizePageResultsForProtocol6.d.ts.map +1 -0
  19. package/dist/compatibility/normalizePageResultsForProtocol6.js +18 -0
  20. package/dist/compatibility/normalizeSandboxToHostMessage.d.ts +1091 -0
  21. package/dist/compatibility/normalizeSandboxToHostMessage.d.ts.map +1 -0
  22. package/dist/compatibility/normalizeSandboxToHostMessage.js +9 -0
  23. package/dist/compatibility/pageForProtocol3To5.d.ts +159 -0
  24. package/dist/compatibility/pageForProtocol3To5.d.ts.map +1 -0
  25. package/dist/{lifecycle/legacyPage.js → compatibility/pageForProtocol3To5.js} +50 -9
  26. package/dist/compatibility/pageResult.d.ts +11 -0
  27. package/dist/compatibility/pageResult.d.ts.map +1 -0
  28. package/dist/compatibility/pageWithNullTextFallbackProperties.d.ts +9 -0
  29. package/dist/compatibility/pageWithNullTextFallbackProperties.d.ts.map +1 -0
  30. package/dist/compatibility/pageWithNullTextFallbackProperties.js +46 -0
  31. package/dist/createCustomBlockHost.d.ts +18 -19
  32. package/dist/createCustomBlockHost.d.ts.map +1 -1
  33. package/dist/createCustomBlockHost.js +103 -38
  34. package/dist/index.d.ts +2 -19
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +1 -2
  37. package/dist/{localBlockUrl.d.ts → isAllowedLocalPreviewUrl.d.ts} +2 -2
  38. package/dist/isAllowedLocalPreviewUrl.d.ts.map +1 -0
  39. package/dist/{localBlockUrl.js → isAllowedLocalPreviewUrl.js} +3 -7
  40. package/dist/lifecycle/initErrors.d.ts +1 -0
  41. package/dist/lifecycle/initErrors.d.ts.map +1 -1
  42. package/dist/lifecycle/initErrors.js +7 -0
  43. package/dist/lifecycle/initializationController.d.ts +6 -4
  44. package/dist/lifecycle/initializationController.d.ts.map +1 -1
  45. package/dist/lifecycle/initializationController.js +24 -15
  46. package/dist/lifecycle/resolveManifest.d.ts +13 -0
  47. package/dist/lifecycle/resolveManifest.d.ts.map +1 -0
  48. package/dist/lifecycle/resolveManifest.js +21 -0
  49. package/dist/lifecycle/types.d.ts +1637 -17
  50. package/dist/lifecycle/types.d.ts.map +1 -1
  51. package/dist/lifecycle/types.js +18 -0
  52. package/dist/messages/sandboxMessageRouter.d.ts.map +1 -1
  53. package/dist/messages/sandboxMessageRouter.js +2 -2
  54. package/dist/protocol/dataSources/dataSourcePage.d.ts +3 -4
  55. package/dist/protocol/dataSources/dataSourcePage.js +2 -3
  56. package/dist/protocol/index.d.ts +1 -0
  57. package/dist/protocol/index.js +1 -0
  58. package/dist/protocol/isLocalBlockServerUrl.d.ts +2 -0
  59. package/dist/protocol/isLocalBlockServerUrl.js +9 -0
  60. package/dist/protocol/messages/connect.d.ts +2 -2
  61. package/dist/protocol/messages/connect.js +2 -2
  62. package/dist/protocol/messages/createPageResult.d.ts +2 -2
  63. package/dist/protocol/messages/createPageResult.js +3 -3
  64. package/dist/protocol/messages/getPage.d.ts +2 -2
  65. package/dist/protocol/messages/getPage.js +3 -3
  66. package/dist/protocol/messages/hostToSandbox.d.ts +3 -3
  67. package/dist/protocol/messages/hostToSandbox.js +10 -10
  68. package/dist/protocol/messages/init.d.ts +1 -1
  69. package/dist/protocol/messages/queryDataSourceResult.d.ts +3 -3
  70. package/dist/protocol/messages/queryDataSourceResult.js +6 -3
  71. package/dist/protocol/messages/updatePageResult.d.ts +2 -2
  72. package/dist/protocol/messages/updatePageResult.js +3 -3
  73. package/dist/protocol/pages/page.d.ts +2 -2
  74. package/dist/protocol/pages/page.js +1 -1
  75. package/dist/protocol/protocolVersion.d.ts +2 -2
  76. package/dist/protocol/protocolVersion.js +2 -2
  77. package/dist/protocol.d.ts +9 -0
  78. package/dist/protocol.d.ts.map +1 -0
  79. package/dist/protocol.js +8 -0
  80. package/docs/bridge/changelog.md +67 -0
  81. package/docs/bridge/protocol.md +182 -0
  82. package/docs/bridge/versioning.md +38 -0
  83. package/docs/compatibility.md +68 -0
  84. package/docs/handlers.md +199 -0
  85. package/docs/lifecycle.md +117 -0
  86. package/package.json +10 -2
  87. package/src/autoBindProperties.ts +5 -2
  88. package/src/compatibility/addMetadataReadSchemasForProtocol3To4.ts +36 -0
  89. package/src/compatibility/normalizeHostToSandboxMessage.ts +54 -0
  90. package/src/compatibility/normalizePageResultsForProtocol3To5.ts +28 -0
  91. package/src/compatibility/normalizePageResultsForProtocol6.ts +23 -0
  92. package/src/compatibility/normalizeSandboxToHostMessage.ts +10 -0
  93. package/src/{lifecycle/legacyPage.ts → compatibility/pageForProtocol3To5.ts} +52 -11
  94. package/src/compatibility/pageResult.ts +18 -0
  95. package/src/compatibility/pageWithNullTextFallbackProperties.ts +53 -0
  96. package/src/createCustomBlockHost.ts +152 -62
  97. package/src/index.ts +4 -51
  98. package/src/{localBlockUrl.ts → isAllowedLocalPreviewUrl.ts} +4 -7
  99. package/src/lifecycle/initErrors.ts +9 -0
  100. package/src/lifecycle/initializationController.ts +34 -19
  101. package/src/lifecycle/resolveManifest.ts +31 -0
  102. package/src/lifecycle/types.ts +84 -16
  103. package/src/messages/sandboxMessageRouter.ts +2 -2
  104. package/src/protocol.ts +8 -0
  105. package/dist/lifecycle/legacyPage.d.ts +0 -70
  106. package/dist/lifecycle/legacyPage.d.ts.map +0 -1
  107. package/dist/lifecycle/loadCustomBlockManifest.d.ts +0 -16
  108. package/dist/lifecycle/loadCustomBlockManifest.d.ts.map +0 -1
  109. package/dist/lifecycle/loadCustomBlockManifest.js +0 -65
  110. package/dist/lifecycle/manifestOptions.d.ts +0 -17
  111. package/dist/lifecycle/manifestOptions.d.ts.map +0 -1
  112. package/dist/lifecycle/normalizeHostToSandboxMessage.d.ts +0 -6
  113. package/dist/lifecycle/normalizeHostToSandboxMessage.d.ts.map +0 -1
  114. package/dist/lifecycle/normalizeHostToSandboxMessage.js +0 -14
  115. package/dist/lifecycle/normalizePage.d.ts +0 -7
  116. package/dist/lifecycle/normalizePage.d.ts.map +0 -1
  117. package/dist/lifecycle/normalizePage.js +0 -47
  118. package/dist/localBlockUrl.d.ts.map +0 -1
  119. package/src/lifecycle/loadCustomBlockManifest.ts +0 -89
  120. package/src/lifecycle/manifestOptions.ts +0 -19
  121. package/src/lifecycle/normalizeHostToSandboxMessage.ts +0 -27
  122. package/src/lifecycle/normalizePage.ts +0 -71
  123. /package/dist/{lifecycle/manifestOptions.js → compatibility/pageResult.js} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lifecycle/types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,8BAA8B,EAAE,MAAM,4DAA4D,CAAA;AAE3G,OAAO,EACN,KAAK,mBAAmB,EAExB,MAAM,8CAA8C,CAAA;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAA;AAC1F,O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BAA2B,EAAE,UAAU,CAAC,CAAA;CAC1D,GACD;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,wBAAwB,CAAA;CAAE,CAAA;AAEvD,MAAM,MAAM,kCAAkC,GAAG,CAAC,IAAI,EAAE;IACvD,QAAQ,EAAE,mBAAmB,CAAA;IAC7B,MAAM,EAAE,WAAW,CAAA;CACnB,KAAK,OAAO,CAAC,kCAAkC,CAAC,CAAA"}
@@ -2,11 +2,19 @@ import { notionContrastModeSchema } from "../protocol/contrast.js";
2
2
  import { notionDataSourceBindingsSchema } from "../protocol/dataSources/dataSource.js";
3
3
  import { notionBlockIdSchema } from "../protocol/ids.js";
4
4
  import { manifestSchema, } from "../protocol/manifest.js";
5
+ import { customBlockInitErrorInfoSchema, } from "../protocol/messages/init.js";
5
6
  import { customBlockPageSchema } from "../protocol/pages/page.js";
6
7
  import { notionParentSchema } from "../protocol/parent.js";
7
8
  import { notionThemeSchema } from "../protocol/theme.js";
8
9
  import { notionUserSchema } from "../protocol/users/user.js";
9
10
  import * as v from "valibot";
11
+ export const customBlockHostManifestResultSchema = v.variant("status", [
12
+ v.object({ status: v.literal("success"), manifest: manifestSchema }),
13
+ v.object({
14
+ status: v.literal("error"),
15
+ error: customBlockInitErrorInfoSchema,
16
+ }),
17
+ ]);
10
18
  export const customBlockHostInitialStateSchema = v.object({
11
19
  theme: notionThemeSchema,
12
20
  /**
@@ -21,3 +29,13 @@ export const customBlockHostInitialStateSchema = v.object({
21
29
  dataSources: v.object({ bindings: notionDataSourceBindingsSchema }),
22
30
  currentUser: notionUserSchema,
23
31
  });
32
+ export const customBlockHostPreparedStateResultSchema = v.variant("status", [
33
+ v.object({
34
+ status: v.literal("success"),
35
+ initialState: v.omit(customBlockHostInitialStateSchema, ["manifest"]),
36
+ }),
37
+ v.object({
38
+ status: v.literal("error"),
39
+ error: customBlockInitErrorInfoSchema,
40
+ }),
41
+ ]);
@@ -1 +1 @@
1
- {"version":3,"file":"sandboxMessageR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AC1C,CAAA;AAED,wBAAgB,0BAA0B,CACzC,OAAO,EAAE,2BAA2B,GAClC,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CA0I/B"}
@@ -1,6 +1,6 @@
1
1
  import { isInitHandshakeMessage } from "../protocol/messages/isInitHandshakeMessage.js";
2
- import { sandboxToHostMessageSchema } from "../protocol/messages/sandboxToHost.js";
3
2
  import * as v from "valibot";
3
+ import { normalizeSandboxToHostMessage } from "../compatibility/normalizeSandboxToHostMessage.js";
4
4
  import { invalidConnectPayloadError, invalidInitResultPayloadError, } from "../lifecycle/initErrors.js";
5
5
  import { unreachable } from "../utils.js";
6
6
  import { getInvalidSandboxMessageResponse } from "./invalidSandboxMessage.js";
@@ -61,7 +61,7 @@ export function createSandboxMessageRouter(options) {
61
61
  return;
62
62
  }
63
63
  // Parse and validate the message from the sandbox.
64
- const parsed = v.safeParse(sandboxToHostMessageSchema, event.data);
64
+ const parsed = normalizeSandboxToHostMessage(event.data);
65
65
  if (!parsed.success) {
66
66
  onInvalidSandboxMessage(event.data, parsed.issues);
67
67
  return;
@@ -1,9 +1,8 @@
1
1
  import * as v from "valibot";
2
2
  /**
3
- * Bridge shape for a data source page, as parsed from inbound host messages. The host keys
4
- * properties by raw property ID. Only actual schema properties are included.
3
+ * Query page shape for protocols 3–5, with flat values keyed by raw property ID.
5
4
  */
6
- export declare const legacyNotionDataSourcePageBridgeSchema: v.ObjectSchema<{
5
+ export declare const notionDataSourcePageForProtocol3To5Schema: v.ObjectSchema<{
7
6
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
8
7
  /** Whether the page or an ancestor is archived. */
9
8
  readonly is_archived: v.BooleanSchema<undefined>;
@@ -71,4 +70,4 @@ export declare const legacyNotionDataSourcePageBridgeSchema: v.ObjectSchema<{
71
70
  readonly table: v.StringSchema<undefined>;
72
71
  }, undefined>, undefined>], undefined>, undefined>, undefined>;
73
72
  }, undefined>;
74
- export type LegacyNotionDataSourcePageBridge = v.InferOutput<typeof legacyNotionDataSourcePageBridgeSchema>;
73
+ export type NotionDataSourcePageForProtocol3To5 = v.InferOutput<typeof notionDataSourcePageForProtocol3To5Schema>;
@@ -2,10 +2,9 @@ import * as v from "valibot";
2
2
  import { notionPageIdSchema } from "../ids.js";
3
3
  import { notionDataSourceValueSchema } from "./dataSourceValue.js";
4
4
  /**
5
- * Bridge shape for a data source page, as parsed from inbound host messages. The host keys
6
- * properties by raw property ID. Only actual schema properties are included.
5
+ * Query page shape for protocols 3–5, with flat values keyed by raw property ID.
7
6
  */
8
- export const legacyNotionDataSourcePageBridgeSchema = v.object({
7
+ export const notionDataSourcePageForProtocol3To5Schema = v.object({
9
8
  id: notionPageIdSchema,
10
9
  /** Whether the page or an ancestor is archived. */
11
10
  is_archived: v.boolean(),
@@ -16,6 +16,7 @@ export * from "./dataSources/recordPointer.js";
16
16
  export * from "./dataSources/sortDirection.js";
17
17
  export * from "./errors.js";
18
18
  export * from "./ids.js";
19
+ export { isLocalBlockServerUrl } from "./isLocalBlockServerUrl.js";
19
20
  export * from "./manifest.js";
20
21
  export * from "./messages/connect.js";
21
22
  export * from "./messages/contrastModeChanged.js";
@@ -16,6 +16,7 @@ export * from "./dataSources/recordPointer.js";
16
16
  export * from "./dataSources/sortDirection.js";
17
17
  export * from "./errors.js";
18
18
  export * from "./ids.js";
19
+ export { isLocalBlockServerUrl } from "./isLocalBlockServerUrl.js";
19
20
  export * from "./manifest.js";
20
21
  export * from "./messages/connect.js";
21
22
  export * from "./messages/contrastModeChanged.js";
@@ -0,0 +1,2 @@
1
+ /** Accepts HTTP(S) block servers on localhost, *.localhost, or 127.0.0.1 without credentials. */
2
+ export declare function isLocalBlockServerUrl(url: URL): boolean;
@@ -0,0 +1,9 @@
1
+ /** Accepts HTTP(S) block servers on localhost, *.localhost, or 127.0.0.1 without credentials. */
2
+ export function isLocalBlockServerUrl(url) {
3
+ return ((url.protocol === "http:" || url.protocol === "https:") &&
4
+ (url.hostname === "localhost" ||
5
+ url.hostname === "127.0.0.1" ||
6
+ url.hostname.endsWith(".localhost")) &&
7
+ url.username === "" &&
8
+ url.password === "");
9
+ }
@@ -10,8 +10,8 @@ export declare const connectMessageSchema: v.VariantSchema<"status", [v.ObjectSc
10
10
  readonly sdkVersion: v.StringSchema<undefined>;
11
11
  readonly status: v.LiteralSchema<"success", undefined>;
12
12
  /**
13
- * The data sources and settings the custom block expects. Hosts may omit
14
- * this when they already have an authoritative manifest.
13
+ * The custom block manifest injected by local dev tooling. The SDK omits it on
14
+ * non-loopback origins. Initialization uses it only when manifestSource is "sandbox".
15
15
  */
16
16
  readonly manifest: v.OptionalSchema<v.ObjectSchema<{
17
17
  readonly version: v.LiteralSchema<1, undefined>;
@@ -25,8 +25,8 @@ export const connectMessageSchema = v.variant("status", [
25
25
  v.object({
26
26
  status: v.literal("success"),
27
27
  /**
28
- * The data sources and settings the custom block expects. Hosts may omit
29
- * this when they already have an authoritative manifest.
28
+ * The custom block manifest injected by local dev tooling. The SDK omits it on
29
+ * non-loopback origins. Initialization uses it only when manifestSource is "sandbox".
30
30
  */
31
31
  manifest: v.optional(manifestSchema),
32
32
  ...connectMessageCommonEntries,
@@ -314,7 +314,7 @@ export declare const createPageResultMessageSchema: v.VariantSchema<"status", [v
314
314
  readonly isRetryable: v.BooleanSchema<undefined>;
315
315
  }, undefined>;
316
316
  }, undefined>], undefined>;
317
- export declare const createPageResultMessageLegacySchema: v.VariantSchema<"status", [v.ObjectSchema<{
317
+ export declare const createPageResultMessageWithProtocol3To5CompatibilitySchema: v.VariantSchema<"status", [v.ObjectSchema<{
318
318
  readonly type: v.LiteralSchema<"createPageResult", undefined>;
319
319
  readonly requestId: v.StringSchema<undefined>;
320
320
  readonly status: v.LiteralSchema<"success", undefined>;
@@ -894,4 +894,4 @@ export declare const createPageResultMessageLegacySchema: v.VariantSchema<"statu
894
894
  }, undefined>;
895
895
  }, undefined>], undefined>;
896
896
  export type CreatePageResultMessage = v.InferOutput<typeof createPageResultMessageSchema>;
897
- export type CreatePageResultMessageLegacy = v.InferOutput<typeof createPageResultMessageLegacySchema>;
897
+ export type CreatePageResultMessageWithProtocol3To5Compatibility = v.InferOutput<typeof createPageResultMessageWithProtocol3To5CompatibilitySchema>;
@@ -1,5 +1,5 @@
1
1
  import * as v from "valibot";
2
- import { legacyNotionPageSchema, notionPageDataSchema } from "../pages/page.js";
2
+ import { notionPageDataSchema, notionPageForProtocol3To5Schema, } from "../pages/page.js";
3
3
  // The schema accepts any string code. The type lists known codes for
4
4
  // autocomplete, with an open string fallback for newer senders.
5
5
  export const customBlockCreatePageErrorCodeSchema = v.string();
@@ -26,13 +26,13 @@ export const createPageResultMessageSchema = v.variant("status", [
26
26
  error: customBlockCreatePageErrorInfoSchema,
27
27
  }),
28
28
  ]);
29
- export const createPageResultMessageLegacySchema = v.variant("status", [
29
+ export const createPageResultMessageWithProtocol3To5CompatibilitySchema = v.variant("status", [
30
30
  v.object({
31
31
  type: v.literal("createPageResult"),
32
32
  requestId: v.string(),
33
33
  status: v.literal("success"),
34
34
  /** The newly created page. */
35
- page: v.union([notionPageDataSchema, legacyNotionPageSchema]),
35
+ page: v.union([notionPageDataSchema, notionPageForProtocol3To5Schema]),
36
36
  }),
37
37
  v.object({
38
38
  type: v.literal("createPageResult"),
@@ -320,7 +320,7 @@ export declare const getPageResultMessageSchema: v.VariantSchema<"status", [v.Ob
320
320
  readonly isRetryable: v.BooleanSchema<undefined>;
321
321
  }, undefined>;
322
322
  }, undefined>], undefined>;
323
- export declare const getPageResultMessageLegacySchema: v.VariantSchema<"status", [v.ObjectSchema<{
323
+ export declare const getPageResultMessageWithProtocol3To5CompatibilitySchema: v.VariantSchema<"status", [v.ObjectSchema<{
324
324
  readonly type: v.LiteralSchema<"getPageResult", undefined>;
325
325
  readonly requestId: v.StringSchema<undefined>;
326
326
  readonly status: v.LiteralSchema<"success", undefined>;
@@ -899,4 +899,4 @@ export declare const getPageResultMessageLegacySchema: v.VariantSchema<"status",
899
899
  }, undefined>;
900
900
  }, undefined>], undefined>;
901
901
  export type GetPageResultMessage = v.InferOutput<typeof getPageResultMessageSchema>;
902
- export type GetPageResultMessageLegacy = v.InferOutput<typeof getPageResultMessageLegacySchema>;
902
+ export type GetPageResultMessageWithProtocol3To5Compatibility = v.InferOutput<typeof getPageResultMessageWithProtocol3To5CompatibilitySchema>;
@@ -1,6 +1,6 @@
1
1
  import * as v from "valibot";
2
2
  import { notionDataSourceIdSchema, notionPageIdSchema } from "../ids.js";
3
- import { legacyNotionPageSchema, notionPageDataSchema } from "../pages/page.js";
3
+ import { notionPageDataSchema, notionPageForProtocol3To5Schema, } from "../pages/page.js";
4
4
  // The schema accepts any string code. The type lists known codes for
5
5
  // autocomplete, with an open string fallback for newer senders.
6
6
  export const customBlockGetPageErrorCodeSchema = v.string();
@@ -32,12 +32,12 @@ export const getPageResultMessageSchema = v.variant("status", [
32
32
  error: customBlockGetPageErrorInfoSchema,
33
33
  }),
34
34
  ]);
35
- export const getPageResultMessageLegacySchema = v.variant("status", [
35
+ export const getPageResultMessageWithProtocol3To5CompatibilitySchema = v.variant("status", [
36
36
  v.object({
37
37
  type: v.literal("getPageResult"),
38
38
  requestId: v.string(),
39
39
  status: v.literal("success"),
40
- page: v.union([notionPageDataSchema, legacyNotionPageSchema]),
40
+ page: v.union([notionPageDataSchema, notionPageForProtocol3To5Schema]),
41
41
  }),
42
42
  v.object({
43
43
  type: v.literal("getPageResult"),
@@ -1743,9 +1743,9 @@ export declare const hostToSandboxMessageSchema: v.VariantSchema<"type", [v.Vari
1743
1743
  }, undefined>;
1744
1744
  }, undefined>], undefined>], undefined>;
1745
1745
  /**
1746
- * Discriminated union of every message the host is allowed to send the sandbox.
1746
+ * Host messages accepting both current page shapes and protocol 3–5 page shapes.
1747
1747
  */
1748
- export declare const hostToSandboxMessageLegacySchema: v.VariantSchema<"type", [v.VariantSchema<"status", [v.ObjectSchema<{
1748
+ export declare const hostToSandboxMessageWithProtocol3To5CompatibilitySchema: v.VariantSchema<"type", [v.VariantSchema<"status", [v.ObjectSchema<{
1749
1749
  readonly type: v.LiteralSchema<"init", undefined>;
1750
1750
  readonly initializationId: v.StringSchema<undefined>;
1751
1751
  readonly status: v.LiteralSchema<"success", undefined>;
@@ -4382,4 +4382,4 @@ export declare const hostToSandboxMessageLegacySchema: v.VariantSchema<"type", [
4382
4382
  }, undefined>;
4383
4383
  }, undefined>], undefined>], undefined>;
4384
4384
  export type HostToSandboxMessage = v.InferOutput<typeof hostToSandboxMessageSchema>;
4385
- export type HostToSandboxMessageLegacy = v.InferOutput<typeof hostToSandboxMessageLegacySchema>;
4385
+ export type HostToSandboxMessageWithProtocol3To5Compatibility = v.InferOutput<typeof hostToSandboxMessageWithProtocol3To5CompatibilitySchema>;
@@ -1,9 +1,9 @@
1
1
  import * as v from "valibot";
2
2
  import { contrastModeChangedMessageSchema } from "./contrastModeChanged.js";
3
- import { createPageResultMessageLegacySchema, createPageResultMessageSchema, } from "./createPageResult.js";
3
+ import { createPageResultMessageSchema, createPageResultMessageWithProtocol3To5CompatibilitySchema, } from "./createPageResult.js";
4
4
  import { currentUserChangedMessageSchema } from "./currentUserChanged.js";
5
5
  import { dataSourcesChangedMessageSchema } from "./dataSourcesChanged.js";
6
- import { getPageResultMessageLegacySchema, getPageResultMessageSchema, } from "./getPage.js";
6
+ import { getPageResultMessageSchema, getPageResultMessageWithProtocol3To5CompatibilitySchema, } from "./getPage.js";
7
7
  import { getUserResultMessageSchema } from "./getUser.js";
8
8
  import { initMessageSchema } from "./init.js";
9
9
  import { invalidSandboxMessageSchema } from "./invalidSandboxMessage.js";
@@ -12,9 +12,9 @@ import { openExternalUrlResultMessageSchema } from "./openExternalUrl.js";
12
12
  import { openPageResultMessageSchema } from "./openPage.js";
13
13
  import { pageChangedMessageSchema } from "./pageChanged.js";
14
14
  import { parentChangedMessageSchema } from "./parentChanged.js";
15
- import { queryDataSourceResultMessageLegacySchema, queryDataSourceResultMessageSchema, } from "./queryDataSourceResult.js";
15
+ import { queryDataSourceResultMessageSchema, queryDataSourceResultMessageWithProtocol3To5CompatibilitySchema, } from "./queryDataSourceResult.js";
16
16
  import { themeChangedMessageSchema } from "./themeChanged.js";
17
- import { updatePageResultMessageLegacySchema, updatePageResultMessageSchema, } from "./updatePageResult.js";
17
+ import { updatePageResultMessageSchema, updatePageResultMessageWithProtocol3To5CompatibilitySchema, } from "./updatePageResult.js";
18
18
  const baseHostToSandboxMessageSchema = v.variant("type", [
19
19
  initMessageSchema,
20
20
  themeChangedMessageSchema,
@@ -37,12 +37,12 @@ export const hostToSandboxMessageSchema = v.variant("type", [
37
37
  updatePageResultMessageSchema,
38
38
  ]);
39
39
  /**
40
- * Discriminated union of every message the host is allowed to send the sandbox.
40
+ * Host messages accepting both current page shapes and protocol 3–5 page shapes.
41
41
  */
42
- export const hostToSandboxMessageLegacySchema = v.variant("type", [
42
+ export const hostToSandboxMessageWithProtocol3To5CompatibilitySchema = v.variant("type", [
43
43
  ...baseHostToSandboxMessageSchema.options,
44
- queryDataSourceResultMessageLegacySchema,
45
- getPageResultMessageLegacySchema,
46
- createPageResultMessageLegacySchema,
47
- updatePageResultMessageLegacySchema,
44
+ queryDataSourceResultMessageWithProtocol3To5CompatibilitySchema,
45
+ getPageResultMessageWithProtocol3To5CompatibilitySchema,
46
+ createPageResultMessageWithProtocol3To5CompatibilitySchema,
47
+ updatePageResultMessageWithProtocol3To5CompatibilitySchema,
48
48
  ]);
@@ -2,7 +2,7 @@ import * as v from "valibot";
2
2
  import type { CustomBlockErrorCode, CustomBlockErrorInfo } from "../errors.js";
3
3
  import type { CustomBlockInitResultErrorCode } from "./initResult.js";
4
4
  export declare const customBlockInitErrorCodeSchema: v.StringSchema<undefined>;
5
- export type CustomBlockInitErrorCode = CustomBlockErrorCode<"manifest_unavailable" | "manifest_invalid" | "invalid_connect_payload" | "invalid_protocol_version" | "unsupported_protocol_version" | "init_timeout" | "context_unavailable" | "current_user_unavailable" | "initial_state_timeout" | "missing_data_source_binding" | "data_source_unavailable" | "missing_property_binding" | "invalid_property_binding">;
5
+ export type CustomBlockInitErrorCode = CustomBlockErrorCode<"manifest_unavailable" | "manifest_invalid" | "invalid_local_preview_url" | "invalid_connect_payload" | "invalid_protocol_version" | "unsupported_protocol_version" | "init_timeout" | "context_unavailable" | "current_user_unavailable" | "initial_state_timeout" | "missing_data_source_binding" | "data_source_unavailable" | "missing_property_binding" | "invalid_property_binding">;
6
6
  export type CustomBlockInitErrorInfo = CustomBlockErrorInfo<CustomBlockInitErrorCode>;
7
7
  /**
8
8
  * Every initialization failure visible to block code. This combines errors
@@ -1,7 +1,7 @@
1
1
  import * as v from "valibot";
2
2
  import type { CustomBlockErrorCode, CustomBlockErrorInfo } from "../errors.js";
3
3
  export declare const customBlockQueryDataSourceErrorCodeSchema: v.StringSchema<undefined>;
4
- export type CustomBlockQueryDataSourceErrorCode = CustomBlockErrorCode<"query_data_source_failed" | "invalid_data_source_query" | "invalid_data_source_query_filter" | "invalid_data_source_query_sort" | "unknown_data_source_key" | "unmapped_data_source" | "data_source_schema_unavailable">;
4
+ export type CustomBlockQueryDataSourceErrorCode = CustomBlockErrorCode<"query_data_source_failed" | "invalid_data_source_query" | "data_source_query_invalid_limit" | "invalid_data_source_query_filter" | "invalid_data_source_query_sort" | "unknown_data_source_key" | "unmapped_data_source" | "data_source_schema_unavailable">;
5
5
  export type CustomBlockQueryDataSourceErrorInfo = CustomBlockErrorInfo<CustomBlockQueryDataSourceErrorCode>;
6
6
  export declare const customBlockQueryDataSourceErrorInfoSchema: v.ObjectSchema<{
7
7
  readonly code: v.StringSchema<undefined>;
@@ -314,7 +314,7 @@ export declare const queryDataSourceResultMessageSchema: v.VariantSchema<"status
314
314
  readonly isRetryable: v.BooleanSchema<undefined>;
315
315
  }, undefined>;
316
316
  }, undefined>], undefined>;
317
- export declare const queryDataSourceResultMessageLegacySchema: v.VariantSchema<"status", [v.ObjectSchema<{
317
+ export declare const queryDataSourceResultMessageWithProtocol3To5CompatibilitySchema: v.VariantSchema<"status", [v.ObjectSchema<{
318
318
  readonly type: v.LiteralSchema<"queryDataSourceResult", undefined>;
319
319
  readonly subscriptionId: v.StringSchema<undefined>;
320
320
  readonly status: v.LiteralSchema<"success", undefined>;
@@ -683,4 +683,4 @@ export declare const queryDataSourceResultMessageLegacySchema: v.VariantSchema<"
683
683
  }, undefined>;
684
684
  }, undefined>], undefined>;
685
685
  export type QueryDataSourceResultMessage = v.InferOutput<typeof queryDataSourceResultMessageSchema>;
686
- export type QueryDataSourceResultMessageLegacy = v.InferOutput<typeof queryDataSourceResultMessageLegacySchema>;
686
+ export type QueryDataSourceResultMessageWithProtocol3To5Compatibility = v.InferOutput<typeof queryDataSourceResultMessageWithProtocol3To5CompatibilitySchema>;
@@ -1,5 +1,5 @@
1
1
  import * as v from "valibot";
2
- import { legacyNotionDataSourcePageBridgeSchema } from "../dataSources/dataSourcePage.js";
2
+ import { notionDataSourcePageForProtocol3To5Schema } from "../dataSources/dataSourcePage.js";
3
3
  import { notionPageDataSchema } from "../pages/page.js";
4
4
  // The schema accepts any string code. The type lists known codes for
5
5
  // autocomplete, with an open string fallback for newer senders.
@@ -27,12 +27,15 @@ export const queryDataSourceResultMessageSchema = v.variant("status", [
27
27
  error: customBlockQueryDataSourceErrorInfoSchema,
28
28
  }),
29
29
  ]);
30
- export const queryDataSourceResultMessageLegacySchema = v.variant("status", [
30
+ export const queryDataSourceResultMessageWithProtocol3To5CompatibilitySchema = v.variant("status", [
31
31
  v.object({
32
32
  type: v.literal("queryDataSourceResult"),
33
33
  subscriptionId: v.string(),
34
34
  status: v.literal("success"),
35
- items: v.array(v.union([notionPageDataSchema, legacyNotionDataSourcePageBridgeSchema])),
35
+ items: v.array(v.union([
36
+ notionPageDataSchema,
37
+ notionDataSourcePageForProtocol3To5Schema,
38
+ ])),
36
39
  hasMore: v.boolean(),
37
40
  }),
38
41
  v.object({
@@ -313,7 +313,7 @@ export declare const updatePageResultMessageSchema: v.VariantSchema<"status", [v
313
313
  readonly isRetryable: v.BooleanSchema<undefined>;
314
314
  }, undefined>;
315
315
  }, undefined>], undefined>;
316
- export declare const updatePageResultMessageLegacySchema: v.VariantSchema<"status", [v.ObjectSchema<{
316
+ export declare const updatePageResultMessageWithProtocol3To5CompatibilitySchema: v.VariantSchema<"status", [v.ObjectSchema<{
317
317
  readonly type: v.LiteralSchema<"updatePageResult", undefined>;
318
318
  readonly requestId: v.StringSchema<undefined>;
319
319
  readonly status: v.LiteralSchema<"success", undefined>;
@@ -892,4 +892,4 @@ export declare const updatePageResultMessageLegacySchema: v.VariantSchema<"statu
892
892
  }, undefined>;
893
893
  }, undefined>], undefined>;
894
894
  export type UpdatePageResultMessage = v.InferOutput<typeof updatePageResultMessageSchema>;
895
- export type UpdatePageResultMessageLegacy = v.InferOutput<typeof updatePageResultMessageLegacySchema>;
895
+ export type UpdatePageResultMessageWithProtocol3To5Compatibility = v.InferOutput<typeof updatePageResultMessageWithProtocol3To5CompatibilitySchema>;
@@ -1,5 +1,5 @@
1
1
  import * as v from "valibot";
2
- import { legacyNotionPageSchema, notionPageDataSchema } from "../pages/page.js";
2
+ import { notionPageDataSchema, notionPageForProtocol3To5Schema, } from "../pages/page.js";
3
3
  // The schema accepts any string code. The type lists known codes for
4
4
  // autocomplete, with an open string fallback for newer senders.
5
5
  export const customBlockUpdatePageErrorCodeSchema = v.string();
@@ -25,12 +25,12 @@ export const updatePageResultMessageSchema = v.variant("status", [
25
25
  error: customBlockUpdatePageErrorInfoSchema,
26
26
  }),
27
27
  ]);
28
- export const updatePageResultMessageLegacySchema = v.variant("status", [
28
+ export const updatePageResultMessageWithProtocol3To5CompatibilitySchema = v.variant("status", [
29
29
  v.object({
30
30
  type: v.literal("updatePageResult"),
31
31
  requestId: v.string(),
32
32
  status: v.literal("success"),
33
- page: v.union([notionPageDataSchema, legacyNotionPageSchema]),
33
+ page: v.union([notionPageDataSchema, notionPageForProtocol3To5Schema]),
34
34
  }),
35
35
  v.object({
36
36
  type: v.literal("updatePageResult"),
@@ -1139,7 +1139,7 @@ export declare const notionPageDataSchema: v.ObjectSchema<{
1139
1139
  readonly in_trash: v.BooleanSchema<undefined>;
1140
1140
  }, undefined>;
1141
1141
  export type NotionPageData = v.InferInput<typeof notionPageDataSchema>;
1142
- export declare const legacyNotionPageSchema: v.ObjectSchema<{
1142
+ export declare const notionPageForProtocol3To5Schema: v.ObjectSchema<{
1143
1143
  readonly object: v.LiteralSchema<"page", undefined>;
1144
1144
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
1145
1145
  readonly parent: v.VariantSchema<"type", [v.ObjectSchema<{
@@ -1418,5 +1418,5 @@ export declare const legacyNotionPageSchema: v.ObjectSchema<{
1418
1418
  /** Whether the page or an ancestor is in Trash. */
1419
1419
  readonly in_trash: v.BooleanSchema<undefined>;
1420
1420
  }, undefined>;
1421
- export type LegacyNotionPage = v.InferOutput<typeof legacyNotionPageSchema>;
1421
+ export type NotionPageForProtocol3To5 = v.InferOutput<typeof notionPageForProtocol3To5Schema>;
1422
1422
  export {};
@@ -300,7 +300,7 @@ export const notionPageDataSchema = v.object({
300
300
  /** Whether the page or an ancestor is in Trash. */
301
301
  in_trash: v.boolean(),
302
302
  });
303
- export const legacyNotionPageSchema = v.object({
303
+ export const notionPageForProtocol3To5Schema = v.object({
304
304
  object: v.literal("page"),
305
305
  id: notionPageIdSchema,
306
306
  parent: notionParentSchema,
@@ -3,6 +3,6 @@
3
3
  * Increase this value for breaking wire changes. Hosts can continue to accept
4
4
  * older versions, so this value does not set the minimum or maximum they accept.
5
5
  */
6
- export declare const LATEST_BRIDGE_PROTOCOL_VERSION = 7;
7
- export declare const LEGACY_PROPERTY_SHAPE_PROTOCOL_VERSION = 6;
6
+ export declare const LATEST_BRIDGE_PROTOCOL_VERSION = 8;
7
+ export declare const UNIFIED_PAGE_PROTOCOL_VERSION = 6;
8
8
  export declare const TEXT_FALLBACK_PROPERTY_PROTOCOL_VERSION = 7;
@@ -3,9 +3,9 @@
3
3
  * Increase this value for breaking wire changes. Hosts can continue to accept
4
4
  * older versions, so this value does not set the minimum or maximum they accept.
5
5
  */
6
- export const LATEST_BRIDGE_PROTOCOL_VERSION = 7;
6
+ export const LATEST_BRIDGE_PROTOCOL_VERSION = 8;
7
7
  // Protocol 6 introduces unified pages with name-keyed property objects.
8
8
  // Keep this cutoff fixed when the latest protocol version increases.
9
- export const LEGACY_PROPERTY_SHAPE_PROTOCOL_VERSION = 6;
9
+ export const UNIFIED_PAGE_PROTOCOL_VERSION = 6;
10
10
  // Protocol 7 adds typed text fallbacks for previously unsupported page properties.
11
11
  export const TEXT_FALLBACK_PROPERTY_PROTOCOL_VERSION = 7;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The protocol package is private and is bundled into the published host package.
3
+ * This public /protocol entrypoint lets consumers use the schemas, types, and
4
+ * constants that ship with their host version without a separate protocol package.
5
+ *
6
+ * Keep wire definitions here so the package root stays focused on host APIs.
7
+ */
8
+ export * from "./protocol/index.js";
9
+ //# sourceMappingURL=protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,cAAc,kCAAkC,CAAA"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The protocol package is private and is bundled into the published host package.
3
+ * This public /protocol entrypoint lets consumers use the schemas, types, and
4
+ * constants that ship with their host version without a separate protocol package.
5
+ *
6
+ * Keep wire definitions here so the package root stays focused on host APIs.
7
+ */
8
+ export * from "./protocol/index.js";
@@ -0,0 +1,67 @@
1
+ # Bridge protocol changelog
2
+
3
+ The bridge protocol defines the messages exchanged by a custom block's SDK and its host. This
4
+ changelog records breaking contract changes and the SDK releases that introduced them. It also
5
+ describes compatibility exceptions within a declared protocol version and their effects on blocks.
6
+ Protocol version rules are in [Bridge protocol versioning](versioning.md). The host's
7
+ [compatibility reference](../compatibility.md) describes current support and response
8
+ conversions.
9
+
10
+ Publication dates refer to npm releases in Pacific time, not deployment in Notion. Unqualified SDK
11
+ versions refer to `@notionhq/custom-blocks`.
12
+
13
+ | Protocol | SDK release | Published | Breaking contract changes |
14
+ | ------------------------------------------------------ | ---------------- | ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
15
+ | 1 | `ncblock@0.0.1` | May 11, 2026 | Initial `ready` / `init` handshake and block APIs |
16
+ | 2 | `ncblock@0.0.36` | June 18, 2026 | Structured errors, handshake changes, and raw data-source IDs instead of manifest keys |
17
+ | 3 | `0.1.0` | July 22, 2026 | Accumulated contract changes include `connect → init → initResult`, initialization identity, subscription identity, and required structured connect errors |
18
+ | 4 | `0.2.0` | September 17, 2026 | Required `init.contrastMode` and page/query `is_archived` and `in_trash` fields |
19
+ | 5 [†](#protocol-5-unavailable-containing-page-context) | `0.2.16` | September 30, 2026 | Query filters and sorts must address actual database properties. Filter and sort payloads reject extra fields |
20
+ | 6 [‡](#protocol-6-richer-fallback-properties) | `0.3.0` | October 26, 2026 | Typed, display-name-keyed query properties and unified page responses replace the older query representation |
21
+ | 7 | `0.3.3` | October 30, 2026 | Typed text fallback properties for unique ID, button, formula, location, rollup, and verification |
22
+ | 8 | `0.4.0` | November 2, 2026 | Local manifests move from `/manifest` to HTML metadata sent in `connect`; `manifestSource` selects the initialization manifest |
23
+
24
+ The table lists SDK release boundaries, not complete supported version ranges. Host compatibility
25
+ depends on `connect.bridgeProtocolVersion`, not the SDK package version.
26
+
27
+ ## Protocol 8: local manifest declarations
28
+
29
+ The dev shell removes the `/manifest` route and embeds the local manifest in block HTML. The SDK
30
+ reads that metadata and sends the declaration in `connect.manifest`; initialization no longer
31
+ fetches `/manifest`.
32
+
33
+ The host option `manifestSource` selects the initialization manifest: `"sandbox"` uses the
34
+ declaration from `connect`, and `"host"` uses the persisted manifest returned by
35
+ `getPersistedManifest`. Only the selected source determines initialization. Deployed blocks using
36
+ supported earlier protocols retain their existing response formats.
37
+
38
+ The shared host runtime minimum remains 3. The dev shell uses the Worker manifest in host mode and
39
+ accepts supported earlier protocols. Sandbox-mode initialization uses the protocol 8 declaration
40
+ from `connect`.
41
+
42
+ ## Changes within a declared version
43
+
44
+ ### Protocol 5: unavailable containing-page context
45
+
46
+ On October 2, 2026, SDK 0.2.17 added `{ type: "unavailable" }` to containing-page context while
47
+ retaining protocol 5. SDK 0.2.16 rejects that shape. The host preserves later protocol 5 behavior
48
+ and accepts the limitation for the older SDK, as decided on October 31, 2026. Affected blocks must
49
+ upgrade and rebuild. The host's [compatibility reference](../compatibility.md)
50
+ describes current compatibility behavior.
51
+
52
+ ### Protocol 6: richer fallback properties
53
+
54
+ The protocol version changed in code on October 22, 2026. On October 26, the `pages` and
55
+ `dataSources` APIs adopted a shared page representation: data-source query rows and page operation
56
+ results use the same page shape, with typed properties keyed by display name.
57
+
58
+ Some SDKs added text fallback property objects for unique ID, button, formula, location, rollup, and
59
+ verification while still reporting protocol 6. Earlier protocol 6 SDKs reject those property
60
+ objects. Because both groups declare the same protocol version, updated hosts send `null` for these
61
+ properties to every protocol 6 block.
62
+
63
+ Blocks built with the later protocol 6 SDKs therefore lose those property values when their host
64
+ updates. UI that displays the values can become empty, and code that assumes a property object is
65
+ present can fail. Upgrade the SDK to protocol 7 or later and rebuild the block to receive the text
66
+ fallback property objects. Host adapters continue returning the current page shape; the host runtime
67
+ applies the protocol-specific conversion.