@notionhq/custom-blocks-host 0.3.5 → 0.3.6
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/browser.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/lifecycle/legacyPage.d.ts +4 -2
- package/dist/lifecycle/legacyPage.d.ts.map +1 -1
- package/dist/lifecycle/legacyPage.js +12 -0
- package/dist/lifecycle/normalizeHostToSandboxMessage.d.ts.map +1 -1
- package/dist/lifecycle/normalizeHostToSandboxMessage.js +8 -2
- package/dist/lifecycle/normalizePage.d.ts +7 -0
- package/dist/lifecycle/normalizePage.d.ts.map +1 -0
- package/dist/lifecycle/normalizePage.js +22 -0
- package/dist/messages/types.d.ts +1 -2
- package/dist/messages/types.d.ts.map +1 -1
- package/dist/protocol/dataSources/dataSourcePage.d.ts +0 -160
- package/dist/protocol/dataSources/dataSourcePage.js +0 -7
- package/dist/protocol/messages/createPage.js +2 -2
- package/dist/protocol/messages/createPageResult.d.ts +468 -1
- package/dist/protocol/messages/createPageResult.js +17 -2
- package/dist/protocol/messages/getPage.d.ts +468 -1
- package/dist/protocol/messages/getPage.js +18 -3
- package/dist/protocol/messages/hostToSandbox.d.ts +1172 -328
- package/dist/protocol/messages/hostToSandbox.js +9 -6
- package/dist/protocol/messages/queryDataSourceResult.d.ts +142 -6
- package/dist/protocol/messages/queryDataSourceResult.js +4 -6
- package/dist/protocol/messages/sandboxToHost.d.ts +2 -0
- package/dist/protocol/messages/updatePage.d.ts +1 -0
- package/dist/protocol/messages/updatePage.js +4 -3
- package/dist/protocol/messages/updatePageResult.d.ts +467 -1
- package/dist/protocol/messages/updatePageResult.js +16 -2
- package/dist/protocol/pages/page.d.ts +386 -6
- package/dist/protocol/pages/page.js +23 -2
- package/dist/protocol/protocolVersion.js +1 -1
- package/package.json +1 -1
- package/src/index.ts +2 -4
- package/src/lifecycle/legacyPage.ts +28 -3
- package/src/lifecycle/normalizeHostToSandboxMessage.ts +13 -2
- package/src/lifecycle/normalizePage.ts +35 -0
- package/src/messages/types.ts +1 -1
- package/dist/lifecycle/normalizeQueryPage.d.ts +0 -3
- package/dist/lifecycle/normalizeQueryPage.d.ts.map +0 -1
- package/dist/lifecycle/normalizeQueryPage.js +0 -13
- package/src/lifecycle/normalizeQueryPage.ts +0 -25
|
@@ -313,7 +313,7 @@ export declare const notionPagePropertyValueSchema: v.VariantSchema<"type", [v.O
|
|
|
313
313
|
readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
314
314
|
}, undefined>], undefined>;
|
|
315
315
|
export type NotionPagePropertyValue = v.InferOutput<typeof notionPagePropertyValueSchema>;
|
|
316
|
-
export declare const
|
|
316
|
+
export declare const notionPagePropertyWriteMapSchema: v.RecordSchema<v.StringSchema<undefined>, v.VariantSchema<"type", [v.ObjectSchema<{
|
|
317
317
|
readonly id: v.StringSchema<undefined>;
|
|
318
318
|
readonly type: v.LiteralSchema<"title", undefined>;
|
|
319
319
|
readonly title: v.ArraySchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
|
|
@@ -466,14 +466,394 @@ export declare const notionPagePropertyReadMapSchema: v.RecordSchema<v.StringSch
|
|
|
466
466
|
readonly type: v.LiteralSchema<"last_visited_time", undefined>;
|
|
467
467
|
readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
468
468
|
}, undefined>], undefined>, undefined>;
|
|
469
|
+
export declare const notionPagePropertyReadMapSchema: v.RecordSchema<v.StringSchema<undefined>, v.NullableSchema<v.VariantSchema<"type", [v.ObjectSchema<{
|
|
470
|
+
readonly id: v.StringSchema<undefined>;
|
|
471
|
+
readonly type: v.LiteralSchema<"title", undefined>;
|
|
472
|
+
readonly title: v.ArraySchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
|
|
473
|
+
}, undefined>, v.ObjectSchema<{
|
|
474
|
+
readonly id: v.StringSchema<undefined>;
|
|
475
|
+
readonly type: v.LiteralSchema<"rich_text", undefined>;
|
|
476
|
+
readonly rich_text: v.ArraySchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
|
|
477
|
+
}, undefined>, v.ObjectSchema<{
|
|
478
|
+
readonly id: v.StringSchema<undefined>;
|
|
479
|
+
readonly type: v.LiteralSchema<"number", undefined>;
|
|
480
|
+
readonly number: v.NullableSchema<v.NumberSchema<undefined>, undefined>;
|
|
481
|
+
}, undefined>, v.ObjectSchema<{
|
|
482
|
+
readonly id: v.StringSchema<undefined>;
|
|
483
|
+
readonly type: v.LiteralSchema<"url", undefined>;
|
|
484
|
+
readonly url: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
485
|
+
}, undefined>, v.ObjectSchema<{
|
|
486
|
+
readonly id: v.StringSchema<undefined>;
|
|
487
|
+
readonly type: v.LiteralSchema<"email", undefined>;
|
|
488
|
+
readonly email: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
489
|
+
}, undefined>, v.ObjectSchema<{
|
|
490
|
+
readonly id: v.StringSchema<undefined>;
|
|
491
|
+
readonly type: v.LiteralSchema<"phone_number", undefined>;
|
|
492
|
+
readonly phone_number: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
493
|
+
}, undefined>, v.ObjectSchema<{
|
|
494
|
+
readonly id: v.StringSchema<undefined>;
|
|
495
|
+
readonly type: v.LiteralSchema<"checkbox", undefined>;
|
|
496
|
+
readonly checkbox: v.BooleanSchema<undefined>;
|
|
497
|
+
}, undefined>, v.ObjectSchema<{
|
|
498
|
+
readonly id: v.StringSchema<undefined>;
|
|
499
|
+
readonly type: v.LiteralSchema<"select", undefined>;
|
|
500
|
+
readonly select: v.NullableSchema<v.UnionSchema<[v.ObjectSchema<{
|
|
501
|
+
readonly id: v.StringSchema<undefined>;
|
|
502
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
503
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
504
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
505
|
+
}, undefined>, v.ObjectSchema<{
|
|
506
|
+
readonly name: v.StringSchema<undefined>;
|
|
507
|
+
readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
508
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
509
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
510
|
+
}, undefined>], undefined>, undefined>;
|
|
511
|
+
}, undefined>, v.ObjectSchema<{
|
|
512
|
+
readonly id: v.StringSchema<undefined>;
|
|
513
|
+
readonly type: v.LiteralSchema<"status", undefined>;
|
|
514
|
+
readonly status: v.NullableSchema<v.UnionSchema<[v.ObjectSchema<{
|
|
515
|
+
readonly id: v.StringSchema<undefined>;
|
|
516
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
517
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
518
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
519
|
+
}, undefined>, v.ObjectSchema<{
|
|
520
|
+
readonly name: v.StringSchema<undefined>;
|
|
521
|
+
readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
522
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
523
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
524
|
+
}, undefined>], undefined>, undefined>;
|
|
525
|
+
}, undefined>, v.ObjectSchema<{
|
|
526
|
+
readonly id: v.StringSchema<undefined>;
|
|
527
|
+
readonly type: v.LiteralSchema<"multi_select", undefined>;
|
|
528
|
+
readonly multi_select: v.ArraySchema<v.UnionSchema<[v.ObjectSchema<{
|
|
529
|
+
readonly id: v.StringSchema<undefined>;
|
|
530
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
531
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
532
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
533
|
+
}, undefined>, v.ObjectSchema<{
|
|
534
|
+
readonly name: v.StringSchema<undefined>;
|
|
535
|
+
readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
536
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
537
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
538
|
+
}, undefined>], undefined>, undefined>;
|
|
539
|
+
}, undefined>, v.ObjectSchema<{
|
|
540
|
+
readonly id: v.StringSchema<undefined>;
|
|
541
|
+
readonly type: v.LiteralSchema<"date", undefined>;
|
|
542
|
+
readonly date: v.NullableSchema<v.ObjectSchema<{
|
|
543
|
+
readonly start: v.StringSchema<undefined>;
|
|
544
|
+
readonly end: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
545
|
+
readonly time_zone: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
546
|
+
}, undefined>, undefined>;
|
|
547
|
+
}, undefined>, v.ObjectSchema<{
|
|
548
|
+
readonly id: v.StringSchema<undefined>;
|
|
549
|
+
readonly type: v.LiteralSchema<"people", undefined>;
|
|
550
|
+
readonly people: v.ArraySchema<v.UnionSchema<[v.ObjectSchema<{
|
|
551
|
+
readonly object: v.OptionalSchema<v.LiteralSchema<"user", undefined>, undefined>;
|
|
552
|
+
readonly id: v.StringSchema<undefined>;
|
|
553
|
+
}, undefined>, v.ObjectSchema<{
|
|
554
|
+
readonly object: v.LiteralSchema<"group", undefined>;
|
|
555
|
+
readonly id: v.StringSchema<undefined>;
|
|
556
|
+
readonly name: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
557
|
+
}, undefined>], undefined>, undefined>;
|
|
558
|
+
}, undefined>, v.ObjectSchema<{
|
|
559
|
+
readonly id: v.StringSchema<undefined>;
|
|
560
|
+
readonly type: v.LiteralSchema<"relation", undefined>;
|
|
561
|
+
readonly has_more: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
562
|
+
readonly relation: v.ArraySchema<v.ObjectSchema<{
|
|
563
|
+
readonly id: v.StringSchema<undefined>;
|
|
564
|
+
}, undefined>, undefined>;
|
|
565
|
+
}, undefined>, v.ObjectSchema<{
|
|
566
|
+
readonly id: v.StringSchema<undefined>;
|
|
567
|
+
readonly type: v.LiteralSchema<"files", undefined>;
|
|
568
|
+
readonly files: v.ArraySchema<v.UnionSchema<[v.ObjectSchema<{
|
|
569
|
+
readonly type: v.LiteralSchema<"external", undefined>;
|
|
570
|
+
readonly name: v.StringSchema<undefined>;
|
|
571
|
+
readonly external: v.ObjectSchema<{
|
|
572
|
+
readonly url: v.StringSchema<undefined>;
|
|
573
|
+
}, undefined>;
|
|
574
|
+
}, undefined>, v.ObjectSchema<{
|
|
575
|
+
readonly type: v.LiteralSchema<"file", undefined>;
|
|
576
|
+
readonly name: v.StringSchema<undefined>;
|
|
577
|
+
readonly file: v.ObjectSchema<{
|
|
578
|
+
readonly url: v.StringSchema<undefined>;
|
|
579
|
+
readonly expiry_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
580
|
+
}, undefined>;
|
|
581
|
+
}, undefined>], undefined>, undefined>;
|
|
582
|
+
}, undefined>, v.ObjectSchema<{
|
|
583
|
+
readonly id: v.StringSchema<undefined>;
|
|
584
|
+
readonly type: v.LiteralSchema<"place", undefined>;
|
|
585
|
+
readonly place: v.NullableSchema<v.ObjectSchema<{
|
|
586
|
+
readonly lat: v.NumberSchema<undefined>;
|
|
587
|
+
readonly lon: v.NumberSchema<undefined>;
|
|
588
|
+
readonly name: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
589
|
+
readonly address: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
590
|
+
readonly aws_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
591
|
+
readonly google_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
592
|
+
}, undefined>, undefined>;
|
|
593
|
+
}, undefined>, v.ObjectSchema<{
|
|
594
|
+
readonly id: v.StringSchema<undefined>;
|
|
595
|
+
readonly type: v.LiteralSchema<"created_time", undefined>;
|
|
596
|
+
readonly created_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
597
|
+
}, undefined>, v.ObjectSchema<{
|
|
598
|
+
readonly id: v.StringSchema<undefined>;
|
|
599
|
+
readonly type: v.LiteralSchema<"last_edited_time", undefined>;
|
|
600
|
+
readonly last_edited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
601
|
+
}, undefined>, v.ObjectSchema<{
|
|
602
|
+
readonly id: v.StringSchema<undefined>;
|
|
603
|
+
readonly type: v.LiteralSchema<"created_by", undefined>;
|
|
604
|
+
readonly created_by: v.NullableSchema<v.ObjectSchema<{
|
|
605
|
+
readonly id: v.StringSchema<undefined>;
|
|
606
|
+
readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
|
|
607
|
+
readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
608
|
+
}, undefined>, undefined>;
|
|
609
|
+
}, undefined>, v.ObjectSchema<{
|
|
610
|
+
readonly id: v.StringSchema<undefined>;
|
|
611
|
+
readonly type: v.LiteralSchema<"last_edited_by", undefined>;
|
|
612
|
+
readonly last_edited_by: v.NullableSchema<v.ObjectSchema<{
|
|
613
|
+
readonly id: v.StringSchema<undefined>;
|
|
614
|
+
readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
|
|
615
|
+
readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
616
|
+
}, undefined>, undefined>;
|
|
617
|
+
}, undefined>, v.ObjectSchema<{
|
|
618
|
+
readonly id: v.StringSchema<undefined>;
|
|
619
|
+
readonly type: v.LiteralSchema<"last_visited_time", undefined>;
|
|
620
|
+
readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
621
|
+
}, undefined>], undefined>, undefined>, undefined>;
|
|
469
622
|
export type NotionPagePropertyReadMap = v.InferOutput<typeof notionPagePropertyReadMapSchema>;
|
|
470
|
-
export type NotionPagePropertyWriteMap =
|
|
471
|
-
type: "created_time" | "last_edited_time" | "created_by" | "last_edited_by" | "last_visited_time";
|
|
472
|
-
}>>;
|
|
623
|
+
export type NotionPagePropertyWriteMap = v.InferInput<typeof notionPagePropertyWriteMapSchema>;
|
|
473
624
|
/**
|
|
474
625
|
* The `Page` object returned in `createPageResult` messages.
|
|
475
626
|
*/
|
|
476
|
-
export declare const
|
|
627
|
+
export declare const notionPageDataSchema: v.ObjectSchema<{
|
|
628
|
+
readonly object: v.LiteralSchema<"page", undefined>;
|
|
629
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
|
|
630
|
+
readonly parent: v.VariantSchema<"type", [v.ObjectSchema<{
|
|
631
|
+
readonly type: v.LiteralSchema<"page_id", undefined>;
|
|
632
|
+
readonly page_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
|
|
633
|
+
}, undefined>, v.ObjectSchema<{
|
|
634
|
+
readonly type: v.LiteralSchema<"data_source_id", undefined>;
|
|
635
|
+
readonly data_source_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>;
|
|
636
|
+
}, undefined>, v.ObjectSchema<{
|
|
637
|
+
readonly type: v.LiteralSchema<"workspace", undefined>;
|
|
638
|
+
readonly workspace: v.LiteralSchema<true, undefined>;
|
|
639
|
+
}, undefined>, v.ObjectSchema<{
|
|
640
|
+
readonly type: v.LiteralSchema<"block_id", undefined>;
|
|
641
|
+
readonly block_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionBlockId">]>;
|
|
642
|
+
}, undefined>, v.ObjectSchema<{
|
|
643
|
+
readonly type: v.LiteralSchema<"agent_id", undefined>;
|
|
644
|
+
readonly agent_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionAgentId">]>;
|
|
645
|
+
}, undefined>, v.ObjectSchema<{
|
|
646
|
+
readonly type: v.LiteralSchema<"unavailable", undefined>;
|
|
647
|
+
}, undefined>], undefined>;
|
|
648
|
+
readonly properties: v.RecordSchema<v.StringSchema<undefined>, v.NullableSchema<v.VariantSchema<"type", [v.ObjectSchema<{
|
|
649
|
+
readonly id: v.StringSchema<undefined>;
|
|
650
|
+
readonly type: v.LiteralSchema<"title", undefined>;
|
|
651
|
+
readonly title: v.ArraySchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
|
|
652
|
+
}, undefined>, v.ObjectSchema<{
|
|
653
|
+
readonly id: v.StringSchema<undefined>;
|
|
654
|
+
readonly type: v.LiteralSchema<"rich_text", undefined>;
|
|
655
|
+
readonly rich_text: v.ArraySchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
|
|
656
|
+
}, undefined>, v.ObjectSchema<{
|
|
657
|
+
readonly id: v.StringSchema<undefined>;
|
|
658
|
+
readonly type: v.LiteralSchema<"number", undefined>;
|
|
659
|
+
readonly number: v.NullableSchema<v.NumberSchema<undefined>, undefined>;
|
|
660
|
+
}, undefined>, v.ObjectSchema<{
|
|
661
|
+
readonly id: v.StringSchema<undefined>;
|
|
662
|
+
readonly type: v.LiteralSchema<"url", undefined>;
|
|
663
|
+
readonly url: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
664
|
+
}, undefined>, v.ObjectSchema<{
|
|
665
|
+
readonly id: v.StringSchema<undefined>;
|
|
666
|
+
readonly type: v.LiteralSchema<"email", undefined>;
|
|
667
|
+
readonly email: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
668
|
+
}, undefined>, v.ObjectSchema<{
|
|
669
|
+
readonly id: v.StringSchema<undefined>;
|
|
670
|
+
readonly type: v.LiteralSchema<"phone_number", undefined>;
|
|
671
|
+
readonly phone_number: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
672
|
+
}, undefined>, v.ObjectSchema<{
|
|
673
|
+
readonly id: v.StringSchema<undefined>;
|
|
674
|
+
readonly type: v.LiteralSchema<"checkbox", undefined>;
|
|
675
|
+
readonly checkbox: v.BooleanSchema<undefined>;
|
|
676
|
+
}, undefined>, v.ObjectSchema<{
|
|
677
|
+
readonly id: v.StringSchema<undefined>;
|
|
678
|
+
readonly type: v.LiteralSchema<"select", undefined>;
|
|
679
|
+
readonly select: v.NullableSchema<v.UnionSchema<[v.ObjectSchema<{
|
|
680
|
+
readonly id: v.StringSchema<undefined>;
|
|
681
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
682
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
683
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
684
|
+
}, undefined>, v.ObjectSchema<{
|
|
685
|
+
readonly name: v.StringSchema<undefined>;
|
|
686
|
+
readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
687
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
688
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
689
|
+
}, undefined>], undefined>, undefined>;
|
|
690
|
+
}, undefined>, v.ObjectSchema<{
|
|
691
|
+
readonly id: v.StringSchema<undefined>;
|
|
692
|
+
readonly type: v.LiteralSchema<"status", undefined>;
|
|
693
|
+
readonly status: v.NullableSchema<v.UnionSchema<[v.ObjectSchema<{
|
|
694
|
+
readonly id: v.StringSchema<undefined>;
|
|
695
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
696
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
697
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
698
|
+
}, undefined>, v.ObjectSchema<{
|
|
699
|
+
readonly name: v.StringSchema<undefined>;
|
|
700
|
+
readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
701
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
702
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
703
|
+
}, undefined>], undefined>, undefined>;
|
|
704
|
+
}, undefined>, v.ObjectSchema<{
|
|
705
|
+
readonly id: v.StringSchema<undefined>;
|
|
706
|
+
readonly type: v.LiteralSchema<"multi_select", undefined>;
|
|
707
|
+
readonly multi_select: v.ArraySchema<v.UnionSchema<[v.ObjectSchema<{
|
|
708
|
+
readonly id: v.StringSchema<undefined>;
|
|
709
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
710
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
711
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
712
|
+
}, undefined>, v.ObjectSchema<{
|
|
713
|
+
readonly name: v.StringSchema<undefined>;
|
|
714
|
+
readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
715
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
716
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
717
|
+
}, undefined>], undefined>, undefined>;
|
|
718
|
+
}, undefined>, v.ObjectSchema<{
|
|
719
|
+
readonly id: v.StringSchema<undefined>;
|
|
720
|
+
readonly type: v.LiteralSchema<"date", undefined>;
|
|
721
|
+
readonly date: v.NullableSchema<v.ObjectSchema<{
|
|
722
|
+
readonly start: v.StringSchema<undefined>;
|
|
723
|
+
readonly end: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
724
|
+
readonly time_zone: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
725
|
+
}, undefined>, undefined>;
|
|
726
|
+
}, undefined>, v.ObjectSchema<{
|
|
727
|
+
readonly id: v.StringSchema<undefined>;
|
|
728
|
+
readonly type: v.LiteralSchema<"people", undefined>;
|
|
729
|
+
readonly people: v.ArraySchema<v.UnionSchema<[v.ObjectSchema<{
|
|
730
|
+
readonly object: v.OptionalSchema<v.LiteralSchema<"user", undefined>, undefined>;
|
|
731
|
+
readonly id: v.StringSchema<undefined>;
|
|
732
|
+
}, undefined>, v.ObjectSchema<{
|
|
733
|
+
readonly object: v.LiteralSchema<"group", undefined>;
|
|
734
|
+
readonly id: v.StringSchema<undefined>;
|
|
735
|
+
readonly name: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
736
|
+
}, undefined>], undefined>, undefined>;
|
|
737
|
+
}, undefined>, v.ObjectSchema<{
|
|
738
|
+
readonly id: v.StringSchema<undefined>;
|
|
739
|
+
readonly type: v.LiteralSchema<"relation", undefined>;
|
|
740
|
+
readonly has_more: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
741
|
+
readonly relation: v.ArraySchema<v.ObjectSchema<{
|
|
742
|
+
readonly id: v.StringSchema<undefined>;
|
|
743
|
+
}, undefined>, undefined>;
|
|
744
|
+
}, undefined>, v.ObjectSchema<{
|
|
745
|
+
readonly id: v.StringSchema<undefined>;
|
|
746
|
+
readonly type: v.LiteralSchema<"files", undefined>;
|
|
747
|
+
readonly files: v.ArraySchema<v.UnionSchema<[v.ObjectSchema<{
|
|
748
|
+
readonly type: v.LiteralSchema<"external", undefined>;
|
|
749
|
+
readonly name: v.StringSchema<undefined>;
|
|
750
|
+
readonly external: v.ObjectSchema<{
|
|
751
|
+
readonly url: v.StringSchema<undefined>;
|
|
752
|
+
}, undefined>;
|
|
753
|
+
}, undefined>, v.ObjectSchema<{
|
|
754
|
+
readonly type: v.LiteralSchema<"file", undefined>;
|
|
755
|
+
readonly name: v.StringSchema<undefined>;
|
|
756
|
+
readonly file: v.ObjectSchema<{
|
|
757
|
+
readonly url: v.StringSchema<undefined>;
|
|
758
|
+
readonly expiry_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
759
|
+
}, undefined>;
|
|
760
|
+
}, undefined>], undefined>, undefined>;
|
|
761
|
+
}, undefined>, v.ObjectSchema<{
|
|
762
|
+
readonly id: v.StringSchema<undefined>;
|
|
763
|
+
readonly type: v.LiteralSchema<"place", undefined>;
|
|
764
|
+
readonly place: v.NullableSchema<v.ObjectSchema<{
|
|
765
|
+
readonly lat: v.NumberSchema<undefined>;
|
|
766
|
+
readonly lon: v.NumberSchema<undefined>;
|
|
767
|
+
readonly name: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
768
|
+
readonly address: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
769
|
+
readonly aws_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
770
|
+
readonly google_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
771
|
+
}, undefined>, undefined>;
|
|
772
|
+
}, undefined>, v.ObjectSchema<{
|
|
773
|
+
readonly id: v.StringSchema<undefined>;
|
|
774
|
+
readonly type: v.LiteralSchema<"created_time", undefined>;
|
|
775
|
+
readonly created_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
776
|
+
}, undefined>, v.ObjectSchema<{
|
|
777
|
+
readonly id: v.StringSchema<undefined>;
|
|
778
|
+
readonly type: v.LiteralSchema<"last_edited_time", undefined>;
|
|
779
|
+
readonly last_edited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
780
|
+
}, undefined>, v.ObjectSchema<{
|
|
781
|
+
readonly id: v.StringSchema<undefined>;
|
|
782
|
+
readonly type: v.LiteralSchema<"created_by", undefined>;
|
|
783
|
+
readonly created_by: v.NullableSchema<v.ObjectSchema<{
|
|
784
|
+
readonly id: v.StringSchema<undefined>;
|
|
785
|
+
readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
|
|
786
|
+
readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
787
|
+
}, undefined>, undefined>;
|
|
788
|
+
}, undefined>, v.ObjectSchema<{
|
|
789
|
+
readonly id: v.StringSchema<undefined>;
|
|
790
|
+
readonly type: v.LiteralSchema<"last_edited_by", undefined>;
|
|
791
|
+
readonly last_edited_by: v.NullableSchema<v.ObjectSchema<{
|
|
792
|
+
readonly id: v.StringSchema<undefined>;
|
|
793
|
+
readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
|
|
794
|
+
readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
795
|
+
}, undefined>, undefined>;
|
|
796
|
+
}, undefined>, v.ObjectSchema<{
|
|
797
|
+
readonly id: v.StringSchema<undefined>;
|
|
798
|
+
readonly type: v.LiteralSchema<"last_visited_time", undefined>;
|
|
799
|
+
readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
800
|
+
}, undefined>], undefined>, undefined>, undefined>;
|
|
801
|
+
readonly created_by: v.OptionalSchema<v.NullableSchema<v.ObjectSchema<{
|
|
802
|
+
readonly id: v.StringSchema<undefined>;
|
|
803
|
+
readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
|
|
804
|
+
readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
805
|
+
}, undefined>, undefined>, null>;
|
|
806
|
+
readonly last_edited_by: v.OptionalSchema<v.NullableSchema<v.ObjectSchema<{
|
|
807
|
+
readonly id: v.StringSchema<undefined>;
|
|
808
|
+
readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
|
|
809
|
+
readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
810
|
+
}, undefined>, undefined>, null>;
|
|
811
|
+
readonly last_visited_time: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, null>;
|
|
812
|
+
readonly created_time: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, null>;
|
|
813
|
+
readonly last_edited_time: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, null>;
|
|
814
|
+
readonly icon: v.OptionalSchema<v.NullableSchema<v.VariantSchema<"type", [v.ObjectSchema<{
|
|
815
|
+
readonly type: v.LiteralSchema<"emoji", undefined>;
|
|
816
|
+
readonly emoji: v.StringSchema<undefined>;
|
|
817
|
+
}, undefined>, v.ObjectSchema<{
|
|
818
|
+
readonly type: v.LiteralSchema<"custom_emoji", undefined>;
|
|
819
|
+
readonly custom_emoji: v.ObjectSchema<{
|
|
820
|
+
readonly id: v.StringSchema<undefined>;
|
|
821
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
822
|
+
readonly url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
823
|
+
}, undefined>;
|
|
824
|
+
}, undefined>, v.ObjectSchema<{
|
|
825
|
+
readonly type: v.LiteralSchema<"external", undefined>;
|
|
826
|
+
readonly external: v.ObjectSchema<{
|
|
827
|
+
readonly url: v.StringSchema<undefined>;
|
|
828
|
+
}, undefined>;
|
|
829
|
+
}, undefined>, v.ObjectSchema<{
|
|
830
|
+
readonly type: v.LiteralSchema<"file", undefined>;
|
|
831
|
+
readonly file: v.ObjectSchema<{
|
|
832
|
+
readonly url: v.StringSchema<undefined>;
|
|
833
|
+
readonly expiry_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
834
|
+
}, undefined>;
|
|
835
|
+
}, undefined>], undefined>, undefined>, null>;
|
|
836
|
+
readonly cover: v.OptionalSchema<v.NullableSchema<v.VariantSchema<"type", [v.ObjectSchema<{
|
|
837
|
+
readonly type: v.LiteralSchema<"external", undefined>;
|
|
838
|
+
readonly external: v.ObjectSchema<{
|
|
839
|
+
readonly url: v.StringSchema<undefined>;
|
|
840
|
+
}, undefined>;
|
|
841
|
+
}, undefined>, v.ObjectSchema<{
|
|
842
|
+
readonly type: v.LiteralSchema<"file", undefined>;
|
|
843
|
+
readonly file: v.ObjectSchema<{
|
|
844
|
+
readonly url: v.StringSchema<undefined>;
|
|
845
|
+
readonly expiry_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
846
|
+
}, undefined>;
|
|
847
|
+
}, undefined>], undefined>, undefined>, null>;
|
|
848
|
+
readonly url: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, null>;
|
|
849
|
+
readonly public_url: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, null>;
|
|
850
|
+
/** Whether the page or an ancestor is archived. */
|
|
851
|
+
readonly is_archived: v.BooleanSchema<undefined>;
|
|
852
|
+
/** Whether the page or an ancestor is in Trash. */
|
|
853
|
+
readonly in_trash: v.BooleanSchema<undefined>;
|
|
854
|
+
}, undefined>;
|
|
855
|
+
export type NotionPageData = v.InferInput<typeof notionPageDataSchema>;
|
|
856
|
+
export declare const legacyNotionPageSchema: v.ObjectSchema<{
|
|
477
857
|
readonly object: v.LiteralSchema<"page", undefined>;
|
|
478
858
|
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
|
|
479
859
|
readonly parent: v.VariantSchema<"type", [v.ObjectSchema<{
|
|
@@ -690,5 +1070,5 @@ export declare const notionPageSchema: v.ObjectSchema<{
|
|
|
690
1070
|
/** Whether the page or an ancestor is in Trash. */
|
|
691
1071
|
readonly in_trash: v.BooleanSchema<undefined>;
|
|
692
1072
|
}, undefined>;
|
|
693
|
-
export type
|
|
1073
|
+
export type LegacyNotionPage = v.InferOutput<typeof legacyNotionPageSchema>;
|
|
694
1074
|
export {};
|
|
@@ -118,6 +118,7 @@ const notionPlaceInputSchema = v.object({
|
|
|
118
118
|
const pagePropertyBaseSchema = {
|
|
119
119
|
id: v.string(),
|
|
120
120
|
};
|
|
121
|
+
// TODO(custom-blocks): Make spaceId required for metadataActor
|
|
121
122
|
const metadataActorSchema = v.nullable(v.object({
|
|
122
123
|
...notionRecordPointerSchema.entries,
|
|
123
124
|
table: v.picklist(["notion_user", "bot", "organization_bot"]),
|
|
@@ -229,15 +230,35 @@ export const notionPagePropertyValueSchema = v.variant("type", [
|
|
|
229
230
|
last_visited_time: nullableStringSchema,
|
|
230
231
|
}),
|
|
231
232
|
]);
|
|
232
|
-
export const
|
|
233
|
+
export const notionPagePropertyWriteMapSchema = v.record(v.string(), notionPagePropertyValueSchema);
|
|
234
|
+
export const notionPagePropertyReadMapSchema = v.record(v.string(), v.nullable(notionPagePropertyValueSchema));
|
|
233
235
|
/**
|
|
234
236
|
* The `Page` object returned in `createPageResult` messages.
|
|
235
237
|
*/
|
|
236
|
-
export const
|
|
238
|
+
export const notionPageDataSchema = v.object({
|
|
237
239
|
object: v.literal("page"),
|
|
238
240
|
id: notionPageIdSchema,
|
|
239
241
|
parent: notionParentSchema,
|
|
240
242
|
properties: notionPagePropertyReadMapSchema,
|
|
243
|
+
created_by: v.optional(metadataActorSchema, null),
|
|
244
|
+
last_edited_by: v.optional(metadataActorSchema, null),
|
|
245
|
+
last_visited_time: v.optional(v.nullable(v.string()), null),
|
|
246
|
+
created_time: v.optional(v.nullable(v.string()), null),
|
|
247
|
+
last_edited_time: v.optional(v.nullable(v.string()), null),
|
|
248
|
+
icon: v.optional(v.nullable(notionPageIconSchema), null),
|
|
249
|
+
cover: v.optional(v.nullable(notionPageCoverSchema), null),
|
|
250
|
+
url: v.optional(v.nullable(v.string()), null),
|
|
251
|
+
public_url: v.optional(v.nullable(v.string()), null),
|
|
252
|
+
/** Whether the page or an ancestor is archived. */
|
|
253
|
+
is_archived: v.boolean(),
|
|
254
|
+
/** Whether the page or an ancestor is in Trash. */
|
|
255
|
+
in_trash: v.boolean(),
|
|
256
|
+
});
|
|
257
|
+
export const legacyNotionPageSchema = v.object({
|
|
258
|
+
object: v.literal("page"),
|
|
259
|
+
id: notionPageIdSchema,
|
|
260
|
+
parent: notionParentSchema,
|
|
261
|
+
properties: notionPagePropertyWriteMapSchema,
|
|
241
262
|
created_time: v.optional(v.string()),
|
|
242
263
|
last_edited_time: v.optional(v.string()),
|
|
243
264
|
icon: v.optional(notionPageIconSchema),
|
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
* older versions, so this value does not set the minimum or maximum they accept.
|
|
5
5
|
*/
|
|
6
6
|
export const LATEST_BRIDGE_PROTOCOL_VERSION = 6;
|
|
7
|
-
// Protocol 6 introduces name-keyed property objects
|
|
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;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
export type {
|
|
2
|
-
LegacyNotionDataSourcePageBridge,
|
|
3
|
-
NotionDataSourcePageBridge,
|
|
4
|
-
} from "@notionhq/custom-blocks-protocol/dataSources/dataSourcePage.js"
|
|
1
|
+
export type { LegacyNotionDataSourcePageBridge } from "@notionhq/custom-blocks-protocol/dataSources/dataSourcePage.js"
|
|
5
2
|
export type { NotionPropertySchemasById } from "@notionhq/custom-blocks-protocol/dataSources/propertySchema.js"
|
|
6
3
|
export type { CustomBlockErrorInfo } from "@notionhq/custom-blocks-protocol/errors.js"
|
|
7
4
|
export type { NotionPageId } from "@notionhq/custom-blocks-protocol/ids.js"
|
|
@@ -37,6 +34,7 @@ export type {
|
|
|
37
34
|
NotionDateInput,
|
|
38
35
|
NotionFileInput,
|
|
39
36
|
NotionPageCover,
|
|
37
|
+
NotionPageData,
|
|
40
38
|
NotionPageIcon,
|
|
41
39
|
NotionPagePropertyReadMap,
|
|
42
40
|
NotionPagePropertyValue,
|
|
@@ -1,9 +1,34 @@
|
|
|
1
|
-
import type { NotionDataSourcePageBridge } from "@notionhq/custom-blocks-protocol/dataSources/dataSourcePage.js"
|
|
2
1
|
import type { NotionDataSourceValue } from "@notionhq/custom-blocks-protocol/dataSources/dataSourceValue.js"
|
|
3
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
LegacyNotionPage,
|
|
4
|
+
NotionPagePropertyValue,
|
|
5
|
+
notionPageDataSchema,
|
|
6
|
+
} from "@notionhq/custom-blocks-protocol/pages/page.js"
|
|
7
|
+
import type { InferOutput } from "valibot"
|
|
4
8
|
import { unreachable } from "../utils.js"
|
|
5
9
|
|
|
6
|
-
export function
|
|
10
|
+
export function toLegacyPage(
|
|
11
|
+
page: InferOutput<typeof notionPageDataSchema>,
|
|
12
|
+
): LegacyNotionPage {
|
|
13
|
+
return {
|
|
14
|
+
...page,
|
|
15
|
+
properties: Object.fromEntries(
|
|
16
|
+
Object.values(page.properties).flatMap(property =>
|
|
17
|
+
property ? [[property.id, property]] : [],
|
|
18
|
+
),
|
|
19
|
+
),
|
|
20
|
+
icon: page.icon ?? undefined,
|
|
21
|
+
cover: page.cover ?? undefined,
|
|
22
|
+
created_time: page.created_time ?? undefined,
|
|
23
|
+
last_edited_time: page.last_edited_time ?? undefined,
|
|
24
|
+
url: page.url ?? undefined,
|
|
25
|
+
public_url: page.public_url ?? undefined,
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function toLegacyQueryPage(
|
|
30
|
+
page: InferOutput<typeof notionPageDataSchema>,
|
|
31
|
+
) {
|
|
7
32
|
const propertiesById: Record<string, NotionDataSourceValue | undefined> = {}
|
|
8
33
|
for (const property of Object.values(page.properties)) {
|
|
9
34
|
if (property) {
|
|
@@ -2,7 +2,7 @@ import type {
|
|
|
2
2
|
HostToSandboxMessage,
|
|
3
3
|
HostToSandboxMessageLegacy,
|
|
4
4
|
} from "@notionhq/custom-blocks-protocol/messages/hostToSandbox.js"
|
|
5
|
-
import {
|
|
5
|
+
import { normalizeToLegacyPage } from "./normalizePage.js"
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Normalizes an outgoing message for the bridge protocol version requested by the sandbox.
|
|
@@ -13,6 +13,17 @@ export function normalizeHostToSandboxMessage(
|
|
|
13
13
|
message: HostToSandboxMessage,
|
|
14
14
|
bridgeProtocolVersion: number,
|
|
15
15
|
): HostToSandboxMessageLegacy {
|
|
16
|
-
|
|
16
|
+
if (
|
|
17
|
+
message.type !== "queryDataSourceResult" &&
|
|
18
|
+
message.type !== "getPageResult" &&
|
|
19
|
+
message.type !== "createPageResult" &&
|
|
20
|
+
message.type !== "updatePageResult"
|
|
21
|
+
) {
|
|
22
|
+
return message
|
|
23
|
+
}
|
|
24
|
+
const normalizedMessage = normalizeToLegacyPage(
|
|
25
|
+
message,
|
|
26
|
+
bridgeProtocolVersion,
|
|
27
|
+
)
|
|
17
28
|
return normalizedMessage
|
|
18
29
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { CreatePageResultMessage } from "@notionhq/custom-blocks-protocol/messages/createPageResult.js"
|
|
2
|
+
import type { GetPageResultMessage } from "@notionhq/custom-blocks-protocol/messages/getPage.js"
|
|
3
|
+
import type { HostToSandboxMessageLegacy } from "@notionhq/custom-blocks-protocol/messages/hostToSandbox.js"
|
|
4
|
+
import type { QueryDataSourceResultMessage } from "@notionhq/custom-blocks-protocol/messages/queryDataSourceResult.js"
|
|
5
|
+
import type { UpdatePageResultMessage } from "@notionhq/custom-blocks-protocol/messages/updatePageResult.js"
|
|
6
|
+
import { LEGACY_PROPERTY_SHAPE_PROTOCOL_VERSION } from "@notionhq/custom-blocks-protocol/protocolVersion.js"
|
|
7
|
+
import { unreachable } from "../utils.js"
|
|
8
|
+
import { toLegacyPage, toLegacyQueryPage } from "./legacyPage.js"
|
|
9
|
+
|
|
10
|
+
export function normalizeToLegacyPage(
|
|
11
|
+
message:
|
|
12
|
+
| CreatePageResultMessage
|
|
13
|
+
| GetPageResultMessage
|
|
14
|
+
| UpdatePageResultMessage
|
|
15
|
+
| QueryDataSourceResultMessage,
|
|
16
|
+
bridgeProtocolVersion: number,
|
|
17
|
+
): HostToSandboxMessageLegacy {
|
|
18
|
+
// Forward up to date messages
|
|
19
|
+
if (bridgeProtocolVersion >= LEGACY_PROPERTY_SHAPE_PROTOCOL_VERSION) {
|
|
20
|
+
return message
|
|
21
|
+
}
|
|
22
|
+
if (message.status === "error") {
|
|
23
|
+
return message
|
|
24
|
+
}
|
|
25
|
+
switch (message.type) {
|
|
26
|
+
case "queryDataSourceResult":
|
|
27
|
+
return { ...message, items: message.items.map(toLegacyQueryPage) }
|
|
28
|
+
case "getPageResult":
|
|
29
|
+
case "createPageResult":
|
|
30
|
+
case "updatePageResult":
|
|
31
|
+
return { ...message, page: toLegacyPage(message.page) }
|
|
32
|
+
default:
|
|
33
|
+
return unreachable(message)
|
|
34
|
+
}
|
|
35
|
+
}
|
package/src/messages/types.ts
CHANGED
|
@@ -57,7 +57,7 @@ import type {
|
|
|
57
57
|
import type { InferInput } from "valibot"
|
|
58
58
|
import type { CustomBlockHostQueryDataSourceResult } from "../queries/types.js"
|
|
59
59
|
|
|
60
|
-
type MaybePromise<T> = T | Promise<T>
|
|
60
|
+
export type MaybePromise<T> = T | Promise<T>
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
63
|
* Host results use InferInput so adapters can return plain string IDs.
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { HostToSandboxMessage, HostToSandboxMessageLegacy } from "../protocol/messages/hostToSandbox.js";
|
|
2
|
-
export declare function normalizeQueryPage(message: HostToSandboxMessageLegacy | HostToSandboxMessage, bridgeProtocolVersion: number): HostToSandboxMessageLegacy;
|
|
3
|
-
//# sourceMappingURL=normalizeQueryPage.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"normalizeQueryPage.d.ts","sourceRoot":"","sources":["../../src/lifecycle/normalizeQueryPage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,oBAAoB,EACpB,0BAA0B,EAC1B,MAAM,4DAA4D,CAAA;AAInE,wBAAgB,kBAAkB,CACjC,OAAO,EAAE,0BAA0B,GAAG,oBAAoB,EAC1D,qBAAqB,EAAE,MAAM,GAC3B,0BAA0B,CAc5B"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { LEGACY_PROPERTY_SHAPE_PROTOCOL_VERSION } from "../protocol/protocolVersion.js";
|
|
2
|
-
import { toLegacyQueryPage } from "./legacyPage.js";
|
|
3
|
-
export function normalizeQueryPage(message, bridgeProtocolVersion) {
|
|
4
|
-
if (bridgeProtocolVersion < LEGACY_PROPERTY_SHAPE_PROTOCOL_VERSION &&
|
|
5
|
-
message.type === "queryDataSourceResult" &&
|
|
6
|
-
message.status === "success") {
|
|
7
|
-
return {
|
|
8
|
-
...message,
|
|
9
|
-
items: message.items.map(page => "properties" in page ? toLegacyQueryPage(page) : page),
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
return message;
|
|
13
|
-
}
|