@notionhq/custom-blocks-dev-shell 0.1.115 → 0.2.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 (139) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +92 -13
  3. package/THIRD_PARTY_LICENSES.md +133 -0
  4. package/dist/assets/index-Do-x8yIt.css +2 -0
  5. package/dist/assets/index-n0_PUieY.js +11 -0
  6. package/dist/index.html +2 -2
  7. package/dist-cli/cli/published-cli.js +8572 -51
  8. package/docs/bindings.md +17 -12
  9. package/docs/bridge/changelog.md +94 -0
  10. package/docs/bridge/protocol.md +239 -0
  11. package/docs/bridge/versioning.md +39 -0
  12. package/docs/data-sources.md +49 -36
  13. package/docs/host/README.md +193 -0
  14. package/docs/host/docs/compatibility.md +76 -0
  15. package/docs/host/docs/handlers.md +210 -0
  16. package/docs/host/docs/lifecycle.md +131 -0
  17. package/package.json +5 -3
  18. package/dist/assets/index-DXzPwq_J.js +0 -11
  19. package/dist/assets/index-E1j3FxAu.css +0 -2
  20. package/dist-cli/cli/binding-cli-flags.js +0 -33
  21. package/dist-cli/cli/binding-errors.js +0 -15
  22. package/dist-cli/cli/block-csp.js +0 -84
  23. package/dist-cli/cli/build-block-registry.js +0 -30
  24. package/dist-cli/cli/convert-values.js +0 -222
  25. package/dist-cli/cli/convert.js +0 -210
  26. package/dist-cli/cli/data-source-files.js +0 -6
  27. package/dist-cli/cli/data-sources.js +0 -114
  28. package/dist-cli/cli/dev-shell-launcher.js +0 -239
  29. package/dist-cli/cli/dev-shell-run.js +0 -72
  30. package/dist-cli/cli/errors.js +0 -12
  31. package/dist-cli/cli/launcher-bindings.js +0 -144
  32. package/dist-cli/cli/materialize.js +0 -105
  33. package/dist-cli/cli/ports.js +0 -20
  34. package/dist-cli/cli/prebuilt.js +0 -23
  35. package/dist-cli/cli/runtime-error-client.js +0 -52
  36. package/dist-cli/cli/serve-ui.js +0 -110
  37. package/dist-cli/cli/shared-server.js +0 -70
  38. package/dist-cli/cli/utils.js +0 -52
  39. package/dist-cli/cli/vite-block-server.js +0 -125
  40. package/dist-cli/cli/vite-middleware.js +0 -111
  41. package/dist-cli/cli/worker-manifest.js +0 -158
  42. package/dist-cli/protocol/contrast.d.ts +0 -4
  43. package/dist-cli/protocol/contrast.js +0 -3
  44. package/dist-cli/protocol/dataSources/dataSource.d.ts +0 -786
  45. package/dist-cli/protocol/dataSources/dataSource.js +0 -66
  46. package/dist-cli/protocol/dataSources/dataSourcePage.d.ts +0 -74
  47. package/dist-cli/protocol/dataSources/dataSourcePage.js +0 -15
  48. package/dist-cli/protocol/dataSources/dataSourceValue.d.ts +0 -66
  49. package/dist-cli/protocol/dataSources/dataSourceValue.js +0 -14
  50. package/dist-cli/protocol/dataSources/dateValue.d.ts +0 -157
  51. package/dist-cli/protocol/dataSources/dateValue.js +0 -61
  52. package/dist-cli/protocol/dataSources/errors.d.ts +0 -8
  53. package/dist-cli/protocol/dataSources/errors.js +0 -7
  54. package/dist-cli/protocol/dataSources/propertySchema.d.ts +0 -200
  55. package/dist-cli/protocol/dataSources/propertySchema.js +0 -174
  56. package/dist-cli/protocol/dataSources/recordPointer.d.ts +0 -9
  57. package/dist-cli/protocol/dataSources/recordPointer.js +0 -8
  58. package/dist-cli/protocol/dataSources/sortDirection.d.ts +0 -3
  59. package/dist-cli/protocol/dataSources/sortDirection.js +0 -2
  60. package/dist-cli/protocol/errors.d.ts +0 -12
  61. package/dist-cli/protocol/errors.js +0 -6
  62. package/dist-cli/protocol/ids.d.ts +0 -31
  63. package/dist-cli/protocol/ids.js +0 -26
  64. package/dist-cli/protocol/index.d.ts +0 -53
  65. package/dist-cli/protocol/index.js +0 -53
  66. package/dist-cli/protocol/manifest.d.ts +0 -67
  67. package/dist-cli/protocol/manifest.js +0 -36
  68. package/dist-cli/protocol/messages/connect.d.ts +0 -54
  69. package/dist-cli/protocol/messages/connect.js +0 -39
  70. package/dist-cli/protocol/messages/contrastModeChanged.d.ts +0 -7
  71. package/dist-cli/protocol/messages/contrastModeChanged.js +0 -7
  72. package/dist-cli/protocol/messages/createPage.d.ts +0 -290
  73. package/dist-cli/protocol/messages/createPage.js +0 -51
  74. package/dist-cli/protocol/messages/createPageResult.d.ts +0 -897
  75. package/dist-cli/protocol/messages/createPageResult.js +0 -43
  76. package/dist-cli/protocol/messages/currentUserChanged.d.ts +0 -18
  77. package/dist-cli/protocol/messages/currentUserChanged.js +0 -9
  78. package/dist-cli/protocol/messages/dataSourcesChanged.d.ts +0 -157
  79. package/dist-cli/protocol/messages/dataSourcesChanged.js +0 -13
  80. package/dist-cli/protocol/messages/getPage.d.ts +0 -902
  81. package/dist-cli/protocol/messages/getPage.js +0 -48
  82. package/dist-cli/protocol/messages/getUser.d.ts +0 -44
  83. package/dist-cli/protocol/messages/getUser.js +0 -32
  84. package/dist-cli/protocol/messages/hostToSandbox.d.ts +0 -4385
  85. package/dist-cli/protocol/messages/hostToSandbox.js +0 -48
  86. package/dist-cli/protocol/messages/incomingType.d.ts +0 -9
  87. package/dist-cli/protocol/messages/incomingType.js +0 -17
  88. package/dist-cli/protocol/messages/init.d.ts +0 -273
  89. package/dist-cli/protocol/messages/init.js +0 -57
  90. package/dist-cli/protocol/messages/initResult.d.ts +0 -37
  91. package/dist-cli/protocol/messages/initResult.js +0 -29
  92. package/dist-cli/protocol/messages/invalidHostMessage.d.ts +0 -14
  93. package/dist-cli/protocol/messages/invalidHostMessage.js +0 -13
  94. package/dist-cli/protocol/messages/invalidSandboxMessage.d.ts +0 -14
  95. package/dist-cli/protocol/messages/invalidSandboxMessage.js +0 -13
  96. package/dist-cli/protocol/messages/isInitHandshakeMessage.d.ts +0 -4
  97. package/dist-cli/protocol/messages/isInitHandshakeMessage.js +0 -11
  98. package/dist-cli/protocol/messages/listUsers.d.ts +0 -52
  99. package/dist-cli/protocol/messages/listUsers.js +0 -33
  100. package/dist-cli/protocol/messages/messagePayload.d.ts +0 -19
  101. package/dist-cli/protocol/messages/messagePayload.js +0 -1
  102. package/dist-cli/protocol/messages/openExternalUrl.d.ts +0 -32
  103. package/dist-cli/protocol/messages/openExternalUrl.js +0 -26
  104. package/dist-cli/protocol/messages/openPage.d.ts +0 -38
  105. package/dist-cli/protocol/messages/openPage.js +0 -34
  106. package/dist-cli/protocol/messages/pageChanged.d.ts +0 -32
  107. package/dist-cli/protocol/messages/pageChanged.js +0 -9
  108. package/dist-cli/protocol/messages/parentChanged.d.ts +0 -26
  109. package/dist-cli/protocol/messages/parentChanged.js +0 -9
  110. package/dist-cli/protocol/messages/queryDataSource.d.ts +0 -1446
  111. package/dist-cli/protocol/messages/queryDataSource.js +0 -252
  112. package/dist-cli/protocol/messages/queryDataSourceResult.d.ts +0 -686
  113. package/dist-cli/protocol/messages/queryDataSourceResult.js +0 -44
  114. package/dist-cli/protocol/messages/resize.d.ts +0 -11
  115. package/dist-cli/protocol/messages/resize.js +0 -10
  116. package/dist-cli/protocol/messages/sandboxToHost.d.ts +0 -1091
  117. package/dist-cli/protocol/messages/sandboxToHost.js +0 -33
  118. package/dist-cli/protocol/messages/themeChanged.d.ts +0 -10
  119. package/dist-cli/protocol/messages/themeChanged.js +0 -10
  120. package/dist-cli/protocol/messages/unsubscribeDataSourceQuery.d.ts +0 -10
  121. package/dist-cli/protocol/messages/unsubscribeDataSourceQuery.js +0 -9
  122. package/dist-cli/protocol/messages/updatePage.d.ts +0 -271
  123. package/dist-cli/protocol/messages/updatePage.js +0 -23
  124. package/dist-cli/protocol/messages/updatePageResult.d.ts +0 -895
  125. package/dist-cli/protocol/messages/updatePageResult.js +0 -41
  126. package/dist-cli/protocol/pages/page.d.ts +0 -1422
  127. package/dist-cli/protocol/pages/page.js +0 -318
  128. package/dist-cli/protocol/parent.d.ts +0 -32
  129. package/dist-cli/protocol/parent.js +0 -13
  130. package/dist-cli/protocol/protocolVersion.d.ts +0 -8
  131. package/dist-cli/protocol/protocolVersion.js +0 -11
  132. package/dist-cli/protocol/theme.d.ts +0 -3
  133. package/dist-cli/protocol/theme.js +0 -2
  134. package/dist-cli/protocol/users/user.d.ts +0 -32
  135. package/dist-cli/protocol/users/user.js +0 -20
  136. package/dist-cli/shared/block-registry.js +0 -28
  137. package/dist-cli/shared/data-source.js +0 -22
  138. package/dist-cli/shared/runtime-config.js +0 -10
  139. package/dist-cli/shared/sample-data-source.js +0 -12
@@ -1,48 +0,0 @@
1
- import * as v from "valibot";
2
- import { contrastModeChangedMessageSchema } from "./contrastModeChanged.js";
3
- import { createPageResultMessageLegacySchema, createPageResultMessageSchema, } from "./createPageResult.js";
4
- import { currentUserChangedMessageSchema } from "./currentUserChanged.js";
5
- import { dataSourcesChangedMessageSchema } from "./dataSourcesChanged.js";
6
- import { getPageResultMessageLegacySchema, getPageResultMessageSchema, } from "./getPage.js";
7
- import { getUserResultMessageSchema } from "./getUser.js";
8
- import { initMessageSchema } from "./init.js";
9
- import { invalidSandboxMessageSchema } from "./invalidSandboxMessage.js";
10
- import { listUsersResultMessageSchema } from "./listUsers.js";
11
- import { openExternalUrlResultMessageSchema } from "./openExternalUrl.js";
12
- import { openPageResultMessageSchema } from "./openPage.js";
13
- import { pageChangedMessageSchema } from "./pageChanged.js";
14
- import { parentChangedMessageSchema } from "./parentChanged.js";
15
- import { queryDataSourceResultMessageLegacySchema, queryDataSourceResultMessageSchema, } from "./queryDataSourceResult.js";
16
- import { themeChangedMessageSchema } from "./themeChanged.js";
17
- import { updatePageResultMessageLegacySchema, updatePageResultMessageSchema, } from "./updatePageResult.js";
18
- const baseHostToSandboxMessageSchema = v.variant("type", [
19
- initMessageSchema,
20
- themeChangedMessageSchema,
21
- contrastModeChangedMessageSchema,
22
- parentChangedMessageSchema,
23
- pageChangedMessageSchema,
24
- currentUserChangedMessageSchema,
25
- dataSourcesChangedMessageSchema,
26
- getUserResultMessageSchema,
27
- listUsersResultMessageSchema,
28
- openPageResultMessageSchema,
29
- openExternalUrlResultMessageSchema,
30
- invalidSandboxMessageSchema,
31
- ]);
32
- export const hostToSandboxMessageSchema = v.variant("type", [
33
- ...baseHostToSandboxMessageSchema.options,
34
- queryDataSourceResultMessageSchema,
35
- getPageResultMessageSchema,
36
- createPageResultMessageSchema,
37
- updatePageResultMessageSchema,
38
- ]);
39
- /**
40
- * Discriminated union of every message the host is allowed to send the sandbox.
41
- */
42
- export const hostToSandboxMessageLegacySchema = v.variant("type", [
43
- ...baseHostToSandboxMessageSchema.options,
44
- queryDataSourceResultMessageLegacySchema,
45
- getPageResultMessageLegacySchema,
46
- createPageResultMessageLegacySchema,
47
- updatePageResultMessageLegacySchema,
48
- ]);
@@ -1,9 +0,0 @@
1
- /**
2
- * Reads the `type` field off an inbound bridge message, if any.
3
- *
4
- * Used by both sides of the bridge after the canonical message schema rejects a payload. We still
5
- * want to know what type the sender claimed to be sending so we can (a) avoid NACK loops on
6
- * `invalidHostMessage` / `invalidSandboxMessage` and (b) include the type in the failure reason
7
- * for debugging.
8
- */
9
- export declare function readIncomingType(data: unknown): string | undefined;
@@ -1,17 +0,0 @@
1
- /**
2
- * Reads the `type` field off an inbound bridge message, if any.
3
- *
4
- * Used by both sides of the bridge after the canonical message schema rejects a payload. We still
5
- * want to know what type the sender claimed to be sending so we can (a) avoid NACK loops on
6
- * `invalidHostMessage` / `invalidSandboxMessage` and (b) include the type in the failure reason
7
- * for debugging.
8
- */
9
- export function readIncomingType(data) {
10
- if (typeof data === "object" &&
11
- data !== null &&
12
- "type" in data &&
13
- typeof data.type === "string") {
14
- return data.type;
15
- }
16
- return undefined;
17
- }
@@ -1,273 +0,0 @@
1
- import * as v from "valibot";
2
- import type { CustomBlockErrorCode, CustomBlockErrorInfo } from "../errors.js";
3
- import type { CustomBlockInitResultErrorCode } from "./initResult.js";
4
- export declare const customBlockInitErrorCodeSchema: v.StringSchema<undefined>;
5
- export type CustomBlockInitErrorCode = CustomBlockErrorCode<"manifest_unavailable" | "manifest_invalid" | "invalid_connect_payload" | "invalid_protocol_version" | "unsupported_protocol_version" | "init_timeout" | "context_unavailable" | "current_user_unavailable" | "initial_state_timeout" | "missing_data_source_binding" | "data_source_unavailable" | "missing_property_binding" | "invalid_property_binding">;
6
- export type CustomBlockInitErrorInfo = CustomBlockErrorInfo<CustomBlockInitErrorCode>;
7
- /**
8
- * Every initialization failure visible to block code. This combines errors
9
- * received in `init`, errors the sandbox reports in `initResult`, and failures
10
- * detected locally while running `initCustomBlock()`.
11
- */
12
- export type CustomBlockInitializationErrorCode = CustomBlockInitErrorCode | CustomBlockInitResultErrorCode | CustomBlockErrorCode<"not_in_iframe">;
13
- export type CustomBlockInitializationErrorInfo = CustomBlockErrorInfo<CustomBlockInitializationErrorCode>;
14
- export declare const customBlockInitErrorInfoSchema: v.ObjectSchema<{
15
- readonly code: v.StringSchema<undefined>;
16
- readonly message: v.StringSchema<undefined>;
17
- readonly isRetryable: v.BooleanSchema<undefined>;
18
- }, undefined>;
19
- export declare class CustomBlockInitializationError extends Error implements CustomBlockErrorInfo {
20
- constructor(error: CustomBlockInitializationErrorInfo);
21
- code: CustomBlockInitializationErrorCode;
22
- isRetryable: boolean;
23
- }
24
- /**
25
- * Initialization message sent by the host to the sandbox exactly once, in response to the
26
- * sandbox's `connect` message. The sandbox echoes `initializationId` in `initResult`. After
27
- * successful initialization, live updates flow through narrower messages
28
- * (`themeChanged`, `contrastModeChanged`, `parentChanged`, `pageChanged`,
29
- * `dataSourcesChanged`).
30
- */
31
- export declare const initMessageSchema: v.VariantSchema<"status", [v.ObjectSchema<{
32
- readonly type: v.LiteralSchema<"init", undefined>;
33
- readonly initializationId: v.StringSchema<undefined>;
34
- readonly status: v.LiteralSchema<"success", undefined>;
35
- readonly theme: v.PicklistSchema<["light", "dark"], undefined>;
36
- readonly contrastMode: v.PicklistSchema<["standard", "high"], undefined>;
37
- readonly blockId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionBlockId">]>;
38
- readonly parent: v.VariantSchema<"type", [v.ObjectSchema<{
39
- readonly type: v.LiteralSchema<"page_id", undefined>;
40
- readonly page_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
41
- }, undefined>, v.ObjectSchema<{
42
- readonly type: v.LiteralSchema<"data_source_id", undefined>;
43
- readonly data_source_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>;
44
- }, undefined>, v.ObjectSchema<{
45
- readonly type: v.LiteralSchema<"workspace", undefined>;
46
- readonly workspace: v.LiteralSchema<true, undefined>;
47
- }, undefined>, v.ObjectSchema<{
48
- readonly type: v.LiteralSchema<"block_id", undefined>;
49
- readonly block_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionBlockId">]>;
50
- }, undefined>, v.ObjectSchema<{
51
- readonly type: v.LiteralSchema<"agent_id", undefined>;
52
- readonly agent_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionAgentId">]>;
53
- }, undefined>, v.ObjectSchema<{
54
- readonly type: v.LiteralSchema<"unavailable", undefined>;
55
- }, undefined>], undefined>;
56
- readonly page: v.VariantSchema<"type", [v.ObjectSchema<{
57
- readonly type: v.LiteralSchema<"unavailable", undefined>;
58
- }, undefined>, v.ObjectSchema<{
59
- readonly type: v.LiteralSchema<"page", undefined>;
60
- readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
61
- readonly parent: v.VariantSchema<"type", [v.ObjectSchema<{
62
- readonly type: v.LiteralSchema<"page_id", undefined>;
63
- readonly page_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
64
- }, undefined>, v.ObjectSchema<{
65
- readonly type: v.LiteralSchema<"data_source_id", undefined>;
66
- readonly data_source_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>;
67
- }, undefined>, v.ObjectSchema<{
68
- readonly type: v.LiteralSchema<"workspace", undefined>;
69
- readonly workspace: v.LiteralSchema<true, undefined>;
70
- }, undefined>, v.ObjectSchema<{
71
- readonly type: v.LiteralSchema<"block_id", undefined>;
72
- readonly block_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionBlockId">]>;
73
- }, undefined>, v.ObjectSchema<{
74
- readonly type: v.LiteralSchema<"agent_id", undefined>;
75
- readonly agent_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionAgentId">]>;
76
- }, undefined>, v.ObjectSchema<{
77
- readonly type: v.LiteralSchema<"unavailable", undefined>;
78
- }, undefined>], undefined>;
79
- }, undefined>], undefined>;
80
- readonly manifest: v.ObjectSchema<{
81
- readonly version: v.LiteralSchema<1, undefined>;
82
- readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
83
- readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
84
- readonly slashCommand: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
85
- readonly icon: v.OptionalSchema<v.ObjectSchema<{
86
- readonly type: v.LiteralSchema<"emoji", undefined>;
87
- readonly emoji: v.StringSchema<undefined>;
88
- }, undefined>, undefined>;
89
- readonly dataSources: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
90
- readonly name: v.StringSchema<undefined>;
91
- readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
92
- readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
93
- readonly type: v.LiteralSchema<"emoji", undefined>;
94
- readonly emoji: v.StringSchema<undefined>;
95
- }, undefined>, v.ObjectSchema<{
96
- readonly type: v.LiteralSchema<"external", undefined>;
97
- readonly url: v.StringSchema<undefined>;
98
- }, undefined>], undefined>, undefined>;
99
- readonly properties: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
100
- readonly name: v.StringSchema<undefined>;
101
- readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
102
- readonly type: v.PicklistSchema<readonly ["title", "rich_text", "number", "checkbox", "url", "email", "phone_number", "select", "multi_select", "status", "date", "people", "files", "unique_id", "relation", "place", "formula", "rollup", "button", "verification", "last_visited_time", "location", "created_time", "last_edited_time", "created_by", "last_edited_by"], undefined>;
103
- }, undefined>, undefined>, {}>;
104
- }, undefined>, undefined>, {}>;
105
- }, undefined>;
106
- readonly dataSources: v.ObjectSchema<{
107
- readonly bindings: v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
108
- readonly collectionPointer: v.OptionalSchema<v.ObjectSchema<{
109
- readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>;
110
- readonly table: v.StringSchema<undefined>;
111
- readonly spaceId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionSpaceId">]>, undefined>;
112
- }, undefined>, undefined>;
113
- readonly collectionSchema: v.OptionalSchema<v.ObjectSchema<{
114
- readonly id: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>, undefined>;
115
- readonly propertiesById: v.RecordSchema<v.StringSchema<undefined>, v.VariantSchema<"type", [v.ObjectSchema<{
116
- readonly name: v.StringSchema<undefined>;
117
- readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
118
- readonly type: v.LiteralSchema<"title", undefined>;
119
- }, undefined>, v.ObjectSchema<{
120
- readonly name: v.StringSchema<undefined>;
121
- readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
122
- readonly type: v.LiteralSchema<"rich_text", undefined>;
123
- }, undefined>, v.ObjectSchema<{
124
- readonly name: v.StringSchema<undefined>;
125
- readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
126
- readonly type: v.LiteralSchema<"number", undefined>;
127
- }, undefined>, v.ObjectSchema<{
128
- readonly name: v.StringSchema<undefined>;
129
- readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
130
- readonly type: v.LiteralSchema<"checkbox", undefined>;
131
- }, undefined>, v.ObjectSchema<{
132
- readonly name: v.StringSchema<undefined>;
133
- readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
134
- readonly type: v.LiteralSchema<"url", undefined>;
135
- }, undefined>, v.ObjectSchema<{
136
- readonly name: v.StringSchema<undefined>;
137
- readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
138
- readonly type: v.LiteralSchema<"email", undefined>;
139
- }, undefined>, v.ObjectSchema<{
140
- readonly name: v.StringSchema<undefined>;
141
- readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
142
- readonly type: v.LiteralSchema<"phone_number", undefined>;
143
- }, undefined>, v.ObjectSchema<{
144
- readonly name: v.StringSchema<undefined>;
145
- readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
146
- readonly type: v.LiteralSchema<"select", undefined>;
147
- readonly options: v.ArraySchema<v.ObjectSchema<{
148
- readonly id: v.StringSchema<undefined>;
149
- readonly name: v.StringSchema<undefined>;
150
- readonly color: v.OptionalSchema<v.PicklistSchema<["default", "gray", "brown", "orange", "yellow", "green", "blue", "purple", "pink", "red", "gray_background", "brown_background", "orange_background", "yellow_background", "green_background", "blue_background", "purple_background", "pink_background", "red_background", "default_background"], undefined>, undefined>;
151
- readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
152
- }, undefined>, undefined>;
153
- }, undefined>, v.ObjectSchema<{
154
- readonly name: v.StringSchema<undefined>;
155
- readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
156
- readonly type: v.LiteralSchema<"multi_select", undefined>;
157
- readonly options: v.ArraySchema<v.ObjectSchema<{
158
- readonly id: v.StringSchema<undefined>;
159
- readonly name: v.StringSchema<undefined>;
160
- readonly color: v.OptionalSchema<v.PicklistSchema<["default", "gray", "brown", "orange", "yellow", "green", "blue", "purple", "pink", "red", "gray_background", "brown_background", "orange_background", "yellow_background", "green_background", "blue_background", "purple_background", "pink_background", "red_background", "default_background"], undefined>, undefined>;
161
- readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
162
- }, undefined>, undefined>;
163
- }, undefined>, v.ObjectSchema<{
164
- readonly name: v.StringSchema<undefined>;
165
- readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
166
- readonly type: v.LiteralSchema<"status", undefined>;
167
- readonly options: v.ArraySchema<v.ObjectSchema<{
168
- readonly id: v.StringSchema<undefined>;
169
- readonly name: v.StringSchema<undefined>;
170
- readonly color: v.OptionalSchema<v.PicklistSchema<["default", "gray", "brown", "orange", "yellow", "green", "blue", "purple", "pink", "red", "gray_background", "brown_background", "orange_background", "yellow_background", "green_background", "blue_background", "purple_background", "pink_background", "red_background", "default_background"], undefined>, undefined>;
171
- readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
172
- }, undefined>, undefined>;
173
- readonly groups: v.ArraySchema<v.ObjectSchema<{
174
- readonly id: v.StringSchema<undefined>;
175
- readonly name: v.StringSchema<undefined>;
176
- readonly color: v.OptionalSchema<v.PicklistSchema<["default", "gray", "brown", "orange", "yellow", "green", "blue", "purple", "pink", "red", "gray_background", "brown_background", "orange_background", "yellow_background", "green_background", "blue_background", "purple_background", "pink_background", "red_background", "default_background"], undefined>, undefined>;
177
- readonly option_ids: v.ArraySchema<v.StringSchema<undefined>, undefined>;
178
- }, undefined>, undefined>;
179
- }, undefined>, v.ObjectSchema<{
180
- readonly name: v.StringSchema<undefined>;
181
- readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
182
- readonly type: v.LiteralSchema<"date", undefined>;
183
- }, undefined>, v.ObjectSchema<{
184
- readonly name: v.StringSchema<undefined>;
185
- readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
186
- readonly type: v.LiteralSchema<"people", undefined>;
187
- }, undefined>, v.ObjectSchema<{
188
- readonly name: v.StringSchema<undefined>;
189
- readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
190
- readonly type: v.LiteralSchema<"files", undefined>;
191
- }, undefined>, v.ObjectSchema<{
192
- readonly name: v.StringSchema<undefined>;
193
- readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
194
- readonly type: v.LiteralSchema<"unique_id", undefined>;
195
- }, undefined>, v.ObjectSchema<{
196
- readonly name: v.StringSchema<undefined>;
197
- readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
198
- readonly type: v.LiteralSchema<"relation", undefined>;
199
- readonly data_source_id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
200
- readonly dual_property: v.OptionalSchema<v.ObjectSchema<{
201
- readonly synced_property_id: v.StringSchema<undefined>;
202
- readonly synced_property_name: v.StringSchema<undefined>;
203
- }, undefined>, undefined>;
204
- }, undefined>, v.ObjectSchema<{
205
- readonly name: v.StringSchema<undefined>;
206
- readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
207
- readonly type: v.LiteralSchema<"place", undefined>;
208
- }, undefined>, v.ObjectSchema<{
209
- readonly name: v.StringSchema<undefined>;
210
- readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
211
- readonly type: v.LiteralSchema<"formula", undefined>;
212
- }, undefined>, v.ObjectSchema<{
213
- readonly name: v.StringSchema<undefined>;
214
- readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
215
- readonly type: v.LiteralSchema<"rollup", undefined>;
216
- }, undefined>, v.ObjectSchema<{
217
- readonly name: v.StringSchema<undefined>;
218
- readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
219
- readonly type: v.LiteralSchema<"button", undefined>;
220
- }, undefined>, v.ObjectSchema<{
221
- readonly name: v.StringSchema<undefined>;
222
- readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
223
- readonly type: v.LiteralSchema<"verification", undefined>;
224
- }, undefined>, v.ObjectSchema<{
225
- readonly name: v.StringSchema<undefined>;
226
- readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
227
- readonly type: v.LiteralSchema<"last_visited_time", undefined>;
228
- }, undefined>, v.ObjectSchema<{
229
- readonly name: v.StringSchema<undefined>;
230
- readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
231
- readonly type: v.LiteralSchema<"location", undefined>;
232
- }, undefined>, v.ObjectSchema<{
233
- readonly name: v.StringSchema<undefined>;
234
- readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
235
- readonly type: v.LiteralSchema<"created_time", undefined>;
236
- }, undefined>, v.ObjectSchema<{
237
- readonly name: v.StringSchema<undefined>;
238
- readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
239
- readonly type: v.LiteralSchema<"last_edited_time", undefined>;
240
- }, undefined>, v.ObjectSchema<{
241
- readonly name: v.StringSchema<undefined>;
242
- readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
243
- readonly type: v.LiteralSchema<"created_by", undefined>;
244
- }, undefined>, v.ObjectSchema<{
245
- readonly name: v.StringSchema<undefined>;
246
- readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
247
- readonly type: v.LiteralSchema<"last_edited_by", undefined>;
248
- }, undefined>], undefined>, undefined>;
249
- }, undefined>, undefined>;
250
- readonly propertyIdsByKey: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.OptionalSchema<v.StringSchema<undefined>, undefined>, undefined>, undefined>;
251
- }, undefined>, undefined>;
252
- }, undefined>;
253
- readonly currentUser: v.ObjectSchema<{
254
- readonly object: v.LiteralSchema<"user", undefined>;
255
- readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionUserId">]>;
256
- readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
257
- readonly avatar_url: v.NullableSchema<v.StringSchema<undefined>, undefined>;
258
- readonly type: v.LiteralSchema<"person", undefined>;
259
- readonly person: v.ObjectSchema<{
260
- readonly email: v.StringSchema<undefined>;
261
- }, undefined>;
262
- }, undefined>;
263
- }, undefined>, v.ObjectSchema<{
264
- readonly type: v.LiteralSchema<"init", undefined>;
265
- readonly initializationId: v.StringSchema<undefined>;
266
- readonly status: v.LiteralSchema<"error", undefined>;
267
- readonly error: v.ObjectSchema<{
268
- readonly code: v.StringSchema<undefined>;
269
- readonly message: v.StringSchema<undefined>;
270
- readonly isRetryable: v.BooleanSchema<undefined>;
271
- }, undefined>;
272
- }, undefined>], undefined>;
273
- export type InitMessage = v.InferOutput<typeof initMessageSchema>;
@@ -1,57 +0,0 @@
1
- import * as v from "valibot";
2
- import { notionContrastModeSchema } from "../contrast.js";
3
- import { notionDataSourceBindingsSchema } from "../dataSources/dataSource.js";
4
- import { notionBlockIdSchema } from "../ids.js";
5
- import { manifestSchema } from "../manifest.js";
6
- import { customBlockPageSchema } from "../pages/page.js";
7
- import { notionParentSchema } from "../parent.js";
8
- import { notionThemeSchema } from "../theme.js";
9
- import { notionUserSchema } from "../users/user.js";
10
- // The schema accepts any string code. The type lists known codes for
11
- // autocomplete, with an open string fallback for newer senders.
12
- export const customBlockInitErrorCodeSchema = v.string();
13
- export const customBlockInitErrorInfoSchema = v.object({
14
- code: customBlockInitErrorCodeSchema,
15
- message: v.string(),
16
- isRetryable: v.boolean(),
17
- });
18
- export class CustomBlockInitializationError extends Error {
19
- constructor(error) {
20
- super(error.message);
21
- this.name = "CustomBlockInitializationError";
22
- this.code = error.code;
23
- this.isRetryable = error.isRetryable;
24
- }
25
- code;
26
- isRetryable;
27
- }
28
- /**
29
- * Initialization message sent by the host to the sandbox exactly once, in response to the
30
- * sandbox's `connect` message. The sandbox echoes `initializationId` in `initResult`. After
31
- * successful initialization, live updates flow through narrower messages
32
- * (`themeChanged`, `contrastModeChanged`, `parentChanged`, `pageChanged`,
33
- * `dataSourcesChanged`).
34
- */
35
- export const initMessageSchema = v.variant("status", [
36
- v.object({
37
- type: v.literal("init"),
38
- initializationId: v.string(),
39
- status: v.literal("success"),
40
- theme: notionThemeSchema,
41
- contrastMode: notionContrastModeSchema,
42
- blockId: notionBlockIdSchema,
43
- parent: notionParentSchema,
44
- page: customBlockPageSchema,
45
- manifest: manifestSchema,
46
- dataSources: v.object({
47
- bindings: notionDataSourceBindingsSchema,
48
- }),
49
- currentUser: notionUserSchema,
50
- }),
51
- v.object({
52
- type: v.literal("init"),
53
- initializationId: v.string(),
54
- status: v.literal("error"),
55
- error: customBlockInitErrorInfoSchema,
56
- }),
57
- ]);
@@ -1,37 +0,0 @@
1
- import * as v from "valibot";
2
- import type { CustomBlockErrorCode, CustomBlockErrorInfo } from "../errors.js";
3
- export declare const customBlockInitResultErrorCodeSchema: v.StringSchema<undefined>;
4
- export type CustomBlockInitResultErrorCode = CustomBlockErrorCode<
5
- /**
6
- * The host-provided bindings defined in `init.dataSources` were rejected by the sandbox because
7
- * they did not completely match the expected manifest keys.
8
- */
9
- "invalid_init_bindings"
10
- /** The host-provided `init` payload failed to parse. */
11
- | "invalid_init_payload">;
12
- export type CustomBlockInitResultErrorInfo = CustomBlockErrorInfo<CustomBlockInitResultErrorCode>;
13
- export declare const customBlockInitResultErrorInfoSchema: v.ObjectSchema<{
14
- readonly code: v.StringSchema<undefined>;
15
- readonly message: v.StringSchema<undefined>;
16
- readonly isRetryable: v.BooleanSchema<undefined>;
17
- }, undefined>;
18
- /**
19
- * Acknowledges whether the sandbox successfully applied the host's `init` response.
20
- */
21
- export declare const initResultMessageSchema: v.VariantSchema<"status", [v.ObjectSchema<{
22
- readonly type: v.LiteralSchema<"initResult", undefined>;
23
- readonly initializationId: v.StringSchema<undefined>;
24
- readonly status: v.LiteralSchema<"success", undefined>;
25
- /** Height of the initial rendered custom-block content, in CSS pixels. */
26
- readonly initialHeight: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
27
- }, undefined>, v.ObjectSchema<{
28
- readonly type: v.LiteralSchema<"initResult", undefined>;
29
- readonly initializationId: v.StringSchema<undefined>;
30
- readonly status: v.LiteralSchema<"error", undefined>;
31
- readonly error: v.ObjectSchema<{
32
- readonly code: v.StringSchema<undefined>;
33
- readonly message: v.StringSchema<undefined>;
34
- readonly isRetryable: v.BooleanSchema<undefined>;
35
- }, undefined>;
36
- }, undefined>], undefined>;
37
- export type InitResultMessage = v.InferOutput<typeof initResultMessageSchema>;
@@ -1,29 +0,0 @@
1
- import * as v from "valibot";
2
- // The schema accepts any string code. The type lists known codes for
3
- // autocomplete, with an open string fallback for newer senders.
4
- export const customBlockInitResultErrorCodeSchema = v.string();
5
- export const customBlockInitResultErrorInfoSchema = v.object({
6
- code: customBlockInitResultErrorCodeSchema,
7
- message: v.string(),
8
- isRetryable: v.boolean(),
9
- });
10
- /**
11
- * Acknowledges whether the sandbox successfully applied the host's `init` response.
12
- */
13
- export const initResultMessageSchema = v.variant("status", [
14
- v.object({
15
- type: v.literal("initResult"),
16
- initializationId: v.string(),
17
- status: v.literal("success"),
18
- /** Height of the initial rendered custom-block content, in CSS pixels. */
19
- // Older SDKs can omit the height. Current SDKs always send it.
20
- // TODO(custom-blocks): Make this required when MIN_HOST_SUPPORTED_BRIDGE_PROTOCOL_VERSION increases to 4.
21
- initialHeight: v.optional(v.pipe(v.number(), v.finite(), v.minValue(0))),
22
- }),
23
- v.object({
24
- type: v.literal("initResult"),
25
- initializationId: v.string(),
26
- status: v.literal("error"),
27
- error: customBlockInitResultErrorInfoSchema,
28
- }),
29
- ]);
@@ -1,14 +0,0 @@
1
- import * as v from "valibot";
2
- /**
3
- * Sent by the sandbox back to the host when an inbound host-to-sandbox message could not be parsed
4
- * (unknown `type`, schema mismatch, etc.). The host should never reply to an `invalidHostMessage`
5
- * with another bridge error message.
6
- */
7
- export declare const invalidHostMessageSchema: v.ObjectSchema<{
8
- readonly type: v.LiteralSchema<"invalidHostMessage", undefined>;
9
- /**
10
- * A human-readable string intended for sandbox-side logging. It has no structured contract.
11
- */
12
- readonly reason: v.StringSchema<undefined>;
13
- }, undefined>;
14
- export type InvalidHostMessage = v.InferOutput<typeof invalidHostMessageSchema>;
@@ -1,13 +0,0 @@
1
- import * as v from "valibot";
2
- /**
3
- * Sent by the sandbox back to the host when an inbound host-to-sandbox message could not be parsed
4
- * (unknown `type`, schema mismatch, etc.). The host should never reply to an `invalidHostMessage`
5
- * with another bridge error message.
6
- */
7
- export const invalidHostMessageSchema = v.object({
8
- type: v.literal("invalidHostMessage"),
9
- /**
10
- * A human-readable string intended for sandbox-side logging. It has no structured contract.
11
- */
12
- reason: v.string(),
13
- });
@@ -1,14 +0,0 @@
1
- import * as v from "valibot";
2
- /**
3
- * Sent by the host back to the sandbox when an inbound sandbox-to-host message could not be parsed
4
- * (unknown `type`, schema mismatch, etc.). The sandbox should never reply to an
5
- * `invalidSandboxMessage` with another bridge error message.
6
- */
7
- export declare const invalidSandboxMessageSchema: v.ObjectSchema<{
8
- readonly type: v.LiteralSchema<"invalidSandboxMessage", undefined>;
9
- /**
10
- * A human-readable string intended for sandbox-side logging. It has no structured contract.
11
- */
12
- readonly reason: v.StringSchema<undefined>;
13
- }, undefined>;
14
- export type InvalidSandboxMessage = v.InferOutput<typeof invalidSandboxMessageSchema>;
@@ -1,13 +0,0 @@
1
- import * as v from "valibot";
2
- /**
3
- * Sent by the host back to the sandbox when an inbound sandbox-to-host message could not be parsed
4
- * (unknown `type`, schema mismatch, etc.). The sandbox should never reply to an
5
- * `invalidSandboxMessage` with another bridge error message.
6
- */
7
- export const invalidSandboxMessageSchema = v.object({
8
- type: v.literal("invalidSandboxMessage"),
9
- /**
10
- * A human-readable string intended for sandbox-side logging. It has no structured contract.
11
- */
12
- reason: v.string(),
13
- });
@@ -1,4 +0,0 @@
1
- import type { HostToSandboxMessage } from "./hostToSandbox.js";
2
- import type { SandboxToHostMessage } from "./sandboxToHost.js";
3
- /** Returns whether a message belongs to the initialization handshake. */
4
- export declare function isInitHandshakeMessage(message: SandboxToHostMessage | HostToSandboxMessage): boolean;
@@ -1,11 +0,0 @@
1
- /** Returns whether a message belongs to the initialization handshake. */
2
- export function isInitHandshakeMessage(message) {
3
- switch (message.type) {
4
- case "connect":
5
- case "init":
6
- case "initResult":
7
- return true;
8
- default:
9
- return false;
10
- }
11
- }
@@ -1,52 +0,0 @@
1
- import * as v from "valibot";
2
- import type { CustomBlockErrorCode, CustomBlockErrorInfo } from "../errors.js";
3
- export declare const customBlockListUsersErrorCodeSchema: v.StringSchema<undefined>;
4
- export type CustomBlockListUsersErrorCode = CustomBlockErrorCode<"list_users_failed">;
5
- export type CustomBlockListUsersErrorInfo = CustomBlockErrorInfo<CustomBlockListUsersErrorCode>;
6
- export declare const customBlockListUsersErrorInfoSchema: v.ObjectSchema<{
7
- readonly code: v.StringSchema<undefined>;
8
- readonly message: v.StringSchema<undefined>;
9
- readonly isRetryable: v.BooleanSchema<undefined>;
10
- }, undefined>;
11
- /**
12
- * Sandbox -> host: list users visible in the custom block's workspace.
13
- */
14
- export declare const listUsersMessageSchema: v.ObjectSchema<{
15
- readonly type: v.LiteralSchema<"listUsers", undefined>;
16
- readonly requestId: v.StringSchema<undefined>;
17
- readonly startCursor: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
18
- readonly pageSize: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
19
- }, undefined>;
20
- export type ListUsersMessage = v.InferOutput<typeof listUsersMessageSchema>;
21
- export declare const listUsersResultMessageSchema: v.VariantSchema<"status", [v.ObjectSchema<{
22
- readonly type: v.LiteralSchema<"listUsersResult", undefined>;
23
- readonly requestId: v.StringSchema<undefined>;
24
- readonly status: v.LiteralSchema<"success", undefined>;
25
- readonly list: v.ObjectSchema<{
26
- readonly object: v.LiteralSchema<"list", undefined>;
27
- readonly results: v.ArraySchema<v.ObjectSchema<{
28
- readonly object: v.LiteralSchema<"user", undefined>;
29
- readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionUserId">]>;
30
- readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
31
- readonly avatar_url: v.NullableSchema<v.StringSchema<undefined>, undefined>;
32
- readonly type: v.LiteralSchema<"person", undefined>;
33
- readonly person: v.ObjectSchema<{
34
- readonly email: v.StringSchema<undefined>;
35
- }, undefined>;
36
- }, undefined>, undefined>;
37
- readonly next_cursor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
38
- readonly has_more: v.BooleanSchema<undefined>;
39
- readonly type: v.LiteralSchema<"user", undefined>;
40
- readonly user: v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>;
41
- }, undefined>;
42
- }, undefined>, v.ObjectSchema<{
43
- readonly type: v.LiteralSchema<"listUsersResult", undefined>;
44
- readonly requestId: v.StringSchema<undefined>;
45
- readonly status: v.LiteralSchema<"error", undefined>;
46
- readonly error: v.ObjectSchema<{
47
- readonly code: v.StringSchema<undefined>;
48
- readonly message: v.StringSchema<undefined>;
49
- readonly isRetryable: v.BooleanSchema<undefined>;
50
- }, undefined>;
51
- }, undefined>], undefined>;
52
- export type ListUsersResultMessage = v.InferOutput<typeof listUsersResultMessageSchema>;