@notionhq/custom-blocks-host 0.5.2 → 0.6.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/README.md +9 -0
- package/dist/browser.js +1 -1
- package/dist/compatibility/normalizeHostToSandboxMessage.d.ts.map +1 -1
- package/dist/compatibility/normalizeHostToSandboxMessage.js +5 -1
- package/dist/compatibility/normalizeSandboxToHostMessage.d.ts +87 -1
- package/dist/compatibility/normalizeSandboxToHostMessage.d.ts.map +1 -1
- package/dist/compatibility/pages/toIconForProtocol3To8.d.ts +4 -0
- package/dist/compatibility/pages/toIconForProtocol3To8.d.ts.map +1 -0
- package/dist/compatibility/pages/toIconForProtocol3To8.js +13 -0
- package/dist/compatibility/protocol3To5/toPageForProtocol3To5.d.ts.map +1 -1
- package/dist/compatibility/protocol3To5/toPageForProtocol3To5.js +2 -1
- package/dist/compatibility/protocol3To5/toQueryPageForProtocol3To5.d.ts +8 -8
- package/dist/compatibility/protocol6/normalizePageResultsForProtocol6.d.ts.map +1 -1
- package/dist/compatibility/protocol6/normalizePageResultsForProtocol6.js +9 -2
- package/dist/compatibility/protocol7To8/normalizePageResultsForProtocol7To8.d.ts +4 -0
- package/dist/compatibility/protocol7To8/normalizePageResultsForProtocol7To8.d.ts.map +1 -0
- package/dist/compatibility/protocol7To8/normalizePageResultsForProtocol7To8.js +16 -0
- package/dist/createCustomBlockHost.d.ts.map +1 -1
- package/dist/createCustomBlockHost.js +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/messages/createSandboxMessageRouter.d.ts +3 -2
- package/dist/messages/createSandboxMessageRouter.d.ts.map +1 -1
- package/dist/messages/createSandboxMessageRouter.js +7 -1
- package/dist/messages/invalidNativeIconColor.d.ts +5 -0
- package/dist/messages/invalidNativeIconColor.d.ts.map +1 -0
- package/dist/messages/invalidNativeIconColor.js +34 -0
- package/dist/pages/types.d.ts +2 -0
- package/dist/pages/types.d.ts.map +1 -1
- package/dist/protocol/compatibility/protocol3To5/bridgePage.d.ts +7 -1
- package/dist/protocol/dataSources/messages/queryDataSource.d.ts +14 -2
- package/dist/protocol/icons.d.ts +17 -0
- package/dist/protocol/icons.js +27 -0
- package/dist/protocol/index.d.ts +3 -2
- package/dist/protocol/index.js +3 -2
- package/dist/protocol/messages/hostToSandbox.d.ts +77 -11
- package/dist/protocol/messages/sandboxToHost.d.ts +87 -1
- package/dist/protocol/pages/bridgePage.d.ts +7 -1
- package/dist/protocol/pages/messages/createPage.d.ts +102 -4
- package/dist/protocol/pages/messages/createPage.js +3 -1
- package/dist/protocol/pages/messages/getPage.d.ts +21 -3
- package/dist/protocol/pages/messages/updatePage.d.ts +29 -5
- package/dist/protocol/pages/pageAppearance.d.ts +36 -1
- package/dist/protocol/pages/pageAppearance.js +9 -0
- package/dist/protocol/utils/protocolVersion.d.ts +2 -1
- package/dist/protocol/utils/protocolVersion.js +3 -1
- package/docs/bridge/changelog.md +12 -0
- package/docs/bridge/protocol.md +11 -0
- package/docs/bridge/versioning.md +1 -0
- package/docs/compatibility.md +15 -7
- package/package.json +1 -1
- package/src/compatibility/normalizeHostToSandboxMessage.ts +5 -0
- package/src/compatibility/pages/toIconForProtocol3To8.ts +17 -0
- package/src/compatibility/protocol3To5/toPageForProtocol3To5.ts +2 -1
- package/src/compatibility/protocol6/normalizePageResultsForProtocol6.ts +11 -2
- package/src/compatibility/protocol7To8/normalizePageResultsForProtocol7To8.ts +22 -0
- package/src/createCustomBlockHost.ts +1 -0
- package/src/index.ts +1 -0
- package/src/messages/createSandboxMessageRouter.ts +18 -2
- package/src/messages/invalidNativeIconColor.ts +43 -0
- package/src/pages/types.ts +3 -0
|
@@ -248,7 +248,13 @@ export declare const bridgePageSchema: v.ObjectSchema<{
|
|
|
248
248
|
readonly last_visited_time: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, null>;
|
|
249
249
|
readonly created_time: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, null>;
|
|
250
250
|
readonly last_edited_time: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, null>;
|
|
251
|
-
readonly icon: v.OptionalSchema<v.NullableSchema<v.VariantSchema<"type", [v.
|
|
251
|
+
readonly icon: v.OptionalSchema<v.NullableSchema<v.VariantSchema<"type", [v.LooseObjectSchema<{
|
|
252
|
+
readonly type: v.LiteralSchema<"icon", undefined>;
|
|
253
|
+
readonly icon: v.LooseObjectSchema<{
|
|
254
|
+
readonly name: v.StringSchema<undefined>;
|
|
255
|
+
readonly color: v.OptionalSchema<v.GenericSchema<import("../icons.js").NotionIconColor>, undefined>;
|
|
256
|
+
}, undefined>;
|
|
257
|
+
}, undefined>, v.ObjectSchema<{
|
|
252
258
|
readonly type: v.LiteralSchema<"emoji", undefined>;
|
|
253
259
|
readonly emoji: v.StringSchema<undefined>;
|
|
254
260
|
}, undefined>, v.ObjectSchema<{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
import type { CustomBlockCapabilityErrorCode, CustomBlockErrorCode, CustomBlockErrorInfo, CustomBlockRequestErrorCode } from "../../utils/errors.js";
|
|
3
3
|
export declare const customBlockCreatePageErrorCodeSchema: v.StringSchema<undefined>;
|
|
4
|
-
export type CustomBlockCreatePageErrorCode = CustomBlockErrorCode<CustomBlockRequestErrorCode | "create_page_failed" | "invalid_page_parent" | "page_unavailable" | "data_source_access_failed" | "unknown_data_source_key" | "unmapped_data_source" | "data_source_inaccessible" | "unmapped_property" | "property_id_mismatch" | "duplicate_property" | "invalid_property_value" | CustomBlockCapabilityErrorCode>;
|
|
4
|
+
export type CustomBlockCreatePageErrorCode = CustomBlockErrorCode<CustomBlockRequestErrorCode | "create_page_failed" | "invalid_icon_name" | "invalid_icon_color" | "invalid_page_parent" | "page_unavailable" | "data_source_access_failed" | "unknown_data_source_key" | "unmapped_data_source" | "data_source_inaccessible" | "unmapped_property" | "property_id_mismatch" | "duplicate_property" | "invalid_property_value" | CustomBlockCapabilityErrorCode>;
|
|
5
5
|
export type CustomBlockCreatePageErrorInfo = CustomBlockErrorInfo<CustomBlockCreatePageErrorCode>;
|
|
6
6
|
export declare const customBlockCreatePageErrorInfoSchema: v.ObjectSchema<{
|
|
7
7
|
readonly code: v.StringSchema<undefined>;
|
|
@@ -265,7 +265,13 @@ export declare const createPageResultMessageSchema: v.VariantSchema<"status", [v
|
|
|
265
265
|
readonly last_visited_time: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, null>;
|
|
266
266
|
readonly created_time: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, null>;
|
|
267
267
|
readonly last_edited_time: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, null>;
|
|
268
|
-
readonly icon: v.OptionalSchema<v.NullableSchema<v.VariantSchema<"type", [v.
|
|
268
|
+
readonly icon: v.OptionalSchema<v.NullableSchema<v.VariantSchema<"type", [v.LooseObjectSchema<{
|
|
269
|
+
readonly type: v.LiteralSchema<"icon", undefined>;
|
|
270
|
+
readonly icon: v.LooseObjectSchema<{
|
|
271
|
+
readonly name: v.StringSchema<undefined>;
|
|
272
|
+
readonly color: v.OptionalSchema<v.GenericSchema<import("../../icons.js").NotionIconColor>, undefined>;
|
|
273
|
+
}, undefined>;
|
|
274
|
+
}, undefined>, v.ObjectSchema<{
|
|
269
275
|
readonly type: v.LiteralSchema<"emoji", undefined>;
|
|
270
276
|
readonly emoji: v.StringSchema<undefined>;
|
|
271
277
|
}, undefined>, v.ObjectSchema<{
|
|
@@ -568,7 +574,13 @@ export declare const createPageResultMessageWithProtocol3To5CompatibilitySchema:
|
|
|
568
574
|
readonly last_visited_time: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, null>;
|
|
569
575
|
readonly created_time: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, null>;
|
|
570
576
|
readonly last_edited_time: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, null>;
|
|
571
|
-
readonly icon: v.OptionalSchema<v.NullableSchema<v.VariantSchema<"type", [v.
|
|
577
|
+
readonly icon: v.OptionalSchema<v.NullableSchema<v.VariantSchema<"type", [v.LooseObjectSchema<{
|
|
578
|
+
readonly type: v.LiteralSchema<"icon", undefined>;
|
|
579
|
+
readonly icon: v.LooseObjectSchema<{
|
|
580
|
+
readonly name: v.StringSchema<undefined>;
|
|
581
|
+
readonly color: v.OptionalSchema<v.GenericSchema<import("../../icons.js").NotionIconColor>, undefined>;
|
|
582
|
+
}, undefined>;
|
|
583
|
+
}, undefined>, v.ObjectSchema<{
|
|
572
584
|
readonly type: v.LiteralSchema<"emoji", undefined>;
|
|
573
585
|
readonly emoji: v.StringSchema<undefined>;
|
|
574
586
|
}, undefined>, v.ObjectSchema<{
|
|
@@ -844,7 +856,13 @@ export declare const createPageResultMessageWithProtocol3To5CompatibilitySchema:
|
|
|
844
856
|
}, undefined>], undefined>, undefined>;
|
|
845
857
|
readonly created_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
846
858
|
readonly last_edited_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
847
|
-
readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.
|
|
859
|
+
readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.LooseObjectSchema<{
|
|
860
|
+
readonly type: v.LiteralSchema<"icon", undefined>;
|
|
861
|
+
readonly icon: v.LooseObjectSchema<{
|
|
862
|
+
readonly name: v.StringSchema<undefined>;
|
|
863
|
+
readonly color: v.OptionalSchema<v.GenericSchema<import("../../icons.js").NotionIconColor>, undefined>;
|
|
864
|
+
}, undefined>;
|
|
865
|
+
}, undefined>, v.ObjectSchema<{
|
|
848
866
|
readonly type: v.LiteralSchema<"emoji", undefined>;
|
|
849
867
|
readonly emoji: v.StringSchema<undefined>;
|
|
850
868
|
}, undefined>, v.ObjectSchema<{
|
|
@@ -1150,6 +1168,46 @@ export declare const createPageMessageSchema: v.VariantSchema<"type", [v.ObjectS
|
|
|
1150
1168
|
readonly type: v.LiteralSchema<"verification", undefined>;
|
|
1151
1169
|
readonly verification: v.StringSchema<undefined>;
|
|
1152
1170
|
}, undefined>], undefined>, undefined>;
|
|
1171
|
+
readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.LooseObjectSchema<{
|
|
1172
|
+
readonly type: v.LiteralSchema<"icon", undefined>;
|
|
1173
|
+
readonly icon: v.LooseObjectSchema<{
|
|
1174
|
+
readonly name: v.StringSchema<undefined>;
|
|
1175
|
+
readonly color: v.OptionalSchema<v.GenericSchema<import("../../icons.js").NotionIconColor>, undefined>;
|
|
1176
|
+
}, undefined>;
|
|
1177
|
+
}, undefined>, v.ObjectSchema<{
|
|
1178
|
+
readonly type: v.LiteralSchema<"emoji", undefined>;
|
|
1179
|
+
readonly emoji: v.StringSchema<undefined>;
|
|
1180
|
+
}, undefined>, v.ObjectSchema<{
|
|
1181
|
+
readonly type: v.LiteralSchema<"custom_emoji", undefined>;
|
|
1182
|
+
readonly custom_emoji: v.ObjectSchema<{
|
|
1183
|
+
readonly id: v.StringSchema<undefined>;
|
|
1184
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
1185
|
+
readonly url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
1186
|
+
}, undefined>;
|
|
1187
|
+
}, undefined>, v.ObjectSchema<{
|
|
1188
|
+
readonly type: v.LiteralSchema<"external", undefined>;
|
|
1189
|
+
readonly external: v.ObjectSchema<{
|
|
1190
|
+
readonly url: v.StringSchema<undefined>;
|
|
1191
|
+
}, undefined>;
|
|
1192
|
+
}, undefined>, v.ObjectSchema<{
|
|
1193
|
+
readonly type: v.LiteralSchema<"file", undefined>;
|
|
1194
|
+
readonly file: v.ObjectSchema<{
|
|
1195
|
+
readonly url: v.StringSchema<undefined>;
|
|
1196
|
+
readonly expiry_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
1197
|
+
}, undefined>;
|
|
1198
|
+
}, undefined>], undefined>, undefined>;
|
|
1199
|
+
readonly cover: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
|
|
1200
|
+
readonly type: v.LiteralSchema<"external", undefined>;
|
|
1201
|
+
readonly external: v.ObjectSchema<{
|
|
1202
|
+
readonly url: v.StringSchema<undefined>;
|
|
1203
|
+
}, undefined>;
|
|
1204
|
+
}, undefined>, v.ObjectSchema<{
|
|
1205
|
+
readonly type: v.LiteralSchema<"file", undefined>;
|
|
1206
|
+
readonly file: v.ObjectSchema<{
|
|
1207
|
+
readonly url: v.StringSchema<undefined>;
|
|
1208
|
+
readonly expiry_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
1209
|
+
}, undefined>;
|
|
1210
|
+
}, undefined>], undefined>, undefined>;
|
|
1153
1211
|
readonly parent: v.ObjectSchema<{
|
|
1154
1212
|
readonly type: v.LiteralSchema<"page_id", undefined>;
|
|
1155
1213
|
readonly page_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
|
|
@@ -1383,6 +1441,46 @@ export declare const createPageMessageSchema: v.VariantSchema<"type", [v.ObjectS
|
|
|
1383
1441
|
readonly type: v.LiteralSchema<"verification", undefined>;
|
|
1384
1442
|
readonly verification: v.StringSchema<undefined>;
|
|
1385
1443
|
}, undefined>], undefined>, undefined>;
|
|
1444
|
+
readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.LooseObjectSchema<{
|
|
1445
|
+
readonly type: v.LiteralSchema<"icon", undefined>;
|
|
1446
|
+
readonly icon: v.LooseObjectSchema<{
|
|
1447
|
+
readonly name: v.StringSchema<undefined>;
|
|
1448
|
+
readonly color: v.OptionalSchema<v.GenericSchema<import("../../icons.js").NotionIconColor>, undefined>;
|
|
1449
|
+
}, undefined>;
|
|
1450
|
+
}, undefined>, v.ObjectSchema<{
|
|
1451
|
+
readonly type: v.LiteralSchema<"emoji", undefined>;
|
|
1452
|
+
readonly emoji: v.StringSchema<undefined>;
|
|
1453
|
+
}, undefined>, v.ObjectSchema<{
|
|
1454
|
+
readonly type: v.LiteralSchema<"custom_emoji", undefined>;
|
|
1455
|
+
readonly custom_emoji: v.ObjectSchema<{
|
|
1456
|
+
readonly id: v.StringSchema<undefined>;
|
|
1457
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
1458
|
+
readonly url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
1459
|
+
}, undefined>;
|
|
1460
|
+
}, undefined>, v.ObjectSchema<{
|
|
1461
|
+
readonly type: v.LiteralSchema<"external", undefined>;
|
|
1462
|
+
readonly external: v.ObjectSchema<{
|
|
1463
|
+
readonly url: v.StringSchema<undefined>;
|
|
1464
|
+
}, undefined>;
|
|
1465
|
+
}, undefined>, v.ObjectSchema<{
|
|
1466
|
+
readonly type: v.LiteralSchema<"file", undefined>;
|
|
1467
|
+
readonly file: v.ObjectSchema<{
|
|
1468
|
+
readonly url: v.StringSchema<undefined>;
|
|
1469
|
+
readonly expiry_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
1470
|
+
}, undefined>;
|
|
1471
|
+
}, undefined>], undefined>, undefined>;
|
|
1472
|
+
readonly cover: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
|
|
1473
|
+
readonly type: v.LiteralSchema<"external", undefined>;
|
|
1474
|
+
readonly external: v.ObjectSchema<{
|
|
1475
|
+
readonly url: v.StringSchema<undefined>;
|
|
1476
|
+
}, undefined>;
|
|
1477
|
+
}, undefined>, v.ObjectSchema<{
|
|
1478
|
+
readonly type: v.LiteralSchema<"file", undefined>;
|
|
1479
|
+
readonly file: v.ObjectSchema<{
|
|
1480
|
+
readonly url: v.StringSchema<undefined>;
|
|
1481
|
+
readonly expiry_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
1482
|
+
}, undefined>;
|
|
1483
|
+
}, undefined>], undefined>, undefined>;
|
|
1386
1484
|
readonly parent: v.ObjectSchema<{
|
|
1387
1485
|
readonly type: v.LiteralSchema<"data_source_id", undefined>;
|
|
1388
1486
|
readonly data_source_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>;
|
|
@@ -3,6 +3,7 @@ import { bridgePageForProtocol3To5Schema } from "../../compatibility/protocol3To
|
|
|
3
3
|
import { dataSourceParentSchema, pageParentSchema, } from "../../context/parent.js";
|
|
4
4
|
import { notionBlockIdSchema } from "../../utils/ids.js";
|
|
5
5
|
import { bridgePageSchema } from "../bridgePage.js";
|
|
6
|
+
import { notionCreatePageIconSchema, notionPageCoverSchema, } from "../pageAppearance.js";
|
|
6
7
|
import { bridgePagePropertyWriteMapSchema } from "../properties/bridgePagePropertyMaps.js";
|
|
7
8
|
// The schema accepts any string code. The type lists known codes for
|
|
8
9
|
// autocomplete, with an open string fallback for newer senders.
|
|
@@ -74,7 +75,6 @@ export const createPageParentSchema = v.variant("type", [
|
|
|
74
75
|
]);
|
|
75
76
|
/**
|
|
76
77
|
* The sandbox sends this message to ask the host to create a page.
|
|
77
|
-
* The payload mirrors Notion's public `POST /v1/pages` API.
|
|
78
78
|
*/
|
|
79
79
|
const createPageMessageBaseSchema = {
|
|
80
80
|
type: v.literal("createPage"),
|
|
@@ -87,6 +87,8 @@ const createPageMessageBaseSchema = {
|
|
|
87
87
|
* those keys before it sends this message.
|
|
88
88
|
*/
|
|
89
89
|
properties: bridgePagePropertyWriteMapSchema,
|
|
90
|
+
icon: v.optional(notionCreatePageIconSchema),
|
|
91
|
+
cover: v.optional(notionPageCoverSchema),
|
|
90
92
|
};
|
|
91
93
|
// Use a variant so this parent-dependent union can be nested in
|
|
92
94
|
// sandboxToHostMessageSchema's type discriminator.
|
|
@@ -271,7 +271,13 @@ export declare const getPageResultMessageSchema: v.VariantSchema<"status", [v.Ob
|
|
|
271
271
|
readonly last_visited_time: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, null>;
|
|
272
272
|
readonly created_time: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, null>;
|
|
273
273
|
readonly last_edited_time: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, null>;
|
|
274
|
-
readonly icon: v.OptionalSchema<v.NullableSchema<v.VariantSchema<"type", [v.
|
|
274
|
+
readonly icon: v.OptionalSchema<v.NullableSchema<v.VariantSchema<"type", [v.LooseObjectSchema<{
|
|
275
|
+
readonly type: v.LiteralSchema<"icon", undefined>;
|
|
276
|
+
readonly icon: v.LooseObjectSchema<{
|
|
277
|
+
readonly name: v.StringSchema<undefined>;
|
|
278
|
+
readonly color: v.OptionalSchema<v.GenericSchema<import("../../icons.js").NotionIconColor>, undefined>;
|
|
279
|
+
}, undefined>;
|
|
280
|
+
}, undefined>, v.ObjectSchema<{
|
|
275
281
|
readonly type: v.LiteralSchema<"emoji", undefined>;
|
|
276
282
|
readonly emoji: v.StringSchema<undefined>;
|
|
277
283
|
}, undefined>, v.ObjectSchema<{
|
|
@@ -573,7 +579,13 @@ export declare const getPageResultMessageWithProtocol3To5CompatibilitySchema: v.
|
|
|
573
579
|
readonly last_visited_time: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, null>;
|
|
574
580
|
readonly created_time: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, null>;
|
|
575
581
|
readonly last_edited_time: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, null>;
|
|
576
|
-
readonly icon: v.OptionalSchema<v.NullableSchema<v.VariantSchema<"type", [v.
|
|
582
|
+
readonly icon: v.OptionalSchema<v.NullableSchema<v.VariantSchema<"type", [v.LooseObjectSchema<{
|
|
583
|
+
readonly type: v.LiteralSchema<"icon", undefined>;
|
|
584
|
+
readonly icon: v.LooseObjectSchema<{
|
|
585
|
+
readonly name: v.StringSchema<undefined>;
|
|
586
|
+
readonly color: v.OptionalSchema<v.GenericSchema<import("../../icons.js").NotionIconColor>, undefined>;
|
|
587
|
+
}, undefined>;
|
|
588
|
+
}, undefined>, v.ObjectSchema<{
|
|
577
589
|
readonly type: v.LiteralSchema<"emoji", undefined>;
|
|
578
590
|
readonly emoji: v.StringSchema<undefined>;
|
|
579
591
|
}, undefined>, v.ObjectSchema<{
|
|
@@ -849,7 +861,13 @@ export declare const getPageResultMessageWithProtocol3To5CompatibilitySchema: v.
|
|
|
849
861
|
}, undefined>], undefined>, undefined>;
|
|
850
862
|
readonly created_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
851
863
|
readonly last_edited_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
852
|
-
readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.
|
|
864
|
+
readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.LooseObjectSchema<{
|
|
865
|
+
readonly type: v.LiteralSchema<"icon", undefined>;
|
|
866
|
+
readonly icon: v.LooseObjectSchema<{
|
|
867
|
+
readonly name: v.StringSchema<undefined>;
|
|
868
|
+
readonly color: v.OptionalSchema<v.GenericSchema<import("../../icons.js").NotionIconColor>, undefined>;
|
|
869
|
+
}, undefined>;
|
|
870
|
+
}, undefined>, v.ObjectSchema<{
|
|
853
871
|
readonly type: v.LiteralSchema<"emoji", undefined>;
|
|
854
872
|
readonly emoji: v.StringSchema<undefined>;
|
|
855
873
|
}, undefined>, v.ObjectSchema<{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
import type { CustomBlockCapabilityErrorCode, CustomBlockErrorCode, CustomBlockErrorInfo, CustomBlockRequestErrorCode } from "../../utils/errors.js";
|
|
3
3
|
export declare const customBlockUpdatePageErrorCodeSchema: v.StringSchema<undefined>;
|
|
4
|
-
export type CustomBlockUpdatePageErrorCode = CustomBlockErrorCode<CustomBlockRequestErrorCode | "update_page_failed" | "previous_write_incomplete" | "invalid_page_update" | "page_unavailable" | "data_source_access_failed" | "unmapped_property" | "property_id_mismatch" | "duplicate_property" | "invalid_property_value" | CustomBlockCapabilityErrorCode>;
|
|
4
|
+
export type CustomBlockUpdatePageErrorCode = CustomBlockErrorCode<CustomBlockRequestErrorCode | "update_page_failed" | "previous_write_incomplete" | "invalid_page_update" | "invalid_icon_name" | "invalid_icon_color" | "page_unavailable" | "data_source_access_failed" | "unmapped_property" | "property_id_mismatch" | "duplicate_property" | "invalid_property_value" | CustomBlockCapabilityErrorCode>;
|
|
5
5
|
export type CustomBlockUpdatePageErrorInfo = CustomBlockErrorInfo<CustomBlockUpdatePageErrorCode>;
|
|
6
6
|
export declare const customBlockUpdatePageErrorInfoSchema: v.ObjectSchema<{
|
|
7
7
|
readonly code: v.StringSchema<undefined>;
|
|
@@ -264,7 +264,13 @@ export declare const updatePageResultMessageSchema: v.VariantSchema<"status", [v
|
|
|
264
264
|
readonly last_visited_time: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, null>;
|
|
265
265
|
readonly created_time: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, null>;
|
|
266
266
|
readonly last_edited_time: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, null>;
|
|
267
|
-
readonly icon: v.OptionalSchema<v.NullableSchema<v.VariantSchema<"type", [v.
|
|
267
|
+
readonly icon: v.OptionalSchema<v.NullableSchema<v.VariantSchema<"type", [v.LooseObjectSchema<{
|
|
268
|
+
readonly type: v.LiteralSchema<"icon", undefined>;
|
|
269
|
+
readonly icon: v.LooseObjectSchema<{
|
|
270
|
+
readonly name: v.StringSchema<undefined>;
|
|
271
|
+
readonly color: v.OptionalSchema<v.GenericSchema<import("../../icons.js").NotionIconColor>, undefined>;
|
|
272
|
+
}, undefined>;
|
|
273
|
+
}, undefined>, v.ObjectSchema<{
|
|
268
274
|
readonly type: v.LiteralSchema<"emoji", undefined>;
|
|
269
275
|
readonly emoji: v.StringSchema<undefined>;
|
|
270
276
|
}, undefined>, v.ObjectSchema<{
|
|
@@ -566,7 +572,13 @@ export declare const updatePageResultMessageWithProtocol3To5CompatibilitySchema:
|
|
|
566
572
|
readonly last_visited_time: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, null>;
|
|
567
573
|
readonly created_time: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, null>;
|
|
568
574
|
readonly last_edited_time: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, null>;
|
|
569
|
-
readonly icon: v.OptionalSchema<v.NullableSchema<v.VariantSchema<"type", [v.
|
|
575
|
+
readonly icon: v.OptionalSchema<v.NullableSchema<v.VariantSchema<"type", [v.LooseObjectSchema<{
|
|
576
|
+
readonly type: v.LiteralSchema<"icon", undefined>;
|
|
577
|
+
readonly icon: v.LooseObjectSchema<{
|
|
578
|
+
readonly name: v.StringSchema<undefined>;
|
|
579
|
+
readonly color: v.OptionalSchema<v.GenericSchema<import("../../icons.js").NotionIconColor>, undefined>;
|
|
580
|
+
}, undefined>;
|
|
581
|
+
}, undefined>, v.ObjectSchema<{
|
|
570
582
|
readonly type: v.LiteralSchema<"emoji", undefined>;
|
|
571
583
|
readonly emoji: v.StringSchema<undefined>;
|
|
572
584
|
}, undefined>, v.ObjectSchema<{
|
|
@@ -842,7 +854,13 @@ export declare const updatePageResultMessageWithProtocol3To5CompatibilitySchema:
|
|
|
842
854
|
}, undefined>], undefined>, undefined>;
|
|
843
855
|
readonly created_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
844
856
|
readonly last_edited_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
845
|
-
readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.
|
|
857
|
+
readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.LooseObjectSchema<{
|
|
858
|
+
readonly type: v.LiteralSchema<"icon", undefined>;
|
|
859
|
+
readonly icon: v.LooseObjectSchema<{
|
|
860
|
+
readonly name: v.StringSchema<undefined>;
|
|
861
|
+
readonly color: v.OptionalSchema<v.GenericSchema<import("../../icons.js").NotionIconColor>, undefined>;
|
|
862
|
+
}, undefined>;
|
|
863
|
+
}, undefined>, v.ObjectSchema<{
|
|
846
864
|
readonly type: v.LiteralSchema<"emoji", undefined>;
|
|
847
865
|
readonly emoji: v.StringSchema<undefined>;
|
|
848
866
|
}, undefined>, v.ObjectSchema<{
|
|
@@ -1123,7 +1141,13 @@ export declare const updatePageMessageSchema: v.ObjectSchema<{
|
|
|
1123
1141
|
readonly type: v.LiteralSchema<"verification", undefined>;
|
|
1124
1142
|
readonly verification: v.StringSchema<undefined>;
|
|
1125
1143
|
}, undefined>], undefined>, undefined>, undefined>;
|
|
1126
|
-
readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.
|
|
1144
|
+
readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.LooseObjectSchema<{
|
|
1145
|
+
readonly type: v.LiteralSchema<"icon", undefined>;
|
|
1146
|
+
readonly icon: v.LooseObjectSchema<{
|
|
1147
|
+
readonly name: v.StringSchema<undefined>;
|
|
1148
|
+
readonly color: v.OptionalSchema<v.GenericSchema<import("../../icons.js").NotionIconColor>, undefined>;
|
|
1149
|
+
}, undefined>;
|
|
1150
|
+
}, undefined>, v.ObjectSchema<{
|
|
1127
1151
|
readonly type: v.LiteralSchema<"emoji", undefined>;
|
|
1128
1152
|
readonly emoji: v.StringSchema<undefined>;
|
|
1129
1153
|
}, undefined>, v.ObjectSchema<{
|
|
@@ -24,7 +24,13 @@ export declare const notionHostedFileSchema: v.ObjectSchema<{
|
|
|
24
24
|
readonly expiry_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
25
25
|
}, undefined>;
|
|
26
26
|
}, undefined>;
|
|
27
|
-
export declare const notionPageIconSchema: v.VariantSchema<"type", [v.
|
|
27
|
+
export declare const notionPageIconSchema: v.VariantSchema<"type", [v.LooseObjectSchema<{
|
|
28
|
+
readonly type: v.LiteralSchema<"icon", undefined>;
|
|
29
|
+
readonly icon: v.LooseObjectSchema<{
|
|
30
|
+
readonly name: v.StringSchema<undefined>;
|
|
31
|
+
readonly color: v.OptionalSchema<v.GenericSchema<import("../icons.js").NotionIconColor>, undefined>;
|
|
32
|
+
}, undefined>;
|
|
33
|
+
}, undefined>, v.ObjectSchema<{
|
|
28
34
|
readonly type: v.LiteralSchema<"emoji", undefined>;
|
|
29
35
|
readonly emoji: v.StringSchema<undefined>;
|
|
30
36
|
}, undefined>, v.ObjectSchema<{
|
|
@@ -60,3 +66,32 @@ export declare const notionPageCoverSchema: v.VariantSchema<"type", [v.ObjectSch
|
|
|
60
66
|
}, undefined>;
|
|
61
67
|
}, undefined>], undefined>;
|
|
62
68
|
export type NotionPageCover = v.InferOutput<typeof notionPageCoverSchema>;
|
|
69
|
+
export declare const notionCreatePageIconSchema: v.VariantSchema<"type", [v.LooseObjectSchema<{
|
|
70
|
+
readonly type: v.LiteralSchema<"icon", undefined>;
|
|
71
|
+
readonly icon: v.LooseObjectSchema<{
|
|
72
|
+
readonly name: v.StringSchema<undefined>;
|
|
73
|
+
readonly color: v.OptionalSchema<v.GenericSchema<import("../icons.js").NotionIconColor>, undefined>;
|
|
74
|
+
}, undefined>;
|
|
75
|
+
}, undefined>, v.ObjectSchema<{
|
|
76
|
+
readonly type: v.LiteralSchema<"emoji", undefined>;
|
|
77
|
+
readonly emoji: v.StringSchema<undefined>;
|
|
78
|
+
}, undefined>, v.ObjectSchema<{
|
|
79
|
+
readonly type: v.LiteralSchema<"custom_emoji", undefined>;
|
|
80
|
+
readonly custom_emoji: v.ObjectSchema<{
|
|
81
|
+
readonly id: v.StringSchema<undefined>;
|
|
82
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
83
|
+
readonly url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
84
|
+
}, undefined>;
|
|
85
|
+
}, undefined>, v.ObjectSchema<{
|
|
86
|
+
readonly type: v.LiteralSchema<"external", undefined>;
|
|
87
|
+
readonly external: v.ObjectSchema<{
|
|
88
|
+
readonly url: v.StringSchema<undefined>;
|
|
89
|
+
}, undefined>;
|
|
90
|
+
}, undefined>, v.ObjectSchema<{
|
|
91
|
+
readonly type: v.LiteralSchema<"file", undefined>;
|
|
92
|
+
readonly file: v.ObjectSchema<{
|
|
93
|
+
readonly url: v.StringSchema<undefined>;
|
|
94
|
+
readonly expiry_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
95
|
+
}, undefined>;
|
|
96
|
+
}, undefined>], undefined>;
|
|
97
|
+
export type NotionCreatePageIcon = v.InferOutput<typeof notionCreatePageIconSchema>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
+
import { notionNativeIconSchema } from "../icons.js";
|
|
2
3
|
export const notionEmojiIconSchema = v.object({
|
|
3
4
|
type: v.literal("emoji"),
|
|
4
5
|
emoji: v.string(),
|
|
@@ -23,6 +24,7 @@ export const notionHostedFileSchema = v.object({
|
|
|
23
24
|
}),
|
|
24
25
|
});
|
|
25
26
|
export const notionPageIconSchema = v.variant("type", [
|
|
27
|
+
notionNativeIconSchema,
|
|
26
28
|
notionEmojiIconSchema,
|
|
27
29
|
notionCustomEmojiIconSchema,
|
|
28
30
|
notionExternalFileSchema,
|
|
@@ -32,3 +34,10 @@ export const notionPageCoverSchema = v.variant("type", [
|
|
|
32
34
|
notionExternalFileSchema,
|
|
33
35
|
notionHostedFileSchema,
|
|
34
36
|
]);
|
|
37
|
+
export const notionCreatePageIconSchema = v.variant("type", [
|
|
38
|
+
notionNativeIconSchema,
|
|
39
|
+
notionEmojiIconSchema,
|
|
40
|
+
notionCustomEmojiIconSchema,
|
|
41
|
+
notionExternalFileSchema,
|
|
42
|
+
notionHostedFileSchema,
|
|
43
|
+
]);
|
|
@@ -3,6 +3,7 @@
|
|
|
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 =
|
|
6
|
+
export declare const LATEST_BRIDGE_PROTOCOL_VERSION = 9;
|
|
7
7
|
export declare const UNIFIED_PAGE_PROTOCOL_VERSION = 6;
|
|
8
8
|
export declare const TEXT_FALLBACK_PROPERTY_PROTOCOL_VERSION = 7;
|
|
9
|
+
export declare const NATIVE_ICON_PROTOCOL_VERSION = 9;
|
|
@@ -3,9 +3,11 @@
|
|
|
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 =
|
|
6
|
+
export const LATEST_BRIDGE_PROTOCOL_VERSION = 9;
|
|
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
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;
|
|
12
|
+
// Protocol 9 adds native icon responses and writes throughout the page API.
|
|
13
|
+
export const NATIVE_ICON_PROTOCOL_VERSION = 9;
|
package/docs/bridge/changelog.md
CHANGED
|
@@ -20,10 +20,22 @@ versions refer to `@notionhq/custom-blocks`.
|
|
|
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
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
|
+
| 9 | Unreleased | — | Native page icons; older protocols receive external SVG URLs |
|
|
23
24
|
|
|
24
25
|
The table lists SDK release boundaries, not complete supported version ranges. Host compatibility
|
|
25
26
|
depends on `connect.bridgeProtocolVersion`, not the SDK package version.
|
|
26
27
|
|
|
28
|
+
## Protocol 9: native page icons
|
|
29
|
+
|
|
30
|
+
Page operations and query results can return `{ type: "icon", icon: { name, color } }`. Reads and
|
|
31
|
+
writes share a loose shape: names and colors accept strings, color is optional, and additional
|
|
32
|
+
native icon fields are retained. Hosts resolve names and default omitted colors to gray.
|
|
33
|
+
|
|
34
|
+
Protocols 3–8 receive external SVG URLs in page operation results. Protocols 6–8 receive the same
|
|
35
|
+
fallback in query results; protocols 3–5 keep their flat query format without appearance fields. The
|
|
36
|
+
released-SDK compatibility corpus exercises these conversions. Add a frozen protocol-9 reader after
|
|
37
|
+
the SDK release is published.
|
|
38
|
+
|
|
27
39
|
## Protocol 8: local manifest declarations
|
|
28
40
|
|
|
29
41
|
The dev shell removes the `/manifest` route and embeds the local manifest in block HTML. The SDK
|
package/docs/bridge/protocol.md
CHANGED
|
@@ -220,3 +220,14 @@ or `""` when absent. Hosts do not evaluate formulas or rollups.
|
|
|
220
220
|
The host converts responses to the sandbox's declared protocol. See
|
|
221
221
|
[versioning and compatibility](versioning.md) for protocol version rules. The host's
|
|
222
222
|
[compatibility reference](../compatibility.md) describes older response formats.
|
|
223
|
+
|
|
224
|
+
### Native page icon compatibility
|
|
225
|
+
|
|
226
|
+
Protocol 9 and later use native icon objects. Protocols 3–8 receive external SVG URLs in page
|
|
227
|
+
operation results. Unified query results in protocols 6–8 also use external SVG URLs; flat query
|
|
228
|
+
results in protocols 3–5 omit icon fields. Native colors accept any string in responses and write
|
|
229
|
+
inputs, so newer host colors do not require an SDK update.
|
|
230
|
+
|
|
231
|
+
`createPage` accepts native icons, emoji, custom emoji, and URL-backed icons and covers. The
|
|
232
|
+
application adapter checks submitted image URLs against the block's network permissions before
|
|
233
|
+
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
|
|
package/docs/compatibility.md
CHANGED
|
@@ -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
|
|
19
|
+
The current SDK declares protocol 9. 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
|
|
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
|
package/package.json
CHANGED
|
@@ -3,12 +3,14 @@ import type {
|
|
|
3
3
|
HostToSandboxMessageWithProtocol3To5Compatibility,
|
|
4
4
|
} from "@notionhq/custom-blocks-protocol/messages/hostToSandbox.js"
|
|
5
5
|
import {
|
|
6
|
+
NATIVE_ICON_PROTOCOL_VERSION,
|
|
6
7
|
TEXT_FALLBACK_PROPERTY_PROTOCOL_VERSION,
|
|
7
8
|
UNIFIED_PAGE_PROTOCOL_VERSION,
|
|
8
9
|
} from "@notionhq/custom-blocks-protocol/utils/protocolVersion.js"
|
|
9
10
|
import { addMetadataReadSchemasForProtocol3To4 } from "./protocol3To4/addMetadataReadSchemasForProtocol3To4.js"
|
|
10
11
|
import { normalizePageResultsForProtocol3To5 } from "./protocol3To5/normalizePageResultsForProtocol3To5.js"
|
|
11
12
|
import { normalizePageResultsForProtocol6 } from "./protocol6/normalizePageResultsForProtocol6.js"
|
|
13
|
+
import { normalizePageResultsForProtocol7To8 } from "./protocol7To8/normalizePageResultsForProtocol7To8.js"
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* Encodes current host messages for the sandbox's declared protocol. Handlers use
|
|
@@ -50,5 +52,8 @@ export function normalizeHostToSandboxMessage(
|
|
|
50
52
|
if (bridgeProtocolVersion < TEXT_FALLBACK_PROPERTY_PROTOCOL_VERSION) {
|
|
51
53
|
return normalizePageResultsForProtocol6(message)
|
|
52
54
|
}
|
|
55
|
+
if (bridgeProtocolVersion < NATIVE_ICON_PROTOCOL_VERSION) {
|
|
56
|
+
return normalizePageResultsForProtocol7To8(message)
|
|
57
|
+
}
|
|
53
58
|
return message
|
|
54
59
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { NotionPageIcon } from "@notionhq/custom-blocks-protocol/pages/pageAppearance.js"
|
|
2
|
+
|
|
3
|
+
/** Converts native icons for legacy receivers. Delete when the runtime minimum reaches 9. */
|
|
4
|
+
export function toIconForProtocol3To8(
|
|
5
|
+
icon: NotionPageIcon | null,
|
|
6
|
+
): NotionPageIcon | null {
|
|
7
|
+
if (icon?.type !== "icon") {
|
|
8
|
+
return icon
|
|
9
|
+
}
|
|
10
|
+
const { name, color } = icon.icon
|
|
11
|
+
return {
|
|
12
|
+
type: "external",
|
|
13
|
+
external: {
|
|
14
|
+
url: `https://www.notion.so/icons/${name}_${color ?? "gray"}.svg`,
|
|
15
|
+
},
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { BridgePageForProtocol3To5 } from "@notionhq/custom-blocks-protocol/compatibility/protocol3To5/bridgePage.js"
|
|
2
2
|
import type { BridgePage } from "@notionhq/custom-blocks-protocol/pages/bridgePage.js"
|
|
3
|
+
import { toIconForProtocol3To8 } from "../pages/toIconForProtocol3To8.js"
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Converts current page data to the page-operation format used by protocols 3–5.
|
|
@@ -19,7 +20,7 @@ export function toPageForProtocol3To5(
|
|
|
19
20
|
property ? [[property.id, property]] : [],
|
|
20
21
|
),
|
|
21
22
|
),
|
|
22
|
-
icon: page.icon ?? undefined,
|
|
23
|
+
icon: toIconForProtocol3To8(page.icon) ?? undefined,
|
|
23
24
|
cover: page.cover ?? undefined,
|
|
24
25
|
created_time: page.created_time ?? undefined,
|
|
25
26
|
last_edited_time: page.last_edited_time ?? undefined,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { HostToSandboxMessage } from "@notionhq/custom-blocks-protocol/messages/hostToSandbox.js"
|
|
2
|
+
import type { BridgePage } from "@notionhq/custom-blocks-protocol/pages/bridgePage.js"
|
|
2
3
|
import type { SuccessfulPageResult } from "../pages/pageResult.js"
|
|
4
|
+
import { toIconForProtocol3To8 } from "../pages/toIconForProtocol3To8.js"
|
|
3
5
|
import { toPageWithNullTextFallbackProperties } from "../pages/toPageWithNullTextFallbackProperties.js"
|
|
4
6
|
|
|
5
7
|
/**
|
|
@@ -13,11 +15,18 @@ export function normalizePageResultsForProtocol6(
|
|
|
13
15
|
if (message.type === "queryDataSourceResult") {
|
|
14
16
|
return {
|
|
15
17
|
...message,
|
|
16
|
-
items: message.items.map(
|
|
18
|
+
items: message.items.map(toPageForProtocol6),
|
|
17
19
|
}
|
|
18
20
|
}
|
|
19
21
|
return {
|
|
20
22
|
...message,
|
|
21
|
-
page:
|
|
23
|
+
page: toPageForProtocol6(message.page),
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function toPageForProtocol6(page: BridgePage): BridgePage {
|
|
28
|
+
return {
|
|
29
|
+
...toPageWithNullTextFallbackProperties(page),
|
|
30
|
+
icon: toIconForProtocol3To8(page.icon),
|
|
22
31
|
}
|
|
23
32
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { BridgePage } from "@notionhq/custom-blocks-protocol/pages/bridgePage.js"
|
|
2
|
+
import type { SuccessfulPageResult } from "../pages/pageResult.js"
|
|
3
|
+
import { toIconForProtocol3To8 } from "../pages/toIconForProtocol3To8.js"
|
|
4
|
+
|
|
5
|
+
/** Encodes icons for protocols 7–8. Delete when the runtime minimum reaches 9. */
|
|
6
|
+
export function normalizePageResultsForProtocol7To8(
|
|
7
|
+
message: SuccessfulPageResult,
|
|
8
|
+
): SuccessfulPageResult {
|
|
9
|
+
if (message.type === "queryDataSourceResult") {
|
|
10
|
+
if (!message.items.some(page => page.icon?.type === "icon")) {
|
|
11
|
+
return message
|
|
12
|
+
}
|
|
13
|
+
return { ...message, items: message.items.map(toPageWithoutNativeIcon) }
|
|
14
|
+
}
|
|
15
|
+
const page = toPageWithoutNativeIcon(message.page)
|
|
16
|
+
return page === message.page ? message : { ...message, page }
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function toPageWithoutNativeIcon(page: BridgePage): BridgePage {
|
|
20
|
+
const icon = toIconForProtocol3To8(page.icon)
|
|
21
|
+
return icon === page.icon ? page : { ...page, icon }
|
|
22
|
+
}
|
|
@@ -603,6 +603,7 @@ export function createCustomBlockHost(
|
|
|
603
603
|
getInitStatus: () => initializationController.status,
|
|
604
604
|
emit,
|
|
605
605
|
sendNack,
|
|
606
|
+
sendPageMutationError: postToSandbox,
|
|
606
607
|
onInvalidConnect: initializationController.handleInvalidConnect,
|
|
607
608
|
onInvalidInitResult: initializationController.handleInvalidInitResult,
|
|
608
609
|
onConnect: initializationController.handleConnect,
|