@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,27 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import { connectMessageSchema } from "./connect.js";
|
|
3
|
+
import { createPageMessageSchema } from "./createPage.js";
|
|
4
|
+
import { getPageMessageSchema } from "./getPage.js";
|
|
5
|
+
import { getUserMessageSchema } from "./getUser.js";
|
|
6
|
+
import { initResultMessageSchema } from "./initResult.js";
|
|
7
|
+
import { invalidHostMessageSchema } from "./invalidHostMessage.js";
|
|
8
|
+
import { listUsersMessageSchema } from "./listUsers.js";
|
|
9
|
+
import { queryDataSourceMessageSchema } from "./queryDataSource.js";
|
|
10
|
+
import { resizeMessageSchema } from "./resize.js";
|
|
11
|
+
import { updatePageMessageSchema } from "./updatePage.js";
|
|
12
|
+
/**
|
|
13
|
+
* Discriminated union of every message the sandbox is allowed to send the host. Useful for hosts
|
|
14
|
+
* to validate inbound traffic from sandboxes without re-implementing validation logic.
|
|
15
|
+
*/
|
|
16
|
+
export const sandboxToHostMessageSchema = v.variant("type", [
|
|
17
|
+
connectMessageSchema,
|
|
18
|
+
initResultMessageSchema,
|
|
19
|
+
queryDataSourceMessageSchema,
|
|
20
|
+
createPageMessageSchema,
|
|
21
|
+
getPageMessageSchema,
|
|
22
|
+
getUserMessageSchema,
|
|
23
|
+
listUsersMessageSchema,
|
|
24
|
+
updatePageMessageSchema,
|
|
25
|
+
resizeMessageSchema,
|
|
26
|
+
invalidHostMessageSchema,
|
|
27
|
+
]);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
/**
|
|
3
|
+
* Message sent by the host every time the theme changes after the initial
|
|
4
|
+
* `init` handshake.
|
|
5
|
+
*/
|
|
6
|
+
export declare const themeChangedMessageSchema: v.ObjectSchema<{
|
|
7
|
+
readonly type: v.LiteralSchema<"themeChanged", undefined>;
|
|
8
|
+
readonly theme: v.PicklistSchema<["light", "dark"], undefined>;
|
|
9
|
+
}, undefined>;
|
|
10
|
+
export type ThemeChangedMessage = v.InferOutput<typeof themeChangedMessageSchema>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import { notionThemeSchema } from "../theme.js";
|
|
3
|
+
/**
|
|
4
|
+
* Message sent by the host every time the theme changes after the initial
|
|
5
|
+
* `init` handshake.
|
|
6
|
+
*/
|
|
7
|
+
export const themeChangedMessageSchema = v.object({
|
|
8
|
+
type: v.literal("themeChanged"),
|
|
9
|
+
theme: notionThemeSchema,
|
|
10
|
+
});
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
/**
|
|
3
|
+
* The sandbox sends this message to patch a page.
|
|
4
|
+
*/
|
|
5
|
+
export declare const updatePageMessageSchema: v.ObjectSchema<{
|
|
6
|
+
readonly type: v.LiteralSchema<"updatePage", undefined>;
|
|
7
|
+
readonly requestId: v.StringSchema<undefined>;
|
|
8
|
+
readonly pageId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
|
|
9
|
+
/**
|
|
10
|
+
* Property values, keyed by raw property IDs from Notion.
|
|
11
|
+
*
|
|
12
|
+
* Each value must carry the same raw property ID in its `id` field.
|
|
13
|
+
* To update a page with manifest-defined property keys, call `row.update()` on a row returned
|
|
14
|
+
* by `useDataSource()`. The SDK resolves those keys before it sends this message.
|
|
15
|
+
*/
|
|
16
|
+
readonly properties: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.VariantSchema<"type", [v.ObjectSchema<{
|
|
17
|
+
readonly type: v.LiteralSchema<"title", undefined>;
|
|
18
|
+
readonly title: v.ArraySchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
|
|
19
|
+
readonly id: v.StringSchema<undefined>;
|
|
20
|
+
}, undefined>, v.ObjectSchema<{
|
|
21
|
+
readonly type: v.LiteralSchema<"rich_text", undefined>;
|
|
22
|
+
readonly rich_text: v.ArraySchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
|
|
23
|
+
readonly id: v.StringSchema<undefined>;
|
|
24
|
+
}, undefined>, v.ObjectSchema<{
|
|
25
|
+
readonly type: v.LiteralSchema<"number", undefined>;
|
|
26
|
+
readonly number: v.NullableSchema<v.NumberSchema<undefined>, undefined>;
|
|
27
|
+
readonly id: v.StringSchema<undefined>;
|
|
28
|
+
}, undefined>, v.ObjectSchema<{
|
|
29
|
+
readonly type: v.LiteralSchema<"url", undefined>;
|
|
30
|
+
readonly url: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
31
|
+
readonly id: v.StringSchema<undefined>;
|
|
32
|
+
}, undefined>, v.ObjectSchema<{
|
|
33
|
+
readonly type: v.LiteralSchema<"email", undefined>;
|
|
34
|
+
readonly email: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
35
|
+
readonly id: v.StringSchema<undefined>;
|
|
36
|
+
}, undefined>, v.ObjectSchema<{
|
|
37
|
+
readonly type: v.LiteralSchema<"phone_number", undefined>;
|
|
38
|
+
readonly phone_number: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
39
|
+
readonly id: v.StringSchema<undefined>;
|
|
40
|
+
}, undefined>, v.ObjectSchema<{
|
|
41
|
+
readonly type: v.LiteralSchema<"checkbox", undefined>;
|
|
42
|
+
readonly checkbox: v.BooleanSchema<undefined>;
|
|
43
|
+
readonly id: v.StringSchema<undefined>;
|
|
44
|
+
}, undefined>, v.ObjectSchema<{
|
|
45
|
+
readonly type: v.LiteralSchema<"select", undefined>;
|
|
46
|
+
readonly select: v.NullableSchema<v.UnionSchema<[v.ObjectSchema<{
|
|
47
|
+
readonly id: v.StringSchema<undefined>;
|
|
48
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
49
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
50
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
51
|
+
}, undefined>, v.ObjectSchema<{
|
|
52
|
+
readonly name: v.StringSchema<undefined>;
|
|
53
|
+
readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
54
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
55
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
56
|
+
}, undefined>], undefined>, undefined>;
|
|
57
|
+
readonly id: v.StringSchema<undefined>;
|
|
58
|
+
}, undefined>, v.ObjectSchema<{
|
|
59
|
+
readonly type: v.LiteralSchema<"status", undefined>;
|
|
60
|
+
readonly status: v.NullableSchema<v.UnionSchema<[v.ObjectSchema<{
|
|
61
|
+
readonly id: v.StringSchema<undefined>;
|
|
62
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
63
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
64
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
65
|
+
}, undefined>, v.ObjectSchema<{
|
|
66
|
+
readonly name: v.StringSchema<undefined>;
|
|
67
|
+
readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
68
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
69
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
70
|
+
}, undefined>], undefined>, undefined>;
|
|
71
|
+
readonly id: v.StringSchema<undefined>;
|
|
72
|
+
}, undefined>, v.ObjectSchema<{
|
|
73
|
+
readonly type: v.LiteralSchema<"multi_select", undefined>;
|
|
74
|
+
readonly multi_select: v.ArraySchema<v.UnionSchema<[v.ObjectSchema<{
|
|
75
|
+
readonly id: v.StringSchema<undefined>;
|
|
76
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
77
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
78
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
79
|
+
}, undefined>, v.ObjectSchema<{
|
|
80
|
+
readonly name: v.StringSchema<undefined>;
|
|
81
|
+
readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
82
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
83
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
84
|
+
}, undefined>], undefined>, undefined>;
|
|
85
|
+
readonly id: v.StringSchema<undefined>;
|
|
86
|
+
}, undefined>, v.ObjectSchema<{
|
|
87
|
+
readonly type: v.LiteralSchema<"date", undefined>;
|
|
88
|
+
readonly date: v.NullableSchema<v.ObjectSchema<{
|
|
89
|
+
readonly start: v.StringSchema<undefined>;
|
|
90
|
+
readonly end: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
91
|
+
readonly time_zone: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
92
|
+
}, undefined>, undefined>;
|
|
93
|
+
readonly id: v.StringSchema<undefined>;
|
|
94
|
+
}, undefined>, v.ObjectSchema<{
|
|
95
|
+
readonly type: v.LiteralSchema<"people", undefined>;
|
|
96
|
+
readonly people: v.ArraySchema<v.UnionSchema<[v.ObjectSchema<{
|
|
97
|
+
readonly object: v.OptionalSchema<v.LiteralSchema<"user", undefined>, undefined>;
|
|
98
|
+
readonly id: v.StringSchema<undefined>;
|
|
99
|
+
}, undefined>, v.ObjectSchema<{
|
|
100
|
+
readonly object: v.LiteralSchema<"group", undefined>;
|
|
101
|
+
readonly id: v.StringSchema<undefined>;
|
|
102
|
+
readonly name: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
103
|
+
}, undefined>], undefined>, undefined>;
|
|
104
|
+
readonly id: v.StringSchema<undefined>;
|
|
105
|
+
}, undefined>, v.ObjectSchema<{
|
|
106
|
+
readonly type: v.LiteralSchema<"relation", undefined>;
|
|
107
|
+
readonly has_more: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
108
|
+
readonly relation: v.ArraySchema<v.ObjectSchema<{
|
|
109
|
+
readonly id: v.StringSchema<undefined>;
|
|
110
|
+
}, undefined>, undefined>;
|
|
111
|
+
readonly id: v.StringSchema<undefined>;
|
|
112
|
+
}, undefined>, v.ObjectSchema<{
|
|
113
|
+
readonly type: v.LiteralSchema<"files", undefined>;
|
|
114
|
+
readonly files: v.ArraySchema<v.UnionSchema<[v.ObjectSchema<{
|
|
115
|
+
readonly type: v.LiteralSchema<"external", undefined>;
|
|
116
|
+
readonly name: v.StringSchema<undefined>;
|
|
117
|
+
readonly external: v.ObjectSchema<{
|
|
118
|
+
readonly url: v.StringSchema<undefined>;
|
|
119
|
+
}, undefined>;
|
|
120
|
+
}, undefined>, v.ObjectSchema<{
|
|
121
|
+
readonly type: v.LiteralSchema<"file", undefined>;
|
|
122
|
+
readonly name: v.StringSchema<undefined>;
|
|
123
|
+
readonly file: v.ObjectSchema<{
|
|
124
|
+
readonly url: v.StringSchema<undefined>;
|
|
125
|
+
readonly expiry_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
126
|
+
}, undefined>;
|
|
127
|
+
}, undefined>], undefined>, undefined>;
|
|
128
|
+
readonly id: v.StringSchema<undefined>;
|
|
129
|
+
}, undefined>, v.ObjectSchema<{
|
|
130
|
+
readonly type: v.LiteralSchema<"place", undefined>;
|
|
131
|
+
readonly place: v.NullableSchema<v.ObjectSchema<{
|
|
132
|
+
readonly lat: v.NumberSchema<undefined>;
|
|
133
|
+
readonly lon: v.NumberSchema<undefined>;
|
|
134
|
+
readonly name: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
135
|
+
readonly address: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
136
|
+
readonly aws_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
137
|
+
readonly google_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
138
|
+
}, undefined>, undefined>;
|
|
139
|
+
readonly id: v.StringSchema<undefined>;
|
|
140
|
+
}, undefined>], undefined>, undefined>, undefined>;
|
|
141
|
+
readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
|
|
142
|
+
readonly type: v.LiteralSchema<"emoji", undefined>;
|
|
143
|
+
readonly emoji: v.StringSchema<undefined>;
|
|
144
|
+
}, undefined>, v.ObjectSchema<{
|
|
145
|
+
readonly type: v.LiteralSchema<"custom_emoji", undefined>;
|
|
146
|
+
readonly custom_emoji: v.ObjectSchema<{
|
|
147
|
+
readonly id: v.StringSchema<undefined>;
|
|
148
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
149
|
+
readonly url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
150
|
+
}, undefined>;
|
|
151
|
+
}, undefined>, v.ObjectSchema<{
|
|
152
|
+
readonly type: v.LiteralSchema<"external", undefined>;
|
|
153
|
+
readonly external: v.ObjectSchema<{
|
|
154
|
+
readonly url: v.StringSchema<undefined>;
|
|
155
|
+
}, undefined>;
|
|
156
|
+
}, undefined>, v.ObjectSchema<{
|
|
157
|
+
readonly type: v.LiteralSchema<"file", undefined>;
|
|
158
|
+
readonly file: v.ObjectSchema<{
|
|
159
|
+
readonly url: v.StringSchema<undefined>;
|
|
160
|
+
readonly expiry_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
161
|
+
}, undefined>;
|
|
162
|
+
}, undefined>], undefined>, undefined>;
|
|
163
|
+
readonly cover: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
|
|
164
|
+
readonly type: v.LiteralSchema<"external", undefined>;
|
|
165
|
+
readonly external: v.ObjectSchema<{
|
|
166
|
+
readonly url: v.StringSchema<undefined>;
|
|
167
|
+
}, undefined>;
|
|
168
|
+
}, undefined>, v.ObjectSchema<{
|
|
169
|
+
readonly type: v.LiteralSchema<"file", undefined>;
|
|
170
|
+
readonly file: v.ObjectSchema<{
|
|
171
|
+
readonly url: v.StringSchema<undefined>;
|
|
172
|
+
readonly expiry_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
173
|
+
}, undefined>;
|
|
174
|
+
}, undefined>], undefined>, undefined>;
|
|
175
|
+
readonly archived: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
176
|
+
}, undefined>;
|
|
177
|
+
/**
|
|
178
|
+
* The sandbox sends this message to update a page.
|
|
179
|
+
*/
|
|
180
|
+
export type UpdatePageMessage = v.InferOutput<typeof updatePageMessageSchema>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import { notionPageIdSchema } from "../ids.js";
|
|
3
|
+
import { notionPageCoverSchema, notionPageIconSchema, notionPagePropertyWriteMapSchema, } from "../pages/page.js";
|
|
4
|
+
/**
|
|
5
|
+
* The sandbox sends this message to patch a page.
|
|
6
|
+
*/
|
|
7
|
+
export const updatePageMessageSchema = v.object({
|
|
8
|
+
type: v.literal("updatePage"),
|
|
9
|
+
requestId: v.string(),
|
|
10
|
+
pageId: notionPageIdSchema,
|
|
11
|
+
/**
|
|
12
|
+
* Property values, keyed by raw property IDs from Notion.
|
|
13
|
+
*
|
|
14
|
+
* Each value must carry the same raw property ID in its `id` field.
|
|
15
|
+
* To update a page with manifest-defined property keys, call `row.update()` on a row returned
|
|
16
|
+
* by `useDataSource()`. The SDK resolves those keys before it sends this message.
|
|
17
|
+
*/
|
|
18
|
+
properties: v.optional(notionPagePropertyWriteMapSchema),
|
|
19
|
+
icon: v.optional(notionPageIconSchema),
|
|
20
|
+
cover: v.optional(notionPageCoverSchema),
|
|
21
|
+
archived: v.optional(v.boolean()),
|
|
22
|
+
});
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import type { CustomBlockErrorCode, CustomBlockErrorInfo } from "../errors.js";
|
|
3
|
+
export declare const customBlockUpdatePageErrorCodeSchema: v.StringSchema<undefined>;
|
|
4
|
+
export type CustomBlockUpdatePageErrorCode = CustomBlockErrorCode<"update_page_failed" | "invalid_page_update" | "page_access_failed" | "collection_access_failed" | "unmapped_property" | "property_id_mismatch" | "duplicate_property" | "invalid_property_value">;
|
|
5
|
+
export type CustomBlockUpdatePageErrorInfo = CustomBlockErrorInfo<CustomBlockUpdatePageErrorCode>;
|
|
6
|
+
export declare const customBlockUpdatePageErrorInfoSchema: v.ObjectSchema<{
|
|
7
|
+
readonly code: v.StringSchema<undefined>;
|
|
8
|
+
readonly message: v.StringSchema<undefined>;
|
|
9
|
+
readonly isRetryable: v.BooleanSchema<undefined>;
|
|
10
|
+
}, undefined>;
|
|
11
|
+
/**
|
|
12
|
+
* Host -> sandbox: result for a page update request.
|
|
13
|
+
*/
|
|
14
|
+
export declare const updatePageResultMessageSchema: v.VariantSchema<"status", [v.ObjectSchema<{
|
|
15
|
+
readonly type: v.LiteralSchema<"updatePageResult", undefined>;
|
|
16
|
+
readonly requestId: v.StringSchema<undefined>;
|
|
17
|
+
readonly status: v.LiteralSchema<"success", undefined>;
|
|
18
|
+
readonly page: v.ObjectSchema<{
|
|
19
|
+
readonly object: v.LiteralSchema<"page", undefined>;
|
|
20
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
|
|
21
|
+
readonly parent: v.VariantSchema<"type", [v.ObjectSchema<{
|
|
22
|
+
readonly type: v.LiteralSchema<"page_id", undefined>;
|
|
23
|
+
readonly page_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
|
|
24
|
+
}, undefined>, v.ObjectSchema<{
|
|
25
|
+
readonly type: v.LiteralSchema<"data_source_id", undefined>;
|
|
26
|
+
readonly data_source_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>;
|
|
27
|
+
}, undefined>, v.ObjectSchema<{
|
|
28
|
+
readonly type: v.LiteralSchema<"workspace", undefined>;
|
|
29
|
+
readonly workspace: v.LiteralSchema<true, undefined>;
|
|
30
|
+
}, undefined>, v.ObjectSchema<{
|
|
31
|
+
readonly type: v.LiteralSchema<"block_id", undefined>;
|
|
32
|
+
readonly block_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionBlockId">]>;
|
|
33
|
+
}, undefined>, v.ObjectSchema<{
|
|
34
|
+
readonly type: v.LiteralSchema<"agent_id", undefined>;
|
|
35
|
+
readonly agent_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionAgentId">]>;
|
|
36
|
+
}, undefined>], undefined>;
|
|
37
|
+
readonly properties: v.RecordSchema<v.StringSchema<undefined>, v.VariantSchema<"type", [v.ObjectSchema<{
|
|
38
|
+
readonly type: v.LiteralSchema<"title", undefined>;
|
|
39
|
+
readonly title: v.ArraySchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
|
|
40
|
+
readonly id: v.StringSchema<undefined>;
|
|
41
|
+
}, undefined>, v.ObjectSchema<{
|
|
42
|
+
readonly type: v.LiteralSchema<"rich_text", undefined>;
|
|
43
|
+
readonly rich_text: v.ArraySchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
|
|
44
|
+
readonly id: v.StringSchema<undefined>;
|
|
45
|
+
}, undefined>, v.ObjectSchema<{
|
|
46
|
+
readonly type: v.LiteralSchema<"number", undefined>;
|
|
47
|
+
readonly number: v.NullableSchema<v.NumberSchema<undefined>, undefined>;
|
|
48
|
+
readonly id: v.StringSchema<undefined>;
|
|
49
|
+
}, undefined>, v.ObjectSchema<{
|
|
50
|
+
readonly type: v.LiteralSchema<"url", undefined>;
|
|
51
|
+
readonly url: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
52
|
+
readonly id: v.StringSchema<undefined>;
|
|
53
|
+
}, undefined>, v.ObjectSchema<{
|
|
54
|
+
readonly type: v.LiteralSchema<"email", undefined>;
|
|
55
|
+
readonly email: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
56
|
+
readonly id: v.StringSchema<undefined>;
|
|
57
|
+
}, undefined>, v.ObjectSchema<{
|
|
58
|
+
readonly type: v.LiteralSchema<"phone_number", undefined>;
|
|
59
|
+
readonly phone_number: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
60
|
+
readonly id: v.StringSchema<undefined>;
|
|
61
|
+
}, undefined>, v.ObjectSchema<{
|
|
62
|
+
readonly type: v.LiteralSchema<"checkbox", undefined>;
|
|
63
|
+
readonly checkbox: v.BooleanSchema<undefined>;
|
|
64
|
+
readonly id: v.StringSchema<undefined>;
|
|
65
|
+
}, undefined>, v.ObjectSchema<{
|
|
66
|
+
readonly type: v.LiteralSchema<"select", undefined>;
|
|
67
|
+
readonly select: v.NullableSchema<v.UnionSchema<[v.ObjectSchema<{
|
|
68
|
+
readonly id: v.StringSchema<undefined>;
|
|
69
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
70
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
71
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
72
|
+
}, undefined>, v.ObjectSchema<{
|
|
73
|
+
readonly name: v.StringSchema<undefined>;
|
|
74
|
+
readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
75
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
76
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
77
|
+
}, undefined>], undefined>, undefined>;
|
|
78
|
+
readonly id: v.StringSchema<undefined>;
|
|
79
|
+
}, undefined>, v.ObjectSchema<{
|
|
80
|
+
readonly type: v.LiteralSchema<"status", undefined>;
|
|
81
|
+
readonly status: v.NullableSchema<v.UnionSchema<[v.ObjectSchema<{
|
|
82
|
+
readonly id: v.StringSchema<undefined>;
|
|
83
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
84
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
85
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
86
|
+
}, undefined>, v.ObjectSchema<{
|
|
87
|
+
readonly name: v.StringSchema<undefined>;
|
|
88
|
+
readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
89
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
90
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
91
|
+
}, undefined>], undefined>, undefined>;
|
|
92
|
+
readonly id: v.StringSchema<undefined>;
|
|
93
|
+
}, undefined>, v.ObjectSchema<{
|
|
94
|
+
readonly type: v.LiteralSchema<"multi_select", undefined>;
|
|
95
|
+
readonly multi_select: v.ArraySchema<v.UnionSchema<[v.ObjectSchema<{
|
|
96
|
+
readonly id: v.StringSchema<undefined>;
|
|
97
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
98
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
99
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
100
|
+
}, undefined>, v.ObjectSchema<{
|
|
101
|
+
readonly name: v.StringSchema<undefined>;
|
|
102
|
+
readonly id: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
103
|
+
readonly color: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
104
|
+
readonly description: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
105
|
+
}, undefined>], undefined>, undefined>;
|
|
106
|
+
readonly id: v.StringSchema<undefined>;
|
|
107
|
+
}, undefined>, v.ObjectSchema<{
|
|
108
|
+
readonly type: v.LiteralSchema<"date", undefined>;
|
|
109
|
+
readonly date: v.NullableSchema<v.ObjectSchema<{
|
|
110
|
+
readonly start: v.StringSchema<undefined>;
|
|
111
|
+
readonly end: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
112
|
+
readonly time_zone: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
113
|
+
}, undefined>, undefined>;
|
|
114
|
+
readonly id: v.StringSchema<undefined>;
|
|
115
|
+
}, undefined>, v.ObjectSchema<{
|
|
116
|
+
readonly type: v.LiteralSchema<"people", undefined>;
|
|
117
|
+
readonly people: v.ArraySchema<v.UnionSchema<[v.ObjectSchema<{
|
|
118
|
+
readonly object: v.OptionalSchema<v.LiteralSchema<"user", undefined>, undefined>;
|
|
119
|
+
readonly id: v.StringSchema<undefined>;
|
|
120
|
+
}, undefined>, v.ObjectSchema<{
|
|
121
|
+
readonly object: v.LiteralSchema<"group", undefined>;
|
|
122
|
+
readonly id: v.StringSchema<undefined>;
|
|
123
|
+
readonly name: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
124
|
+
}, undefined>], undefined>, undefined>;
|
|
125
|
+
readonly id: v.StringSchema<undefined>;
|
|
126
|
+
}, undefined>, v.ObjectSchema<{
|
|
127
|
+
readonly type: v.LiteralSchema<"relation", undefined>;
|
|
128
|
+
readonly has_more: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
129
|
+
readonly relation: v.ArraySchema<v.ObjectSchema<{
|
|
130
|
+
readonly id: v.StringSchema<undefined>;
|
|
131
|
+
}, undefined>, undefined>;
|
|
132
|
+
readonly id: v.StringSchema<undefined>;
|
|
133
|
+
}, undefined>, v.ObjectSchema<{
|
|
134
|
+
readonly type: v.LiteralSchema<"files", undefined>;
|
|
135
|
+
readonly files: v.ArraySchema<v.UnionSchema<[v.ObjectSchema<{
|
|
136
|
+
readonly type: v.LiteralSchema<"external", undefined>;
|
|
137
|
+
readonly name: v.StringSchema<undefined>;
|
|
138
|
+
readonly external: v.ObjectSchema<{
|
|
139
|
+
readonly url: v.StringSchema<undefined>;
|
|
140
|
+
}, undefined>;
|
|
141
|
+
}, undefined>, v.ObjectSchema<{
|
|
142
|
+
readonly type: v.LiteralSchema<"file", undefined>;
|
|
143
|
+
readonly name: v.StringSchema<undefined>;
|
|
144
|
+
readonly file: v.ObjectSchema<{
|
|
145
|
+
readonly url: v.StringSchema<undefined>;
|
|
146
|
+
readonly expiry_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
147
|
+
}, undefined>;
|
|
148
|
+
}, undefined>], undefined>, undefined>;
|
|
149
|
+
readonly id: v.StringSchema<undefined>;
|
|
150
|
+
}, undefined>, v.ObjectSchema<{
|
|
151
|
+
readonly type: v.LiteralSchema<"place", undefined>;
|
|
152
|
+
readonly place: v.NullableSchema<v.ObjectSchema<{
|
|
153
|
+
readonly lat: v.NumberSchema<undefined>;
|
|
154
|
+
readonly lon: v.NumberSchema<undefined>;
|
|
155
|
+
readonly name: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
156
|
+
readonly address: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
157
|
+
readonly aws_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
158
|
+
readonly google_place_id: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
159
|
+
}, undefined>, undefined>;
|
|
160
|
+
readonly id: v.StringSchema<undefined>;
|
|
161
|
+
}, undefined>], undefined>, undefined>;
|
|
162
|
+
readonly created_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
163
|
+
readonly last_edited_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
164
|
+
readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
|
|
165
|
+
readonly type: v.LiteralSchema<"emoji", undefined>;
|
|
166
|
+
readonly emoji: v.StringSchema<undefined>;
|
|
167
|
+
}, undefined>, v.ObjectSchema<{
|
|
168
|
+
readonly type: v.LiteralSchema<"custom_emoji", undefined>;
|
|
169
|
+
readonly custom_emoji: v.ObjectSchema<{
|
|
170
|
+
readonly id: v.StringSchema<undefined>;
|
|
171
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
172
|
+
readonly url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
173
|
+
}, undefined>;
|
|
174
|
+
}, undefined>, v.ObjectSchema<{
|
|
175
|
+
readonly type: v.LiteralSchema<"external", undefined>;
|
|
176
|
+
readonly external: v.ObjectSchema<{
|
|
177
|
+
readonly url: v.StringSchema<undefined>;
|
|
178
|
+
}, undefined>;
|
|
179
|
+
}, undefined>, v.ObjectSchema<{
|
|
180
|
+
readonly type: v.LiteralSchema<"file", undefined>;
|
|
181
|
+
readonly file: v.ObjectSchema<{
|
|
182
|
+
readonly url: v.StringSchema<undefined>;
|
|
183
|
+
readonly expiry_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
184
|
+
}, undefined>;
|
|
185
|
+
}, undefined>], undefined>, undefined>;
|
|
186
|
+
readonly cover: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
|
|
187
|
+
readonly type: v.LiteralSchema<"external", undefined>;
|
|
188
|
+
readonly external: v.ObjectSchema<{
|
|
189
|
+
readonly url: v.StringSchema<undefined>;
|
|
190
|
+
}, undefined>;
|
|
191
|
+
}, undefined>, v.ObjectSchema<{
|
|
192
|
+
readonly type: v.LiteralSchema<"file", undefined>;
|
|
193
|
+
readonly file: v.ObjectSchema<{
|
|
194
|
+
readonly url: v.StringSchema<undefined>;
|
|
195
|
+
readonly expiry_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
196
|
+
}, undefined>;
|
|
197
|
+
}, undefined>], undefined>, undefined>;
|
|
198
|
+
readonly url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
199
|
+
readonly public_url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
200
|
+
readonly in_trash: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
201
|
+
}, undefined>;
|
|
202
|
+
}, undefined>, v.ObjectSchema<{
|
|
203
|
+
readonly type: v.LiteralSchema<"updatePageResult", undefined>;
|
|
204
|
+
readonly requestId: v.StringSchema<undefined>;
|
|
205
|
+
readonly status: v.LiteralSchema<"error", undefined>;
|
|
206
|
+
readonly error: v.ObjectSchema<{
|
|
207
|
+
readonly code: v.StringSchema<undefined>;
|
|
208
|
+
readonly message: v.StringSchema<undefined>;
|
|
209
|
+
readonly isRetryable: v.BooleanSchema<undefined>;
|
|
210
|
+
}, undefined>;
|
|
211
|
+
}, undefined>], undefined>;
|
|
212
|
+
export type UpdatePageResultMessage = v.InferOutput<typeof updatePageResultMessageSchema>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import { notionPageSchema } from "../pages/page.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 customBlockUpdatePageErrorCodeSchema = v.string();
|
|
6
|
+
export const customBlockUpdatePageErrorInfoSchema = v.object({
|
|
7
|
+
code: customBlockUpdatePageErrorCodeSchema,
|
|
8
|
+
message: v.string(),
|
|
9
|
+
isRetryable: v.boolean(),
|
|
10
|
+
});
|
|
11
|
+
/**
|
|
12
|
+
* Host -> sandbox: result for a page update request.
|
|
13
|
+
*/
|
|
14
|
+
export const updatePageResultMessageSchema = v.variant("status", [
|
|
15
|
+
v.object({
|
|
16
|
+
type: v.literal("updatePageResult"),
|
|
17
|
+
requestId: v.string(),
|
|
18
|
+
status: v.literal("success"),
|
|
19
|
+
page: notionPageSchema,
|
|
20
|
+
}),
|
|
21
|
+
v.object({
|
|
22
|
+
type: v.literal("updatePageResult"),
|
|
23
|
+
requestId: v.string(),
|
|
24
|
+
status: v.literal("error"),
|
|
25
|
+
error: customBlockUpdatePageErrorInfoSchema,
|
|
26
|
+
}),
|
|
27
|
+
]);
|