@valbuild/core 0.138.0 → 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 +44 -0
- package/dist/declarations/src/index.d.ts +2 -0
- package/dist/declarations/src/render.d.ts +36 -33
- package/dist/declarations/src/schema/array.d.ts +13 -8
- package/dist/declarations/src/schema/boolean.d.ts +1 -17
- package/dist/declarations/src/schema/code.d.ts +1 -21
- package/dist/declarations/src/schema/color.d.ts +1 -19
- package/dist/declarations/src/schema/date.d.ts +1 -17
- package/dist/declarations/src/schema/datetime.d.ts +1 -19
- package/dist/declarations/src/schema/discriminatedUnion.d.ts +1 -23
- package/dist/declarations/src/schema/enum.d.ts +1 -19
- package/dist/declarations/src/schema/file.d.ts +1 -19
- package/dist/declarations/src/schema/image.d.ts +1 -24
- package/dist/declarations/src/schema/keyOf.d.ts +14 -6
- package/dist/declarations/src/schema/literal.d.ts +1 -17
- package/dist/declarations/src/schema/locale.d.ts +1 -14
- package/dist/declarations/src/schema/number.d.ts +1 -17
- package/dist/declarations/src/schema/object.d.ts +1 -23
- package/dist/declarations/src/schema/record.d.ts +12 -6
- package/dist/declarations/src/schema/richtext.d.ts +1 -19
- package/dist/declarations/src/schema/route.d.ts +1 -17
- package/dist/declarations/src/schema/settings.d.ts +8 -12
- package/dist/declarations/src/schema/string.d.ts +1 -26
- package/dist/declarations/src/schema/view.d.ts +1 -20
- package/dist/declarations/src/source/filename.d.ts +37 -0
- package/dist/{index-3296fc4f.cjs.prod.js → index-8920ba3f.cjs.prod.js} +324 -625
- package/dist/{index-a25822a3.esm.js → index-d949d13b.esm.js} +324 -625
- package/dist/{index-d3c51a0d.cjs.dev.js → index-e13b725c.cjs.dev.js} +324 -625
- package/dist/valbuild-core.cjs.dev.js +1 -1
- package/dist/valbuild-core.cjs.prod.js +1 -1
- package/dist/valbuild-core.esm.js +1 -1
- package/package.json +1 -1
- package/patch/dist/valbuild-core-patch.cjs.dev.js +1 -1
- package/patch/dist/valbuild-core-patch.cjs.prod.js +1 -1
- package/patch/dist/valbuild-core-patch.esm.js +2 -2
|
@@ -4,7 +4,6 @@ import { ModulePath, SourcePath } from "../val/index.js";
|
|
|
4
4
|
import { ValidationError, ValidationErrors } from "./validation/ValidationError.js";
|
|
5
5
|
import { ValModule } from "../index.js";
|
|
6
6
|
import { ItemPreviewInput, PreviewItem } from "../preview.js";
|
|
7
|
-
import { FieldRender } from "../render.js";
|
|
8
7
|
import { AltSource, ImagesetEntryMetadata } from "./imageset.js";
|
|
9
8
|
/**
|
|
10
9
|
* How an uploaded image is re-encoded in the browser, before it is uploaded.
|
|
@@ -47,8 +46,6 @@ export type ImageOptions = {
|
|
|
47
46
|
};
|
|
48
47
|
export type SerializedImageSchema = {
|
|
49
48
|
type: "image";
|
|
50
|
-
/** Static layout config, carried whole in the serialized schema — see `render.ts`. */
|
|
51
|
-
render?: FieldRender;
|
|
52
49
|
/** Set when this schema declares a `preview`. The closure itself cannot serialize. */
|
|
53
50
|
preview?: true;
|
|
54
51
|
options?: ImageOptions;
|
|
@@ -79,9 +76,8 @@ export declare class ImageSchema<Src extends ImageSource | null> extends Schema<
|
|
|
79
76
|
private readonly isReadonly;
|
|
80
77
|
private readonly isHidden;
|
|
81
78
|
private readonly description?;
|
|
82
|
-
private readonly renderInput;
|
|
83
79
|
private readonly previewInput;
|
|
84
|
-
constructor(options?: ImageOptions | undefined, opt?: boolean, isRemote?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], moduleMetadata?: Record<ModulePath, Record<string, ImagesetEntryMetadata<AltSource>>>, isReadonly?: boolean, isHidden?: boolean, description?: string | undefined,
|
|
80
|
+
constructor(options?: ImageOptions | undefined, opt?: boolean, isRemote?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], moduleMetadata?: Record<ModulePath, Record<string, ImagesetEntryMetadata<AltSource>>>, isReadonly?: boolean, isHidden?: boolean, description?: string | undefined, previewInput?: ItemPreviewInput<Src> | null);
|
|
85
81
|
/**
|
|
86
82
|
* Describe this field.
|
|
87
83
|
*
|
|
@@ -177,25 +173,6 @@ export declare class ImageSchema<Src extends ImageSource | null> extends Schema<
|
|
|
177
173
|
readonly(isReadonly?: boolean): ImageSchema<Src>;
|
|
178
174
|
hidden(isHidden?: boolean): ImageSchema<Src>;
|
|
179
175
|
protected executeCustomValidateAt(path: SourcePath, src: Src): ValidationError[];
|
|
180
|
-
/**
|
|
181
|
-
* How this field is laid out in the editor when it is the item of an array
|
|
182
|
-
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
183
|
-
* instead of a preview row that navigates to it.
|
|
184
|
-
*
|
|
185
|
-
* Static configuration, not a callback — see `render.ts`.
|
|
186
|
-
*
|
|
187
|
-
* @example
|
|
188
|
-
* const schema = s.array(s.image().render({ as: "inline" }));
|
|
189
|
-
* export default c.define("/example.val.ts", schema, [
|
|
190
|
-
* {
|
|
191
|
-
* path: "/public/val/example.png",
|
|
192
|
-
* width: 100,
|
|
193
|
-
* height: 100,
|
|
194
|
-
* mimeType: "image/png",
|
|
195
|
-
* },
|
|
196
|
-
* ]);
|
|
197
|
-
*/
|
|
198
|
-
render(input: FieldRender): ImageSchema<Src>;
|
|
199
176
|
/**
|
|
200
177
|
* How this VALUE is shown where a preview of it is needed — a row in a
|
|
201
178
|
* sortable list, a reference dropdown, a search hit. Never how the field
|
|
@@ -9,7 +9,10 @@ import { ItemPreviewInput, PreviewItem } from "../preview.js";
|
|
|
9
9
|
import { FieldRender } from "../render.js";
|
|
10
10
|
export type SerializedKeyOfSchema = {
|
|
11
11
|
type: "keyOf";
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* `{ as: "inline" }` shows the selected entry's content below the selector.
|
|
14
|
+
* About this field alone; no list reads it. See `render.ts`.
|
|
15
|
+
*/
|
|
13
16
|
render?: FieldRender;
|
|
14
17
|
/** Set when this schema declares a `preview`. The closure itself cannot serialize. */
|
|
15
18
|
preview?: true;
|
|
@@ -92,16 +95,21 @@ export declare class KeyOfSchema<Sel extends GenericSelector<SourceObject>, Src
|
|
|
92
95
|
hidden(isHidden?: boolean): KeyOfSchema<Sel, Src>;
|
|
93
96
|
protected executeCustomValidateAt(path: SourcePath, src: Src): ValidationError[];
|
|
94
97
|
/**
|
|
95
|
-
* How this
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
+
* How this reference is laid out in the editor: `{ as: "inline" }` shows the
|
|
99
|
+
* selected entry's content below the selector, so it can be read (and
|
|
100
|
+
* reached) without leaving the field.
|
|
101
|
+
*
|
|
102
|
+
* This is about the keyOf field alone. Whether a LIST of references draws
|
|
103
|
+
* its rows inline is the list's own `.render(...)` — see `render.ts`.
|
|
98
104
|
*
|
|
99
105
|
* Static configuration, not a callback — see `render.ts`.
|
|
100
106
|
*
|
|
101
107
|
* @example
|
|
102
108
|
* import authorsVal from "./authors.val"; // a record module
|
|
103
|
-
* const schema = s.
|
|
104
|
-
*
|
|
109
|
+
* const schema = s.object({
|
|
110
|
+
* author: s.keyOf(authorsVal).render({ as: "inline" }),
|
|
111
|
+
* });
|
|
112
|
+
* export default c.define("/example.val.ts", schema, { author: "ada" });
|
|
105
113
|
*/
|
|
106
114
|
render(input: FieldRender): KeyOfSchema<Sel, Src>;
|
|
107
115
|
/**
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { CustomValidateFunction, Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
|
|
2
2
|
import { ItemPreviewInput, PreviewItem } from "../preview.js";
|
|
3
|
-
import { FieldRender } from "../render.js";
|
|
4
3
|
import { SourcePath } from "../val/index.js";
|
|
5
4
|
import { ValidationError, ValidationErrors } from "./validation/ValidationError.js";
|
|
6
5
|
export type SerializedLiteralSchema = {
|
|
7
6
|
type: "literal";
|
|
8
|
-
/** Static layout config, carried whole in the serialized schema — see `render.ts`. */
|
|
9
|
-
render?: FieldRender;
|
|
10
7
|
/** Set when this schema declares a `preview`. The closure itself cannot serialize. */
|
|
11
8
|
preview?: true;
|
|
12
9
|
value: string;
|
|
@@ -23,11 +20,10 @@ export declare class LiteralSchema<Src extends string | null> extends Schema<Src
|
|
|
23
20
|
private readonly isReadonly;
|
|
24
21
|
private readonly isHidden;
|
|
25
22
|
private readonly description?;
|
|
26
|
-
private readonly renderInput;
|
|
27
23
|
private readonly previewInput;
|
|
28
24
|
/** Type-only marker: as a record key, this declares the key set. See `LocaleSchema`. */
|
|
29
25
|
readonly __declaresRecordKeys: true;
|
|
30
|
-
constructor(value: string, opt?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined,
|
|
26
|
+
constructor(value: string, opt?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined, previewInput?: ItemPreviewInput<Src> | null);
|
|
31
27
|
/**
|
|
32
28
|
* Describe this field.
|
|
33
29
|
*
|
|
@@ -75,18 +71,6 @@ export declare class LiteralSchema<Src extends string | null> extends Schema<Src
|
|
|
75
71
|
readonly(isReadonly?: boolean): LiteralSchema<Src>;
|
|
76
72
|
hidden(isHidden?: boolean): LiteralSchema<Src>;
|
|
77
73
|
protected executeCustomValidateAt(path: SourcePath, src: Src): ValidationError[];
|
|
78
|
-
/**
|
|
79
|
-
* How this field is laid out in the editor when it is the item of an array
|
|
80
|
-
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
81
|
-
* instead of a preview row that navigates to it.
|
|
82
|
-
*
|
|
83
|
-
* Static configuration, not a callback — see `render.ts`.
|
|
84
|
-
*
|
|
85
|
-
* @example
|
|
86
|
-
* const schema = s.array(s.literal("hero").render({ as: "inline" }));
|
|
87
|
-
* export default c.define("/example.val.ts", schema, ["hero"]);
|
|
88
|
-
*/
|
|
89
|
-
render(input: FieldRender): LiteralSchema<Src>;
|
|
90
74
|
/**
|
|
91
75
|
* How this VALUE is shown where a preview of it is needed — a row in a
|
|
92
76
|
* sortable list, a reference dropdown, a search hit. Never how the field
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
|
|
2
2
|
import { ItemPreviewInput, PreviewItem } from "../preview.js";
|
|
3
|
-
import { FieldRender } from "../render.js";
|
|
4
3
|
import { SourcePath } from "../val/index.js";
|
|
5
4
|
import { ValidationError, ValidationErrors } from "./validation/ValidationError.js";
|
|
6
5
|
export type SerializedLocaleSchema = {
|
|
7
6
|
type: "locale";
|
|
8
|
-
/** Static layout config, carried whole in the serialized schema — see `render.ts`. */
|
|
9
|
-
render?: FieldRender;
|
|
10
7
|
/** Set when this schema declares a `preview`. The closure itself cannot serialize. */
|
|
11
8
|
preview?: true;
|
|
12
9
|
opt: boolean;
|
|
@@ -35,7 +32,6 @@ export declare class LocaleSchema<Src extends string | null> extends Schema<Src>
|
|
|
35
32
|
private readonly isReadonly;
|
|
36
33
|
private readonly isHidden;
|
|
37
34
|
private readonly description?;
|
|
38
|
-
private readonly renderInput;
|
|
39
35
|
private readonly previewInput;
|
|
40
36
|
/**
|
|
41
37
|
* Type-only marker: as a record key, this schema DECLARES the key set.
|
|
@@ -47,7 +43,7 @@ export declare class LocaleSchema<Src extends string | null> extends Schema<Src>
|
|
|
47
43
|
* `RecordSrcOf`.
|
|
48
44
|
*/
|
|
49
45
|
readonly __declaresRecordKeys: true;
|
|
50
|
-
constructor(opt?: boolean, customValidateFunctions?: ((src: Src) => false | string)[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined,
|
|
46
|
+
constructor(opt?: boolean, customValidateFunctions?: ((src: Src) => false | string)[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined, previewInput?: ItemPreviewInput<Src> | null);
|
|
51
47
|
/**
|
|
52
48
|
* A note to whoever edits this field, shown under it in the Studio.
|
|
53
49
|
*
|
|
@@ -92,15 +88,6 @@ export declare class LocaleSchema<Src extends string | null> extends Schema<Src>
|
|
|
92
88
|
hidden(): LocaleSchema<Src>;
|
|
93
89
|
protected isLocaleField(): boolean;
|
|
94
90
|
protected executeCustomValidateAt(path: SourcePath, src: Src): ValidationError[];
|
|
95
|
-
/**
|
|
96
|
-
* How this field is laid out where it is the item of an array or a record.
|
|
97
|
-
* Static configuration, not a callback — see `render.ts`.
|
|
98
|
-
*
|
|
99
|
-
* @example
|
|
100
|
-
* const schema = s.array(s.locale().render({ as: "inline" }));
|
|
101
|
-
* export default c.define("/example.val.ts", schema, ["nb-NO", "en-US"]);
|
|
102
|
-
*/
|
|
103
|
-
render(input: FieldRender): LocaleSchema<Src>;
|
|
104
91
|
/**
|
|
105
92
|
* How this VALUE is shown where a preview of it is needed. Never how the field
|
|
106
93
|
* itself is edited (that is `render`). See `preview.ts`.
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { CustomValidateFunction, Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
|
|
2
2
|
import { ItemPreviewInput, PreviewItem } from "../preview.js";
|
|
3
|
-
import { FieldRender } from "../render.js";
|
|
4
3
|
import { SourcePath } from "../val/index.js";
|
|
5
4
|
import { ValidationError, ValidationErrors } from "./validation/ValidationError.js";
|
|
6
5
|
type NumberOptions = {
|
|
@@ -9,8 +8,6 @@ type NumberOptions = {
|
|
|
9
8
|
};
|
|
10
9
|
export type SerializedNumberSchema = {
|
|
11
10
|
type: "number";
|
|
12
|
-
/** Static layout config, carried whole in the serialized schema — see `render.ts`. */
|
|
13
|
-
render?: FieldRender;
|
|
14
11
|
/** Set when this schema declares a `preview`. The closure itself cannot serialize. */
|
|
15
12
|
preview?: true;
|
|
16
13
|
options?: NumberOptions;
|
|
@@ -27,9 +24,8 @@ export declare class NumberSchema<Src extends number | null> extends Schema<Src>
|
|
|
27
24
|
private readonly isReadonly;
|
|
28
25
|
private readonly isHidden;
|
|
29
26
|
private readonly description?;
|
|
30
|
-
private readonly renderInput;
|
|
31
27
|
private readonly previewInput;
|
|
32
|
-
constructor(options?: NumberOptions | undefined, opt?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined,
|
|
28
|
+
constructor(options?: NumberOptions | undefined, opt?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined, previewInput?: ItemPreviewInput<Src> | null);
|
|
33
29
|
/**
|
|
34
30
|
* Describe this field.
|
|
35
31
|
*
|
|
@@ -91,18 +87,6 @@ export declare class NumberSchema<Src extends number | null> extends Schema<Src>
|
|
|
91
87
|
*/
|
|
92
88
|
min(min: number): NumberSchema<Src>;
|
|
93
89
|
protected executeCustomValidateAt(path: SourcePath, src: Src): ValidationError[];
|
|
94
|
-
/**
|
|
95
|
-
* How this field is laid out in the editor when it is the item of an array
|
|
96
|
-
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
97
|
-
* instead of a preview row that navigates to it.
|
|
98
|
-
*
|
|
99
|
-
* Static configuration, not a callback — see `render.ts`.
|
|
100
|
-
*
|
|
101
|
-
* @example
|
|
102
|
-
* const schema = s.array(s.number().render({ as: "inline" }));
|
|
103
|
-
* export default c.define("/example.val.ts", schema, [1, 2]);
|
|
104
|
-
*/
|
|
105
|
-
render(input: FieldRender): NumberSchema<Src>;
|
|
106
90
|
/**
|
|
107
91
|
* How this VALUE is shown where a preview of it is needed — a row in a
|
|
108
92
|
* sortable list, a reference dropdown, a search hit. Never how the field
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { CustomValidateFunction, Schema, SchemaAssertResult, SelectorOfSchema, SerializedSchema } from "./index.js";
|
|
2
2
|
import { ItemPreviewInput, PreviewItem, ReifiedPreview, PreviewScope } from "../preview.js";
|
|
3
|
-
import { FieldRender } from "../render.js";
|
|
4
3
|
import { SelectorSource } from "../selector/index.js";
|
|
5
4
|
import { ModuleFilePath, SourcePath } from "../val/index.js";
|
|
6
5
|
import { ValidationError, ValidationErrors } from "./validation/ValidationError.js";
|
|
7
6
|
export type SerializedObjectSchema = {
|
|
8
7
|
type: "object";
|
|
9
|
-
/** Static layout config, carried whole in the serialized schema — see `render.ts`. */
|
|
10
|
-
render?: FieldRender;
|
|
11
8
|
/** Set when this schema declares a `preview`. The closure itself cannot serialize. */
|
|
12
9
|
preview?: true;
|
|
13
10
|
items: Record<string, SerializedSchema>;
|
|
@@ -57,9 +54,8 @@ export declare class ObjectSchema<Props extends ObjectSchemaProps, Src extends O
|
|
|
57
54
|
private readonly isReadonly;
|
|
58
55
|
private readonly isHidden;
|
|
59
56
|
private readonly description?;
|
|
60
|
-
private readonly renderInput;
|
|
61
57
|
private readonly previewInput;
|
|
62
|
-
constructor(items: Props, opt?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined,
|
|
58
|
+
constructor(items: Props, opt?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined, previewInput?: ItemPreviewInput<Src> | null);
|
|
63
59
|
/**
|
|
64
60
|
* Describe this field.
|
|
65
61
|
*
|
|
@@ -123,24 +119,6 @@ export declare class ObjectSchema<Props extends ObjectSchemaProps, Src extends O
|
|
|
123
119
|
schema: Schema<SelectorSource>;
|
|
124
120
|
}[];
|
|
125
121
|
protected executeCustomValidateAt(path: SourcePath, src: Src): ValidationError[];
|
|
126
|
-
/**
|
|
127
|
-
* How this field is laid out in the editor when it is the item of an array
|
|
128
|
-
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
129
|
-
* instead of a preview row that navigates to it.
|
|
130
|
-
*
|
|
131
|
-
* Static configuration, not a callback — see `render.ts`.
|
|
132
|
-
*
|
|
133
|
-
* @example
|
|
134
|
-
* // A page builder: each row edits the object in place, instead of
|
|
135
|
-
* // navigating to it.
|
|
136
|
-
* const block = s
|
|
137
|
-
* .object({ heading: s.string(), body: s.string() })
|
|
138
|
-
* .render({ as: "inline" });
|
|
139
|
-
* export default c.define("/example.val.ts", s.array(block), [
|
|
140
|
-
* { heading: "Hello", body: "World" },
|
|
141
|
-
* ]);
|
|
142
|
-
*/
|
|
143
|
-
render(input: FieldRender): ObjectSchema<Props, Src>;
|
|
144
122
|
/**
|
|
145
123
|
* How this VALUE is shown where a preview of it is needed — a row in a
|
|
146
124
|
* sortable list, a reference dropdown, a search hit. Never how the field
|
|
@@ -28,7 +28,10 @@ export type SerializedRecordSchema = {
|
|
|
28
28
|
* schema. See `SerializedArraySchema`.
|
|
29
29
|
*/
|
|
30
30
|
preview?: true;
|
|
31
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* How this record lays out its ENTRIES: `{ as: "inline" }` edits each one
|
|
33
|
+
* in place. Static config, carried whole — see `render.ts`.
|
|
34
|
+
*/
|
|
32
35
|
render?: FieldRender;
|
|
33
36
|
router?: string;
|
|
34
37
|
/**
|
|
@@ -375,15 +378,18 @@ RO extends boolean = false> extends Schema<Src> {
|
|
|
375
378
|
*/
|
|
376
379
|
preview(select: ItemPreviewInput<Src>): RecordSchema<T, K, Src>;
|
|
377
380
|
/**
|
|
378
|
-
* How this
|
|
379
|
-
*
|
|
380
|
-
*
|
|
381
|
+
* How this record lays out its ENTRIES in the editor: `{ as: "inline" }`
|
|
382
|
+
* draws each entry's own editor in place, labelled by its key, instead of a
|
|
383
|
+
* preview row that navigates to it. It reaches the direct entries only.
|
|
384
|
+
*
|
|
385
|
+
* Not for `s.router(...)`, `s.imageset(...)` or `s.fileset(...)`: pages and
|
|
386
|
+
* media have UIs of their own, so this throws on them.
|
|
381
387
|
*
|
|
382
388
|
* Static configuration, not a callback — see `render.ts`.
|
|
383
389
|
*
|
|
384
390
|
* @example
|
|
385
|
-
* const schema = s.
|
|
386
|
-
* export default c.define("/example.val.ts", schema,
|
|
391
|
+
* const schema = s.record(s.string()).render({ as: "inline" });
|
|
392
|
+
* export default c.define("/example.val.ts", schema, { en: "Read more" });
|
|
387
393
|
*/
|
|
388
394
|
render(input: FieldRender): RecordSchema<T, K, Src>;
|
|
389
395
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { CustomValidateFunction, Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
|
|
2
2
|
import { ItemPreviewInput, PreviewItem } from "../preview.js";
|
|
3
|
-
import { FieldRender } from "../render.js";
|
|
4
3
|
import { RichTextSource, RichTextOptions, SerializedRichTextOptions } from "../source/richtext.js";
|
|
5
4
|
import { SourcePath } from "../val/index.js";
|
|
6
5
|
import { ValidationError, ValidationErrors } from "./validation/ValidationError.js";
|
|
@@ -10,8 +9,6 @@ type ValidationOptions = {
|
|
|
10
9
|
};
|
|
11
10
|
export type SerializedRichTextSchema = {
|
|
12
11
|
type: "richtext";
|
|
13
|
-
/** Static layout config, carried whole in the serialized schema — see `render.ts`. */
|
|
14
|
-
render?: FieldRender;
|
|
15
12
|
/** Set when this schema declares a `preview`. The closure itself cannot serialize. */
|
|
16
13
|
preview?: true;
|
|
17
14
|
opt: boolean;
|
|
@@ -28,9 +25,8 @@ export declare class RichTextSchema<O extends RichTextOptions, Src extends RichT
|
|
|
28
25
|
private readonly isReadonly;
|
|
29
26
|
private readonly isHidden;
|
|
30
27
|
private readonly description?;
|
|
31
|
-
private readonly renderInput;
|
|
32
28
|
private readonly previewInput;
|
|
33
|
-
constructor(options: O & ValidationOptions, opt?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined,
|
|
29
|
+
constructor(options: O & ValidationOptions, opt?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined, previewInput?: ItemPreviewInput<Src> | null);
|
|
34
30
|
/**
|
|
35
31
|
* Describe this field.
|
|
36
32
|
*
|
|
@@ -108,20 +104,6 @@ export declare class RichTextSchema<O extends RichTextOptions, Src extends RichT
|
|
|
108
104
|
readonly(isReadonly?: boolean): RichTextSchema<O, Src>;
|
|
109
105
|
hidden(isHidden?: boolean): RichTextSchema<O, Src>;
|
|
110
106
|
protected executeCustomValidateAt(path: SourcePath, src: Src): ValidationError[];
|
|
111
|
-
/**
|
|
112
|
-
* How this field is laid out in the editor when it is the item of an array
|
|
113
|
-
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
114
|
-
* instead of a preview row that navigates to it.
|
|
115
|
-
*
|
|
116
|
-
* Static configuration, not a callback — see `render.ts`.
|
|
117
|
-
*
|
|
118
|
-
* @example
|
|
119
|
-
* const schema = s.array(s.richtext().render({ as: "inline" }));
|
|
120
|
-
* export default c.define("/example.val.ts", schema, [
|
|
121
|
-
* [{ tag: "p", children: ["Hello"] }],
|
|
122
|
-
* ]);
|
|
123
|
-
*/
|
|
124
|
-
render(input: FieldRender): RichTextSchema<O, Src>;
|
|
125
107
|
/**
|
|
126
108
|
* How this VALUE is shown where a preview of it is needed — a row in a
|
|
127
109
|
* sortable list, a reference dropdown, a search hit. Never how the field
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
|
|
2
2
|
import { SourcePath } from "../val/index.js";
|
|
3
3
|
import { ItemPreviewInput, PreviewItem } from "../preview.js";
|
|
4
|
-
import { FieldRender } from "../render.js";
|
|
5
4
|
import { ValidationError, ValidationErrors } from "./validation/ValidationError.js";
|
|
6
5
|
type RouteOptions = {
|
|
7
6
|
include?: RegExp;
|
|
@@ -9,8 +8,6 @@ type RouteOptions = {
|
|
|
9
8
|
};
|
|
10
9
|
export type SerializedRouteSchema = {
|
|
11
10
|
type: "route";
|
|
12
|
-
/** Static layout config, carried whole in the serialized schema — see `render.ts`. */
|
|
13
|
-
render?: FieldRender;
|
|
14
11
|
/** Set when this schema declares a `preview`. The closure itself cannot serialize. */
|
|
15
12
|
preview?: true;
|
|
16
13
|
options?: {
|
|
@@ -37,9 +34,8 @@ export declare class RouteSchema<Src extends string | null> extends Schema<Src>
|
|
|
37
34
|
private readonly isReadonly;
|
|
38
35
|
private readonly isHidden;
|
|
39
36
|
private readonly description?;
|
|
40
|
-
private readonly renderInput;
|
|
41
37
|
private readonly previewInput;
|
|
42
|
-
constructor(options?: RouteOptions | undefined, opt?: boolean, customValidateFunctions?: ((src: Src) => false | string)[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined,
|
|
38
|
+
constructor(options?: RouteOptions | undefined, opt?: boolean, customValidateFunctions?: ((src: Src) => false | string)[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined, previewInput?: ItemPreviewInput<Src> | null);
|
|
43
39
|
/**
|
|
44
40
|
* Describe this field.
|
|
45
41
|
*
|
|
@@ -111,18 +107,6 @@ export declare class RouteSchema<Src extends string | null> extends Schema<Src>
|
|
|
111
107
|
readonly(isReadonly?: boolean): RouteSchema<Src>;
|
|
112
108
|
hidden(isHidden?: boolean): RouteSchema<Src>;
|
|
113
109
|
protected executeCustomValidateAt(path: SourcePath, src: Src): ValidationError[];
|
|
114
|
-
/**
|
|
115
|
-
* How this field is laid out in the editor when it is the item of an array
|
|
116
|
-
* or record: `{ as: "inline" }` renders the field itself inside each row,
|
|
117
|
-
* instead of a preview row that navigates to it.
|
|
118
|
-
*
|
|
119
|
-
* Static configuration, not a callback — see `render.ts`.
|
|
120
|
-
*
|
|
121
|
-
* @example
|
|
122
|
-
* const schema = s.array(s.route().render({ as: "inline" }));
|
|
123
|
-
* export default c.define("/example.val.ts", schema, ["/a-page-slug"]);
|
|
124
|
-
*/
|
|
125
|
-
render(input: FieldRender): RouteSchema<Src>;
|
|
126
110
|
/**
|
|
127
111
|
* How this VALUE is shown where a preview of it is needed — a row in a
|
|
128
112
|
* sortable list, a reference dropdown, a search hit. Never how the field
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
|
|
2
2
|
import { PreviewScope, ReifiedPreview } from "../preview.js";
|
|
3
|
-
import { FieldRender } from "../render.js";
|
|
4
3
|
import { SelectorSource } from "../selector/index.js";
|
|
5
4
|
import { SettingsSource } from "../source/settings.js";
|
|
6
5
|
import { ModuleFilePath, SourcePath } from "../val/index.js";
|
|
@@ -20,19 +19,16 @@ export type SerializedSettingsSchema = {
|
|
|
20
19
|
/**
|
|
21
20
|
* Present in the shape, never set by `s.settings()`.
|
|
22
21
|
*
|
|
23
|
-
* `
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
22
|
+
* `preview` says how a value is drawn where it is an ITEM of an array or a
|
|
23
|
+
* record, and `customValidate` marks a user's `validate` closure. A settings
|
|
24
|
+
* module is not an item, and `s.settings()` takes no arguments to declare
|
|
25
|
+
* either with — so nothing writes them.
|
|
27
26
|
*
|
|
28
|
-
* They are declared anyway, and with their real types rather than `never`,
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* assignable to `Json` — and serialized schemas travel to the Studio and to
|
|
33
|
-
* the MCP tools as JSON.
|
|
27
|
+
* They are declared anyway, and with their real types rather than `never`,
|
|
28
|
+
* because a `?: never` member is typed `undefined`, which makes the whole
|
|
29
|
+
* `SerializedSchema` union stop being assignable to `Json` — and serialized
|
|
30
|
+
* schemas travel to the Studio and to the MCP tools as JSON.
|
|
34
31
|
*/
|
|
35
|
-
render?: FieldRender;
|
|
36
32
|
preview?: true;
|
|
37
33
|
customValidate?: boolean;
|
|
38
34
|
readonly?: boolean;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
|
|
2
2
|
import { ItemPreviewInput, PreviewItem } from "../preview.js";
|
|
3
|
-
import { FieldRender } from "../render.js";
|
|
4
3
|
import { SourcePath } from "../val/index.js";
|
|
5
4
|
import { ValidationError, ValidationErrors } from "./validation/ValidationError.js";
|
|
6
5
|
type StringOptions = {
|
|
@@ -11,16 +10,6 @@ type StringOptions = {
|
|
|
11
10
|
};
|
|
12
11
|
export type SerializedStringSchema = {
|
|
13
12
|
type: "string";
|
|
14
|
-
/**
|
|
15
|
-
* How this field is laid out in the editor, carried WHOLE rather than as a
|
|
16
|
-
* marker.
|
|
17
|
-
*
|
|
18
|
-
* A render is static configuration — no closure, no dependency on source — so
|
|
19
|
-
* unlike a `preview` it serializes in full, and the editor reads it straight
|
|
20
|
-
* off the schema it already has. See `render.ts` for what that assumption
|
|
21
|
-
* buys, and what to do if a render ever needs to stop being static.
|
|
22
|
-
*/
|
|
23
|
-
render?: FieldRender;
|
|
24
13
|
/**
|
|
25
14
|
* Set by `.multiline()`: the field is a growing text box rather than a
|
|
26
15
|
* single-line input.
|
|
@@ -59,13 +48,12 @@ export declare class StringSchema<Src extends string | null> extends Schema<Src>
|
|
|
59
48
|
private readonly opt;
|
|
60
49
|
private readonly isRaw;
|
|
61
50
|
private readonly customValidateFunctions;
|
|
62
|
-
private readonly renderInput;
|
|
63
51
|
private readonly isReadonly;
|
|
64
52
|
private readonly isHidden;
|
|
65
53
|
private readonly description?;
|
|
66
54
|
private readonly previewInput;
|
|
67
55
|
private readonly isMultiline;
|
|
68
|
-
constructor(options?: StringOptions | undefined, opt?: boolean, isRaw?: boolean, customValidateFunctions?: ((src: Src) => false | string)[],
|
|
56
|
+
constructor(options?: StringOptions | undefined, opt?: boolean, isRaw?: boolean, customValidateFunctions?: ((src: Src) => false | string)[], isReadonly?: boolean, isHidden?: boolean, description?: string | undefined, previewInput?: ItemPreviewInput<Src> | null, isMultiline?: boolean);
|
|
69
57
|
/**
|
|
70
58
|
* Describe this field.
|
|
71
59
|
*
|
|
@@ -192,19 +180,6 @@ export declare class StringSchema<Src extends string | null> extends Schema<Src>
|
|
|
192
180
|
* export default c.define("/example.val.ts", schema, "Line one\nLine two");
|
|
193
181
|
*/
|
|
194
182
|
multiline(): StringSchema<Src>;
|
|
195
|
-
/**
|
|
196
|
-
* How this field is laid out in the editor when it is the item of an array or
|
|
197
|
-
* record: `{ as: "inline" }` renders the field itself inside each row,
|
|
198
|
-
* instead of a preview row that navigates to it.
|
|
199
|
-
*
|
|
200
|
-
* Static configuration, not a callback — see `render.ts`. What a CONTAINER
|
|
201
|
-
* shows for its items is a `preview`, which is a different thing entirely.
|
|
202
|
-
*
|
|
203
|
-
* @example
|
|
204
|
-
* const schema = s.array(s.string().render({ as: "inline" }));
|
|
205
|
-
* export default c.define("/example.val.ts", schema, ["First", "Second"]);
|
|
206
|
-
*/
|
|
207
|
-
render(input: FieldRender): StringSchema<Src>;
|
|
208
183
|
/**
|
|
209
184
|
* How this VALUE is shown where a preview of it is needed — a row in a
|
|
210
185
|
* sortable list, a reference dropdown, a search hit. Never how the field
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
|
|
2
2
|
import type { ModuleIdOf, ValModuleBrand } from "../module.js";
|
|
3
3
|
import { ReifiedPreview } from "../preview.js";
|
|
4
|
-
import { FieldRender } from "../render.js";
|
|
5
4
|
import { GenericSelector } from "../selector/index.js";
|
|
6
5
|
import { Source } from "../source/index.js";
|
|
7
6
|
import { ValViewSource } from "../source/view.js";
|
|
@@ -9,7 +8,6 @@ import { ModuleFilePath, SourcePath } from "../val/index.js";
|
|
|
9
8
|
import { ValidationError, ValidationErrors } from "./validation/ValidationError.js";
|
|
10
9
|
export type SerializedValViewSchema = {
|
|
11
10
|
type: "view";
|
|
12
|
-
render?: FieldRender;
|
|
13
11
|
/** Never set: a view has no value of its own to preview. Carried for shape parity. */
|
|
14
12
|
preview?: true;
|
|
15
13
|
/** Always false: a view points at a module, and `null` is not a module. */
|
|
@@ -57,7 +55,6 @@ export declare class ValViewSchema<Id extends string = string, T = unknown> exte
|
|
|
57
55
|
private readonly isReadonly;
|
|
58
56
|
private readonly isHidden;
|
|
59
57
|
private readonly description?;
|
|
60
|
-
private readonly renderInput;
|
|
61
58
|
constructor(moduleFilePath: Id,
|
|
62
59
|
/**
|
|
63
60
|
* The module this points at, as an object.
|
|
@@ -68,7 +65,7 @@ export declare class ValViewSchema<Id extends string = string, T = unknown> exte
|
|
|
68
65
|
* optional). Absent on a schema that came off the wire, which is fine: the
|
|
69
66
|
* Studio navigates to a view, it does not resolve one.
|
|
70
67
|
*/
|
|
71
|
-
valModule?: unknown, isReadonly?: boolean, isHidden?: boolean, description?: string | undefined
|
|
68
|
+
valModule?: unknown, isReadonly?: boolean, isHidden?: boolean, description?: string | undefined);
|
|
72
69
|
/**
|
|
73
70
|
* Describe this field.
|
|
74
71
|
*
|
|
@@ -154,22 +151,6 @@ export declare class ValViewSchema<Id extends string = string, T = unknown> exte
|
|
|
154
151
|
* });
|
|
155
152
|
*/
|
|
156
153
|
hidden(isHidden?: boolean): ValViewSchema<Id, T>;
|
|
157
|
-
/**
|
|
158
|
-
* How this field is laid out in the editor. Static configuration, not a
|
|
159
|
-
* callback — see `render.ts`.
|
|
160
|
-
*
|
|
161
|
-
* @example
|
|
162
|
-
* import otherVal from "./other.val"; // another module
|
|
163
|
-
* const schema = s.object({
|
|
164
|
-
* shared: s.view(otherVal).render({ as: "inline" }),
|
|
165
|
-
* title: s.string(),
|
|
166
|
-
* });
|
|
167
|
-
* export default c.define("/example.val.ts", schema, {
|
|
168
|
-
* shared: { view: "/other.val.ts" },
|
|
169
|
-
* title: "Hello",
|
|
170
|
-
* });
|
|
171
|
-
*/
|
|
172
|
-
render(input: FieldRender): ValViewSchema<Id, T>;
|
|
173
154
|
protected executeSerialize(): SerializedSchema;
|
|
174
155
|
protected executePreview(): ReifiedPreview;
|
|
175
156
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How Val names a media file: a cleaned-up base name, the first five hex of the
|
|
3
|
+
* content's SHA-256, and the extension — `hero-mountains_a1b2c.jpg`.
|
|
4
|
+
*
|
|
5
|
+
* Two producers need this and must agree: an upload (`createFilename`, which
|
|
6
|
+
* has the bytes) and a rename (`createRenamedFilename`, which keeps the bytes
|
|
7
|
+
* and only changes what is in front of the hash). If they disagreed, renaming a
|
|
8
|
+
* file to the name it was uploaded with would give it a different name.
|
|
9
|
+
*/
|
|
10
|
+
/** The `_a1b2c` a Val filename ends in, before the extension. */
|
|
11
|
+
export declare const FILENAME_HASH_SUFFIX_LENGTH = 5;
|
|
12
|
+
/**
|
|
13
|
+
* The part of a filename a person chose, made safe for a URL path.
|
|
14
|
+
*
|
|
15
|
+
* Lower case, with everything `encodeURIComponent` would escape dropped rather
|
|
16
|
+
* than escaped — a path segment that needs decoding is a path segment that gets
|
|
17
|
+
* decoded twice somewhere. Can return the empty string, for a name made only of
|
|
18
|
+
* such characters; a caller that needs a name has to refuse that.
|
|
19
|
+
*/
|
|
20
|
+
export declare function sanitizeFilenameBase(base: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* `base` with a trailing `_<hashPrefix>` removed, so a name that already carries
|
|
23
|
+
* the hash does not get it twice (`photo_a1b2c` + `a1b2c` → `photo_a1b2c`, not
|
|
24
|
+
* `photo_a1b2c_a1b2c`).
|
|
25
|
+
*/
|
|
26
|
+
export declare function stripHashSuffix(base: string, hashPrefix: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* The name a file gets when it is renamed to `newBase`.
|
|
29
|
+
*
|
|
30
|
+
* The hash and the extension are not the editor's to change: the hash keeps two
|
|
31
|
+
* different files from ever sharing a name, and the extension is part of a
|
|
32
|
+
* remote file's validation hash and of how its bytes are served. So they are
|
|
33
|
+
* passed in, and only the base comes from the person.
|
|
34
|
+
*
|
|
35
|
+
* Returns `null` when nothing usable is left of `newBase` after cleaning it.
|
|
36
|
+
*/
|
|
37
|
+
export declare function createRenamedFilename(newBase: string, sha256: string, ext: string): string | null;
|