@valbuild/core 0.63.6 → 0.65.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/dist/declarations/src/expr/expr.d.ts +2 -2
- package/dist/declarations/src/expr/parser.d.ts +2 -2
- package/dist/declarations/src/index.d.ts +49 -94
- package/dist/declarations/src/initSchema.d.ts +19 -49
- package/dist/declarations/src/initVal.d.ts +8 -3
- package/dist/declarations/src/mimeType/all.d.ts +4 -0
- package/dist/declarations/src/mimeType/convertMimeType.d.ts +3 -0
- package/dist/declarations/src/mimeType/index.d.ts +2 -0
- package/dist/declarations/src/module.d.ts +6 -2
- package/dist/declarations/src/schema/array.d.ts +5 -5
- package/dist/declarations/src/schema/boolean.d.ts +2 -2
- package/dist/declarations/src/schema/date.d.ts +5 -5
- package/dist/declarations/src/schema/file.d.ts +5 -4
- package/dist/declarations/src/schema/image.d.ts +4 -4
- package/dist/declarations/src/schema/index.d.ts +44 -3
- package/dist/declarations/src/schema/keyOf.d.ts +9 -9
- package/dist/declarations/src/schema/literal.d.ts +3 -3
- package/dist/declarations/src/schema/number.d.ts +3 -3
- package/dist/declarations/src/schema/object.d.ts +5 -5
- package/dist/declarations/src/schema/record.d.ts +5 -5
- package/dist/declarations/src/schema/richtext.d.ts +6 -25
- package/dist/declarations/src/schema/string.d.ts +2 -2
- package/dist/declarations/src/schema/union.d.ts +18 -19
- package/dist/declarations/src/schema/validation/ValidationError.d.ts +2 -1
- package/dist/declarations/src/selector/SelectorProxy.d.ts +1 -0
- package/dist/declarations/src/source/file.d.ts +7 -4
- package/dist/declarations/src/source/richtext.d.ts +7 -0
- package/dist/declarations/src/val/index.d.ts +1 -1
- package/dist/{index-041f75bd.cjs.prod.js → index-48930c58.cjs.dev.js} +1842 -1050
- package/dist/{index-fccba617.esm.js → index-65ec1d74.esm.js} +1840 -1049
- package/dist/{index-c67ed8f9.cjs.dev.js → index-f1a23e6c.cjs.prod.js} +1842 -1050
- package/dist/{result-a8316efa.esm.js → result-168dfc1d.esm.js} +42 -46
- package/dist/{result-26f67b40.cjs.prod.js → result-787e35f6.cjs.prod.js} +41 -45
- package/dist/{result-48320acd.cjs.dev.js → result-bb1f436e.cjs.dev.js} +41 -45
- package/dist/valbuild-core.cjs.d.ts +2 -2
- package/dist/valbuild-core.cjs.dev.js +4 -3
- package/dist/valbuild-core.cjs.prod.js +4 -3
- package/dist/valbuild-core.esm.js +2 -2
- package/expr/dist/valbuild-core-expr.cjs.d.ts +2 -2
- package/expr/dist/valbuild-core-expr.cjs.dev.js +2 -2
- package/expr/dist/valbuild-core-expr.cjs.prod.js +2 -2
- package/expr/dist/valbuild-core-expr.esm.js +2 -2
- package/fp/dist/valbuild-core-fp.cjs.d.ts +2 -2
- package/fp/dist/valbuild-core-fp.cjs.dev.js +1 -1
- package/fp/dist/valbuild-core-fp.cjs.prod.js +1 -1
- package/fp/dist/valbuild-core-fp.esm.js +1 -1
- package/package.json +1 -1
- package/patch/dist/valbuild-core-patch.cjs.d.ts +2 -2
- package/patch/dist/valbuild-core-patch.cjs.dev.js +8 -9
- package/patch/dist/valbuild-core-patch.cjs.prod.js +8 -9
- package/patch/dist/valbuild-core-patch.esm.js +9 -10
- package/dist/declarations/src/ValApi.d.ts +0 -54
- package/dist/valbuild-core.cjs.d.ts.map +0 -1
- package/expr/dist/valbuild-core-expr.cjs.d.ts.map +0 -1
- package/fp/dist/valbuild-core-fp.cjs.d.ts.map +0 -1
- package/patch/dist/valbuild-core-patch.cjs.d.ts.map +0 -1
@@ -1,8 +1,8 @@
|
|
1
1
|
export declare abstract class Expr {
|
2
|
-
readonly span?: [number,
|
2
|
+
readonly span?: [number, number?] | undefined;
|
3
3
|
abstract type: "StringLiteral" | "Sym" | "StringTemplate" | "Call";
|
4
4
|
abstract transpile(): string;
|
5
|
-
constructor(span?: [number,
|
5
|
+
constructor(span?: [number, number?] | undefined);
|
6
6
|
}
|
7
7
|
export declare class StringLiteral extends Expr {
|
8
8
|
readonly value: string;
|
@@ -2,7 +2,7 @@ import { result } from "../fp/index.js";
|
|
2
2
|
import { Expr } from "./expr.js";
|
3
3
|
export declare class ParserError {
|
4
4
|
readonly message: string;
|
5
|
-
readonly span?: [number,
|
6
|
-
constructor(message: string, span?: [number,
|
5
|
+
readonly span?: [number, number?] | undefined;
|
6
|
+
constructor(message: string, span?: [number, number?] | undefined);
|
7
7
|
}
|
8
8
|
export declare function parse(input: string): result.Result<Expr, ParserError>;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
export { initVal } from "./initVal.js";
|
1
|
+
export { initVal, type ConfigDirectory } from "./initVal.js";
|
2
2
|
export { modules, type ValModules } from "./modules.js";
|
3
3
|
export type { InitVal, ValConfig, ValConstructor, ContentConstructor, } from "./initVal.js";
|
4
4
|
export { Schema, type SerializedSchema, type SelectorOfSchema } from "./schema/index.js";
|
@@ -15,23 +15,25 @@ export type { AllRichTextOptions, Bold, Styles, HeadingNode, ImageNode, Italic,
|
|
15
15
|
export { type Val, type SerializedVal, type ModuleFilePath, type PatchId, type ModulePath, type SourcePath, type JsonOfSource, } from "./val/index.js";
|
16
16
|
export type { Json, JsonPrimitive, JsonArray, JsonObject } from "./Json.js";
|
17
17
|
export type { ValidationError, ValidationErrors, } from "./schema/validation/ValidationError.js";
|
18
|
-
import type { ValidationError, ValidationErrors } from "./schema/validation/ValidationError.js";
|
19
18
|
export type { ValidationFix } from "./schema/validation/ValidationFix.js";
|
20
19
|
export * as expr from "./expr/index.js";
|
21
20
|
export { FILE_REF_PROP, FILE_REF_SUBTYPE_TAG } from "./source/file.js";
|
22
21
|
export { VAL_EXTENSION, type SourceArray } from "./source/index.js";
|
23
22
|
export { derefPatch } from "./patch/deref.js";
|
24
23
|
export { type SelectorSource, type SelectorOf, GenericSelector, } from "./selector/index.js";
|
25
|
-
import { getSource, resolvePath, splitModuleFilePathAndModulePath } from "./module.js";
|
24
|
+
import { getSource, splitModulePath, splitModuleFilePath, resolvePath, splitModuleFilePathAndModulePath, joinModuleFilePathAndModulePath, parentOfSourcePath, patchPathToModulePath, splitJoinedSourcePaths } from "./module.js";
|
25
|
+
declare const ModuleFilePathSep = "?p=";
|
26
|
+
export { ModuleFilePathSep };
|
26
27
|
import { getSchema } from "./selector/index.js";
|
27
|
-
import {
|
28
|
+
import { ModulePath, getValPath, isVal } from "./val/index.js";
|
28
29
|
import { convertFileSource } from "./schema/file.js";
|
29
30
|
import { createValPathOfItem } from "./selector/SelectorProxy.js";
|
30
31
|
import { getVal } from "./future/fetchVal.js";
|
31
|
-
import
|
32
|
-
import { Operation, Patch } from "./patch/index.js";
|
32
|
+
import { Operation } from "./patch/index.js";
|
33
33
|
import { initSchema } from "./initSchema.js";
|
34
|
-
import {
|
34
|
+
import { getMimeType, mimeTypeToFileExt, filenameToMimeType } from "./mimeType/index.js";
|
35
|
+
import { type ImageMetadata } from "./schema/image.js";
|
36
|
+
import { type FileMetadata } from "./schema/file.js";
|
35
37
|
export { type SerializedArraySchema, ArraySchema } from "./schema/array.js";
|
36
38
|
export { type SerializedObjectSchema, ObjectSchema } from "./schema/object.js";
|
37
39
|
export { type SerializedRecordSchema, RecordSchema } from "./schema/record.js";
|
@@ -41,96 +43,13 @@ export { type SerializedBooleanSchema, BooleanSchema } from "./schema/boolean.js
|
|
41
43
|
export { type SerializedImageSchema, ImageSchema } from "./schema/image.js";
|
42
44
|
export { type SerializedFileSchema, FileSchema } from "./schema/file.js";
|
43
45
|
export { type SerializedDateSchema, DateSchema } from "./schema/date.js";
|
46
|
+
export { type SerializedKeyOfSchema, KeyOfSchema } from "./schema/keyOf.js";
|
44
47
|
export { type SerializedRichTextSchema, RichTextSchema, } from "./schema/richtext.js";
|
45
|
-
export { type SerializedUnionSchema, UnionSchema } from "./schema/union.js";
|
48
|
+
export { type SerializedUnionSchema, UnionSchema, type SerializedStringUnionSchema, type SerializedObjectUnionSchema, } from "./schema/union.js";
|
46
49
|
export { type SerializedLiteralSchema, LiteralSchema } from "./schema/literal.js";
|
47
50
|
export { deserializeSchema } from "./schema/deserialize.js";
|
48
|
-
export { ValApi } from "./ValApi.js";
|
49
|
-
export type ApiCommitResponse = {};
|
50
|
-
export type ApiSchemaResponse = {
|
51
|
-
schemaSha: string;
|
52
|
-
schemas: Record<ModuleFilePath, SerializedSchema>;
|
53
|
-
};
|
54
|
-
export type ApiTreeResponse = {
|
55
|
-
schemaSha: string;
|
56
|
-
fatalErrors?: ({
|
57
|
-
message: string;
|
58
|
-
type: "invalid-module-file-path";
|
59
|
-
actualModuleFilePath: string;
|
60
|
-
expectedModuleFilePath: string;
|
61
|
-
} | {
|
62
|
-
message: string;
|
63
|
-
stack?: string;
|
64
|
-
type?: undefined;
|
65
|
-
})[];
|
66
|
-
newPatchId?: PatchId;
|
67
|
-
modules: Record<ModuleFilePath, {
|
68
|
-
source: Json;
|
69
|
-
patches?: {
|
70
|
-
applied: PatchId[];
|
71
|
-
skipped?: PatchId[];
|
72
|
-
errors?: Record<PatchId, {
|
73
|
-
message: string;
|
74
|
-
}>;
|
75
|
-
};
|
76
|
-
validationErrors?: Record<SourcePath, ValidationError[]>;
|
77
|
-
}>;
|
78
|
-
};
|
79
|
-
export type ApiGetPatchResponse = {
|
80
|
-
patches: Record<PatchId, {
|
81
|
-
path: ModuleFilePath;
|
82
|
-
patch?: Patch;
|
83
|
-
createdAt: string;
|
84
|
-
authorId: string | null;
|
85
|
-
appliedAt: {
|
86
|
-
baseSha: string;
|
87
|
-
git?: {
|
88
|
-
commitSha: string;
|
89
|
-
};
|
90
|
-
timestamp: string;
|
91
|
-
} | null;
|
92
|
-
}>;
|
93
|
-
error?: {
|
94
|
-
message: string;
|
95
|
-
};
|
96
|
-
errors?: Record<PatchId, {
|
97
|
-
message: string;
|
98
|
-
}>;
|
99
|
-
};
|
100
|
-
export type ApiDeletePatchResponse = PatchId[];
|
101
|
-
export type ApiPostPatchResponse = Record<ModuleFilePath, {
|
102
|
-
patch_id: PatchId;
|
103
|
-
}>;
|
104
|
-
export type ApiPostValidationResponse = {
|
105
|
-
validationErrors: false;
|
106
|
-
modules: Record<ModuleFilePath, {
|
107
|
-
patches: {
|
108
|
-
applied: PatchId[];
|
109
|
-
};
|
110
|
-
}>;
|
111
|
-
};
|
112
51
|
export declare const FATAL_ERROR_TYPES: readonly ["no-schema", "no-source", "invalid-id", "no-module", "invalid-patch"];
|
113
52
|
export type FatalErrorType = (typeof FATAL_ERROR_TYPES)[number];
|
114
|
-
export type ApiPostValidationErrorResponse = {
|
115
|
-
modules: Record<ModuleFilePath, {
|
116
|
-
patches: {
|
117
|
-
applied: PatchId[];
|
118
|
-
failed?: PatchId[];
|
119
|
-
};
|
120
|
-
}>;
|
121
|
-
validationErrors: Record<ModuleFilePath, {
|
122
|
-
source?: Json;
|
123
|
-
errors: {
|
124
|
-
invalidModulePath?: ModuleFilePath;
|
125
|
-
validation?: ValidationErrors;
|
126
|
-
fatal?: {
|
127
|
-
message: string;
|
128
|
-
stack?: string;
|
129
|
-
type?: FatalErrorType;
|
130
|
-
}[];
|
131
|
-
};
|
132
|
-
}>;
|
133
|
-
};
|
134
53
|
declare const Internal: {
|
135
54
|
VERSION: {
|
136
55
|
core: string | null;
|
@@ -142,12 +61,43 @@ declare const Internal: {
|
|
142
61
|
getSource: typeof getSource;
|
143
62
|
resolvePath: typeof resolvePath;
|
144
63
|
splitModuleFilePathAndModulePath: typeof splitModuleFilePathAndModulePath;
|
64
|
+
joinModuleFilePathAndModulePath: typeof joinModuleFilePathAndModulePath;
|
145
65
|
isVal: typeof isVal;
|
146
66
|
createValPathOfItem: typeof createValPathOfItem;
|
147
67
|
getSHA256Hash: (bits: Uint8Array) => string;
|
148
68
|
initSchema: typeof initSchema;
|
69
|
+
getMimeType: typeof getMimeType;
|
70
|
+
mimeTypeToFileExt: typeof mimeTypeToFileExt;
|
71
|
+
filenameToMimeType: typeof filenameToMimeType;
|
72
|
+
EXT_TO_MIME_TYPES: Record<string, string>;
|
73
|
+
MIME_TYPES_TO_EXT: {
|
74
|
+
[k: string]: string;
|
75
|
+
};
|
149
76
|
ModuleFilePathSep: string;
|
150
|
-
notFileOp: (op: Operation) =>
|
77
|
+
notFileOp: (op: Operation) => op is {
|
78
|
+
op: "add";
|
79
|
+
path: string[];
|
80
|
+
value: import("./patch/index.js").JSONValue;
|
81
|
+
} | {
|
82
|
+
op: "remove";
|
83
|
+
path: import("./fp/array.js").NonEmptyArray<string>;
|
84
|
+
} | {
|
85
|
+
op: "replace";
|
86
|
+
path: string[];
|
87
|
+
value: import("./patch/index.js").JSONValue;
|
88
|
+
} | {
|
89
|
+
op: "move";
|
90
|
+
from: import("./fp/array.js").NonEmptyArray<string>;
|
91
|
+
path: string[];
|
92
|
+
} | {
|
93
|
+
op: "copy";
|
94
|
+
from: string[];
|
95
|
+
path: string[];
|
96
|
+
} | {
|
97
|
+
op: "test";
|
98
|
+
path: string[];
|
99
|
+
value: import("./patch/index.js").JSONValue;
|
100
|
+
};
|
151
101
|
isFileOp: (op: Operation) => op is {
|
152
102
|
op: "file";
|
153
103
|
path: string[];
|
@@ -156,9 +106,14 @@ declare const Internal: {
|
|
156
106
|
};
|
157
107
|
createPatchJSONPath: (modulePath: ModulePath) => string;
|
158
108
|
createPatchPath: (modulePath: ModulePath) => string[];
|
159
|
-
|
109
|
+
splitModulePath: typeof splitModulePath;
|
110
|
+
splitModuleFilePath: typeof splitModuleFilePath;
|
111
|
+
splitJoinedSourcePaths: typeof splitJoinedSourcePaths;
|
112
|
+
parentOfSourcePath: typeof parentOfSourcePath;
|
113
|
+
patchPathToModulePath: typeof patchPathToModulePath;
|
160
114
|
VAL_ENABLE_COOKIE_NAME: "val_enable";
|
161
115
|
VAL_STATE_COOKIE: "val_state";
|
162
116
|
VAL_SESSION_COOKIE: "val_session";
|
117
|
+
createFilename: (data: string | null, filename: string | null, metadata: FileMetadata | ImageMetadata | undefined, sha256: string) => string | null;
|
163
118
|
};
|
164
119
|
export { Internal };
|
@@ -27,60 +27,30 @@ export type InitSchema = {
|
|
27
27
|
readonly date: typeof date;
|
28
28
|
};
|
29
29
|
export declare function initSchema(): {
|
30
|
-
string: <T extends string>(options?: Record<string, never>
|
30
|
+
string: <T extends string>(options?: Record<string, never>) => import("./schema/string.js").StringSchema<T>;
|
31
31
|
boolean: () => import("./schema/index.js").Schema<boolean>;
|
32
32
|
array: <S extends import("./schema/index.js").Schema<import("./selector/index.js").SelectorSource>>(schema: S) => import("./schema/index.js").Schema<import("./schema/index.js").SelectorOfSchema<S>[]>;
|
33
33
|
object: <Props extends {
|
34
34
|
[key: string]: import("./schema/index.js").Schema<import("./selector/index.js").SelectorSource>;
|
35
35
|
} & {
|
36
|
-
valPath?:
|
37
|
-
val?:
|
38
|
-
_type?:
|
39
|
-
_ref?:
|
40
|
-
andThen?:
|
41
|
-
assert?:
|
42
|
-
fold?:
|
36
|
+
valPath?: never;
|
37
|
+
val?: never;
|
38
|
+
_type?: never;
|
39
|
+
_ref?: never;
|
40
|
+
andThen?: never;
|
41
|
+
assert?: never;
|
42
|
+
fold?: never;
|
43
43
|
}>(schema: Props) => import("./schema/index.js").Schema<{ [key in keyof Props]: import("./schema/index.js").SelectorOfSchema<Props[key]>; }>;
|
44
44
|
number: (options?: {
|
45
|
-
max?: number
|
46
|
-
min?: number
|
47
|
-
}
|
48
|
-
union: <Key extends string | import("./schema/index.js").Schema<string>,
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
val?: undefined;
|
57
|
-
valPath?: undefined;
|
58
|
-
} & { [k in Key]: string; } : Key extends import("./schema/index.js").Schema<string> ? string : unknown>[]>(key: Key, ...objects: T_1) => import("./schema/index.js").Schema<T_1 extends import("./schema/index.js").Schema<infer S_1 extends import("./selector/index.js").SelectorSource>[] ? S_1 extends import("./selector/index.js").SelectorSource ? S_1 | (Key extends import("./schema/index.js").Schema<infer K extends import("./selector/index.js").SelectorSource> ? K : never) : never : never>;
|
59
|
-
richtext: <O extends Partial<{
|
60
|
-
style: Partial<{
|
61
|
-
bold: boolean;
|
62
|
-
italic: boolean;
|
63
|
-
lineThrough: boolean;
|
64
|
-
}>;
|
65
|
-
block: Partial<{
|
66
|
-
h1: boolean;
|
67
|
-
h2: boolean;
|
68
|
-
h3: boolean;
|
69
|
-
h4: boolean;
|
70
|
-
h5: boolean;
|
71
|
-
h6: boolean;
|
72
|
-
ul: boolean;
|
73
|
-
ol: boolean;
|
74
|
-
}>;
|
75
|
-
inline: Partial<{
|
76
|
-
a: boolean;
|
77
|
-
img: boolean;
|
78
|
-
}>;
|
79
|
-
}>>(options?: O | undefined) => import("./schema/index.js").Schema<import("./index.js").RichTextSource<O>>;
|
80
|
-
image: (options?: import("./schema/image.js").ImageOptions | undefined) => import("./schema/index.js").Schema<import("./index.js").ImageSource>;
|
81
|
-
literal: <T_2 extends string>(value: T_2) => import("./schema/index.js").Schema<T_2>;
|
82
|
-
keyOf: <Src extends import("./selector/index.js").GenericSelector<import("./source/index.js").SourceObject | import("./source/index.js").SourceArray, 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>;
|
83
|
-
record: <S_3 extends import("./schema/index.js").Schema<import("./selector/index.js").SelectorSource>>(schema: S_3) => import("./schema/index.js").Schema<Record<string, import("./schema/index.js").SelectorOfSchema<S_3>>>;
|
84
|
-
file: (options?: import("./schema/file.js").FileOptions | undefined) => import("./schema/index.js").Schema<import("./index.js").FileSource<import("./schema/file.js").FileMetadata>>;
|
85
|
-
date: <T_3 extends string>(options?: Record<string, never> | undefined) => import("./schema/date.js").DateSchema<T_3>;
|
45
|
+
max?: number;
|
46
|
+
min?: number;
|
47
|
+
}) => import("./schema/index.js").Schema<number>;
|
48
|
+
union: <Key extends string | import("./schema/index.js").Schema<string>, T extends import("./schema/index.js").Schema<Key extends string ? import("./source/index.js").SourceObject & { [k in Key]: string; } : Key extends import("./schema/index.js").Schema<string> ? string : unknown>[]>(key: Key, ...objects: T) => import("./schema/index.js").Schema<T extends import("./schema/index.js").Schema<infer S extends import("./selector/index.js").SelectorSource>[] ? S extends import("./selector/index.js").SelectorSource ? S | (Key extends import("./schema/index.js").Schema<infer K extends import("./selector/index.js").SelectorSource> ? K : never) : never : never>;
|
49
|
+
richtext: <O extends import("./index.js").RichTextOptions>(options?: O) => import("./schema/index.js").Schema<import("./index.js").RichTextSource<O>>;
|
50
|
+
image: (options?: import("./schema/image.js").ImageOptions) => import("./schema/index.js").Schema<import("./index.js").ImageSource>;
|
51
|
+
literal: <T extends string>(value: T) => import("./schema/literal.js").LiteralSchema<T>;
|
52
|
+
keyOf: <Src extends import("./selector/index.js").GenericSelector<import("./source/index.js").SourceObject> & import("./module.js").ValModuleBrand>(valModule: Src) => import("./schema/index.js").Schema<Src extends import("./selector/index.js").GenericSelector<infer S extends import("./source/index.js").Source, undefined> ? S extends readonly import("./source/index.js").Source[] ? number : S extends import("./source/index.js").SourceObject ? string extends keyof S ? import("./schema/string.js").RawString : keyof S : S extends Record<string, import("./source/index.js").Source> ? import("./schema/string.js").RawString : never : never>;
|
53
|
+
record: <S extends import("./schema/index.js").Schema<import("./selector/index.js").SelectorSource>>(schema: S) => import("./schema/index.js").Schema<Record<string, import("./schema/index.js").SelectorOfSchema<S>>>;
|
54
|
+
file: (options?: import("./schema/file.js").FileOptions) => import("./schema/index.js").Schema<import("./index.js").FileSource<import("./schema/file.js").FileMetadata>>;
|
55
|
+
date: (options?: Record<string, never>) => import("./schema/date.js").DateSchema<import("./schema/string.js").RawString>;
|
86
56
|
};
|
@@ -1,14 +1,14 @@
|
|
1
1
|
import { define } from "./module.js";
|
2
2
|
import { InitSchema } from "./initSchema.js";
|
3
3
|
import { getValPath as getPath } from "./val/index.js";
|
4
|
-
import {
|
4
|
+
import { initFile } from "./source/file.js";
|
5
5
|
import { richtext } from "./source/richtext.js";
|
6
6
|
import { link } from "./source/link.js";
|
7
7
|
export type ContentConstructor = {
|
8
8
|
define: typeof define;
|
9
|
-
file: typeof
|
9
|
+
file: ReturnType<typeof initFile>;
|
10
10
|
rt: {
|
11
|
-
image: typeof
|
11
|
+
image: ReturnType<typeof initFile>;
|
12
12
|
link: typeof link;
|
13
13
|
};
|
14
14
|
richtext: typeof richtext;
|
@@ -16,11 +16,16 @@ export type ContentConstructor = {
|
|
16
16
|
export type ValConstructor = {
|
17
17
|
unstable_getPath: typeof getPath;
|
18
18
|
};
|
19
|
+
export type ConfigDirectory = `/public/${string}`;
|
19
20
|
export type ValConfig = {
|
20
21
|
project?: string;
|
21
22
|
root?: string;
|
23
|
+
files?: {
|
24
|
+
directory: ConfigDirectory;
|
25
|
+
};
|
22
26
|
gitCommit?: string;
|
23
27
|
gitBranch?: string;
|
28
|
+
defaultTheme?: "dark" | "light";
|
24
29
|
};
|
25
30
|
export type InitVal = {
|
26
31
|
c: ContentConstructor;
|
@@ -21,14 +21,18 @@ export declare function define<T extends Schema<SelectorSource>>(id: string, //
|
|
21
21
|
schema: T, source: ReplaceRawStringWithString<SelectorOfSchema<T>>): ValModule<SelectorOfSchema<T>>;
|
22
22
|
export declare function getSource(valModule: ValModule<SelectorSource>): Source;
|
23
23
|
export declare function splitModuleFilePathAndModulePath(path: SourcePath): [moduleId: ModuleFilePath, path: ModulePath];
|
24
|
-
export declare
|
24
|
+
export declare function joinModuleFilePathAndModulePath(moduleFilePath: ModuleFilePath, modulePath: ModulePath): SourcePath;
|
25
25
|
export declare function getSourceAtPath(modulePath: ModulePath, valModule: ValModule<SelectorSource> | Source): any;
|
26
26
|
export declare function resolvePath<Src extends ValModule<SelectorSource> | Source, Sch extends Schema<SelectorSource> | SerializedSchema>(path: ModulePath, valModule: Src, schema: Sch): {
|
27
27
|
path: SourcePath;
|
28
28
|
schema: Sch;
|
29
29
|
source: Src;
|
30
30
|
};
|
31
|
-
export declare function
|
31
|
+
export declare function splitModuleFilePath(input: ModuleFilePath): string[];
|
32
|
+
export declare function splitModulePath(input: ModulePath): string[];
|
33
|
+
export declare function splitJoinedSourcePaths(input: string): SourcePath[];
|
34
|
+
export declare function parentOfSourcePath(sourcePath: SourcePath): SourcePath;
|
35
|
+
export declare function patchPathToModulePath(patchPath: string[]): ModulePath;
|
32
36
|
export type SerializedModule = {
|
33
37
|
source: Json;
|
34
38
|
schema: SerializedSchema;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Schema, SelectorOfSchema, SerializedSchema } from "./index.js";
|
1
|
+
import { Schema, SchemaAssertResult, SelectorOfSchema, SerializedSchema } from "./index.js";
|
2
2
|
import { SelectorSource } from "../selector/index.js";
|
3
3
|
import { SourcePath } from "../val/index.js";
|
4
4
|
import { ValidationErrors } from "./validation/ValidationError.js";
|
@@ -7,13 +7,13 @@ export type SerializedArraySchema = {
|
|
7
7
|
item: SerializedSchema;
|
8
8
|
opt: boolean;
|
9
9
|
};
|
10
|
-
export declare class ArraySchema<T extends Schema<SelectorSource
|
10
|
+
export declare class ArraySchema<T extends Schema<SelectorSource>, Src extends SelectorOfSchema<T>[] | null> extends Schema<Src> {
|
11
11
|
readonly item: T;
|
12
12
|
readonly opt: boolean;
|
13
13
|
constructor(item: T, opt?: boolean);
|
14
|
-
validate(path: SourcePath, src:
|
15
|
-
assert(src:
|
16
|
-
nullable(): Schema<
|
14
|
+
validate(path: SourcePath, src: Src): ValidationErrors;
|
15
|
+
assert(path: SourcePath, src: unknown): SchemaAssertResult<Src>;
|
16
|
+
nullable(): Schema<Src | null>;
|
17
17
|
serialize(): SerializedArraySchema;
|
18
18
|
}
|
19
19
|
export declare const array: <S extends Schema<SelectorSource>>(schema: S) => Schema<SelectorOfSchema<S>[]>;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Schema, SerializedSchema } from "./index.js";
|
1
|
+
import { Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
|
2
2
|
import { SourcePath } from "../val/index.js";
|
3
3
|
import { ValidationErrors } from "./validation/ValidationError.js";
|
4
4
|
export type SerializedBooleanSchema = {
|
@@ -9,7 +9,7 @@ export declare class BooleanSchema<Src extends boolean | null> extends Schema<Sr
|
|
9
9
|
readonly opt: boolean;
|
10
10
|
constructor(opt?: boolean);
|
11
11
|
validate(path: SourcePath, src: Src): ValidationErrors;
|
12
|
-
assert(src:
|
12
|
+
assert(path: SourcePath, src: unknown): SchemaAssertResult<Src>;
|
13
13
|
nullable(): Schema<Src | null>;
|
14
14
|
serialize(): SerializedSchema;
|
15
15
|
}
|
@@ -1,5 +1,6 @@
|
|
1
|
-
import { Schema, SerializedSchema } from "./index.js";
|
1
|
+
import { Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
|
2
2
|
import { SourcePath } from "../val/index.js";
|
3
|
+
import { RawString } from "./string.js";
|
3
4
|
import { ValidationErrors } from "./validation/ValidationError.js";
|
4
5
|
type DateOptions = {
|
5
6
|
/**
|
@@ -25,14 +26,13 @@ export type SerializedDateSchema = {
|
|
25
26
|
export declare class DateSchema<Src extends string | null> extends Schema<Src> {
|
26
27
|
readonly options?: DateOptions | undefined;
|
27
28
|
readonly opt: boolean;
|
28
|
-
|
29
|
-
constructor(options?: DateOptions | undefined, opt?: boolean, isRaw?: boolean);
|
29
|
+
constructor(options?: DateOptions | undefined, opt?: boolean);
|
30
30
|
validate(path: SourcePath, src: Src): ValidationErrors;
|
31
|
-
assert(src:
|
31
|
+
assert(path: SourcePath, src: unknown): SchemaAssertResult<Src>;
|
32
32
|
from(from: string): DateSchema<Src>;
|
33
33
|
to(to: string): DateSchema<Src>;
|
34
34
|
nullable(): DateSchema<Src | null>;
|
35
35
|
serialize(): SerializedSchema;
|
36
36
|
}
|
37
|
-
export declare const date:
|
37
|
+
export declare const date: (options?: Record<string, never>) => DateSchema<RawString>;
|
38
38
|
export {};
|
@@ -1,16 +1,17 @@
|
|
1
1
|
import { Json } from "../Json.js";
|
2
2
|
import { FileSource } from "../source/file.js";
|
3
|
-
import { Schema, SerializedSchema } from "./index.js";
|
3
|
+
import { Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
|
4
4
|
import { SourcePath } from "../val/index.js";
|
5
5
|
import { ValidationErrors } from "./validation/ValidationError.js";
|
6
|
-
export type FileOptions =
|
6
|
+
export type FileOptions = {
|
7
|
+
accept?: string;
|
8
|
+
};
|
7
9
|
export type SerializedFileSchema = {
|
8
10
|
type: "file";
|
9
11
|
options?: FileOptions;
|
10
12
|
opt: boolean;
|
11
13
|
};
|
12
14
|
export type FileMetadata = {
|
13
|
-
sha256: string;
|
14
15
|
mimeType?: string;
|
15
16
|
};
|
16
17
|
export declare class FileSchema<Src extends FileSource<FileMetadata | undefined> | null> extends Schema<Src> {
|
@@ -18,7 +19,7 @@ export declare class FileSchema<Src extends FileSource<FileMetadata | undefined>
|
|
18
19
|
readonly opt: boolean;
|
19
20
|
constructor(options?: FileOptions | undefined, opt?: boolean);
|
20
21
|
validate(path: SourcePath, src: Src): ValidationErrors;
|
21
|
-
assert(src:
|
22
|
+
assert(path: SourcePath, src: unknown): SchemaAssertResult<Src>;
|
22
23
|
nullable(): Schema<Src | null>;
|
23
24
|
serialize(): SerializedSchema;
|
24
25
|
}
|
@@ -1,12 +1,13 @@
|
|
1
|
-
import { Schema, SerializedSchema } from "./index.js";
|
1
|
+
import { Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
|
2
2
|
import { FileSource } from "../source/file.js";
|
3
3
|
import { ImageSource } from "../source/image.js";
|
4
4
|
import { SourcePath } from "../val/index.js";
|
5
5
|
import { ValidationErrors } from "./validation/ValidationError.js";
|
6
6
|
export type ImageOptions = {
|
7
|
-
ext
|
7
|
+
ext?: ["jpg"] | ["webp"];
|
8
8
|
directory?: string;
|
9
9
|
prefix?: string;
|
10
|
+
accept?: string;
|
10
11
|
};
|
11
12
|
export type SerializedImageSchema = {
|
12
13
|
type: "image";
|
@@ -16,7 +17,6 @@ export type SerializedImageSchema = {
|
|
16
17
|
export type ImageMetadata = {
|
17
18
|
width: number;
|
18
19
|
height: number;
|
19
|
-
sha256: string;
|
20
20
|
mimeType: string;
|
21
21
|
hotspot?: {
|
22
22
|
x: number;
|
@@ -30,7 +30,7 @@ export declare class ImageSchema<Src extends FileSource<ImageMetadata | undefine
|
|
30
30
|
readonly opt: boolean;
|
31
31
|
constructor(options?: ImageOptions | undefined, opt?: boolean);
|
32
32
|
validate(path: SourcePath, src: Src): ValidationErrors;
|
33
|
-
assert(src:
|
33
|
+
assert(path: SourcePath, src: unknown): SchemaAssertResult<Src>;
|
34
34
|
nullable(): Schema<Src | null>;
|
35
35
|
serialize(): SerializedSchema;
|
36
36
|
}
|
@@ -10,17 +10,58 @@ import { SerializedNumberSchema } from "./number.js";
|
|
10
10
|
import { SerializedObjectSchema } from "./object.js";
|
11
11
|
import { SerializedRecordSchema } from "./record.js";
|
12
12
|
import { SerializedRichTextSchema } from "./richtext.js";
|
13
|
-
import { SerializedStringSchema } from "./string.js";
|
13
|
+
import { RawString, SerializedStringSchema } from "./string.js";
|
14
14
|
import { SerializedUnionSchema } from "./union.js";
|
15
15
|
import { SerializedDateSchema } from "./date.js";
|
16
16
|
import { ValidationErrors } from "./validation/ValidationError.js";
|
17
|
+
import { FileSource } from "../source/file.js";
|
18
|
+
import { GenericRichTextSourceNode, RichTextSource } from "../source/richtext.js";
|
17
19
|
export type SerializedSchema = SerializedStringSchema | SerializedLiteralSchema | SerializedBooleanSchema | SerializedNumberSchema | SerializedObjectSchema | SerializedArraySchema | SerializedUnionSchema | SerializedRichTextSchema | SerializedRecordSchema | SerializedKeyOfSchema | SerializedFileSchema | SerializedDateSchema | SerializedImageSchema;
|
20
|
+
type Primitives = number | string | boolean | null | FileSource;
|
21
|
+
export type AssertError = {
|
22
|
+
message: string;
|
23
|
+
schemaError: true;
|
24
|
+
} | {
|
25
|
+
message: string;
|
26
|
+
typeError: true;
|
27
|
+
} | {
|
28
|
+
message: string;
|
29
|
+
internalError: true;
|
30
|
+
};
|
31
|
+
export type SchemaAssertResult<Src extends SelectorSource> = {
|
32
|
+
data: Src extends RawString ? string : Src extends RichTextSource<{}> ? GenericRichTextSourceNode[] : Src extends Primitives ? Src : Src extends Array<SelectorSource> ? SelectorSource[] : Src extends {
|
33
|
+
[key: string]: SelectorSource;
|
34
|
+
} ? {
|
35
|
+
[key in keyof Src]: SelectorSource;
|
36
|
+
} : never;
|
37
|
+
success: true;
|
38
|
+
} | {
|
39
|
+
success: false;
|
40
|
+
errors: Record<SourcePath, AssertError[]>;
|
41
|
+
};
|
18
42
|
export declare abstract class Schema<Src extends SelectorSource> {
|
43
|
+
/** Validate the value of source content */
|
19
44
|
abstract validate(path: SourcePath, src: Src): ValidationErrors;
|
20
|
-
|
45
|
+
/**
|
46
|
+
* Check if the **root** **type** of source is correct.
|
47
|
+
*
|
48
|
+
* The difference between assert and validate is:
|
49
|
+
* - assert verifies that the root **type** of the source is correct (it does not recurse down). Therefore, assert can be used as a runtime type check.
|
50
|
+
* - validate checks the **value** of the source in addition to the type. It recurses down the source.
|
51
|
+
*
|
52
|
+
* For example assert fails for a StringSchema if the source is not a string,
|
53
|
+
* it will not fail if the length is not correct.
|
54
|
+
* Validate will check the length and all other constraints.
|
55
|
+
*
|
56
|
+
* Assert is useful if you have a generic schema and need to make sure the root type is valid.
|
57
|
+
* When using assert, you must assert recursively if you want to verify the entire source.
|
58
|
+
* For example, if you have an object schema, you must assert each key / value pair manually.
|
59
|
+
*/
|
60
|
+
abstract assert(path: SourcePath, src: unknown): SchemaAssertResult<Src>;
|
21
61
|
abstract nullable(): Schema<Src | null>;
|
22
62
|
abstract serialize(): SerializedSchema;
|
23
63
|
/** MUTATES! since internal and perf sensitive */
|
24
|
-
protected appendValidationError(current: ValidationErrors, path: SourcePath, message: string, value
|
64
|
+
protected appendValidationError(current: ValidationErrors, path: SourcePath, message: string, value: unknown): ValidationErrors;
|
25
65
|
}
|
26
66
|
export type SelectorOfSchema<T extends Schema<SelectorSource>> = T extends Schema<infer Src> ? Src : never;
|
67
|
+
export {};
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import { Schema, SerializedSchema } from "./index.js";
|
1
|
+
import { Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
|
2
2
|
import { ValModuleBrand } from "../module.js";
|
3
3
|
import { GenericSelector } from "../selector/index.js";
|
4
|
-
import { Source,
|
4
|
+
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";
|
@@ -10,18 +10,18 @@ export type SerializedKeyOfSchema = {
|
|
10
10
|
path: SourcePath;
|
11
11
|
schema: SerializedSchema;
|
12
12
|
opt: boolean;
|
13
|
-
values: "string" |
|
13
|
+
values: "string" | string[];
|
14
14
|
};
|
15
|
-
type KeyOfSelector<Sel extends GenericSelector<
|
16
|
-
export declare class KeyOfSchema<Sel extends GenericSelector<
|
15
|
+
type KeyOfSelector<Sel extends GenericSelector<SourceObject>> = Sel extends GenericSelector<infer S> ? S extends readonly Source[] ? number : S extends SourceObject ? string extends keyof S ? RawString : keyof S : S extends Record<string, Source> ? RawString : never : never;
|
16
|
+
export declare class KeyOfSchema<Sel extends GenericSelector<SourceObject>, Src extends KeyOfSelector<Sel> | null> extends Schema<Src> {
|
17
17
|
readonly schema?: SerializedSchema | undefined;
|
18
18
|
readonly sourcePath?: SourcePath | undefined;
|
19
19
|
readonly opt: boolean;
|
20
20
|
constructor(schema?: SerializedSchema | undefined, sourcePath?: SourcePath | undefined, opt?: boolean);
|
21
|
-
validate(path: SourcePath, src:
|
22
|
-
assert(src:
|
23
|
-
nullable(): Schema<
|
21
|
+
validate(path: SourcePath, src: Src): ValidationErrors;
|
22
|
+
assert(path: SourcePath, src: unknown): SchemaAssertResult<Src>;
|
23
|
+
nullable(): Schema<Src | null>;
|
24
24
|
serialize(): SerializedSchema;
|
25
25
|
}
|
26
|
-
export declare const keyOf: <Src extends GenericSelector<SourceObject
|
26
|
+
export declare const keyOf: <Src extends GenericSelector<SourceObject> & ValModuleBrand>(valModule: Src) => Schema<KeyOfSelector<Src>>;
|
27
27
|
export {};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Schema, SerializedSchema } from "./index.js";
|
1
|
+
import { Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
|
2
2
|
import { SourcePath } from "../val/index.js";
|
3
3
|
import { ValidationErrors } from "./validation/ValidationError.js";
|
4
4
|
export type SerializedLiteralSchema = {
|
@@ -11,8 +11,8 @@ export declare class LiteralSchema<Src extends string | null> extends Schema<Src
|
|
11
11
|
readonly opt: boolean;
|
12
12
|
constructor(value: string, opt?: boolean);
|
13
13
|
validate(path: SourcePath, src: Src): ValidationErrors;
|
14
|
-
assert(src:
|
14
|
+
assert(path: SourcePath, src: unknown): SchemaAssertResult<Src>;
|
15
15
|
nullable(): Schema<Src | null>;
|
16
16
|
serialize(): SerializedSchema;
|
17
17
|
}
|
18
|
-
export declare const literal: <T extends string>(value: T) =>
|
18
|
+
export declare const literal: <T extends string>(value: T) => LiteralSchema<T>;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Schema, SerializedSchema } from "./index.js";
|
1
|
+
import { Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
|
2
2
|
import { SourcePath } from "../val/index.js";
|
3
3
|
import { ValidationErrors } from "./validation/ValidationError.js";
|
4
4
|
type NumberOptions = {
|
@@ -15,8 +15,8 @@ export declare class NumberSchema<Src extends number | null> extends Schema<Src>
|
|
15
15
|
readonly opt: boolean;
|
16
16
|
constructor(options?: NumberOptions | undefined, opt?: boolean);
|
17
17
|
validate(path: SourcePath, src: Src): ValidationErrors;
|
18
|
-
assert(src:
|
19
|
-
nullable(): Schema<Src
|
18
|
+
assert(path: SourcePath, src: unknown): SchemaAssertResult<Src>;
|
19
|
+
nullable(): Schema<Src>;
|
20
20
|
serialize(): SerializedSchema;
|
21
21
|
}
|
22
22
|
export declare const number: (options?: NumberOptions) => Schema<number>;
|