@notionhq/custom-blocks-host 0.4.3 → 0.5.1

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 (41) hide show
  1. package/README.md +7 -0
  2. package/dist/browser.js +1 -1
  3. package/dist/context/initialState.d.ts +5 -13
  4. package/dist/context/initialState.d.ts.map +1 -1
  5. package/dist/createCustomBlockHost.d.ts +22 -11
  6. package/dist/createCustomBlockHost.d.ts.map +1 -1
  7. package/dist/createCustomBlockHost.js +9 -4
  8. package/dist/dataSources/types.d.ts +7 -3
  9. package/dist/dataSources/types.d.ts.map +1 -1
  10. package/dist/index.d.ts +5 -4
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/manifest/types.d.ts +3 -7
  13. package/dist/manifest/types.d.ts.map +1 -1
  14. package/dist/messages/handlers.d.ts +10 -9
  15. package/dist/messages/handlers.d.ts.map +1 -1
  16. package/dist/messages/result.d.ts +12 -0
  17. package/dist/messages/result.d.ts.map +1 -0
  18. package/dist/messages/result.js +1 -0
  19. package/dist/navigation/types.d.ts +1 -3
  20. package/dist/navigation/types.d.ts.map +1 -1
  21. package/dist/pages/types.d.ts +12 -14
  22. package/dist/pages/types.d.ts.map +1 -1
  23. package/dist/protocol/context/parent.d.ts +2 -0
  24. package/dist/protocol/index.d.ts +1 -1
  25. package/dist/protocol/pages/makeBridgePage.d.ts +3 -1
  26. package/dist/protocol/users/makeBridgeUser.d.ts +3 -1
  27. package/dist/users/types.d.ts +11 -5
  28. package/dist/users/types.d.ts.map +1 -1
  29. package/docs/handlers.md +15 -7
  30. package/docs/lifecycle.md +14 -0
  31. package/package.json +1 -1
  32. package/src/context/initialState.ts +7 -16
  33. package/src/createCustomBlockHost.ts +40 -21
  34. package/src/dataSources/types.ts +8 -11
  35. package/src/index.ts +5 -6
  36. package/src/manifest/types.ts +4 -4
  37. package/src/messages/handlers.ts +11 -19
  38. package/src/messages/result.ts +11 -0
  39. package/src/navigation/types.ts +1 -11
  40. package/src/pages/types.ts +13 -46
  41. package/src/users/types.ts +12 -21
@@ -1,50 +1,10 @@
1
- import type { BridgeMessagePayload } from "@notionhq/custom-blocks-protocol/messages/messagePayload.js"
2
- import type {
3
- CustomBlockCreatePageErrorInfo,
4
- createPageMessageSchema,
5
- createPageResultMessageSchema,
6
- } from "@notionhq/custom-blocks-protocol/pages/messages/createPage.js"
7
- import type {
8
- CustomBlockGetPageErrorInfo,
9
- getPageMessageSchema,
10
- getPageResultMessageSchema,
11
- } from "@notionhq/custom-blocks-protocol/pages/messages/getPage.js"
12
- import type {
13
- CustomBlockOpenPageErrorInfo,
14
- openPageMessageSchema,
15
- openPageResultMessageSchema,
16
- } from "@notionhq/custom-blocks-protocol/pages/messages/openPage.js"
17
- import type {
18
- CustomBlockUpdatePageErrorInfo,
19
- updatePageMessageSchema,
20
- updatePageResultMessageSchema,
21
- } from "@notionhq/custom-blocks-protocol/pages/messages/updatePage.js"
1
+ import type { BridgePage } from "@notionhq/custom-blocks-protocol/pages/bridgePage.js"
2
+ import type { createPageMessageSchema } from "@notionhq/custom-blocks-protocol/pages/messages/createPage.js"
3
+ import type { getPageMessageSchema } from "@notionhq/custom-blocks-protocol/pages/messages/getPage.js"
4
+ import type { openPageMessageSchema } from "@notionhq/custom-blocks-protocol/pages/messages/openPage.js"
5
+ import type { updatePageMessageSchema } from "@notionhq/custom-blocks-protocol/pages/messages/updatePage.js"
22
6
  import type { InferInput } from "valibot"
23
-
24
- /**
25
- * Host results use InferInput so adapters can return plain string IDs.
26
- * The runtime validates results before sending them and assigns protocol ID brands.
27
- * Handler requests use parsed protocol types, whose IDs are already branded.
28
- */
29
- export type CustomBlockHostCreatePageResult = BridgeMessagePayload<
30
- InferInput<typeof createPageResultMessageSchema>,
31
- CustomBlockCreatePageErrorInfo
32
- >
33
-
34
- export type CustomBlockHostGetPageResult = BridgeMessagePayload<
35
- InferInput<typeof getPageResultMessageSchema>,
36
- CustomBlockGetPageErrorInfo
37
- >
38
-
39
- export type CustomBlockHostUpdatePageResult = BridgeMessagePayload<
40
- InferInput<typeof updatePageResultMessageSchema>,
41
- CustomBlockUpdatePageErrorInfo
42
- >
43
-
44
- export type CustomBlockHostOpenPageResult = BridgeMessagePayload<
45
- InferInput<typeof openPageResultMessageSchema>,
46
- CustomBlockOpenPageErrorInfo
47
- >
7
+ import type { CustomBlockHostResult } from "../messages/result.js"
48
8
 
49
9
  export type CreatePageMessageInput = InferInput<typeof createPageMessageSchema>
50
10
 
@@ -53,3 +13,10 @@ export type GetPageMessageInput = InferInput<typeof getPageMessageSchema>
53
13
  export type OpenPageMessageInput = InferInput<typeof openPageMessageSchema>
54
14
 
55
15
  export type UpdatePageMessageInput = InferInput<typeof updatePageMessageSchema>
16
+
17
+ export type CustomBlockHostPageResult = CustomBlockHostResult<{
18
+ page: BridgePage
19
+ }>
20
+ export type CustomBlockHostOpenPageResult = CustomBlockHostResult<{
21
+ pageId: string
22
+ }>
@@ -1,26 +1,17 @@
1
- import type { BridgeMessagePayload } from "@notionhq/custom-blocks-protocol/messages/messagePayload.js"
2
- import type {
3
- CustomBlockGetUserErrorInfo,
4
- getUserMessageSchema,
5
- getUserResultMessageSchema,
6
- } from "@notionhq/custom-blocks-protocol/users/messages/getUser.js"
7
- import type {
8
- CustomBlockListUsersErrorInfo,
9
- listUsersMessageSchema,
10
- listUsersResultMessageSchema,
11
- } from "@notionhq/custom-blocks-protocol/users/messages/listUsers.js"
1
+ import type { BridgeUser } from "@notionhq/custom-blocks-protocol/users/bridgeUser.js"
2
+ import type { BridgeUserList } from "@notionhq/custom-blocks-protocol/users/bridgeUserList.js"
3
+ import type { getUserMessageSchema } from "@notionhq/custom-blocks-protocol/users/messages/getUser.js"
4
+ import type { listUsersMessageSchema } from "@notionhq/custom-blocks-protocol/users/messages/listUsers.js"
12
5
  import type { InferInput } from "valibot"
13
-
14
- export type CustomBlockHostGetUserResult = BridgeMessagePayload<
15
- InferInput<typeof getUserResultMessageSchema>,
16
- CustomBlockGetUserErrorInfo
17
- >
18
-
19
- export type CustomBlockHostListUsersResult = BridgeMessagePayload<
20
- InferInput<typeof listUsersResultMessageSchema>,
21
- CustomBlockListUsersErrorInfo
22
- >
6
+ import type { CustomBlockHostResult } from "../messages/result.js"
23
7
 
24
8
  export type GetUserMessageInput = InferInput<typeof getUserMessageSchema>
25
9
 
26
10
  export type ListUsersMessageInput = InferInput<typeof listUsersMessageSchema>
11
+
12
+ export type CustomBlockHostUserResult = CustomBlockHostResult<{
13
+ user: BridgeUser
14
+ }>
15
+ export type CustomBlockHostUserListResult = CustomBlockHostResult<{
16
+ list: BridgeUserList
17
+ }>