@valbuild/core 0.77.1 → 0.78.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/dist/declarations/src/index.d.ts +1 -0
- package/dist/declarations/src/initSchema.d.ts +2 -2
- package/dist/declarations/src/preview.d.ts +39 -0
- package/dist/declarations/src/schema/array.d.ts +16 -2
- package/dist/declarations/src/schema/boolean.d.ts +2 -0
- package/dist/declarations/src/schema/date.d.ts +2 -0
- package/dist/declarations/src/schema/file.d.ts +2 -0
- package/dist/declarations/src/schema/image.d.ts +2 -0
- package/dist/declarations/src/schema/index.d.ts +3 -1
- package/dist/declarations/src/schema/keyOf.d.ts +2 -0
- package/dist/declarations/src/schema/literal.d.ts +2 -0
- package/dist/declarations/src/schema/number.d.ts +2 -0
- package/dist/declarations/src/schema/object.d.ts +3 -1
- package/dist/declarations/src/schema/record.d.ts +17 -2
- package/dist/declarations/src/schema/richtext.d.ts +2 -0
- package/dist/declarations/src/schema/string.d.ts +2 -0
- package/dist/declarations/src/schema/union.d.ts +3 -1
- package/dist/{index-ee3d5938.cjs.prod.js → index-1061d844.cjs.prod.js} +248 -2
- package/dist/{index-ba3bd117.esm.js → index-24c8829d.esm.js} +248 -2
- package/dist/{index-895564f9.cjs.dev.js → index-beacdff9.cjs.dev.js} +248 -2
- 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
@@ -52,6 +52,7 @@ export { type SerializedRichTextSchema, RichTextSchema, } from "./schema/richtex
|
|
52
52
|
export { type SerializedUnionSchema, UnionSchema, type SerializedStringUnionSchema, type SerializedObjectUnionSchema, } from "./schema/union.js";
|
53
53
|
export { type SerializedLiteralSchema, LiteralSchema } from "./schema/literal.js";
|
54
54
|
export { deserializeSchema } from "./schema/deserialize.js";
|
55
|
+
export { type ListRecordPreview, type ListArrayPreview, type ReifiedPreview, } from "./preview.js";
|
55
56
|
export declare const FATAL_ERROR_TYPES: readonly ["no-schema", "no-source", "invalid-id", "no-module", "invalid-patch"];
|
56
57
|
export type FatalErrorType = (typeof FATAL_ERROR_TYPES)[number];
|
57
58
|
export declare const DEFAULT_CONTENT_HOST = "https://content.val.build";
|
@@ -47,7 +47,7 @@ export type InitSchema = {
|
|
47
47
|
export declare function initSchema(): {
|
48
48
|
string: <T extends string>(options?: Record<string, never> | undefined) => import("./schema/string.js").StringSchema<T>;
|
49
49
|
boolean: () => import("./schema/index.js").Schema<boolean>;
|
50
|
-
array: <S extends import("./schema/index.js").Schema<import("./selector/index.js").SelectorSource>>(schema: S) => import("./schema/
|
50
|
+
array: <S extends import("./schema/index.js").Schema<import("./selector/index.js").SelectorSource>>(schema: S) => import("./schema/array.js").ArraySchema<S, import("./schema/index.js").SelectorOfSchema<S>[] | null>;
|
51
51
|
object: <Props extends {
|
52
52
|
[key: string]: import("./schema/index.js").Schema<import("./selector/index.js").SelectorSource>;
|
53
53
|
} & {
|
@@ -98,7 +98,7 @@ export declare function initSchema(): {
|
|
98
98
|
image: (options?: import("./schema/image.js").ImageOptions | undefined) => import("./schema/image.js").ImageSchema<import("./index.js").ImageSource>;
|
99
99
|
literal: <T_2 extends string>(value: T_2) => import("./schema/literal.js").LiteralSchema<T_2>;
|
100
100
|
keyOf: <Src extends import("./selector/index.js").GenericSelector<import("./source/index.js").SourceObject, undefined> & import("./module.js").ValModuleBrand>(valModule: Src) => import("./schema/index.js").Schema<Src extends import("./selector/index.js").GenericSelector<infer S_2 extends import("./source/index.js").Source, undefined> ? S_2 extends readonly import("./source/index.js").Source[] ? number : S_2 extends import("./source/index.js").SourceObject ? string extends keyof S_2 ? import("./schema/string.js").RawString : keyof S_2 : S_2 extends Record<string, import("./source/index.js").Source> ? import("./schema/string.js").RawString : never : never>;
|
101
|
-
record: <S_3 extends import("./schema/index.js").Schema<import("./selector/index.js").SelectorSource>>(schema: S_3) => import("./schema/
|
101
|
+
record: <S_3 extends import("./schema/index.js").Schema<import("./selector/index.js").SelectorSource>>(schema: S_3) => import("./schema/record.js").RecordSchema<S_3, Record<string, import("./schema/index.js").SelectorOfSchema<S_3>>>;
|
102
102
|
file: (options?: import("./schema/file.js").FileOptions | undefined) => import("./schema/file.js").FileSchema<import("./index.js").FileSource<import("./schema/file.js").FileMetadata>>;
|
103
103
|
date: (options?: Record<string, never> | undefined) => import("./schema/date.js").DateSchema<import("./schema/string.js").RawString>;
|
104
104
|
};
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import { Schema } from "./schema/index.js";
|
2
|
+
import { SelectorSource } from "./selector/index.js";
|
3
|
+
import { ImageSource } from "./source/image.js";
|
4
|
+
import { ModuleFilePath, SourcePath } from "./val/index.js";
|
5
|
+
export type ListRecordPreview = {
|
6
|
+
layout: "list";
|
7
|
+
parent: "record";
|
8
|
+
items: [
|
9
|
+
key: string,
|
10
|
+
value: {
|
11
|
+
title: string;
|
12
|
+
subtitle?: string | null;
|
13
|
+
image?: ImageSource | null;
|
14
|
+
}
|
15
|
+
][];
|
16
|
+
};
|
17
|
+
export type ListArrayPreview = {
|
18
|
+
layout: "list";
|
19
|
+
parent: "array";
|
20
|
+
items: {
|
21
|
+
title: string;
|
22
|
+
subtitle?: string | null;
|
23
|
+
image?: ImageSource | null;
|
24
|
+
}[];
|
25
|
+
};
|
26
|
+
type PreviewTypes = ListRecordPreview | ListArrayPreview;
|
27
|
+
type WithStatus<T> = {
|
28
|
+
status: "error";
|
29
|
+
message: string;
|
30
|
+
} | {
|
31
|
+
status: "loading";
|
32
|
+
data?: T;
|
33
|
+
} | {
|
34
|
+
status: "success";
|
35
|
+
data: T;
|
36
|
+
};
|
37
|
+
export type ReifiedPreview = Record<SourcePath | ModuleFilePath, WithStatus<PreviewTypes>>;
|
38
|
+
export type PreviewSelector<T extends Schema<SelectorSource>> = T extends Schema<infer S> ? S : never;
|
39
|
+
export {};
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import { Schema, SchemaAssertResult, SelectorOfSchema, SerializedSchema } from "./index.js";
|
2
|
+
import { PreviewSelector, ReifiedPreview } from "../preview.js";
|
2
3
|
import { SelectorSource } from "../selector/index.js";
|
3
|
-
import {
|
4
|
+
import { ImageSource } from "../source/image.js";
|
5
|
+
import { ModuleFilePath, SourcePath } from "../val/index.js";
|
4
6
|
import { ValidationErrors } from "./validation/ValidationError.js";
|
5
7
|
export type SerializedArraySchema = {
|
6
8
|
type: "array";
|
@@ -15,5 +17,17 @@ export declare class ArraySchema<T extends Schema<SelectorSource>, Src extends S
|
|
15
17
|
assert(path: SourcePath, src: unknown): SchemaAssertResult<Src>;
|
16
18
|
nullable(): Schema<Src | null>;
|
17
19
|
serialize(): SerializedArraySchema;
|
20
|
+
private previewInput;
|
21
|
+
protected executePreview(sourcePath: SourcePath | ModuleFilePath, src: Src): ReifiedPreview;
|
22
|
+
preview(input: {
|
23
|
+
layout: "list";
|
24
|
+
prepare: (input: {
|
25
|
+
val: PreviewSelector<T>;
|
26
|
+
}) => {
|
27
|
+
title: string;
|
28
|
+
subtitle?: string | null;
|
29
|
+
image?: ImageSource | null;
|
30
|
+
};
|
31
|
+
}): this;
|
18
32
|
}
|
19
|
-
export declare const array: <S extends Schema<SelectorSource>>(schema: S) =>
|
33
|
+
export declare const array: <S extends Schema<SelectorSource>>(schema: S) => ArraySchema<S, SelectorOfSchema<S>[] | null>;
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
|
2
|
+
import { ReifiedPreview } from "../preview.js";
|
2
3
|
import { SourcePath } from "../val/index.js";
|
3
4
|
import { ValidationErrors } from "./validation/ValidationError.js";
|
4
5
|
export type SerializedBooleanSchema = {
|
@@ -12,5 +13,6 @@ export declare class BooleanSchema<Src extends boolean | null> extends Schema<Sr
|
|
12
13
|
assert(path: SourcePath, src: unknown): SchemaAssertResult<Src>;
|
13
14
|
nullable(): Schema<Src | null>;
|
14
15
|
serialize(): SerializedSchema;
|
16
|
+
protected executePreview(): ReifiedPreview;
|
15
17
|
}
|
16
18
|
export declare const boolean: () => Schema<boolean>;
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
|
2
|
+
import { ReifiedPreview } from "../preview.js";
|
2
3
|
import { SourcePath } from "../val/index.js";
|
3
4
|
import { RawString } from "./string.js";
|
4
5
|
import { ValidationErrors } from "./validation/ValidationError.js";
|
@@ -33,6 +34,7 @@ export declare class DateSchema<Src extends string | null> extends Schema<Src> {
|
|
33
34
|
to(to: string): DateSchema<Src>;
|
34
35
|
nullable(): DateSchema<Src | null>;
|
35
36
|
serialize(): SerializedSchema;
|
37
|
+
protected executePreview(): ReifiedPreview;
|
36
38
|
}
|
37
39
|
export declare const date: (options?: Record<string, never>) => DateSchema<RawString>;
|
38
40
|
export {};
|
@@ -4,6 +4,7 @@ import { Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
|
|
4
4
|
import { SourcePath } from "../val/index.js";
|
5
5
|
import { ValidationErrors } from "./validation/ValidationError.js";
|
6
6
|
import { RemoteSource } from "../index.js";
|
7
|
+
import { ReifiedPreview } from "../preview.js";
|
7
8
|
export type FileOptions = {
|
8
9
|
accept?: string;
|
9
10
|
};
|
@@ -26,6 +27,7 @@ export declare class FileSchema<Src extends FileSource<FileMetadata | undefined>
|
|
26
27
|
assert(path: SourcePath, src: unknown): SchemaAssertResult<Src>;
|
27
28
|
nullable(): Schema<Src | null>;
|
28
29
|
serialize(): SerializedSchema;
|
30
|
+
protected executePreview(): ReifiedPreview;
|
29
31
|
}
|
30
32
|
export declare const file: (options?: FileOptions) => FileSchema<FileSource<FileMetadata>>;
|
31
33
|
export declare function convertFileSource<Metadata extends {
|
@@ -5,6 +5,7 @@ import { SourcePath } from "../val/index.js";
|
|
5
5
|
import { ValidationErrors } from "./validation/ValidationError.js";
|
6
6
|
import { FileMetadata } from "../index.js";
|
7
7
|
import { RemoteSource } from "../source/remote.js";
|
8
|
+
import { ReifiedPreview } from "../preview.js";
|
8
9
|
export type ImageOptions = {
|
9
10
|
ext?: ["jpg"] | ["webp"];
|
10
11
|
directory?: string;
|
@@ -36,5 +37,6 @@ export declare class ImageSchema<Src extends FileSource<ImageMetadata | undefine
|
|
36
37
|
assert(path: SourcePath, src: unknown): SchemaAssertResult<Src>;
|
37
38
|
nullable(): Schema<Src | null>;
|
38
39
|
serialize(): SerializedSchema;
|
40
|
+
protected executePreview(): ReifiedPreview;
|
39
41
|
}
|
40
42
|
export declare const image: (options?: ImageOptions) => ImageSchema<ImageSource>;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { SelectorSource } from "../selector/index.js";
|
2
|
-
import { SourcePath } from "../val/index.js";
|
2
|
+
import { ModuleFilePath, SourcePath } from "../val/index.js";
|
3
3
|
import { SerializedArraySchema } from "./array.js";
|
4
4
|
import { SerializedBooleanSchema } from "./boolean.js";
|
5
5
|
import { SerializedFileSchema } from "./file.js";
|
@@ -16,6 +16,7 @@ import { SerializedDateSchema } from "./date.js";
|
|
16
16
|
import { ValidationErrors } from "./validation/ValidationError.js";
|
17
17
|
import { FileSource } from "../source/file.js";
|
18
18
|
import { GenericRichTextSourceNode, RichTextSource } from "../source/richtext.js";
|
19
|
+
import { ReifiedPreview } from "../preview.js";
|
19
20
|
export type SerializedSchema = SerializedStringSchema | SerializedLiteralSchema | SerializedBooleanSchema | SerializedNumberSchema | SerializedObjectSchema | SerializedArraySchema | SerializedUnionSchema | SerializedRichTextSchema | SerializedRecordSchema | SerializedKeyOfSchema | SerializedFileSchema | SerializedDateSchema | SerializedImageSchema;
|
20
21
|
type Primitives = number | string | boolean | null | FileSource;
|
21
22
|
export type AssertError = {
|
@@ -60,6 +61,7 @@ export declare abstract class Schema<Src extends SelectorSource> {
|
|
60
61
|
abstract assert(path: SourcePath, src: unknown): SchemaAssertResult<Src>;
|
61
62
|
abstract nullable(): Schema<Src | null>;
|
62
63
|
abstract serialize(): SerializedSchema;
|
64
|
+
protected abstract executePreview(sourcePath: SourcePath | ModuleFilePath, src: Src): ReifiedPreview;
|
63
65
|
/** MUTATES! since internal and perf sensitive */
|
64
66
|
protected appendValidationError(current: ValidationErrors, path: SourcePath, message: string, value: unknown): ValidationErrors;
|
65
67
|
}
|
@@ -5,6 +5,7 @@ import { Source, SourceObject } from "../source/index.js";
|
|
5
5
|
import { SourcePath } from "../val/index.js";
|
6
6
|
import { ValidationErrors } from "./validation/ValidationError.js";
|
7
7
|
import { RawString } from "./string.js";
|
8
|
+
import { ReifiedPreview } from "../preview.js";
|
8
9
|
export type SerializedKeyOfSchema = {
|
9
10
|
type: "keyOf";
|
10
11
|
path: SourcePath;
|
@@ -22,6 +23,7 @@ export declare class KeyOfSchema<Sel extends GenericSelector<SourceObject>, Src
|
|
22
23
|
assert(path: SourcePath, src: unknown): SchemaAssertResult<Src>;
|
23
24
|
nullable(): Schema<Src | null>;
|
24
25
|
serialize(): SerializedSchema;
|
26
|
+
protected executePreview(): ReifiedPreview;
|
25
27
|
}
|
26
28
|
export declare const keyOf: <Src extends GenericSelector<SourceObject, undefined> & ValModuleBrand>(valModule: Src) => Schema<KeyOfSelector<Src>>;
|
27
29
|
export {};
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
|
2
|
+
import { ReifiedPreview } from "../preview.js";
|
2
3
|
import { SourcePath } from "../val/index.js";
|
3
4
|
import { ValidationErrors } from "./validation/ValidationError.js";
|
4
5
|
export type SerializedLiteralSchema = {
|
@@ -14,5 +15,6 @@ export declare class LiteralSchema<Src extends string | null> extends Schema<Src
|
|
14
15
|
assert(path: SourcePath, src: unknown): SchemaAssertResult<Src>;
|
15
16
|
nullable(): Schema<Src | null>;
|
16
17
|
serialize(): SerializedSchema;
|
18
|
+
protected executePreview(): ReifiedPreview;
|
17
19
|
}
|
18
20
|
export declare const literal: <T extends string>(value: T) => LiteralSchema<T>;
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
|
2
|
+
import { ReifiedPreview } from "../preview.js";
|
2
3
|
import { SourcePath } from "../val/index.js";
|
3
4
|
import { ValidationErrors } from "./validation/ValidationError.js";
|
4
5
|
type NumberOptions = {
|
@@ -18,6 +19,7 @@ export declare class NumberSchema<Src extends number | null> extends Schema<Src>
|
|
18
19
|
assert(path: SourcePath, src: unknown): SchemaAssertResult<Src>;
|
19
20
|
nullable(): Schema<Src>;
|
20
21
|
serialize(): SerializedSchema;
|
22
|
+
protected executePreview(): ReifiedPreview;
|
21
23
|
}
|
22
24
|
export declare const number: (options?: NumberOptions) => Schema<number>;
|
23
25
|
export {};
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { Schema, SchemaAssertResult, SelectorOfSchema, SerializedSchema } from "./index.js";
|
2
|
+
import { ReifiedPreview } from "../preview.js";
|
2
3
|
import { SelectorSource } from "../selector/index.js";
|
3
|
-
import { SourcePath } from "../val/index.js";
|
4
|
+
import { ModuleFilePath, SourcePath } from "../val/index.js";
|
4
5
|
import { ValidationErrors } from "./validation/ValidationError.js";
|
5
6
|
export type SerializedObjectSchema = {
|
6
7
|
type: "object";
|
@@ -36,6 +37,7 @@ export declare class ObjectSchema<Props extends ObjectSchemaProps, Src extends O
|
|
36
37
|
assert(path: SourcePath, src: unknown): SchemaAssertResult<Src>;
|
37
38
|
nullable(): Schema<Src | null>;
|
38
39
|
serialize(): SerializedSchema;
|
40
|
+
protected executePreview(sourcePath: SourcePath | ModuleFilePath, src: Src): ReifiedPreview;
|
39
41
|
}
|
40
42
|
export declare const object: <Props extends ObjectSchemaProps>(schema: Props) => Schema<{ [key in keyof Props]: SelectorOfSchema<Props[key]>; }>;
|
41
43
|
export {};
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import { Schema, SchemaAssertResult, SelectorOfSchema, SerializedSchema } from "./index.js";
|
2
|
+
import { PreviewSelector, ReifiedPreview } from "../preview.js";
|
2
3
|
import { SelectorSource } from "../selector/index.js";
|
3
|
-
import {
|
4
|
+
import { ImageSource } from "../source/image.js";
|
5
|
+
import { ModuleFilePath, SourcePath } from "../val/index.js";
|
4
6
|
import { ValidationErrors } from "./validation/ValidationError.js";
|
5
7
|
export type SerializedRecordSchema = {
|
6
8
|
type: "record";
|
@@ -15,5 +17,18 @@ export declare class RecordSchema<T extends Schema<SelectorSource>, Src extends
|
|
15
17
|
assert(path: SourcePath, src: unknown): SchemaAssertResult<Src>;
|
16
18
|
nullable(): Schema<Src | null>;
|
17
19
|
serialize(): SerializedRecordSchema;
|
20
|
+
private previewInput;
|
21
|
+
protected executePreview(sourcePath: SourcePath | ModuleFilePath, src: Src): ReifiedPreview;
|
22
|
+
preview(input: {
|
23
|
+
layout: "list";
|
24
|
+
prepare: (input: {
|
25
|
+
key: string;
|
26
|
+
val: PreviewSelector<T>;
|
27
|
+
}) => {
|
28
|
+
title: string;
|
29
|
+
subtitle?: string | null;
|
30
|
+
image?: ImageSource | null;
|
31
|
+
};
|
32
|
+
}): this;
|
18
33
|
}
|
19
|
-
export declare const record: <S extends Schema<SelectorSource>>(schema: S) =>
|
34
|
+
export declare const record: <S extends Schema<SelectorSource>>(schema: S) => RecordSchema<S, Record<string, SelectorOfSchema<S>>>;
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
|
2
|
+
import { ReifiedPreview } from "../preview.js";
|
2
3
|
import { ImageSource } from "../source/image.js";
|
3
4
|
import { RichTextSource, RichTextOptions, SerializedRichTextOptions } from "../source/richtext.js";
|
4
5
|
import { SourcePath } from "../val/index.js";
|
@@ -25,6 +26,7 @@ export declare class RichTextSchema<O extends RichTextOptions, Src extends RichT
|
|
25
26
|
private recursiveAssert;
|
26
27
|
nullable(): Schema<Src | null>;
|
27
28
|
serialize(): SerializedSchema;
|
29
|
+
protected executePreview(): ReifiedPreview;
|
28
30
|
}
|
29
31
|
export declare const richtext: <O extends Partial<{
|
30
32
|
style: Partial<{
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
|
2
|
+
import { ReifiedPreview } from "../preview.js";
|
2
3
|
import { SourcePath } from "../val/index.js";
|
3
4
|
import { ValidationErrors } from "./validation/ValidationError.js";
|
4
5
|
type StringOptions = {
|
@@ -44,6 +45,7 @@ export declare class StringSchema<Src extends string | null> extends Schema<Src>
|
|
44
45
|
nullable(): StringSchema<Src | null>;
|
45
46
|
raw(): StringSchema<Src extends null ? RawString | null : RawString>;
|
46
47
|
serialize(): SerializedSchema;
|
48
|
+
protected executePreview(): ReifiedPreview;
|
47
49
|
}
|
48
50
|
export declare const string: <T extends string>(options?: Record<string, never>) => StringSchema<T>;
|
49
51
|
export {};
|
@@ -1,7 +1,8 @@
|
|
1
1
|
import { Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
|
2
|
+
import { ReifiedPreview } from "../preview.js";
|
2
3
|
import { SelectorSource } from "../selector/index.js";
|
3
4
|
import { SourceObject } from "../source/index.js";
|
4
|
-
import { SourcePath } from "../val/index.js";
|
5
|
+
import { ModuleFilePath, SourcePath } from "../val/index.js";
|
5
6
|
import { SerializedLiteralSchema } from "./literal.js";
|
6
7
|
import { SerializedObjectSchema } from "./object.js";
|
7
8
|
import { ValidationErrors } from "./validation/ValidationError.js";
|
@@ -32,6 +33,7 @@ export declare class UnionSchema<Key extends string | Schema<string>, T extends
|
|
32
33
|
nullable(): Schema<Src | null>;
|
33
34
|
serialize(): SerializedSchema;
|
34
35
|
constructor(key: Key, items: T, opt?: boolean);
|
36
|
+
protected executePreview(sourcePath: SourcePath | ModuleFilePath, src: Src): ReifiedPreview;
|
35
37
|
}
|
36
38
|
export declare const union: <Key extends string | Schema<string>, T extends Schema<Key extends string ? {
|
37
39
|
[x: string]: import("../source/index.js").Source;
|