@notionhq/custom-blocks-dev-shell 0.1.116 → 0.2.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.
package/dist/index.html CHANGED
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>Workers local shell</title>
7
- <script type="module" crossorigin src="/assets/index-DSaseWP_.js"></script>
7
+ <script type="module" crossorigin src="/assets/index-n0_PUieY.js"></script>
8
8
  <link rel="stylesheet" crossorigin href="/assets/index-Do-x8yIt.css">
9
9
  </head>
10
10
  <body>
@@ -939,6 +939,32 @@ var notionParentSchema = variant("type", [
939
939
  unavailableParentSchema
940
940
  ]);
941
941
 
942
+ // ../protocol/src/icons.ts
943
+ var notionIconNameSchema = string();
944
+ var knownNotionIconColorSchema = picklist([
945
+ "gray",
946
+ "lightgray",
947
+ "brown",
948
+ "yellow",
949
+ "orange",
950
+ "green",
951
+ "blue",
952
+ "purple",
953
+ "pink",
954
+ "red"
955
+ ]);
956
+ var notionIconColorSchema = union([
957
+ knownNotionIconColorSchema,
958
+ string()
959
+ ]);
960
+ var notionNativeIconSchema = looseObject({
961
+ type: literal("icon"),
962
+ icon: looseObject({
963
+ name: notionIconNameSchema,
964
+ color: optional(notionIconColorSchema)
965
+ })
966
+ });
967
+
942
968
  // ../protocol/src/pages/pageAppearance.ts
943
969
  var notionEmojiIconSchema = object({
944
970
  type: literal("emoji"),
@@ -964,6 +990,7 @@ var notionHostedFileSchema = object({
964
990
  })
965
991
  });
966
992
  var notionPageIconSchema = variant("type", [
993
+ notionNativeIconSchema,
967
994
  notionEmojiIconSchema,
968
995
  notionCustomEmojiIconSchema,
969
996
  notionExternalFileSchema,
@@ -973,6 +1000,13 @@ var notionPageCoverSchema = variant("type", [
973
1000
  notionExternalFileSchema,
974
1001
  notionHostedFileSchema
975
1002
  ]);
1003
+ var notionCreatePageIconSchema = variant("type", [
1004
+ notionNativeIconSchema,
1005
+ notionEmojiIconSchema,
1006
+ notionCustomEmojiIconSchema,
1007
+ notionExternalFileSchema,
1008
+ notionHostedFileSchema
1009
+ ]);
976
1010
 
977
1011
  // ../protocol/src/utils/nullableStringSchema.ts
978
1012
  var nullableStringSchema = nullable(string());
@@ -1237,11 +1271,6 @@ var bridgePagePropertyValueSchema = variant("type", [
1237
1271
  type: literal("last_edited_by"),
1238
1272
  last_edited_by: metadataActorSchema
1239
1273
  }),
1240
- object({
1241
- ...pagePropertyBaseSchema,
1242
- type: literal("last_visited_time"),
1243
- last_visited_time: nullableStringSchema
1244
- }),
1245
1274
  object({
1246
1275
  ...pagePropertyBaseSchema,
1247
1276
  type: literal("unique_id"),
@@ -1446,7 +1475,6 @@ var NOTION_PROPERTY_TYPES = [
1446
1475
  "rollup",
1447
1476
  "button",
1448
1477
  "verification",
1449
- "last_visited_time",
1450
1478
  "location",
1451
1479
  "created_time",
1452
1480
  "last_edited_time",
@@ -1494,7 +1522,6 @@ var notionPropertySchemaSchema = variant("type", [
1494
1522
  // Internal-only types passed through under their bridge-native names.
1495
1523
  object({ ...baseProp.entries, type: literal("button") }),
1496
1524
  object({ ...baseProp.entries, type: literal("verification") }),
1497
- object({ ...baseProp.entries, type: literal("last_visited_time") }),
1498
1525
  object({ ...baseProp.entries, type: literal("location") }),
1499
1526
  // Synthetic built-ins. The host always emits one of each per data source.
1500
1527
  object({ ...baseProp.entries, type: literal("created_time") }),
@@ -1837,7 +1864,6 @@ var bridgePageSchema = object({
1837
1864
  properties: bridgePagePropertyReadMapSchema,
1838
1865
  created_by: optional(metadataActorSchema, null),
1839
1866
  last_edited_by: optional(metadataActorSchema, null),
1840
- last_visited_time: optional(nullable(string()), null),
1841
1867
  created_time: optional(nullable(string()), null),
1842
1868
  last_edited_time: optional(nullable(string()), null),
1843
1869
  icon: optional(nullable(notionPageIconSchema), null),
@@ -1949,7 +1975,7 @@ var notionDataSourceSchema = object({
1949
1975
  // ../protocol/src/manifest/capabilities.ts
1950
1976
  var customBlockCapabilityDeclarationSchema = object({
1951
1977
  capability: string(),
1952
- resource: string()
1978
+ resource: union([string(), pipe(array(string()), minLength(1))])
1953
1979
  });
1954
1980
 
1955
1981
  // ../protocol/src/manifest/manifest.ts
@@ -1968,6 +1994,11 @@ var manifestPropertySchema = object({
1968
1994
  description: optional(string()),
1969
1995
  type: notionPropertyTypeSchema
1970
1996
  });
1997
+ var manifestPageSchema = object({
1998
+ name: string(),
1999
+ description: optional(string()),
2000
+ icon: optional(manifestIconSchema)
2001
+ });
1971
2002
  var manifestDataSourceSchema = object({
1972
2003
  name: string(),
1973
2004
  description: optional(string()),
@@ -1981,6 +2012,7 @@ var manifestSchema = object({
1981
2012
  slashCommand: optional(string()),
1982
2013
  icon: optional(object({ type: literal("emoji"), emoji: string() })),
1983
2014
  dataSources: optional(record(string(), manifestDataSourceSchema), {}),
2015
+ pages: optional(record(string(), manifestPageSchema)),
1984
2016
  /**
1985
2017
  * Capabilities the block needs. Omitted means the block predates capability
1986
2018
  * approval, so hosts do not ask the viewer. An empty array declares no
@@ -2184,7 +2216,9 @@ var createPageMessageBaseSchema = {
2184
2216
  * To create a page with manifest-defined property keys, call `pages.create`. The SDK resolves
2185
2217
  * those keys before it sends this message.
2186
2218
  */
2187
- properties: bridgePagePropertyWriteMapSchema
2219
+ properties: bridgePagePropertyWriteMapSchema,
2220
+ icon: optional(notionCreatePageIconSchema),
2221
+ cover: optional(notionPageCoverSchema)
2188
2222
  };
2189
2223
  var createPageMessageSchema = variant("type", [
2190
2224
  object({
@@ -2397,6 +2431,8 @@ var listUsersResultMessageSchema = variant("status", [
2397
2431
  // ../protocol/src/messages/invalidSandboxMessage.ts
2398
2432
  var invalidSandboxMessageSchema = object({
2399
2433
  type: literal("invalidSandboxMessage"),
2434
+ /** Identifies the rejected request or response, when readable. */
2435
+ requestId: optional(string()),
2400
2436
  /**
2401
2437
  * A human-readable string intended for sandbox-side logging. It has no structured contract.
2402
2438
  */
@@ -2436,6 +2472,8 @@ var hostToSandboxMessageWithProtocol3To5CompatibilitySchema = variant("type", [
2436
2472
  // ../protocol/src/messages/invalidHostMessage.ts
2437
2473
  var invalidHostMessageSchema = object({
2438
2474
  type: literal("invalidHostMessage"),
2475
+ /** Identifies the rejected request or response, when readable. */
2476
+ requestId: optional(string()),
2439
2477
  /**
2440
2478
  * A human-readable string intended for sandbox-side logging. It has no structured contract.
2441
2479
  */
@@ -2459,6 +2497,9 @@ var sandboxToHostMessageSchema = variant("type", [
2459
2497
  invalidHostMessageSchema
2460
2498
  ]);
2461
2499
 
2500
+ // ../protocol/src/utils/readRequestId.ts
2501
+ var requestIdentitySchema = object({ requestId: string() });
2502
+
2462
2503
  // cli/diagnostics/formatUnknownError.ts
2463
2504
  function formatUnknownError(error) {
2464
2505
  return error instanceof Error ? error.message : String(error);
@@ -6504,15 +6545,11 @@ function convertPublicApiPropertyValue(publicType, value) {
6504
6545
  const uniqueId = payload;
6505
6546
  return uniqueId.prefix ? `${uniqueId.prefix}-${uniqueId.number}` : String(uniqueId.number);
6506
6547
  }
6507
- // The production host still serializes formula, rollup, and
6508
- // last_visited_time as plain text. Match it so fixtures predict what a
6509
- // block receives from the real host.
6548
+ // Match the production host’s text serialization for formula and rollup.
6510
6549
  case "formula":
6511
6550
  return formulaToText(payload);
6512
6551
  case "rollup":
6513
6552
  return rollupToText(payload);
6514
- case "last_visited_time":
6515
- return payload;
6516
6553
  case "created_time":
6517
6554
  case "last_edited_time":
6518
6555
  return timestampToLocal(payload);
@@ -6636,8 +6673,7 @@ var VALUE_SCHEMAS = {
6636
6673
  rollup: stringValue,
6637
6674
  verification: stringValue,
6638
6675
  place: stringValue,
6639
- location: stringValue,
6640
- last_visited_time: stringValue
6676
+ location: stringValue
6641
6677
  };
6642
6678
  function matchesPropertyType(value, type) {
6643
6679
  return is(VALUE_SCHEMAS[type] ?? anyLocalValue, value);
@@ -7804,6 +7840,61 @@ var SharedServer = class {
7804
7840
  }
7805
7841
  };
7806
7842
 
7843
+ // cli/server/waitForPreviewUrls.ts
7844
+ import { request } from "node:http";
7845
+ import { setTimeout as delay } from "node:timers/promises";
7846
+ async function waitForPreviewUrls(urls, signal, timeoutMs = 1e4) {
7847
+ const deadline = new AbortController();
7848
+ const timer = setTimeout(() => deadline.abort(), timeoutMs);
7849
+ const bounded = AbortSignal.any([signal, deadline.signal]);
7850
+ const pending = new Set(urls);
7851
+ try {
7852
+ while (pending.size > 0) {
7853
+ bounded.throwIfAborted();
7854
+ await Promise.all(
7855
+ [...pending].map(async (url) => {
7856
+ if (await respondsSuccessfully(new URL(url), bounded)) {
7857
+ pending.delete(url);
7858
+ }
7859
+ })
7860
+ );
7861
+ if (pending.size > 0) {
7862
+ await delay(100, void 0, { signal: bounded });
7863
+ }
7864
+ }
7865
+ bounded.throwIfAborted();
7866
+ } catch (error) {
7867
+ if (deadline.signal.aborted && !signal.aborted) {
7868
+ throw new Error(
7869
+ `Preview readiness timed out after ${timeoutMs}ms. No successful HTTP response from: ${[...pending].join(", ")}.`
7870
+ );
7871
+ }
7872
+ throw error;
7873
+ } finally {
7874
+ clearTimeout(timer);
7875
+ }
7876
+ }
7877
+ function respondsSuccessfully(url, signal) {
7878
+ return new Promise((resolve10) => {
7879
+ const probe = request(
7880
+ {
7881
+ hostname: "127.0.0.1",
7882
+ port: url.port,
7883
+ path: `${url.pathname}${url.search}`,
7884
+ headers: { Host: url.host },
7885
+ signal
7886
+ },
7887
+ (response) => {
7888
+ const status = response.statusCode ?? 0;
7889
+ response.destroy();
7890
+ resolve10(status >= 200 && status < 300);
7891
+ }
7892
+ );
7893
+ probe.on("error", () => resolve10(false));
7894
+ probe.end();
7895
+ });
7896
+ }
7897
+
7807
7898
  // cli/server/writeBlockViteConfig.ts
7808
7899
  import { existsSync as existsSync5, mkdirSync as mkdirSync4, writeFileSync as writeFileSync2 } from "node:fs";
7809
7900
  import { relative, resolve as resolve4 } from "node:path";
@@ -8286,6 +8377,8 @@ async function launchDevShell(options) {
8286
8377
  if (installSignalHandlers) {
8287
8378
  installProcessSignalHandlers(run);
8288
8379
  }
8380
+ const readiness = new AbortController();
8381
+ run.addResource(() => readiness.abort());
8289
8382
  try {
8290
8383
  const writeReady = configureStartupOutput(options.argv.includes("--json"));
8291
8384
  const args = parseWorkerLaunchArgs(options.argv);
@@ -8351,16 +8444,28 @@ async function launchDevShell(options) {
8351
8444
  if (run.closing) {
8352
8445
  return;
8353
8446
  }
8354
- writeReady?.({
8355
- event: "ready",
8356
- shellUrl: `http://localhost:${args.shellPort}`,
8357
- workerDir,
8358
- devShellVersion: options.devShellVersion,
8359
- customBlocks: describeStartupCustomBlocks(
8360
- plan,
8361
- dataService.getSnapshot().dataSources
8362
- )
8363
- });
8447
+ if (writeReady) {
8448
+ await waitForPreviewUrls(
8449
+ [
8450
+ `http://localhost:${args.shellPort}`,
8451
+ ...plan.registry.map((block) => block.url)
8452
+ ],
8453
+ readiness.signal
8454
+ );
8455
+ if (run.closing) {
8456
+ return;
8457
+ }
8458
+ writeReady({
8459
+ event: "ready",
8460
+ shellUrl: `http://localhost:${args.shellPort}`,
8461
+ workerDir,
8462
+ devShellVersion: options.devShellVersion,
8463
+ customBlocks: describeStartupCustomBlocks(
8464
+ plan,
8465
+ dataService.getSnapshot().dataSources
8466
+ )
8467
+ });
8468
+ }
8364
8469
  printSummary(args, plan.registry);
8365
8470
  } catch (error) {
8366
8471
  if (run.closing) {
@@ -19,11 +19,31 @@ versions refer to `@notionhq/custom-blocks`.
19
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
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
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 |
22
+ | 8 | `0.3.4` | November 3, 2026 | Local manifests move from `/manifest` to HTML metadata sent in `connect`; `manifestSource` selects the initialization manifest |
23
+ | 9 | Unreleased | — | Native page icons; older protocols receive external SVG URLs |
24
+ | 10 | `0.4.0` | November 10, 2026 | Removes `last_visited_time` from property schemas, page properties, and page metadata |
23
25
 
24
26
  The table lists SDK release boundaries, not complete supported version ranges. Host compatibility
25
27
  depends on `connect.bridgeProtocolVersion`, not the SDK package version.
26
28
 
29
+ ## Protocol 10: remove last visited time
30
+
31
+ `last_visited_time` is viewer-specific recents data, not a database property type. Protocol 10
32
+ removes it from manifests, binding schemas, page property values, and top-level page metadata. Older
33
+ SDKs can still connect, but updated hosts no longer load or return viewer visit data. Older readers
34
+ default the absent page field to `null`. Blocks that use this field must remove that use and
35
+ rebuild.
36
+
37
+ ## Protocol 9: native page icons
38
+
39
+ Page operations and query results can return `{ type: "icon", icon: { name, color } }`. Reads and
40
+ writes share a loose shape: names and colors accept strings, color is optional, and additional
41
+ native icon fields are retained. Hosts resolve names and default omitted colors to gray.
42
+
43
+ Protocols 3–8 receive external SVG URLs in page operation results. Protocols 6–8 receive the same
44
+ fallback in query results; protocols 3–5 keep their flat query format without appearance fields. The
45
+ released-SDK compatibility corpus exercises these conversions.
46
+
27
47
  ## Protocol 8: local manifest declarations
28
48
 
29
49
  The dev shell removes the `/manifest` route and embeds the local manifest in block HTML. The SDK
@@ -41,6 +61,13 @@ from `connect`.
41
61
 
42
62
  ## Changes within a declared version
43
63
 
64
+ ### Protocol 8: correlated request rejections
65
+
66
+ Bridge NACKs (`invalidHostMessage` and `invalidSandboxMessage`) gain an optional string `requestId`.
67
+ Updated SDKs complete the matching request immediately when a rejection can be correlated. Older
68
+ readers ignore the additional field; updated readers continue to accept NACKs without an ID.
69
+ Uncorrelated requests use the SDK's 60-second timeout. This additive change retains protocol 8.
70
+
44
71
  ### Protocol 5: unavailable containing-page context
45
72
 
46
73
  On October 2, 2026, SDK 0.2.17 added `{ type: "unavailable" }` to containing-page context while
@@ -62,7 +62,9 @@ a different origin from its embedding page.
62
62
  - `queryDataSource` is a long-lived subscription; requests and every update use its stable
63
63
  `subscriptionId`.
64
64
  - The initialization lifecycle uses `initializationId`, not `requestId` or `subscriptionId`.
65
- - One-way messages, such as `resize` and bridge NACKs, have no correlation ID.
65
+ - One-way messages, such as `resize`, have no correlation ID.
66
+ - Bridge NACKs include the rejected message's `requestId` when it is a string. The ID identifies the
67
+ original request, including when the rejected message is its response.
66
68
 
67
69
  Hosts key query state by `subscriptionId`, replace state when a request reuses one, and suppress
68
70
  stale asynchronous results.
@@ -82,6 +84,22 @@ On parse failure, the host replies with `invalidSandboxMessage` and the sandbox
82
84
  `invalidHostMessage`, except for the handshake cases below. These replies are negative
83
85
  acknowledgments (NACKs). Receivers do not NACK another NACK.
84
86
 
87
+ A sandbox request with a `requestId` expects a terminal result or correlated rejection. On parse
88
+ failure, read `requestId` separately from the invalid payload. The host includes a readable string
89
+ ID in `invalidSandboxMessage`, even for an unknown request type. The SDK completes the matching
90
+ request with `invalid_sandbox_message`. When the SDK rejects a host response, it completes the
91
+ matching request locally with `invalid_host_message` and includes the ID in `invalidHostMessage`.
92
+ Both errors have `isRetryable: false`.
93
+
94
+ One-shot SDK requests time out after 60 seconds. Missing, unreadable, or unknown IDs do not fail
95
+ unrelated requests. NACK IDs are optional: older readers ignore them, and newer readers accept
96
+ legacy NACKs without IDs. Those requests retain the timeout fallback.
97
+
98
+ Request completion clears its timer, removes the pending entry, and ignores duplicate or late
99
+ results. Disposing the SDK completes pending calls locally with `request_disposed` and clears their
100
+ timers. The SDK does not retry or cancel host work. A timed-out write may still complete; check its
101
+ resulting state before repeating it. Data source subscriptions use a separate lifecycle.
102
+
85
103
  Malformed sandbox messages do not change the host's initialization state or timeout, except as
86
104
  follows:
87
105
 
@@ -167,9 +185,15 @@ filter: {
167
185
 
168
186
  ## Capabilities
169
187
 
170
- `manifest.capabilities` lists `{ capability, resource }` declarations. Both fields are open strings,
171
- so a newer vocabulary never makes an older receiver reject a manifest. An omitted `capabilities`
172
- marks a block that predates approval.
188
+ `manifest.capabilities` lists `{ capability, resource }` declarations. `capability` is an open
189
+ string and `resource` is an open string or a non-empty array of them, so a newer vocabulary never
190
+ makes an older receiver reject a manifest. An array declares the capability on each element.
191
+ Receivers never split a resource string on commas. An omitted `capabilities` marks a block that
192
+ predates approval.
193
+
194
+ Page capability resources can name one manifest data source as `data_source:<key>`. The key is the
195
+ semantic key from `manifest.dataSources`; hosts resolve it to the bound data source when they record
196
+ and check grants. Bare `data_source` covers every declared key.
173
197
 
174
198
  The `capability_not_granted` error code is reserved for a request that the viewer's grants do not
175
199
  cover, with `isRetryable: false`. No adapter sends it yet, and no receiver restricts requests by
@@ -202,3 +226,14 @@ or `""` when absent. Hosts do not evaluate formulas or rollups.
202
226
  The host converts responses to the sandbox's declared protocol. See
203
227
  [versioning and compatibility](versioning.md) for protocol version rules. The host's
204
228
  [compatibility reference](../host/docs/compatibility.md) describes older response formats.
229
+
230
+ ### Native page icon compatibility
231
+
232
+ Protocol 9 and later use native icon objects. Protocols 3–8 receive external SVG URLs in page
233
+ operation results. Unified query results in protocols 6–8 also use external SVG URLs; flat query
234
+ results in protocols 3–5 omit icon fields. Native colors accept any string in responses and write
235
+ inputs, so newer host colors do not require an SDK update.
236
+
237
+ `createPage` accepts native icons, emoji, custom emoji, and URL-backed icons and covers. The
238
+ application adapter checks submitted image URLs against the block's network permissions before
239
+ creating a page.
@@ -17,6 +17,7 @@ conversions.
17
17
 
18
18
  `connect.bridgeProtocolVersion` selects the wire contract. `sdkVersion` is analytics metadata.
19
19
  `LATEST_BRIDGE_PROTOCOL_VERSION` identifies the latest contract defined by the package.
20
+ `NATIVE_ICON_PROTOCOL_VERSION` is 9, the first protocol with native icon responses and writes.
20
21
 
21
22
  ## Protocol export names
22
23
 
@@ -9,6 +9,13 @@ Create the host before navigating the iframe. Pass the full block URL as `sandbo
9
9
 
10
10
  For configuration and lifecycle details, see [Initialization and lifecycle](docs/lifecycle.md).
11
11
 
12
+ Use `BridgeParent` from `@notionhq/custom-blocks-host/protocol` to construct parent references with
13
+ plain string IDs. The host validates the parent before sending it to the block.
14
+
15
+ Implement `CustomBlockHostHandlers` to connect the host to your application. Handlers return shared
16
+ bridge data using `CustomBlockHostResult`. Use `makeBridgePage` to construct a complete `BridgePage`
17
+ from your records. See [Return bridge data](docs/handlers.md#return-bridge-data).
18
+
12
19
  ## Create a host
13
20
 
14
21
  Install `@notionhq/custom-blocks-host` in your embedding application. Run this TypeScript through
@@ -175,3 +182,12 @@ These schemas validate wire payloads. Your application still enforces permission
175
182
 
176
183
  `dist/browser.js` is one ES module with all dependencies. Use it when the browser must not fetch
177
184
  additional modules, such as under an exact-URL Content Security Policy.
185
+
186
+ ### Native page icons
187
+
188
+ `CustomBlockHostPageIcon` accepts canonical native icon names from adapters. Adapters validate names
189
+ and colors before writing. The runtime validates response payloads.
190
+
191
+ Adapters must check URL-backed icon and cover writes against the block's network permissions before
192
+ mutating records. Notion permits the submitted HTTPS destination only when its origin is
193
+ allowlisted; that origin is trusted to redirect.
@@ -16,7 +16,7 @@ does not guarantee that future features work.
16
16
 
17
17
  `sdkVersion` is analytics metadata. Compatibility behavior depends on the protocol version.
18
18
 
19
- The current SDK declares protocol 8. The shared runtime minimum is 3. The dev shell uses the Worker
19
+ The current SDK declares protocol 10. The shared runtime minimum is 3. The dev shell uses the Worker
20
20
  manifest in host mode and accepts the shared runtime's supported protocol versions. Protocols 7 and
21
21
  8 use the same page and query response formats. Protocol 8's local manifest declaration is selected
22
22
  only in sandbox mode; host mode uses the persisted manifest. See the
@@ -35,12 +35,13 @@ through.
35
35
 
36
36
  ## Current compatibility behavior
37
37
 
38
- | Target | Query results | Page operation results | Binding schemas |
39
- | ------ | --------------------------------------------------------------------------- | ------------------------------------------------------------- | ------------------------------------------------------------------------ |
40
- | 3–4 | Flat ID-keyed values, including synthetic metadata entries | ID-keyed properties with unsupported property objects omitted | Synthetic metadata read schemas restored in outgoing copies |
41
- | 5 | Same query values as protocols 3–4 | Same page format as protocols 3–4 | Actual database schemas. The SDK supplies synthetic read schemas locally |
42
- | 6 | Unified name-keyed properties. Text fallback property objects become `null` | Same unified page format | Actual database schemas |
43
- | 7+ | Unified pages with typed text fallback properties | Same unified page format | Actual database schemas |
38
+ | Target | Query results | Page operation results | Binding schemas | Native icons |
39
+ | ------ | --------------------------------------------------------------------------- | ------------------------------------------------------------- | ------------------------------------------------------------------------ | --------------------------------------------------------------------------- |
40
+ | 3–4 | Flat ID-keyed values, including synthetic metadata entries | ID-keyed properties with unsupported property objects omitted | Synthetic metadata read schemas restored in outgoing copies | External SVG URLs in page operations; icons omitted from flat query results |
41
+ | 5 | Same query values as protocols 3–4 | Same page format as protocols 3–4 | Actual database schemas. The SDK supplies synthetic read schemas locally | Same as protocols 3–4 |
42
+ | 6 | Unified name-keyed properties. Text fallback property objects become `null` | Same unified page format | Actual database schemas | External SVG URLs |
43
+ | 7–8 | Unified pages with typed text fallback properties | Same unified page format | Actual database schemas | External SVG URLs |
44
+ | 9+ | Unified pages with typed text fallback properties | Same unified page format | Actual database schemas | Native icon objects |
44
45
 
45
46
  The synthetic metadata IDs are `created_time`, `last_edited_time`, `created_by`, and
46
47
  `last_edited_by`. They retain metadata meaning if an actual property uses the same raw ID. This
@@ -52,6 +53,13 @@ Release-specific compatibility limits are documented in the changelog entries fo
52
53
  and
53
54
  [protocol 6 text fallback properties](../../bridge/changelog.md#protocol-6-richer-fallback-properties).
54
55
 
56
+ ### Native page icons
57
+
58
+ Protocol 9 and later receive native icon objects. Protocols 3–8 receive external SVG URLs in page
59
+ operation results, and protocols 6–8 also receive them in query results. Protocols 3–5 use flat
60
+ query results without page appearance fields. Omitted native colors default to gray when producing
61
+ SVG URLs.
62
+
55
63
  ### Unavailable containing-page context
56
64
 
57
65
  Protocols 3–4 receive `context_unavailable` during initialization or stop when containing-page
@@ -11,18 +11,26 @@ hosts must provide their own permissions, data access, and persistence.
11
11
 
12
12
  ## Handler contracts
13
13
 
14
- `queryDataSource` is required. Other handlers are optional. Omitting a one-shot request handler
15
- sends no response to that request. A handler returns a result synchronously or as a promise. Errors
16
- carry `{ code, message, isRetryable }`, with open string codes.
14
+ `queryDataSource` is required. Other handlers are optional. A handler returns a result synchronously
15
+ or as a promise. Errors carry `{ code, message, isRetryable }`, with open string codes.
17
16
 
18
- Handler requests are validated messages with branded IDs. Initial state, setters, handler results,
19
- and `*MessageInput` types accept plain string IDs. The runtime validates these inputs and applies
20
- schema defaults. ID brands do not check record existence or access.
17
+ ### Return bridge data
18
+
19
+ Handlers return data in the bridge's shared types. Use bridge builders to construct complete objects
20
+ from application records.
21
+
22
+ The host validates result shapes, matches responses to requests, and converts responses for the
23
+ block's protocol version. Your application checks that records exist and that the viewer may perform
24
+ the requested operation.
21
25
 
22
26
  Query filters and sorts are validated against the actual bound database schema before
23
27
  `queryDataSource` runs. See the [wire reference](../../bridge/protocol.md#data-sources) for
24
28
  query semantics.
25
29
 
30
+ For one-shot requests, a missing handler returns `unsupported_operation`. A handler that throws,
31
+ rejects, or returns a malformed result produces `unknown_error`. Exception details go to `onLog`;
32
+ the sandbox receives a generic error. Specific errors returned by handlers pass through unchanged.
33
+
26
34
  ## Connect a data source
27
35
 
28
36
  Connect an embedded block to an in-memory Tasks data source with one numeric Estimate property. This
@@ -42,7 +50,11 @@ import type {
42
50
  CustomBlockHostDataSourcesPayload,
43
51
  CustomBlockHostHandlers,
44
52
  } from "@notionhq/custom-blocks-host"
45
- import type { BridgeCustomBlockManifest, BridgePage } from "@notionhq/custom-blocks-host/protocol"
53
+ import {
54
+ makeBridgePage,
55
+ type BridgeCustomBlockManifest,
56
+ type BridgePage,
57
+ } from "@notionhq/custom-blocks-host/protocol"
46
58
 
47
59
  const tasksId = "44444444-4444-4444-8444-444444444444"
48
60
 
@@ -110,8 +122,7 @@ const handlers: CustomBlockHostHandlers = {
110
122
  }
111
123
 
112
124
  const items: BridgePage[] = [
113
- {
114
- object: "page",
125
+ makeBridgePage({
115
126
  id: "55555555-5555-4555-8555-555555555555",
116
127
  parent: { type: "data_source_id", data_source_id: tasksId },
117
128
  is_archived: false,
@@ -119,7 +130,7 @@ const handlers: CustomBlockHostHandlers = {
119
130
  properties: {
120
131
  Estimate: { id: "estimate-id", type: "number", number: estimate },
121
132
  },
122
- },
133
+ }),
123
134
  ]
124
135
 
125
136
  return {
@@ -60,6 +60,20 @@ late results. Manifest and state preparation providers must respect their `signa
60
60
  `setCurrentUser()` hold updates during initialization and send them after `initResult.success`. For
61
61
  data-source query refreshes, see [Handlers and data](handlers.md#refresh-active-queries).
62
62
 
63
+ `setDataSources()` returns a synchronous `CustomBlockHostSetDataSourcesResult`. Success means local
64
+ acceptance only; it does not guarantee sandbox delivery or successful initialization. Existing
65
+ callers can ignore the return value. Malformed bindings can throw during schema parsing.
66
+
67
+ - `{ status: "success" }`: accepts the bindings into local state.
68
+ - `{ status: "error", error: { code, message, isRetryable } }`: logs a warning, keeps the last
69
+ accepted bindings and pending update, and sends no update. Codes are
70
+ `missing_data_source_binding`, `missing_property_binding`, and `invalid_property_binding`. All
71
+ have `isRetryable: false`; correct the bindings before resubmitting.
72
+
73
+ Pre-connect updates are checked against the selected manifest during initialization. Later updates
74
+ are validated once that manifest is available. Accepted updates wait for `initResult.success` before
75
+ sending; after failed initialization, they only change local state and do not restart it.
76
+
63
77
  ## Callbacks
64
78
 
65
79
  The required `onStatusChange(state)` callback receives the `CustomBlockHostStatus` union:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@notionhq/custom-blocks-dev-shell",
3
- "version": "0.1.116",
3
+ "version": "0.2.0",
4
4
  "description": "Local development shell for Notion custom block workers.",
5
5
  "license": "MIT",
6
6
  "type": "module",