@valbuild/shared 0.138.4 → 0.139.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 +36 -0
- package/dist/declarations/src/internal/zod/SerializedSchema.d.ts +0 -3
- package/internal/dist/valbuild-shared-internal.cjs.dev.js +6 -5
- package/internal/dist/valbuild-shared-internal.cjs.prod.js +6 -5
- package/internal/dist/valbuild-shared-internal.esm.js +6 -5
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# @valbuild/shared
|
|
2
2
|
|
|
3
|
+
## 0.139.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#776](https://github.com/valbuild/val/pull/776) [`3eb5031`](https://github.com/valbuild/val/commit/3eb503167ae466ee586303c95efcc14665129481) Thanks [@freekh](https://github.com/freekh)! - **Breaking:** `.render({ as: "inline" })` now goes on the list, not on its items.
|
|
8
|
+
|
|
9
|
+
You now write `s.array(item).render({ as: "inline" })` and `s.record(item).render({ as: "inline" })`. Each item is then edited in its own row instead of in a preview row you click into. The list decides. The item schema stays reusable, and a page builder made of tagged blocks needs nothing on each block:
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
// before
|
|
13
|
+
s.array(
|
|
14
|
+
s.discriminatedUnion(
|
|
15
|
+
"type",
|
|
16
|
+
hero.render({ as: "inline" }),
|
|
17
|
+
text.render({ as: "inline" }),
|
|
18
|
+
),
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
// after
|
|
22
|
+
s.array(s.discriminatedUnion("type", hero, text)).render({ as: "inline" });
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
What changed:
|
|
26
|
+
|
|
27
|
+
- Only `s.array()`, `s.record()` and `s.keyOf()` have `.render(...)` now. On every other schema the method is gone, so the old placement shows up as a type error. Move the render out one level.
|
|
28
|
+
- The render only affects the list's own items. A list nested inside one of those items keeps its default unless it has its own `.render`.
|
|
29
|
+
- `s.router()`, `s.imageset()` and `s.fileset()` throw if you give them a render, because pages and media have their own editors.
|
|
30
|
+
- `s.keyOf(...).render({ as: "inline" })` means the same as before: the selected entry's content is shown below the dropdown.
|
|
31
|
+
|
|
32
|
+
**Watch for one case that still compiles:** an array or record that is itself the item of another list. `s.record(s.array(s.string()).render({ as: "inline" }))` used to show the record's arrays inline. Now it shows each array's strings inline. To keep the old layout, write `s.record(s.array(s.string())).render({ as: "inline" })`.
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- Updated dependencies [[`3eb5031`](https://github.com/valbuild/val/commit/3eb503167ae466ee586303c95efcc14665129481)]:
|
|
37
|
+
- @valbuild/core@0.139.0
|
|
38
|
+
|
|
3
39
|
## 0.138.4
|
|
4
40
|
|
|
5
41
|
### Patch Changes
|
|
@@ -86,9 +86,6 @@ export declare const SerializedSettingsSchema: z.ZodType<SerializedSettingsSchem
|
|
|
86
86
|
*/
|
|
87
87
|
export declare const SerializedValViewSchema: z.ZodObject<{
|
|
88
88
|
type: z.ZodLiteral<"view">;
|
|
89
|
-
render: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
90
|
-
as: z.ZodLiteral<"inline">;
|
|
91
|
-
}, z.core.$strip>>>;
|
|
92
89
|
moduleFilePath: z.ZodType<import("@valbuild/core").ModuleFilePath, unknown, z.core.$ZodTypeInternals<import("@valbuild/core").ModuleFilePath, unknown>>;
|
|
93
90
|
opt: z.ZodLiteral<false>;
|
|
94
91
|
readonly: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -987,7 +987,8 @@ var _excluded = ["directory"];
|
|
|
987
987
|
|
|
988
988
|
// A render is static config, so unlike a `preview` it travels WHOLE — this
|
|
989
989
|
// is the field the editor reads the layout from. See `core/src/render.ts`.
|
|
990
|
-
//
|
|
990
|
+
// Only array, record and keyOf carry one, and `{ as: "inline" }` is all it
|
|
991
|
+
// says. A stale `render` on any other schema is stripped here, harmlessly.
|
|
991
992
|
// NB: these z.objects STRIP unknown keys, so a render variant that is not
|
|
992
993
|
// declared here is silently dropped in transit — add it here when it is added
|
|
993
994
|
// to `render.ts`.
|
|
@@ -1009,7 +1010,6 @@ var FieldRender = InlineRender.optional();
|
|
|
1009
1010
|
* - those differ per schema, so there is nothing to share.
|
|
1010
1011
|
*/
|
|
1011
1012
|
var commonSchemaFields = {
|
|
1012
|
-
render: FieldRender,
|
|
1013
1013
|
preview: zod.z.literal(true).optional(),
|
|
1014
1014
|
// Whether the schema declares a `.validate()`. The function cannot serialize,
|
|
1015
1015
|
// so this flag is what tells the Studio to run the custom validators on the
|
|
@@ -1068,6 +1068,7 @@ var SerializedObjectSchema = zod.z.lazy(function () {
|
|
|
1068
1068
|
});
|
|
1069
1069
|
var SerializedArraySchema = zod.z.lazy(function () {
|
|
1070
1070
|
return zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
|
|
1071
|
+
render: FieldRender,
|
|
1071
1072
|
type: zod.z.literal("array"),
|
|
1072
1073
|
item: SerializedSchema,
|
|
1073
1074
|
opt: zod.z["boolean"]()
|
|
@@ -1160,6 +1161,7 @@ var SerializedRichTextSchema = zod.z.object(getSitemapTree._objectSpread2(getSit
|
|
|
1160
1161
|
}));
|
|
1161
1162
|
var SerializedRecordSchema = zod.z.lazy(function () {
|
|
1162
1163
|
return zod.z.preprocess(readLegacyDirectoryAsDir, zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
|
|
1164
|
+
render: FieldRender,
|
|
1163
1165
|
type: zod.z.literal("record"),
|
|
1164
1166
|
item: SerializedSchema,
|
|
1165
1167
|
opt: zod.z["boolean"](),
|
|
@@ -1176,6 +1178,7 @@ var SerializedRecordSchema = zod.z.lazy(function () {
|
|
|
1176
1178
|
});
|
|
1177
1179
|
var SerializedKeyOfSchema = zod.z.lazy(function () {
|
|
1178
1180
|
return zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
|
|
1181
|
+
render: FieldRender,
|
|
1179
1182
|
type: zod.z.literal("keyOf"),
|
|
1180
1183
|
path: SourcePath,
|
|
1181
1184
|
schema: zod.z.union([zod.z.object({
|
|
@@ -1235,7 +1238,6 @@ var SerializedCodeSchema = zod.z.object(getSitemapTree._objectSpread2(getSitemap
|
|
|
1235
1238
|
}));
|
|
1236
1239
|
var SerializedLocaleSchema = zod.z.object({
|
|
1237
1240
|
type: zod.z.literal("locale"),
|
|
1238
|
-
render: FieldRender,
|
|
1239
1241
|
preview: zod.z.literal(true).optional(),
|
|
1240
1242
|
opt: zod.z["boolean"](),
|
|
1241
1243
|
customValidate: zod.z["boolean"]().optional(),
|
|
@@ -1261,7 +1263,7 @@ var SerializedRouteSchema = zod.z.object(getSitemapTree._objectSpread2(getSitema
|
|
|
1261
1263
|
|
|
1262
1264
|
// A settings module, and each section inside one, serialize as this - the
|
|
1263
1265
|
// shape is recursive because `items` holds sections which are themselves
|
|
1264
|
-
// settings schemas. `s.settings()` never writes
|
|
1266
|
+
// settings schemas. `s.settings()` never writes preview/customValidate
|
|
1265
1267
|
// (see core/src/schema/settings.ts), but they are accepted here because they
|
|
1266
1268
|
// are part of the declared type.
|
|
1267
1269
|
var SerializedSettingsSchema = zod.z.lazy(function () {
|
|
@@ -1287,7 +1289,6 @@ var SerializedSettingsSchema = zod.z.lazy(function () {
|
|
|
1287
1289
|
*/
|
|
1288
1290
|
var SerializedValViewSchema = zod.z.object({
|
|
1289
1291
|
type: zod.z.literal("view"),
|
|
1290
|
-
render: FieldRender.optional(),
|
|
1291
1292
|
moduleFilePath: ModuleFilePath$1,
|
|
1292
1293
|
opt: zod.z.literal(false),
|
|
1293
1294
|
readonly: zod.z["boolean"]().optional(),
|
|
@@ -987,7 +987,8 @@ var _excluded = ["directory"];
|
|
|
987
987
|
|
|
988
988
|
// A render is static config, so unlike a `preview` it travels WHOLE — this
|
|
989
989
|
// is the field the editor reads the layout from. See `core/src/render.ts`.
|
|
990
|
-
//
|
|
990
|
+
// Only array, record and keyOf carry one, and `{ as: "inline" }` is all it
|
|
991
|
+
// says. A stale `render` on any other schema is stripped here, harmlessly.
|
|
991
992
|
// NB: these z.objects STRIP unknown keys, so a render variant that is not
|
|
992
993
|
// declared here is silently dropped in transit — add it here when it is added
|
|
993
994
|
// to `render.ts`.
|
|
@@ -1009,7 +1010,6 @@ var FieldRender = InlineRender.optional();
|
|
|
1009
1010
|
* - those differ per schema, so there is nothing to share.
|
|
1010
1011
|
*/
|
|
1011
1012
|
var commonSchemaFields = {
|
|
1012
|
-
render: FieldRender,
|
|
1013
1013
|
preview: zod.z.literal(true).optional(),
|
|
1014
1014
|
// Whether the schema declares a `.validate()`. The function cannot serialize,
|
|
1015
1015
|
// so this flag is what tells the Studio to run the custom validators on the
|
|
@@ -1068,6 +1068,7 @@ var SerializedObjectSchema = zod.z.lazy(function () {
|
|
|
1068
1068
|
});
|
|
1069
1069
|
var SerializedArraySchema = zod.z.lazy(function () {
|
|
1070
1070
|
return zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
|
|
1071
|
+
render: FieldRender,
|
|
1071
1072
|
type: zod.z.literal("array"),
|
|
1072
1073
|
item: SerializedSchema,
|
|
1073
1074
|
opt: zod.z["boolean"]()
|
|
@@ -1160,6 +1161,7 @@ var SerializedRichTextSchema = zod.z.object(getSitemapTree._objectSpread2(getSit
|
|
|
1160
1161
|
}));
|
|
1161
1162
|
var SerializedRecordSchema = zod.z.lazy(function () {
|
|
1162
1163
|
return zod.z.preprocess(readLegacyDirectoryAsDir, zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
|
|
1164
|
+
render: FieldRender,
|
|
1163
1165
|
type: zod.z.literal("record"),
|
|
1164
1166
|
item: SerializedSchema,
|
|
1165
1167
|
opt: zod.z["boolean"](),
|
|
@@ -1176,6 +1178,7 @@ var SerializedRecordSchema = zod.z.lazy(function () {
|
|
|
1176
1178
|
});
|
|
1177
1179
|
var SerializedKeyOfSchema = zod.z.lazy(function () {
|
|
1178
1180
|
return zod.z.object(getSitemapTree._objectSpread2(getSitemapTree._objectSpread2({}, commonSchemaFields), {}, {
|
|
1181
|
+
render: FieldRender,
|
|
1179
1182
|
type: zod.z.literal("keyOf"),
|
|
1180
1183
|
path: SourcePath,
|
|
1181
1184
|
schema: zod.z.union([zod.z.object({
|
|
@@ -1235,7 +1238,6 @@ var SerializedCodeSchema = zod.z.object(getSitemapTree._objectSpread2(getSitemap
|
|
|
1235
1238
|
}));
|
|
1236
1239
|
var SerializedLocaleSchema = zod.z.object({
|
|
1237
1240
|
type: zod.z.literal("locale"),
|
|
1238
|
-
render: FieldRender,
|
|
1239
1241
|
preview: zod.z.literal(true).optional(),
|
|
1240
1242
|
opt: zod.z["boolean"](),
|
|
1241
1243
|
customValidate: zod.z["boolean"]().optional(),
|
|
@@ -1261,7 +1263,7 @@ var SerializedRouteSchema = zod.z.object(getSitemapTree._objectSpread2(getSitema
|
|
|
1261
1263
|
|
|
1262
1264
|
// A settings module, and each section inside one, serialize as this - the
|
|
1263
1265
|
// shape is recursive because `items` holds sections which are themselves
|
|
1264
|
-
// settings schemas. `s.settings()` never writes
|
|
1266
|
+
// settings schemas. `s.settings()` never writes preview/customValidate
|
|
1265
1267
|
// (see core/src/schema/settings.ts), but they are accepted here because they
|
|
1266
1268
|
// are part of the declared type.
|
|
1267
1269
|
var SerializedSettingsSchema = zod.z.lazy(function () {
|
|
@@ -1287,7 +1289,6 @@ var SerializedSettingsSchema = zod.z.lazy(function () {
|
|
|
1287
1289
|
*/
|
|
1288
1290
|
var SerializedValViewSchema = zod.z.object({
|
|
1289
1291
|
type: zod.z.literal("view"),
|
|
1290
|
-
render: FieldRender.optional(),
|
|
1291
1292
|
moduleFilePath: ModuleFilePath$1,
|
|
1292
1293
|
opt: zod.z.literal(false),
|
|
1293
1294
|
readonly: zod.z["boolean"]().optional(),
|
|
@@ -980,7 +980,8 @@ var _excluded = ["directory"];
|
|
|
980
980
|
|
|
981
981
|
// A render is static config, so unlike a `preview` it travels WHOLE — this
|
|
982
982
|
// is the field the editor reads the layout from. See `core/src/render.ts`.
|
|
983
|
-
//
|
|
983
|
+
// Only array, record and keyOf carry one, and `{ as: "inline" }` is all it
|
|
984
|
+
// says. A stale `render` on any other schema is stripped here, harmlessly.
|
|
984
985
|
// NB: these z.objects STRIP unknown keys, so a render variant that is not
|
|
985
986
|
// declared here is silently dropped in transit — add it here when it is added
|
|
986
987
|
// to `render.ts`.
|
|
@@ -1002,7 +1003,6 @@ var FieldRender = InlineRender.optional();
|
|
|
1002
1003
|
* - those differ per schema, so there is nothing to share.
|
|
1003
1004
|
*/
|
|
1004
1005
|
var commonSchemaFields = {
|
|
1005
|
-
render: FieldRender,
|
|
1006
1006
|
preview: z.literal(true).optional(),
|
|
1007
1007
|
// Whether the schema declares a `.validate()`. The function cannot serialize,
|
|
1008
1008
|
// so this flag is what tells the Studio to run the custom validators on the
|
|
@@ -1061,6 +1061,7 @@ var SerializedObjectSchema = z.lazy(function () {
|
|
|
1061
1061
|
});
|
|
1062
1062
|
var SerializedArraySchema = z.lazy(function () {
|
|
1063
1063
|
return z.object(_objectSpread2(_objectSpread2({}, commonSchemaFields), {}, {
|
|
1064
|
+
render: FieldRender,
|
|
1064
1065
|
type: z.literal("array"),
|
|
1065
1066
|
item: SerializedSchema,
|
|
1066
1067
|
opt: z["boolean"]()
|
|
@@ -1153,6 +1154,7 @@ var SerializedRichTextSchema = z.object(_objectSpread2(_objectSpread2({}, common
|
|
|
1153
1154
|
}));
|
|
1154
1155
|
var SerializedRecordSchema = z.lazy(function () {
|
|
1155
1156
|
return z.preprocess(readLegacyDirectoryAsDir, z.object(_objectSpread2(_objectSpread2({}, commonSchemaFields), {}, {
|
|
1157
|
+
render: FieldRender,
|
|
1156
1158
|
type: z.literal("record"),
|
|
1157
1159
|
item: SerializedSchema,
|
|
1158
1160
|
opt: z["boolean"](),
|
|
@@ -1169,6 +1171,7 @@ var SerializedRecordSchema = z.lazy(function () {
|
|
|
1169
1171
|
});
|
|
1170
1172
|
var SerializedKeyOfSchema = z.lazy(function () {
|
|
1171
1173
|
return z.object(_objectSpread2(_objectSpread2({}, commonSchemaFields), {}, {
|
|
1174
|
+
render: FieldRender,
|
|
1172
1175
|
type: z.literal("keyOf"),
|
|
1173
1176
|
path: SourcePath,
|
|
1174
1177
|
schema: z.union([z.object({
|
|
@@ -1228,7 +1231,6 @@ var SerializedCodeSchema = z.object(_objectSpread2(_objectSpread2({}, commonSche
|
|
|
1228
1231
|
}));
|
|
1229
1232
|
var SerializedLocaleSchema = z.object({
|
|
1230
1233
|
type: z.literal("locale"),
|
|
1231
|
-
render: FieldRender,
|
|
1232
1234
|
preview: z.literal(true).optional(),
|
|
1233
1235
|
opt: z["boolean"](),
|
|
1234
1236
|
customValidate: z["boolean"]().optional(),
|
|
@@ -1254,7 +1256,7 @@ var SerializedRouteSchema = z.object(_objectSpread2(_objectSpread2({}, commonSch
|
|
|
1254
1256
|
|
|
1255
1257
|
// A settings module, and each section inside one, serialize as this - the
|
|
1256
1258
|
// shape is recursive because `items` holds sections which are themselves
|
|
1257
|
-
// settings schemas. `s.settings()` never writes
|
|
1259
|
+
// settings schemas. `s.settings()` never writes preview/customValidate
|
|
1258
1260
|
// (see core/src/schema/settings.ts), but they are accepted here because they
|
|
1259
1261
|
// are part of the declared type.
|
|
1260
1262
|
var SerializedSettingsSchema = z.lazy(function () {
|
|
@@ -1280,7 +1282,6 @@ var SerializedSettingsSchema = z.lazy(function () {
|
|
|
1280
1282
|
*/
|
|
1281
1283
|
var SerializedValViewSchema = z.object({
|
|
1282
1284
|
type: z.literal("view"),
|
|
1283
|
-
render: FieldRender.optional(),
|
|
1284
1285
|
moduleFilePath: ModuleFilePath$1,
|
|
1285
1286
|
opt: z.literal(false),
|
|
1286
1287
|
readonly: z["boolean"]().optional(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@valbuild/shared",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.139.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Val shared types and utilities",
|
|
6
6
|
"repository": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"flexsearch": "^0.8.212",
|
|
38
38
|
"zod": "^4.4.3",
|
|
39
39
|
"zod-validation-error": "^5.0.0",
|
|
40
|
-
"@valbuild/core": "0.
|
|
40
|
+
"@valbuild/core": "0.139.0"
|
|
41
41
|
},
|
|
42
42
|
"files": [
|
|
43
43
|
"CHANGELOG.md",
|