@notionhq/custom-blocks-dev-shell 0.3.1 → 0.4.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.
- package/README.md +42 -18
- package/data/customers.json +286 -0
- package/data/meetings.json +519 -0
- package/data/people.json +171 -47
- package/data/projects.json +338 -0
- package/data/tasks.json +828 -38
- package/dist/assets/index-B4LAgGzW.css +2 -0
- package/dist/assets/index-CjUu48lJ.js +12 -0
- package/dist/index.html +3 -3
- package/dist-cli/cli/published-cli.js +1418 -912
- package/docs/bindings.md +16 -22
- package/docs/bridge/changelog.md +54 -15
- package/docs/bridge/protocol.md +152 -83
- package/docs/bridge/versioning.md +16 -4
- package/docs/data-sources.md +44 -31
- package/docs/host/README.md +26 -29
- package/docs/host/docs/compatibility.md +59 -31
- package/docs/host/docs/handlers.md +22 -15
- package/docs/host/docs/host-contract.md +71 -71
- package/docs/host/docs/lifecycle.md +64 -53
- package/package.json +1 -1
- package/data/radar.json +0 -87
- package/dist/assets/index-Do-x8yIt.css +0 -2
- package/dist/assets/index-Jy9OWV_k.js +0 -12
|
@@ -180,6 +180,22 @@ function includes(requirement, message$1) {
|
|
|
180
180
|
};
|
|
181
181
|
}
|
|
182
182
|
// @__NO_SIDE_EFFECTS__
|
|
183
|
+
function integer(message$1) {
|
|
184
|
+
return {
|
|
185
|
+
kind: "validation",
|
|
186
|
+
type: "integer",
|
|
187
|
+
reference: integer,
|
|
188
|
+
async: false,
|
|
189
|
+
expects: null,
|
|
190
|
+
requirement: Number.isInteger,
|
|
191
|
+
message: message$1,
|
|
192
|
+
"~run"(dataset, config$1) {
|
|
193
|
+
if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "integer", dataset, config$1);
|
|
194
|
+
return dataset;
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
// @__NO_SIDE_EFFECTS__
|
|
183
199
|
function maxLength(requirement, message$1) {
|
|
184
200
|
return {
|
|
185
201
|
kind: "validation",
|
|
@@ -259,6 +275,22 @@ function regex(requirement, message$1) {
|
|
|
259
275
|
};
|
|
260
276
|
}
|
|
261
277
|
// @__NO_SIDE_EFFECTS__
|
|
278
|
+
function safeInteger(message$1) {
|
|
279
|
+
return {
|
|
280
|
+
kind: "validation",
|
|
281
|
+
type: "safe_integer",
|
|
282
|
+
reference: safeInteger,
|
|
283
|
+
async: false,
|
|
284
|
+
expects: null,
|
|
285
|
+
requirement: Number.isSafeInteger,
|
|
286
|
+
message: message$1,
|
|
287
|
+
"~run"(dataset, config$1) {
|
|
288
|
+
if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "safe integer", dataset, config$1);
|
|
289
|
+
return dataset;
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
// @__NO_SIDE_EFFECTS__
|
|
262
294
|
function transform(operation) {
|
|
263
295
|
return {
|
|
264
296
|
kind: "transformation",
|
|
@@ -444,6 +476,23 @@ function never(message$1) {
|
|
|
444
476
|
});
|
|
445
477
|
}
|
|
446
478
|
// @__NO_SIDE_EFFECTS__
|
|
479
|
+
function nonOptional(wrapped, message$1) {
|
|
480
|
+
return _standardSchema({
|
|
481
|
+
kind: "schema",
|
|
482
|
+
type: "non_optional",
|
|
483
|
+
reference: nonOptional,
|
|
484
|
+
expects: "!undefined",
|
|
485
|
+
async: false,
|
|
486
|
+
wrapped,
|
|
487
|
+
message: message$1,
|
|
488
|
+
"~run"(dataset, config$1) {
|
|
489
|
+
if (dataset.value !== void 0) dataset = this.wrapped["~run"](dataset, config$1);
|
|
490
|
+
if (dataset.value === void 0) _addIssue(this, "type", dataset, config$1);
|
|
491
|
+
return dataset;
|
|
492
|
+
}
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
// @__NO_SIDE_EFFECTS__
|
|
447
496
|
function nullable(wrapped, default_) {
|
|
448
497
|
return _standardSchema({
|
|
449
498
|
kind: "schema",
|
|
@@ -897,6 +946,17 @@ function pipe(...pipe$1) {
|
|
|
897
946
|
});
|
|
898
947
|
}
|
|
899
948
|
// @__NO_SIDE_EFFECTS__
|
|
949
|
+
function required(schema, arg2, arg3) {
|
|
950
|
+
const keys = Array.isArray(arg2) ? arg2 : void 0;
|
|
951
|
+
const message$1 = Array.isArray(arg2) ? arg3 : arg2;
|
|
952
|
+
const entries$1 = {};
|
|
953
|
+
for (const key in schema.entries) entries$1[key] = !keys || keys.includes(key) ? /* @__PURE__ */ nonOptional(schema.entries[key], message$1) : schema.entries[key];
|
|
954
|
+
return _standardSchema({
|
|
955
|
+
...schema,
|
|
956
|
+
entries: entries$1
|
|
957
|
+
});
|
|
958
|
+
}
|
|
959
|
+
// @__NO_SIDE_EFFECTS__
|
|
900
960
|
function safeParse(schema, input, config$1) {
|
|
901
961
|
const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config$1));
|
|
902
962
|
return {
|
|
@@ -907,8 +967,204 @@ function safeParse(schema, input, config$1) {
|
|
|
907
967
|
};
|
|
908
968
|
}
|
|
909
969
|
|
|
970
|
+
// ../protocol/src/dataSources/properties/propertySchema.ts
|
|
971
|
+
var notionPropertyColorSchema = picklist([
|
|
972
|
+
"default",
|
|
973
|
+
"gray",
|
|
974
|
+
"brown",
|
|
975
|
+
"orange",
|
|
976
|
+
"yellow",
|
|
977
|
+
"green",
|
|
978
|
+
"blue",
|
|
979
|
+
"purple",
|
|
980
|
+
"pink",
|
|
981
|
+
"red",
|
|
982
|
+
"gray_background",
|
|
983
|
+
"brown_background",
|
|
984
|
+
"orange_background",
|
|
985
|
+
"yellow_background",
|
|
986
|
+
"green_background",
|
|
987
|
+
"blue_background",
|
|
988
|
+
"purple_background",
|
|
989
|
+
"pink_background",
|
|
990
|
+
"red_background",
|
|
991
|
+
"default_background"
|
|
992
|
+
]);
|
|
993
|
+
var notionPropertyOptionSchema = object({
|
|
994
|
+
id: string(),
|
|
995
|
+
name: string(),
|
|
996
|
+
color: optional(notionPropertyColorSchema),
|
|
997
|
+
description: optional(string())
|
|
998
|
+
});
|
|
999
|
+
var notionStatusGroupSchema = object({
|
|
1000
|
+
id: string(),
|
|
1001
|
+
name: string(),
|
|
1002
|
+
color: optional(notionPropertyColorSchema),
|
|
1003
|
+
option_ids: array(string())
|
|
1004
|
+
});
|
|
1005
|
+
var notionDualPropertySchema = object({
|
|
1006
|
+
synced_property_id: string(),
|
|
1007
|
+
synced_property_name: string()
|
|
1008
|
+
});
|
|
1009
|
+
var baseProp = object({
|
|
1010
|
+
name: string(),
|
|
1011
|
+
description: optional(string())
|
|
1012
|
+
});
|
|
1013
|
+
var NOTION_PROPERTY_TYPES = [
|
|
1014
|
+
"title",
|
|
1015
|
+
"rich_text",
|
|
1016
|
+
"number",
|
|
1017
|
+
"checkbox",
|
|
1018
|
+
"url",
|
|
1019
|
+
"email",
|
|
1020
|
+
"phone_number",
|
|
1021
|
+
"select",
|
|
1022
|
+
"multi_select",
|
|
1023
|
+
"status",
|
|
1024
|
+
"date",
|
|
1025
|
+
"people",
|
|
1026
|
+
"files",
|
|
1027
|
+
"unique_id",
|
|
1028
|
+
"relation",
|
|
1029
|
+
"place",
|
|
1030
|
+
"formula",
|
|
1031
|
+
"rollup",
|
|
1032
|
+
"button",
|
|
1033
|
+
"verification",
|
|
1034
|
+
"created_time",
|
|
1035
|
+
"last_edited_time",
|
|
1036
|
+
"created_by",
|
|
1037
|
+
"last_edited_by"
|
|
1038
|
+
];
|
|
1039
|
+
var notionPropertyTypeSchema = picklist(NOTION_PROPERTY_TYPES);
|
|
1040
|
+
var notionPropertySchemaSchema = variant("type", [
|
|
1041
|
+
object({ ...baseProp.entries, type: literal("title") }),
|
|
1042
|
+
object({ ...baseProp.entries, type: literal("rich_text") }),
|
|
1043
|
+
object({ ...baseProp.entries, type: literal("number") }),
|
|
1044
|
+
object({ ...baseProp.entries, type: literal("checkbox") }),
|
|
1045
|
+
object({ ...baseProp.entries, type: literal("url") }),
|
|
1046
|
+
object({ ...baseProp.entries, type: literal("email") }),
|
|
1047
|
+
object({ ...baseProp.entries, type: literal("phone_number") }),
|
|
1048
|
+
object({
|
|
1049
|
+
...baseProp.entries,
|
|
1050
|
+
type: literal("select"),
|
|
1051
|
+
options: array(notionPropertyOptionSchema)
|
|
1052
|
+
}),
|
|
1053
|
+
object({
|
|
1054
|
+
...baseProp.entries,
|
|
1055
|
+
type: literal("multi_select"),
|
|
1056
|
+
options: array(notionPropertyOptionSchema)
|
|
1057
|
+
}),
|
|
1058
|
+
object({
|
|
1059
|
+
...baseProp.entries,
|
|
1060
|
+
type: literal("status"),
|
|
1061
|
+
options: array(notionPropertyOptionSchema),
|
|
1062
|
+
groups: array(notionStatusGroupSchema)
|
|
1063
|
+
}),
|
|
1064
|
+
object({ ...baseProp.entries, type: literal("date") }),
|
|
1065
|
+
object({ ...baseProp.entries, type: literal("people") }),
|
|
1066
|
+
object({ ...baseProp.entries, type: literal("files") }),
|
|
1067
|
+
object({ ...baseProp.entries, type: literal("unique_id") }),
|
|
1068
|
+
object({
|
|
1069
|
+
...baseProp.entries,
|
|
1070
|
+
type: literal("relation"),
|
|
1071
|
+
data_source_id: optional(string()),
|
|
1072
|
+
dual_property: optional(notionDualPropertySchema)
|
|
1073
|
+
}),
|
|
1074
|
+
object({ ...baseProp.entries, type: literal("place") }),
|
|
1075
|
+
object({ ...baseProp.entries, type: literal("formula") }),
|
|
1076
|
+
object({ ...baseProp.entries, type: literal("rollup") }),
|
|
1077
|
+
// Internal-only types passed through under their bridge-native names.
|
|
1078
|
+
object({ ...baseProp.entries, type: literal("button") }),
|
|
1079
|
+
object({ ...baseProp.entries, type: literal("verification") }),
|
|
1080
|
+
// Page creation and edit metadata property types.
|
|
1081
|
+
object({ ...baseProp.entries, type: literal("created_time") }),
|
|
1082
|
+
object({ ...baseProp.entries, type: literal("last_edited_time") }),
|
|
1083
|
+
object({ ...baseProp.entries, type: literal("created_by") }),
|
|
1084
|
+
object({ ...baseProp.entries, type: literal("last_edited_by") })
|
|
1085
|
+
]);
|
|
1086
|
+
|
|
1087
|
+
// ../protocol/src/manifest/grants.ts
|
|
1088
|
+
var customBlockGrantSchema = object({
|
|
1089
|
+
action: string(),
|
|
1090
|
+
resource: union([string(), pipe(array(string()), minLength(1))])
|
|
1091
|
+
});
|
|
1092
|
+
|
|
1093
|
+
// ../protocol/src/manifest/manifest.ts
|
|
1094
|
+
var bridgeManifestIconSchema = variant("type", [
|
|
1095
|
+
object({
|
|
1096
|
+
type: literal("emoji"),
|
|
1097
|
+
emoji: string()
|
|
1098
|
+
}),
|
|
1099
|
+
object({
|
|
1100
|
+
type: literal("external"),
|
|
1101
|
+
url: string()
|
|
1102
|
+
})
|
|
1103
|
+
]);
|
|
1104
|
+
var bridgeManifestPropertySchema = object({
|
|
1105
|
+
name: string(),
|
|
1106
|
+
description: optional(string()),
|
|
1107
|
+
type: notionPropertyTypeSchema
|
|
1108
|
+
});
|
|
1109
|
+
var manifestPageSchema = object({
|
|
1110
|
+
name: string(),
|
|
1111
|
+
description: optional(string()),
|
|
1112
|
+
icon: optional(bridgeManifestIconSchema)
|
|
1113
|
+
});
|
|
1114
|
+
var bridgeManifestDataSourceSchema = object({
|
|
1115
|
+
name: string(),
|
|
1116
|
+
description: optional(string()),
|
|
1117
|
+
icon: optional(bridgeManifestIconSchema),
|
|
1118
|
+
properties: optional(
|
|
1119
|
+
record(string(), bridgeManifestPropertySchema),
|
|
1120
|
+
{}
|
|
1121
|
+
)
|
|
1122
|
+
});
|
|
1123
|
+
var manifestSchema = object({
|
|
1124
|
+
version: literal(1),
|
|
1125
|
+
name: optional(string()),
|
|
1126
|
+
description: optional(string()),
|
|
1127
|
+
slashCommand: optional(string()),
|
|
1128
|
+
icon: optional(object({ type: literal("emoji"), emoji: string() })),
|
|
1129
|
+
dataSources: optional(
|
|
1130
|
+
record(string(), bridgeManifestDataSourceSchema),
|
|
1131
|
+
{}
|
|
1132
|
+
),
|
|
1133
|
+
pages: optional(record(string(), manifestPageSchema)),
|
|
1134
|
+
/**
|
|
1135
|
+
* Grants the block needs. Omitted means the block predates viewer
|
|
1136
|
+
* approval, so hosts do not ask the viewer. An empty array declares
|
|
1137
|
+
* nothing.
|
|
1138
|
+
*/
|
|
1139
|
+
grants: optional(array(customBlockGrantSchema))
|
|
1140
|
+
});
|
|
1141
|
+
|
|
1142
|
+
// ../protocol/src/handshake/connect.ts
|
|
1143
|
+
var connectRequestMessageSchema = object({
|
|
1144
|
+
type: literal("connect"),
|
|
1145
|
+
/** Identifies this request. The host echoes it in `connectResult`. */
|
|
1146
|
+
requestId: string(),
|
|
1147
|
+
/** Every protocol contract the SDK implements, from which the host selects one. */
|
|
1148
|
+
supportedProtocolVersions: pipe(
|
|
1149
|
+
array(pipe(number(), integer(), minValue(1))),
|
|
1150
|
+
minLength(1),
|
|
1151
|
+
check((versions) => new Set(versions).size === versions.length)
|
|
1152
|
+
),
|
|
1153
|
+
/** SDK package version for diagnostics. Does not select the wire protocol. */
|
|
1154
|
+
sdkVersion: string(),
|
|
1155
|
+
/**
|
|
1156
|
+
* Manifest injected by local dev tooling. The SDK omits it on non-loopback origins.
|
|
1157
|
+
* The host selects it only when `manifestSource` is `"sandbox"`.
|
|
1158
|
+
*/
|
|
1159
|
+
manifest: optional(manifestSchema)
|
|
1160
|
+
});
|
|
1161
|
+
|
|
1162
|
+
// ../protocol/src/context/contrast.ts
|
|
1163
|
+
var notionContrastModeSchema = picklist(["standard", "high"]);
|
|
1164
|
+
|
|
910
1165
|
// ../protocol/src/utils/ids.ts
|
|
911
1166
|
var notionBlockIdSchema = pipe(string(), brand("NotionBlockId"));
|
|
1167
|
+
var notionViewIdSchema = pipe(string(), brand("NotionViewId"));
|
|
912
1168
|
var notionDataSourceIdSchema = pipe(
|
|
913
1169
|
string(),
|
|
914
1170
|
brand("NotionDataSourceId")
|
|
@@ -921,22 +1177,104 @@ var notionAppInstallationIdSchema = pipe(
|
|
|
921
1177
|
brand("NotionAppInstallationId")
|
|
922
1178
|
);
|
|
923
1179
|
|
|
924
|
-
// ../protocol/src/context/
|
|
925
|
-
var
|
|
926
|
-
type: literal("
|
|
927
|
-
|
|
1180
|
+
// ../protocol/src/context/instance.ts
|
|
1181
|
+
var customBlockInstanceSchema = variant("type", [
|
|
1182
|
+
strictObject({ type: literal("block"), blockId: notionBlockIdSchema }),
|
|
1183
|
+
strictObject({ type: literal("page"), blockId: notionBlockIdSchema }),
|
|
1184
|
+
strictObject({ type: literal("view"), viewId: notionViewIdSchema })
|
|
1185
|
+
]);
|
|
1186
|
+
|
|
1187
|
+
// ../protocol/src/context/theme.ts
|
|
1188
|
+
var notionThemeSchema = picklist(["light", "dark"]);
|
|
1189
|
+
|
|
1190
|
+
// ../protocol/src/handshake/init.ts
|
|
1191
|
+
var customBlockInitErrorCodeSchema = string();
|
|
1192
|
+
var customBlockInitErrorInfoSchema = object({
|
|
1193
|
+
code: customBlockInitErrorCodeSchema,
|
|
1194
|
+
message: string(),
|
|
1195
|
+
isRetryable: boolean()
|
|
928
1196
|
});
|
|
929
|
-
var
|
|
930
|
-
type: literal("
|
|
931
|
-
|
|
1197
|
+
var setupInitMessageSchema = object({
|
|
1198
|
+
type: literal("init"),
|
|
1199
|
+
requestId: string(),
|
|
1200
|
+
instance: customBlockInstanceSchema,
|
|
1201
|
+
manifest: manifestSchema,
|
|
1202
|
+
preferences: object({
|
|
1203
|
+
theme: notionThemeSchema,
|
|
1204
|
+
contrastMode: notionContrastModeSchema
|
|
1205
|
+
})
|
|
932
1206
|
});
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
1207
|
+
|
|
1208
|
+
// ../protocol/src/handshake/initResult.ts
|
|
1209
|
+
var customBlockInitResultErrorCodeSchema = string();
|
|
1210
|
+
var customBlockInitResultErrorInfoSchema = object({
|
|
1211
|
+
code: customBlockInitResultErrorCodeSchema,
|
|
1212
|
+
message: string(),
|
|
1213
|
+
isRetryable: boolean()
|
|
936
1214
|
});
|
|
937
|
-
var
|
|
938
|
-
|
|
939
|
-
|
|
1215
|
+
var initResultRequestMessageSchema = variant("status", [
|
|
1216
|
+
object({
|
|
1217
|
+
type: literal("initResult"),
|
|
1218
|
+
requestId: string(),
|
|
1219
|
+
status: literal("success")
|
|
1220
|
+
}),
|
|
1221
|
+
object({
|
|
1222
|
+
type: literal("initResult"),
|
|
1223
|
+
requestId: string(),
|
|
1224
|
+
status: literal("error"),
|
|
1225
|
+
error: customBlockInitResultErrorInfoSchema
|
|
1226
|
+
})
|
|
1227
|
+
]);
|
|
1228
|
+
|
|
1229
|
+
// ../protocol/src/utils/errors.ts
|
|
1230
|
+
var customBlockErrorInfoSchema = object({
|
|
1231
|
+
code: string(),
|
|
1232
|
+
message: string(),
|
|
1233
|
+
isRetryable: boolean()
|
|
1234
|
+
});
|
|
1235
|
+
|
|
1236
|
+
// ../protocol/src/compatibility/protocol3To11/connect.ts
|
|
1237
|
+
var connectMessageCommonEntries = {
|
|
1238
|
+
type: literal("connect"),
|
|
1239
|
+
/** Identifies this startup attempt and is echoed in `init` and `initResult`. */
|
|
1240
|
+
initializationId: string(),
|
|
1241
|
+
/** The protocol version declared by the SDK. The host accepts or rejects this version without negotiation. */
|
|
1242
|
+
bridgeProtocolVersion: number(),
|
|
1243
|
+
/** SDK package version for diagnostics. Does not select the wire protocol. */
|
|
1244
|
+
sdkVersion: string()
|
|
1245
|
+
};
|
|
1246
|
+
var protocol3To11ConnectSuccessMessageSchema = object({
|
|
1247
|
+
status: literal("success"),
|
|
1248
|
+
/** Local dev manifest, selected only when `manifestSource` is `"sandbox"`. */
|
|
1249
|
+
manifest: optional(manifestSchema),
|
|
1250
|
+
...connectMessageCommonEntries
|
|
1251
|
+
});
|
|
1252
|
+
var protocol3To11ConnectErrorMessageSchema = object({
|
|
1253
|
+
status: literal("error"),
|
|
1254
|
+
error: customBlockErrorInfoSchema,
|
|
1255
|
+
...connectMessageCommonEntries
|
|
1256
|
+
});
|
|
1257
|
+
var protocol3To11ConnectMessageSchema = variant("status", [
|
|
1258
|
+
protocol3To11ConnectSuccessMessageSchema,
|
|
1259
|
+
protocol3To11ConnectErrorMessageSchema
|
|
1260
|
+
]);
|
|
1261
|
+
|
|
1262
|
+
// ../protocol/src/context/parent.ts
|
|
1263
|
+
var pageParentSchema = object({
|
|
1264
|
+
type: literal("page_id"),
|
|
1265
|
+
page_id: notionPageIdSchema
|
|
1266
|
+
});
|
|
1267
|
+
var dataSourceParentSchema = object({
|
|
1268
|
+
type: literal("data_source_id"),
|
|
1269
|
+
data_source_id: notionDataSourceIdSchema
|
|
1270
|
+
});
|
|
1271
|
+
var workspaceParentSchema = object({
|
|
1272
|
+
type: literal("workspace"),
|
|
1273
|
+
workspace: literal(true)
|
|
1274
|
+
});
|
|
1275
|
+
var blockParentSchema = object({
|
|
1276
|
+
type: literal("block_id"),
|
|
1277
|
+
block_id: notionBlockIdSchema
|
|
940
1278
|
});
|
|
941
1279
|
var agentParentSchema = object({
|
|
942
1280
|
type: literal("agent_id"),
|
|
@@ -957,740 +1295,658 @@ var notionParentSchema = variant("type", [
|
|
|
957
1295
|
unavailableParentSchema
|
|
958
1296
|
]);
|
|
959
1297
|
|
|
960
|
-
// ../protocol/src/
|
|
961
|
-
var
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
var bridgeNotionHostedFileSchema = object({
|
|
966
|
-
type: literal("file"),
|
|
967
|
-
file: object({
|
|
968
|
-
url: string(),
|
|
969
|
-
expiry_time: optional(string())
|
|
970
|
-
})
|
|
1298
|
+
// ../protocol/src/dataSources/dataSourcePointer.ts
|
|
1299
|
+
var dataSourcePointerValidator = object({
|
|
1300
|
+
id: notionDataSourceIdSchema,
|
|
1301
|
+
table: string(),
|
|
1302
|
+
spaceId: optional(notionSpaceIdSchema)
|
|
971
1303
|
});
|
|
972
|
-
var bridgeFilePropertyItemSchema = union([
|
|
973
|
-
object({ ...bridgeExternalFileSchema.entries, name: string() }),
|
|
974
|
-
object({ ...bridgeNotionHostedFileSchema.entries, name: string() })
|
|
975
|
-
]);
|
|
976
1304
|
|
|
977
|
-
// ../protocol/src/
|
|
978
|
-
var
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
"blue",
|
|
987
|
-
"purple",
|
|
988
|
-
"pink",
|
|
989
|
-
"red"
|
|
990
|
-
]);
|
|
991
|
-
var bridgeIconColorSchema = union([
|
|
992
|
-
knownBridgeIconColorSchema,
|
|
993
|
-
string()
|
|
994
|
-
]);
|
|
995
|
-
var bridgeIconSchema = looseObject({
|
|
996
|
-
type: literal("icon"),
|
|
997
|
-
icon: looseObject({
|
|
998
|
-
name: bridgeIconNameSchema,
|
|
999
|
-
color: optional(bridgeIconColorSchema)
|
|
1000
|
-
})
|
|
1001
|
-
});
|
|
1002
|
-
var bridgeEmojiSchema = object({
|
|
1003
|
-
type: literal("emoji"),
|
|
1004
|
-
emoji: string()
|
|
1305
|
+
// ../protocol/src/dataSources/dataSourceSchema.ts
|
|
1306
|
+
var notionDataSourceSchemaValidator = object({
|
|
1307
|
+
id: optional(notionDataSourceIdSchema),
|
|
1308
|
+
/**
|
|
1309
|
+
* Describes actual database properties in protocol 5. Protocol 3/4 payloads can also include
|
|
1310
|
+
* synthetic metadata for compatibility. Use this map to resolve property bindings. Use this map
|
|
1311
|
+
* to validate filter and sort references.
|
|
1312
|
+
*/
|
|
1313
|
+
propertiesById: record(string(), notionPropertySchemaSchema)
|
|
1005
1314
|
});
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1315
|
+
|
|
1316
|
+
// ../protocol/src/dataSources/bridgeDataSourceBinding.ts
|
|
1317
|
+
var bridgeDataSourceBindingSchema = object({
|
|
1318
|
+
dataSourcePointer: optional(dataSourcePointerValidator),
|
|
1319
|
+
/**
|
|
1320
|
+
* Describes database properties. Use this schema to resolve property bindings. Use this
|
|
1321
|
+
* schema to validate filter and sort references. Undefined when the host does not provide a
|
|
1322
|
+
* database schema.
|
|
1323
|
+
*/
|
|
1324
|
+
dataSourceSchema: optional(notionDataSourceSchemaValidator),
|
|
1325
|
+
/**
|
|
1326
|
+
* Maps user-defined property keys to database property IDs. Use this map to resolve a key
|
|
1327
|
+
* such as `name` to its database property ID. A value of `undefined` marks a declared
|
|
1328
|
+
* property without a binding. Omitted when the host does not provide property mappings.
|
|
1329
|
+
* Synthetic metadata does not add entries to this map.
|
|
1330
|
+
*/
|
|
1331
|
+
propertyIdsByKey: optional(record(string(), optional(string()))),
|
|
1332
|
+
/**
|
|
1333
|
+
* `true` when the data source is bound but the viewer can't read it. The host omits
|
|
1334
|
+
* `dataSourcePointer`, `dataSourceSchema`, and `propertyIdsByKey`, so the binding reveals
|
|
1335
|
+
* nothing about the data source. The block still initializes.
|
|
1336
|
+
*/
|
|
1337
|
+
inaccessible: optional(literal(true))
|
|
1013
1338
|
});
|
|
1014
1339
|
|
|
1015
|
-
// ../protocol/src/
|
|
1016
|
-
var
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
bridgeExternalFileSchema,
|
|
1021
|
-
bridgeNotionHostedFileSchema
|
|
1022
|
-
]);
|
|
1023
|
-
var bridgePageCoverSchema = variant("type", [
|
|
1024
|
-
bridgeExternalFileSchema,
|
|
1025
|
-
bridgeNotionHostedFileSchema
|
|
1026
|
-
]);
|
|
1340
|
+
// ../protocol/src/dataSources/bridgeDataSourceBindings.ts
|
|
1341
|
+
var bridgeDataSourceBindingsSchema = record(
|
|
1342
|
+
string(),
|
|
1343
|
+
bridgeDataSourceBindingSchema
|
|
1344
|
+
);
|
|
1027
1345
|
|
|
1028
|
-
// ../protocol/src/
|
|
1029
|
-
var
|
|
1346
|
+
// ../protocol/src/users/userId.ts
|
|
1347
|
+
var notionUserIdSchema = pipe(string(), brand("NotionUserId"));
|
|
1030
1348
|
|
|
1031
|
-
// ../protocol/src/
|
|
1032
|
-
var
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
unit: picklist(["hour", "minute"]),
|
|
1040
|
-
value: number()
|
|
1041
|
-
});
|
|
1042
|
-
var notionDisabledReminderSchema = object({
|
|
1043
|
-
unit: literal("none")
|
|
1044
|
-
});
|
|
1045
|
-
var notionDateTimeReminderSchema = union([
|
|
1046
|
-
notionDateReminderSchema,
|
|
1047
|
-
notionTimeReminderSchema
|
|
1048
|
-
]);
|
|
1049
|
-
var dateOrDisabledReminder = optional(
|
|
1050
|
-
union([notionDateReminderSchema, notionDisabledReminderSchema])
|
|
1051
|
-
);
|
|
1052
|
-
var dateTimeOrDisabledReminder = optional(
|
|
1053
|
-
union([notionDateTimeReminderSchema, notionDisabledReminderSchema])
|
|
1054
|
-
);
|
|
1055
|
-
var notionDateSchema = object({
|
|
1056
|
-
type: literal("date"),
|
|
1057
|
-
start_date: string(),
|
|
1058
|
-
reminder: dateOrDisabledReminder
|
|
1059
|
-
});
|
|
1060
|
-
var notionDateRangeSchema = object({
|
|
1061
|
-
type: literal("daterange"),
|
|
1062
|
-
start_date: string(),
|
|
1063
|
-
end_date: string(),
|
|
1064
|
-
reminder: dateOrDisabledReminder
|
|
1065
|
-
});
|
|
1066
|
-
var notionDateTimeSchema = object({
|
|
1067
|
-
type: literal("datetime"),
|
|
1068
|
-
start_date: string(),
|
|
1069
|
-
start_time: string(),
|
|
1070
|
-
time_zone: optional(string()),
|
|
1071
|
-
reminder: dateTimeOrDisabledReminder
|
|
1349
|
+
// ../protocol/src/compatibility/protocol3To11/bridgeUser.ts
|
|
1350
|
+
var bridgeUserForProtocol3To11Schema = object({
|
|
1351
|
+
object: literal("user"),
|
|
1352
|
+
id: notionUserIdSchema,
|
|
1353
|
+
name: optional(string()),
|
|
1354
|
+
avatar_url: nullable(string()),
|
|
1355
|
+
type: literal("person"),
|
|
1356
|
+
person: object({ email: string() })
|
|
1072
1357
|
});
|
|
1073
|
-
var
|
|
1074
|
-
type: literal("
|
|
1075
|
-
|
|
1076
|
-
start_time: string(),
|
|
1077
|
-
end_date: string(),
|
|
1078
|
-
end_time: string(),
|
|
1079
|
-
time_zone: optional(string()),
|
|
1080
|
-
reminder: dateTimeOrDisabledReminder
|
|
1358
|
+
var currentUserChangedForProtocol3To11Schema = object({
|
|
1359
|
+
type: literal("currentUserChanged"),
|
|
1360
|
+
currentUser: bridgeUserForProtocol3To11Schema
|
|
1081
1361
|
});
|
|
1082
|
-
var
|
|
1083
|
-
notionDateSchema,
|
|
1084
|
-
notionDateRangeSchema,
|
|
1085
|
-
notionDateTimeSchema,
|
|
1086
|
-
notionDateTimeRangeSchema
|
|
1087
|
-
]);
|
|
1088
|
-
|
|
1089
|
-
// ../protocol/src/pages/properties/dateInput.ts
|
|
1090
|
-
var dateInputEntries = {
|
|
1091
|
-
start: string(),
|
|
1092
|
-
end: optional(nullableStringSchema),
|
|
1093
|
-
time_zone: optional(nullableStringSchema),
|
|
1094
|
-
reminder: optional(
|
|
1095
|
-
union([notionDateTimeReminderSchema, notionDisabledReminderSchema])
|
|
1096
|
-
)
|
|
1097
|
-
};
|
|
1098
|
-
var notionDateInputSchema = union([
|
|
1362
|
+
var getUserResultForProtocol3To11Schema = variant("status", [
|
|
1099
1363
|
object({
|
|
1100
|
-
|
|
1101
|
-
|
|
1364
|
+
type: literal("getUserResult"),
|
|
1365
|
+
requestId: string(),
|
|
1366
|
+
status: literal("success"),
|
|
1367
|
+
user: bridgeUserForProtocol3To11Schema
|
|
1102
1368
|
}),
|
|
1103
1369
|
object({
|
|
1104
|
-
|
|
1105
|
-
|
|
1370
|
+
type: literal("getUserResult"),
|
|
1371
|
+
requestId: string(),
|
|
1372
|
+
status: literal("error"),
|
|
1373
|
+
error: customBlockErrorInfoSchema
|
|
1374
|
+
})
|
|
1375
|
+
]);
|
|
1376
|
+
var listUsersResultForProtocol3To11Schema = variant("status", [
|
|
1377
|
+
object({
|
|
1378
|
+
type: literal("listUsersResult"),
|
|
1379
|
+
requestId: string(),
|
|
1380
|
+
status: literal("success"),
|
|
1381
|
+
list: object({
|
|
1382
|
+
object: literal("list"),
|
|
1383
|
+
results: array(bridgeUserForProtocol3To11Schema),
|
|
1384
|
+
next_cursor: nullable(string()),
|
|
1385
|
+
has_more: boolean(),
|
|
1386
|
+
type: literal("user"),
|
|
1387
|
+
user: record(string(), unknown())
|
|
1388
|
+
})
|
|
1106
1389
|
}),
|
|
1107
1390
|
object({
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1391
|
+
type: literal("listUsersResult"),
|
|
1392
|
+
requestId: string(),
|
|
1393
|
+
status: literal("error"),
|
|
1394
|
+
error: customBlockErrorInfoSchema
|
|
1112
1395
|
})
|
|
1113
1396
|
]);
|
|
1114
1397
|
|
|
1115
|
-
// ../protocol/src/
|
|
1116
|
-
var
|
|
1117
|
-
|
|
1118
|
-
table: string()
|
|
1119
|
-
});
|
|
1120
|
-
|
|
1121
|
-
// ../protocol/src/pages/properties/metadataActor.ts
|
|
1122
|
-
var metadataActorSchema = nullable(
|
|
1398
|
+
// ../protocol/src/compatibility/protocol3To11/containingPage.ts
|
|
1399
|
+
var protocol3To11ContainingPageSchema = variant("type", [
|
|
1400
|
+
object({ type: literal("unavailable") }),
|
|
1123
1401
|
object({
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1402
|
+
type: literal("page"),
|
|
1403
|
+
id: notionPageIdSchema,
|
|
1404
|
+
parent: notionParentSchema
|
|
1127
1405
|
})
|
|
1128
|
-
);
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
lat: number(),
|
|
1133
|
-
lon: number(),
|
|
1134
|
-
name: optional(nullableStringSchema),
|
|
1135
|
-
address: optional(nullableStringSchema),
|
|
1136
|
-
aws_place_id: optional(nullableStringSchema),
|
|
1137
|
-
google_place_id: optional(nullableStringSchema)
|
|
1406
|
+
]);
|
|
1407
|
+
var protocol3To11PageChangedMessageSchema = object({
|
|
1408
|
+
type: literal("pageChanged"),
|
|
1409
|
+
page: protocol3To11ContainingPageSchema
|
|
1138
1410
|
});
|
|
1139
1411
|
|
|
1140
|
-
// ../protocol/src/
|
|
1141
|
-
var
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1412
|
+
// ../protocol/src/compatibility/protocol3To11/init.ts
|
|
1413
|
+
var protocol3To11InitSuccessMessageSchema = object({
|
|
1414
|
+
type: literal("init"),
|
|
1415
|
+
initializationId: string(),
|
|
1416
|
+
status: literal("success"),
|
|
1417
|
+
theme: notionThemeSchema,
|
|
1418
|
+
contrastMode: notionContrastModeSchema,
|
|
1419
|
+
blockId: notionBlockIdSchema,
|
|
1420
|
+
parent: notionParentSchema,
|
|
1421
|
+
page: protocol3To11ContainingPageSchema,
|
|
1422
|
+
manifest: manifestSchema,
|
|
1423
|
+
dataSources: object({
|
|
1424
|
+
bindings: bridgeDataSourceBindingsSchema
|
|
1153
1425
|
}),
|
|
1426
|
+
currentUser: bridgeUserForProtocol3To11Schema
|
|
1427
|
+
});
|
|
1428
|
+
var protocol3To11InitMessageSchema = variant("status", [
|
|
1429
|
+
protocol3To11InitSuccessMessageSchema,
|
|
1154
1430
|
object({
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1431
|
+
type: literal("init"),
|
|
1432
|
+
initializationId: string(),
|
|
1433
|
+
status: literal("error"),
|
|
1434
|
+
error: customBlockErrorInfoSchema
|
|
1159
1435
|
})
|
|
1160
1436
|
]);
|
|
1161
1437
|
|
|
1162
|
-
// ../protocol/src/
|
|
1163
|
-
var
|
|
1438
|
+
// ../protocol/src/compatibility/protocol3To11/initResult.ts
|
|
1439
|
+
var protocol3To11InitResultMessageSchema = variant("status", [
|
|
1164
1440
|
object({
|
|
1165
|
-
|
|
1166
|
-
|
|
1441
|
+
type: literal("initResult"),
|
|
1442
|
+
initializationId: string(),
|
|
1443
|
+
status: literal("success"),
|
|
1444
|
+
/** Initial rendered content height in CSS pixels. Omission is accepted for protocols that do not supply it. */
|
|
1445
|
+
initialHeight: optional(pipe(number(), finite(), minValue(0)))
|
|
1167
1446
|
}),
|
|
1168
1447
|
object({
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1448
|
+
type: literal("initResult"),
|
|
1449
|
+
initializationId: string(),
|
|
1450
|
+
status: literal("error"),
|
|
1451
|
+
error: customBlockErrorInfoSchema
|
|
1172
1452
|
})
|
|
1173
1453
|
]);
|
|
1174
1454
|
|
|
1175
|
-
// ../protocol/src/
|
|
1176
|
-
var
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
}),
|
|
1188
|
-
object({
|
|
1189
|
-
...pagePropertyBaseSchema,
|
|
1190
|
-
type: literal("number"),
|
|
1191
|
-
number: nullable(number())
|
|
1192
|
-
}),
|
|
1193
|
-
object({
|
|
1194
|
-
...pagePropertyBaseSchema,
|
|
1195
|
-
type: literal("url"),
|
|
1196
|
-
url: nullableStringSchema
|
|
1197
|
-
}),
|
|
1198
|
-
object({
|
|
1199
|
-
...pagePropertyBaseSchema,
|
|
1200
|
-
type: literal("email"),
|
|
1201
|
-
email: nullableStringSchema
|
|
1202
|
-
}),
|
|
1203
|
-
object({
|
|
1204
|
-
...pagePropertyBaseSchema,
|
|
1205
|
-
type: literal("phone_number"),
|
|
1206
|
-
phone_number: nullableStringSchema
|
|
1207
|
-
}),
|
|
1208
|
-
object({
|
|
1209
|
-
...pagePropertyBaseSchema,
|
|
1210
|
-
type: literal("checkbox"),
|
|
1211
|
-
checkbox: boolean()
|
|
1212
|
-
}),
|
|
1213
|
-
object({
|
|
1214
|
-
...pagePropertyBaseSchema,
|
|
1215
|
-
type: literal("select"),
|
|
1216
|
-
select: nullable(notionSelectOptionInputSchema)
|
|
1217
|
-
}),
|
|
1218
|
-
object({
|
|
1219
|
-
...pagePropertyBaseSchema,
|
|
1220
|
-
type: literal("status"),
|
|
1221
|
-
status: nullable(notionSelectOptionInputSchema)
|
|
1222
|
-
}),
|
|
1223
|
-
object({
|
|
1224
|
-
...pagePropertyBaseSchema,
|
|
1225
|
-
type: literal("multi_select"),
|
|
1226
|
-
multi_select: array(notionSelectOptionInputSchema)
|
|
1227
|
-
}),
|
|
1228
|
-
object({
|
|
1229
|
-
...pagePropertyBaseSchema,
|
|
1230
|
-
type: literal("date"),
|
|
1231
|
-
date: nullable(notionDateInputSchema)
|
|
1232
|
-
}),
|
|
1233
|
-
object({
|
|
1234
|
-
...pagePropertyBaseSchema,
|
|
1235
|
-
type: literal("people"),
|
|
1236
|
-
people: array(notionUserInputSchema)
|
|
1237
|
-
}),
|
|
1238
|
-
object({
|
|
1239
|
-
...pagePropertyBaseSchema,
|
|
1240
|
-
type: literal("relation"),
|
|
1241
|
-
has_more: optional(boolean()),
|
|
1242
|
-
relation: array(notionRelationInputSchema)
|
|
1243
|
-
}),
|
|
1244
|
-
object({
|
|
1245
|
-
...pagePropertyBaseSchema,
|
|
1246
|
-
type: literal("files"),
|
|
1247
|
-
files: array(bridgeFilePropertyItemSchema)
|
|
1248
|
-
}),
|
|
1249
|
-
object({
|
|
1250
|
-
...pagePropertyBaseSchema,
|
|
1251
|
-
type: literal("place"),
|
|
1252
|
-
place: nullable(notionPlaceInputSchema)
|
|
1253
|
-
}),
|
|
1254
|
-
object({
|
|
1255
|
-
...pagePropertyBaseSchema,
|
|
1256
|
-
type: literal("created_time"),
|
|
1257
|
-
created_time: nullableStringSchema
|
|
1258
|
-
}),
|
|
1259
|
-
object({
|
|
1260
|
-
...pagePropertyBaseSchema,
|
|
1261
|
-
type: literal("last_edited_time"),
|
|
1262
|
-
last_edited_time: nullableStringSchema
|
|
1263
|
-
}),
|
|
1264
|
-
object({
|
|
1265
|
-
...pagePropertyBaseSchema,
|
|
1266
|
-
type: literal("created_by"),
|
|
1267
|
-
created_by: metadataActorSchema
|
|
1268
|
-
}),
|
|
1269
|
-
object({
|
|
1270
|
-
...pagePropertyBaseSchema,
|
|
1271
|
-
type: literal("last_edited_by"),
|
|
1272
|
-
last_edited_by: metadataActorSchema
|
|
1273
|
-
}),
|
|
1274
|
-
object({
|
|
1275
|
-
...pagePropertyBaseSchema,
|
|
1276
|
-
type: literal("unique_id"),
|
|
1277
|
-
unique_id: string()
|
|
1278
|
-
}),
|
|
1279
|
-
object({
|
|
1280
|
-
...pagePropertyBaseSchema,
|
|
1281
|
-
type: literal("button"),
|
|
1282
|
-
button: string()
|
|
1283
|
-
}),
|
|
1284
|
-
object({
|
|
1285
|
-
...pagePropertyBaseSchema,
|
|
1286
|
-
type: literal("formula"),
|
|
1287
|
-
formula: string()
|
|
1288
|
-
}),
|
|
1289
|
-
object({
|
|
1290
|
-
...pagePropertyBaseSchema,
|
|
1291
|
-
type: literal("rollup"),
|
|
1292
|
-
rollup: string()
|
|
1293
|
-
}),
|
|
1294
|
-
object({
|
|
1295
|
-
...pagePropertyBaseSchema,
|
|
1296
|
-
type: literal("verification"),
|
|
1297
|
-
verification: string()
|
|
1298
|
-
})
|
|
1455
|
+
// ../protocol/src/compatibility/handshake.ts
|
|
1456
|
+
var sandboxConnectMessageSchema = union([
|
|
1457
|
+
connectRequestMessageSchema,
|
|
1458
|
+
protocol3To11ConnectMessageSchema
|
|
1459
|
+
]);
|
|
1460
|
+
var hostInitMessageSchema = union([
|
|
1461
|
+
setupInitMessageSchema,
|
|
1462
|
+
protocol3To11InitMessageSchema
|
|
1463
|
+
]);
|
|
1464
|
+
var initResultMessageWithCompatibilitySchema = union([
|
|
1465
|
+
initResultRequestMessageSchema,
|
|
1466
|
+
protocol3To11InitResultMessageSchema
|
|
1299
1467
|
]);
|
|
1300
1468
|
|
|
1301
|
-
// ../protocol/src/
|
|
1302
|
-
var
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
);
|
|
1306
|
-
var bridgePagePropertyReadMapSchema = record(
|
|
1307
|
-
string(),
|
|
1308
|
-
nullable(bridgePagePropertyValueSchema)
|
|
1309
|
-
);
|
|
1310
|
-
|
|
1311
|
-
// ../protocol/src/compatibility/protocol3To5/bridgePage.ts
|
|
1312
|
-
var bridgePageForProtocol3To5Schema = object({
|
|
1313
|
-
object: literal("page"),
|
|
1314
|
-
id: notionPageIdSchema,
|
|
1315
|
-
parent: notionParentSchema,
|
|
1316
|
-
properties: bridgePagePropertyWriteMapSchema,
|
|
1317
|
-
created_time: optional(string()),
|
|
1318
|
-
last_edited_time: optional(string()),
|
|
1319
|
-
icon: optional(bridgePageIconSchema),
|
|
1320
|
-
cover: optional(bridgePageCoverSchema),
|
|
1321
|
-
url: optional(string()),
|
|
1322
|
-
public_url: optional(string()),
|
|
1323
|
-
/** Whether the page or an ancestor is archived. */
|
|
1324
|
-
is_archived: boolean(),
|
|
1325
|
-
/** Whether the page or an ancestor is in Trash. */
|
|
1326
|
-
in_trash: boolean()
|
|
1469
|
+
// ../protocol/src/context/messages/contrastModeChanged.ts
|
|
1470
|
+
var contrastModeChangedMessageSchema = object({
|
|
1471
|
+
type: literal("contrastModeChanged"),
|
|
1472
|
+
contrastMode: notionContrastModeSchema
|
|
1327
1473
|
});
|
|
1328
1474
|
|
|
1329
|
-
// ../protocol/src/
|
|
1330
|
-
var
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1475
|
+
// ../protocol/src/context/containingPage.ts
|
|
1476
|
+
var customBlockPageSchema = variant("type", [
|
|
1477
|
+
/** The viewer cannot access the containing page. Its ID and parent are not exposed. */
|
|
1478
|
+
object({ type: literal("unavailable") }),
|
|
1479
|
+
/** The accessible containing page, with its ID and parent location. */
|
|
1480
|
+
object({
|
|
1481
|
+
type: literal("page"),
|
|
1482
|
+
id: notionPageIdSchema,
|
|
1483
|
+
/**
|
|
1484
|
+
* The containing page's own parent. It lets a block distinguish a freestanding page from a
|
|
1485
|
+
* database row without a round trip. Not to be confused with the top-level `parent` runtime
|
|
1486
|
+
* value, which is the custom block's own parent.
|
|
1487
|
+
*/
|
|
1488
|
+
parent: notionParentSchema,
|
|
1489
|
+
/** How this block's containing page is displayed. Defaults to `full_page` for hosts without peek presentation. */
|
|
1490
|
+
displayMode: optional(
|
|
1491
|
+
picklist(["full_page", "side_peek", "center_peek"]),
|
|
1492
|
+
"full_page"
|
|
1493
|
+
)
|
|
1494
|
+
})
|
|
1337
1495
|
]);
|
|
1338
1496
|
|
|
1339
|
-
// ../protocol/src/
|
|
1340
|
-
var
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
is_archived: boolean(),
|
|
1344
|
-
/** Whether the page or an ancestor is in Trash. */
|
|
1345
|
-
in_trash: boolean(),
|
|
1346
|
-
propertiesById: record(string(), optional(notionDataSourceValueSchema))
|
|
1497
|
+
// ../protocol/src/context/messages/pageChanged.ts
|
|
1498
|
+
var pageChangedMessageSchema = object({
|
|
1499
|
+
type: literal("pageChanged"),
|
|
1500
|
+
page: customBlockPageSchema
|
|
1347
1501
|
});
|
|
1348
1502
|
|
|
1349
|
-
// ../protocol/src/
|
|
1350
|
-
var
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
spaceId: optional(notionSpaceIdSchema)
|
|
1503
|
+
// ../protocol/src/context/messages/pageError.ts
|
|
1504
|
+
var pageErrorMessageSchema = object({
|
|
1505
|
+
type: literal("pageError"),
|
|
1506
|
+
error: customBlockErrorInfoSchema
|
|
1354
1507
|
});
|
|
1355
1508
|
|
|
1356
|
-
// ../protocol/src/
|
|
1357
|
-
var
|
|
1358
|
-
"
|
|
1359
|
-
|
|
1360
|
-
"brown",
|
|
1361
|
-
"orange",
|
|
1362
|
-
"yellow",
|
|
1363
|
-
"green",
|
|
1364
|
-
"blue",
|
|
1365
|
-
"purple",
|
|
1366
|
-
"pink",
|
|
1367
|
-
"red",
|
|
1368
|
-
"gray_background",
|
|
1369
|
-
"brown_background",
|
|
1370
|
-
"orange_background",
|
|
1371
|
-
"yellow_background",
|
|
1372
|
-
"green_background",
|
|
1373
|
-
"blue_background",
|
|
1374
|
-
"purple_background",
|
|
1375
|
-
"pink_background",
|
|
1376
|
-
"red_background",
|
|
1377
|
-
"default_background"
|
|
1378
|
-
]);
|
|
1379
|
-
var notionPropertyOptionSchema = object({
|
|
1380
|
-
id: string(),
|
|
1381
|
-
name: string(),
|
|
1382
|
-
color: optional(notionPropertyColorSchema),
|
|
1383
|
-
description: optional(string())
|
|
1384
|
-
});
|
|
1385
|
-
var notionStatusGroupSchema = object({
|
|
1386
|
-
id: string(),
|
|
1387
|
-
name: string(),
|
|
1388
|
-
color: optional(notionPropertyColorSchema),
|
|
1389
|
-
option_ids: array(string())
|
|
1390
|
-
});
|
|
1391
|
-
var notionDualPropertySchema = object({
|
|
1392
|
-
synced_property_id: string(),
|
|
1393
|
-
synced_property_name: string()
|
|
1509
|
+
// ../protocol/src/context/messages/parentChanged.ts
|
|
1510
|
+
var parentChangedMessageSchema = object({
|
|
1511
|
+
type: literal("parentChanged"),
|
|
1512
|
+
parent: notionParentSchema
|
|
1394
1513
|
});
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1514
|
+
|
|
1515
|
+
// ../protocol/src/context/messages/parentError.ts
|
|
1516
|
+
var parentErrorMessageSchema = object({
|
|
1517
|
+
type: literal("parentError"),
|
|
1518
|
+
error: customBlockErrorInfoSchema
|
|
1398
1519
|
});
|
|
1399
|
-
var NOTION_PROPERTY_TYPES = [
|
|
1400
|
-
"title",
|
|
1401
|
-
"rich_text",
|
|
1402
|
-
"number",
|
|
1403
|
-
"checkbox",
|
|
1404
|
-
"url",
|
|
1405
|
-
"email",
|
|
1406
|
-
"phone_number",
|
|
1407
|
-
"select",
|
|
1408
|
-
"multi_select",
|
|
1409
|
-
"status",
|
|
1410
|
-
"date",
|
|
1411
|
-
"people",
|
|
1412
|
-
"files",
|
|
1413
|
-
"unique_id",
|
|
1414
|
-
"relation",
|
|
1415
|
-
"place",
|
|
1416
|
-
"formula",
|
|
1417
|
-
"rollup",
|
|
1418
|
-
"button",
|
|
1419
|
-
"verification",
|
|
1420
|
-
"created_time",
|
|
1421
|
-
"last_edited_time",
|
|
1422
|
-
"created_by",
|
|
1423
|
-
"last_edited_by"
|
|
1424
|
-
];
|
|
1425
|
-
var notionPropertyTypeSchema = picklist(NOTION_PROPERTY_TYPES);
|
|
1426
|
-
var notionPropertySchemaSchema = variant("type", [
|
|
1427
|
-
object({ ...baseProp.entries, type: literal("title") }),
|
|
1428
|
-
object({ ...baseProp.entries, type: literal("rich_text") }),
|
|
1429
|
-
object({ ...baseProp.entries, type: literal("number") }),
|
|
1430
|
-
object({ ...baseProp.entries, type: literal("checkbox") }),
|
|
1431
|
-
object({ ...baseProp.entries, type: literal("url") }),
|
|
1432
|
-
object({ ...baseProp.entries, type: literal("email") }),
|
|
1433
|
-
object({ ...baseProp.entries, type: literal("phone_number") }),
|
|
1434
|
-
object({
|
|
1435
|
-
...baseProp.entries,
|
|
1436
|
-
type: literal("select"),
|
|
1437
|
-
options: array(notionPropertyOptionSchema)
|
|
1438
|
-
}),
|
|
1439
|
-
object({
|
|
1440
|
-
...baseProp.entries,
|
|
1441
|
-
type: literal("multi_select"),
|
|
1442
|
-
options: array(notionPropertyOptionSchema)
|
|
1443
|
-
}),
|
|
1444
|
-
object({
|
|
1445
|
-
...baseProp.entries,
|
|
1446
|
-
type: literal("status"),
|
|
1447
|
-
options: array(notionPropertyOptionSchema),
|
|
1448
|
-
groups: array(notionStatusGroupSchema)
|
|
1449
|
-
}),
|
|
1450
|
-
object({ ...baseProp.entries, type: literal("date") }),
|
|
1451
|
-
object({ ...baseProp.entries, type: literal("people") }),
|
|
1452
|
-
object({ ...baseProp.entries, type: literal("files") }),
|
|
1453
|
-
object({ ...baseProp.entries, type: literal("unique_id") }),
|
|
1454
|
-
object({
|
|
1455
|
-
...baseProp.entries,
|
|
1456
|
-
type: literal("relation"),
|
|
1457
|
-
data_source_id: optional(string()),
|
|
1458
|
-
dual_property: optional(notionDualPropertySchema)
|
|
1459
|
-
}),
|
|
1460
|
-
object({ ...baseProp.entries, type: literal("place") }),
|
|
1461
|
-
object({ ...baseProp.entries, type: literal("formula") }),
|
|
1462
|
-
object({ ...baseProp.entries, type: literal("rollup") }),
|
|
1463
|
-
// Internal-only types passed through under their bridge-native names.
|
|
1464
|
-
object({ ...baseProp.entries, type: literal("button") }),
|
|
1465
|
-
object({ ...baseProp.entries, type: literal("verification") }),
|
|
1466
|
-
// Synthetic built-ins. The host always emits one of each per data source.
|
|
1467
|
-
object({ ...baseProp.entries, type: literal("created_time") }),
|
|
1468
|
-
object({ ...baseProp.entries, type: literal("last_edited_time") }),
|
|
1469
|
-
object({ ...baseProp.entries, type: literal("created_by") }),
|
|
1470
|
-
object({ ...baseProp.entries, type: literal("last_edited_by") })
|
|
1471
|
-
]);
|
|
1472
1520
|
|
|
1473
|
-
// ../protocol/src/
|
|
1474
|
-
var
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
* Describes actual database properties in protocol 5. Protocol 3/4 payloads can also include
|
|
1478
|
-
* synthetic metadata for compatibility. Use this map to resolve property bindings. Use this map
|
|
1479
|
-
* to validate filter and sort references.
|
|
1480
|
-
*/
|
|
1481
|
-
propertiesById: record(string(), notionPropertySchemaSchema)
|
|
1521
|
+
// ../protocol/src/context/messages/themeChanged.ts
|
|
1522
|
+
var themeChangedMessageSchema = object({
|
|
1523
|
+
type: literal("themeChanged"),
|
|
1524
|
+
theme: notionThemeSchema
|
|
1482
1525
|
});
|
|
1483
1526
|
|
|
1484
|
-
// ../protocol/src/
|
|
1485
|
-
var
|
|
1486
|
-
|
|
1487
|
-
object({
|
|
1488
|
-
|
|
1489
|
-
object({
|
|
1490
|
-
type: literal("page"),
|
|
1491
|
-
id: notionPageIdSchema,
|
|
1492
|
-
/**
|
|
1493
|
-
* The containing page's own parent. It lets a block distinguish a freestanding page from a
|
|
1494
|
-
* database row without a round trip. Not to be confused with the top-level `parent` runtime
|
|
1495
|
-
* value, which is the custom block's own parent.
|
|
1496
|
-
*/
|
|
1497
|
-
parent: notionParentSchema
|
|
1527
|
+
// ../protocol/src/dataSources/messages/dataSourcesChanged.ts
|
|
1528
|
+
var dataSourcesChangedMessageSchema = object({
|
|
1529
|
+
type: literal("dataSourcesChanged"),
|
|
1530
|
+
dataSources: object({
|
|
1531
|
+
bindings: bridgeDataSourceBindingsSchema
|
|
1498
1532
|
})
|
|
1499
|
-
]);
|
|
1500
|
-
|
|
1501
|
-
// ../protocol/src/context/contrast.ts
|
|
1502
|
-
var notionContrastModeSchema = picklist(["standard", "high"]);
|
|
1503
|
-
|
|
1504
|
-
// ../protocol/src/context/theme.ts
|
|
1505
|
-
var notionThemeSchema = picklist(["light", "dark"]);
|
|
1506
|
-
|
|
1507
|
-
// ../protocol/src/dataSources/bridgeDataSourceBinding.ts
|
|
1508
|
-
var bridgeDataSourceBindingSchema = object({
|
|
1509
|
-
dataSourcePointer: optional(dataSourcePointerValidator),
|
|
1510
|
-
/**
|
|
1511
|
-
* Describes database properties. Use this schema to resolve property bindings. Use this
|
|
1512
|
-
* schema to validate filter and sort references. Undefined when the host does not provide a
|
|
1513
|
-
* database schema.
|
|
1514
|
-
*/
|
|
1515
|
-
dataSourceSchema: optional(notionDataSourceSchemaValidator),
|
|
1516
|
-
/**
|
|
1517
|
-
* Maps user-defined property keys to database property IDs. Use this map to resolve a key
|
|
1518
|
-
* such as `name` to its database property ID. A value of `undefined` marks a declared
|
|
1519
|
-
* property without a binding. Omitted when the host does not provide property mappings.
|
|
1520
|
-
* Synthetic metadata does not add entries to this map.
|
|
1521
|
-
*/
|
|
1522
|
-
propertyIdsByKey: optional(record(string(), optional(string()))),
|
|
1523
|
-
/**
|
|
1524
|
-
* `true` when the data source is bound but the viewer can't read it. The host omits
|
|
1525
|
-
* `dataSourcePointer`, `dataSourceSchema`, and `propertyIdsByKey`, so the binding reveals
|
|
1526
|
-
* nothing about the data source. The block still initializes.
|
|
1527
|
-
*/
|
|
1528
|
-
inaccessible: optional(literal(true))
|
|
1529
1533
|
});
|
|
1530
1534
|
|
|
1531
|
-
// ../protocol/src/dataSources/
|
|
1532
|
-
var
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
)
|
|
1536
|
-
|
|
1537
|
-
// ../protocol/src/manifest/grants.ts
|
|
1538
|
-
var customBlockGrantSchema = object({
|
|
1539
|
-
action: string(),
|
|
1540
|
-
resource: union([string(), pipe(array(string()), minLength(1))])
|
|
1535
|
+
// ../protocol/src/dataSources/messages/getDataSource.ts
|
|
1536
|
+
var getDataSourceMessageSchema = object({
|
|
1537
|
+
type: literal("getDataSource"),
|
|
1538
|
+
requestId: string(),
|
|
1539
|
+
key: string()
|
|
1541
1540
|
});
|
|
1542
|
-
|
|
1543
|
-
// ../protocol/src/manifest/manifest.ts
|
|
1544
|
-
var bridgeManifestIconSchema = variant("type", [
|
|
1541
|
+
var getDataSourceResultMessageSchema = variant("status", [
|
|
1545
1542
|
object({
|
|
1546
|
-
type: literal("
|
|
1547
|
-
|
|
1543
|
+
type: literal("getDataSourceResult"),
|
|
1544
|
+
requestId: string(),
|
|
1545
|
+
status: literal("success"),
|
|
1546
|
+
binding: required(
|
|
1547
|
+
omit(bridgeDataSourceBindingSchema, ["inaccessible"])
|
|
1548
|
+
)
|
|
1548
1549
|
}),
|
|
1549
1550
|
object({
|
|
1550
|
-
type: literal("
|
|
1551
|
-
|
|
1551
|
+
type: literal("getDataSourceResult"),
|
|
1552
|
+
requestId: string(),
|
|
1553
|
+
status: literal("error"),
|
|
1554
|
+
error: customBlockErrorInfoSchema
|
|
1552
1555
|
})
|
|
1553
1556
|
]);
|
|
1554
|
-
var
|
|
1555
|
-
|
|
1556
|
-
description: optional(string()),
|
|
1557
|
-
type: notionPropertyTypeSchema
|
|
1557
|
+
var dataSourcesInvalidatedMessageSchema = object({
|
|
1558
|
+
type: literal("dataSourcesInvalidated")
|
|
1558
1559
|
});
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1560
|
+
|
|
1561
|
+
// ../protocol/src/dataSources/properties/dateValue.ts
|
|
1562
|
+
var notionDateReminderSchema = object({
|
|
1563
|
+
unit: picklist(["year", "month", "week", "day"]),
|
|
1564
|
+
value: number(),
|
|
1565
|
+
time: string(),
|
|
1566
|
+
defaultTimeZone: optional(string())
|
|
1563
1567
|
});
|
|
1564
|
-
var
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
icon: optional(bridgeManifestIconSchema),
|
|
1568
|
-
properties: optional(
|
|
1569
|
-
record(string(), bridgeManifestPropertySchema),
|
|
1570
|
-
{}
|
|
1571
|
-
)
|
|
1568
|
+
var notionTimeReminderSchema = object({
|
|
1569
|
+
unit: picklist(["hour", "minute"]),
|
|
1570
|
+
value: number()
|
|
1572
1571
|
});
|
|
1573
|
-
var
|
|
1574
|
-
|
|
1575
|
-
name: optional(string()),
|
|
1576
|
-
description: optional(string()),
|
|
1577
|
-
slashCommand: optional(string()),
|
|
1578
|
-
icon: optional(object({ type: literal("emoji"), emoji: string() })),
|
|
1579
|
-
dataSources: optional(
|
|
1580
|
-
record(string(), bridgeManifestDataSourceSchema),
|
|
1581
|
-
{}
|
|
1582
|
-
),
|
|
1583
|
-
pages: optional(record(string(), manifestPageSchema)),
|
|
1584
|
-
/**
|
|
1585
|
-
* Grants the block needs. Omitted means the block predates viewer
|
|
1586
|
-
* approval, so hosts do not ask the viewer. An empty array declares
|
|
1587
|
-
* nothing.
|
|
1588
|
-
*/
|
|
1589
|
-
grants: optional(array(customBlockGrantSchema))
|
|
1572
|
+
var notionDisabledReminderSchema = object({
|
|
1573
|
+
unit: literal("none")
|
|
1590
1574
|
});
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1575
|
+
var notionDateTimeReminderSchema = union([
|
|
1576
|
+
notionDateReminderSchema,
|
|
1577
|
+
notionTimeReminderSchema
|
|
1578
|
+
]);
|
|
1579
|
+
var dateOrDisabledReminder = optional(
|
|
1580
|
+
union([notionDateReminderSchema, notionDisabledReminderSchema])
|
|
1581
|
+
);
|
|
1582
|
+
var dateTimeOrDisabledReminder = optional(
|
|
1583
|
+
union([notionDateTimeReminderSchema, notionDisabledReminderSchema])
|
|
1584
|
+
);
|
|
1585
|
+
var notionDateSchema = object({
|
|
1586
|
+
type: literal("date"),
|
|
1587
|
+
start_date: string(),
|
|
1588
|
+
reminder: dateOrDisabledReminder
|
|
1589
|
+
});
|
|
1590
|
+
var notionDateRangeSchema = object({
|
|
1591
|
+
type: literal("daterange"),
|
|
1592
|
+
start_date: string(),
|
|
1593
|
+
end_date: string(),
|
|
1594
|
+
reminder: dateOrDisabledReminder
|
|
1595
|
+
});
|
|
1596
|
+
var notionDateTimeSchema = object({
|
|
1597
|
+
type: literal("datetime"),
|
|
1598
|
+
start_date: string(),
|
|
1599
|
+
start_time: string(),
|
|
1600
|
+
time_zone: optional(string()),
|
|
1601
|
+
reminder: dateTimeOrDisabledReminder
|
|
1602
|
+
});
|
|
1603
|
+
var notionDateTimeRangeSchema = object({
|
|
1604
|
+
type: literal("datetimerange"),
|
|
1605
|
+
start_date: string(),
|
|
1606
|
+
start_time: string(),
|
|
1607
|
+
end_date: string(),
|
|
1608
|
+
end_time: string(),
|
|
1609
|
+
time_zone: optional(string()),
|
|
1610
|
+
reminder: dateTimeOrDisabledReminder
|
|
1611
|
+
});
|
|
1612
|
+
var notionDateValueSchema = variant("type", [
|
|
1613
|
+
notionDateSchema,
|
|
1614
|
+
notionDateRangeSchema,
|
|
1615
|
+
notionDateTimeSchema,
|
|
1616
|
+
notionDateTimeRangeSchema
|
|
1617
|
+
]);
|
|
1618
|
+
|
|
1619
|
+
// ../protocol/src/utils/recordPointer.ts
|
|
1620
|
+
var notionRecordPointerSchema = object({
|
|
1621
|
+
id: string(),
|
|
1622
|
+
table: string()
|
|
1623
|
+
});
|
|
1624
|
+
|
|
1625
|
+
// ../protocol/src/compatibility/protocol3To5/dataSourceValue.ts
|
|
1626
|
+
var notionDataSourceValueSchema = union([
|
|
1627
|
+
string(),
|
|
1628
|
+
number(),
|
|
1629
|
+
boolean(),
|
|
1630
|
+
notionDateValueSchema,
|
|
1631
|
+
array(string()),
|
|
1632
|
+
array(notionRecordPointerSchema)
|
|
1633
|
+
]);
|
|
1634
|
+
|
|
1635
|
+
// ../protocol/src/compatibility/protocol3To5/dataSourcePage.ts
|
|
1636
|
+
var notionDataSourcePageForProtocol3To5Schema = object({
|
|
1637
|
+
id: notionPageIdSchema,
|
|
1638
|
+
/** Whether the page or an ancestor is archived. */
|
|
1639
|
+
is_archived: boolean(),
|
|
1640
|
+
/** Whether the page or an ancestor is in Trash. */
|
|
1641
|
+
in_trash: boolean(),
|
|
1642
|
+
propertiesById: record(string(), optional(notionDataSourceValueSchema))
|
|
1643
|
+
});
|
|
1644
|
+
|
|
1645
|
+
// ../protocol/src/files.ts
|
|
1646
|
+
var bridgeExternalFileSchema = object({
|
|
1647
|
+
type: literal("external"),
|
|
1648
|
+
external: object({ url: string() })
|
|
1649
|
+
});
|
|
1650
|
+
var bridgeNotionHostedFileSchema = object({
|
|
1651
|
+
type: literal("file"),
|
|
1652
|
+
file: object({
|
|
1653
|
+
url: string(),
|
|
1654
|
+
expiry_time: optional(string())
|
|
1604
1655
|
})
|
|
1605
1656
|
});
|
|
1657
|
+
var bridgeFilePropertyItemSchema = union([
|
|
1658
|
+
object({ ...bridgeExternalFileSchema.entries, name: string() }),
|
|
1659
|
+
object({ ...bridgeNotionHostedFileSchema.entries, name: string() })
|
|
1660
|
+
]);
|
|
1606
1661
|
|
|
1607
|
-
// ../protocol/src/
|
|
1608
|
-
var
|
|
1609
|
-
var
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1662
|
+
// ../protocol/src/icons.ts
|
|
1663
|
+
var bridgeIconNameSchema = string();
|
|
1664
|
+
var knownBridgeIconColorSchema = picklist([
|
|
1665
|
+
"gray",
|
|
1666
|
+
"lightgray",
|
|
1667
|
+
"brown",
|
|
1668
|
+
"yellow",
|
|
1669
|
+
"orange",
|
|
1670
|
+
"green",
|
|
1671
|
+
"blue",
|
|
1672
|
+
"purple",
|
|
1673
|
+
"pink",
|
|
1674
|
+
"red"
|
|
1675
|
+
]);
|
|
1676
|
+
var bridgeIconColorSchema = union([
|
|
1677
|
+
knownBridgeIconColorSchema,
|
|
1678
|
+
string()
|
|
1679
|
+
]);
|
|
1680
|
+
var bridgeIconSchema = looseObject({
|
|
1681
|
+
type: literal("icon"),
|
|
1682
|
+
icon: looseObject({
|
|
1683
|
+
name: bridgeIconNameSchema,
|
|
1684
|
+
color: optional(bridgeIconColorSchema)
|
|
1685
|
+
})
|
|
1613
1686
|
});
|
|
1614
|
-
var
|
|
1687
|
+
var bridgeEmojiSchema = object({
|
|
1688
|
+
type: literal("emoji"),
|
|
1689
|
+
emoji: string()
|
|
1690
|
+
});
|
|
1691
|
+
var bridgeCustomEmojiSchema = object({
|
|
1692
|
+
type: literal("custom_emoji"),
|
|
1693
|
+
custom_emoji: object({
|
|
1694
|
+
id: string(),
|
|
1695
|
+
name: optional(string()),
|
|
1696
|
+
url: optional(string())
|
|
1697
|
+
})
|
|
1698
|
+
});
|
|
1699
|
+
|
|
1700
|
+
// ../protocol/src/pages/pageAppearance.ts
|
|
1701
|
+
var bridgePageIconSchema = variant("type", [
|
|
1702
|
+
bridgeIconSchema,
|
|
1703
|
+
bridgeEmojiSchema,
|
|
1704
|
+
bridgeCustomEmojiSchema,
|
|
1705
|
+
bridgeExternalFileSchema,
|
|
1706
|
+
bridgeNotionHostedFileSchema
|
|
1707
|
+
]);
|
|
1708
|
+
var bridgePageCoverSchema = variant("type", [
|
|
1709
|
+
bridgeExternalFileSchema,
|
|
1710
|
+
bridgeNotionHostedFileSchema
|
|
1711
|
+
]);
|
|
1712
|
+
|
|
1713
|
+
// ../protocol/src/utils/nullableStringSchema.ts
|
|
1714
|
+
var nullableStringSchema = nullable(string());
|
|
1715
|
+
|
|
1716
|
+
// ../protocol/src/pages/properties/dateInput.ts
|
|
1717
|
+
var dateInputEntries = {
|
|
1718
|
+
start: string(),
|
|
1719
|
+
end: optional(nullableStringSchema),
|
|
1720
|
+
time_zone: optional(nullableStringSchema),
|
|
1721
|
+
reminder: optional(
|
|
1722
|
+
union([notionDateTimeReminderSchema, notionDisabledReminderSchema])
|
|
1723
|
+
)
|
|
1724
|
+
};
|
|
1725
|
+
var notionDateInputSchema = union([
|
|
1615
1726
|
object({
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
status: literal("success"),
|
|
1619
|
-
theme: notionThemeSchema,
|
|
1620
|
-
contrastMode: notionContrastModeSchema,
|
|
1621
|
-
blockId: notionBlockIdSchema,
|
|
1622
|
-
parent: notionParentSchema,
|
|
1623
|
-
page: customBlockPageSchema,
|
|
1624
|
-
manifest: manifestSchema,
|
|
1625
|
-
dataSources: object({
|
|
1626
|
-
bindings: bridgeDataSourceBindingsSchema
|
|
1627
|
-
}),
|
|
1628
|
-
currentUser: bridgeUserSchema
|
|
1727
|
+
...dateInputEntries,
|
|
1728
|
+
start: pipe(string(), includes("T"))
|
|
1629
1729
|
}),
|
|
1630
1730
|
object({
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1731
|
+
...dateInputEntries,
|
|
1732
|
+
time_zone: string()
|
|
1733
|
+
}),
|
|
1734
|
+
object({
|
|
1735
|
+
...dateInputEntries,
|
|
1736
|
+
reminder: optional(
|
|
1737
|
+
union([notionDateReminderSchema, notionDisabledReminderSchema])
|
|
1738
|
+
)
|
|
1635
1739
|
})
|
|
1636
1740
|
]);
|
|
1637
1741
|
|
|
1638
|
-
// ../protocol/src/
|
|
1639
|
-
var
|
|
1640
|
-
string(),
|
|
1742
|
+
// ../protocol/src/pages/properties/metadataActor.ts
|
|
1743
|
+
var metadataActorSchema = nullable(
|
|
1641
1744
|
object({
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
inaccessible: optional(literal(true))
|
|
1745
|
+
...notionRecordPointerSchema.entries,
|
|
1746
|
+
table: picklist(["notion_user", "bot", "organization_bot"]),
|
|
1747
|
+
spaceId: optional(string())
|
|
1646
1748
|
})
|
|
1647
1749
|
);
|
|
1648
|
-
var dataSourceBindingsMessageForProtocol3To10Schema = variant(
|
|
1649
|
-
"type",
|
|
1650
|
-
[
|
|
1651
|
-
object({
|
|
1652
|
-
...initMessageSchema.options[0].entries,
|
|
1653
|
-
dataSources: object({
|
|
1654
|
-
bindings: bridgeDataSourceBindingsForProtocol3To10Schema
|
|
1655
|
-
})
|
|
1656
|
-
}),
|
|
1657
|
-
object({
|
|
1658
|
-
type: literal("dataSourcesChanged"),
|
|
1659
|
-
dataSources: object({
|
|
1660
|
-
bindings: bridgeDataSourceBindingsForProtocol3To10Schema
|
|
1661
|
-
})
|
|
1662
|
-
})
|
|
1663
|
-
]
|
|
1664
|
-
);
|
|
1665
1750
|
|
|
1666
|
-
// ../protocol/src/
|
|
1667
|
-
var
|
|
1668
|
-
|
|
1669
|
-
|
|
1751
|
+
// ../protocol/src/pages/properties/placeInput.ts
|
|
1752
|
+
var notionPlaceInputSchema = object({
|
|
1753
|
+
lat: number(),
|
|
1754
|
+
lon: number(),
|
|
1755
|
+
name: optional(nullableStringSchema),
|
|
1756
|
+
address: optional(nullableStringSchema),
|
|
1757
|
+
aws_place_id: optional(nullableStringSchema),
|
|
1758
|
+
google_place_id: optional(nullableStringSchema)
|
|
1670
1759
|
});
|
|
1671
1760
|
|
|
1672
|
-
// ../protocol/src/
|
|
1673
|
-
var
|
|
1674
|
-
type: literal("pageChanged"),
|
|
1675
|
-
page: customBlockPageSchema
|
|
1676
|
-
});
|
|
1761
|
+
// ../protocol/src/pages/properties/relationInput.ts
|
|
1762
|
+
var notionRelationInputSchema = object({ id: string() });
|
|
1677
1763
|
|
|
1678
|
-
// ../protocol/src/
|
|
1679
|
-
var
|
|
1680
|
-
type: literal("parentChanged"),
|
|
1681
|
-
parent: notionParentSchema
|
|
1682
|
-
});
|
|
1764
|
+
// ../protocol/src/pages/properties/richText.ts
|
|
1765
|
+
var notionRichTextItemSchema = record(string(), unknown());
|
|
1683
1766
|
|
|
1684
|
-
// ../protocol/src/
|
|
1685
|
-
var
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1767
|
+
// ../protocol/src/pages/properties/selectOption.ts
|
|
1768
|
+
var notionSelectOptionInputSchema = union([
|
|
1769
|
+
object({
|
|
1770
|
+
id: string(),
|
|
1771
|
+
name: optional(string()),
|
|
1772
|
+
color: optional(string()),
|
|
1773
|
+
description: optional(nullableStringSchema)
|
|
1774
|
+
}),
|
|
1775
|
+
object({
|
|
1776
|
+
name: string(),
|
|
1777
|
+
id: optional(string()),
|
|
1778
|
+
color: optional(string()),
|
|
1779
|
+
description: optional(nullableStringSchema)
|
|
1780
|
+
})
|
|
1781
|
+
]);
|
|
1689
1782
|
|
|
1690
|
-
// ../protocol/src/
|
|
1691
|
-
var
|
|
1692
|
-
|
|
1693
|
-
|
|
1783
|
+
// ../protocol/src/pages/properties/userInput.ts
|
|
1784
|
+
var notionUserInputSchema = union([
|
|
1785
|
+
object({
|
|
1786
|
+
object: optional(literal("user")),
|
|
1787
|
+
id: string()
|
|
1788
|
+
}),
|
|
1789
|
+
object({
|
|
1790
|
+
object: literal("group"),
|
|
1791
|
+
id: string(),
|
|
1792
|
+
name: optional(nullableStringSchema)
|
|
1793
|
+
})
|
|
1794
|
+
]);
|
|
1795
|
+
|
|
1796
|
+
// ../protocol/src/pages/properties/bridgePagePropertyValue.ts
|
|
1797
|
+
var pagePropertyBaseSchema = { id: string() };
|
|
1798
|
+
var bridgePagePropertyValueSchema = variant("type", [
|
|
1799
|
+
object({
|
|
1800
|
+
...pagePropertyBaseSchema,
|
|
1801
|
+
type: literal("title"),
|
|
1802
|
+
title: array(notionRichTextItemSchema)
|
|
1803
|
+
}),
|
|
1804
|
+
object({
|
|
1805
|
+
...pagePropertyBaseSchema,
|
|
1806
|
+
type: literal("rich_text"),
|
|
1807
|
+
rich_text: array(notionRichTextItemSchema)
|
|
1808
|
+
}),
|
|
1809
|
+
object({
|
|
1810
|
+
...pagePropertyBaseSchema,
|
|
1811
|
+
type: literal("number"),
|
|
1812
|
+
number: nullable(number())
|
|
1813
|
+
}),
|
|
1814
|
+
object({
|
|
1815
|
+
...pagePropertyBaseSchema,
|
|
1816
|
+
type: literal("url"),
|
|
1817
|
+
url: nullableStringSchema
|
|
1818
|
+
}),
|
|
1819
|
+
object({
|
|
1820
|
+
...pagePropertyBaseSchema,
|
|
1821
|
+
type: literal("email"),
|
|
1822
|
+
email: nullableStringSchema
|
|
1823
|
+
}),
|
|
1824
|
+
object({
|
|
1825
|
+
...pagePropertyBaseSchema,
|
|
1826
|
+
type: literal("phone_number"),
|
|
1827
|
+
phone_number: nullableStringSchema
|
|
1828
|
+
}),
|
|
1829
|
+
object({
|
|
1830
|
+
...pagePropertyBaseSchema,
|
|
1831
|
+
type: literal("checkbox"),
|
|
1832
|
+
checkbox: boolean()
|
|
1833
|
+
}),
|
|
1834
|
+
object({
|
|
1835
|
+
...pagePropertyBaseSchema,
|
|
1836
|
+
type: literal("select"),
|
|
1837
|
+
select: nullable(notionSelectOptionInputSchema)
|
|
1838
|
+
}),
|
|
1839
|
+
object({
|
|
1840
|
+
...pagePropertyBaseSchema,
|
|
1841
|
+
type: literal("status"),
|
|
1842
|
+
status: nullable(notionSelectOptionInputSchema)
|
|
1843
|
+
}),
|
|
1844
|
+
object({
|
|
1845
|
+
...pagePropertyBaseSchema,
|
|
1846
|
+
type: literal("multi_select"),
|
|
1847
|
+
multi_select: array(notionSelectOptionInputSchema)
|
|
1848
|
+
}),
|
|
1849
|
+
object({
|
|
1850
|
+
...pagePropertyBaseSchema,
|
|
1851
|
+
type: literal("date"),
|
|
1852
|
+
date: nullable(notionDateInputSchema)
|
|
1853
|
+
}),
|
|
1854
|
+
object({
|
|
1855
|
+
...pagePropertyBaseSchema,
|
|
1856
|
+
type: literal("people"),
|
|
1857
|
+
people: array(notionUserInputSchema)
|
|
1858
|
+
}),
|
|
1859
|
+
object({
|
|
1860
|
+
...pagePropertyBaseSchema,
|
|
1861
|
+
type: literal("relation"),
|
|
1862
|
+
has_more: optional(boolean()),
|
|
1863
|
+
relation: array(notionRelationInputSchema)
|
|
1864
|
+
}),
|
|
1865
|
+
object({
|
|
1866
|
+
...pagePropertyBaseSchema,
|
|
1867
|
+
type: literal("files"),
|
|
1868
|
+
files: array(bridgeFilePropertyItemSchema)
|
|
1869
|
+
}),
|
|
1870
|
+
object({
|
|
1871
|
+
...pagePropertyBaseSchema,
|
|
1872
|
+
type: literal("place"),
|
|
1873
|
+
place: nullable(notionPlaceInputSchema)
|
|
1874
|
+
}),
|
|
1875
|
+
object({
|
|
1876
|
+
...pagePropertyBaseSchema,
|
|
1877
|
+
type: literal("created_time"),
|
|
1878
|
+
created_time: nullableStringSchema
|
|
1879
|
+
}),
|
|
1880
|
+
object({
|
|
1881
|
+
...pagePropertyBaseSchema,
|
|
1882
|
+
type: literal("last_edited_time"),
|
|
1883
|
+
last_edited_time: nullableStringSchema
|
|
1884
|
+
}),
|
|
1885
|
+
object({
|
|
1886
|
+
...pagePropertyBaseSchema,
|
|
1887
|
+
type: literal("created_by"),
|
|
1888
|
+
created_by: metadataActorSchema
|
|
1889
|
+
}),
|
|
1890
|
+
object({
|
|
1891
|
+
...pagePropertyBaseSchema,
|
|
1892
|
+
type: literal("last_edited_by"),
|
|
1893
|
+
last_edited_by: metadataActorSchema
|
|
1894
|
+
}),
|
|
1895
|
+
object({
|
|
1896
|
+
...pagePropertyBaseSchema,
|
|
1897
|
+
type: literal("unique_id"),
|
|
1898
|
+
unique_id: string()
|
|
1899
|
+
}),
|
|
1900
|
+
object({
|
|
1901
|
+
...pagePropertyBaseSchema,
|
|
1902
|
+
type: literal("button"),
|
|
1903
|
+
button: string()
|
|
1904
|
+
}),
|
|
1905
|
+
object({
|
|
1906
|
+
...pagePropertyBaseSchema,
|
|
1907
|
+
type: literal("formula"),
|
|
1908
|
+
formula: string()
|
|
1909
|
+
}),
|
|
1910
|
+
object({
|
|
1911
|
+
...pagePropertyBaseSchema,
|
|
1912
|
+
type: literal("rollup"),
|
|
1913
|
+
rollup: string()
|
|
1914
|
+
}),
|
|
1915
|
+
object({
|
|
1916
|
+
...pagePropertyBaseSchema,
|
|
1917
|
+
type: literal("verification"),
|
|
1918
|
+
verification: string()
|
|
1919
|
+
})
|
|
1920
|
+
]);
|
|
1921
|
+
|
|
1922
|
+
// ../protocol/src/pages/properties/bridgePagePropertyMaps.ts
|
|
1923
|
+
var bridgePagePropertyWriteMapSchema = record(
|
|
1924
|
+
string(),
|
|
1925
|
+
bridgePagePropertyValueSchema
|
|
1926
|
+
);
|
|
1927
|
+
var bridgePagePropertyReadMapSchema = record(
|
|
1928
|
+
string(),
|
|
1929
|
+
nullable(bridgePagePropertyValueSchema)
|
|
1930
|
+
);
|
|
1931
|
+
|
|
1932
|
+
// ../protocol/src/pages/bridgePage.ts
|
|
1933
|
+
var bridgePageSchema = object({
|
|
1934
|
+
object: literal("page"),
|
|
1935
|
+
id: notionPageIdSchema,
|
|
1936
|
+
parent: notionParentSchema,
|
|
1937
|
+
properties: bridgePagePropertyReadMapSchema,
|
|
1938
|
+
created_by: optional(metadataActorSchema, null),
|
|
1939
|
+
last_edited_by: optional(metadataActorSchema, null),
|
|
1940
|
+
created_time: optional(nullable(string()), null),
|
|
1941
|
+
last_edited_time: optional(nullable(string()), null),
|
|
1942
|
+
icon: optional(nullable(bridgePageIconSchema), null),
|
|
1943
|
+
cover: optional(nullable(bridgePageCoverSchema), null),
|
|
1944
|
+
url: optional(nullable(string()), null),
|
|
1945
|
+
public_url: optional(nullable(string()), null),
|
|
1946
|
+
/** Whether the page or an ancestor is archived. */
|
|
1947
|
+
is_archived: boolean(),
|
|
1948
|
+
/** Whether the page or an ancestor is in Trash. */
|
|
1949
|
+
in_trash: boolean()
|
|
1694
1950
|
});
|
|
1695
1951
|
|
|
1696
1952
|
// ../protocol/src/dataSources/bridgeArchiveStatus.ts
|
|
@@ -1700,9 +1956,14 @@ var bridgeArchiveStatusSchema = picklist([
|
|
|
1700
1956
|
"all"
|
|
1701
1957
|
]);
|
|
1702
1958
|
|
|
1703
|
-
// ../protocol/src/dataSources/
|
|
1704
|
-
var
|
|
1705
|
-
|
|
1959
|
+
// ../protocol/src/dataSources/bridgeDataSourceQueryLimitClamp.ts
|
|
1960
|
+
var bridgeDataSourceQueryLimitClampSchema = pipe(
|
|
1961
|
+
object({
|
|
1962
|
+
requested: pipe(number(), safeInteger(), minValue(1)),
|
|
1963
|
+
applied: pipe(number(), safeInteger(), minValue(1))
|
|
1964
|
+
}),
|
|
1965
|
+
check((value) => value.applied < value.requested)
|
|
1966
|
+
);
|
|
1706
1967
|
|
|
1707
1968
|
// ../protocol/src/dataSources/filters/checkboxFilterOperator.ts
|
|
1708
1969
|
var customBlockCheckboxFilterOperatorSchema = union([
|
|
@@ -1984,34 +2245,6 @@ var bridgeDataSourceSortSchema = strictObject({
|
|
|
1984
2245
|
direction: notionSortDirectionSchema
|
|
1985
2246
|
});
|
|
1986
2247
|
|
|
1987
|
-
// ../protocol/src/dataSources/messages/dataSourcesChanged.ts
|
|
1988
|
-
var dataSourcesChangedMessageSchema = object({
|
|
1989
|
-
type: literal("dataSourcesChanged"),
|
|
1990
|
-
dataSources: object({
|
|
1991
|
-
bindings: bridgeDataSourceBindingsSchema
|
|
1992
|
-
})
|
|
1993
|
-
});
|
|
1994
|
-
|
|
1995
|
-
// ../protocol/src/pages/bridgePage.ts
|
|
1996
|
-
var bridgePageSchema = object({
|
|
1997
|
-
object: literal("page"),
|
|
1998
|
-
id: notionPageIdSchema,
|
|
1999
|
-
parent: notionParentSchema,
|
|
2000
|
-
properties: bridgePagePropertyReadMapSchema,
|
|
2001
|
-
created_by: optional(metadataActorSchema, null),
|
|
2002
|
-
last_edited_by: optional(metadataActorSchema, null),
|
|
2003
|
-
created_time: optional(nullable(string()), null),
|
|
2004
|
-
last_edited_time: optional(nullable(string()), null),
|
|
2005
|
-
icon: optional(nullable(bridgePageIconSchema), null),
|
|
2006
|
-
cover: optional(nullable(bridgePageCoverSchema), null),
|
|
2007
|
-
url: optional(nullable(string()), null),
|
|
2008
|
-
public_url: optional(nullable(string()), null),
|
|
2009
|
-
/** Whether the page or an ancestor is archived. */
|
|
2010
|
-
is_archived: boolean(),
|
|
2011
|
-
/** Whether the page or an ancestor is in Trash. */
|
|
2012
|
-
in_trash: boolean()
|
|
2013
|
-
});
|
|
2014
|
-
|
|
2015
2248
|
// ../protocol/src/dataSources/messages/queryDataSource.ts
|
|
2016
2249
|
var queryDataSourceMessageSchema = object({
|
|
2017
2250
|
type: literal("queryDataSource"),
|
|
@@ -2039,7 +2272,8 @@ var queryDataSourceResultMessageSchema = variant("status", [
|
|
|
2039
2272
|
subscriptionId: string(),
|
|
2040
2273
|
status: literal("success"),
|
|
2041
2274
|
items: array(bridgePageSchema),
|
|
2042
|
-
hasMore: boolean()
|
|
2275
|
+
hasMore: boolean(),
|
|
2276
|
+
limitClamp: optional(bridgeDataSourceQueryLimitClampSchema)
|
|
2043
2277
|
}),
|
|
2044
2278
|
object({
|
|
2045
2279
|
type: literal("queryDataSourceResult"),
|
|
@@ -2056,7 +2290,8 @@ var queryDataSourceResultMessageWithProtocol3To5CompatibilitySchema = variant("s
|
|
|
2056
2290
|
items: array(
|
|
2057
2291
|
union([bridgePageSchema, notionDataSourcePageForProtocol3To5Schema])
|
|
2058
2292
|
),
|
|
2059
|
-
hasMore: boolean()
|
|
2293
|
+
hasMore: boolean(),
|
|
2294
|
+
limitClamp: optional(bridgeDataSourceQueryLimitClampSchema)
|
|
2060
2295
|
}),
|
|
2061
2296
|
object({
|
|
2062
2297
|
type: literal("queryDataSourceResult"),
|
|
@@ -2066,112 +2301,20 @@ var queryDataSourceResultMessageWithProtocol3To5CompatibilitySchema = variant("s
|
|
|
2066
2301
|
})
|
|
2067
2302
|
]);
|
|
2068
2303
|
|
|
2069
|
-
// ../protocol/src/
|
|
2070
|
-
var
|
|
2071
|
-
type: literal("unsubscribeDataSourceQuery"),
|
|
2072
|
-
/** The subscription to remove from the host. */
|
|
2073
|
-
subscriptionId: string()
|
|
2074
|
-
});
|
|
2075
|
-
|
|
2076
|
-
// ../protocol/src/dataSources/notionDataSource.ts
|
|
2077
|
-
var notionDataSourceSchema = object({
|
|
2078
|
-
key: string(),
|
|
2079
|
-
dataSourcePointer: optional(dataSourcePointerValidator),
|
|
2080
|
-
/**
|
|
2081
|
-
* Describes database properties. Use this schema to resolve property bindings. Use this
|
|
2082
|
-
* schema to validate filter and sort references. Undefined when the host does not provide a
|
|
2083
|
-
* database schema.
|
|
2084
|
-
*/
|
|
2085
|
-
dataSourceSchema: optional(notionDataSourceSchemaValidator),
|
|
2086
|
-
/**
|
|
2087
|
-
* Maps user-defined property keys to database property IDs. Use this map to resolve a key
|
|
2088
|
-
* such as `name` to its database property ID. A value of `undefined` marks a declared
|
|
2089
|
-
* property without a valid binding. Synthetic metadata does not add entries to this map.
|
|
2090
|
-
*/
|
|
2091
|
-
propertyIdsByKey: record(string(), optional(string())),
|
|
2092
|
-
/**
|
|
2093
|
-
* Describes property values in query snapshots. Keys use the same property IDs as a snapshot's
|
|
2094
|
-
* `propertiesById` map.
|
|
2095
|
-
*
|
|
2096
|
-
* Includes four synthetic metadata fields, even when the database schema is unavailable:
|
|
2097
|
-
* `created_time`, `last_edited_time`, `created_by`, and `last_edited_by`. Also includes
|
|
2098
|
-
* database properties when the host provides their schema.
|
|
2099
|
-
*
|
|
2100
|
-
* Use `propertiesById` to read a value. Use this map to read the value's schema. Use
|
|
2101
|
-
* `dataSourceSchema` to validate filter and sort references.
|
|
2102
|
-
*/
|
|
2103
|
-
propertySchemasById: record(string(), notionPropertySchemaSchema),
|
|
2104
|
-
/**
|
|
2105
|
-
* `true` when the data source is bound but the viewer can't read it. The block still
|
|
2106
|
-
* initializes. Queries and writes that use this data source fail with
|
|
2107
|
-
* `data_source_inaccessible`.
|
|
2108
|
-
*/
|
|
2109
|
-
inaccessible: optional(literal(true))
|
|
2110
|
-
});
|
|
2111
|
-
|
|
2112
|
-
// ../protocol/src/utils/errors.ts
|
|
2113
|
-
var customBlockErrorInfoSchema = object({
|
|
2114
|
-
code: string(),
|
|
2115
|
-
message: string(),
|
|
2116
|
-
isRetryable: boolean()
|
|
2117
|
-
});
|
|
2118
|
-
|
|
2119
|
-
// ../protocol/src/handshake/connect.ts
|
|
2120
|
-
var connectMessageCommonEntries = {
|
|
2121
|
-
type: literal("connect"),
|
|
2122
|
-
initializationId: string(),
|
|
2123
|
-
/**
|
|
2124
|
-
* The bridge protocol version this sandbox uses to communicate with its host.
|
|
2125
|
-
* Hosts control which versions they support and can support multiple versions
|
|
2126
|
-
* at the same time. Support for older versions is eventually removed, so blocks
|
|
2127
|
-
* may need to update their SDK to continue working.
|
|
2128
|
-
*/
|
|
2129
|
-
bridgeProtocolVersion: number(),
|
|
2130
|
-
/**
|
|
2131
|
-
* Semver version of the SDK package that sent this connect message. Should only be used for
|
|
2132
|
-
* analytics purposes. Business logic should compare against `bridgeProtocolVersion` instead.
|
|
2133
|
-
*/
|
|
2134
|
-
sdkVersion: string()
|
|
2135
|
-
};
|
|
2136
|
-
var connectMessageSchema = variant("status", [
|
|
2137
|
-
object({
|
|
2138
|
-
status: literal("success"),
|
|
2139
|
-
/**
|
|
2140
|
-
* The custom block manifest injected by local dev tooling. The SDK omits it on
|
|
2141
|
-
* non-loopback origins. Initialization uses it only when manifestSource is "sandbox".
|
|
2142
|
-
*/
|
|
2143
|
-
manifest: optional(manifestSchema),
|
|
2144
|
-
...connectMessageCommonEntries
|
|
2145
|
-
}),
|
|
2146
|
-
object({
|
|
2147
|
-
status: literal("error"),
|
|
2148
|
-
error: customBlockErrorInfoSchema,
|
|
2149
|
-
...connectMessageCommonEntries
|
|
2150
|
-
})
|
|
2151
|
-
]);
|
|
2152
|
-
|
|
2153
|
-
// ../protocol/src/handshake/initResult.ts
|
|
2154
|
-
var customBlockInitResultErrorCodeSchema = string();
|
|
2155
|
-
var customBlockInitResultErrorInfoSchema = object({
|
|
2156
|
-
code: customBlockInitResultErrorCodeSchema,
|
|
2157
|
-
message: string(),
|
|
2158
|
-
isRetryable: boolean()
|
|
2159
|
-
});
|
|
2160
|
-
var initResultMessageSchema = variant("status", [
|
|
2304
|
+
// ../protocol/src/handshake/connectResult.ts
|
|
2305
|
+
var connectResultMessageSchema = variant("status", [
|
|
2161
2306
|
object({
|
|
2162
|
-
type: literal("
|
|
2163
|
-
|
|
2307
|
+
type: literal("connectResult"),
|
|
2308
|
+
requestId: string(),
|
|
2164
2309
|
status: literal("success"),
|
|
2165
|
-
/**
|
|
2166
|
-
|
|
2167
|
-
// TODO(custom-blocks): Make this required when MIN_HOST_SUPPORTED_BRIDGE_PROTOCOL_VERSION increases to 4.
|
|
2168
|
-
initialHeight: optional(pipe(number(), finite(), minValue(0)))
|
|
2310
|
+
/** The version selected from `connect.supportedProtocolVersions`, used for the rest of this connection. */
|
|
2311
|
+
protocolVersion: pipe(number(), integer(), minValue(1))
|
|
2169
2312
|
}),
|
|
2170
2313
|
object({
|
|
2171
|
-
type: literal("
|
|
2172
|
-
|
|
2314
|
+
type: literal("connectResult"),
|
|
2315
|
+
requestId: string(),
|
|
2173
2316
|
status: literal("error"),
|
|
2174
|
-
error:
|
|
2317
|
+
error: customBlockErrorInfoSchema
|
|
2175
2318
|
})
|
|
2176
2319
|
]);
|
|
2177
2320
|
|
|
@@ -2201,6 +2344,24 @@ var openExternalUrlResultMessageSchema = variant("status", [
|
|
|
2201
2344
|
})
|
|
2202
2345
|
]);
|
|
2203
2346
|
|
|
2347
|
+
// ../protocol/src/compatibility/protocol3To5/bridgePage.ts
|
|
2348
|
+
var bridgePageForProtocol3To5Schema = object({
|
|
2349
|
+
object: literal("page"),
|
|
2350
|
+
id: notionPageIdSchema,
|
|
2351
|
+
parent: notionParentSchema,
|
|
2352
|
+
properties: bridgePagePropertyWriteMapSchema,
|
|
2353
|
+
created_time: optional(string()),
|
|
2354
|
+
last_edited_time: optional(string()),
|
|
2355
|
+
icon: optional(bridgePageIconSchema),
|
|
2356
|
+
cover: optional(bridgePageCoverSchema),
|
|
2357
|
+
url: optional(string()),
|
|
2358
|
+
public_url: optional(string()),
|
|
2359
|
+
/** Whether the page or an ancestor is archived. */
|
|
2360
|
+
is_archived: boolean(),
|
|
2361
|
+
/** Whether the page or an ancestor is in Trash. */
|
|
2362
|
+
in_trash: boolean()
|
|
2363
|
+
});
|
|
2364
|
+
|
|
2204
2365
|
// ../protocol/src/pages/messages/createPage.ts
|
|
2205
2366
|
var customBlockCreatePageErrorCodeSchema = string();
|
|
2206
2367
|
var customBlockCreatePageErrorInfoSchema = object({
|
|
@@ -2404,7 +2565,7 @@ var updatePageMessageSchema = object({
|
|
|
2404
2565
|
* Property values, keyed by raw property IDs from Notion.
|
|
2405
2566
|
*
|
|
2406
2567
|
* Each value must carry the same raw property ID in its `id` field.
|
|
2407
|
-
* To update a page with manifest-defined property keys, call `row.
|
|
2568
|
+
* To update a page with manifest-defined property keys, call `row.updateByKey()` on a row returned
|
|
2408
2569
|
* by `useDataSource()`. The SDK resolves those keys before it sends this message.
|
|
2409
2570
|
*/
|
|
2410
2571
|
properties: optional(bridgePagePropertyWriteMapSchema),
|
|
@@ -2413,12 +2574,45 @@ var updatePageMessageSchema = object({
|
|
|
2413
2574
|
archived: optional(boolean())
|
|
2414
2575
|
});
|
|
2415
2576
|
|
|
2577
|
+
// ../protocol/src/users/bridgeUser.ts
|
|
2578
|
+
var bridgeUserSchema = object({
|
|
2579
|
+
object: literal("user"),
|
|
2580
|
+
id: notionUserIdSchema,
|
|
2581
|
+
/** The user's name, or `null` when unavailable. Empty strings are preserved. */
|
|
2582
|
+
name: nullable(string()),
|
|
2583
|
+
avatar_url: nullable(string()),
|
|
2584
|
+
type: literal("person"),
|
|
2585
|
+
person: object({
|
|
2586
|
+
email: string()
|
|
2587
|
+
})
|
|
2588
|
+
});
|
|
2589
|
+
|
|
2416
2590
|
// ../protocol/src/users/messages/currentUserChanged.ts
|
|
2417
2591
|
var currentUserChangedMessageSchema = object({
|
|
2418
2592
|
type: literal("currentUserChanged"),
|
|
2419
2593
|
currentUser: bridgeUserSchema
|
|
2420
2594
|
});
|
|
2421
2595
|
|
|
2596
|
+
// ../protocol/src/users/messages/getCurrentUser.ts
|
|
2597
|
+
var getCurrentUserMessageSchema = object({
|
|
2598
|
+
type: literal("getCurrentUser"),
|
|
2599
|
+
requestId: string()
|
|
2600
|
+
});
|
|
2601
|
+
var getCurrentUserResultMessageSchema = variant("status", [
|
|
2602
|
+
object({
|
|
2603
|
+
type: literal("getCurrentUserResult"),
|
|
2604
|
+
requestId: string(),
|
|
2605
|
+
status: literal("success"),
|
|
2606
|
+
user: bridgeUserSchema
|
|
2607
|
+
}),
|
|
2608
|
+
object({
|
|
2609
|
+
type: literal("getCurrentUserResult"),
|
|
2610
|
+
requestId: string(),
|
|
2611
|
+
status: literal("error"),
|
|
2612
|
+
error: customBlockErrorInfoSchema
|
|
2613
|
+
})
|
|
2614
|
+
]);
|
|
2615
|
+
|
|
2422
2616
|
// ../protocol/src/users/messages/getUser.ts
|
|
2423
2617
|
var customBlockGetUserErrorCodeSchema = string();
|
|
2424
2618
|
var customBlockGetUserErrorInfoSchema = object({
|
|
@@ -2469,24 +2663,128 @@ var listUsersMessageSchema = object({
|
|
|
2469
2663
|
startCursor: optional(string()),
|
|
2470
2664
|
pageSize: optional(number())
|
|
2471
2665
|
});
|
|
2472
|
-
var listUsersResultMessageSchema = variant("status", [
|
|
2473
|
-
object({
|
|
2474
|
-
type: literal("listUsersResult"),
|
|
2475
|
-
requestId: string(),
|
|
2476
|
-
status: literal("success"),
|
|
2477
|
-
list: bridgeUserListSchema
|
|
2478
|
-
}),
|
|
2479
|
-
object({
|
|
2480
|
-
type: literal("listUsersResult"),
|
|
2481
|
-
requestId: string(),
|
|
2482
|
-
status: literal("error"),
|
|
2483
|
-
error: customBlockListUsersErrorInfoSchema
|
|
2484
|
-
})
|
|
2485
|
-
]);
|
|
2666
|
+
var listUsersResultMessageSchema = variant("status", [
|
|
2667
|
+
object({
|
|
2668
|
+
type: literal("listUsersResult"),
|
|
2669
|
+
requestId: string(),
|
|
2670
|
+
status: literal("success"),
|
|
2671
|
+
list: bridgeUserListSchema
|
|
2672
|
+
}),
|
|
2673
|
+
object({
|
|
2674
|
+
type: literal("listUsersResult"),
|
|
2675
|
+
requestId: string(),
|
|
2676
|
+
status: literal("error"),
|
|
2677
|
+
error: customBlockListUsersErrorInfoSchema
|
|
2678
|
+
})
|
|
2679
|
+
]);
|
|
2680
|
+
|
|
2681
|
+
// ../protocol/src/messages/invalidSandboxMessage.ts
|
|
2682
|
+
var invalidSandboxMessageSchema = object({
|
|
2683
|
+
type: literal("invalidSandboxMessage"),
|
|
2684
|
+
/** Identifies the rejected request or response, when readable. */
|
|
2685
|
+
requestId: optional(string()),
|
|
2686
|
+
/**
|
|
2687
|
+
* A human-readable string intended for sandbox-side logging. It has no structured contract.
|
|
2688
|
+
*/
|
|
2689
|
+
reason: string()
|
|
2690
|
+
});
|
|
2691
|
+
|
|
2692
|
+
// ../protocol/src/messages/hostToSandbox.ts
|
|
2693
|
+
var hostToSandboxMessageSchema = variant("type", [
|
|
2694
|
+
connectResultMessageSchema,
|
|
2695
|
+
setupInitMessageSchema,
|
|
2696
|
+
getDataSourceResultMessageSchema,
|
|
2697
|
+
getCurrentUserResultMessageSchema,
|
|
2698
|
+
dataSourcesInvalidatedMessageSchema,
|
|
2699
|
+
themeChangedMessageSchema,
|
|
2700
|
+
contrastModeChangedMessageSchema,
|
|
2701
|
+
parentChangedMessageSchema,
|
|
2702
|
+
pageChangedMessageSchema,
|
|
2703
|
+
pageErrorMessageSchema,
|
|
2704
|
+
parentErrorMessageSchema,
|
|
2705
|
+
currentUserChangedMessageSchema,
|
|
2706
|
+
dataSourcesChangedMessageSchema,
|
|
2707
|
+
getUserResultMessageSchema,
|
|
2708
|
+
listUsersResultMessageSchema,
|
|
2709
|
+
openPageResultMessageSchema,
|
|
2710
|
+
openExternalUrlResultMessageSchema,
|
|
2711
|
+
invalidSandboxMessageSchema,
|
|
2712
|
+
queryDataSourceResultMessageSchema,
|
|
2713
|
+
getPageResultMessageSchema,
|
|
2714
|
+
createPageResultMessageSchema,
|
|
2715
|
+
updatePageResultMessageSchema
|
|
2716
|
+
]);
|
|
2717
|
+
|
|
2718
|
+
// ../protocol/src/compatibility/protocol3To11/hostToSandbox.ts
|
|
2719
|
+
var protocol3To11HostToSandboxMessageSchema = variant("type", [
|
|
2720
|
+
protocol3To11InitMessageSchema,
|
|
2721
|
+
themeChangedMessageSchema,
|
|
2722
|
+
contrastModeChangedMessageSchema,
|
|
2723
|
+
parentChangedMessageSchema,
|
|
2724
|
+
protocol3To11PageChangedMessageSchema,
|
|
2725
|
+
currentUserChangedForProtocol3To11Schema,
|
|
2726
|
+
dataSourcesChangedMessageSchema,
|
|
2727
|
+
getUserResultForProtocol3To11Schema,
|
|
2728
|
+
listUsersResultForProtocol3To11Schema,
|
|
2729
|
+
openPageResultMessageSchema,
|
|
2730
|
+
openExternalUrlResultMessageSchema,
|
|
2731
|
+
invalidSandboxMessageSchema,
|
|
2732
|
+
queryDataSourceResultMessageWithProtocol3To5CompatibilitySchema,
|
|
2733
|
+
getPageResultMessageWithProtocol3To5CompatibilitySchema,
|
|
2734
|
+
createPageResultMessageWithProtocol3To5CompatibilitySchema,
|
|
2735
|
+
updatePageResultMessageWithProtocol3To5CompatibilitySchema
|
|
2736
|
+
]);
|
|
2737
|
+
|
|
2738
|
+
// ../protocol/src/compatibility/hostToSandbox.ts
|
|
2739
|
+
var hostToSandboxMessageWithCompatibilitySchema = union([
|
|
2740
|
+
hostToSandboxMessageSchema,
|
|
2741
|
+
protocol3To11HostToSandboxMessageSchema
|
|
2742
|
+
]);
|
|
2743
|
+
|
|
2744
|
+
// ../protocol/src/compatibility/protocol3To10/dataSourceBindings.ts
|
|
2745
|
+
var bridgeDataSourceBindingsForProtocol3To10Schema = record(
|
|
2746
|
+
string(),
|
|
2747
|
+
object({
|
|
2748
|
+
collectionPointer: optional(dataSourcePointerValidator),
|
|
2749
|
+
collectionSchema: optional(notionDataSourceSchemaValidator),
|
|
2750
|
+
propertyIdsByKey: optional(record(string(), optional(string()))),
|
|
2751
|
+
inaccessible: optional(literal(true))
|
|
2752
|
+
})
|
|
2753
|
+
);
|
|
2754
|
+
var dataSourceBindingsMessageForProtocol3To10Schema = variant(
|
|
2755
|
+
"type",
|
|
2756
|
+
[
|
|
2757
|
+
object({
|
|
2758
|
+
...protocol3To11InitSuccessMessageSchema.entries,
|
|
2759
|
+
dataSources: object({
|
|
2760
|
+
bindings: bridgeDataSourceBindingsForProtocol3To10Schema
|
|
2761
|
+
})
|
|
2762
|
+
}),
|
|
2763
|
+
object({
|
|
2764
|
+
type: literal("dataSourcesChanged"),
|
|
2765
|
+
dataSources: object({
|
|
2766
|
+
bindings: bridgeDataSourceBindingsForProtocol3To10Schema
|
|
2767
|
+
})
|
|
2768
|
+
})
|
|
2769
|
+
]
|
|
2770
|
+
);
|
|
2771
|
+
|
|
2772
|
+
// ../protocol/src/context/messages/resize.ts
|
|
2773
|
+
var resizeMessageSchema = object({
|
|
2774
|
+
type: literal("resize"),
|
|
2775
|
+
height: pipe(number(), finite(), minValue(0))
|
|
2776
|
+
});
|
|
2777
|
+
|
|
2778
|
+
// ../protocol/src/dataSources/messages/unsubscribeDataSourceQuery.ts
|
|
2779
|
+
var unsubscribeDataSourceQueryMessageSchema = object({
|
|
2780
|
+
type: literal("unsubscribeDataSourceQuery"),
|
|
2781
|
+
/** The subscription to remove from the host. */
|
|
2782
|
+
subscriptionId: string()
|
|
2783
|
+
});
|
|
2486
2784
|
|
|
2487
|
-
// ../protocol/src/messages/
|
|
2488
|
-
var
|
|
2489
|
-
type: literal("
|
|
2785
|
+
// ../protocol/src/messages/invalidHostMessage.ts
|
|
2786
|
+
var invalidHostMessageSchema = object({
|
|
2787
|
+
type: literal("invalidHostMessage"),
|
|
2490
2788
|
/** Identifies the rejected request or response, when readable. */
|
|
2491
2789
|
requestId: optional(string()),
|
|
2492
2790
|
/**
|
|
@@ -2495,51 +2793,57 @@ var invalidSandboxMessageSchema = object({
|
|
|
2495
2793
|
reason: string()
|
|
2496
2794
|
});
|
|
2497
2795
|
|
|
2498
|
-
// ../protocol/src/
|
|
2499
|
-
var
|
|
2500
|
-
|
|
2796
|
+
// ../protocol/src/compatibility/protocol3To11/sandboxToHost.ts
|
|
2797
|
+
var protocol3To11SandboxToHostMessageSchema = variant("type", [
|
|
2798
|
+
protocol3To11ConnectMessageSchema,
|
|
2799
|
+
protocol3To11InitResultMessageSchema,
|
|
2800
|
+
queryDataSourceMessageSchema,
|
|
2801
|
+
unsubscribeDataSourceQueryMessageSchema,
|
|
2802
|
+
createPageMessageSchema,
|
|
2803
|
+
getPageMessageSchema,
|
|
2804
|
+
getUserMessageSchema,
|
|
2805
|
+
listUsersMessageSchema,
|
|
2806
|
+
openPageMessageSchema,
|
|
2807
|
+
openExternalUrlMessageSchema,
|
|
2808
|
+
updatePageMessageSchema,
|
|
2809
|
+
resizeMessageSchema,
|
|
2810
|
+
invalidHostMessageSchema
|
|
2811
|
+
]);
|
|
2812
|
+
|
|
2813
|
+
// ../protocol/src/compatibility/protocol11/hostToSandbox.ts
|
|
2814
|
+
var protocol11HostToSandboxMessageSchema = variant("type", [
|
|
2815
|
+
protocol3To11InitMessageSchema,
|
|
2501
2816
|
themeChangedMessageSchema,
|
|
2502
2817
|
contrastModeChangedMessageSchema,
|
|
2503
2818
|
parentChangedMessageSchema,
|
|
2504
|
-
|
|
2505
|
-
|
|
2819
|
+
protocol3To11PageChangedMessageSchema,
|
|
2820
|
+
currentUserChangedForProtocol3To11Schema,
|
|
2506
2821
|
dataSourcesChangedMessageSchema,
|
|
2507
|
-
|
|
2508
|
-
|
|
2822
|
+
getUserResultForProtocol3To11Schema,
|
|
2823
|
+
listUsersResultForProtocol3To11Schema,
|
|
2509
2824
|
openPageResultMessageSchema,
|
|
2510
2825
|
openExternalUrlResultMessageSchema,
|
|
2511
|
-
invalidSandboxMessageSchema
|
|
2512
|
-
]);
|
|
2513
|
-
var hostToSandboxMessageSchema = variant("type", [
|
|
2514
|
-
...baseHostToSandboxMessageSchema.options,
|
|
2826
|
+
invalidSandboxMessageSchema,
|
|
2515
2827
|
queryDataSourceResultMessageSchema,
|
|
2516
2828
|
getPageResultMessageSchema,
|
|
2517
2829
|
createPageResultMessageSchema,
|
|
2518
2830
|
updatePageResultMessageSchema
|
|
2519
2831
|
]);
|
|
2520
|
-
var hostToSandboxMessageWithProtocol3To5CompatibilitySchema = variant("type", [
|
|
2521
|
-
...baseHostToSandboxMessageSchema.options,
|
|
2522
|
-
queryDataSourceResultMessageWithProtocol3To5CompatibilitySchema,
|
|
2523
|
-
getPageResultMessageWithProtocol3To5CompatibilitySchema,
|
|
2524
|
-
createPageResultMessageWithProtocol3To5CompatibilitySchema,
|
|
2525
|
-
updatePageResultMessageWithProtocol3To5CompatibilitySchema
|
|
2526
|
-
]);
|
|
2527
2832
|
|
|
2528
|
-
// ../protocol/src/
|
|
2529
|
-
var
|
|
2530
|
-
type: literal("
|
|
2531
|
-
/**
|
|
2532
|
-
|
|
2533
|
-
/**
|
|
2534
|
-
* A human-readable string intended for sandbox-side logging. It has no structured contract.
|
|
2535
|
-
*/
|
|
2536
|
-
reason: string()
|
|
2833
|
+
// ../protocol/src/handshake/ready.ts
|
|
2834
|
+
var readyMessageSchema = object({
|
|
2835
|
+
type: literal("ready"),
|
|
2836
|
+
/** Initial rendered content height in CSS pixels, applied by the embedding application before reveal. */
|
|
2837
|
+
initialHeight: pipe(number(), finite(), minValue(0))
|
|
2537
2838
|
});
|
|
2538
2839
|
|
|
2539
2840
|
// ../protocol/src/messages/sandboxToHost.ts
|
|
2540
2841
|
var sandboxToHostMessageSchema = variant("type", [
|
|
2541
|
-
|
|
2542
|
-
|
|
2842
|
+
connectRequestMessageSchema,
|
|
2843
|
+
getDataSourceMessageSchema,
|
|
2844
|
+
getCurrentUserMessageSchema,
|
|
2845
|
+
initResultRequestMessageSchema,
|
|
2846
|
+
readyMessageSchema,
|
|
2543
2847
|
queryDataSourceMessageSchema,
|
|
2544
2848
|
unsubscribeDataSourceQueryMessageSchema,
|
|
2545
2849
|
createPageMessageSchema,
|
|
@@ -2553,6 +2857,52 @@ var sandboxToHostMessageSchema = variant("type", [
|
|
|
2553
2857
|
invalidHostMessageSchema
|
|
2554
2858
|
]);
|
|
2555
2859
|
|
|
2860
|
+
// ../protocol/src/compatibility/sandboxToHost.ts
|
|
2861
|
+
var sandboxToHostMessageWithCompatibilitySchema = union([
|
|
2862
|
+
sandboxToHostMessageSchema,
|
|
2863
|
+
protocol3To11SandboxToHostMessageSchema
|
|
2864
|
+
]);
|
|
2865
|
+
|
|
2866
|
+
// ../protocol/src/dataSources/errors.ts
|
|
2867
|
+
var customBlockDataSourceResolutionErrorCodeSchema = string();
|
|
2868
|
+
var customBlockPropertyErrorCodeSchema = string();
|
|
2869
|
+
|
|
2870
|
+
// ../protocol/src/dataSources/notionDataSource.ts
|
|
2871
|
+
var notionDataSourceSchema = object({
|
|
2872
|
+
key: string(),
|
|
2873
|
+
dataSourcePointer: optional(dataSourcePointerValidator),
|
|
2874
|
+
/**
|
|
2875
|
+
* Describes database properties. Use this schema to resolve property bindings. Use this
|
|
2876
|
+
* schema to validate filter and sort references. Undefined when the host does not provide a
|
|
2877
|
+
* database schema.
|
|
2878
|
+
*/
|
|
2879
|
+
dataSourceSchema: optional(notionDataSourceSchemaValidator),
|
|
2880
|
+
/**
|
|
2881
|
+
* Maps user-defined property keys to database property IDs. Use this map to resolve a key
|
|
2882
|
+
* such as `name` to its database property ID. A value of `undefined` marks a declared
|
|
2883
|
+
* property without a valid binding. Synthetic metadata does not add entries to this map.
|
|
2884
|
+
*/
|
|
2885
|
+
propertyIdsByKey: record(string(), optional(string())),
|
|
2886
|
+
/**
|
|
2887
|
+
* Describes property values in query snapshots. Keys use the same property IDs as a snapshot's
|
|
2888
|
+
* `propertiesById` map.
|
|
2889
|
+
*
|
|
2890
|
+
* Includes four synthetic metadata fields, even when the database schema is unavailable:
|
|
2891
|
+
* `created_time`, `last_edited_time`, `created_by`, and `last_edited_by`. Also includes
|
|
2892
|
+
* database properties when the host provides their schema.
|
|
2893
|
+
*
|
|
2894
|
+
* Use `propertiesById` to read a value. Use this map to read the value's schema. Use
|
|
2895
|
+
* `dataSourceSchema` to validate filter and sort references.
|
|
2896
|
+
*/
|
|
2897
|
+
propertySchemasById: record(string(), notionPropertySchemaSchema),
|
|
2898
|
+
/**
|
|
2899
|
+
* `true` when the data source is bound but the viewer can't read it. The block still
|
|
2900
|
+
* initializes. Queries and writes that use this data source fail with
|
|
2901
|
+
* `data_source_inaccessible`.
|
|
2902
|
+
*/
|
|
2903
|
+
inaccessible: optional(literal(true))
|
|
2904
|
+
});
|
|
2905
|
+
|
|
2556
2906
|
// ../protocol/src/utils/readRequestId.ts
|
|
2557
2907
|
var requestIdentitySchema = object({ requestId: string() });
|
|
2558
2908
|
|
|
@@ -2619,6 +2969,50 @@ function slugify(name) {
|
|
|
2619
2969
|
import { readFileSync } from "node:fs";
|
|
2620
2970
|
import { basename, resolve } from "node:path";
|
|
2621
2971
|
|
|
2972
|
+
// shared/dataSources/sampleDataSource.ts
|
|
2973
|
+
var sampleDataSourceTypeSchema = picklist([
|
|
2974
|
+
"built-in",
|
|
2975
|
+
"worker",
|
|
2976
|
+
"manual",
|
|
2977
|
+
"syncedFromProd"
|
|
2978
|
+
]);
|
|
2979
|
+
var sampleDataSourceRowSchema = looseObject({ id: string() });
|
|
2980
|
+
var sampleDataSourcePropertiesSchema = record(
|
|
2981
|
+
string(),
|
|
2982
|
+
notionPropertySchemaSchema
|
|
2983
|
+
);
|
|
2984
|
+
var loadedSampleDataSourceSchema = object({
|
|
2985
|
+
status: literal("loaded"),
|
|
2986
|
+
/** Filename without .json. This is the sample data source's identity. */
|
|
2987
|
+
filename: string(),
|
|
2988
|
+
type: sampleDataSourceTypeSchema,
|
|
2989
|
+
name: string(),
|
|
2990
|
+
icon: optional(string()),
|
|
2991
|
+
schema: sampleDataSourcePropertiesSchema,
|
|
2992
|
+
rows: array(sampleDataSourceRowSchema)
|
|
2993
|
+
});
|
|
2994
|
+
var sampleDataSourceLoadErrorSchema = object({
|
|
2995
|
+
status: literal("failed"),
|
|
2996
|
+
filename: string(),
|
|
2997
|
+
message: string()
|
|
2998
|
+
});
|
|
2999
|
+
var sampleDataSourceSchema = variant("status", [
|
|
3000
|
+
loadedSampleDataSourceSchema,
|
|
3001
|
+
sampleDataSourceLoadErrorSchema
|
|
3002
|
+
]);
|
|
3003
|
+
function selectSampleDataSource({
|
|
3004
|
+
slotKey,
|
|
3005
|
+
sources,
|
|
3006
|
+
explicitFilename
|
|
3007
|
+
}) {
|
|
3008
|
+
if (explicitFilename !== void 0) {
|
|
3009
|
+
return sources.find(
|
|
3010
|
+
(source) => `${source.filename}.json` === explicitFilename
|
|
3011
|
+
);
|
|
3012
|
+
}
|
|
3013
|
+
return sources.find((source) => source.filename === `worker_${slotKey}`) ?? sources.find((source) => source.filename === slotKey);
|
|
3014
|
+
}
|
|
3015
|
+
|
|
2622
3016
|
// ../node_modules/.pnpm/temporal-polyfill@1.0.6/node_modules/temporal-polyfill/chunks/root.js
|
|
2623
3017
|
var NativeTemporal = globalThis.Temporal;
|
|
2624
3018
|
|
|
@@ -6356,48 +6750,104 @@ var Temporal = /* @__PURE__ */ Object.defineProperties({}, {
|
|
|
6356
6750
|
var Temporal2 = NativeTemporal || Temporal;
|
|
6357
6751
|
var toTemporalInstant2 = NativeTemporal ? Date.prototype.toTemporalInstant : toTemporalInstant;
|
|
6358
6752
|
|
|
6359
|
-
// shared/
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
|
|
6365
|
-
|
|
6366
|
-
|
|
6367
|
-
|
|
6368
|
-
|
|
6369
|
-
|
|
6370
|
-
|
|
6371
|
-
|
|
6372
|
-
|
|
6373
|
-
|
|
6374
|
-
|
|
6375
|
-
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
})
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
|
|
6384
|
-
|
|
6385
|
-
|
|
6386
|
-
|
|
6387
|
-
|
|
6388
|
-
|
|
6389
|
-
|
|
6390
|
-
|
|
6391
|
-
|
|
6392
|
-
|
|
6393
|
-
|
|
6753
|
+
// shared/utils/unreachable.ts
|
|
6754
|
+
function unreachable(value) {
|
|
6755
|
+
throw new Error(
|
|
6756
|
+
`[custom-blocks-dev-shell] Unexpected value encountered: ${JSON.stringify(value)}`
|
|
6757
|
+
);
|
|
6758
|
+
}
|
|
6759
|
+
|
|
6760
|
+
// shared/dataSources/toNotionDateInput.ts
|
|
6761
|
+
function toNotionDateInput(value) {
|
|
6762
|
+
if ("time_zone" in value && value.time_zone !== void 0) {
|
|
6763
|
+
validateTimeZone(value.time_zone);
|
|
6764
|
+
}
|
|
6765
|
+
switch (value.type) {
|
|
6766
|
+
case "date":
|
|
6767
|
+
return {
|
|
6768
|
+
start: normalizeDateBoundary({ value: value.start_date }),
|
|
6769
|
+
reminder: value.reminder
|
|
6770
|
+
};
|
|
6771
|
+
case "daterange":
|
|
6772
|
+
return {
|
|
6773
|
+
start: normalizeDateBoundary({ value: value.start_date }),
|
|
6774
|
+
end: normalizeDateBoundary({ value: value.end_date }),
|
|
6775
|
+
reminder: value.reminder
|
|
6776
|
+
};
|
|
6777
|
+
case "datetime":
|
|
6778
|
+
return {
|
|
6779
|
+
start: normalizeDateBoundary({
|
|
6780
|
+
value: `${value.start_date}T${value.start_time}`,
|
|
6781
|
+
timeZone: value.time_zone
|
|
6782
|
+
}),
|
|
6783
|
+
reminder: value.reminder
|
|
6784
|
+
};
|
|
6785
|
+
case "datetimerange":
|
|
6786
|
+
return {
|
|
6787
|
+
start: normalizeDateBoundary({
|
|
6788
|
+
value: `${value.start_date}T${value.start_time}`,
|
|
6789
|
+
timeZone: value.time_zone
|
|
6790
|
+
}),
|
|
6791
|
+
end: normalizeDateBoundary({
|
|
6792
|
+
value: `${value.end_date}T${value.end_time}`,
|
|
6793
|
+
timeZone: value.time_zone
|
|
6794
|
+
}),
|
|
6795
|
+
reminder: value.reminder
|
|
6796
|
+
};
|
|
6797
|
+
default:
|
|
6798
|
+
return unreachable(value);
|
|
6799
|
+
}
|
|
6800
|
+
}
|
|
6801
|
+
function normalizeDateBoundary({
|
|
6802
|
+
value,
|
|
6803
|
+
timeZone
|
|
6394
6804
|
}) {
|
|
6395
|
-
if (
|
|
6396
|
-
return
|
|
6397
|
-
|
|
6398
|
-
|
|
6805
|
+
if (!value.includes("T")) {
|
|
6806
|
+
return Temporal2.PlainDate.from(value).toString();
|
|
6807
|
+
}
|
|
6808
|
+
if (/(?:Z|[+-]\d{2}:?\d{2})$/i.test(value)) {
|
|
6809
|
+
return Temporal2.Instant.from(value).toString();
|
|
6810
|
+
}
|
|
6811
|
+
return Temporal2.PlainDateTime.from(value).toZonedDateTime(timeZone ?? "UTC").toInstant().toString();
|
|
6812
|
+
}
|
|
6813
|
+
function validateTimeZone(timeZone) {
|
|
6814
|
+
try {
|
|
6815
|
+
Temporal2.Instant.fromEpochMilliseconds(0).toZonedDateTimeISO(timeZone);
|
|
6816
|
+
} catch (cause) {
|
|
6817
|
+
if (!(cause instanceof RangeError)) {
|
|
6818
|
+
throw cause;
|
|
6819
|
+
}
|
|
6820
|
+
throw new RangeError(`invalid time zone "${timeZone}"`, { cause });
|
|
6821
|
+
}
|
|
6822
|
+
}
|
|
6823
|
+
|
|
6824
|
+
// shared/dataSources/toDataSourceDateValue.ts
|
|
6825
|
+
function toDataSourceDateValue(value) {
|
|
6826
|
+
if (is(notionDateValueSchema, value)) {
|
|
6827
|
+
return value;
|
|
6828
|
+
}
|
|
6829
|
+
if (typeof value !== "string") {
|
|
6830
|
+
return void 0;
|
|
6831
|
+
}
|
|
6832
|
+
try {
|
|
6833
|
+
const [date, time] = value.split("T");
|
|
6834
|
+
const { start } = toNotionDateInput({
|
|
6835
|
+
type: "datetime",
|
|
6836
|
+
start_date: date,
|
|
6837
|
+
start_time: time ?? "00:00:00Z"
|
|
6838
|
+
});
|
|
6839
|
+
return {
|
|
6840
|
+
type: "datetime",
|
|
6841
|
+
start_date: start.slice(0, 10),
|
|
6842
|
+
start_time: start.slice(11),
|
|
6843
|
+
time_zone: "UTC"
|
|
6844
|
+
};
|
|
6845
|
+
} catch (error) {
|
|
6846
|
+
if (error instanceof RangeError) {
|
|
6847
|
+
return void 0;
|
|
6848
|
+
}
|
|
6849
|
+
throw error;
|
|
6399
6850
|
}
|
|
6400
|
-
return sources.find((source) => source.filename === `worker_${slotKey}`) ?? sources.find((source) => source.filename === slotKey);
|
|
6401
6851
|
}
|
|
6402
6852
|
|
|
6403
6853
|
// cli/dataSources/listDataSourceFiles.ts
|
|
@@ -6415,7 +6865,14 @@ var DEV_SHELL_STATUS_GROUP_NAMES = [
|
|
|
6415
6865
|
"Future"
|
|
6416
6866
|
];
|
|
6417
6867
|
function readDataSources(dataDir) {
|
|
6418
|
-
return
|
|
6868
|
+
return readSampleDataSourcesSnapshot(dataDir).dataSources.map((source) => {
|
|
6869
|
+
if (source.status === "failed") {
|
|
6870
|
+
throw new Error(
|
|
6871
|
+
`${resolve(dataDir, `${source.filename}.json`)}: ${source.message}`
|
|
6872
|
+
);
|
|
6873
|
+
}
|
|
6874
|
+
return source;
|
|
6875
|
+
}).sort((left, right) => left.name.localeCompare(right.name));
|
|
6419
6876
|
}
|
|
6420
6877
|
function readSampleDataSourcesSnapshot(dataDir) {
|
|
6421
6878
|
const dataSources = [];
|
|
@@ -6434,13 +6891,44 @@ function readSampleDataSourcesSnapshot(dataDir) {
|
|
|
6434
6891
|
});
|
|
6435
6892
|
}
|
|
6436
6893
|
}
|
|
6437
|
-
return { dataSources };
|
|
6894
|
+
return { dataSources: rejectDuplicatePageIds(dataSources) };
|
|
6895
|
+
}
|
|
6896
|
+
function rejectDuplicatePageIds(sources) {
|
|
6897
|
+
const filenamesByPageId = /* @__PURE__ */ new Map();
|
|
6898
|
+
for (const source of sources) {
|
|
6899
|
+
if (source.status === "failed") {
|
|
6900
|
+
continue;
|
|
6901
|
+
}
|
|
6902
|
+
for (const row of source.rows) {
|
|
6903
|
+
const filenames = filenamesByPageId.get(row.id) ?? [];
|
|
6904
|
+
filenames.push(source.filename);
|
|
6905
|
+
filenamesByPageId.set(row.id, filenames);
|
|
6906
|
+
}
|
|
6907
|
+
}
|
|
6908
|
+
const errorsByFilename = /* @__PURE__ */ new Map();
|
|
6909
|
+
for (const [pageId, filenames] of filenamesByPageId) {
|
|
6910
|
+
if (filenames.length < 2) {
|
|
6911
|
+
continue;
|
|
6912
|
+
}
|
|
6913
|
+
const files = [...new Set(filenames)].map((filename) => `${filename}.json`).join(", ");
|
|
6914
|
+
const message = `Duplicate page ID "${pageId}" in ${files}. Give each row a unique ID across all sample data files.`;
|
|
6915
|
+
for (const filename of filenames) {
|
|
6916
|
+
if (!errorsByFilename.has(filename)) {
|
|
6917
|
+
errorsByFilename.set(filename, message);
|
|
6918
|
+
}
|
|
6919
|
+
}
|
|
6920
|
+
}
|
|
6921
|
+
return sources.map((source) => {
|
|
6922
|
+
const message = errorsByFilename.get(source.filename);
|
|
6923
|
+
return message === void 0 ? source : { status: "failed", filename: source.filename, message };
|
|
6924
|
+
});
|
|
6438
6925
|
}
|
|
6439
6926
|
var nonEmptyString = pipe(string(), nonEmpty());
|
|
6440
6927
|
var statusOptionsSchema = array(
|
|
6441
6928
|
object({
|
|
6442
6929
|
id: nonEmptyString,
|
|
6443
|
-
name: nonEmptyString
|
|
6930
|
+
name: nonEmptyString,
|
|
6931
|
+
color: optional(notionPropertyColorSchema)
|
|
6444
6932
|
})
|
|
6445
6933
|
);
|
|
6446
6934
|
var statusGroupsSchema = array(
|
|
@@ -6515,26 +7003,28 @@ function readDataSource(file) {
|
|
|
6515
7003
|
),
|
|
6516
7004
|
rows
|
|
6517
7005
|
};
|
|
6518
|
-
|
|
7006
|
+
validateDateValues(file, source);
|
|
6519
7007
|
return source;
|
|
6520
7008
|
}
|
|
6521
|
-
function
|
|
7009
|
+
function validateDateValues(file, source) {
|
|
6522
7010
|
const dateProperties = Object.entries(source.schema).filter(
|
|
6523
|
-
([, property]) => property.type === "date"
|
|
7011
|
+
([, property]) => property.type === "date" || property.type === "created_time" || property.type === "last_edited_time"
|
|
6524
7012
|
);
|
|
6525
7013
|
for (const row of source.rows) {
|
|
6526
7014
|
for (const [propertyId] of dateProperties) {
|
|
6527
7015
|
const value = row[propertyId];
|
|
6528
|
-
if (
|
|
7016
|
+
if (value === void 0 || value === null) {
|
|
6529
7017
|
continue;
|
|
6530
7018
|
}
|
|
6531
7019
|
try {
|
|
6532
|
-
|
|
6533
|
-
|
|
6534
|
-
|
|
7020
|
+
const date = toDataSourceDateValue(value);
|
|
7021
|
+
if (date === void 0) {
|
|
7022
|
+
throw new Error("Expected a date value or ISO timestamp.");
|
|
7023
|
+
}
|
|
7024
|
+
toNotionDateInput(date);
|
|
6535
7025
|
} catch (cause) {
|
|
6536
7026
|
throw new Error(
|
|
6537
|
-
`${file}: row "${row.id}", property "${propertyId}":
|
|
7027
|
+
`${file}: row "${row.id}", property "${propertyId}": ${formatUnknownError(cause)}`,
|
|
6538
7028
|
{ cause }
|
|
6539
7029
|
);
|
|
6540
7030
|
}
|
|
@@ -6550,13 +7040,6 @@ function toNotionPropertySchema(propertyKey, property) {
|
|
|
6550
7040
|
});
|
|
6551
7041
|
}
|
|
6552
7042
|
|
|
6553
|
-
// cli/utils/unreachable.ts
|
|
6554
|
-
function unreachable(value) {
|
|
6555
|
-
throw new Error(
|
|
6556
|
-
`[custom-blocks-dev-shell] Unexpected value encountered: ${JSON.stringify(value)}`
|
|
6557
|
-
);
|
|
6558
|
-
}
|
|
6559
|
-
|
|
6560
7043
|
// cli/dataSources/conversion/convertPublicApiPropertyValue.ts
|
|
6561
7044
|
function convertPublicApiPropertyValue(publicType, value) {
|
|
6562
7045
|
if (typeof value !== "object" || value === null) {
|
|
@@ -7309,10 +7792,13 @@ import { basename as basename2, dirname } from "node:path";
|
|
|
7309
7792
|
// cli/dataSources/copyPrebuiltDataSources.ts
|
|
7310
7793
|
import { copyFileSync, existsSync as existsSync2, mkdirSync } from "node:fs";
|
|
7311
7794
|
import { resolve as resolve2 } from "node:path";
|
|
7312
|
-
function copyPrebuiltDataSources(prebuiltDir, dataDir) {
|
|
7795
|
+
function copyPrebuiltDataSources(prebuiltDir, dataDir, selectedFilename) {
|
|
7313
7796
|
mkdirSync(dataDir, { recursive: true });
|
|
7314
7797
|
const written = [];
|
|
7315
7798
|
for (const source of readDataSources(prebuiltDir)) {
|
|
7799
|
+
if (selectedFilename !== void 0 && source.filename !== selectedFilename) {
|
|
7800
|
+
continue;
|
|
7801
|
+
}
|
|
7316
7802
|
const filename = `${source.filename}.json`;
|
|
7317
7803
|
const target = resolve2(dataDir, filename);
|
|
7318
7804
|
if (existsSync2(target)) {
|
|
@@ -7331,9 +7817,15 @@ function createDevShellDataService(options) {
|
|
|
7331
7817
|
const clients = /* @__PURE__ */ new Set();
|
|
7332
7818
|
let snapshot = {
|
|
7333
7819
|
blocks,
|
|
7334
|
-
|
|
7335
|
-
|
|
7336
|
-
|
|
7820
|
+
prebuiltSources: readDataSources(prebuiltDir).map((source) => ({
|
|
7821
|
+
filename: source.filename,
|
|
7822
|
+
name: source.name,
|
|
7823
|
+
icon: source.icon,
|
|
7824
|
+
rowCount: source.rows.length,
|
|
7825
|
+
propertyNames: Object.values(source.schema).map(
|
|
7826
|
+
(property) => property.name
|
|
7827
|
+
)
|
|
7828
|
+
})),
|
|
7337
7829
|
...readSampleDataSourcesSnapshot(dataDir)
|
|
7338
7830
|
};
|
|
7339
7831
|
let serialized = JSON.stringify(snapshot);
|
|
@@ -7440,8 +7932,22 @@ function createDevShellDataService(options) {
|
|
|
7440
7932
|
);
|
|
7441
7933
|
return;
|
|
7442
7934
|
}
|
|
7935
|
+
const filename = new URL(
|
|
7936
|
+
req.url ?? "/",
|
|
7937
|
+
"http://localhost"
|
|
7938
|
+
).searchParams.get("filename");
|
|
7939
|
+
if (filename !== null && !snapshot.prebuiltSources.some((source) => source.filename === filename)) {
|
|
7940
|
+
res.writeHead(400, { "Content-Type": "application/json" }).end(
|
|
7941
|
+
JSON.stringify({ error: "Choose an available example data source." })
|
|
7942
|
+
);
|
|
7943
|
+
return;
|
|
7944
|
+
}
|
|
7443
7945
|
try {
|
|
7444
|
-
const written = copyPrebuiltDataSources(
|
|
7946
|
+
const written = copyPrebuiltDataSources(
|
|
7947
|
+
prebuiltDir,
|
|
7948
|
+
dataDir,
|
|
7949
|
+
filename ?? void 0
|
|
7950
|
+
);
|
|
7445
7951
|
if (written.length > 0) {
|
|
7446
7952
|
log(`Added example data sources: ${written.join(", ")}`);
|
|
7447
7953
|
}
|