@valbuild/shared 0.123.2 → 0.124.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +108 -0
- package/dist/declarations/src/internal/ApiRoutes.d.ts +77 -0
- package/dist/declarations/src/internal/search/searchIndex.d.ts +31 -2
- package/internal/dist/valbuild-shared-internal.cjs.dev.js +183 -145
- package/internal/dist/valbuild-shared-internal.cjs.prod.js +183 -145
- package/internal/dist/valbuild-shared-internal.esm.js +183 -145
- package/package.json +2 -2
|
@@ -911,97 +911,96 @@ var InlineRender = zod.z.object({
|
|
|
911
911
|
as: zod.z.literal("inline")
|
|
912
912
|
});
|
|
913
913
|
var FieldRender = InlineRender.optional();
|
|
914
|
-
|
|
915
|
-
|
|
914
|
+
|
|
915
|
+
/**
|
|
916
|
+
* The fields EVERY serialized schema carries, in one place.
|
|
917
|
+
*
|
|
918
|
+
* Spread into each schema below rather than retyped, because retyping them is
|
|
919
|
+
* exactly how they went missing: `customValidate` and `description` were
|
|
920
|
+
* declared on six of the eighteen schemas and silently dropped by the other
|
|
921
|
+
* twelve. A field added to the base of `SerializedSchema` needs adding here and
|
|
922
|
+
* nowhere else.
|
|
923
|
+
*
|
|
924
|
+
* `type`, `opt` and whatever is particular to the schema stay at the call site
|
|
925
|
+
* - those differ per schema, so there is nothing to share.
|
|
926
|
+
*/
|
|
927
|
+
var commonSchemaFields = {
|
|
916
928
|
render: FieldRender,
|
|
929
|
+
preview: zod.z.literal(true).optional(),
|
|
930
|
+
// Whether the schema declares a `.validate()`. The function cannot serialize,
|
|
931
|
+
// so this flag is what tells the Studio to run the custom validators on the
|
|
932
|
+
// main thread against the real instance - dropped, and they never run at all.
|
|
933
|
+
// See `hasCustomValidate` in `ui/spa/validation/customValidate.ts`.
|
|
934
|
+
customValidate: zod.z["boolean"]().optional(),
|
|
935
|
+
readonly: zod.z["boolean"]().optional(),
|
|
936
|
+
hidden: zod.z["boolean"]().optional(),
|
|
937
|
+
description: zod.z.string().optional()
|
|
938
|
+
};
|
|
939
|
+
var SerializedStringSchema = zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
|
|
940
|
+
type: zod.z.literal("string"),
|
|
917
941
|
// `.multiline()`. Stripped like any undeclared key if it goes missing here,
|
|
918
942
|
// which is a single-line input where the author asked for a text box.
|
|
919
943
|
multiline: zod.z["boolean"]().optional(),
|
|
920
|
-
preview: zod.z.literal(true).optional(),
|
|
921
944
|
options: zod.z.object({
|
|
922
945
|
maxLength: zod.z.number().optional(),
|
|
923
946
|
minLength: zod.z.number().optional(),
|
|
924
947
|
regexp: zod.z.object({
|
|
948
|
+
// `.regexp(re, message)`'s message. Written by
|
|
949
|
+
// `StringSchema.executeSerialize`, so omitting it here strips the
|
|
950
|
+
// author's own wording and leaves the generic "Expected string to
|
|
951
|
+
// match reg exp: …" in its place.
|
|
952
|
+
message: zod.z.string().optional(),
|
|
925
953
|
source: zod.z.string(),
|
|
926
954
|
flags: zod.z.string()
|
|
927
|
-
}).optional()
|
|
955
|
+
}).optional(),
|
|
956
|
+
customValidate: zod.z["boolean"]().optional()
|
|
928
957
|
}).optional(),
|
|
929
958
|
opt: zod.z["boolean"](),
|
|
930
|
-
raw: zod.z["boolean"]()
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
});
|
|
934
|
-
var SerializedLiteralSchema = zod.z.object({
|
|
959
|
+
raw: zod.z["boolean"]()
|
|
960
|
+
}));
|
|
961
|
+
var SerializedLiteralSchema = zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
|
|
935
962
|
type: zod.z.literal("literal"),
|
|
936
|
-
render: FieldRender,
|
|
937
|
-
preview: zod.z.literal(true).optional(),
|
|
938
963
|
value: zod.z.string(),
|
|
939
|
-
opt: zod.z["boolean"]()
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
});
|
|
943
|
-
var SerializedBooleanSchema = zod.z.object({
|
|
964
|
+
opt: zod.z["boolean"]()
|
|
965
|
+
}));
|
|
966
|
+
var SerializedBooleanSchema = zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
|
|
944
967
|
type: zod.z.literal("boolean"),
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
readonly: zod.z["boolean"]().optional(),
|
|
949
|
-
hidden: zod.z["boolean"]().optional()
|
|
950
|
-
});
|
|
951
|
-
var SerializedNumberSchema = zod.z.object({
|
|
968
|
+
opt: zod.z["boolean"]()
|
|
969
|
+
}));
|
|
970
|
+
var SerializedNumberSchema = zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
|
|
952
971
|
type: zod.z.literal("number"),
|
|
953
|
-
render: FieldRender,
|
|
954
|
-
preview: zod.z.literal(true).optional(),
|
|
955
972
|
options: zod.z.object({
|
|
956
973
|
max: zod.z.number().optional(),
|
|
957
974
|
min: zod.z.number().optional()
|
|
958
975
|
}).optional(),
|
|
959
|
-
opt: zod.z["boolean"]()
|
|
960
|
-
|
|
961
|
-
hidden: zod.z["boolean"]().optional()
|
|
962
|
-
});
|
|
976
|
+
opt: zod.z["boolean"]()
|
|
977
|
+
}));
|
|
963
978
|
var SerializedObjectSchema = zod.z.lazy(function () {
|
|
964
|
-
return zod.z.object({
|
|
979
|
+
return zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
|
|
965
980
|
type: zod.z.literal("object"),
|
|
966
|
-
render: FieldRender,
|
|
967
|
-
preview: zod.z.literal(true).optional(),
|
|
968
981
|
items: zod.z.record(zod.z.string(), SerializedSchema),
|
|
969
|
-
opt: zod.z["boolean"]()
|
|
970
|
-
|
|
971
|
-
hidden: zod.z["boolean"]().optional()
|
|
972
|
-
});
|
|
982
|
+
opt: zod.z["boolean"]()
|
|
983
|
+
}));
|
|
973
984
|
});
|
|
974
985
|
var SerializedArraySchema = zod.z.lazy(function () {
|
|
975
|
-
return zod.z.object({
|
|
986
|
+
return zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
|
|
976
987
|
type: zod.z.literal("array"),
|
|
977
|
-
render: FieldRender,
|
|
978
|
-
preview: zod.z.literal(true).optional(),
|
|
979
988
|
item: SerializedSchema,
|
|
980
|
-
opt: zod.z["boolean"]()
|
|
981
|
-
|
|
982
|
-
hidden: zod.z["boolean"]().optional()
|
|
983
|
-
});
|
|
989
|
+
opt: zod.z["boolean"]()
|
|
990
|
+
}));
|
|
984
991
|
});
|
|
985
992
|
var SerializedUnionSchema = zod.z.lazy(function () {
|
|
986
|
-
return zod.z.union([zod.z.object({
|
|
993
|
+
return zod.z.union([zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
|
|
987
994
|
type: zod.z.literal("union"),
|
|
988
|
-
render: FieldRender,
|
|
989
|
-
preview: zod.z.literal(true).optional(),
|
|
990
995
|
key: SerializedLiteralSchema,
|
|
991
996
|
items: zod.z.array(SerializedLiteralSchema),
|
|
992
|
-
opt: zod.z["boolean"]()
|
|
993
|
-
|
|
994
|
-
hidden: zod.z["boolean"]().optional()
|
|
995
|
-
}), zod.z.object({
|
|
997
|
+
opt: zod.z["boolean"]()
|
|
998
|
+
})), zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
|
|
996
999
|
type: zod.z.literal("union"),
|
|
997
|
-
render: FieldRender,
|
|
998
|
-
preview: zod.z.literal(true).optional(),
|
|
999
1000
|
key: zod.z.string(),
|
|
1000
1001
|
items: zod.z.array(SerializedObjectSchema),
|
|
1001
|
-
opt: zod.z["boolean"]()
|
|
1002
|
-
|
|
1003
|
-
hidden: zod.z["boolean"]().optional()
|
|
1004
|
-
})]);
|
|
1002
|
+
opt: zod.z["boolean"]()
|
|
1003
|
+
}))]);
|
|
1005
1004
|
});
|
|
1006
1005
|
var ImageEncodeOption = zod.z.union([zod.z.literal(false), zod.z.object({
|
|
1007
1006
|
type: zod.z.literal("webp"),
|
|
@@ -1014,15 +1013,16 @@ var ImageOptions = zod.z.object({
|
|
|
1014
1013
|
accept: zod.z.string().optional(),
|
|
1015
1014
|
encode: ImageEncodeOption.optional()
|
|
1016
1015
|
});
|
|
1017
|
-
var SerializedImageSchema = zod.z.object({
|
|
1016
|
+
var SerializedImageSchema = zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
|
|
1018
1017
|
type: zod.z.literal("image"),
|
|
1019
|
-
render: FieldRender,
|
|
1020
|
-
preview: zod.z.literal(true).optional(),
|
|
1021
1018
|
options: ImageOptions.optional(),
|
|
1022
1019
|
opt: zod.z["boolean"](),
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1020
|
+
// `.remote()`, and the gallery a gallery-backed field reads its metadata
|
|
1021
|
+
// from. Neither is cosmetic: dropped, a remote field looks local and a
|
|
1022
|
+
// gallery-backed one looks like it holds its own dimensions.
|
|
1023
|
+
remote: zod.z["boolean"]().optional(),
|
|
1024
|
+
referencedModule: zod.z.string().optional()
|
|
1025
|
+
}));
|
|
1026
1026
|
var RichTextOptions = zod.z.lazy(function () {
|
|
1027
1027
|
return zod.z.object({
|
|
1028
1028
|
// Set by `.maxLength()` / `.minLength()`, not by the options argument.
|
|
@@ -1045,20 +1045,14 @@ var RichTextOptions = zod.z.lazy(function () {
|
|
|
1045
1045
|
img: zod.z.union([zod.z["boolean"](), SerializedImageSchema]).optional()
|
|
1046
1046
|
});
|
|
1047
1047
|
});
|
|
1048
|
-
var SerializedRichTextSchema = zod.z.object({
|
|
1048
|
+
var SerializedRichTextSchema = zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
|
|
1049
1049
|
type: zod.z.literal("richtext"),
|
|
1050
|
-
render: FieldRender,
|
|
1051
|
-
preview: zod.z.literal(true).optional(),
|
|
1052
1050
|
options: RichTextOptions.optional(),
|
|
1053
|
-
opt: zod.z["boolean"]()
|
|
1054
|
-
|
|
1055
|
-
hidden: zod.z["boolean"]().optional()
|
|
1056
|
-
});
|
|
1051
|
+
opt: zod.z["boolean"]()
|
|
1052
|
+
}));
|
|
1057
1053
|
var SerializedRecordSchema = zod.z.lazy(function () {
|
|
1058
|
-
return zod.z.object({
|
|
1054
|
+
return zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
|
|
1059
1055
|
type: zod.z.literal("record"),
|
|
1060
|
-
render: FieldRender,
|
|
1061
|
-
preview: zod.z.literal(true).optional(),
|
|
1062
1056
|
item: SerializedSchema,
|
|
1063
1057
|
opt: zod.z["boolean"](),
|
|
1064
1058
|
// Optional gallery marker for files/images
|
|
@@ -1069,16 +1063,12 @@ var SerializedRecordSchema = zod.z.lazy(function () {
|
|
|
1069
1063
|
remote: zod.z["boolean"]().optional(),
|
|
1070
1064
|
encode: ImageEncodeOption.optional(),
|
|
1071
1065
|
alt: SerializedSchema.optional(),
|
|
1072
|
-
moduleMetadata: zod.z.record(zod.z.string(), zod.z.record(zod.z.string(), zod.z.any())).optional()
|
|
1073
|
-
|
|
1074
|
-
hidden: zod.z["boolean"]().optional()
|
|
1075
|
-
}).passthrough();
|
|
1066
|
+
moduleMetadata: zod.z.record(zod.z.string(), zod.z.record(zod.z.string(), zod.z.any())).optional()
|
|
1067
|
+
})).passthrough();
|
|
1076
1068
|
});
|
|
1077
1069
|
var SerializedKeyOfSchema = zod.z.lazy(function () {
|
|
1078
|
-
return zod.z.object({
|
|
1070
|
+
return zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
|
|
1079
1071
|
type: zod.z.literal("keyOf"),
|
|
1080
|
-
render: FieldRender,
|
|
1081
|
-
preview: zod.z.literal(true).optional(),
|
|
1082
1072
|
path: SourcePath,
|
|
1083
1073
|
schema: zod.z.union([zod.z.object({
|
|
1084
1074
|
type: zod.z.literal("object"),
|
|
@@ -1089,82 +1079,54 @@ var SerializedKeyOfSchema = zod.z.lazy(function () {
|
|
|
1089
1079
|
opt: zod.z["boolean"]().optional()
|
|
1090
1080
|
})]).optional(),
|
|
1091
1081
|
values: zod.z.union([zod.z.literal("string"), zod.z.array(zod.z.string())]),
|
|
1092
|
-
opt: zod.z["boolean"]()
|
|
1093
|
-
|
|
1094
|
-
hidden: zod.z["boolean"]().optional()
|
|
1095
|
-
});
|
|
1082
|
+
opt: zod.z["boolean"]()
|
|
1083
|
+
}));
|
|
1096
1084
|
});
|
|
1097
1085
|
var FileOptions = zod.z.object({
|
|
1098
1086
|
accept: zod.z.string().optional()
|
|
1099
1087
|
});
|
|
1100
|
-
var SerializedFileSchema = zod.z.object({
|
|
1088
|
+
var SerializedFileSchema = zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
|
|
1101
1089
|
type: zod.z.literal("file"),
|
|
1102
|
-
render: FieldRender,
|
|
1103
|
-
preview: zod.z.literal(true).optional(),
|
|
1104
1090
|
options: FileOptions.optional(),
|
|
1105
1091
|
opt: zod.z["boolean"](),
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1092
|
+
// See `SerializedImageSchema` above: `.remote()` and the gallery a
|
|
1093
|
+
// gallery-backed field reads from.
|
|
1094
|
+
remote: zod.z["boolean"]().optional(),
|
|
1095
|
+
referencedModule: zod.z.string().optional()
|
|
1096
|
+
}));
|
|
1109
1097
|
var DateOptions = zod.z.object({
|
|
1110
1098
|
from: zod.z.string().optional(),
|
|
1111
1099
|
to: zod.z.string().optional()
|
|
1112
1100
|
});
|
|
1113
|
-
var SerializedDateSchema = zod.z.object({
|
|
1101
|
+
var SerializedDateSchema = zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
|
|
1114
1102
|
type: zod.z.literal("date"),
|
|
1115
|
-
render: FieldRender,
|
|
1116
|
-
preview: zod.z.literal(true).optional(),
|
|
1117
1103
|
options: DateOptions.optional(),
|
|
1118
|
-
opt: zod.z["boolean"]()
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
hidden: zod.z["boolean"]().optional(),
|
|
1122
|
-
description: zod.z.string().optional()
|
|
1123
|
-
});
|
|
1124
|
-
var SerializedDateTimeSchema = zod.z.object({
|
|
1104
|
+
opt: zod.z["boolean"]()
|
|
1105
|
+
}));
|
|
1106
|
+
var SerializedDateTimeSchema = zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
|
|
1125
1107
|
type: zod.z.literal("dateTime"),
|
|
1126
|
-
render: FieldRender,
|
|
1127
|
-
preview: zod.z.literal(true).optional(),
|
|
1128
1108
|
options: DateOptions.optional(),
|
|
1129
|
-
opt: zod.z["boolean"]()
|
|
1130
|
-
|
|
1131
|
-
readonly: zod.z["boolean"]().optional(),
|
|
1132
|
-
hidden: zod.z["boolean"]().optional(),
|
|
1133
|
-
description: zod.z.string().optional()
|
|
1134
|
-
});
|
|
1109
|
+
opt: zod.z["boolean"]()
|
|
1110
|
+
}));
|
|
1135
1111
|
var ColorOptions = zod.z.object({
|
|
1136
1112
|
format: zod.z["enum"](["hex", "rgb", "hsl", "oklch"]).optional(),
|
|
1137
1113
|
alpha: zod.z["boolean"]().optional()
|
|
1138
1114
|
});
|
|
1139
|
-
var SerializedColorSchema = zod.z.object({
|
|
1115
|
+
var SerializedColorSchema = zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
|
|
1140
1116
|
type: zod.z.literal("color"),
|
|
1141
|
-
render: FieldRender,
|
|
1142
|
-
preview: zod.z.literal(true).optional(),
|
|
1143
1117
|
options: ColorOptions.optional(),
|
|
1144
|
-
opt: zod.z["boolean"]()
|
|
1145
|
-
|
|
1146
|
-
readonly: zod.z["boolean"]().optional(),
|
|
1147
|
-
hidden: zod.z["boolean"]().optional(),
|
|
1148
|
-
description: zod.z.string().optional()
|
|
1149
|
-
});
|
|
1118
|
+
opt: zod.z["boolean"]()
|
|
1119
|
+
}));
|
|
1150
1120
|
var CodeOptions = zod.z.object({
|
|
1151
1121
|
language: zod.z["enum"](core.CODE_LANGUAGES).optional()
|
|
1152
1122
|
});
|
|
1153
|
-
var SerializedCodeSchema = zod.z.object({
|
|
1123
|
+
var SerializedCodeSchema = zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
|
|
1154
1124
|
type: zod.z.literal("code"),
|
|
1155
|
-
render: FieldRender,
|
|
1156
|
-
preview: zod.z.literal(true).optional(),
|
|
1157
1125
|
options: CodeOptions.optional(),
|
|
1158
|
-
opt: zod.z["boolean"]()
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
hidden: zod.z["boolean"]().optional(),
|
|
1162
|
-
description: zod.z.string().optional()
|
|
1163
|
-
});
|
|
1164
|
-
var SerializedRouteSchema = zod.z.object({
|
|
1126
|
+
opt: zod.z["boolean"]()
|
|
1127
|
+
}));
|
|
1128
|
+
var SerializedRouteSchema = zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
|
|
1165
1129
|
type: zod.z.literal("route"),
|
|
1166
|
-
render: FieldRender,
|
|
1167
|
-
preview: zod.z.literal(true).optional(),
|
|
1168
1130
|
options: zod.z.object({
|
|
1169
1131
|
include: zod.z.object({
|
|
1170
1132
|
source: zod.z.string(),
|
|
@@ -1176,11 +1138,8 @@ var SerializedRouteSchema = zod.z.object({
|
|
|
1176
1138
|
}).optional(),
|
|
1177
1139
|
customValidate: zod.z["boolean"]().optional()
|
|
1178
1140
|
}).optional(),
|
|
1179
|
-
opt: zod.z["boolean"]()
|
|
1180
|
-
|
|
1181
|
-
readonly: zod.z["boolean"]().optional(),
|
|
1182
|
-
hidden: zod.z["boolean"]().optional()
|
|
1183
|
-
});
|
|
1141
|
+
opt: zod.z["boolean"]()
|
|
1142
|
+
}));
|
|
1184
1143
|
|
|
1185
1144
|
// A settings module, and each section inside one, serialize as this - the
|
|
1186
1145
|
// shape is recursive because `items` holds sections which are themselves
|
|
@@ -1188,17 +1147,11 @@ var SerializedRouteSchema = zod.z.object({
|
|
|
1188
1147
|
// (see core/src/schema/settings.ts), but they are accepted here because they
|
|
1189
1148
|
// are part of the declared type.
|
|
1190
1149
|
var SerializedSettingsSchema = zod.z.lazy(function () {
|
|
1191
|
-
return zod.z.object({
|
|
1150
|
+
return zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
|
|
1192
1151
|
type: zod.z.literal("settings"),
|
|
1193
|
-
render: FieldRender,
|
|
1194
|
-
preview: zod.z.literal(true).optional(),
|
|
1195
1152
|
items: zod.z.record(zod.z.string(), SerializedSchema),
|
|
1196
|
-
opt: zod.z["boolean"]()
|
|
1197
|
-
|
|
1198
|
-
readonly: zod.z["boolean"]().optional(),
|
|
1199
|
-
hidden: zod.z["boolean"]().optional(),
|
|
1200
|
-
description: zod.z.string().optional()
|
|
1201
|
-
});
|
|
1153
|
+
opt: zod.z["boolean"]()
|
|
1154
|
+
}));
|
|
1202
1155
|
});
|
|
1203
1156
|
var SerializedSchema = zod.z.union([SerializedStringSchema, SerializedLiteralSchema, SerializedBooleanSchema, SerializedNumberSchema, SerializedObjectSchema, SerializedArraySchema, SerializedUnionSchema, SerializedRichTextSchema, SerializedRecordSchema, SerializedKeyOfSchema, SerializedRouteSchema, SerializedFileSchema, SerializedDateSchema, SerializedDateTimeSchema, SerializedColorSchema, SerializedCodeSchema, SerializedSettingsSchema, SerializedImageSchema]);
|
|
1204
1157
|
|
|
@@ -2510,6 +2463,66 @@ var Api = {
|
|
|
2510
2463
|
* actually mounts. A file at a fixed commit cannot change, so the response is
|
|
2511
2464
|
* immutable and the browser's own cache handles flipping between commits.
|
|
2512
2465
|
*/
|
|
2466
|
+
/**
|
|
2467
|
+
* One `.jsonValues()` entry's content, as it was at a commit.
|
|
2468
|
+
*
|
|
2469
|
+
* The history pane's counterpart to `/json`. A `.jsonValues()` record's
|
|
2470
|
+
* source is only `{_type:"json"}` markers - the content is per entry, fetched
|
|
2471
|
+
* on demand - so without this the commit pane rendered every entry as an
|
|
2472
|
+
* empty field, which is a claim that the author left it blank.
|
|
2473
|
+
*
|
|
2474
|
+
* One entry per request, deliberately: the store fetches an entry when
|
|
2475
|
+
* something reads inside it, so a batch would mean guessing which entries the
|
|
2476
|
+
* pane is about to show. Authenticated for the same reasons as
|
|
2477
|
+
* `/history/files` below.
|
|
2478
|
+
*/
|
|
2479
|
+
"/history/json": {
|
|
2480
|
+
GET: {
|
|
2481
|
+
req: {
|
|
2482
|
+
query: {
|
|
2483
|
+
commit_sha: onlyOneStringQueryParam,
|
|
2484
|
+
path: onlyOneStringQueryParam,
|
|
2485
|
+
key: onlyOneStringQueryParam
|
|
2486
|
+
},
|
|
2487
|
+
cookies: {
|
|
2488
|
+
val_session: zod.z.string().optional()
|
|
2489
|
+
}
|
|
2490
|
+
},
|
|
2491
|
+
res: zod.z.union([unauthorizedResponse, notFoundResponse, zod.z.object({
|
|
2492
|
+
status: zod.z.literal(400),
|
|
2493
|
+
json: GenericError.and(zod.z.object({
|
|
2494
|
+
kind: zod.z.string().optional()
|
|
2495
|
+
}))
|
|
2496
|
+
}), zod.z.object({
|
|
2497
|
+
status: zod.z.literal(500),
|
|
2498
|
+
json: GenericError.and(zod.z.object({
|
|
2499
|
+
kind: zod.z.string().optional()
|
|
2500
|
+
}))
|
|
2501
|
+
}), zod.z.object({
|
|
2502
|
+
status: zod.z.literal(200),
|
|
2503
|
+
json: zod.z.object({
|
|
2504
|
+
path: ModuleFilePath,
|
|
2505
|
+
key: zod.z.string(),
|
|
2506
|
+
content: zod.z.unknown()
|
|
2507
|
+
})
|
|
2508
|
+
})])
|
|
2509
|
+
}
|
|
2510
|
+
},
|
|
2511
|
+
/**
|
|
2512
|
+
* A binary file as it was at a commit.
|
|
2513
|
+
*
|
|
2514
|
+
* AUTHENTICATED, unlike `/files` below - and the difference is not an
|
|
2515
|
+
* oversight in either direction. See the comment on `/files`: what makes it
|
|
2516
|
+
* safe to leave open is that a `patch_id` is an unguessable UUID, and what
|
|
2517
|
+
* makes leaving it open NECESSARY is that a draft image is fetched by the
|
|
2518
|
+
* app's own backend during Next image optimisation, with no cookies.
|
|
2519
|
+
*
|
|
2520
|
+
* Neither holds here. A commit sha is published - `git log`, the GitHub UI,
|
|
2521
|
+
* every PR - so it is not a secret to stand in for a credential. And nothing
|
|
2522
|
+
* fetches these server-side: they are read by the Studio, in a browser that
|
|
2523
|
+
* has the session cookie, for the history pane and for staging a restore.
|
|
2524
|
+
* So this one asks.
|
|
2525
|
+
*/
|
|
2513
2526
|
"/history/files": {
|
|
2514
2527
|
GET: {
|
|
2515
2528
|
req: {
|
|
@@ -2517,6 +2530,9 @@ var Api = {
|
|
|
2517
2530
|
commit_sha: onlyOneStringQueryParam,
|
|
2518
2531
|
path: onlyOneStringQueryParam,
|
|
2519
2532
|
remote: onlyOneStringQueryParam.optional()
|
|
2533
|
+
},
|
|
2534
|
+
cookies: {
|
|
2535
|
+
val_session: zod.z.string().optional()
|
|
2520
2536
|
}
|
|
2521
2537
|
},
|
|
2522
2538
|
res: zod.z.union([unauthorizedResponse, notFoundResponse, zod.z.object({
|
|
@@ -5329,6 +5345,28 @@ function getRefParts(ref) {
|
|
|
5329
5345
|
* them — an agent and an editor searching the same project should find the same
|
|
5330
5346
|
* things.
|
|
5331
5347
|
*/
|
|
5348
|
+
/**
|
|
5349
|
+
* The parts of FlexSearch's `Index` this module uses.
|
|
5350
|
+
*
|
|
5351
|
+
* Structural, rather than importing flexsearch's own `Index`, because
|
|
5352
|
+
* {@link SearchIndex} is EXPORTED — and a `.d.ts` that names `flexsearch` pulls
|
|
5353
|
+
* that package's `declare module "flexsearch"` into every consumer's TypeScript
|
|
5354
|
+
* program. Ambient module declarations are global to a program, so a consumer
|
|
5355
|
+
* with its own flexsearch at another version then checks its OWN calls against
|
|
5356
|
+
* the copy we dragged in, whichever of the two wins.
|
|
5357
|
+
*
|
|
5358
|
+
* That is not hypothetical: `@valbuild/shared` gained a flexsearch dependency
|
|
5359
|
+
* in 0.123.0 for `search_content`, and valbuild/web — which pins flexsearch
|
|
5360
|
+
* 0.7 and calls `new flexsearch.Document({ language: "en", … })` — stopped
|
|
5361
|
+
* building on 0.123.2, because 0.8's `DocumentOptions` has no `language`. Its
|
|
5362
|
+
* own resolved copy was still 0.7; only the types had been replaced.
|
|
5363
|
+
*
|
|
5364
|
+
* Three methods is all this module calls, and none of their signatures here is
|
|
5365
|
+
* a guess: `add` and `remove` are used in `indexModule`/`removeModule`, and
|
|
5366
|
+
* `search`'s result is only ever `.length`-ed, `.slice`-d and mapped over as
|
|
5367
|
+
* ids. `FlexSearch.Index` is still constructed with the real library in
|
|
5368
|
+
* {@link createSearchIndex} — a value import, which does not reach the `.d.ts`.
|
|
5369
|
+
*/
|
|
5332
5370
|
|
|
5333
5371
|
/** An index with nothing in it. Fill it with {@link indexModule}. */
|
|
5334
5372
|
function createSearchIndex() {
|
|
@@ -5430,9 +5468,9 @@ function removeModule(searchIndex, moduleFilePath) {
|
|
|
5430
5468
|
_step;
|
|
5431
5469
|
try {
|
|
5432
5470
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
5433
|
-
var
|
|
5434
|
-
index.remove(
|
|
5435
|
-
pathToLabel["delete"](
|
|
5471
|
+
var _id = _step.value;
|
|
5472
|
+
index.remove(_id);
|
|
5473
|
+
pathToLabel["delete"](_id);
|
|
5436
5474
|
}
|
|
5437
5475
|
} catch (err) {
|
|
5438
5476
|
_iterator.e(err);
|