@notionhq/custom-blocks 0.3.5 → 0.5.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 (192) hide show
  1. package/README.md +2 -2
  2. package/dist/bridge/SandboxBridge.d.ts +4 -39
  3. package/dist/bridge/SandboxBridge.d.ts.map +1 -1
  4. package/dist/bridge/SandboxBridge.js +36 -142
  5. package/dist/bridge/requests.d.ts +35 -0
  6. package/dist/bridge/requests.d.ts.map +1 -0
  7. package/dist/bridge/requests.js +97 -0
  8. package/dist/dataSources/bridge/resolveDataSourceQuery.d.ts.map +1 -1
  9. package/dist/dataSources/bridge/resolveDataSourceQuery.js +18 -4
  10. package/dist/dataSources/bridge/resolveDataSources.js +4 -4
  11. package/dist/dataSources/createDataSourcePage.d.ts.map +1 -1
  12. package/dist/dataSources/createDataSourcePage.js +5 -1
  13. package/dist/dataSources/filters/resolveFilter.d.ts.map +1 -1
  14. package/dist/dataSources/filters/resolveFilter.js +13 -3
  15. package/dist/dataSources/filters/types.d.ts +9 -3
  16. package/dist/dataSources/filters/types.d.ts.map +1 -1
  17. package/dist/dataSources/properties/resolvePropertyAddress.js +1 -1
  18. package/dist/dataSources/properties/resolvePropertyWriteMapForDataSource.js +1 -1
  19. package/dist/dataSources/resolvePageDataSource.js +2 -2
  20. package/dist/dataSources/subscribeToDataSource.d.ts +1 -4
  21. package/dist/dataSources/subscribeToDataSource.d.ts.map +1 -1
  22. package/dist/dataSources/subscribeToDataSource.js +2 -3
  23. package/dist/dataSources/types.d.ts +2 -0
  24. package/dist/dataSources/types.d.ts.map +1 -1
  25. package/dist/files/files.d.ts +2 -0
  26. package/dist/files/files.d.ts.map +1 -0
  27. package/dist/files/files.js +1 -0
  28. package/dist/files/icons.d.ts +2 -0
  29. package/dist/files/icons.d.ts.map +1 -0
  30. package/dist/files/icons.js +1 -0
  31. package/dist/index.d.ts +5 -4
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/initialization/getInitBindingError.js +2 -2
  34. package/dist/manifest/types.d.ts +5 -4
  35. package/dist/manifest/types.d.ts.map +1 -1
  36. package/dist/navigation/openExternalUrl.d.ts.map +1 -1
  37. package/dist/navigation/openExternalUrl.js +2 -1
  38. package/dist/pages/bridge/getPageForDataSource.d.ts.map +1 -1
  39. package/dist/pages/bridge/getPageForDataSource.js +3 -2
  40. package/dist/pages/bridge/sendCreatePageRequest.d.ts.map +1 -1
  41. package/dist/pages/bridge/sendCreatePageRequest.js +2 -1
  42. package/dist/pages/bridge/toNotionPageFieldsFromBridgePage.d.ts +14 -2
  43. package/dist/pages/bridge/toNotionPageFieldsFromBridgePage.d.ts.map +1 -1
  44. package/dist/pages/bridge/toNotionPageFieldsFromBridgePage.js +0 -1
  45. package/dist/pages/bridge/toNotionPagePropertyFromBridgeProperty.d.ts.map +1 -1
  46. package/dist/pages/bridge/toNotionPagePropertyFromBridgeProperty.js +0 -8
  47. package/dist/pages/bridge/updatePage.d.ts.map +1 -1
  48. package/dist/pages/bridge/updatePage.js +20 -5
  49. package/dist/pages/createPage.d.ts.map +1 -1
  50. package/dist/pages/createPage.js +5 -1
  51. package/dist/pages/openPage.d.ts.map +1 -1
  52. package/dist/pages/openPage.js +2 -1
  53. package/dist/pages/properties/getPropertyByKey.js +2 -2
  54. package/dist/pages/types.d.ts +10 -14
  55. package/dist/pages/types.d.ts.map +1 -1
  56. package/dist/protocol/compatibility/protocol3To10/dataSourceBindings.d.ts +530 -0
  57. package/dist/protocol/compatibility/protocol3To10/dataSourceBindings.js +25 -0
  58. package/dist/protocol/compatibility/protocol3To5/bridgePage.d.ts +12 -11
  59. package/dist/protocol/compatibility/protocol3To5/bridgePage.js +3 -3
  60. package/dist/protocol/context/containingPage.d.ts +3 -0
  61. package/dist/protocol/context/messages/pageChanged.d.ts +3 -0
  62. package/dist/protocol/context/messages/parentChanged.d.ts +3 -0
  63. package/dist/protocol/context/parent.d.ts +5 -0
  64. package/dist/protocol/context/parent.js +6 -1
  65. package/dist/protocol/dataSources/bridgeArchiveStatus.d.ts +3 -0
  66. package/dist/protocol/dataSources/bridgeArchiveStatus.js +6 -0
  67. package/dist/protocol/dataSources/bridgeDataSourceBinding.d.ts +3 -11
  68. package/dist/protocol/dataSources/bridgeDataSourceBinding.js +5 -5
  69. package/dist/protocol/dataSources/bridgeDataSourceBindings.d.ts +2 -10
  70. package/dist/protocol/dataSources/{collectionPointer.d.ts → dataSourcePointer.d.ts} +2 -2
  71. package/dist/protocol/dataSources/{collectionPointer.js → dataSourcePointer.js} +1 -1
  72. package/dist/protocol/dataSources/{collectionSchema.d.ts → dataSourceSchema.d.ts} +2 -10
  73. package/dist/protocol/dataSources/{collectionSchema.js → dataSourceSchema.js} +1 -1
  74. package/dist/protocol/dataSources/filters/bridgeDataSourceFilter.d.ts +1458 -12
  75. package/dist/protocol/dataSources/filters/bridgeDataSourceFilterCondition.d.ts +729 -6
  76. package/dist/protocol/dataSources/filters/bridgeDataSourceFilterCondition.js +14 -2
  77. package/dist/protocol/dataSources/filters/peopleFilterOperator.d.ts +3 -3
  78. package/dist/protocol/dataSources/filters/peopleFilterOperator.js +1 -1
  79. package/dist/protocol/dataSources/filters/timestampFilterOperator.d.ts +354 -0
  80. package/dist/protocol/dataSources/filters/timestampFilterOperator.js +4 -0
  81. package/dist/protocol/dataSources/messages/dataSourcesChanged.d.ts +2 -10
  82. package/dist/protocol/dataSources/messages/queryDataSource.d.ts +1485 -38
  83. package/dist/protocol/dataSources/messages/queryDataSource.js +2 -0
  84. package/dist/protocol/dataSources/notionDataSource.d.ts +3 -19
  85. package/dist/protocol/dataSources/notionDataSource.js +5 -5
  86. package/dist/protocol/dataSources/properties/propertySchema.d.ts +4 -13
  87. package/dist/protocol/dataSources/properties/propertySchema.js +2 -6
  88. package/dist/protocol/dataSources/resolveDataSourceBinding.d.ts +4 -4
  89. package/dist/protocol/dataSources/resolveDataSourceBinding.js +2 -2
  90. package/dist/protocol/files.d.ts +32 -0
  91. package/dist/protocol/files.js +17 -0
  92. package/dist/protocol/handshake/connect.d.ts +15 -4
  93. package/dist/protocol/handshake/init.d.ts +23 -14
  94. package/dist/protocol/icons.d.ts +32 -0
  95. package/dist/protocol/icons.js +39 -0
  96. package/dist/protocol/index.d.ts +25 -19
  97. package/dist/protocol/index.js +15 -9
  98. package/dist/protocol/manifest/grants.d.ts +48 -0
  99. package/dist/protocol/manifest/grants.js +19 -0
  100. package/dist/protocol/manifest/manifest.d.ts +39 -16
  101. package/dist/protocol/manifest/manifest.js +17 -11
  102. package/dist/protocol/messages/hostToSandbox.d.ts +196 -177
  103. package/dist/protocol/messages/invalidHostMessage.d.ts +2 -0
  104. package/dist/protocol/messages/invalidHostMessage.js +2 -0
  105. package/dist/protocol/messages/invalidSandboxMessage.d.ts +2 -0
  106. package/dist/protocol/messages/invalidSandboxMessage.js +2 -0
  107. package/dist/protocol/messages/sandboxToHost.d.ts +1571 -50
  108. package/dist/protocol/navigation/openExternalUrl.d.ts +2 -2
  109. package/dist/protocol/pages/bridgePage.d.ts +12 -12
  110. package/dist/protocol/pages/bridgePage.js +3 -4
  111. package/dist/protocol/pages/makeBridgePage.d.ts +3 -1
  112. package/dist/protocol/pages/messages/createPage.d.ts +645 -62
  113. package/dist/protocol/pages/messages/createPage.js +27 -13
  114. package/dist/protocol/pages/messages/getPage.d.ts +38 -37
  115. package/dist/protocol/pages/messages/openPage.d.ts +2 -2
  116. package/dist/protocol/pages/messages/updatePage.d.ts +47 -48
  117. package/dist/protocol/pages/messages/updatePage.js +3 -3
  118. package/dist/protocol/pages/pageAppearance.d.ts +9 -28
  119. package/dist/protocol/pages/pageAppearance.js +11 -31
  120. package/dist/protocol/pages/properties/bridgePagePropertyMaps.d.ts +4 -20
  121. package/dist/protocol/pages/properties/bridgePagePropertyValue.d.ts +2 -10
  122. package/dist/protocol/pages/properties/bridgePagePropertyValue.js +2 -12
  123. package/dist/protocol/users/makeBridgeUser.d.ts +3 -1
  124. package/dist/protocol/users/messages/getUser.d.ts +2 -2
  125. package/dist/protocol/users/messages/listUsers.d.ts +2 -2
  126. package/dist/protocol/utils/errors.d.ts +6 -4
  127. package/dist/protocol/utils/errors.js +3 -3
  128. package/dist/protocol/utils/ids.d.ts +2 -0
  129. package/dist/protocol/utils/ids.js +1 -0
  130. package/dist/protocol/utils/protocolVersion.d.ts +3 -1
  131. package/dist/protocol/utils/protocolVersion.js +5 -1
  132. package/dist/protocol/utils/readRequestId.d.ts +2 -0
  133. package/dist/protocol/utils/readRequestId.js +7 -0
  134. package/dist/react/NotionCustomBlock.d.ts.map +1 -1
  135. package/dist/react/NotionCustomBlock.js +1 -15
  136. package/dist/users/getUser.d.ts.map +1 -1
  137. package/dist/users/getUser.js +2 -1
  138. package/dist/users/listUsers.d.ts.map +1 -1
  139. package/dist/users/listUsers.js +4 -2
  140. package/dist/utils/version.js +1 -1
  141. package/docs/data-sources.md +85 -83
  142. package/docs/deployment.md +4 -5
  143. package/docs/errors.md +47 -5
  144. package/docs/grants.md +127 -0
  145. package/docs/pages.md +105 -56
  146. package/docs/users.md +2 -2
  147. package/package.json +1 -1
  148. package/src/bridge/SandboxBridge.ts +44 -243
  149. package/src/bridge/requests.ts +138 -0
  150. package/src/dataSources/bridge/resolveDataSourceQuery.ts +24 -4
  151. package/src/dataSources/bridge/resolveDataSources.ts +4 -4
  152. package/src/dataSources/createDataSourcePage.ts +5 -1
  153. package/src/dataSources/filters/resolveFilter.ts +12 -3
  154. package/src/dataSources/filters/types.ts +7 -4
  155. package/src/dataSources/properties/resolvePropertyAddress.ts +1 -1
  156. package/src/dataSources/properties/resolvePropertyWriteMapForDataSource.ts +1 -1
  157. package/src/dataSources/resolvePageDataSource.ts +2 -2
  158. package/src/dataSources/subscribeToDataSource.ts +7 -19
  159. package/src/dataSources/types.ts +3 -0
  160. package/src/files/files.ts +5 -0
  161. package/src/files/icons.ts +9 -0
  162. package/src/index.ts +10 -11
  163. package/src/initialization/getInitBindingError.ts +2 -2
  164. package/src/manifest/types.ts +10 -4
  165. package/src/navigation/openExternalUrl.ts +5 -1
  166. package/src/pages/bridge/getPageForDataSource.ts +6 -2
  167. package/src/pages/bridge/sendCreatePageRequest.ts +5 -1
  168. package/src/pages/bridge/toNotionPageFieldsFromBridgePage.ts +0 -1
  169. package/src/pages/bridge/toNotionPagePropertyFromBridgeProperty.ts +0 -8
  170. package/src/pages/bridge/updatePage.ts +29 -9
  171. package/src/pages/createPage.ts +5 -1
  172. package/src/pages/openPage.ts +5 -1
  173. package/src/pages/properties/getPropertyByKey.ts +2 -2
  174. package/src/pages/types.ts +14 -16
  175. package/src/react/NotionCustomBlock.tsx +1 -16
  176. package/src/users/getUser.ts +5 -1
  177. package/src/users/listUsers.ts +9 -4
  178. package/dist/bridge/pendingRequests.d.ts +0 -14
  179. package/dist/bridge/pendingRequests.d.ts.map +0 -1
  180. package/dist/bridge/pendingRequests.js +0 -28
  181. package/dist/protocol/dataSources/filters/createdByFilterOperator.d.ts +0 -17
  182. package/dist/protocol/dataSources/filters/createdByFilterOperator.js +0 -11
  183. package/dist/protocol/manifest/capabilities.d.ts +0 -37
  184. package/dist/protocol/manifest/capabilities.js +0 -13
  185. package/dist/protocol/pages/properties/fileInput.d.ts +0 -16
  186. package/dist/protocol/pages/properties/fileInput.js +0 -16
  187. package/dist/react/DebugMessageLog.d.ts +0 -2
  188. package/dist/react/DebugMessageLog.d.ts.map +0 -1
  189. package/dist/react/DebugMessageLog.js +0 -23
  190. package/docs/capabilities.md +0 -111
  191. package/src/bridge/pendingRequests.ts +0 -28
  192. package/src/react/DebugMessageLog.tsx +0 -34
@@ -1,34 +1,14 @@
1
1
  import * as v from "valibot";
2
- export const notionEmojiIconSchema = v.object({
3
- type: v.literal("emoji"),
4
- emoji: v.string(),
5
- });
6
- export const notionCustomEmojiIconSchema = v.object({
7
- type: v.literal("custom_emoji"),
8
- custom_emoji: v.object({
9
- id: v.string(),
10
- name: v.optional(v.string()),
11
- url: v.optional(v.string()),
12
- }),
13
- });
14
- export const notionExternalFileSchema = v.object({
15
- type: v.literal("external"),
16
- external: v.object({ url: v.string() }),
17
- });
18
- export const notionHostedFileSchema = v.object({
19
- type: v.literal("file"),
20
- file: v.object({
21
- url: v.string(),
22
- expiry_time: v.optional(v.string()),
23
- }),
24
- });
25
- export const notionPageIconSchema = v.variant("type", [
26
- notionEmojiIconSchema,
27
- notionCustomEmojiIconSchema,
28
- notionExternalFileSchema,
29
- notionHostedFileSchema,
2
+ import { bridgeExternalFileSchema, bridgeNotionHostedFileSchema, } from "../files.js";
3
+ import { bridgeCustomEmojiSchema, bridgeEmojiSchema, bridgeIconSchema, } from "../icons.js";
4
+ export const bridgePageIconSchema = v.variant("type", [
5
+ bridgeIconSchema,
6
+ bridgeEmojiSchema,
7
+ bridgeCustomEmojiSchema,
8
+ bridgeExternalFileSchema,
9
+ bridgeNotionHostedFileSchema,
30
10
  ]);
31
- export const notionPageCoverSchema = v.variant("type", [
32
- notionExternalFileSchema,
33
- notionHostedFileSchema,
11
+ export const bridgePageCoverSchema = v.variant("type", [
12
+ bridgeExternalFileSchema,
13
+ bridgeNotionHostedFileSchema,
34
14
  ]);
@@ -138,17 +138,17 @@ export declare const bridgePagePropertyWriteMapSchema: v.RecordSchema<v.StringSc
138
138
  readonly type: v.LiteralSchema<"files", undefined>;
139
139
  readonly files: v.ArraySchema<v.UnionSchema<[v.ObjectSchema<{
140
140
  readonly type: v.LiteralSchema<"external", undefined>;
141
- readonly name: v.StringSchema<undefined>;
142
141
  readonly external: v.ObjectSchema<{
143
142
  readonly url: v.StringSchema<undefined>;
144
143
  }, undefined>;
144
+ readonly name: v.StringSchema<undefined>;
145
145
  }, undefined>, v.ObjectSchema<{
146
146
  readonly type: v.LiteralSchema<"file", undefined>;
147
- readonly name: v.StringSchema<undefined>;
148
147
  readonly file: v.ObjectSchema<{
149
148
  readonly url: v.StringSchema<undefined>;
150
149
  readonly expiry_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
151
150
  }, undefined>;
151
+ readonly name: v.StringSchema<undefined>;
152
152
  }, undefined>], undefined>, undefined>;
153
153
  }, undefined>, v.ObjectSchema<{
154
154
  readonly id: v.StringSchema<undefined>;
@@ -185,10 +185,6 @@ export declare const bridgePagePropertyWriteMapSchema: v.RecordSchema<v.StringSc
185
185
  readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
186
186
  readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
187
187
  }, undefined>, undefined>;
188
- }, undefined>, v.ObjectSchema<{
189
- readonly id: v.StringSchema<undefined>;
190
- readonly type: v.LiteralSchema<"last_visited_time", undefined>;
191
- readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
192
188
  }, undefined>, v.ObjectSchema<{
193
189
  readonly id: v.StringSchema<undefined>;
194
190
  readonly type: v.LiteralSchema<"unique_id", undefined>;
@@ -201,10 +197,6 @@ export declare const bridgePagePropertyWriteMapSchema: v.RecordSchema<v.StringSc
201
197
  readonly id: v.StringSchema<undefined>;
202
198
  readonly type: v.LiteralSchema<"formula", undefined>;
203
199
  readonly formula: v.StringSchema<undefined>;
204
- }, undefined>, v.ObjectSchema<{
205
- readonly id: v.StringSchema<undefined>;
206
- readonly type: v.LiteralSchema<"location", undefined>;
207
- readonly location: v.StringSchema<undefined>;
208
200
  }, undefined>, v.ObjectSchema<{
209
201
  readonly id: v.StringSchema<undefined>;
210
202
  readonly type: v.LiteralSchema<"rollup", undefined>;
@@ -353,17 +345,17 @@ export declare const bridgePagePropertyReadMapSchema: v.RecordSchema<v.StringSch
353
345
  readonly type: v.LiteralSchema<"files", undefined>;
354
346
  readonly files: v.ArraySchema<v.UnionSchema<[v.ObjectSchema<{
355
347
  readonly type: v.LiteralSchema<"external", undefined>;
356
- readonly name: v.StringSchema<undefined>;
357
348
  readonly external: v.ObjectSchema<{
358
349
  readonly url: v.StringSchema<undefined>;
359
350
  }, undefined>;
351
+ readonly name: v.StringSchema<undefined>;
360
352
  }, undefined>, v.ObjectSchema<{
361
353
  readonly type: v.LiteralSchema<"file", undefined>;
362
- readonly name: v.StringSchema<undefined>;
363
354
  readonly file: v.ObjectSchema<{
364
355
  readonly url: v.StringSchema<undefined>;
365
356
  readonly expiry_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
366
357
  }, undefined>;
358
+ readonly name: v.StringSchema<undefined>;
367
359
  }, undefined>], undefined>, undefined>;
368
360
  }, undefined>, v.ObjectSchema<{
369
361
  readonly id: v.StringSchema<undefined>;
@@ -400,10 +392,6 @@ export declare const bridgePagePropertyReadMapSchema: v.RecordSchema<v.StringSch
400
392
  readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
401
393
  readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
402
394
  }, undefined>, undefined>;
403
- }, undefined>, v.ObjectSchema<{
404
- readonly id: v.StringSchema<undefined>;
405
- readonly type: v.LiteralSchema<"last_visited_time", undefined>;
406
- readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
407
395
  }, undefined>, v.ObjectSchema<{
408
396
  readonly id: v.StringSchema<undefined>;
409
397
  readonly type: v.LiteralSchema<"unique_id", undefined>;
@@ -416,10 +404,6 @@ export declare const bridgePagePropertyReadMapSchema: v.RecordSchema<v.StringSch
416
404
  readonly id: v.StringSchema<undefined>;
417
405
  readonly type: v.LiteralSchema<"formula", undefined>;
418
406
  readonly formula: v.StringSchema<undefined>;
419
- }, undefined>, v.ObjectSchema<{
420
- readonly id: v.StringSchema<undefined>;
421
- readonly type: v.LiteralSchema<"location", undefined>;
422
- readonly location: v.StringSchema<undefined>;
423
407
  }, undefined>, v.ObjectSchema<{
424
408
  readonly id: v.StringSchema<undefined>;
425
409
  readonly type: v.LiteralSchema<"rollup", undefined>;
@@ -138,17 +138,17 @@ export declare const bridgePagePropertyValueSchema: v.VariantSchema<"type", [v.O
138
138
  readonly type: v.LiteralSchema<"files", undefined>;
139
139
  readonly files: v.ArraySchema<v.UnionSchema<[v.ObjectSchema<{
140
140
  readonly type: v.LiteralSchema<"external", undefined>;
141
- readonly name: v.StringSchema<undefined>;
142
141
  readonly external: v.ObjectSchema<{
143
142
  readonly url: v.StringSchema<undefined>;
144
143
  }, undefined>;
144
+ readonly name: v.StringSchema<undefined>;
145
145
  }, undefined>, v.ObjectSchema<{
146
146
  readonly type: v.LiteralSchema<"file", undefined>;
147
- readonly name: v.StringSchema<undefined>;
148
147
  readonly file: v.ObjectSchema<{
149
148
  readonly url: v.StringSchema<undefined>;
150
149
  readonly expiry_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
151
150
  }, undefined>;
151
+ readonly name: v.StringSchema<undefined>;
152
152
  }, undefined>], undefined>, undefined>;
153
153
  }, undefined>, v.ObjectSchema<{
154
154
  readonly id: v.StringSchema<undefined>;
@@ -185,10 +185,6 @@ export declare const bridgePagePropertyValueSchema: v.VariantSchema<"type", [v.O
185
185
  readonly table: v.PicklistSchema<["notion_user", "bot", "organization_bot"], undefined>;
186
186
  readonly spaceId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
187
187
  }, undefined>, undefined>;
188
- }, undefined>, v.ObjectSchema<{
189
- readonly id: v.StringSchema<undefined>;
190
- readonly type: v.LiteralSchema<"last_visited_time", undefined>;
191
- readonly last_visited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
192
188
  }, undefined>, v.ObjectSchema<{
193
189
  readonly id: v.StringSchema<undefined>;
194
190
  readonly type: v.LiteralSchema<"unique_id", undefined>;
@@ -201,10 +197,6 @@ export declare const bridgePagePropertyValueSchema: v.VariantSchema<"type", [v.O
201
197
  readonly id: v.StringSchema<undefined>;
202
198
  readonly type: v.LiteralSchema<"formula", undefined>;
203
199
  readonly formula: v.StringSchema<undefined>;
204
- }, undefined>, v.ObjectSchema<{
205
- readonly id: v.StringSchema<undefined>;
206
- readonly type: v.LiteralSchema<"location", undefined>;
207
- readonly location: v.StringSchema<undefined>;
208
200
  }, undefined>, v.ObjectSchema<{
209
201
  readonly id: v.StringSchema<undefined>;
210
202
  readonly type: v.LiteralSchema<"rollup", undefined>;
@@ -1,7 +1,7 @@
1
1
  import * as v from "valibot";
2
+ import { bridgeFilePropertyItemSchema } from "../../files.js";
2
3
  import { nullableStringSchema } from "../../utils/nullableStringSchema.js";
3
4
  import { notionDateInputSchema } from "./dateInput.js";
4
- import { notionFileInputSchema } from "./fileInput.js";
5
5
  import { metadataActorSchema } from "./metadataActor.js";
6
6
  import { notionPlaceInputSchema } from "./placeInput.js";
7
7
  import { notionRelationInputSchema } from "./relationInput.js";
@@ -79,7 +79,7 @@ export const bridgePagePropertyValueSchema = v.variant("type", [
79
79
  v.object({
80
80
  ...pagePropertyBaseSchema,
81
81
  type: v.literal("files"),
82
- files: v.array(notionFileInputSchema),
82
+ files: v.array(bridgeFilePropertyItemSchema),
83
83
  }),
84
84
  v.object({
85
85
  ...pagePropertyBaseSchema,
@@ -106,11 +106,6 @@ export const bridgePagePropertyValueSchema = v.variant("type", [
106
106
  type: v.literal("last_edited_by"),
107
107
  last_edited_by: metadataActorSchema,
108
108
  }),
109
- v.object({
110
- ...pagePropertyBaseSchema,
111
- type: v.literal("last_visited_time"),
112
- last_visited_time: nullableStringSchema,
113
- }),
114
109
  v.object({
115
110
  ...pagePropertyBaseSchema,
116
111
  type: v.literal("unique_id"),
@@ -126,11 +121,6 @@ export const bridgePagePropertyValueSchema = v.variant("type", [
126
121
  type: v.literal("formula"),
127
122
  formula: v.string(),
128
123
  }),
129
- v.object({
130
- ...pagePropertyBaseSchema,
131
- type: v.literal("location"),
132
- location: v.string(),
133
- }),
134
124
  v.object({
135
125
  ...pagePropertyBaseSchema,
136
126
  type: v.literal("rollup"),
@@ -1,4 +1,6 @@
1
+ import * as v from "valibot";
1
2
  import type { BridgeUser } from "./bridgeUser.js";
2
- export type MakeBridgeUserArgs = Pick<BridgeUser, "id" | "person"> & Partial<Omit<BridgeUser, "object" | "type" | "id" | "person">>;
3
+ import { bridgeUserSchema } from "./bridgeUser.js";
4
+ export type MakeBridgeUserArgs = Pick<v.InferInput<typeof bridgeUserSchema>, "id" | "person"> & Partial<Omit<v.InferInput<typeof bridgeUserSchema>, "object" | "type" | "id" | "person">>;
3
5
  /** Builds the shared person-user payload; callers supply identity and profile data. */
4
6
  export declare function makeBridgeUser(args: MakeBridgeUserArgs): BridgeUser;
@@ -1,7 +1,7 @@
1
1
  import * as v from "valibot";
2
- import type { CustomBlockCapabilityErrorCode, CustomBlockErrorCode, CustomBlockErrorInfo } from "../../utils/errors.js";
2
+ import type { CustomBlockErrorCode, CustomBlockErrorInfo, CustomBlockGrantErrorCode, CustomBlockRequestErrorCode } from "../../utils/errors.js";
3
3
  export declare const customBlockGetUserErrorCodeSchema: v.StringSchema<undefined>;
4
- export type CustomBlockGetUserErrorCode = CustomBlockErrorCode<"get_user_failed" | CustomBlockCapabilityErrorCode>;
4
+ export type CustomBlockGetUserErrorCode = CustomBlockErrorCode<CustomBlockRequestErrorCode | "get_user_failed" | CustomBlockGrantErrorCode>;
5
5
  export type CustomBlockGetUserErrorInfo = CustomBlockErrorInfo<CustomBlockGetUserErrorCode>;
6
6
  export declare const customBlockGetUserErrorInfoSchema: v.ObjectSchema<{
7
7
  readonly code: v.StringSchema<undefined>;
@@ -1,7 +1,7 @@
1
1
  import * as v from "valibot";
2
- import type { CustomBlockCapabilityErrorCode, CustomBlockErrorCode, CustomBlockErrorInfo } from "../../utils/errors.js";
2
+ import type { CustomBlockErrorCode, CustomBlockErrorInfo, CustomBlockGrantErrorCode, CustomBlockRequestErrorCode } from "../../utils/errors.js";
3
3
  export declare const customBlockListUsersErrorCodeSchema: v.StringSchema<undefined>;
4
- export type CustomBlockListUsersErrorCode = CustomBlockErrorCode<"list_users_failed" | CustomBlockCapabilityErrorCode>;
4
+ export type CustomBlockListUsersErrorCode = CustomBlockErrorCode<CustomBlockRequestErrorCode | "list_users_failed" | CustomBlockGrantErrorCode>;
5
5
  export type CustomBlockListUsersErrorInfo = CustomBlockErrorInfo<CustomBlockListUsersErrorCode>;
6
6
  export declare const customBlockListUsersErrorInfoSchema: v.ObjectSchema<{
7
7
  readonly code: v.StringSchema<undefined>;
@@ -1,11 +1,11 @@
1
1
  import * as v from "valibot";
2
2
  export type CustomBlockErrorCode<KnownCode extends string> = KnownCode | "unknown_error" | (string & {});
3
3
  /**
4
- * Reserved for a request that needs a capability the block did not declare or
5
- * the viewer did not grant. No host sends it yet.
4
+ * Reserved for a request that needs a grant the block did not declare or the
5
+ * viewer did not approve. No host sends it yet.
6
6
  */
7
- export declare const CAPABILITY_NOT_GRANTED_ERROR_CODE = "capability_not_granted";
8
- export type CustomBlockCapabilityErrorCode = typeof CAPABILITY_NOT_GRANTED_ERROR_CODE;
7
+ export declare const NOT_GRANTED_ERROR_CODE = "not_granted";
8
+ export type CustomBlockGrantErrorCode = typeof NOT_GRANTED_ERROR_CODE;
9
9
  export type CustomBlockErrorInfo<TCode extends string = string> = {
10
10
  code: TCode;
11
11
  message: string;
@@ -16,3 +16,5 @@ export declare const customBlockErrorInfoSchema: v.ObjectSchema<{
16
16
  readonly message: v.StringSchema<undefined>;
17
17
  readonly isRetryable: v.BooleanSchema<undefined>;
18
18
  }, undefined>;
19
+ /** Failures shared by one-shot requests. */
20
+ export type CustomBlockRequestErrorCode = CustomBlockErrorCode<"request_timeout" | "request_send_failed" | "request_disposed" | "invalid_host_message" | "invalid_sandbox_message" | "unsupported_operation">;
@@ -1,9 +1,9 @@
1
1
  import * as v from "valibot";
2
2
  /**
3
- * Reserved for a request that needs a capability the block did not declare or
4
- * the viewer did not grant. No host sends it yet.
3
+ * Reserved for a request that needs a grant the block did not declare or the
4
+ * viewer did not approve. No host sends it yet.
5
5
  */
6
- export const CAPABILITY_NOT_GRANTED_ERROR_CODE = "capability_not_granted";
6
+ export const NOT_GRANTED_ERROR_CODE = "not_granted";
7
7
  export const customBlockErrorInfoSchema = v.object({
8
8
  code: v.string(),
9
9
  message: v.string(),
@@ -29,3 +29,5 @@ export type NotionAgentId = v.InferOutput<typeof notionAgentIdSchema>;
29
29
  */
30
30
  export declare const notionSpaceIdSchema: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionSpaceId">]>;
31
31
  export type NotionSpaceId = v.InferOutput<typeof notionSpaceIdSchema>;
32
+ export declare const notionAppInstallationIdSchema: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionAppInstallationId">]>;
33
+ export type NotionAppInstallationId = v.InferOutput<typeof notionAppInstallationIdSchema>;
@@ -24,3 +24,4 @@ export const notionAgentIdSchema = v.pipe(v.string(), v.brand("NotionAgentId"));
24
24
  * but the brand keeps space IDs from being accidentally mixed with other IDs in TypeScript.
25
25
  */
26
26
  export const notionSpaceIdSchema = v.pipe(v.string(), v.brand("NotionSpaceId"));
27
+ export const notionAppInstallationIdSchema = v.pipe(v.string(), v.brand("NotionAppInstallationId"));
@@ -3,6 +3,8 @@
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 = 8;
6
+ export declare const LATEST_BRIDGE_PROTOCOL_VERSION = 11;
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;
10
+ export declare const DATA_SOURCE_NAMING_PROTOCOL_VERSION = 11;
@@ -3,9 +3,13 @@
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 = 8;
6
+ export const LATEST_BRIDGE_PROTOCOL_VERSION = 11;
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;
14
+ // Protocol 11 renames binding fields to data-source terminology.
15
+ export const DATA_SOURCE_NAMING_PROTOCOL_VERSION = 11;
@@ -0,0 +1,2 @@
1
+ /** Reads correlation without accepting the rest of an invalid message. */
2
+ export declare function readRequestId(data: unknown): string | undefined;
@@ -0,0 +1,7 @@
1
+ import * as v from "valibot";
2
+ const requestIdentitySchema = v.object({ requestId: v.string() });
3
+ /** Reads correlation without accepting the rest of an invalid message. */
4
+ export function readRequestId(data) {
5
+ const result = v.safeParse(requestIdentitySchema, data);
6
+ return result.success ? result.output.requestId : undefined;
7
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"NotionCustomBlock.d.ts","sourceRoot":"","sources":["../../src/react/NotionCustomBlock.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAQtC,OAAO,iCAAiC,CAAA;AAExC;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACpC,QAAQ,EAAE,SAAS,CAAA;IACnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB;;;;OAIG;IACH,aAAa,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,KAAK,SAAS,CAAC,CAAA;CACzD,CAAA;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAAC,EACjC,QAAQ,EACR,QAAe,EACf,aAAa,GACb,EAAE,sBAAsB,+BAkDxB"}
1
+ {"version":3,"file":"NotionCustomBlock.d.ts","sourceRoot":"","sources":["../../src/react/NotionCustomBlock.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAOtC,OAAO,iCAAiC,CAAA;AAExC;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACpC,QAAQ,EAAE,SAAS,CAAA;IACnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB;;;;OAIG;IACH,aAAa,CAAC,EAAE,SAAS,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,KAAK,SAAS,CAAC,CAAA;CACzD,CAAA;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAAC,EACjC,QAAQ,EACR,QAAe,EACf,aAAa,GACb,EAAE,sBAAsB,+BAoCxB"}
@@ -1,9 +1,8 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useEffect, useLayoutEffect, useState } from "react";
2
+ import { useEffect, useLayoutEffect } from "react";
3
3
  import { getBridge } from "../bridge/getBridge.js";
4
4
  import { useCustomBlockInit } from "../initialization/react/useCustomBlockInit.js";
5
5
  import { autoResize } from "../layout/autoResize.js";
6
- import { DebugMessageLog } from "./DebugMessageLog.js";
7
6
  import { InitializationErrorDetails } from "./InitializationErrorDetails.js";
8
7
  import { MissingHostScreen } from "./MissingHostScreen.js";
9
8
  import "./InitializationErrorScreen.css";
@@ -27,7 +26,6 @@ import "./InitializationErrorScreen.css";
27
26
  */
28
27
  export function NotionCustomBlock({ children, fallback = null, errorFallback, }) {
29
28
  const init = useCustomBlockInit();
30
- const [debugOpen, setDebugOpen] = useState(false);
31
29
  // Keep the host iframe height in sync with the block's content after initialization.
32
30
  useEffect(() => {
33
31
  if (!init.isLoaded || typeof window === "undefined") {
@@ -35,15 +33,6 @@ export function NotionCustomBlock({ children, fallback = null, errorFallback, })
35
33
  }
36
34
  return autoResize({ target: document.getElementById("root") });
37
35
  }, [init.isLoaded]);
38
- useEffect(() => {
39
- const onKeyDown = (e) => {
40
- if (e.key === "\\") {
41
- setDebugOpen(prev => !prev);
42
- }
43
- };
44
- window.addEventListener("keydown", onKeyDown);
45
- return () => window.removeEventListener("keydown", onKeyDown);
46
- }, []);
47
36
  useLayoutEffect(() => {
48
37
  if (!init.isLoaded) {
49
38
  return;
@@ -52,9 +41,6 @@ export function NotionCustomBlock({ children, fallback = null, errorFallback, })
52
41
  // height to the host as part of the `initResult` message.
53
42
  getBridge().completeInitialization();
54
43
  }, [init.isLoaded]);
55
- if (debugOpen) {
56
- return _jsx(DebugMessageLog, {});
57
- }
58
44
  if (init.error) {
59
45
  if (errorFallback === undefined) {
60
46
  return _jsx(DefaultInitErrorFallback, { error: init.error });
@@ -1 +1 @@
1
- {"version":3,"file":"getUser.d.ts","sourceRoot":"","sources":["../../src/users/getUser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kDAAkD,CAAA;AAGpF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE/C;;GAEG;AACH,wBAAsB,OAAO,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC,CAK1E"}
1
+ {"version":3,"file":"getUser.d.ts","sourceRoot":"","sources":["../../src/users/getUser.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kDAAkD,CAAA;AAGpF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE/C;;GAEG;AACH,wBAAsB,OAAO,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC,CAQ1E"}
@@ -1,10 +1,11 @@
1
+ import { getUserResultMessageSchema } from "../protocol/users/messages/getUser.js";
1
2
  import { getBridge } from "../bridge/getBridge.js";
2
3
  import { toNotionUserFromBridgeUser } from "./bridge/toNotionUserFromBridgeUser.js";
3
4
  /**
4
5
  * Fetches a user by id.
5
6
  */
6
7
  export async function getUser(userId) {
7
- const result = await getBridge().requestGetUser({ userId });
8
+ const result = await getBridge().request({ type: "getUser", userId }, getUserResultMessageSchema);
8
9
  return result.status === "error"
9
10
  ? result
10
11
  : { status: "success", user: toNotionUserFromBridgeUser(result.user) };
@@ -1 +1 @@
1
- {"version":3,"file":"listUsers.d.ts","sourceRoot":"","sources":["../../src/users/listUsers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEhE;;GAEG;AACH,wBAAsB,SAAS,CAC9B,KAAK,GAAE,aAAkB,GACvB,OAAO,CAAC,eAAe,CAAC,CAa1B"}
1
+ {"version":3,"file":"listUsers.d.ts","sourceRoot":"","sources":["../../src/users/listUsers.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEhE;;GAEG;AACH,wBAAsB,SAAS,CAC9B,KAAK,GAAE,aAAkB,GACvB,OAAO,CAAC,eAAe,CAAC,CAiB1B"}
@@ -1,13 +1,15 @@
1
+ import { listUsersResultMessageSchema } from "../protocol/users/messages/listUsers.js";
1
2
  import { getBridge } from "../bridge/getBridge.js";
2
3
  import { toNotionUserFromBridgeUser } from "./bridge/toNotionUserFromBridgeUser.js";
3
4
  /**
4
5
  * Lists users visible in the current custom block workspace.
5
6
  */
6
7
  export async function listUsers(input = {}) {
7
- const result = await getBridge().requestListUsers({
8
+ const result = await getBridge().request({
9
+ type: "listUsers",
8
10
  startCursor: input.startCursor,
9
11
  pageSize: input.pageSize,
10
- });
12
+ }, listUsersResultMessageSchema);
11
13
  return result.status === "error"
12
14
  ? result
13
15
  : {
@@ -4,4 +4,4 @@
4
4
  *
5
5
  * WARNING: Generated during SDK publish. Do not edit in the published package.
6
6
  */
7
- export const CUSTOM_BLOCKS_SDK_VERSION = "0.3.5"
7
+ export const CUSTOM_BLOCKS_SDK_VERSION = "0.5.0"