@notionhq/custom-blocks-host 0.3.7 → 0.3.11
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 +21 -10
- package/dist/browser.js +1 -1
- package/dist/lifecycle/legacyPage.js +12 -0
- package/dist/lifecycle/normalizeHostToSandboxMessage.d.ts +1 -1
- package/dist/lifecycle/normalizeHostToSandboxMessage.d.ts.map +1 -1
- package/dist/lifecycle/normalizeHostToSandboxMessage.js +1 -3
- package/dist/lifecycle/normalizePage.d.ts.map +1 -1
- package/dist/lifecycle/normalizePage.js +29 -4
- package/dist/protocol/messages/createPage.d.ts +24 -0
- package/dist/protocol/messages/createPageResult.d.ts +72 -0
- package/dist/protocol/messages/getPage.d.ts +72 -0
- package/dist/protocol/messages/hostToSandbox.d.ts +264 -0
- package/dist/protocol/messages/queryDataSourceResult.d.ts +48 -0
- package/dist/protocol/messages/sandboxToHost.d.ts +48 -0
- package/dist/protocol/messages/updatePage.d.ts +24 -0
- package/dist/protocol/messages/updatePageResult.d.ts +72 -0
- package/dist/protocol/pages/page.d.ts +120 -0
- package/dist/protocol/pages/page.js +30 -0
- package/dist/protocol/protocolVersion.d.ts +2 -1
- package/dist/protocol/protocolVersion.js +3 -1
- package/package.json +2 -2
- package/src/lifecycle/legacyPage.ts +12 -0
- package/src/lifecycle/normalizeHostToSandboxMessage.ts +1 -3
- package/src/lifecycle/normalizePage.ts +40 -4
|
@@ -226,6 +226,30 @@ export declare const updatePageResultMessageSchema: v.VariantSchema<"status", [v
|
|
|
226
226
|
readonly id: v.StringSchema<undefined>;
|
|
227
227
|
readonly type: v.LiteralSchema<"last_visited_time", undefined>;
|
|
228
228
|
readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
229
|
+
}, undefined>, v.ObjectSchema<{
|
|
230
|
+
readonly id: v.StringSchema<undefined>;
|
|
231
|
+
readonly type: v.LiteralSchema<"unique_id", undefined>;
|
|
232
|
+
readonly unique_id: v.StringSchema<undefined>;
|
|
233
|
+
}, undefined>, v.ObjectSchema<{
|
|
234
|
+
readonly id: v.StringSchema<undefined>;
|
|
235
|
+
readonly type: v.LiteralSchema<"button", undefined>;
|
|
236
|
+
readonly button: v.StringSchema<undefined>;
|
|
237
|
+
}, undefined>, v.ObjectSchema<{
|
|
238
|
+
readonly id: v.StringSchema<undefined>;
|
|
239
|
+
readonly type: v.LiteralSchema<"formula", undefined>;
|
|
240
|
+
readonly formula: v.StringSchema<undefined>;
|
|
241
|
+
}, undefined>, v.ObjectSchema<{
|
|
242
|
+
readonly id: v.StringSchema<undefined>;
|
|
243
|
+
readonly type: v.LiteralSchema<"location", undefined>;
|
|
244
|
+
readonly location: v.StringSchema<undefined>;
|
|
245
|
+
}, undefined>, v.ObjectSchema<{
|
|
246
|
+
readonly id: v.StringSchema<undefined>;
|
|
247
|
+
readonly type: v.LiteralSchema<"rollup", undefined>;
|
|
248
|
+
readonly rollup: v.StringSchema<undefined>;
|
|
249
|
+
}, undefined>, v.ObjectSchema<{
|
|
250
|
+
readonly id: v.StringSchema<undefined>;
|
|
251
|
+
readonly type: v.LiteralSchema<"verification", undefined>;
|
|
252
|
+
readonly verification: v.StringSchema<undefined>;
|
|
229
253
|
}, undefined>], undefined>, undefined>, undefined>;
|
|
230
254
|
readonly created_by: v.OptionalSchema<v.NullableSchema<v.ObjectSchema<{
|
|
231
255
|
readonly id: v.StringSchema<undefined>;
|
|
@@ -504,6 +528,30 @@ export declare const updatePageResultMessageLegacySchema: v.VariantSchema<"statu
|
|
|
504
528
|
readonly id: v.StringSchema<undefined>;
|
|
505
529
|
readonly type: v.LiteralSchema<"last_visited_time", undefined>;
|
|
506
530
|
readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
531
|
+
}, undefined>, v.ObjectSchema<{
|
|
532
|
+
readonly id: v.StringSchema<undefined>;
|
|
533
|
+
readonly type: v.LiteralSchema<"unique_id", undefined>;
|
|
534
|
+
readonly unique_id: v.StringSchema<undefined>;
|
|
535
|
+
}, undefined>, v.ObjectSchema<{
|
|
536
|
+
readonly id: v.StringSchema<undefined>;
|
|
537
|
+
readonly type: v.LiteralSchema<"button", undefined>;
|
|
538
|
+
readonly button: v.StringSchema<undefined>;
|
|
539
|
+
}, undefined>, v.ObjectSchema<{
|
|
540
|
+
readonly id: v.StringSchema<undefined>;
|
|
541
|
+
readonly type: v.LiteralSchema<"formula", undefined>;
|
|
542
|
+
readonly formula: v.StringSchema<undefined>;
|
|
543
|
+
}, undefined>, v.ObjectSchema<{
|
|
544
|
+
readonly id: v.StringSchema<undefined>;
|
|
545
|
+
readonly type: v.LiteralSchema<"location", undefined>;
|
|
546
|
+
readonly location: v.StringSchema<undefined>;
|
|
547
|
+
}, undefined>, v.ObjectSchema<{
|
|
548
|
+
readonly id: v.StringSchema<undefined>;
|
|
549
|
+
readonly type: v.LiteralSchema<"rollup", undefined>;
|
|
550
|
+
readonly rollup: v.StringSchema<undefined>;
|
|
551
|
+
}, undefined>, v.ObjectSchema<{
|
|
552
|
+
readonly id: v.StringSchema<undefined>;
|
|
553
|
+
readonly type: v.LiteralSchema<"verification", undefined>;
|
|
554
|
+
readonly verification: v.StringSchema<undefined>;
|
|
507
555
|
}, undefined>], undefined>, undefined>, undefined>;
|
|
508
556
|
readonly created_by: v.OptionalSchema<v.NullableSchema<v.ObjectSchema<{
|
|
509
557
|
readonly id: v.StringSchema<undefined>;
|
|
@@ -767,6 +815,30 @@ export declare const updatePageResultMessageLegacySchema: v.VariantSchema<"statu
|
|
|
767
815
|
readonly id: v.StringSchema<undefined>;
|
|
768
816
|
readonly type: v.LiteralSchema<"last_visited_time", undefined>;
|
|
769
817
|
readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
818
|
+
}, undefined>, v.ObjectSchema<{
|
|
819
|
+
readonly id: v.StringSchema<undefined>;
|
|
820
|
+
readonly type: v.LiteralSchema<"unique_id", undefined>;
|
|
821
|
+
readonly unique_id: v.StringSchema<undefined>;
|
|
822
|
+
}, undefined>, v.ObjectSchema<{
|
|
823
|
+
readonly id: v.StringSchema<undefined>;
|
|
824
|
+
readonly type: v.LiteralSchema<"button", undefined>;
|
|
825
|
+
readonly button: v.StringSchema<undefined>;
|
|
826
|
+
}, undefined>, v.ObjectSchema<{
|
|
827
|
+
readonly id: v.StringSchema<undefined>;
|
|
828
|
+
readonly type: v.LiteralSchema<"formula", undefined>;
|
|
829
|
+
readonly formula: v.StringSchema<undefined>;
|
|
830
|
+
}, undefined>, v.ObjectSchema<{
|
|
831
|
+
readonly id: v.StringSchema<undefined>;
|
|
832
|
+
readonly type: v.LiteralSchema<"location", undefined>;
|
|
833
|
+
readonly location: v.StringSchema<undefined>;
|
|
834
|
+
}, undefined>, v.ObjectSchema<{
|
|
835
|
+
readonly id: v.StringSchema<undefined>;
|
|
836
|
+
readonly type: v.LiteralSchema<"rollup", undefined>;
|
|
837
|
+
readonly rollup: v.StringSchema<undefined>;
|
|
838
|
+
}, undefined>, v.ObjectSchema<{
|
|
839
|
+
readonly id: v.StringSchema<undefined>;
|
|
840
|
+
readonly type: v.LiteralSchema<"verification", undefined>;
|
|
841
|
+
readonly verification: v.StringSchema<undefined>;
|
|
770
842
|
}, undefined>], undefined>, undefined>;
|
|
771
843
|
readonly created_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
772
844
|
readonly last_edited_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -387,6 +387,30 @@ export declare const notionPagePropertyValueSchema: v.VariantSchema<"type", [v.O
|
|
|
387
387
|
readonly id: v.StringSchema<undefined>;
|
|
388
388
|
readonly type: v.LiteralSchema<"last_visited_time", undefined>;
|
|
389
389
|
readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
390
|
+
}, undefined>, v.ObjectSchema<{
|
|
391
|
+
readonly id: v.StringSchema<undefined>;
|
|
392
|
+
readonly type: v.LiteralSchema<"unique_id", undefined>;
|
|
393
|
+
readonly unique_id: v.StringSchema<undefined>;
|
|
394
|
+
}, undefined>, v.ObjectSchema<{
|
|
395
|
+
readonly id: v.StringSchema<undefined>;
|
|
396
|
+
readonly type: v.LiteralSchema<"button", undefined>;
|
|
397
|
+
readonly button: v.StringSchema<undefined>;
|
|
398
|
+
}, undefined>, v.ObjectSchema<{
|
|
399
|
+
readonly id: v.StringSchema<undefined>;
|
|
400
|
+
readonly type: v.LiteralSchema<"formula", undefined>;
|
|
401
|
+
readonly formula: v.StringSchema<undefined>;
|
|
402
|
+
}, undefined>, v.ObjectSchema<{
|
|
403
|
+
readonly id: v.StringSchema<undefined>;
|
|
404
|
+
readonly type: v.LiteralSchema<"location", undefined>;
|
|
405
|
+
readonly location: v.StringSchema<undefined>;
|
|
406
|
+
}, undefined>, v.ObjectSchema<{
|
|
407
|
+
readonly id: v.StringSchema<undefined>;
|
|
408
|
+
readonly type: v.LiteralSchema<"rollup", undefined>;
|
|
409
|
+
readonly rollup: v.StringSchema<undefined>;
|
|
410
|
+
}, undefined>, v.ObjectSchema<{
|
|
411
|
+
readonly id: v.StringSchema<undefined>;
|
|
412
|
+
readonly type: v.LiteralSchema<"verification", undefined>;
|
|
413
|
+
readonly verification: v.StringSchema<undefined>;
|
|
390
414
|
}, undefined>], undefined>;
|
|
391
415
|
export type NotionPagePropertyValue = v.InferOutput<typeof notionPagePropertyValueSchema>;
|
|
392
416
|
export declare const notionPagePropertyWriteMapSchema: v.RecordSchema<v.StringSchema<undefined>, v.VariantSchema<"type", [v.ObjectSchema<{
|
|
@@ -579,6 +603,30 @@ export declare const notionPagePropertyWriteMapSchema: v.RecordSchema<v.StringSc
|
|
|
579
603
|
readonly id: v.StringSchema<undefined>;
|
|
580
604
|
readonly type: v.LiteralSchema<"last_visited_time", undefined>;
|
|
581
605
|
readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
606
|
+
}, undefined>, v.ObjectSchema<{
|
|
607
|
+
readonly id: v.StringSchema<undefined>;
|
|
608
|
+
readonly type: v.LiteralSchema<"unique_id", undefined>;
|
|
609
|
+
readonly unique_id: v.StringSchema<undefined>;
|
|
610
|
+
}, undefined>, v.ObjectSchema<{
|
|
611
|
+
readonly id: v.StringSchema<undefined>;
|
|
612
|
+
readonly type: v.LiteralSchema<"button", undefined>;
|
|
613
|
+
readonly button: v.StringSchema<undefined>;
|
|
614
|
+
}, undefined>, v.ObjectSchema<{
|
|
615
|
+
readonly id: v.StringSchema<undefined>;
|
|
616
|
+
readonly type: v.LiteralSchema<"formula", undefined>;
|
|
617
|
+
readonly formula: v.StringSchema<undefined>;
|
|
618
|
+
}, undefined>, v.ObjectSchema<{
|
|
619
|
+
readonly id: v.StringSchema<undefined>;
|
|
620
|
+
readonly type: v.LiteralSchema<"location", undefined>;
|
|
621
|
+
readonly location: v.StringSchema<undefined>;
|
|
622
|
+
}, undefined>, v.ObjectSchema<{
|
|
623
|
+
readonly id: v.StringSchema<undefined>;
|
|
624
|
+
readonly type: v.LiteralSchema<"rollup", undefined>;
|
|
625
|
+
readonly rollup: v.StringSchema<undefined>;
|
|
626
|
+
}, undefined>, v.ObjectSchema<{
|
|
627
|
+
readonly id: v.StringSchema<undefined>;
|
|
628
|
+
readonly type: v.LiteralSchema<"verification", undefined>;
|
|
629
|
+
readonly verification: v.StringSchema<undefined>;
|
|
582
630
|
}, undefined>], undefined>, undefined>;
|
|
583
631
|
export declare const notionPagePropertyReadMapSchema: v.RecordSchema<v.StringSchema<undefined>, v.NullableSchema<v.VariantSchema<"type", [v.ObjectSchema<{
|
|
584
632
|
readonly id: v.StringSchema<undefined>;
|
|
@@ -770,6 +818,30 @@ export declare const notionPagePropertyReadMapSchema: v.RecordSchema<v.StringSch
|
|
|
770
818
|
readonly id: v.StringSchema<undefined>;
|
|
771
819
|
readonly type: v.LiteralSchema<"last_visited_time", undefined>;
|
|
772
820
|
readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
821
|
+
}, undefined>, v.ObjectSchema<{
|
|
822
|
+
readonly id: v.StringSchema<undefined>;
|
|
823
|
+
readonly type: v.LiteralSchema<"unique_id", undefined>;
|
|
824
|
+
readonly unique_id: v.StringSchema<undefined>;
|
|
825
|
+
}, undefined>, v.ObjectSchema<{
|
|
826
|
+
readonly id: v.StringSchema<undefined>;
|
|
827
|
+
readonly type: v.LiteralSchema<"button", undefined>;
|
|
828
|
+
readonly button: v.StringSchema<undefined>;
|
|
829
|
+
}, undefined>, v.ObjectSchema<{
|
|
830
|
+
readonly id: v.StringSchema<undefined>;
|
|
831
|
+
readonly type: v.LiteralSchema<"formula", undefined>;
|
|
832
|
+
readonly formula: v.StringSchema<undefined>;
|
|
833
|
+
}, undefined>, v.ObjectSchema<{
|
|
834
|
+
readonly id: v.StringSchema<undefined>;
|
|
835
|
+
readonly type: v.LiteralSchema<"location", undefined>;
|
|
836
|
+
readonly location: v.StringSchema<undefined>;
|
|
837
|
+
}, undefined>, v.ObjectSchema<{
|
|
838
|
+
readonly id: v.StringSchema<undefined>;
|
|
839
|
+
readonly type: v.LiteralSchema<"rollup", undefined>;
|
|
840
|
+
readonly rollup: v.StringSchema<undefined>;
|
|
841
|
+
}, undefined>, v.ObjectSchema<{
|
|
842
|
+
readonly id: v.StringSchema<undefined>;
|
|
843
|
+
readonly type: v.LiteralSchema<"verification", undefined>;
|
|
844
|
+
readonly verification: v.StringSchema<undefined>;
|
|
773
845
|
}, undefined>], undefined>, undefined>, undefined>;
|
|
774
846
|
export type NotionPagePropertyReadMap = v.InferOutput<typeof notionPagePropertyReadMapSchema>;
|
|
775
847
|
export type NotionPagePropertyWriteMap = v.InferInput<typeof notionPagePropertyWriteMapSchema>;
|
|
@@ -987,6 +1059,30 @@ export declare const notionPageDataSchema: v.ObjectSchema<{
|
|
|
987
1059
|
readonly id: v.StringSchema<undefined>;
|
|
988
1060
|
readonly type: v.LiteralSchema<"last_visited_time", undefined>;
|
|
989
1061
|
readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
1062
|
+
}, undefined>, v.ObjectSchema<{
|
|
1063
|
+
readonly id: v.StringSchema<undefined>;
|
|
1064
|
+
readonly type: v.LiteralSchema<"unique_id", undefined>;
|
|
1065
|
+
readonly unique_id: v.StringSchema<undefined>;
|
|
1066
|
+
}, undefined>, v.ObjectSchema<{
|
|
1067
|
+
readonly id: v.StringSchema<undefined>;
|
|
1068
|
+
readonly type: v.LiteralSchema<"button", undefined>;
|
|
1069
|
+
readonly button: v.StringSchema<undefined>;
|
|
1070
|
+
}, undefined>, v.ObjectSchema<{
|
|
1071
|
+
readonly id: v.StringSchema<undefined>;
|
|
1072
|
+
readonly type: v.LiteralSchema<"formula", undefined>;
|
|
1073
|
+
readonly formula: v.StringSchema<undefined>;
|
|
1074
|
+
}, undefined>, v.ObjectSchema<{
|
|
1075
|
+
readonly id: v.StringSchema<undefined>;
|
|
1076
|
+
readonly type: v.LiteralSchema<"location", undefined>;
|
|
1077
|
+
readonly location: v.StringSchema<undefined>;
|
|
1078
|
+
}, undefined>, v.ObjectSchema<{
|
|
1079
|
+
readonly id: v.StringSchema<undefined>;
|
|
1080
|
+
readonly type: v.LiteralSchema<"rollup", undefined>;
|
|
1081
|
+
readonly rollup: v.StringSchema<undefined>;
|
|
1082
|
+
}, undefined>, v.ObjectSchema<{
|
|
1083
|
+
readonly id: v.StringSchema<undefined>;
|
|
1084
|
+
readonly type: v.LiteralSchema<"verification", undefined>;
|
|
1085
|
+
readonly verification: v.StringSchema<undefined>;
|
|
990
1086
|
}, undefined>], undefined>, undefined>, undefined>;
|
|
991
1087
|
readonly created_by: v.OptionalSchema<v.NullableSchema<v.ObjectSchema<{
|
|
992
1088
|
readonly id: v.StringSchema<undefined>;
|
|
@@ -1254,6 +1350,30 @@ export declare const legacyNotionPageSchema: v.ObjectSchema<{
|
|
|
1254
1350
|
readonly id: v.StringSchema<undefined>;
|
|
1255
1351
|
readonly type: v.LiteralSchema<"last_visited_time", undefined>;
|
|
1256
1352
|
readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
1353
|
+
}, undefined>, v.ObjectSchema<{
|
|
1354
|
+
readonly id: v.StringSchema<undefined>;
|
|
1355
|
+
readonly type: v.LiteralSchema<"unique_id", undefined>;
|
|
1356
|
+
readonly unique_id: v.StringSchema<undefined>;
|
|
1357
|
+
}, undefined>, v.ObjectSchema<{
|
|
1358
|
+
readonly id: v.StringSchema<undefined>;
|
|
1359
|
+
readonly type: v.LiteralSchema<"button", undefined>;
|
|
1360
|
+
readonly button: v.StringSchema<undefined>;
|
|
1361
|
+
}, undefined>, v.ObjectSchema<{
|
|
1362
|
+
readonly id: v.StringSchema<undefined>;
|
|
1363
|
+
readonly type: v.LiteralSchema<"formula", undefined>;
|
|
1364
|
+
readonly formula: v.StringSchema<undefined>;
|
|
1365
|
+
}, undefined>, v.ObjectSchema<{
|
|
1366
|
+
readonly id: v.StringSchema<undefined>;
|
|
1367
|
+
readonly type: v.LiteralSchema<"location", undefined>;
|
|
1368
|
+
readonly location: v.StringSchema<undefined>;
|
|
1369
|
+
}, undefined>, v.ObjectSchema<{
|
|
1370
|
+
readonly id: v.StringSchema<undefined>;
|
|
1371
|
+
readonly type: v.LiteralSchema<"rollup", undefined>;
|
|
1372
|
+
readonly rollup: v.StringSchema<undefined>;
|
|
1373
|
+
}, undefined>, v.ObjectSchema<{
|
|
1374
|
+
readonly id: v.StringSchema<undefined>;
|
|
1375
|
+
readonly type: v.LiteralSchema<"verification", undefined>;
|
|
1376
|
+
readonly verification: v.StringSchema<undefined>;
|
|
1257
1377
|
}, undefined>], undefined>, undefined>;
|
|
1258
1378
|
readonly created_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
1259
1379
|
readonly last_edited_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -245,6 +245,36 @@ export const notionPagePropertyValueSchema = v.variant("type", [
|
|
|
245
245
|
type: v.literal("last_visited_time"),
|
|
246
246
|
last_visited_time: nullableStringSchema,
|
|
247
247
|
}),
|
|
248
|
+
v.object({
|
|
249
|
+
...pagePropertyBaseSchema,
|
|
250
|
+
type: v.literal("unique_id"),
|
|
251
|
+
unique_id: v.string(),
|
|
252
|
+
}),
|
|
253
|
+
v.object({
|
|
254
|
+
...pagePropertyBaseSchema,
|
|
255
|
+
type: v.literal("button"),
|
|
256
|
+
button: v.string(),
|
|
257
|
+
}),
|
|
258
|
+
v.object({
|
|
259
|
+
...pagePropertyBaseSchema,
|
|
260
|
+
type: v.literal("formula"),
|
|
261
|
+
formula: v.string(),
|
|
262
|
+
}),
|
|
263
|
+
v.object({
|
|
264
|
+
...pagePropertyBaseSchema,
|
|
265
|
+
type: v.literal("location"),
|
|
266
|
+
location: v.string(),
|
|
267
|
+
}),
|
|
268
|
+
v.object({
|
|
269
|
+
...pagePropertyBaseSchema,
|
|
270
|
+
type: v.literal("rollup"),
|
|
271
|
+
rollup: v.string(),
|
|
272
|
+
}),
|
|
273
|
+
v.object({
|
|
274
|
+
...pagePropertyBaseSchema,
|
|
275
|
+
type: v.literal("verification"),
|
|
276
|
+
verification: v.string(),
|
|
277
|
+
}),
|
|
248
278
|
]);
|
|
249
279
|
export const notionPagePropertyWriteMapSchema = v.record(v.string(), notionPagePropertyValueSchema);
|
|
250
280
|
export const notionPagePropertyReadMapSchema = v.record(v.string(), v.nullable(notionPagePropertyValueSchema));
|
|
@@ -3,5 +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 =
|
|
6
|
+
export declare const LATEST_BRIDGE_PROTOCOL_VERSION = 7;
|
|
7
7
|
export declare const LEGACY_PROPERTY_SHAPE_PROTOCOL_VERSION = 6;
|
|
8
|
+
export declare const TEXT_FALLBACK_PROPERTY_PROTOCOL_VERSION = 7;
|
|
@@ -3,7 +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 =
|
|
6
|
+
export const LATEST_BRIDGE_PROTOCOL_VERSION = 7;
|
|
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 LEGACY_PROPERTY_SHAPE_PROTOCOL_VERSION = 6;
|
|
10
|
+
// Protocol 7 adds typed text fallbacks for previously unsupported page properties.
|
|
11
|
+
export const TEXT_FALLBACK_PROPERTY_PROTOCOL_VERSION = 7;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@notionhq/custom-blocks-host",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.11",
|
|
4
4
|
"description": "Reusable host runtime for Notion custom blocks.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"valibot": "^1.
|
|
20
|
+
"valibot": "^1.5.0"
|
|
21
21
|
},
|
|
22
22
|
"files": [
|
|
23
23
|
"src",
|
|
@@ -119,6 +119,18 @@ function toLegacyProperty(
|
|
|
119
119
|
return property.relation.map(page => ({ id: page.id, table: "block" }))
|
|
120
120
|
case "files":
|
|
121
121
|
return property.files.map(file => file.name).join(",")
|
|
122
|
+
case "unique_id":
|
|
123
|
+
return property.unique_id
|
|
124
|
+
case "button":
|
|
125
|
+
return property.button
|
|
126
|
+
case "formula":
|
|
127
|
+
return property.formula
|
|
128
|
+
case "location":
|
|
129
|
+
return property.location
|
|
130
|
+
case "rollup":
|
|
131
|
+
return property.rollup
|
|
132
|
+
case "verification":
|
|
133
|
+
return property.verification
|
|
122
134
|
case "place":
|
|
123
135
|
return ""
|
|
124
136
|
case "created_time":
|
|
@@ -5,10 +5,8 @@ import type {
|
|
|
5
5
|
import { normalizeToLegacyPage } from "./normalizePage.js"
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Normalizes
|
|
8
|
+
* Normalizes outgoing page shapes for the sandbox's bridge protocol version.
|
|
9
9
|
*/
|
|
10
|
-
// TODO(custom-blocks): Remove this function when MIN_HOST_SUPPORTED_BRIDGE_PROTOCOL_VERSION
|
|
11
|
-
// reaches 6.
|
|
12
10
|
export function normalizeHostToSandboxMessage(
|
|
13
11
|
message: HostToSandboxMessage,
|
|
14
12
|
bridgeProtocolVersion: number,
|
|
@@ -3,7 +3,12 @@ import type { GetPageResultMessage } from "@notionhq/custom-blocks-protocol/mess
|
|
|
3
3
|
import type { HostToSandboxMessageLegacy } from "@notionhq/custom-blocks-protocol/messages/hostToSandbox.js"
|
|
4
4
|
import type { QueryDataSourceResultMessage } from "@notionhq/custom-blocks-protocol/messages/queryDataSourceResult.js"
|
|
5
5
|
import type { UpdatePageResultMessage } from "@notionhq/custom-blocks-protocol/messages/updatePageResult.js"
|
|
6
|
-
import {
|
|
6
|
+
import type { notionPageDataSchema } from "@notionhq/custom-blocks-protocol/pages/page.js"
|
|
7
|
+
import {
|
|
8
|
+
LEGACY_PROPERTY_SHAPE_PROTOCOL_VERSION,
|
|
9
|
+
TEXT_FALLBACK_PROPERTY_PROTOCOL_VERSION,
|
|
10
|
+
} from "@notionhq/custom-blocks-protocol/protocolVersion.js"
|
|
11
|
+
import type { InferOutput } from "valibot"
|
|
7
12
|
import { unreachable } from "../utils.js"
|
|
8
13
|
import { toLegacyPage, toLegacyQueryPage } from "./legacyPage.js"
|
|
9
14
|
|
|
@@ -15,8 +20,7 @@ export function normalizeToLegacyPage(
|
|
|
15
20
|
| QueryDataSourceResultMessage,
|
|
16
21
|
bridgeProtocolVersion: number,
|
|
17
22
|
): HostToSandboxMessageLegacy {
|
|
18
|
-
|
|
19
|
-
if (bridgeProtocolVersion >= LEGACY_PROPERTY_SHAPE_PROTOCOL_VERSION) {
|
|
23
|
+
if (bridgeProtocolVersion >= TEXT_FALLBACK_PROPERTY_PROTOCOL_VERSION) {
|
|
20
24
|
return message
|
|
21
25
|
}
|
|
22
26
|
if (message.status === "error") {
|
|
@@ -24,12 +28,44 @@ export function normalizeToLegacyPage(
|
|
|
24
28
|
}
|
|
25
29
|
switch (message.type) {
|
|
26
30
|
case "queryDataSourceResult":
|
|
31
|
+
if (bridgeProtocolVersion >= LEGACY_PROPERTY_SHAPE_PROTOCOL_VERSION) {
|
|
32
|
+
return { ...message, items: message.items.map(toPreFallbackPage) }
|
|
33
|
+
}
|
|
27
34
|
return { ...message, items: message.items.map(toLegacyQueryPage) }
|
|
28
35
|
case "getPageResult":
|
|
29
36
|
case "createPageResult":
|
|
30
37
|
case "updatePageResult":
|
|
31
|
-
return {
|
|
38
|
+
return {
|
|
39
|
+
...message,
|
|
40
|
+
page:
|
|
41
|
+
bridgeProtocolVersion >= LEGACY_PROPERTY_SHAPE_PROTOCOL_VERSION
|
|
42
|
+
? toPreFallbackPage(message.page)
|
|
43
|
+
: toLegacyPage(toPreFallbackPage(message.page)),
|
|
44
|
+
}
|
|
32
45
|
default:
|
|
33
46
|
return unreachable(message)
|
|
34
47
|
}
|
|
35
48
|
}
|
|
49
|
+
|
|
50
|
+
function toPreFallbackPage(
|
|
51
|
+
page: InferOutput<typeof notionPageDataSchema>,
|
|
52
|
+
): InferOutput<typeof notionPageDataSchema> {
|
|
53
|
+
return {
|
|
54
|
+
...page,
|
|
55
|
+
properties: Object.fromEntries(
|
|
56
|
+
Object.entries(page.properties).map(([name, property]) => {
|
|
57
|
+
switch (property?.type) {
|
|
58
|
+
case "unique_id":
|
|
59
|
+
case "button":
|
|
60
|
+
case "formula":
|
|
61
|
+
case "location":
|
|
62
|
+
case "rollup":
|
|
63
|
+
case "verification":
|
|
64
|
+
return [name, null]
|
|
65
|
+
default:
|
|
66
|
+
return [name, property]
|
|
67
|
+
}
|
|
68
|
+
}),
|
|
69
|
+
),
|
|
70
|
+
}
|
|
71
|
+
}
|