@notionhq/custom-blocks-host 0.0.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.
- package/README.md +204 -0
- package/dist/autoBindProperties.d.ts +21 -0
- package/dist/autoBindProperties.d.ts.map +1 -0
- package/dist/autoBindProperties.js +38 -0
- package/dist/createCustomBlockHost.d.ts +46 -0
- package/dist/createCustomBlockHost.d.ts.map +1 -0
- package/dist/createCustomBlockHost.js +433 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/lifecycle/initErrors.d.ts +13 -0
- package/dist/lifecycle/initErrors.d.ts.map +1 -0
- package/dist/lifecycle/initErrors.js +152 -0
- package/dist/lifecycle/initializationController.d.ts +54 -0
- package/dist/lifecycle/initializationController.d.ts.map +1 -0
- package/dist/lifecycle/initializationController.js +182 -0
- package/dist/lifecycle/protocolVersion.d.ts +2 -0
- package/dist/lifecycle/protocolVersion.d.ts.map +1 -0
- package/dist/lifecycle/protocolVersion.js +3 -0
- package/dist/lifecycle/types.d.ts +28 -0
- package/dist/lifecycle/types.d.ts.map +1 -0
- package/dist/lifecycle/types.js +1 -0
- package/dist/messages/invalidSandboxMessage.d.ts +7 -0
- package/dist/messages/invalidSandboxMessage.d.ts.map +1 -0
- package/dist/messages/invalidSandboxMessage.js +21 -0
- package/dist/messages/types.d.ts +29 -0
- package/dist/messages/types.d.ts.map +1 -0
- package/dist/messages/types.js +1 -0
- package/dist/protocol/contrast.d.ts +4 -0
- package/dist/protocol/contrast.js +3 -0
- package/dist/protocol/dataSources/dataSource.d.ts +731 -0
- package/dist/protocol/dataSources/dataSource.js +37 -0
- package/dist/protocol/dataSources/dataSourcePage.d.ts +72 -0
- package/dist/protocol/dataSources/dataSourcePage.js +12 -0
- package/dist/protocol/dataSources/dataSourceValue.d.ts +66 -0
- package/dist/protocol/dataSources/dataSourceValue.js +14 -0
- package/dist/protocol/dataSources/dateValue.d.ts +157 -0
- package/dist/protocol/dataSources/dateValue.js +59 -0
- package/dist/protocol/dataSources/errors.d.ts +8 -0
- package/dist/protocol/dataSources/errors.js +7 -0
- package/dist/protocol/dataSources/propertySchema.d.ts +197 -0
- package/dist/protocol/dataSources/propertySchema.js +165 -0
- package/dist/protocol/dataSources/recordPointer.d.ts +9 -0
- package/dist/protocol/dataSources/recordPointer.js +8 -0
- package/dist/protocol/errors.d.ts +12 -0
- package/dist/protocol/errors.js +6 -0
- package/dist/protocol/ids.d.ts +31 -0
- package/dist/protocol/ids.js +26 -0
- package/dist/protocol/incomingType.d.ts +9 -0
- package/dist/protocol/incomingType.js +17 -0
- package/dist/protocol/index.d.ts +48 -0
- package/dist/protocol/index.js +48 -0
- package/dist/protocol/manifest.d.ts +60 -0
- package/dist/protocol/manifest.js +32 -0
- package/dist/protocol/messagePayload.d.ts +19 -0
- package/dist/protocol/messagePayload.js +1 -0
- package/dist/protocol/messages/connect.d.ts +47 -0
- package/dist/protocol/messages/connect.js +38 -0
- package/dist/protocol/messages/contrastModeChanged.d.ts +7 -0
- package/dist/protocol/messages/contrastModeChanged.js +7 -0
- package/dist/protocol/messages/createPage.d.ts +200 -0
- package/dist/protocol/messages/createPage.js +52 -0
- package/dist/protocol/messages/createPageResult.d.ts +213 -0
- package/dist/protocol/messages/createPageResult.js +28 -0
- package/dist/protocol/messages/currentUserChanged.d.ts +18 -0
- package/dist/protocol/messages/currentUserChanged.js +9 -0
- package/dist/protocol/messages/dataSourcesChanged.d.ts +157 -0
- package/dist/protocol/messages/dataSourcesChanged.js +13 -0
- package/dist/protocol/messages/getPage.d.ts +218 -0
- package/dist/protocol/messages/getPage.js +33 -0
- package/dist/protocol/messages/getUser.d.ts +44 -0
- package/dist/protocol/messages/getUser.js +32 -0
- package/dist/protocol/messages/hostToSandbox.d.ts +1167 -0
- package/dist/protocol/messages/hostToSandbox.js +34 -0
- package/dist/protocol/messages/init.d.ts +259 -0
- package/dist/protocol/messages/init.js +56 -0
- package/dist/protocol/messages/initResult.d.ts +37 -0
- package/dist/protocol/messages/initResult.js +28 -0
- package/dist/protocol/messages/invalidHostMessage.d.ts +14 -0
- package/dist/protocol/messages/invalidHostMessage.js +13 -0
- package/dist/protocol/messages/invalidSandboxMessage.d.ts +14 -0
- package/dist/protocol/messages/invalidSandboxMessage.js +13 -0
- package/dist/protocol/messages/listUsers.d.ts +52 -0
- package/dist/protocol/messages/listUsers.js +33 -0
- package/dist/protocol/messages/pageChanged.d.ts +27 -0
- package/dist/protocol/messages/pageChanged.js +9 -0
- package/dist/protocol/messages/parentChanged.d.ts +24 -0
- package/dist/protocol/messages/parentChanged.js +9 -0
- package/dist/protocol/messages/queryDataSource.d.ts +985 -0
- package/dist/protocol/messages/queryDataSource.js +123 -0
- package/dist/protocol/messages/queryDataSourceResult.d.ts +93 -0
- package/dist/protocol/messages/queryDataSourceResult.js +28 -0
- package/dist/protocol/messages/resize.d.ts +11 -0
- package/dist/protocol/messages/resize.js +10 -0
- package/dist/protocol/messages/sandboxToHost.d.ts +744 -0
- package/dist/protocol/messages/sandboxToHost.js +27 -0
- package/dist/protocol/messages/themeChanged.d.ts +10 -0
- package/dist/protocol/messages/themeChanged.js +10 -0
- package/dist/protocol/messages/updatePage.d.ts +180 -0
- package/dist/protocol/messages/updatePage.js +22 -0
- package/dist/protocol/messages/updatePageResult.d.ts +212 -0
- package/dist/protocol/messages/updatePageResult.js +27 -0
- package/dist/protocol/pages/page.d.ts +597 -0
- package/dist/protocol/pages/page.js +212 -0
- package/dist/protocol/parent.d.ts +28 -0
- package/dist/protocol/parent.js +12 -0
- package/dist/protocol/protocolVersion.d.ts +6 -0
- package/dist/protocol/protocolVersion.js +6 -0
- package/dist/protocol/theme.d.ts +3 -0
- package/dist/protocol/theme.js +2 -0
- package/dist/protocol/users/user.d.ts +32 -0
- package/dist/protocol/users/user.js +20 -0
- package/dist/queries/querySubscriptions.d.ts +17 -0
- package/dist/queries/querySubscriptions.d.ts.map +1 -0
- package/dist/queries/querySubscriptions.js +38 -0
- package/dist/queries/types.d.ts +4 -0
- package/dist/queries/types.d.ts.map +1 -0
- package/dist/queries/types.js +1 -0
- package/dist/queries/validateQueryDataSourceFilter.d.ts +5 -0
- package/dist/queries/validateQueryDataSourceFilter.d.ts.map +1 -0
- package/dist/queries/validateQueryDataSourceFilter.js +72 -0
- package/dist/queries/validateQueryDataSourceSorts.d.ts +8 -0
- package/dist/queries/validateQueryDataSourceSorts.d.ts.map +1 -0
- package/dist/queries/validateQueryDataSourceSorts.js +47 -0
- package/dist/utils.d.ts +5 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +6 -0
- package/package.json +26 -0
- package/src/autoBindProperties.ts +63 -0
- package/src/createCustomBlockHost.ts +605 -0
- package/src/index.ts +25 -0
- package/src/lifecycle/initErrors.ts +165 -0
- package/src/lifecycle/initializationController.ts +290 -0
- package/src/lifecycle/protocolVersion.ts +3 -0
- package/src/lifecycle/types.ts +40 -0
- package/src/messages/invalidSandboxMessage.ts +35 -0
- package/src/messages/types.ts +80 -0
- package/src/queries/querySubscriptions.ts +57 -0
- package/src/queries/types.ts +10 -0
- package/src/queries/validateQueryDataSourceFilter.ts +101 -0
- package/src/queries/validateQueryDataSourceSorts.ts +69 -0
- package/src/utils.ts +8 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import { contrastModeChangedMessageSchema } from "./contrastModeChanged.js";
|
|
3
|
+
import { createPageResultMessageSchema } from "./createPageResult.js";
|
|
4
|
+
import { currentUserChangedMessageSchema } from "./currentUserChanged.js";
|
|
5
|
+
import { dataSourcesChangedMessageSchema } from "./dataSourcesChanged.js";
|
|
6
|
+
import { 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 { pageChangedMessageSchema } from "./pageChanged.js";
|
|
12
|
+
import { parentChangedMessageSchema } from "./parentChanged.js";
|
|
13
|
+
import { queryDataSourceResultMessageSchema } from "./queryDataSourceResult.js";
|
|
14
|
+
import { themeChangedMessageSchema } from "./themeChanged.js";
|
|
15
|
+
import { updatePageResultMessageSchema } from "./updatePageResult.js";
|
|
16
|
+
/**
|
|
17
|
+
* Discriminated union of every message the host is allowed to send the sandbox.
|
|
18
|
+
*/
|
|
19
|
+
export const hostToSandboxMessageSchema = v.variant("type", [
|
|
20
|
+
initMessageSchema,
|
|
21
|
+
themeChangedMessageSchema,
|
|
22
|
+
contrastModeChangedMessageSchema,
|
|
23
|
+
parentChangedMessageSchema,
|
|
24
|
+
pageChangedMessageSchema,
|
|
25
|
+
currentUserChangedMessageSchema,
|
|
26
|
+
dataSourcesChangedMessageSchema,
|
|
27
|
+
queryDataSourceResultMessageSchema,
|
|
28
|
+
createPageResultMessageSchema,
|
|
29
|
+
getPageResultMessageSchema,
|
|
30
|
+
getUserResultMessageSchema,
|
|
31
|
+
listUsersResultMessageSchema,
|
|
32
|
+
updatePageResultMessageSchema,
|
|
33
|
+
invalidSandboxMessageSchema,
|
|
34
|
+
]);
|
|
@@ -0,0 +1,259 @@
|
|
|
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" | "context_unavailable" | "current_user_unavailable" | "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" | "init_timeout">;
|
|
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.OptionalSchema<v.PicklistSchema<["standard", "high"], undefined>, "standard" | "high">;
|
|
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>], undefined>;
|
|
54
|
+
readonly page: v.ObjectSchema<{
|
|
55
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
|
|
56
|
+
readonly parent: v.VariantSchema<"type", [v.ObjectSchema<{
|
|
57
|
+
readonly type: v.LiteralSchema<"page_id", undefined>;
|
|
58
|
+
readonly page_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
|
|
59
|
+
}, undefined>, v.ObjectSchema<{
|
|
60
|
+
readonly type: v.LiteralSchema<"data_source_id", undefined>;
|
|
61
|
+
readonly data_source_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>;
|
|
62
|
+
}, undefined>, v.ObjectSchema<{
|
|
63
|
+
readonly type: v.LiteralSchema<"workspace", undefined>;
|
|
64
|
+
readonly workspace: v.LiteralSchema<true, undefined>;
|
|
65
|
+
}, undefined>, v.ObjectSchema<{
|
|
66
|
+
readonly type: v.LiteralSchema<"block_id", undefined>;
|
|
67
|
+
readonly block_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionBlockId">]>;
|
|
68
|
+
}, undefined>, v.ObjectSchema<{
|
|
69
|
+
readonly type: v.LiteralSchema<"agent_id", undefined>;
|
|
70
|
+
readonly agent_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionAgentId">]>;
|
|
71
|
+
}, undefined>], undefined>;
|
|
72
|
+
}, undefined>;
|
|
73
|
+
readonly manifest: v.ObjectSchema<{
|
|
74
|
+
readonly version: v.LiteralSchema<1, undefined>;
|
|
75
|
+
readonly dataSources: v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
|
|
76
|
+
readonly name: v.StringSchema<undefined>;
|
|
77
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
78
|
+
readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
|
|
79
|
+
readonly type: v.LiteralSchema<"emoji", undefined>;
|
|
80
|
+
readonly emoji: v.StringSchema<undefined>;
|
|
81
|
+
}, undefined>, v.ObjectSchema<{
|
|
82
|
+
readonly type: v.LiteralSchema<"external", undefined>;
|
|
83
|
+
readonly url: v.StringSchema<undefined>;
|
|
84
|
+
}, undefined>], undefined>, undefined>;
|
|
85
|
+
readonly properties: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
|
|
86
|
+
readonly name: v.StringSchema<undefined>;
|
|
87
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
88
|
+
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>;
|
|
89
|
+
}, undefined>, undefined>, {}>;
|
|
90
|
+
}, undefined>, undefined>;
|
|
91
|
+
}, undefined>;
|
|
92
|
+
readonly dataSources: v.ObjectSchema<{
|
|
93
|
+
readonly bindings: v.RecordSchema<v.StringSchema<undefined>, v.ObjectSchema<{
|
|
94
|
+
readonly collectionPointer: v.OptionalSchema<v.ObjectSchema<{
|
|
95
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>;
|
|
96
|
+
readonly table: v.StringSchema<undefined>;
|
|
97
|
+
readonly spaceId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionSpaceId">]>, undefined>;
|
|
98
|
+
}, undefined>, undefined>;
|
|
99
|
+
readonly collectionSchema: v.OptionalSchema<v.ObjectSchema<{
|
|
100
|
+
readonly id: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>, undefined>;
|
|
101
|
+
readonly propertiesById: v.RecordSchema<v.StringSchema<undefined>, v.VariantSchema<"type", [v.ObjectSchema<{
|
|
102
|
+
readonly type: v.LiteralSchema<"title", undefined>;
|
|
103
|
+
readonly name: v.StringSchema<undefined>;
|
|
104
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
105
|
+
}, undefined>, v.ObjectSchema<{
|
|
106
|
+
readonly type: v.LiteralSchema<"rich_text", undefined>;
|
|
107
|
+
readonly name: v.StringSchema<undefined>;
|
|
108
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
109
|
+
}, undefined>, v.ObjectSchema<{
|
|
110
|
+
readonly type: v.LiteralSchema<"number", undefined>;
|
|
111
|
+
readonly name: v.StringSchema<undefined>;
|
|
112
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
113
|
+
}, undefined>, v.ObjectSchema<{
|
|
114
|
+
readonly type: v.LiteralSchema<"checkbox", undefined>;
|
|
115
|
+
readonly name: v.StringSchema<undefined>;
|
|
116
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
117
|
+
}, undefined>, v.ObjectSchema<{
|
|
118
|
+
readonly type: v.LiteralSchema<"url", undefined>;
|
|
119
|
+
readonly name: v.StringSchema<undefined>;
|
|
120
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
121
|
+
}, undefined>, v.ObjectSchema<{
|
|
122
|
+
readonly type: v.LiteralSchema<"email", undefined>;
|
|
123
|
+
readonly name: v.StringSchema<undefined>;
|
|
124
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
125
|
+
}, undefined>, v.ObjectSchema<{
|
|
126
|
+
readonly type: v.LiteralSchema<"phone_number", undefined>;
|
|
127
|
+
readonly name: v.StringSchema<undefined>;
|
|
128
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
129
|
+
}, undefined>, v.ObjectSchema<{
|
|
130
|
+
readonly type: v.LiteralSchema<"select", undefined>;
|
|
131
|
+
readonly options: v.ArraySchema<v.ObjectSchema<{
|
|
132
|
+
readonly id: v.StringSchema<undefined>;
|
|
133
|
+
readonly name: v.StringSchema<undefined>;
|
|
134
|
+
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>;
|
|
135
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
136
|
+
}, undefined>, undefined>;
|
|
137
|
+
readonly name: v.StringSchema<undefined>;
|
|
138
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
139
|
+
}, undefined>, v.ObjectSchema<{
|
|
140
|
+
readonly type: v.LiteralSchema<"multi_select", undefined>;
|
|
141
|
+
readonly options: v.ArraySchema<v.ObjectSchema<{
|
|
142
|
+
readonly id: v.StringSchema<undefined>;
|
|
143
|
+
readonly name: v.StringSchema<undefined>;
|
|
144
|
+
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>;
|
|
145
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
146
|
+
}, undefined>, undefined>;
|
|
147
|
+
readonly name: v.StringSchema<undefined>;
|
|
148
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
149
|
+
}, undefined>, v.ObjectSchema<{
|
|
150
|
+
readonly type: v.LiteralSchema<"status", undefined>;
|
|
151
|
+
readonly options: v.ArraySchema<v.ObjectSchema<{
|
|
152
|
+
readonly id: v.StringSchema<undefined>;
|
|
153
|
+
readonly name: v.StringSchema<undefined>;
|
|
154
|
+
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>;
|
|
155
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
156
|
+
}, undefined>, undefined>;
|
|
157
|
+
readonly groups: 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 option_ids: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
162
|
+
}, undefined>, undefined>;
|
|
163
|
+
readonly name: v.StringSchema<undefined>;
|
|
164
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
165
|
+
}, undefined>, v.ObjectSchema<{
|
|
166
|
+
readonly type: v.LiteralSchema<"date", undefined>;
|
|
167
|
+
readonly name: v.StringSchema<undefined>;
|
|
168
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
169
|
+
}, undefined>, v.ObjectSchema<{
|
|
170
|
+
readonly type: v.LiteralSchema<"people", undefined>;
|
|
171
|
+
readonly name: v.StringSchema<undefined>;
|
|
172
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
173
|
+
}, undefined>, v.ObjectSchema<{
|
|
174
|
+
readonly type: v.LiteralSchema<"files", undefined>;
|
|
175
|
+
readonly name: v.StringSchema<undefined>;
|
|
176
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
177
|
+
}, undefined>, v.ObjectSchema<{
|
|
178
|
+
readonly type: v.LiteralSchema<"unique_id", undefined>;
|
|
179
|
+
readonly name: v.StringSchema<undefined>;
|
|
180
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
181
|
+
}, undefined>, v.ObjectSchema<{
|
|
182
|
+
readonly type: v.LiteralSchema<"relation", undefined>;
|
|
183
|
+
readonly data_source_id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
184
|
+
readonly dual_property: v.OptionalSchema<v.ObjectSchema<{
|
|
185
|
+
readonly synced_property_id: v.StringSchema<undefined>;
|
|
186
|
+
readonly synced_property_name: v.StringSchema<undefined>;
|
|
187
|
+
}, undefined>, undefined>;
|
|
188
|
+
readonly name: v.StringSchema<undefined>;
|
|
189
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
190
|
+
}, undefined>, v.ObjectSchema<{
|
|
191
|
+
readonly type: v.LiteralSchema<"place", undefined>;
|
|
192
|
+
readonly name: v.StringSchema<undefined>;
|
|
193
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
194
|
+
}, undefined>, v.ObjectSchema<{
|
|
195
|
+
readonly type: v.LiteralSchema<"formula", undefined>;
|
|
196
|
+
readonly name: v.StringSchema<undefined>;
|
|
197
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
198
|
+
}, undefined>, v.ObjectSchema<{
|
|
199
|
+
readonly type: v.LiteralSchema<"rollup", undefined>;
|
|
200
|
+
readonly name: v.StringSchema<undefined>;
|
|
201
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
202
|
+
}, undefined>, v.ObjectSchema<{
|
|
203
|
+
readonly type: v.LiteralSchema<"button", undefined>;
|
|
204
|
+
readonly name: v.StringSchema<undefined>;
|
|
205
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
206
|
+
}, undefined>, v.ObjectSchema<{
|
|
207
|
+
readonly type: v.LiteralSchema<"verification", undefined>;
|
|
208
|
+
readonly name: v.StringSchema<undefined>;
|
|
209
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
210
|
+
}, undefined>, v.ObjectSchema<{
|
|
211
|
+
readonly type: v.LiteralSchema<"last_visited_time", undefined>;
|
|
212
|
+
readonly name: v.StringSchema<undefined>;
|
|
213
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
214
|
+
}, undefined>, v.ObjectSchema<{
|
|
215
|
+
readonly type: v.LiteralSchema<"location", undefined>;
|
|
216
|
+
readonly name: v.StringSchema<undefined>;
|
|
217
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
218
|
+
}, undefined>, v.ObjectSchema<{
|
|
219
|
+
readonly type: v.LiteralSchema<"created_time", undefined>;
|
|
220
|
+
readonly name: v.StringSchema<undefined>;
|
|
221
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
222
|
+
}, undefined>, v.ObjectSchema<{
|
|
223
|
+
readonly type: v.LiteralSchema<"last_edited_time", undefined>;
|
|
224
|
+
readonly name: v.StringSchema<undefined>;
|
|
225
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
226
|
+
}, undefined>, v.ObjectSchema<{
|
|
227
|
+
readonly type: v.LiteralSchema<"created_by", undefined>;
|
|
228
|
+
readonly name: v.StringSchema<undefined>;
|
|
229
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
230
|
+
}, undefined>, v.ObjectSchema<{
|
|
231
|
+
readonly type: v.LiteralSchema<"last_edited_by", undefined>;
|
|
232
|
+
readonly name: v.StringSchema<undefined>;
|
|
233
|
+
readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
234
|
+
}, undefined>], undefined>, undefined>;
|
|
235
|
+
}, undefined>, undefined>;
|
|
236
|
+
readonly propertyIdsByKey: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.OptionalSchema<v.StringSchema<undefined>, undefined>, undefined>, undefined>;
|
|
237
|
+
}, undefined>, undefined>;
|
|
238
|
+
}, undefined>;
|
|
239
|
+
readonly currentUser: v.ObjectSchema<{
|
|
240
|
+
readonly object: v.LiteralSchema<"user", undefined>;
|
|
241
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionUserId">]>;
|
|
242
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
243
|
+
readonly avatar_url: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
244
|
+
readonly type: v.LiteralSchema<"person", undefined>;
|
|
245
|
+
readonly person: v.ObjectSchema<{
|
|
246
|
+
readonly email: v.StringSchema<undefined>;
|
|
247
|
+
}, undefined>;
|
|
248
|
+
}, undefined>;
|
|
249
|
+
}, undefined>, v.ObjectSchema<{
|
|
250
|
+
readonly type: v.LiteralSchema<"init", undefined>;
|
|
251
|
+
readonly initializationId: v.StringSchema<undefined>;
|
|
252
|
+
readonly status: v.LiteralSchema<"error", undefined>;
|
|
253
|
+
readonly error: v.ObjectSchema<{
|
|
254
|
+
readonly code: v.StringSchema<undefined>;
|
|
255
|
+
readonly message: v.StringSchema<undefined>;
|
|
256
|
+
readonly isRetryable: v.BooleanSchema<undefined>;
|
|
257
|
+
}, undefined>;
|
|
258
|
+
}, undefined>], undefined>;
|
|
259
|
+
export type InitMessage = v.InferOutput<typeof initMessageSchema>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import { DEFAULT_CONTRAST_MODE, 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
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Initialization message sent by the host to the sandbox exactly once, in response to the
|
|
28
|
+
* sandbox's `connect` message. The sandbox echoes `initializationId` in `initResult`. After
|
|
29
|
+
* successful initialization, live updates flow through narrower messages
|
|
30
|
+
* (`themeChanged`, `contrastModeChanged`, `parentChanged`, `pageChanged`,
|
|
31
|
+
* `dataSourcesChanged`).
|
|
32
|
+
*/
|
|
33
|
+
export const initMessageSchema = v.variant("status", [
|
|
34
|
+
v.object({
|
|
35
|
+
type: v.literal("init"),
|
|
36
|
+
initializationId: v.string(),
|
|
37
|
+
status: v.literal("success"),
|
|
38
|
+
theme: notionThemeSchema,
|
|
39
|
+
// TODO(custom-blocks): Make this required when bumping bridge protocol version 4.
|
|
40
|
+
contrastMode: v.optional(notionContrastModeSchema, DEFAULT_CONTRAST_MODE),
|
|
41
|
+
blockId: notionBlockIdSchema,
|
|
42
|
+
parent: notionParentSchema,
|
|
43
|
+
page: customBlockPageSchema,
|
|
44
|
+
manifest: manifestSchema,
|
|
45
|
+
dataSources: v.object({
|
|
46
|
+
bindings: notionDataSourceBindingsSchema,
|
|
47
|
+
}),
|
|
48
|
+
currentUser: notionUserSchema,
|
|
49
|
+
}),
|
|
50
|
+
v.object({
|
|
51
|
+
type: v.literal("init"),
|
|
52
|
+
initializationId: v.string(),
|
|
53
|
+
status: v.literal("error"),
|
|
54
|
+
error: customBlockInitErrorInfoSchema,
|
|
55
|
+
}),
|
|
56
|
+
]);
|
|
@@ -0,0 +1,37 @@
|
|
|
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>;
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
// TODO(custom-blocks): Make this required when bumping bridge protocol version 4.
|
|
20
|
+
initialHeight: v.optional(v.pipe(v.number(), v.finite(), v.minValue(0))),
|
|
21
|
+
}),
|
|
22
|
+
v.object({
|
|
23
|
+
type: v.literal("initResult"),
|
|
24
|
+
initializationId: v.string(),
|
|
25
|
+
status: v.literal("error"),
|
|
26
|
+
error: customBlockInitResultErrorInfoSchema,
|
|
27
|
+
}),
|
|
28
|
+
]);
|
|
@@ -0,0 +1,14 @@
|
|
|
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>;
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
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>;
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
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>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import { notionUserListSchema } from "../users/user.js";
|
|
3
|
+
// The schema accepts any string code. The type lists known codes for
|
|
4
|
+
// autocomplete, with an open string fallback for newer senders.
|
|
5
|
+
export const customBlockListUsersErrorCodeSchema = v.string();
|
|
6
|
+
export const customBlockListUsersErrorInfoSchema = v.object({
|
|
7
|
+
code: customBlockListUsersErrorCodeSchema,
|
|
8
|
+
message: v.string(),
|
|
9
|
+
isRetryable: v.boolean(),
|
|
10
|
+
});
|
|
11
|
+
/**
|
|
12
|
+
* Sandbox -> host: list users visible in the custom block's workspace.
|
|
13
|
+
*/
|
|
14
|
+
export const listUsersMessageSchema = v.object({
|
|
15
|
+
type: v.literal("listUsers"),
|
|
16
|
+
requestId: v.string(),
|
|
17
|
+
startCursor: v.optional(v.string()),
|
|
18
|
+
pageSize: v.optional(v.number()),
|
|
19
|
+
});
|
|
20
|
+
export const listUsersResultMessageSchema = v.variant("status", [
|
|
21
|
+
v.object({
|
|
22
|
+
type: v.literal("listUsersResult"),
|
|
23
|
+
requestId: v.string(),
|
|
24
|
+
status: v.literal("success"),
|
|
25
|
+
list: notionUserListSchema,
|
|
26
|
+
}),
|
|
27
|
+
v.object({
|
|
28
|
+
type: v.literal("listUsersResult"),
|
|
29
|
+
requestId: v.string(),
|
|
30
|
+
status: v.literal("error"),
|
|
31
|
+
error: customBlockListUsersErrorInfoSchema,
|
|
32
|
+
}),
|
|
33
|
+
]);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
/**
|
|
3
|
+
* Message sent by the host whenever the custom block's nearest page ancestor changes.
|
|
4
|
+
*/
|
|
5
|
+
export declare const pageChangedMessageSchema: v.ObjectSchema<{
|
|
6
|
+
readonly type: v.LiteralSchema<"pageChanged", undefined>;
|
|
7
|
+
readonly page: v.ObjectSchema<{
|
|
8
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
|
|
9
|
+
readonly parent: v.VariantSchema<"type", [v.ObjectSchema<{
|
|
10
|
+
readonly type: v.LiteralSchema<"page_id", undefined>;
|
|
11
|
+
readonly page_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
|
|
12
|
+
}, undefined>, v.ObjectSchema<{
|
|
13
|
+
readonly type: v.LiteralSchema<"data_source_id", undefined>;
|
|
14
|
+
readonly data_source_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>;
|
|
15
|
+
}, undefined>, v.ObjectSchema<{
|
|
16
|
+
readonly type: v.LiteralSchema<"workspace", undefined>;
|
|
17
|
+
readonly workspace: v.LiteralSchema<true, undefined>;
|
|
18
|
+
}, undefined>, v.ObjectSchema<{
|
|
19
|
+
readonly type: v.LiteralSchema<"block_id", undefined>;
|
|
20
|
+
readonly block_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionBlockId">]>;
|
|
21
|
+
}, undefined>, v.ObjectSchema<{
|
|
22
|
+
readonly type: v.LiteralSchema<"agent_id", undefined>;
|
|
23
|
+
readonly agent_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionAgentId">]>;
|
|
24
|
+
}, undefined>], undefined>;
|
|
25
|
+
}, undefined>;
|
|
26
|
+
}, undefined>;
|
|
27
|
+
export type PageChangedMessage = v.InferOutput<typeof pageChangedMessageSchema>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import { customBlockPageSchema } from "../pages/page.js";
|
|
3
|
+
/**
|
|
4
|
+
* Message sent by the host whenever the custom block's nearest page ancestor changes.
|
|
5
|
+
*/
|
|
6
|
+
export const pageChangedMessageSchema = v.object({
|
|
7
|
+
type: v.literal("pageChanged"),
|
|
8
|
+
page: customBlockPageSchema,
|
|
9
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
/**
|
|
3
|
+
* Message sent by the host whenever the custom block's parent changes.
|
|
4
|
+
*/
|
|
5
|
+
export declare const parentChangedMessageSchema: v.ObjectSchema<{
|
|
6
|
+
readonly type: v.LiteralSchema<"parentChanged", undefined>;
|
|
7
|
+
readonly parent: v.VariantSchema<"type", [v.ObjectSchema<{
|
|
8
|
+
readonly type: v.LiteralSchema<"page_id", undefined>;
|
|
9
|
+
readonly page_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
|
|
10
|
+
}, undefined>, v.ObjectSchema<{
|
|
11
|
+
readonly type: v.LiteralSchema<"data_source_id", undefined>;
|
|
12
|
+
readonly data_source_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>;
|
|
13
|
+
}, undefined>, v.ObjectSchema<{
|
|
14
|
+
readonly type: v.LiteralSchema<"workspace", undefined>;
|
|
15
|
+
readonly workspace: v.LiteralSchema<true, undefined>;
|
|
16
|
+
}, undefined>, v.ObjectSchema<{
|
|
17
|
+
readonly type: v.LiteralSchema<"block_id", undefined>;
|
|
18
|
+
readonly block_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionBlockId">]>;
|
|
19
|
+
}, undefined>, v.ObjectSchema<{
|
|
20
|
+
readonly type: v.LiteralSchema<"agent_id", undefined>;
|
|
21
|
+
readonly agent_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionAgentId">]>;
|
|
22
|
+
}, undefined>], undefined>;
|
|
23
|
+
}, undefined>;
|
|
24
|
+
export type ParentChangedMessage = v.InferOutput<typeof parentChangedMessageSchema>;
|