@notionhq/custom-blocks-dev-shell 0.3.1 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -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-CohEBjwO.css +2 -0
- package/dist/assets/index-G-f2Po2-.js +12 -0
- package/dist/index.html +3 -3
- package/dist-cli/cli/published-cli.js +1276 -722
- package/docs/bindings.md +17 -22
- package/docs/bridge/changelog.md +66 -19
- package/docs/bridge/protocol.md +172 -83
- package/docs/bridge/versioning.md +16 -4
- package/docs/data-sources.md +44 -31
- package/docs/host/README.md +35 -40
- package/docs/host/docs/compatibility.md +71 -31
- package/docs/host/docs/handlers.md +31 -15
- package/docs/host/docs/host-contract.md +83 -76
- package/docs/host/docs/lifecycle.md +76 -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,205 @@ function safeParse(schema, input, config$1) {
|
|
|
907
967
|
};
|
|
908
968
|
}
|
|
909
969
|
|
|
970
|
+
// ../protocol/src/dataSources/properties/propertySchema.ts
|
|
971
|
+
var knownNotionPropertyColorSchema = 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 notionPropertyColorSchema = union([knownNotionPropertyColorSchema, string()]);
|
|
994
|
+
var notionPropertyOptionSchema = object({
|
|
995
|
+
id: string(),
|
|
996
|
+
name: string(),
|
|
997
|
+
color: optional(notionPropertyColorSchema),
|
|
998
|
+
description: optional(string())
|
|
999
|
+
});
|
|
1000
|
+
var notionStatusGroupSchema = object({
|
|
1001
|
+
id: string(),
|
|
1002
|
+
name: string(),
|
|
1003
|
+
color: optional(notionPropertyColorSchema),
|
|
1004
|
+
option_ids: array(string())
|
|
1005
|
+
});
|
|
1006
|
+
var notionDualPropertySchema = object({
|
|
1007
|
+
synced_property_id: string(),
|
|
1008
|
+
synced_property_name: string()
|
|
1009
|
+
});
|
|
1010
|
+
var baseProp = object({
|
|
1011
|
+
name: string(),
|
|
1012
|
+
description: optional(string())
|
|
1013
|
+
});
|
|
1014
|
+
var NOTION_PROPERTY_TYPES = [
|
|
1015
|
+
"title",
|
|
1016
|
+
"rich_text",
|
|
1017
|
+
"number",
|
|
1018
|
+
"checkbox",
|
|
1019
|
+
"url",
|
|
1020
|
+
"email",
|
|
1021
|
+
"phone_number",
|
|
1022
|
+
"select",
|
|
1023
|
+
"multi_select",
|
|
1024
|
+
"status",
|
|
1025
|
+
"date",
|
|
1026
|
+
"people",
|
|
1027
|
+
"files",
|
|
1028
|
+
"unique_id",
|
|
1029
|
+
"relation",
|
|
1030
|
+
"place",
|
|
1031
|
+
"formula",
|
|
1032
|
+
"rollup",
|
|
1033
|
+
"button",
|
|
1034
|
+
"verification",
|
|
1035
|
+
"created_time",
|
|
1036
|
+
"last_edited_time",
|
|
1037
|
+
"created_by",
|
|
1038
|
+
"last_edited_by"
|
|
1039
|
+
];
|
|
1040
|
+
var notionPropertyTypeSchema = picklist(NOTION_PROPERTY_TYPES);
|
|
1041
|
+
var notionPropertySchemaSchema = variant("type", [
|
|
1042
|
+
object({ ...baseProp.entries, type: literal("title") }),
|
|
1043
|
+
object({ ...baseProp.entries, type: literal("rich_text") }),
|
|
1044
|
+
object({ ...baseProp.entries, type: literal("number") }),
|
|
1045
|
+
object({ ...baseProp.entries, type: literal("checkbox") }),
|
|
1046
|
+
object({ ...baseProp.entries, type: literal("url") }),
|
|
1047
|
+
object({ ...baseProp.entries, type: literal("email") }),
|
|
1048
|
+
object({ ...baseProp.entries, type: literal("phone_number") }),
|
|
1049
|
+
object({
|
|
1050
|
+
...baseProp.entries,
|
|
1051
|
+
type: literal("select"),
|
|
1052
|
+
options: array(notionPropertyOptionSchema)
|
|
1053
|
+
}),
|
|
1054
|
+
object({
|
|
1055
|
+
...baseProp.entries,
|
|
1056
|
+
type: literal("multi_select"),
|
|
1057
|
+
options: array(notionPropertyOptionSchema)
|
|
1058
|
+
}),
|
|
1059
|
+
object({
|
|
1060
|
+
...baseProp.entries,
|
|
1061
|
+
type: literal("status"),
|
|
1062
|
+
options: array(notionPropertyOptionSchema),
|
|
1063
|
+
groups: array(notionStatusGroupSchema)
|
|
1064
|
+
}),
|
|
1065
|
+
object({ ...baseProp.entries, type: literal("date") }),
|
|
1066
|
+
object({ ...baseProp.entries, type: literal("people") }),
|
|
1067
|
+
object({ ...baseProp.entries, type: literal("files") }),
|
|
1068
|
+
object({ ...baseProp.entries, type: literal("unique_id") }),
|
|
1069
|
+
object({
|
|
1070
|
+
...baseProp.entries,
|
|
1071
|
+
type: literal("relation"),
|
|
1072
|
+
data_source_id: optional(string()),
|
|
1073
|
+
dual_property: optional(notionDualPropertySchema)
|
|
1074
|
+
}),
|
|
1075
|
+
object({ ...baseProp.entries, type: literal("place") }),
|
|
1076
|
+
object({ ...baseProp.entries, type: literal("formula") }),
|
|
1077
|
+
object({ ...baseProp.entries, type: literal("rollup") }),
|
|
1078
|
+
// Internal-only types passed through under their bridge-native names.
|
|
1079
|
+
object({ ...baseProp.entries, type: literal("button") }),
|
|
1080
|
+
object({ ...baseProp.entries, type: literal("verification") }),
|
|
1081
|
+
// Page creation and edit metadata property types.
|
|
1082
|
+
object({ ...baseProp.entries, type: literal("created_time") }),
|
|
1083
|
+
object({ ...baseProp.entries, type: literal("last_edited_time") }),
|
|
1084
|
+
object({ ...baseProp.entries, type: literal("created_by") }),
|
|
1085
|
+
object({ ...baseProp.entries, type: literal("last_edited_by") })
|
|
1086
|
+
]);
|
|
1087
|
+
|
|
1088
|
+
// ../protocol/src/manifest/grants.ts
|
|
1089
|
+
var customBlockGrantSchema = object({
|
|
1090
|
+
action: string(),
|
|
1091
|
+
resource: union([string(), pipe(array(string()), minLength(1))])
|
|
1092
|
+
});
|
|
1093
|
+
|
|
1094
|
+
// ../protocol/src/manifest/manifest.ts
|
|
1095
|
+
var bridgeManifestIconSchema = variant("type", [
|
|
1096
|
+
object({
|
|
1097
|
+
type: literal("emoji"),
|
|
1098
|
+
emoji: string()
|
|
1099
|
+
}),
|
|
1100
|
+
object({
|
|
1101
|
+
type: literal("external"),
|
|
1102
|
+
url: string()
|
|
1103
|
+
})
|
|
1104
|
+
]);
|
|
1105
|
+
var bridgeManifestPropertySchema = object({
|
|
1106
|
+
name: string(),
|
|
1107
|
+
description: optional(string()),
|
|
1108
|
+
type: notionPropertyTypeSchema
|
|
1109
|
+
});
|
|
1110
|
+
var manifestPageSchema = object({
|
|
1111
|
+
name: string(),
|
|
1112
|
+
description: optional(string()),
|
|
1113
|
+
icon: optional(bridgeManifestIconSchema)
|
|
1114
|
+
});
|
|
1115
|
+
var bridgeManifestDataSourceSchema = object({
|
|
1116
|
+
name: string(),
|
|
1117
|
+
description: optional(string()),
|
|
1118
|
+
icon: optional(bridgeManifestIconSchema),
|
|
1119
|
+
properties: optional(
|
|
1120
|
+
record(string(), bridgeManifestPropertySchema),
|
|
1121
|
+
{}
|
|
1122
|
+
)
|
|
1123
|
+
});
|
|
1124
|
+
var manifestSchema = object({
|
|
1125
|
+
version: literal(1),
|
|
1126
|
+
name: optional(string()),
|
|
1127
|
+
description: optional(string()),
|
|
1128
|
+
slashCommand: optional(string()),
|
|
1129
|
+
icon: optional(object({ type: literal("emoji"), emoji: string() })),
|
|
1130
|
+
dataSources: optional(
|
|
1131
|
+
record(string(), bridgeManifestDataSourceSchema),
|
|
1132
|
+
{}
|
|
1133
|
+
),
|
|
1134
|
+
pages: optional(record(string(), manifestPageSchema)),
|
|
1135
|
+
/**
|
|
1136
|
+
* Grants the block needs. Omitted means the block predates viewer
|
|
1137
|
+
* approval, so hosts do not ask the viewer. An empty array declares
|
|
1138
|
+
* nothing.
|
|
1139
|
+
*/
|
|
1140
|
+
grants: optional(array(customBlockGrantSchema))
|
|
1141
|
+
});
|
|
1142
|
+
|
|
1143
|
+
// ../protocol/src/handshake/connect.ts
|
|
1144
|
+
var connectRequestMessageSchema = object({
|
|
1145
|
+
type: literal("connect"),
|
|
1146
|
+
/** Identifies this request. The host echoes it in `connectResult`. */
|
|
1147
|
+
requestId: string(),
|
|
1148
|
+
/** Every protocol contract the SDK implements, from which the host selects one. */
|
|
1149
|
+
supportedProtocolVersions: pipe(
|
|
1150
|
+
array(pipe(number(), integer(), minValue(1))),
|
|
1151
|
+
minLength(1),
|
|
1152
|
+
check((versions) => new Set(versions).size === versions.length)
|
|
1153
|
+
),
|
|
1154
|
+
/** SDK package version for diagnostics. Does not select the wire protocol. */
|
|
1155
|
+
sdkVersion: string(),
|
|
1156
|
+
/**
|
|
1157
|
+
* Manifest injected by local dev tooling. The SDK omits it on non-loopback origins.
|
|
1158
|
+
* The host selects it only when `manifestSource` is `"sandbox"`.
|
|
1159
|
+
*/
|
|
1160
|
+
manifest: optional(manifestSchema)
|
|
1161
|
+
});
|
|
1162
|
+
|
|
1163
|
+
// ../protocol/src/context/contrast.ts
|
|
1164
|
+
var notionContrastModeSchema = picklist(["standard", "high"]);
|
|
1165
|
+
|
|
910
1166
|
// ../protocol/src/utils/ids.ts
|
|
911
1167
|
var notionBlockIdSchema = pipe(string(), brand("NotionBlockId"));
|
|
1168
|
+
var notionViewIdSchema = pipe(string(), brand("NotionViewId"));
|
|
912
1169
|
var notionDataSourceIdSchema = pipe(
|
|
913
1170
|
string(),
|
|
914
1171
|
brand("NotionDataSourceId")
|
|
@@ -921,22 +1178,104 @@ var notionAppInstallationIdSchema = pipe(
|
|
|
921
1178
|
brand("NotionAppInstallationId")
|
|
922
1179
|
);
|
|
923
1180
|
|
|
924
|
-
// ../protocol/src/context/
|
|
925
|
-
var
|
|
926
|
-
type: literal("
|
|
927
|
-
|
|
928
|
-
})
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
1181
|
+
// ../protocol/src/context/instance.ts
|
|
1182
|
+
var customBlockInstanceSchema = variant("type", [
|
|
1183
|
+
strictObject({ type: literal("block"), blockId: notionBlockIdSchema }),
|
|
1184
|
+
strictObject({ type: literal("page"), blockId: notionBlockIdSchema }),
|
|
1185
|
+
strictObject({ type: literal("view"), viewId: notionViewIdSchema })
|
|
1186
|
+
]);
|
|
1187
|
+
|
|
1188
|
+
// ../protocol/src/context/theme.ts
|
|
1189
|
+
var notionThemeSchema = picklist(["light", "dark"]);
|
|
1190
|
+
|
|
1191
|
+
// ../protocol/src/handshake/init.ts
|
|
1192
|
+
var customBlockInitErrorCodeSchema = string();
|
|
1193
|
+
var customBlockInitErrorInfoSchema = object({
|
|
1194
|
+
code: customBlockInitErrorCodeSchema,
|
|
1195
|
+
message: string(),
|
|
1196
|
+
isRetryable: boolean()
|
|
932
1197
|
});
|
|
933
|
-
var
|
|
934
|
-
type: literal("
|
|
935
|
-
|
|
1198
|
+
var setupInitMessageSchema = object({
|
|
1199
|
+
type: literal("init"),
|
|
1200
|
+
requestId: string(),
|
|
1201
|
+
instance: customBlockInstanceSchema,
|
|
1202
|
+
manifest: manifestSchema,
|
|
1203
|
+
preferences: object({
|
|
1204
|
+
theme: notionThemeSchema,
|
|
1205
|
+
contrastMode: notionContrastModeSchema
|
|
1206
|
+
})
|
|
936
1207
|
});
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
1208
|
+
|
|
1209
|
+
// ../protocol/src/handshake/initResult.ts
|
|
1210
|
+
var customBlockInitResultErrorCodeSchema = string();
|
|
1211
|
+
var customBlockInitResultErrorInfoSchema = object({
|
|
1212
|
+
code: customBlockInitResultErrorCodeSchema,
|
|
1213
|
+
message: string(),
|
|
1214
|
+
isRetryable: boolean()
|
|
1215
|
+
});
|
|
1216
|
+
var initResultRequestMessageSchema = variant("status", [
|
|
1217
|
+
object({
|
|
1218
|
+
type: literal("initResult"),
|
|
1219
|
+
requestId: string(),
|
|
1220
|
+
status: literal("success")
|
|
1221
|
+
}),
|
|
1222
|
+
object({
|
|
1223
|
+
type: literal("initResult"),
|
|
1224
|
+
requestId: string(),
|
|
1225
|
+
status: literal("error"),
|
|
1226
|
+
error: customBlockInitResultErrorInfoSchema
|
|
1227
|
+
})
|
|
1228
|
+
]);
|
|
1229
|
+
|
|
1230
|
+
// ../protocol/src/utils/errors.ts
|
|
1231
|
+
var customBlockErrorInfoSchema = object({
|
|
1232
|
+
code: string(),
|
|
1233
|
+
message: string(),
|
|
1234
|
+
isRetryable: boolean()
|
|
1235
|
+
});
|
|
1236
|
+
|
|
1237
|
+
// ../protocol/src/compatibility/protocol3To11/connect.ts
|
|
1238
|
+
var connectMessageCommonEntries = {
|
|
1239
|
+
type: literal("connect"),
|
|
1240
|
+
/** Identifies this startup attempt and is echoed in `init` and `initResult`. */
|
|
1241
|
+
initializationId: string(),
|
|
1242
|
+
/** The protocol version declared by the SDK. The host accepts or rejects this version without negotiation. */
|
|
1243
|
+
bridgeProtocolVersion: number(),
|
|
1244
|
+
/** SDK package version for diagnostics. Does not select the wire protocol. */
|
|
1245
|
+
sdkVersion: string()
|
|
1246
|
+
};
|
|
1247
|
+
var protocol3To11ConnectSuccessMessageSchema = object({
|
|
1248
|
+
status: literal("success"),
|
|
1249
|
+
/** Local dev manifest, selected only when `manifestSource` is `"sandbox"`. */
|
|
1250
|
+
manifest: optional(manifestSchema),
|
|
1251
|
+
...connectMessageCommonEntries
|
|
1252
|
+
});
|
|
1253
|
+
var protocol3To11ConnectErrorMessageSchema = object({
|
|
1254
|
+
status: literal("error"),
|
|
1255
|
+
error: customBlockErrorInfoSchema,
|
|
1256
|
+
...connectMessageCommonEntries
|
|
1257
|
+
});
|
|
1258
|
+
var protocol3To11ConnectMessageSchema = variant("status", [
|
|
1259
|
+
protocol3To11ConnectSuccessMessageSchema,
|
|
1260
|
+
protocol3To11ConnectErrorMessageSchema
|
|
1261
|
+
]);
|
|
1262
|
+
|
|
1263
|
+
// ../protocol/src/context/parent.ts
|
|
1264
|
+
var pageParentSchema = object({
|
|
1265
|
+
type: literal("page_id"),
|
|
1266
|
+
page_id: notionPageIdSchema
|
|
1267
|
+
});
|
|
1268
|
+
var dataSourceParentSchema = object({
|
|
1269
|
+
type: literal("data_source_id"),
|
|
1270
|
+
data_source_id: notionDataSourceIdSchema
|
|
1271
|
+
});
|
|
1272
|
+
var workspaceParentSchema = object({
|
|
1273
|
+
type: literal("workspace"),
|
|
1274
|
+
workspace: literal(true)
|
|
1275
|
+
});
|
|
1276
|
+
var blockParentSchema = object({
|
|
1277
|
+
type: literal("block_id"),
|
|
1278
|
+
block_id: notionBlockIdSchema
|
|
940
1279
|
});
|
|
941
1280
|
var agentParentSchema = object({
|
|
942
1281
|
type: literal("agent_id"),
|
|
@@ -957,6 +1296,265 @@ var notionParentSchema = variant("type", [
|
|
|
957
1296
|
unavailableParentSchema
|
|
958
1297
|
]);
|
|
959
1298
|
|
|
1299
|
+
// ../protocol/src/dataSources/dataSourcePointer.ts
|
|
1300
|
+
var dataSourcePointerValidator = object({
|
|
1301
|
+
id: notionDataSourceIdSchema,
|
|
1302
|
+
table: string(),
|
|
1303
|
+
spaceId: optional(notionSpaceIdSchema)
|
|
1304
|
+
});
|
|
1305
|
+
|
|
1306
|
+
// ../protocol/src/dataSources/dataSourceSchema.ts
|
|
1307
|
+
var notionDataSourceSchemaValidator = object({
|
|
1308
|
+
id: optional(notionDataSourceIdSchema),
|
|
1309
|
+
/**
|
|
1310
|
+
* Describes actual database properties in protocol 5. Protocol 3/4 payloads can also include
|
|
1311
|
+
* synthetic metadata for compatibility. Use this map to resolve property bindings. Use this map
|
|
1312
|
+
* to validate filter and sort references.
|
|
1313
|
+
*/
|
|
1314
|
+
propertiesById: record(string(), notionPropertySchemaSchema)
|
|
1315
|
+
});
|
|
1316
|
+
|
|
1317
|
+
// ../protocol/src/dataSources/bridgeDataSourceBinding.ts
|
|
1318
|
+
var bridgeDataSourceBindingSchema = object({
|
|
1319
|
+
dataSourcePointer: optional(dataSourcePointerValidator),
|
|
1320
|
+
/**
|
|
1321
|
+
* Describes database properties. Use this schema to resolve property bindings. Use this
|
|
1322
|
+
* schema to validate filter and sort references. Undefined when the host does not provide a
|
|
1323
|
+
* database schema.
|
|
1324
|
+
*/
|
|
1325
|
+
dataSourceSchema: optional(notionDataSourceSchemaValidator),
|
|
1326
|
+
/**
|
|
1327
|
+
* Maps user-defined property keys to database property IDs. Use this map to resolve a key
|
|
1328
|
+
* such as `name` to its database property ID. A value of `undefined` marks a declared
|
|
1329
|
+
* property without a binding. Omitted when the host does not provide property mappings.
|
|
1330
|
+
* Synthetic metadata does not add entries to this map.
|
|
1331
|
+
*/
|
|
1332
|
+
propertyIdsByKey: optional(record(string(), optional(string()))),
|
|
1333
|
+
/**
|
|
1334
|
+
* `true` when the data source is bound but the viewer can't read it. The host omits
|
|
1335
|
+
* `dataSourcePointer`, `dataSourceSchema`, and `propertyIdsByKey`, so the binding reveals
|
|
1336
|
+
* nothing about the data source. The block still initializes.
|
|
1337
|
+
*/
|
|
1338
|
+
inaccessible: optional(literal(true))
|
|
1339
|
+
});
|
|
1340
|
+
|
|
1341
|
+
// ../protocol/src/dataSources/bridgeDataSourceBindings.ts
|
|
1342
|
+
var bridgeDataSourceBindingsSchema = record(
|
|
1343
|
+
string(),
|
|
1344
|
+
bridgeDataSourceBindingSchema
|
|
1345
|
+
);
|
|
1346
|
+
|
|
1347
|
+
// ../protocol/src/users/userId.ts
|
|
1348
|
+
var notionUserIdSchema = pipe(string(), brand("NotionUserId"));
|
|
1349
|
+
|
|
1350
|
+
// ../protocol/src/compatibility/protocol3To11/bridgeUser.ts
|
|
1351
|
+
var bridgeUserForProtocol3To11Schema = object({
|
|
1352
|
+
object: literal("user"),
|
|
1353
|
+
id: notionUserIdSchema,
|
|
1354
|
+
name: optional(string()),
|
|
1355
|
+
avatar_url: nullable(string()),
|
|
1356
|
+
type: literal("person"),
|
|
1357
|
+
person: object({ email: string() })
|
|
1358
|
+
});
|
|
1359
|
+
var currentUserChangedForProtocol3To11Schema = object({
|
|
1360
|
+
type: literal("currentUserChanged"),
|
|
1361
|
+
currentUser: bridgeUserForProtocol3To11Schema
|
|
1362
|
+
});
|
|
1363
|
+
var getUserResultForProtocol3To11Schema = variant("status", [
|
|
1364
|
+
object({
|
|
1365
|
+
type: literal("getUserResult"),
|
|
1366
|
+
requestId: string(),
|
|
1367
|
+
status: literal("success"),
|
|
1368
|
+
user: bridgeUserForProtocol3To11Schema
|
|
1369
|
+
}),
|
|
1370
|
+
object({
|
|
1371
|
+
type: literal("getUserResult"),
|
|
1372
|
+
requestId: string(),
|
|
1373
|
+
status: literal("error"),
|
|
1374
|
+
error: customBlockErrorInfoSchema
|
|
1375
|
+
})
|
|
1376
|
+
]);
|
|
1377
|
+
var listUsersResultForProtocol3To11Schema = variant("status", [
|
|
1378
|
+
object({
|
|
1379
|
+
type: literal("listUsersResult"),
|
|
1380
|
+
requestId: string(),
|
|
1381
|
+
status: literal("success"),
|
|
1382
|
+
list: object({
|
|
1383
|
+
object: literal("list"),
|
|
1384
|
+
results: array(bridgeUserForProtocol3To11Schema),
|
|
1385
|
+
next_cursor: nullable(string()),
|
|
1386
|
+
has_more: boolean(),
|
|
1387
|
+
type: literal("user"),
|
|
1388
|
+
user: record(string(), unknown())
|
|
1389
|
+
})
|
|
1390
|
+
}),
|
|
1391
|
+
object({
|
|
1392
|
+
type: literal("listUsersResult"),
|
|
1393
|
+
requestId: string(),
|
|
1394
|
+
status: literal("error"),
|
|
1395
|
+
error: customBlockErrorInfoSchema
|
|
1396
|
+
})
|
|
1397
|
+
]);
|
|
1398
|
+
|
|
1399
|
+
// ../protocol/src/compatibility/protocol3To11/containingPage.ts
|
|
1400
|
+
var protocol3To11ContainingPageSchema = variant("type", [
|
|
1401
|
+
object({ type: literal("unavailable") }),
|
|
1402
|
+
object({
|
|
1403
|
+
type: literal("page"),
|
|
1404
|
+
id: notionPageIdSchema,
|
|
1405
|
+
parent: notionParentSchema
|
|
1406
|
+
})
|
|
1407
|
+
]);
|
|
1408
|
+
var protocol3To11PageChangedMessageSchema = object({
|
|
1409
|
+
type: literal("pageChanged"),
|
|
1410
|
+
page: protocol3To11ContainingPageSchema
|
|
1411
|
+
});
|
|
1412
|
+
|
|
1413
|
+
// ../protocol/src/compatibility/protocol3To11/init.ts
|
|
1414
|
+
var protocol3To11InitSuccessMessageSchema = object({
|
|
1415
|
+
type: literal("init"),
|
|
1416
|
+
initializationId: string(),
|
|
1417
|
+
status: literal("success"),
|
|
1418
|
+
theme: notionThemeSchema,
|
|
1419
|
+
contrastMode: notionContrastModeSchema,
|
|
1420
|
+
blockId: notionBlockIdSchema,
|
|
1421
|
+
parent: notionParentSchema,
|
|
1422
|
+
page: protocol3To11ContainingPageSchema,
|
|
1423
|
+
manifest: manifestSchema,
|
|
1424
|
+
dataSources: object({
|
|
1425
|
+
bindings: bridgeDataSourceBindingsSchema
|
|
1426
|
+
}),
|
|
1427
|
+
currentUser: bridgeUserForProtocol3To11Schema
|
|
1428
|
+
});
|
|
1429
|
+
var protocol3To11InitMessageSchema = variant("status", [
|
|
1430
|
+
protocol3To11InitSuccessMessageSchema,
|
|
1431
|
+
object({
|
|
1432
|
+
type: literal("init"),
|
|
1433
|
+
initializationId: string(),
|
|
1434
|
+
status: literal("error"),
|
|
1435
|
+
error: customBlockErrorInfoSchema
|
|
1436
|
+
})
|
|
1437
|
+
]);
|
|
1438
|
+
|
|
1439
|
+
// ../protocol/src/compatibility/protocol3To11/initResult.ts
|
|
1440
|
+
var protocol3To11InitResultErrorCodeSchema = string();
|
|
1441
|
+
var protocol3To11InitResultMessageSchema = variant("status", [
|
|
1442
|
+
object({
|
|
1443
|
+
type: literal("initResult"),
|
|
1444
|
+
initializationId: string(),
|
|
1445
|
+
status: literal("success"),
|
|
1446
|
+
/** Initial rendered content height in CSS pixels. Omission is accepted for protocols that do not supply it. */
|
|
1447
|
+
initialHeight: optional(pipe(number(), finite(), minValue(0)))
|
|
1448
|
+
}),
|
|
1449
|
+
object({
|
|
1450
|
+
type: literal("initResult"),
|
|
1451
|
+
initializationId: string(),
|
|
1452
|
+
status: literal("error"),
|
|
1453
|
+
error: object({
|
|
1454
|
+
...customBlockErrorInfoSchema.entries,
|
|
1455
|
+
code: protocol3To11InitResultErrorCodeSchema
|
|
1456
|
+
})
|
|
1457
|
+
})
|
|
1458
|
+
]);
|
|
1459
|
+
|
|
1460
|
+
// ../protocol/src/compatibility/handshake.ts
|
|
1461
|
+
var sandboxConnectMessageSchema = union([
|
|
1462
|
+
connectRequestMessageSchema,
|
|
1463
|
+
protocol3To11ConnectMessageSchema
|
|
1464
|
+
]);
|
|
1465
|
+
var hostInitMessageSchema = union([
|
|
1466
|
+
setupInitMessageSchema,
|
|
1467
|
+
protocol3To11InitMessageSchema
|
|
1468
|
+
]);
|
|
1469
|
+
var initResultMessageWithCompatibilitySchema = union([
|
|
1470
|
+
initResultRequestMessageSchema,
|
|
1471
|
+
protocol3To11InitResultMessageSchema
|
|
1472
|
+
]);
|
|
1473
|
+
|
|
1474
|
+
// ../protocol/src/context/messages/contrastModeChanged.ts
|
|
1475
|
+
var contrastModeChangedMessageSchema = object({
|
|
1476
|
+
type: literal("contrastModeChanged"),
|
|
1477
|
+
contrastMode: notionContrastModeSchema
|
|
1478
|
+
});
|
|
1479
|
+
|
|
1480
|
+
// ../protocol/src/context/containingPage.ts
|
|
1481
|
+
var customBlockPageSchema = variant("type", [
|
|
1482
|
+
/** The viewer cannot access the containing page. Its ID and parent are not exposed. */
|
|
1483
|
+
object({ type: literal("unavailable") }),
|
|
1484
|
+
/** The accessible containing page, with its ID and parent location. */
|
|
1485
|
+
object({
|
|
1486
|
+
type: literal("page"),
|
|
1487
|
+
id: notionPageIdSchema,
|
|
1488
|
+
/**
|
|
1489
|
+
* The containing page's own parent. It lets a block distinguish a freestanding page from a
|
|
1490
|
+
* database row without a round trip. Not to be confused with the top-level `parent` runtime
|
|
1491
|
+
* value, which is the custom block's own parent.
|
|
1492
|
+
*/
|
|
1493
|
+
parent: notionParentSchema,
|
|
1494
|
+
/** How this block's containing page is displayed. Defaults to `full_page` for hosts without peek presentation. */
|
|
1495
|
+
displayMode: optional(
|
|
1496
|
+
picklist(["full_page", "side_peek", "center_peek"]),
|
|
1497
|
+
"full_page"
|
|
1498
|
+
)
|
|
1499
|
+
})
|
|
1500
|
+
]);
|
|
1501
|
+
|
|
1502
|
+
// ../protocol/src/context/messages/pageChanged.ts
|
|
1503
|
+
var pageChangedMessageSchema = object({
|
|
1504
|
+
type: literal("pageChanged"),
|
|
1505
|
+
page: customBlockPageSchema
|
|
1506
|
+
});
|
|
1507
|
+
|
|
1508
|
+
// ../protocol/src/context/messages/pageError.ts
|
|
1509
|
+
var pageErrorMessageSchema = object({
|
|
1510
|
+
type: literal("pageError"),
|
|
1511
|
+
error: customBlockErrorInfoSchema
|
|
1512
|
+
});
|
|
1513
|
+
|
|
1514
|
+
// ../protocol/src/context/messages/parentChanged.ts
|
|
1515
|
+
var parentChangedMessageSchema = object({
|
|
1516
|
+
type: literal("parentChanged"),
|
|
1517
|
+
parent: notionParentSchema
|
|
1518
|
+
});
|
|
1519
|
+
|
|
1520
|
+
// ../protocol/src/context/messages/parentError.ts
|
|
1521
|
+
var parentErrorMessageSchema = object({
|
|
1522
|
+
type: literal("parentError"),
|
|
1523
|
+
error: customBlockErrorInfoSchema
|
|
1524
|
+
});
|
|
1525
|
+
|
|
1526
|
+
// ../protocol/src/context/messages/themeChanged.ts
|
|
1527
|
+
var themeChangedMessageSchema = object({
|
|
1528
|
+
type: literal("themeChanged"),
|
|
1529
|
+
theme: notionThemeSchema
|
|
1530
|
+
});
|
|
1531
|
+
|
|
1532
|
+
// ../protocol/src/dataSources/messages/getDataSource.ts
|
|
1533
|
+
var getDataSourceMessageSchema = object({
|
|
1534
|
+
type: literal("getDataSource"),
|
|
1535
|
+
requestId: string(),
|
|
1536
|
+
key: string()
|
|
1537
|
+
});
|
|
1538
|
+
var getDataSourceResultMessageSchema = variant("status", [
|
|
1539
|
+
object({
|
|
1540
|
+
type: literal("getDataSourceResult"),
|
|
1541
|
+
requestId: string(),
|
|
1542
|
+
status: literal("success"),
|
|
1543
|
+
binding: required(
|
|
1544
|
+
omit(bridgeDataSourceBindingSchema, ["inaccessible"])
|
|
1545
|
+
)
|
|
1546
|
+
}),
|
|
1547
|
+
object({
|
|
1548
|
+
type: literal("getDataSourceResult"),
|
|
1549
|
+
requestId: string(),
|
|
1550
|
+
status: literal("error"),
|
|
1551
|
+
error: customBlockErrorInfoSchema
|
|
1552
|
+
})
|
|
1553
|
+
]);
|
|
1554
|
+
var dataSourcesInvalidatedMessageSchema = object({
|
|
1555
|
+
type: literal("dataSourcesInvalidated")
|
|
1556
|
+
});
|
|
1557
|
+
|
|
960
1558
|
// ../protocol/src/files.ts
|
|
961
1559
|
var bridgeExternalFileSchema = object({
|
|
962
1560
|
type: literal("external"),
|
|
@@ -1122,7 +1720,6 @@ var notionRecordPointerSchema = object({
|
|
|
1122
1720
|
var metadataActorSchema = nullable(
|
|
1123
1721
|
object({
|
|
1124
1722
|
...notionRecordPointerSchema.entries,
|
|
1125
|
-
table: picklist(["notion_user", "bot", "organization_bot"]),
|
|
1126
1723
|
spaceId: optional(string())
|
|
1127
1724
|
})
|
|
1128
1725
|
);
|
|
@@ -1308,391 +1905,38 @@ var bridgePagePropertyReadMapSchema = record(
|
|
|
1308
1905
|
nullable(bridgePagePropertyValueSchema)
|
|
1309
1906
|
);
|
|
1310
1907
|
|
|
1311
|
-
// ../protocol/src/
|
|
1312
|
-
var
|
|
1908
|
+
// ../protocol/src/pages/bridgePage.ts
|
|
1909
|
+
var pageIconReadSchema = union([
|
|
1910
|
+
bridgePageIconSchema,
|
|
1911
|
+
pipe(
|
|
1912
|
+
object({ type: string() }),
|
|
1913
|
+
check(
|
|
1914
|
+
(icon) => !bridgePageIconSchema.options.some(
|
|
1915
|
+
(option) => option.entries.type.literal === icon.type
|
|
1916
|
+
)
|
|
1917
|
+
),
|
|
1918
|
+
transform(() => null)
|
|
1919
|
+
)
|
|
1920
|
+
]);
|
|
1921
|
+
var bridgePageSchema = object({
|
|
1313
1922
|
object: literal("page"),
|
|
1314
1923
|
id: notionPageIdSchema,
|
|
1315
1924
|
parent: notionParentSchema,
|
|
1316
|
-
properties:
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1925
|
+
properties: bridgePagePropertyReadMapSchema,
|
|
1926
|
+
created_by: optional(metadataActorSchema, null),
|
|
1927
|
+
last_edited_by: optional(metadataActorSchema, null),
|
|
1928
|
+
created_time: optional(nullable(string()), null),
|
|
1929
|
+
last_edited_time: optional(nullable(string()), null),
|
|
1930
|
+
icon: optional(nullable(pageIconReadSchema), null),
|
|
1931
|
+
cover: optional(nullable(bridgePageCoverSchema), null),
|
|
1932
|
+
url: optional(nullable(string()), null),
|
|
1933
|
+
public_url: optional(nullable(string()), null),
|
|
1323
1934
|
/** Whether the page or an ancestor is archived. */
|
|
1324
1935
|
is_archived: boolean(),
|
|
1325
1936
|
/** Whether the page or an ancestor is in Trash. */
|
|
1326
1937
|
in_trash: boolean()
|
|
1327
1938
|
});
|
|
1328
1939
|
|
|
1329
|
-
// ../protocol/src/compatibility/protocol3To5/dataSourceValue.ts
|
|
1330
|
-
var notionDataSourceValueSchema = union([
|
|
1331
|
-
string(),
|
|
1332
|
-
number(),
|
|
1333
|
-
boolean(),
|
|
1334
|
-
notionDateValueSchema,
|
|
1335
|
-
array(string()),
|
|
1336
|
-
array(notionRecordPointerSchema)
|
|
1337
|
-
]);
|
|
1338
|
-
|
|
1339
|
-
// ../protocol/src/compatibility/protocol3To5/dataSourcePage.ts
|
|
1340
|
-
var notionDataSourcePageForProtocol3To5Schema = object({
|
|
1341
|
-
id: notionPageIdSchema,
|
|
1342
|
-
/** Whether the page or an ancestor is archived. */
|
|
1343
|
-
is_archived: boolean(),
|
|
1344
|
-
/** Whether the page or an ancestor is in Trash. */
|
|
1345
|
-
in_trash: boolean(),
|
|
1346
|
-
propertiesById: record(string(), optional(notionDataSourceValueSchema))
|
|
1347
|
-
});
|
|
1348
|
-
|
|
1349
|
-
// ../protocol/src/dataSources/dataSourcePointer.ts
|
|
1350
|
-
var dataSourcePointerValidator = object({
|
|
1351
|
-
id: notionDataSourceIdSchema,
|
|
1352
|
-
table: string(),
|
|
1353
|
-
spaceId: optional(notionSpaceIdSchema)
|
|
1354
|
-
});
|
|
1355
|
-
|
|
1356
|
-
// ../protocol/src/dataSources/properties/propertySchema.ts
|
|
1357
|
-
var notionPropertyColorSchema = picklist([
|
|
1358
|
-
"default",
|
|
1359
|
-
"gray",
|
|
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()
|
|
1394
|
-
});
|
|
1395
|
-
var baseProp = object({
|
|
1396
|
-
name: string(),
|
|
1397
|
-
description: optional(string())
|
|
1398
|
-
});
|
|
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
|
-
|
|
1473
|
-
// ../protocol/src/dataSources/dataSourceSchema.ts
|
|
1474
|
-
var notionDataSourceSchemaValidator = object({
|
|
1475
|
-
id: optional(notionDataSourceIdSchema),
|
|
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)
|
|
1482
|
-
});
|
|
1483
|
-
|
|
1484
|
-
// ../protocol/src/context/containingPage.ts
|
|
1485
|
-
var customBlockPageSchema = variant("type", [
|
|
1486
|
-
/** The viewer cannot access the containing page; its ID and parent are not exposed. */
|
|
1487
|
-
object({ type: literal("unavailable") }),
|
|
1488
|
-
/** The viewer can access the containing page; includes its ID and parent location. */
|
|
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
|
|
1498
|
-
})
|
|
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
|
-
});
|
|
1530
|
-
|
|
1531
|
-
// ../protocol/src/dataSources/bridgeDataSourceBindings.ts
|
|
1532
|
-
var bridgeDataSourceBindingsSchema = record(
|
|
1533
|
-
string(),
|
|
1534
|
-
bridgeDataSourceBindingSchema
|
|
1535
|
-
);
|
|
1536
|
-
|
|
1537
|
-
// ../protocol/src/manifest/grants.ts
|
|
1538
|
-
var customBlockGrantSchema = object({
|
|
1539
|
-
action: string(),
|
|
1540
|
-
resource: union([string(), pipe(array(string()), minLength(1))])
|
|
1541
|
-
});
|
|
1542
|
-
|
|
1543
|
-
// ../protocol/src/manifest/manifest.ts
|
|
1544
|
-
var bridgeManifestIconSchema = variant("type", [
|
|
1545
|
-
object({
|
|
1546
|
-
type: literal("emoji"),
|
|
1547
|
-
emoji: string()
|
|
1548
|
-
}),
|
|
1549
|
-
object({
|
|
1550
|
-
type: literal("external"),
|
|
1551
|
-
url: string()
|
|
1552
|
-
})
|
|
1553
|
-
]);
|
|
1554
|
-
var bridgeManifestPropertySchema = object({
|
|
1555
|
-
name: string(),
|
|
1556
|
-
description: optional(string()),
|
|
1557
|
-
type: notionPropertyTypeSchema
|
|
1558
|
-
});
|
|
1559
|
-
var manifestPageSchema = object({
|
|
1560
|
-
name: string(),
|
|
1561
|
-
description: optional(string()),
|
|
1562
|
-
icon: optional(bridgeManifestIconSchema)
|
|
1563
|
-
});
|
|
1564
|
-
var bridgeManifestDataSourceSchema = object({
|
|
1565
|
-
name: string(),
|
|
1566
|
-
description: optional(string()),
|
|
1567
|
-
icon: optional(bridgeManifestIconSchema),
|
|
1568
|
-
properties: optional(
|
|
1569
|
-
record(string(), bridgeManifestPropertySchema),
|
|
1570
|
-
{}
|
|
1571
|
-
)
|
|
1572
|
-
});
|
|
1573
|
-
var manifestSchema = object({
|
|
1574
|
-
version: literal(1),
|
|
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))
|
|
1590
|
-
});
|
|
1591
|
-
|
|
1592
|
-
// ../protocol/src/users/userId.ts
|
|
1593
|
-
var notionUserIdSchema = pipe(string(), brand("NotionUserId"));
|
|
1594
|
-
|
|
1595
|
-
// ../protocol/src/users/bridgeUser.ts
|
|
1596
|
-
var bridgeUserSchema = object({
|
|
1597
|
-
object: literal("user"),
|
|
1598
|
-
id: notionUserIdSchema,
|
|
1599
|
-
name: optional(string()),
|
|
1600
|
-
avatar_url: nullable(string()),
|
|
1601
|
-
type: literal("person"),
|
|
1602
|
-
person: object({
|
|
1603
|
-
email: string()
|
|
1604
|
-
})
|
|
1605
|
-
});
|
|
1606
|
-
|
|
1607
|
-
// ../protocol/src/handshake/init.ts
|
|
1608
|
-
var customBlockInitErrorCodeSchema = string();
|
|
1609
|
-
var customBlockInitErrorInfoSchema = object({
|
|
1610
|
-
code: customBlockInitErrorCodeSchema,
|
|
1611
|
-
message: string(),
|
|
1612
|
-
isRetryable: boolean()
|
|
1613
|
-
});
|
|
1614
|
-
var initMessageSchema = variant("status", [
|
|
1615
|
-
object({
|
|
1616
|
-
type: literal("init"),
|
|
1617
|
-
initializationId: string(),
|
|
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
|
|
1629
|
-
}),
|
|
1630
|
-
object({
|
|
1631
|
-
type: literal("init"),
|
|
1632
|
-
initializationId: string(),
|
|
1633
|
-
status: literal("error"),
|
|
1634
|
-
error: customBlockInitErrorInfoSchema
|
|
1635
|
-
})
|
|
1636
|
-
]);
|
|
1637
|
-
|
|
1638
|
-
// ../protocol/src/compatibility/protocol3To10/dataSourceBindings.ts
|
|
1639
|
-
var bridgeDataSourceBindingsForProtocol3To10Schema = record(
|
|
1640
|
-
string(),
|
|
1641
|
-
object({
|
|
1642
|
-
collectionPointer: optional(dataSourcePointerValidator),
|
|
1643
|
-
collectionSchema: optional(notionDataSourceSchemaValidator),
|
|
1644
|
-
propertyIdsByKey: optional(record(string(), optional(string()))),
|
|
1645
|
-
inaccessible: optional(literal(true))
|
|
1646
|
-
})
|
|
1647
|
-
);
|
|
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
|
-
|
|
1666
|
-
// ../protocol/src/context/messages/contrastModeChanged.ts
|
|
1667
|
-
var contrastModeChangedMessageSchema = object({
|
|
1668
|
-
type: literal("contrastModeChanged"),
|
|
1669
|
-
contrastMode: notionContrastModeSchema
|
|
1670
|
-
});
|
|
1671
|
-
|
|
1672
|
-
// ../protocol/src/context/messages/pageChanged.ts
|
|
1673
|
-
var pageChangedMessageSchema = object({
|
|
1674
|
-
type: literal("pageChanged"),
|
|
1675
|
-
page: customBlockPageSchema
|
|
1676
|
-
});
|
|
1677
|
-
|
|
1678
|
-
// ../protocol/src/context/messages/parentChanged.ts
|
|
1679
|
-
var parentChangedMessageSchema = object({
|
|
1680
|
-
type: literal("parentChanged"),
|
|
1681
|
-
parent: notionParentSchema
|
|
1682
|
-
});
|
|
1683
|
-
|
|
1684
|
-
// ../protocol/src/context/messages/resize.ts
|
|
1685
|
-
var resizeMessageSchema = object({
|
|
1686
|
-
type: literal("resize"),
|
|
1687
|
-
height: pipe(number(), finite(), minValue(0))
|
|
1688
|
-
});
|
|
1689
|
-
|
|
1690
|
-
// ../protocol/src/context/messages/themeChanged.ts
|
|
1691
|
-
var themeChangedMessageSchema = object({
|
|
1692
|
-
type: literal("themeChanged"),
|
|
1693
|
-
theme: notionThemeSchema
|
|
1694
|
-
});
|
|
1695
|
-
|
|
1696
1940
|
// ../protocol/src/dataSources/bridgeArchiveStatus.ts
|
|
1697
1941
|
var bridgeArchiveStatusSchema = picklist([
|
|
1698
1942
|
"active",
|
|
@@ -1700,9 +1944,14 @@ var bridgeArchiveStatusSchema = picklist([
|
|
|
1700
1944
|
"all"
|
|
1701
1945
|
]);
|
|
1702
1946
|
|
|
1703
|
-
// ../protocol/src/dataSources/
|
|
1704
|
-
var
|
|
1705
|
-
|
|
1947
|
+
// ../protocol/src/dataSources/bridgeDataSourceQueryLimitClamp.ts
|
|
1948
|
+
var bridgeDataSourceQueryLimitClampSchema = pipe(
|
|
1949
|
+
object({
|
|
1950
|
+
requested: pipe(number(), safeInteger(), minValue(1)),
|
|
1951
|
+
applied: pipe(number(), safeInteger(), minValue(1))
|
|
1952
|
+
}),
|
|
1953
|
+
check((value) => value.applied < value.requested)
|
|
1954
|
+
);
|
|
1706
1955
|
|
|
1707
1956
|
// ../protocol/src/dataSources/filters/checkboxFilterOperator.ts
|
|
1708
1957
|
var customBlockCheckboxFilterOperatorSchema = union([
|
|
@@ -1984,34 +2233,6 @@ var bridgeDataSourceSortSchema = strictObject({
|
|
|
1984
2233
|
direction: notionSortDirectionSchema
|
|
1985
2234
|
});
|
|
1986
2235
|
|
|
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
2236
|
// ../protocol/src/dataSources/messages/queryDataSource.ts
|
|
2016
2237
|
var queryDataSourceMessageSchema = object({
|
|
2017
2238
|
type: literal("queryDataSource"),
|
|
@@ -2039,24 +2260,8 @@ var queryDataSourceResultMessageSchema = variant("status", [
|
|
|
2039
2260
|
subscriptionId: string(),
|
|
2040
2261
|
status: literal("success"),
|
|
2041
2262
|
items: array(bridgePageSchema),
|
|
2042
|
-
hasMore: boolean()
|
|
2043
|
-
|
|
2044
|
-
object({
|
|
2045
|
-
type: literal("queryDataSourceResult"),
|
|
2046
|
-
subscriptionId: string(),
|
|
2047
|
-
status: literal("error"),
|
|
2048
|
-
error: customBlockQueryDataSourceErrorInfoSchema
|
|
2049
|
-
})
|
|
2050
|
-
]);
|
|
2051
|
-
var queryDataSourceResultMessageWithProtocol3To5CompatibilitySchema = variant("status", [
|
|
2052
|
-
object({
|
|
2053
|
-
type: literal("queryDataSourceResult"),
|
|
2054
|
-
subscriptionId: string(),
|
|
2055
|
-
status: literal("success"),
|
|
2056
|
-
items: array(
|
|
2057
|
-
union([bridgePageSchema, notionDataSourcePageForProtocol3To5Schema])
|
|
2058
|
-
),
|
|
2059
|
-
hasMore: boolean()
|
|
2263
|
+
hasMore: boolean(),
|
|
2264
|
+
limitClamp: optional(bridgeDataSourceQueryLimitClampSchema)
|
|
2060
2265
|
}),
|
|
2061
2266
|
object({
|
|
2062
2267
|
type: literal("queryDataSourceResult"),
|
|
@@ -2066,112 +2271,20 @@ var queryDataSourceResultMessageWithProtocol3To5CompatibilitySchema = variant("s
|
|
|
2066
2271
|
})
|
|
2067
2272
|
]);
|
|
2068
2273
|
|
|
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", [
|
|
2274
|
+
// ../protocol/src/handshake/connectResult.ts
|
|
2275
|
+
var connectResultMessageSchema = variant("status", [
|
|
2161
2276
|
object({
|
|
2162
|
-
type: literal("
|
|
2163
|
-
|
|
2277
|
+
type: literal("connectResult"),
|
|
2278
|
+
requestId: string(),
|
|
2164
2279
|
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)))
|
|
2280
|
+
/** The version selected from `connect.supportedProtocolVersions`, used for the rest of this connection. */
|
|
2281
|
+
protocolVersion: pipe(number(), integer(), minValue(1))
|
|
2169
2282
|
}),
|
|
2170
2283
|
object({
|
|
2171
|
-
type: literal("
|
|
2172
|
-
|
|
2284
|
+
type: literal("connectResult"),
|
|
2285
|
+
requestId: string(),
|
|
2173
2286
|
status: literal("error"),
|
|
2174
|
-
error:
|
|
2287
|
+
error: customBlockErrorInfoSchema
|
|
2175
2288
|
})
|
|
2176
2289
|
]);
|
|
2177
2290
|
|
|
@@ -2223,21 +2336,6 @@ var createPageResultMessageSchema = variant("status", [
|
|
|
2223
2336
|
error: customBlockCreatePageErrorInfoSchema
|
|
2224
2337
|
})
|
|
2225
2338
|
]);
|
|
2226
|
-
var createPageResultMessageWithProtocol3To5CompatibilitySchema = variant("status", [
|
|
2227
|
-
object({
|
|
2228
|
-
type: literal("createPageResult"),
|
|
2229
|
-
requestId: string(),
|
|
2230
|
-
status: literal("success"),
|
|
2231
|
-
/** The newly created page. */
|
|
2232
|
-
page: union([bridgePageSchema, bridgePageForProtocol3To5Schema])
|
|
2233
|
-
}),
|
|
2234
|
-
object({
|
|
2235
|
-
type: literal("createPageResult"),
|
|
2236
|
-
requestId: string(),
|
|
2237
|
-
status: literal("error"),
|
|
2238
|
-
error: customBlockCreatePageErrorInfoSchema
|
|
2239
|
-
})
|
|
2240
|
-
]);
|
|
2241
2339
|
var notionCreatePagePositionSchema = variant("type", [
|
|
2242
2340
|
object({ type: literal("start") }),
|
|
2243
2341
|
object({ type: literal("end") }),
|
|
@@ -2316,20 +2414,6 @@ var getPageResultMessageSchema = variant("status", [
|
|
|
2316
2414
|
error: customBlockGetPageErrorInfoSchema
|
|
2317
2415
|
})
|
|
2318
2416
|
]);
|
|
2319
|
-
var getPageResultMessageWithProtocol3To5CompatibilitySchema = variant("status", [
|
|
2320
|
-
object({
|
|
2321
|
-
type: literal("getPageResult"),
|
|
2322
|
-
requestId: string(),
|
|
2323
|
-
status: literal("success"),
|
|
2324
|
-
page: union([bridgePageSchema, bridgePageForProtocol3To5Schema])
|
|
2325
|
-
}),
|
|
2326
|
-
object({
|
|
2327
|
-
type: literal("getPageResult"),
|
|
2328
|
-
requestId: string(),
|
|
2329
|
-
status: literal("error"),
|
|
2330
|
-
error: customBlockGetPageErrorInfoSchema
|
|
2331
|
-
})
|
|
2332
|
-
]);
|
|
2333
2417
|
|
|
2334
2418
|
// ../protocol/src/pages/messages/openPage.ts
|
|
2335
2419
|
var openPageModeSchema = picklist(["side_peek", "center_peek"]);
|
|
@@ -2359,34 +2443,20 @@ var openPageResultMessageSchema = variant("status", [
|
|
|
2359
2443
|
error: customBlockOpenPageErrorInfoSchema
|
|
2360
2444
|
})
|
|
2361
2445
|
]);
|
|
2362
|
-
|
|
2363
|
-
// ../protocol/src/pages/messages/updatePage.ts
|
|
2364
|
-
var customBlockUpdatePageErrorCodeSchema = string();
|
|
2365
|
-
var customBlockUpdatePageErrorInfoSchema = object({
|
|
2366
|
-
code: customBlockUpdatePageErrorCodeSchema,
|
|
2367
|
-
message: string(),
|
|
2368
|
-
isRetryable: boolean()
|
|
2369
|
-
});
|
|
2370
|
-
var updatePageResultMessageSchema = variant("status", [
|
|
2371
|
-
object({
|
|
2372
|
-
type: literal("updatePageResult"),
|
|
2373
|
-
requestId: string(),
|
|
2374
|
-
status: literal("success"),
|
|
2375
|
-
page: bridgePageSchema
|
|
2376
|
-
}),
|
|
2377
|
-
object({
|
|
2378
|
-
type: literal("updatePageResult"),
|
|
2379
|
-
requestId: string(),
|
|
2380
|
-
status: literal("error"),
|
|
2381
|
-
error: customBlockUpdatePageErrorInfoSchema
|
|
2382
|
-
})
|
|
2383
|
-
]);
|
|
2384
|
-
var updatePageResultMessageWithProtocol3To5CompatibilitySchema = variant("status", [
|
|
2446
|
+
|
|
2447
|
+
// ../protocol/src/pages/messages/updatePage.ts
|
|
2448
|
+
var customBlockUpdatePageErrorCodeSchema = string();
|
|
2449
|
+
var customBlockUpdatePageErrorInfoSchema = object({
|
|
2450
|
+
code: customBlockUpdatePageErrorCodeSchema,
|
|
2451
|
+
message: string(),
|
|
2452
|
+
isRetryable: boolean()
|
|
2453
|
+
});
|
|
2454
|
+
var updatePageResultMessageSchema = variant("status", [
|
|
2385
2455
|
object({
|
|
2386
2456
|
type: literal("updatePageResult"),
|
|
2387
2457
|
requestId: string(),
|
|
2388
2458
|
status: literal("success"),
|
|
2389
|
-
page:
|
|
2459
|
+
page: bridgePageSchema
|
|
2390
2460
|
}),
|
|
2391
2461
|
object({
|
|
2392
2462
|
type: literal("updatePageResult"),
|
|
@@ -2404,7 +2474,7 @@ var updatePageMessageSchema = object({
|
|
|
2404
2474
|
* Property values, keyed by raw property IDs from Notion.
|
|
2405
2475
|
*
|
|
2406
2476
|
* 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.
|
|
2477
|
+
* To update a page with manifest-defined property keys, call `row.updateByKey()` on a row returned
|
|
2408
2478
|
* by `useDataSource()`. The SDK resolves those keys before it sends this message.
|
|
2409
2479
|
*/
|
|
2410
2480
|
properties: optional(bridgePagePropertyWriteMapSchema),
|
|
@@ -2413,11 +2483,38 @@ var updatePageMessageSchema = object({
|
|
|
2413
2483
|
archived: optional(boolean())
|
|
2414
2484
|
});
|
|
2415
2485
|
|
|
2416
|
-
// ../protocol/src/users/
|
|
2417
|
-
var
|
|
2418
|
-
|
|
2419
|
-
|
|
2486
|
+
// ../protocol/src/users/bridgeUser.ts
|
|
2487
|
+
var bridgeUserSchema = object({
|
|
2488
|
+
object: literal("user"),
|
|
2489
|
+
id: notionUserIdSchema,
|
|
2490
|
+
/** The user's name, or `null` when unavailable. Empty strings are preserved. */
|
|
2491
|
+
name: nullable(string()),
|
|
2492
|
+
avatar_url: nullable(string()),
|
|
2493
|
+
type: literal("person"),
|
|
2494
|
+
person: object({
|
|
2495
|
+
email: string()
|
|
2496
|
+
})
|
|
2497
|
+
});
|
|
2498
|
+
|
|
2499
|
+
// ../protocol/src/users/messages/getCurrentUser.ts
|
|
2500
|
+
var getCurrentUserMessageSchema = object({
|
|
2501
|
+
type: literal("getCurrentUser"),
|
|
2502
|
+
requestId: string()
|
|
2420
2503
|
});
|
|
2504
|
+
var getCurrentUserResultMessageSchema = variant("status", [
|
|
2505
|
+
object({
|
|
2506
|
+
type: literal("getCurrentUserResult"),
|
|
2507
|
+
requestId: string(),
|
|
2508
|
+
status: literal("success"),
|
|
2509
|
+
user: bridgeUserSchema
|
|
2510
|
+
}),
|
|
2511
|
+
object({
|
|
2512
|
+
type: literal("getCurrentUserResult"),
|
|
2513
|
+
requestId: string(),
|
|
2514
|
+
status: literal("error"),
|
|
2515
|
+
error: customBlockErrorInfoSchema
|
|
2516
|
+
})
|
|
2517
|
+
]);
|
|
2421
2518
|
|
|
2422
2519
|
// ../protocol/src/users/messages/getUser.ts
|
|
2423
2520
|
var customBlockGetUserErrorCodeSchema = string();
|
|
@@ -2446,6 +2543,35 @@ var getUserResultMessageSchema = variant("status", [
|
|
|
2446
2543
|
})
|
|
2447
2544
|
]);
|
|
2448
2545
|
|
|
2546
|
+
// ../protocol/src/users/viewer.ts
|
|
2547
|
+
var bridgeViewerSchema = variant("type", [
|
|
2548
|
+
object({
|
|
2549
|
+
type: literal("user"),
|
|
2550
|
+
userId: pipe(notionUserIdSchema, nonEmpty())
|
|
2551
|
+
}),
|
|
2552
|
+
object({ type: literal("anonymous") })
|
|
2553
|
+
]);
|
|
2554
|
+
|
|
2555
|
+
// ../protocol/src/users/messages/getViewer.ts
|
|
2556
|
+
var getViewerMessageSchema = object({
|
|
2557
|
+
type: literal("getViewer"),
|
|
2558
|
+
requestId: string()
|
|
2559
|
+
});
|
|
2560
|
+
var getViewerResultMessageSchema = variant("status", [
|
|
2561
|
+
object({
|
|
2562
|
+
type: literal("getViewerResult"),
|
|
2563
|
+
requestId: string(),
|
|
2564
|
+
status: literal("success"),
|
|
2565
|
+
viewer: bridgeViewerSchema
|
|
2566
|
+
}),
|
|
2567
|
+
object({
|
|
2568
|
+
type: literal("getViewerResult"),
|
|
2569
|
+
requestId: string(),
|
|
2570
|
+
status: literal("error"),
|
|
2571
|
+
error: customBlockErrorInfoSchema
|
|
2572
|
+
})
|
|
2573
|
+
]);
|
|
2574
|
+
|
|
2449
2575
|
// ../protocol/src/users/bridgeUserList.ts
|
|
2450
2576
|
var bridgeUserListSchema = object({
|
|
2451
2577
|
object: literal("list"),
|
|
@@ -2456,90 +2582,313 @@ var bridgeUserListSchema = object({
|
|
|
2456
2582
|
user: record(string(), unknown())
|
|
2457
2583
|
});
|
|
2458
2584
|
|
|
2459
|
-
// ../protocol/src/users/messages/listUsers.ts
|
|
2460
|
-
var customBlockListUsersErrorCodeSchema = string();
|
|
2461
|
-
var customBlockListUsersErrorInfoSchema = object({
|
|
2462
|
-
code: customBlockListUsersErrorCodeSchema,
|
|
2463
|
-
message: string(),
|
|
2464
|
-
isRetryable: boolean()
|
|
2465
|
-
});
|
|
2466
|
-
var listUsersMessageSchema = object({
|
|
2467
|
-
type: literal("listUsers"),
|
|
2468
|
-
requestId: string(),
|
|
2469
|
-
startCursor: optional(string()),
|
|
2470
|
-
pageSize: optional(number())
|
|
2585
|
+
// ../protocol/src/users/messages/listUsers.ts
|
|
2586
|
+
var customBlockListUsersErrorCodeSchema = string();
|
|
2587
|
+
var customBlockListUsersErrorInfoSchema = object({
|
|
2588
|
+
code: customBlockListUsersErrorCodeSchema,
|
|
2589
|
+
message: string(),
|
|
2590
|
+
isRetryable: boolean()
|
|
2591
|
+
});
|
|
2592
|
+
var listUsersMessageSchema = object({
|
|
2593
|
+
type: literal("listUsers"),
|
|
2594
|
+
requestId: string(),
|
|
2595
|
+
startCursor: optional(string()),
|
|
2596
|
+
pageSize: optional(number())
|
|
2597
|
+
});
|
|
2598
|
+
var listUsersResultMessageSchema = variant("status", [
|
|
2599
|
+
object({
|
|
2600
|
+
type: literal("listUsersResult"),
|
|
2601
|
+
requestId: string(),
|
|
2602
|
+
status: literal("success"),
|
|
2603
|
+
list: bridgeUserListSchema
|
|
2604
|
+
}),
|
|
2605
|
+
object({
|
|
2606
|
+
type: literal("listUsersResult"),
|
|
2607
|
+
requestId: string(),
|
|
2608
|
+
status: literal("error"),
|
|
2609
|
+
error: customBlockListUsersErrorInfoSchema
|
|
2610
|
+
})
|
|
2611
|
+
]);
|
|
2612
|
+
|
|
2613
|
+
// ../protocol/src/messages/invalidSandboxMessage.ts
|
|
2614
|
+
var invalidSandboxMessageSchema = object({
|
|
2615
|
+
type: literal("invalidSandboxMessage"),
|
|
2616
|
+
/** Identifies the rejected request or response, when readable. */
|
|
2617
|
+
requestId: optional(string()),
|
|
2618
|
+
/** Identifies the affected query subscription, when readable. */
|
|
2619
|
+
subscriptionId: optional(string()),
|
|
2620
|
+
/**
|
|
2621
|
+
* A human-readable string intended for sandbox-side logging. It has no structured contract.
|
|
2622
|
+
*/
|
|
2623
|
+
reason: string()
|
|
2624
|
+
});
|
|
2625
|
+
|
|
2626
|
+
// ../protocol/src/messages/hostToSandbox.ts
|
|
2627
|
+
var hostToSandboxMessageSchema = variant("type", [
|
|
2628
|
+
connectResultMessageSchema,
|
|
2629
|
+
setupInitMessageSchema,
|
|
2630
|
+
getDataSourceResultMessageSchema,
|
|
2631
|
+
getCurrentUserResultMessageSchema,
|
|
2632
|
+
getViewerResultMessageSchema,
|
|
2633
|
+
dataSourcesInvalidatedMessageSchema,
|
|
2634
|
+
themeChangedMessageSchema,
|
|
2635
|
+
contrastModeChangedMessageSchema,
|
|
2636
|
+
parentChangedMessageSchema,
|
|
2637
|
+
pageChangedMessageSchema,
|
|
2638
|
+
pageErrorMessageSchema,
|
|
2639
|
+
parentErrorMessageSchema,
|
|
2640
|
+
getUserResultMessageSchema,
|
|
2641
|
+
listUsersResultMessageSchema,
|
|
2642
|
+
openPageResultMessageSchema,
|
|
2643
|
+
openExternalUrlResultMessageSchema,
|
|
2644
|
+
invalidSandboxMessageSchema,
|
|
2645
|
+
queryDataSourceResultMessageSchema,
|
|
2646
|
+
getPageResultMessageSchema,
|
|
2647
|
+
createPageResultMessageSchema,
|
|
2648
|
+
updatePageResultMessageSchema
|
|
2649
|
+
]);
|
|
2650
|
+
|
|
2651
|
+
// ../protocol/src/compatibility/protocol3To5/bridgePage.ts
|
|
2652
|
+
var bridgePageForProtocol3To5Schema = object({
|
|
2653
|
+
object: literal("page"),
|
|
2654
|
+
id: notionPageIdSchema,
|
|
2655
|
+
parent: notionParentSchema,
|
|
2656
|
+
properties: bridgePagePropertyWriteMapSchema,
|
|
2657
|
+
created_time: optional(string()),
|
|
2658
|
+
last_edited_time: optional(string()),
|
|
2659
|
+
icon: optional(bridgePageIconSchema),
|
|
2660
|
+
cover: optional(bridgePageCoverSchema),
|
|
2661
|
+
url: optional(string()),
|
|
2662
|
+
public_url: optional(string()),
|
|
2663
|
+
/** Whether the page or an ancestor is archived. */
|
|
2664
|
+
is_archived: boolean(),
|
|
2665
|
+
/** Whether the page or an ancestor is in Trash. */
|
|
2666
|
+
in_trash: boolean()
|
|
2667
|
+
});
|
|
2668
|
+
|
|
2669
|
+
// ../protocol/src/compatibility/protocol3To5/dataSourceValue.ts
|
|
2670
|
+
var notionDataSourceValueSchema = union([
|
|
2671
|
+
string(),
|
|
2672
|
+
number(),
|
|
2673
|
+
boolean(),
|
|
2674
|
+
notionDateValueSchema,
|
|
2675
|
+
array(string()),
|
|
2676
|
+
array(notionRecordPointerSchema)
|
|
2677
|
+
]);
|
|
2678
|
+
|
|
2679
|
+
// ../protocol/src/compatibility/protocol3To5/dataSourcePage.ts
|
|
2680
|
+
var notionDataSourcePageForProtocol3To5Schema = object({
|
|
2681
|
+
id: notionPageIdSchema,
|
|
2682
|
+
/** Whether the page or an ancestor is archived. */
|
|
2683
|
+
is_archived: boolean(),
|
|
2684
|
+
/** Whether the page or an ancestor is in Trash. */
|
|
2685
|
+
in_trash: boolean(),
|
|
2686
|
+
propertiesById: record(string(), optional(notionDataSourceValueSchema))
|
|
2687
|
+
});
|
|
2688
|
+
|
|
2689
|
+
// ../protocol/src/compatibility/protocol3To5/pageResults.ts
|
|
2690
|
+
var createPageResultMessageWithProtocol3To5CompatibilitySchema = variant("status", [
|
|
2691
|
+
object({
|
|
2692
|
+
type: literal("createPageResult"),
|
|
2693
|
+
requestId: string(),
|
|
2694
|
+
status: literal("success"),
|
|
2695
|
+
/** The newly created page. */
|
|
2696
|
+
page: union([bridgePageSchema, bridgePageForProtocol3To5Schema])
|
|
2697
|
+
}),
|
|
2698
|
+
object({
|
|
2699
|
+
type: literal("createPageResult"),
|
|
2700
|
+
requestId: string(),
|
|
2701
|
+
status: literal("error"),
|
|
2702
|
+
error: customBlockCreatePageErrorInfoSchema
|
|
2703
|
+
})
|
|
2704
|
+
]);
|
|
2705
|
+
var getPageResultMessageWithProtocol3To5CompatibilitySchema = variant("status", [
|
|
2706
|
+
object({
|
|
2707
|
+
type: literal("getPageResult"),
|
|
2708
|
+
requestId: string(),
|
|
2709
|
+
status: literal("success"),
|
|
2710
|
+
page: union([bridgePageSchema, bridgePageForProtocol3To5Schema])
|
|
2711
|
+
}),
|
|
2712
|
+
object({
|
|
2713
|
+
type: literal("getPageResult"),
|
|
2714
|
+
requestId: string(),
|
|
2715
|
+
status: literal("error"),
|
|
2716
|
+
error: customBlockGetPageErrorInfoSchema
|
|
2717
|
+
})
|
|
2718
|
+
]);
|
|
2719
|
+
var updatePageResultMessageWithProtocol3To5CompatibilitySchema = variant("status", [
|
|
2720
|
+
object({
|
|
2721
|
+
type: literal("updatePageResult"),
|
|
2722
|
+
requestId: string(),
|
|
2723
|
+
status: literal("success"),
|
|
2724
|
+
page: union([bridgePageSchema, bridgePageForProtocol3To5Schema])
|
|
2725
|
+
}),
|
|
2726
|
+
object({
|
|
2727
|
+
type: literal("updatePageResult"),
|
|
2728
|
+
requestId: string(),
|
|
2729
|
+
status: literal("error"),
|
|
2730
|
+
error: customBlockUpdatePageErrorInfoSchema
|
|
2731
|
+
})
|
|
2732
|
+
]);
|
|
2733
|
+
var queryDataSourceResultMessageWithProtocol3To5CompatibilitySchema = variant("status", [
|
|
2734
|
+
object({
|
|
2735
|
+
type: literal("queryDataSourceResult"),
|
|
2736
|
+
subscriptionId: string(),
|
|
2737
|
+
status: literal("success"),
|
|
2738
|
+
items: array(
|
|
2739
|
+
union([bridgePageSchema, notionDataSourcePageForProtocol3To5Schema])
|
|
2740
|
+
),
|
|
2741
|
+
hasMore: boolean(),
|
|
2742
|
+
limitClamp: optional(bridgeDataSourceQueryLimitClampSchema)
|
|
2743
|
+
}),
|
|
2744
|
+
object({
|
|
2745
|
+
type: literal("queryDataSourceResult"),
|
|
2746
|
+
subscriptionId: string(),
|
|
2747
|
+
status: literal("error"),
|
|
2748
|
+
error: customBlockQueryDataSourceErrorInfoSchema
|
|
2749
|
+
})
|
|
2750
|
+
]);
|
|
2751
|
+
|
|
2752
|
+
// ../protocol/src/compatibility/protocol11/dataSourcesChanged.ts
|
|
2753
|
+
var dataSourcesChangedMessageSchema = object({
|
|
2754
|
+
type: literal("dataSourcesChanged"),
|
|
2755
|
+
dataSources: object({
|
|
2756
|
+
bindings: bridgeDataSourceBindingsSchema
|
|
2757
|
+
})
|
|
2758
|
+
});
|
|
2759
|
+
|
|
2760
|
+
// ../protocol/src/compatibility/protocol3To11/hostToSandbox.ts
|
|
2761
|
+
var protocol3To11HostToSandboxMessageSchema = variant("type", [
|
|
2762
|
+
protocol3To11InitMessageSchema,
|
|
2763
|
+
themeChangedMessageSchema,
|
|
2764
|
+
contrastModeChangedMessageSchema,
|
|
2765
|
+
parentChangedMessageSchema,
|
|
2766
|
+
protocol3To11PageChangedMessageSchema,
|
|
2767
|
+
currentUserChangedForProtocol3To11Schema,
|
|
2768
|
+
dataSourcesChangedMessageSchema,
|
|
2769
|
+
getUserResultForProtocol3To11Schema,
|
|
2770
|
+
listUsersResultForProtocol3To11Schema,
|
|
2771
|
+
openPageResultMessageSchema,
|
|
2772
|
+
openExternalUrlResultMessageSchema,
|
|
2773
|
+
invalidSandboxMessageSchema,
|
|
2774
|
+
queryDataSourceResultMessageWithProtocol3To5CompatibilitySchema,
|
|
2775
|
+
getPageResultMessageWithProtocol3To5CompatibilitySchema,
|
|
2776
|
+
createPageResultMessageWithProtocol3To5CompatibilitySchema,
|
|
2777
|
+
updatePageResultMessageWithProtocol3To5CompatibilitySchema
|
|
2778
|
+
]);
|
|
2779
|
+
|
|
2780
|
+
// ../protocol/src/compatibility/hostToSandbox.ts
|
|
2781
|
+
var hostToSandboxMessageWithCompatibilitySchema = union([
|
|
2782
|
+
hostToSandboxMessageSchema,
|
|
2783
|
+
protocol3To11HostToSandboxMessageSchema
|
|
2784
|
+
]);
|
|
2785
|
+
|
|
2786
|
+
// ../protocol/src/compatibility/protocol3To10/dataSourceBindings.ts
|
|
2787
|
+
var bridgeDataSourceBindingsForProtocol3To10Schema = record(
|
|
2788
|
+
string(),
|
|
2789
|
+
object({
|
|
2790
|
+
collectionPointer: optional(dataSourcePointerValidator),
|
|
2791
|
+
collectionSchema: optional(notionDataSourceSchemaValidator),
|
|
2792
|
+
propertyIdsByKey: optional(record(string(), optional(string()))),
|
|
2793
|
+
inaccessible: optional(literal(true))
|
|
2794
|
+
})
|
|
2795
|
+
);
|
|
2796
|
+
var dataSourceBindingsMessageForProtocol3To10Schema = variant(
|
|
2797
|
+
"type",
|
|
2798
|
+
[
|
|
2799
|
+
object({
|
|
2800
|
+
...protocol3To11InitSuccessMessageSchema.entries,
|
|
2801
|
+
dataSources: object({
|
|
2802
|
+
bindings: bridgeDataSourceBindingsForProtocol3To10Schema
|
|
2803
|
+
})
|
|
2804
|
+
}),
|
|
2805
|
+
object({
|
|
2806
|
+
type: literal("dataSourcesChanged"),
|
|
2807
|
+
dataSources: object({
|
|
2808
|
+
bindings: bridgeDataSourceBindingsForProtocol3To10Schema
|
|
2809
|
+
})
|
|
2810
|
+
})
|
|
2811
|
+
]
|
|
2812
|
+
);
|
|
2813
|
+
|
|
2814
|
+
// ../protocol/src/context/messages/resize.ts
|
|
2815
|
+
var resizeMessageSchema = object({
|
|
2816
|
+
type: literal("resize"),
|
|
2817
|
+
height: pipe(number(), finite(), minValue(0))
|
|
2818
|
+
});
|
|
2819
|
+
|
|
2820
|
+
// ../protocol/src/dataSources/messages/unsubscribeDataSourceQuery.ts
|
|
2821
|
+
var unsubscribeDataSourceQueryMessageSchema = object({
|
|
2822
|
+
type: literal("unsubscribeDataSourceQuery"),
|
|
2823
|
+
/** The subscription to remove from the host. */
|
|
2824
|
+
subscriptionId: string()
|
|
2471
2825
|
});
|
|
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
|
-
]);
|
|
2486
2826
|
|
|
2487
|
-
// ../protocol/src/messages/
|
|
2488
|
-
var
|
|
2489
|
-
type: literal("
|
|
2827
|
+
// ../protocol/src/messages/invalidHostMessage.ts
|
|
2828
|
+
var invalidHostMessageSchema = object({
|
|
2829
|
+
type: literal("invalidHostMessage"),
|
|
2490
2830
|
/** Identifies the rejected request or response, when readable. */
|
|
2491
2831
|
requestId: optional(string()),
|
|
2832
|
+
/** Identifies the affected query subscription, when readable. */
|
|
2833
|
+
subscriptionId: optional(string()),
|
|
2492
2834
|
/**
|
|
2493
2835
|
* A human-readable string intended for sandbox-side logging. It has no structured contract.
|
|
2494
2836
|
*/
|
|
2495
2837
|
reason: string()
|
|
2496
2838
|
});
|
|
2497
2839
|
|
|
2498
|
-
// ../protocol/src/
|
|
2499
|
-
var
|
|
2500
|
-
|
|
2840
|
+
// ../protocol/src/compatibility/protocol3To11/sandboxToHost.ts
|
|
2841
|
+
var protocol3To11SandboxToHostMessageSchema = variant("type", [
|
|
2842
|
+
protocol3To11ConnectMessageSchema,
|
|
2843
|
+
protocol3To11InitResultMessageSchema,
|
|
2844
|
+
queryDataSourceMessageSchema,
|
|
2845
|
+
unsubscribeDataSourceQueryMessageSchema,
|
|
2846
|
+
createPageMessageSchema,
|
|
2847
|
+
getPageMessageSchema,
|
|
2848
|
+
getUserMessageSchema,
|
|
2849
|
+
listUsersMessageSchema,
|
|
2850
|
+
openPageMessageSchema,
|
|
2851
|
+
openExternalUrlMessageSchema,
|
|
2852
|
+
updatePageMessageSchema,
|
|
2853
|
+
resizeMessageSchema,
|
|
2854
|
+
invalidHostMessageSchema
|
|
2855
|
+
]);
|
|
2856
|
+
|
|
2857
|
+
// ../protocol/src/compatibility/protocol11/hostToSandbox.ts
|
|
2858
|
+
var protocol11HostToSandboxMessageSchema = variant("type", [
|
|
2859
|
+
protocol3To11InitMessageSchema,
|
|
2501
2860
|
themeChangedMessageSchema,
|
|
2502
2861
|
contrastModeChangedMessageSchema,
|
|
2503
2862
|
parentChangedMessageSchema,
|
|
2504
|
-
|
|
2505
|
-
|
|
2863
|
+
protocol3To11PageChangedMessageSchema,
|
|
2864
|
+
currentUserChangedForProtocol3To11Schema,
|
|
2506
2865
|
dataSourcesChangedMessageSchema,
|
|
2507
|
-
|
|
2508
|
-
|
|
2866
|
+
getUserResultForProtocol3To11Schema,
|
|
2867
|
+
listUsersResultForProtocol3To11Schema,
|
|
2509
2868
|
openPageResultMessageSchema,
|
|
2510
2869
|
openExternalUrlResultMessageSchema,
|
|
2511
|
-
invalidSandboxMessageSchema
|
|
2512
|
-
]);
|
|
2513
|
-
var hostToSandboxMessageSchema = variant("type", [
|
|
2514
|
-
...baseHostToSandboxMessageSchema.options,
|
|
2870
|
+
invalidSandboxMessageSchema,
|
|
2515
2871
|
queryDataSourceResultMessageSchema,
|
|
2516
2872
|
getPageResultMessageSchema,
|
|
2517
2873
|
createPageResultMessageSchema,
|
|
2518
2874
|
updatePageResultMessageSchema
|
|
2519
2875
|
]);
|
|
2520
|
-
var hostToSandboxMessageWithProtocol3To5CompatibilitySchema = variant("type", [
|
|
2521
|
-
...baseHostToSandboxMessageSchema.options,
|
|
2522
|
-
queryDataSourceResultMessageWithProtocol3To5CompatibilitySchema,
|
|
2523
|
-
getPageResultMessageWithProtocol3To5CompatibilitySchema,
|
|
2524
|
-
createPageResultMessageWithProtocol3To5CompatibilitySchema,
|
|
2525
|
-
updatePageResultMessageWithProtocol3To5CompatibilitySchema
|
|
2526
|
-
]);
|
|
2527
2876
|
|
|
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()
|
|
2877
|
+
// ../protocol/src/handshake/ready.ts
|
|
2878
|
+
var readyMessageSchema = object({
|
|
2879
|
+
type: literal("ready"),
|
|
2880
|
+
/** Initial rendered content height in CSS pixels, applied by the embedding application before reveal. */
|
|
2881
|
+
initialHeight: pipe(number(), finite(), minValue(0))
|
|
2537
2882
|
});
|
|
2538
2883
|
|
|
2539
2884
|
// ../protocol/src/messages/sandboxToHost.ts
|
|
2540
2885
|
var sandboxToHostMessageSchema = variant("type", [
|
|
2541
|
-
|
|
2542
|
-
|
|
2886
|
+
connectRequestMessageSchema,
|
|
2887
|
+
getDataSourceMessageSchema,
|
|
2888
|
+
getCurrentUserMessageSchema,
|
|
2889
|
+
getViewerMessageSchema,
|
|
2890
|
+
initResultRequestMessageSchema,
|
|
2891
|
+
readyMessageSchema,
|
|
2543
2892
|
queryDataSourceMessageSchema,
|
|
2544
2893
|
unsubscribeDataSourceQueryMessageSchema,
|
|
2545
2894
|
createPageMessageSchema,
|
|
@@ -2553,9 +2902,105 @@ var sandboxToHostMessageSchema = variant("type", [
|
|
|
2553
2902
|
invalidHostMessageSchema
|
|
2554
2903
|
]);
|
|
2555
2904
|
|
|
2905
|
+
// ../protocol/src/compatibility/sandboxToHost.ts
|
|
2906
|
+
var sandboxToHostMessageWithCompatibilitySchema = union([
|
|
2907
|
+
sandboxToHostMessageSchema,
|
|
2908
|
+
protocol3To11SandboxToHostMessageSchema
|
|
2909
|
+
]);
|
|
2910
|
+
|
|
2911
|
+
// ../protocol/src/dataSources/errors.ts
|
|
2912
|
+
var customBlockDataSourceResolutionErrorCodeSchema = string();
|
|
2913
|
+
var customBlockPropertyErrorCodeSchema = string();
|
|
2914
|
+
|
|
2915
|
+
// ../protocol/src/dataSources/notionDataSource.ts
|
|
2916
|
+
var notionDataSourceSchema = object({
|
|
2917
|
+
key: string(),
|
|
2918
|
+
dataSourcePointer: optional(dataSourcePointerValidator),
|
|
2919
|
+
/**
|
|
2920
|
+
* Describes database properties. Use this schema to resolve property bindings. Use this
|
|
2921
|
+
* schema to validate filter and sort references. Undefined when the host does not provide a
|
|
2922
|
+
* database schema.
|
|
2923
|
+
*/
|
|
2924
|
+
dataSourceSchema: optional(notionDataSourceSchemaValidator),
|
|
2925
|
+
/**
|
|
2926
|
+
* Maps user-defined property keys to database property IDs. Use this map to resolve a key
|
|
2927
|
+
* such as `name` to its database property ID. A value of `undefined` marks a declared
|
|
2928
|
+
* property without a valid binding. Synthetic metadata does not add entries to this map.
|
|
2929
|
+
*/
|
|
2930
|
+
propertyIdsByKey: record(string(), optional(string())),
|
|
2931
|
+
/**
|
|
2932
|
+
* Describes property values in query snapshots. Keys use the same property IDs as a snapshot's
|
|
2933
|
+
* `propertiesById` map.
|
|
2934
|
+
*
|
|
2935
|
+
* Includes four synthetic metadata fields, even when the database schema is unavailable:
|
|
2936
|
+
* `created_time`, `last_edited_time`, `created_by`, and `last_edited_by`. Also includes
|
|
2937
|
+
* database properties when the host provides their schema.
|
|
2938
|
+
*
|
|
2939
|
+
* Use `propertiesById` to read a value. Use this map to read the value's schema. Use
|
|
2940
|
+
* `dataSourceSchema` to validate filter and sort references.
|
|
2941
|
+
*/
|
|
2942
|
+
propertySchemasById: record(string(), notionPropertySchemaSchema),
|
|
2943
|
+
/**
|
|
2944
|
+
* `true` when the data source is bound but the viewer can't read it. The block still
|
|
2945
|
+
* initializes. Queries and writes that use this data source fail with
|
|
2946
|
+
* `data_source_inaccessible`.
|
|
2947
|
+
*/
|
|
2948
|
+
inaccessible: optional(literal(true))
|
|
2949
|
+
});
|
|
2950
|
+
|
|
2556
2951
|
// ../protocol/src/utils/readRequestId.ts
|
|
2557
2952
|
var requestIdentitySchema = object({ requestId: string() });
|
|
2558
2953
|
|
|
2954
|
+
// shared/dataSources/localPropertyValues.ts
|
|
2955
|
+
var stringValue = string();
|
|
2956
|
+
var numberValue = pipe(number(), finite());
|
|
2957
|
+
var booleanValue = boolean();
|
|
2958
|
+
var stringArrayValue = array(string());
|
|
2959
|
+
var pointerArrayValue = array(notionRecordPointerSchema);
|
|
2960
|
+
var anyLocalValue = union([
|
|
2961
|
+
stringValue,
|
|
2962
|
+
numberValue,
|
|
2963
|
+
booleanValue,
|
|
2964
|
+
notionDateValueSchema,
|
|
2965
|
+
stringArrayValue,
|
|
2966
|
+
pointerArrayValue
|
|
2967
|
+
]);
|
|
2968
|
+
var bindingValueSchemas = {
|
|
2969
|
+
title: stringValue,
|
|
2970
|
+
rich_text: stringValue,
|
|
2971
|
+
url: stringValue,
|
|
2972
|
+
email: stringValue,
|
|
2973
|
+
phone_number: stringValue,
|
|
2974
|
+
select: stringValue,
|
|
2975
|
+
status: stringValue,
|
|
2976
|
+
number: numberValue,
|
|
2977
|
+
checkbox: booleanValue,
|
|
2978
|
+
multi_select: stringArrayValue,
|
|
2979
|
+
date: notionDateValueSchema,
|
|
2980
|
+
created_time: notionDateValueSchema,
|
|
2981
|
+
last_edited_time: notionDateValueSchema,
|
|
2982
|
+
people: pointerArrayValue,
|
|
2983
|
+
relation: pointerArrayValue,
|
|
2984
|
+
files: stringValue
|
|
2985
|
+
};
|
|
2986
|
+
var convertedValueSchemas = {
|
|
2987
|
+
...bindingValueSchemas,
|
|
2988
|
+
created_by: pointerArrayValue,
|
|
2989
|
+
last_edited_by: pointerArrayValue,
|
|
2990
|
+
unique_id: stringValue,
|
|
2991
|
+
formula: stringValue,
|
|
2992
|
+
rollup: stringValue,
|
|
2993
|
+
verification: stringValue,
|
|
2994
|
+
place: stringValue
|
|
2995
|
+
};
|
|
2996
|
+
function matchesConvertedPropertyType(value, type) {
|
|
2997
|
+
const schema = is(notionPropertyTypeSchema, type) ? convertedValueSchemas[type] : void 0;
|
|
2998
|
+
return is(schema ?? anyLocalValue, value);
|
|
2999
|
+
}
|
|
3000
|
+
function isConvertedDataSourceValue(value) {
|
|
3001
|
+
return is(anyLocalValue, value);
|
|
3002
|
+
}
|
|
3003
|
+
|
|
2559
3004
|
// cli/diagnostics/formatUnknownError.ts
|
|
2560
3005
|
function formatUnknownError(error) {
|
|
2561
3006
|
return error instanceof Error ? error.message : String(error);
|
|
@@ -6356,6 +6801,68 @@ var Temporal = /* @__PURE__ */ Object.defineProperties({}, {
|
|
|
6356
6801
|
var Temporal2 = NativeTemporal || Temporal;
|
|
6357
6802
|
var toTemporalInstant2 = NativeTemporal ? Date.prototype.toTemporalInstant : toTemporalInstant;
|
|
6358
6803
|
|
|
6804
|
+
// shared/dataSources/notionDate.ts
|
|
6805
|
+
function toNotionDateInput(value) {
|
|
6806
|
+
if ("time_zone" in value && value.time_zone !== void 0) {
|
|
6807
|
+
validateTimeZone(value.time_zone);
|
|
6808
|
+
}
|
|
6809
|
+
const start = parseDatePropertyEndpoint(value, "start").toString();
|
|
6810
|
+
if (value.type === "daterange" || value.type === "datetimerange") {
|
|
6811
|
+
return {
|
|
6812
|
+
start,
|
|
6813
|
+
end: parseDatePropertyEndpoint(value, "end").toString(),
|
|
6814
|
+
reminder: value.reminder
|
|
6815
|
+
};
|
|
6816
|
+
}
|
|
6817
|
+
return { start, reminder: value.reminder };
|
|
6818
|
+
}
|
|
6819
|
+
function parseDatePropertyEndpoint(value, endpoint) {
|
|
6820
|
+
const useEnd = endpoint === "end" && (value.type === "daterange" || value.type === "datetimerange");
|
|
6821
|
+
const date = useEnd ? value.end_date : value.start_date;
|
|
6822
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(date)) {
|
|
6823
|
+
const field = useEnd ? "end_date" : "start_date";
|
|
6824
|
+
throw new RangeError(`${field} must use YYYY-MM-DD.`);
|
|
6825
|
+
}
|
|
6826
|
+
if (value.type === "datetime" || value.type === "datetimerange") {
|
|
6827
|
+
const time = useEnd && value.type === "datetimerange" ? value.end_time : value.start_time;
|
|
6828
|
+
return parseDateBoundary({
|
|
6829
|
+
value: `${date}T${time}`,
|
|
6830
|
+
timeZone: value.time_zone
|
|
6831
|
+
});
|
|
6832
|
+
}
|
|
6833
|
+
return Temporal2.PlainDate.from(date);
|
|
6834
|
+
}
|
|
6835
|
+
function parseDateBoundary({
|
|
6836
|
+
value,
|
|
6837
|
+
timeZone
|
|
6838
|
+
}) {
|
|
6839
|
+
if (!value.includes("T")) {
|
|
6840
|
+
return Temporal2.PlainDate.from(value);
|
|
6841
|
+
}
|
|
6842
|
+
if (/(?:Z|[+-]\d{2}:?\d{2})$/i.test(value)) {
|
|
6843
|
+
return Temporal2.Instant.from(value);
|
|
6844
|
+
}
|
|
6845
|
+
const localTime = Temporal2.PlainDateTime.from(value);
|
|
6846
|
+
const zone = timeZone ?? "UTC";
|
|
6847
|
+
const zonedTime = localTime.toZonedDateTime(zone, {
|
|
6848
|
+
disambiguation: "earlier"
|
|
6849
|
+
});
|
|
6850
|
+
if (!zonedTime.toPlainDateTime().equals(localTime)) {
|
|
6851
|
+
throw new RangeError(`Local time "${value}" does not exist in "${zone}".`);
|
|
6852
|
+
}
|
|
6853
|
+
return zonedTime.toInstant();
|
|
6854
|
+
}
|
|
6855
|
+
function validateTimeZone(timeZone) {
|
|
6856
|
+
try {
|
|
6857
|
+
Temporal2.Instant.fromEpochMilliseconds(0).toZonedDateTimeISO(timeZone);
|
|
6858
|
+
} catch (cause) {
|
|
6859
|
+
if (!(cause instanceof RangeError)) {
|
|
6860
|
+
throw cause;
|
|
6861
|
+
}
|
|
6862
|
+
throw new RangeError(`invalid time zone "${timeZone}"`, { cause });
|
|
6863
|
+
}
|
|
6864
|
+
}
|
|
6865
|
+
|
|
6359
6866
|
// shared/dataSources/sampleDataSource.ts
|
|
6360
6867
|
var sampleDataSourceTypeSchema = picklist([
|
|
6361
6868
|
"built-in",
|
|
@@ -6400,6 +6907,35 @@ function selectSampleDataSource({
|
|
|
6400
6907
|
return sources.find((source) => source.filename === `worker_${slotKey}`) ?? sources.find((source) => source.filename === slotKey);
|
|
6401
6908
|
}
|
|
6402
6909
|
|
|
6910
|
+
// shared/dataSources/toDataSourceDateValue.ts
|
|
6911
|
+
function toDataSourceDateValue(value) {
|
|
6912
|
+
if (is(notionDateValueSchema, value)) {
|
|
6913
|
+
return value;
|
|
6914
|
+
}
|
|
6915
|
+
if (typeof value !== "string") {
|
|
6916
|
+
return void 0;
|
|
6917
|
+
}
|
|
6918
|
+
try {
|
|
6919
|
+
const [date, time] = value.split("T");
|
|
6920
|
+
const { start } = toNotionDateInput({
|
|
6921
|
+
type: "datetime",
|
|
6922
|
+
start_date: date,
|
|
6923
|
+
start_time: time ?? "00:00:00Z"
|
|
6924
|
+
});
|
|
6925
|
+
return {
|
|
6926
|
+
type: "datetime",
|
|
6927
|
+
start_date: start.slice(0, 10),
|
|
6928
|
+
start_time: start.slice(11),
|
|
6929
|
+
time_zone: "UTC"
|
|
6930
|
+
};
|
|
6931
|
+
} catch (error) {
|
|
6932
|
+
if (error instanceof RangeError) {
|
|
6933
|
+
return void 0;
|
|
6934
|
+
}
|
|
6935
|
+
throw error;
|
|
6936
|
+
}
|
|
6937
|
+
}
|
|
6938
|
+
|
|
6403
6939
|
// cli/dataSources/listDataSourceFiles.ts
|
|
6404
6940
|
import { existsSync, readdirSync } from "node:fs";
|
|
6405
6941
|
function listDataSourceFiles(dataDir) {
|
|
@@ -6415,7 +6951,14 @@ var DEV_SHELL_STATUS_GROUP_NAMES = [
|
|
|
6415
6951
|
"Future"
|
|
6416
6952
|
];
|
|
6417
6953
|
function readDataSources(dataDir) {
|
|
6418
|
-
return
|
|
6954
|
+
return readSampleDataSourcesSnapshot(dataDir).dataSources.map((source) => {
|
|
6955
|
+
if (source.status === "failed") {
|
|
6956
|
+
throw new Error(
|
|
6957
|
+
`${resolve(dataDir, `${source.filename}.json`)}: ${source.message}`
|
|
6958
|
+
);
|
|
6959
|
+
}
|
|
6960
|
+
return source;
|
|
6961
|
+
}).sort((left, right) => left.name.localeCompare(right.name));
|
|
6419
6962
|
}
|
|
6420
6963
|
function readSampleDataSourcesSnapshot(dataDir) {
|
|
6421
6964
|
const dataSources = [];
|
|
@@ -6434,13 +6977,44 @@ function readSampleDataSourcesSnapshot(dataDir) {
|
|
|
6434
6977
|
});
|
|
6435
6978
|
}
|
|
6436
6979
|
}
|
|
6437
|
-
return { dataSources };
|
|
6980
|
+
return { dataSources: rejectDuplicatePageIds(dataSources) };
|
|
6981
|
+
}
|
|
6982
|
+
function rejectDuplicatePageIds(sources) {
|
|
6983
|
+
const filenamesByPageId = /* @__PURE__ */ new Map();
|
|
6984
|
+
for (const source of sources) {
|
|
6985
|
+
if (source.status === "failed") {
|
|
6986
|
+
continue;
|
|
6987
|
+
}
|
|
6988
|
+
for (const row of source.rows) {
|
|
6989
|
+
const filenames = filenamesByPageId.get(row.id) ?? [];
|
|
6990
|
+
filenames.push(source.filename);
|
|
6991
|
+
filenamesByPageId.set(row.id, filenames);
|
|
6992
|
+
}
|
|
6993
|
+
}
|
|
6994
|
+
const errorsByFilename = /* @__PURE__ */ new Map();
|
|
6995
|
+
for (const [pageId, filenames] of filenamesByPageId) {
|
|
6996
|
+
if (filenames.length < 2) {
|
|
6997
|
+
continue;
|
|
6998
|
+
}
|
|
6999
|
+
const files = [...new Set(filenames)].map((filename) => `${filename}.json`).join(", ");
|
|
7000
|
+
const message = `Duplicate page ID "${pageId}" in ${files}. Give each row a unique ID across all sample data files.`;
|
|
7001
|
+
for (const filename of filenames) {
|
|
7002
|
+
if (!errorsByFilename.has(filename)) {
|
|
7003
|
+
errorsByFilename.set(filename, message);
|
|
7004
|
+
}
|
|
7005
|
+
}
|
|
7006
|
+
}
|
|
7007
|
+
return sources.map((source) => {
|
|
7008
|
+
const message = errorsByFilename.get(source.filename);
|
|
7009
|
+
return message === void 0 ? source : { status: "failed", filename: source.filename, message };
|
|
7010
|
+
});
|
|
6438
7011
|
}
|
|
6439
7012
|
var nonEmptyString = pipe(string(), nonEmpty());
|
|
6440
7013
|
var statusOptionsSchema = array(
|
|
6441
7014
|
object({
|
|
6442
7015
|
id: nonEmptyString,
|
|
6443
|
-
name: nonEmptyString
|
|
7016
|
+
name: nonEmptyString,
|
|
7017
|
+
color: optional(notionPropertyColorSchema)
|
|
6444
7018
|
})
|
|
6445
7019
|
);
|
|
6446
7020
|
var statusGroupsSchema = array(
|
|
@@ -6515,26 +7089,28 @@ function readDataSource(file) {
|
|
|
6515
7089
|
),
|
|
6516
7090
|
rows
|
|
6517
7091
|
};
|
|
6518
|
-
|
|
7092
|
+
validateDateValues(file, source);
|
|
6519
7093
|
return source;
|
|
6520
7094
|
}
|
|
6521
|
-
function
|
|
7095
|
+
function validateDateValues(file, source) {
|
|
6522
7096
|
const dateProperties = Object.entries(source.schema).filter(
|
|
6523
|
-
([, property]) => property.type === "date"
|
|
7097
|
+
([, property]) => property.type === "date" || property.type === "created_time" || property.type === "last_edited_time"
|
|
6524
7098
|
);
|
|
6525
7099
|
for (const row of source.rows) {
|
|
6526
7100
|
for (const [propertyId] of dateProperties) {
|
|
6527
7101
|
const value = row[propertyId];
|
|
6528
|
-
if (
|
|
7102
|
+
if (value === void 0 || value === null) {
|
|
6529
7103
|
continue;
|
|
6530
7104
|
}
|
|
6531
7105
|
try {
|
|
6532
|
-
|
|
6533
|
-
|
|
6534
|
-
|
|
7106
|
+
const date = toDataSourceDateValue(value);
|
|
7107
|
+
if (date === void 0) {
|
|
7108
|
+
throw new Error("Expected a date value or ISO timestamp.");
|
|
7109
|
+
}
|
|
7110
|
+
toNotionDateInput(date);
|
|
6535
7111
|
} catch (cause) {
|
|
6536
7112
|
throw new Error(
|
|
6537
|
-
`${file}: row "${row.id}", property "${propertyId}":
|
|
7113
|
+
`${file}: row "${row.id}", property "${propertyId}": ${formatUnknownError(cause)}`,
|
|
6538
7114
|
{ cause }
|
|
6539
7115
|
);
|
|
6540
7116
|
}
|
|
@@ -6550,7 +7126,7 @@ function toNotionPropertySchema(propertyKey, property) {
|
|
|
6550
7126
|
});
|
|
6551
7127
|
}
|
|
6552
7128
|
|
|
6553
|
-
//
|
|
7129
|
+
// shared/utils/unreachable.ts
|
|
6554
7130
|
function unreachable(value) {
|
|
6555
7131
|
throw new Error(
|
|
6556
7132
|
`[custom-blocks-dev-shell] Unexpected value encountered: ${JSON.stringify(value)}`
|
|
@@ -6689,52 +7265,6 @@ function timestampToLocal(timestamp) {
|
|
|
6689
7265
|
start_time: timestamp.slice(11, 16)
|
|
6690
7266
|
} : { type: "date", start_date: timestamp.slice(0, 10) };
|
|
6691
7267
|
}
|
|
6692
|
-
var stringValue = string();
|
|
6693
|
-
var numberValue = pipe(number(), finite());
|
|
6694
|
-
var booleanValue = boolean();
|
|
6695
|
-
var stringArrayValue = array(string());
|
|
6696
|
-
var pointerArrayValue = array(
|
|
6697
|
-
object({ id: string(), table: string() })
|
|
6698
|
-
);
|
|
6699
|
-
var anyLocalValue = union([
|
|
6700
|
-
stringValue,
|
|
6701
|
-
numberValue,
|
|
6702
|
-
booleanValue,
|
|
6703
|
-
notionDateValueSchema,
|
|
6704
|
-
stringArrayValue,
|
|
6705
|
-
pointerArrayValue
|
|
6706
|
-
]);
|
|
6707
|
-
var VALUE_SCHEMAS = {
|
|
6708
|
-
title: stringValue,
|
|
6709
|
-
rich_text: stringValue,
|
|
6710
|
-
url: stringValue,
|
|
6711
|
-
email: stringValue,
|
|
6712
|
-
phone_number: stringValue,
|
|
6713
|
-
select: stringValue,
|
|
6714
|
-
status: stringValue,
|
|
6715
|
-
number: numberValue,
|
|
6716
|
-
checkbox: booleanValue,
|
|
6717
|
-
multi_select: stringArrayValue,
|
|
6718
|
-
date: notionDateValueSchema,
|
|
6719
|
-
created_time: notionDateValueSchema,
|
|
6720
|
-
last_edited_time: notionDateValueSchema,
|
|
6721
|
-
people: pointerArrayValue,
|
|
6722
|
-
relation: pointerArrayValue,
|
|
6723
|
-
created_by: pointerArrayValue,
|
|
6724
|
-
last_edited_by: pointerArrayValue,
|
|
6725
|
-
unique_id: stringValue,
|
|
6726
|
-
files: stringValue,
|
|
6727
|
-
formula: stringValue,
|
|
6728
|
-
rollup: stringValue,
|
|
6729
|
-
verification: stringValue,
|
|
6730
|
-
place: stringValue
|
|
6731
|
-
};
|
|
6732
|
-
function matchesPropertyType(value, type) {
|
|
6733
|
-
return is(VALUE_SCHEMAS[type] ?? anyLocalValue, value);
|
|
6734
|
-
}
|
|
6735
|
-
function isDataSourceValue(value) {
|
|
6736
|
-
return is(anyLocalValue, value);
|
|
6737
|
-
}
|
|
6738
7268
|
|
|
6739
7269
|
// cli/dataSources/conversion/runConvert.ts
|
|
6740
7270
|
var SUPPORTED_TYPES = new Set(NOTION_PROPERTY_TYPES);
|
|
@@ -6894,7 +7424,7 @@ function validateSource(source) {
|
|
|
6894
7424
|
);
|
|
6895
7425
|
continue;
|
|
6896
7426
|
}
|
|
6897
|
-
const matches = declared ?
|
|
7427
|
+
const matches = declared ? matchesConvertedPropertyType(value, declared.type) : isConvertedDataSourceValue(value);
|
|
6898
7428
|
if (!matches) {
|
|
6899
7429
|
issues.push(
|
|
6900
7430
|
`row ${JSON.stringify(row.id)}: ${JSON.stringify(key)} does not match ${declared ? `type ${JSON.stringify(declared.type)}` : "any supported value shape"}`
|
|
@@ -7309,10 +7839,13 @@ import { basename as basename2, dirname } from "node:path";
|
|
|
7309
7839
|
// cli/dataSources/copyPrebuiltDataSources.ts
|
|
7310
7840
|
import { copyFileSync, existsSync as existsSync2, mkdirSync } from "node:fs";
|
|
7311
7841
|
import { resolve as resolve2 } from "node:path";
|
|
7312
|
-
function copyPrebuiltDataSources(prebuiltDir, dataDir) {
|
|
7842
|
+
function copyPrebuiltDataSources(prebuiltDir, dataDir, selectedFilename) {
|
|
7313
7843
|
mkdirSync(dataDir, { recursive: true });
|
|
7314
7844
|
const written = [];
|
|
7315
7845
|
for (const source of readDataSources(prebuiltDir)) {
|
|
7846
|
+
if (selectedFilename !== void 0 && source.filename !== selectedFilename) {
|
|
7847
|
+
continue;
|
|
7848
|
+
}
|
|
7316
7849
|
const filename = `${source.filename}.json`;
|
|
7317
7850
|
const target = resolve2(dataDir, filename);
|
|
7318
7851
|
if (existsSync2(target)) {
|
|
@@ -7331,9 +7864,15 @@ function createDevShellDataService(options) {
|
|
|
7331
7864
|
const clients = /* @__PURE__ */ new Set();
|
|
7332
7865
|
let snapshot = {
|
|
7333
7866
|
blocks,
|
|
7334
|
-
|
|
7335
|
-
|
|
7336
|
-
|
|
7867
|
+
prebuiltSources: readDataSources(prebuiltDir).map((source) => ({
|
|
7868
|
+
filename: source.filename,
|
|
7869
|
+
name: source.name,
|
|
7870
|
+
icon: source.icon,
|
|
7871
|
+
rowCount: source.rows.length,
|
|
7872
|
+
propertyNames: Object.values(source.schema).map(
|
|
7873
|
+
(property) => property.name
|
|
7874
|
+
)
|
|
7875
|
+
})),
|
|
7337
7876
|
...readSampleDataSourcesSnapshot(dataDir)
|
|
7338
7877
|
};
|
|
7339
7878
|
let serialized = JSON.stringify(snapshot);
|
|
@@ -7440,8 +7979,22 @@ function createDevShellDataService(options) {
|
|
|
7440
7979
|
);
|
|
7441
7980
|
return;
|
|
7442
7981
|
}
|
|
7982
|
+
const filename = new URL(
|
|
7983
|
+
req.url ?? "/",
|
|
7984
|
+
"http://localhost"
|
|
7985
|
+
).searchParams.get("filename");
|
|
7986
|
+
if (filename !== null && !snapshot.prebuiltSources.some((source) => source.filename === filename)) {
|
|
7987
|
+
res.writeHead(400, { "Content-Type": "application/json" }).end(
|
|
7988
|
+
JSON.stringify({ error: "Choose an available example data source." })
|
|
7989
|
+
);
|
|
7990
|
+
return;
|
|
7991
|
+
}
|
|
7443
7992
|
try {
|
|
7444
|
-
const written = copyPrebuiltDataSources(
|
|
7993
|
+
const written = copyPrebuiltDataSources(
|
|
7994
|
+
prebuiltDir,
|
|
7995
|
+
dataDir,
|
|
7996
|
+
filename ?? void 0
|
|
7997
|
+
);
|
|
7445
7998
|
if (written.length > 0) {
|
|
7446
7999
|
log(`Added example data sources: ${written.join(", ")}`);
|
|
7447
8000
|
}
|
|
@@ -7712,7 +8265,8 @@ function buildCustomBlockDevShellCsp(args) {
|
|
|
7712
8265
|
"form-action 'none'",
|
|
7713
8266
|
// Local hosts replace Notion's production app, relay, and mobile-shell ancestors.
|
|
7714
8267
|
`frame-ancestors 'self' ${shellOrigin} ${allowedFrameAncestors.join(" ")}`,
|
|
7715
|
-
|
|
8268
|
+
// Allow WebAssembly compilation without enabling JavaScript string evaluation.
|
|
8269
|
+
"script-src 'self' 'unsafe-inline' 'wasm-unsafe-eval'",
|
|
7716
8270
|
`style-src 'self' 'unsafe-inline' https://fonts.googleapis.com ${approved}`
|
|
7717
8271
|
].map((directive) => directive.trim()).join("; ");
|
|
7718
8272
|
}
|