@notionhq/custom-blocks 0.2.23 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/README.md +8 -5
  2. package/dist/bridge/SandboxBridge.d.ts +15 -14
  3. package/dist/bridge/SandboxBridge.d.ts.map +1 -1
  4. package/dist/bridge/SandboxBridge.js +117 -35
  5. package/dist/bridge/dataSources/resolve.d.ts +1 -3
  6. package/dist/bridge/dataSources/resolve.d.ts.map +1 -1
  7. package/dist/bridge/dataSources/resolve.js +1 -11
  8. package/dist/bridge/dataSources/resolveProperty.d.ts +3 -3
  9. package/dist/bridge/dataSources/resolveProperty.d.ts.map +1 -1
  10. package/dist/bridge/dataSources/resolveProperty.js +1 -1
  11. package/dist/bridge/dataSources/subscribe.d.ts +2 -1
  12. package/dist/bridge/dataSources/subscribe.d.ts.map +1 -1
  13. package/dist/bridge/dataSources/subscribe.js +6 -1
  14. package/dist/bridge/hostState.d.ts +11 -39
  15. package/dist/bridge/hostState.d.ts.map +1 -1
  16. package/dist/bridge/hostState.js +5 -50
  17. package/dist/bridge/page.d.ts +14 -0
  18. package/dist/bridge/page.d.ts.map +1 -0
  19. package/dist/bridge/page.js +59 -0
  20. package/dist/bridge/sandboxClient.d.ts +8 -14
  21. package/dist/bridge/sandboxClient.d.ts.map +1 -1
  22. package/dist/bridge/sandboxClient.js +13 -21
  23. package/dist/dataSources.d.ts +8 -0
  24. package/dist/dataSources.d.ts.map +1 -0
  25. package/dist/dataSources.js +103 -0
  26. package/dist/index.d.ts +6 -6
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +3 -2
  29. package/dist/protocol/dataSources/dataSourcePage.d.ts +3 -5
  30. package/dist/protocol/dataSources/dataSourcePage.js +2 -3
  31. package/dist/protocol/dataSources/propertySchema.d.ts +1 -0
  32. package/dist/protocol/index.d.ts +1 -0
  33. package/dist/protocol/index.js +1 -0
  34. package/dist/protocol/messages/createPage.d.ts +28 -0
  35. package/dist/protocol/messages/createPageResult.d.ts +496 -1
  36. package/dist/protocol/messages/createPageResult.js +17 -2
  37. package/dist/protocol/messages/getPage.d.ts +496 -1
  38. package/dist/protocol/messages/getPage.js +18 -3
  39. package/dist/protocol/messages/hostToSandbox.d.ts +2647 -154
  40. package/dist/protocol/messages/hostToSandbox.js +24 -12
  41. package/dist/protocol/messages/openExternalUrl.d.ts +32 -0
  42. package/dist/protocol/messages/openExternalUrl.js +26 -0
  43. package/dist/protocol/messages/queryDataSourceResult.d.ts +468 -1
  44. package/dist/protocol/messages/queryDataSourceResult.js +18 -2
  45. package/dist/protocol/messages/sandboxToHost.d.ts +62 -0
  46. package/dist/protocol/messages/sandboxToHost.js +2 -0
  47. package/dist/protocol/messages/updatePage.d.ts +29 -0
  48. package/dist/protocol/messages/updatePage.js +2 -1
  49. package/dist/protocol/messages/updatePageResult.d.ts +495 -1
  50. package/dist/protocol/messages/updatePageResult.js +16 -2
  51. package/dist/protocol/pages/page.d.ts +470 -3
  52. package/dist/protocol/pages/page.js +53 -1
  53. package/dist/protocol/protocolVersion.d.ts +2 -1
  54. package/dist/protocol/protocolVersion.js +4 -1
  55. package/dist/react/useDataSource.d.ts +1 -1
  56. package/dist/react/useDataSource.d.ts.map +1 -1
  57. package/dist/react/useDataSource.js +1 -3
  58. package/dist/types.d.ts +55 -96
  59. package/dist/types.d.ts.map +1 -1
  60. package/dist/version.js +1 -1
  61. package/docs/block-location.md +3 -3
  62. package/docs/data-sources.md +159 -122
  63. package/docs/errors.md +9 -9
  64. package/docs/links.md +44 -0
  65. package/docs/pages.md +121 -191
  66. package/package.json +1 -1
  67. package/src/bridge/SandboxBridge.ts +189 -62
  68. package/src/bridge/dataSources/resolve.ts +1 -20
  69. package/src/bridge/dataSources/resolveProperty.ts +4 -4
  70. package/src/bridge/dataSources/subscribe.ts +10 -5
  71. package/src/bridge/hostState.ts +21 -100
  72. package/src/bridge/page.ts +90 -0
  73. package/src/bridge/sandboxClient.ts +15 -25
  74. package/src/dataSources.ts +140 -0
  75. package/src/index.ts +9 -19
  76. package/src/react/useDataSource.ts +1 -3
  77. package/src/types.ts +61 -109
@@ -701,6 +701,34 @@ export declare const sandboxToHostMessageSchema: v.VariantSchema<"type", [v.Vari
701
701
  readonly aws_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
702
702
  readonly google_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
703
703
  }, undefined>, undefined>;
704
+ }, undefined>, v.ObjectSchema<{
705
+ readonly id: v.StringSchema<undefined>;
706
+ readonly type: v.LiteralSchema<"created_time", undefined>;
707
+ readonly created_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
708
+ }, undefined>, v.ObjectSchema<{
709
+ readonly id: v.StringSchema<undefined>;
710
+ readonly type: v.LiteralSchema<"last_edited_time", undefined>;
711
+ readonly last_edited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
712
+ }, undefined>, v.ObjectSchema<{
713
+ readonly id: v.StringSchema<undefined>;
714
+ readonly type: v.LiteralSchema<"created_by", undefined>;
715
+ readonly created_by: v.NullableSchema<v.ObjectSchema<{
716
+ readonly id: v.StringSchema<undefined>;
717
+ readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
718
+ readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
719
+ }, undefined>, undefined>;
720
+ }, undefined>, v.ObjectSchema<{
721
+ readonly id: v.StringSchema<undefined>;
722
+ readonly type: v.LiteralSchema<"last_edited_by", undefined>;
723
+ readonly last_edited_by: v.NullableSchema<v.ObjectSchema<{
724
+ readonly id: v.StringSchema<undefined>;
725
+ readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
726
+ readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
727
+ }, undefined>, undefined>;
728
+ }, undefined>, v.ObjectSchema<{
729
+ readonly id: v.StringSchema<undefined>;
730
+ readonly type: v.LiteralSchema<"last_visited_time", undefined>;
731
+ readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
704
732
  }, undefined>], undefined>, undefined>;
705
733
  readonly position: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
706
734
  readonly type: v.LiteralSchema<"start", undefined>;
@@ -717,6 +745,7 @@ export declare const sandboxToHostMessageSchema: v.VariantSchema<"type", [v.Vari
717
745
  readonly type: v.LiteralSchema<"getPage", undefined>;
718
746
  readonly requestId: v.StringSchema<undefined>;
719
747
  readonly pageId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
748
+ readonly dataSourceId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>, undefined>;
720
749
  }, undefined>, v.ObjectSchema<{
721
750
  readonly type: v.LiteralSchema<"getUser", undefined>;
722
751
  readonly requestId: v.StringSchema<undefined>;
@@ -731,10 +760,15 @@ export declare const sandboxToHostMessageSchema: v.VariantSchema<"type", [v.Vari
731
760
  readonly requestId: v.StringSchema<undefined>;
732
761
  readonly pageId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
733
762
  readonly mode: v.PicklistSchema<["side_peek", "center_peek"], undefined>;
763
+ }, undefined>, v.ObjectSchema<{
764
+ readonly type: v.LiteralSchema<"openExternalUrl", undefined>;
765
+ readonly requestId: v.StringSchema<undefined>;
766
+ readonly url: v.StringSchema<undefined>;
734
767
  }, undefined>, v.ObjectSchema<{
735
768
  readonly type: v.LiteralSchema<"updatePage", undefined>;
736
769
  readonly requestId: v.StringSchema<undefined>;
737
770
  readonly pageId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
771
+ readonly dataSourceId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>, undefined>;
738
772
  readonly properties: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.VariantSchema<"type", [v.ObjectSchema<{
739
773
  readonly id: v.StringSchema<undefined>;
740
774
  readonly type: v.LiteralSchema<"title", undefined>;
@@ -859,6 +893,34 @@ export declare const sandboxToHostMessageSchema: v.VariantSchema<"type", [v.Vari
859
893
  readonly aws_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
860
894
  readonly google_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
861
895
  }, undefined>, undefined>;
896
+ }, undefined>, v.ObjectSchema<{
897
+ readonly id: v.StringSchema<undefined>;
898
+ readonly type: v.LiteralSchema<"created_time", undefined>;
899
+ readonly created_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
900
+ }, undefined>, v.ObjectSchema<{
901
+ readonly id: v.StringSchema<undefined>;
902
+ readonly type: v.LiteralSchema<"last_edited_time", undefined>;
903
+ readonly last_edited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
904
+ }, undefined>, v.ObjectSchema<{
905
+ readonly id: v.StringSchema<undefined>;
906
+ readonly type: v.LiteralSchema<"created_by", undefined>;
907
+ readonly created_by: v.NullableSchema<v.ObjectSchema<{
908
+ readonly id: v.StringSchema<undefined>;
909
+ readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
910
+ readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
911
+ }, undefined>, undefined>;
912
+ }, undefined>, v.ObjectSchema<{
913
+ readonly id: v.StringSchema<undefined>;
914
+ readonly type: v.LiteralSchema<"last_edited_by", undefined>;
915
+ readonly last_edited_by: v.NullableSchema<v.ObjectSchema<{
916
+ readonly id: v.StringSchema<undefined>;
917
+ readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
918
+ readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
919
+ }, undefined>, undefined>;
920
+ }, undefined>, v.ObjectSchema<{
921
+ readonly id: v.StringSchema<undefined>;
922
+ readonly type: v.LiteralSchema<"last_visited_time", undefined>;
923
+ readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
862
924
  }, undefined>], undefined>, undefined>, undefined>;
863
925
  readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
864
926
  readonly type: v.LiteralSchema<"emoji", undefined>;
@@ -6,6 +6,7 @@ import { getUserMessageSchema } from "./getUser.js";
6
6
  import { initResultMessageSchema } from "./initResult.js";
7
7
  import { invalidHostMessageSchema } from "./invalidHostMessage.js";
8
8
  import { listUsersMessageSchema } from "./listUsers.js";
9
+ import { openExternalUrlMessageSchema } from "./openExternalUrl.js";
9
10
  import { openPageMessageSchema } from "./openPage.js";
10
11
  import { queryDataSourceMessageSchema } from "./queryDataSource.js";
11
12
  import { resizeMessageSchema } from "./resize.js";
@@ -25,6 +26,7 @@ export const sandboxToHostMessageSchema = v.variant("type", [
25
26
  getUserMessageSchema,
26
27
  listUsersMessageSchema,
27
28
  openPageMessageSchema,
29
+ openExternalUrlMessageSchema,
28
30
  updatePageMessageSchema,
29
31
  resizeMessageSchema,
30
32
  invalidHostMessageSchema,
@@ -6,6 +6,7 @@ export declare const updatePageMessageSchema: v.ObjectSchema<{
6
6
  readonly type: v.LiteralSchema<"updatePage", undefined>;
7
7
  readonly requestId: v.StringSchema<undefined>;
8
8
  readonly pageId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
9
+ readonly dataSourceId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>, undefined>;
9
10
  /**
10
11
  * Property values, keyed by raw property IDs from Notion.
11
12
  *
@@ -137,6 +138,34 @@ export declare const updatePageMessageSchema: v.ObjectSchema<{
137
138
  readonly aws_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
138
139
  readonly google_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
139
140
  }, undefined>, undefined>;
141
+ }, undefined>, v.ObjectSchema<{
142
+ readonly id: v.StringSchema<undefined>;
143
+ readonly type: v.LiteralSchema<"created_time", undefined>;
144
+ readonly created_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
145
+ }, undefined>, v.ObjectSchema<{
146
+ readonly id: v.StringSchema<undefined>;
147
+ readonly type: v.LiteralSchema<"last_edited_time", undefined>;
148
+ readonly last_edited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
149
+ }, undefined>, v.ObjectSchema<{
150
+ readonly id: v.StringSchema<undefined>;
151
+ readonly type: v.LiteralSchema<"created_by", undefined>;
152
+ readonly created_by: v.NullableSchema<v.ObjectSchema<{
153
+ readonly id: v.StringSchema<undefined>;
154
+ readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
155
+ readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
156
+ }, undefined>, undefined>;
157
+ }, undefined>, v.ObjectSchema<{
158
+ readonly id: v.StringSchema<undefined>;
159
+ readonly type: v.LiteralSchema<"last_edited_by", undefined>;
160
+ readonly last_edited_by: v.NullableSchema<v.ObjectSchema<{
161
+ readonly id: v.StringSchema<undefined>;
162
+ readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
163
+ readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
164
+ }, undefined>, undefined>;
165
+ }, undefined>, v.ObjectSchema<{
166
+ readonly id: v.StringSchema<undefined>;
167
+ readonly type: v.LiteralSchema<"last_visited_time", undefined>;
168
+ readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
140
169
  }, undefined>], undefined>, undefined>, undefined>;
141
170
  readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
142
171
  readonly type: v.LiteralSchema<"emoji", undefined>;
@@ -1,5 +1,5 @@
1
1
  import * as v from "valibot";
2
- import { notionPageIdSchema } from "../ids.js";
2
+ import { notionDataSourceIdSchema, notionPageIdSchema } from "../ids.js";
3
3
  import { notionPageCoverSchema, notionPageIconSchema, notionPagePropertyWriteMapSchema, } from "../pages/page.js";
4
4
  /**
5
5
  * The sandbox sends this message to patch a page.
@@ -8,6 +8,7 @@ export const updatePageMessageSchema = v.object({
8
8
  type: v.literal("updatePage"),
9
9
  requestId: v.string(),
10
10
  pageId: notionPageIdSchema,
11
+ dataSourceId: v.optional(notionDataSourceIdSchema),
11
12
  /**
12
13
  * Property values, keyed by raw property IDs from Notion.
13
14
  *