@valbuild/core 0.91.4 → 0.93.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/LICENSE.md ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2025 Fredrik Ekholdt and Blank AS
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -73,6 +73,7 @@ declare const Internal: {
73
73
  splitModuleFilePathAndModulePath: typeof splitModuleFilePathAndModulePath;
74
74
  joinModuleFilePathAndModulePath: typeof joinModuleFilePathAndModulePath;
75
75
  nextAppRouter: import("./router.js").ValRouter;
76
+ externalPageRouter: import("./router.js").ValRouter;
76
77
  remote: {
77
78
  createRemoteRef: typeof createRemoteRef;
78
79
  getValidationBasis: typeof getValidationBasis;
@@ -95,7 +96,30 @@ declare const Internal: {
95
96
  [k: string]: string;
96
97
  };
97
98
  ModuleFilePathSep: string;
98
- notFileOp: (op: Operation) => boolean;
99
+ notFileOp: (op: Operation) => op is {
100
+ op: "add";
101
+ path: string[];
102
+ value: import("./patch/index.js").JSONValue;
103
+ } | {
104
+ op: "remove";
105
+ path: import("./fp/array.js").NonEmptyArray<string>;
106
+ } | {
107
+ op: "replace";
108
+ path: string[];
109
+ value: import("./patch/index.js").JSONValue;
110
+ } | {
111
+ op: "move";
112
+ from: import("./fp/array.js").NonEmptyArray<string>;
113
+ path: string[];
114
+ } | {
115
+ op: "copy";
116
+ from: string[];
117
+ path: string[];
118
+ } | {
119
+ op: "test";
120
+ path: string[];
121
+ value: import("./patch/index.js").JSONValue;
122
+ };
99
123
  isFileOp: (op: Operation) => op is {
100
124
  op: "file";
101
125
  path: string[];
@@ -198,62 +198,32 @@ export type InitSchema = {
198
198
  readonly router: typeof router;
199
199
  };
200
200
  export declare function initSchema(): {
201
- string: <T extends string>(options?: Record<string, never> | undefined) => import("./schema/string.js").StringSchema<T>;
201
+ string: <T extends string>(options?: Record<string, never>) => import("./schema/string.js").StringSchema<T>;
202
202
  boolean: () => import("./schema/boolean.js").BooleanSchema<boolean>;
203
203
  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>[]>;
204
204
  object: <Props extends {
205
205
  [key: string]: import("./schema/index.js").Schema<import("./selector/index.js").SelectorSource>;
206
206
  } & {
207
- valPath?: undefined;
208
- val?: undefined;
209
- _type?: undefined;
210
- _ref?: undefined;
211
- andThen?: undefined;
212
- assert?: undefined;
213
- fold?: undefined;
207
+ valPath?: never;
208
+ val?: never;
209
+ _type?: never;
210
+ _ref?: never;
211
+ andThen?: never;
212
+ assert?: never;
213
+ fold?: never;
214
214
  }>(schema: Props) => import("./schema/object.js").ObjectSchema<Props, { [key in keyof Props]: import("./schema/index.js").SelectorOfSchema<Props[key]>; }>;
215
215
  number: (options?: {
216
- max?: number | undefined;
217
- min?: number | undefined;
218
- } | undefined) => import("./schema/number.js").NumberSchema<number>;
219
- union: <Key extends string | import("./schema/index.js").Schema<string>, T_1 extends import("./schema/index.js").Schema<Key extends string ? {
220
- [x: string]: import("./source/index.js").Source;
221
- } & {
222
- fold?: undefined;
223
- assert?: undefined;
224
- andThen?: undefined;
225
- _ref?: undefined;
226
- _type?: undefined;
227
- val?: undefined;
228
- valPath?: undefined;
229
- } & { [k in Key]: string; } : Key extends import("./schema/index.js").Schema<string> ? string : unknown>[]>(key: Key, ...objects: T_1) => import("./schema/union.js").UnionSchema<Key, T_1, 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>;
230
- richtext: <O extends Partial<{
231
- style: Partial<{
232
- bold: boolean;
233
- italic: boolean;
234
- lineThrough: boolean;
235
- }>;
236
- block: Partial<{
237
- h1: boolean;
238
- h2: boolean;
239
- h3: boolean;
240
- h4: boolean;
241
- h5: boolean;
242
- h6: boolean;
243
- ul: boolean;
244
- ol: boolean;
245
- }>;
246
- inline: Partial<{
247
- a: boolean;
248
- img: boolean | import("./schema/image.js").ImageSchema<import("./index.js").ImageSource | import("./index.js").RemoteSource<import("./schema/image.js").ImageMetadata>>;
249
- }>;
250
- }>>(options?: O | undefined) => import("./schema/richtext.js").RichTextSchema<O, import("./index.js").RichTextSource<O>>;
251
- image: (options?: import("./schema/image.js").ImageOptions | undefined) => import("./schema/image.js").ImageSchema<import("./index.js").ImageSource>;
252
- literal: <T_2 extends string>(value: T_2) => import("./schema/literal.js").LiteralSchema<T_2>;
253
- keyOf: <Src extends import("./selector/index.js").GenericSelector<import("./source/index.js").SourceObject, undefined> & import("./module.js").ValModuleBrand>(valModule: Src) => import("./schema/keyOf.js").KeyOfSchema<Src, 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>;
216
+ max?: number;
217
+ min?: number;
218
+ }) => import("./schema/number.js").NumberSchema<number>;
219
+ 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/union.js").UnionSchema<Key, T, 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>;
220
+ richtext: <O extends import("./index.js").RichTextOptions>(options?: O) => import("./schema/richtext.js").RichTextSchema<O, import("./index.js").RichTextSource<O>>;
221
+ image: (options?: import("./schema/image.js").ImageOptions) => import("./schema/image.js").ImageSchema<import("./index.js").ImageSource>;
222
+ literal: <T extends string>(value: T) => import("./schema/literal.js").LiteralSchema<T>;
223
+ keyOf: <Src extends import("./selector/index.js").GenericSelector<import("./source/index.js").SourceObject> & import("./module.js").ValModuleBrand>(valModule: Src) => import("./schema/keyOf.js").KeyOfSchema<Src, 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>;
254
224
  record: typeof record;
255
- file: (options?: import("./schema/file.js").FileOptions | undefined) => import("./schema/file.js").FileSchema<import("./index.js").FileSource<import("./schema/file.js").FileMetadata>>;
256
- date: (options?: Record<string, never> | undefined) => import("./schema/date.js").DateSchema<import("./schema/string.js").RawString>;
257
- route: <T_3 extends string>(options?: Record<string, never> | undefined) => import("./schema/route.js").RouteSchema<T_3>;
225
+ file: (options?: import("./schema/file.js").FileOptions) => import("./schema/file.js").FileSchema<import("./index.js").FileSource<import("./schema/file.js").FileMetadata>>;
226
+ date: (options?: Record<string, never>) => import("./schema/date.js").DateSchema<import("./schema/string.js").RawString>;
227
+ route: <T extends string>(options?: Record<string, never>) => import("./schema/route.js").RouteSchema<T>;
258
228
  router: typeof router;
259
229
  };
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import { Buffer } from "buffer";
4
2
  export declare function hashToRemoteFileHash(hash: string): string;
5
3
  export declare function getFileHash(text: Buffer): string;
@@ -1,4 +1,5 @@
1
1
  import { ModuleFilePath } from "./val/index.js";
2
+ export declare const externalPageRouter: ValRouter;
2
3
  export type RouteValidationError = {
3
4
  error: {
4
5
  message: string;
@@ -36,5 +36,5 @@ export declare class KeyOfSchema<Sel extends GenericSelector<SourceObject>, Src
36
36
  protected executeSerialize(): SerializedSchema;
37
37
  protected executeRender(): ReifiedRender;
38
38
  }
39
- export declare const keyOf: <Src extends GenericSelector<SourceObject, undefined> & ValModuleBrand>(valModule: Src) => KeyOfSchema<Src, KeyOfSelector<Src>>;
39
+ export declare const keyOf: <Src extends GenericSelector<SourceObject> & ValModuleBrand>(valModule: Src) => KeyOfSchema<Src, KeyOfSelector<Src>>;
40
40
  export {};
@@ -1,9 +1,7 @@
1
1
  import { CustomValidateFunction, Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
2
2
  import { ReifiedRender } from "../render.js";
3
- import { ImageSource } from "../source/image.js";
4
3
  import { RichTextSource, RichTextOptions, SerializedRichTextOptions } from "../source/richtext.js";
5
4
  import { SourcePath } from "../val/index.js";
6
- import { ImageSchema } from "./image.js";
7
5
  import { ValidationErrors } from "./validation/ValidationError.js";
8
6
  type ValidationOptions = {
9
7
  maxLength?: number;
@@ -31,25 +29,5 @@ export declare class RichTextSchema<O extends RichTextOptions, Src extends RichT
31
29
  protected executeSerialize(): SerializedSchema;
32
30
  protected executeRender(): ReifiedRender;
33
31
  }
34
- export declare const richtext: <O extends Partial<{
35
- style: Partial<{
36
- bold: boolean;
37
- italic: boolean;
38
- lineThrough: boolean;
39
- }>;
40
- block: Partial<{
41
- h1: boolean;
42
- h2: boolean;
43
- h3: boolean;
44
- h4: boolean;
45
- h5: boolean;
46
- h6: boolean;
47
- ul: boolean;
48
- ol: boolean;
49
- }>;
50
- inline: Partial<{
51
- a: boolean;
52
- img: boolean | ImageSchema<ImageSource | import("../index.js").RemoteSource<import("./image.js").ImageMetadata>>;
53
- }>;
54
- }>>(options?: O | undefined) => RichTextSchema<O, RichTextSource<O>>;
32
+ export declare const richtext: <O extends RichTextOptions>(options?: O) => RichTextSchema<O, RichTextSource<O>>;
55
33
  export {};
@@ -39,15 +39,5 @@ export declare class UnionSchema<Key extends string | Schema<string>, T extends
39
39
  constructor(key: Key, items: T, opt?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[]);
40
40
  protected executeRender(sourcePath: SourcePath | ModuleFilePath, src: Src): ReifiedRender;
41
41
  }
42
- export declare const union: <Key extends string | Schema<string>, T extends Schema<Key extends string ? {
43
- [x: string]: import("../source/index.js").Source;
44
- } & {
45
- fold?: undefined;
46
- assert?: undefined;
47
- andThen?: undefined;
48
- _ref?: undefined;
49
- _type?: undefined;
50
- val?: undefined;
51
- valPath?: undefined;
52
- } & { [k in Key]: string; } : Key extends Schema<string> ? string : unknown>[]>(key: Key, ...objects: T) => UnionSchema<Key, T, SourceOf<Key, T>>;
42
+ export declare const union: <Key extends string | Schema<string>, T extends Schema<Key extends string ? SourceObject & { [k in Key]: string; } : Key extends Schema<string> ? string : unknown>[]>(key: Key, ...objects: T) => UnionSchema<Key, T, SourceOf<Key, T>>;
53
43
  export {};
@@ -22,7 +22,7 @@ export type FileSource<Metadata extends FileMetadata | undefined = FileMetadata
22
22
  export declare const initFile: (config?: ValConfig) => {
23
23
  <Metadata extends {
24
24
  readonly [key: string]: Json;
25
- }>(ref: `/public/val/${string}`, metadata: Metadata): FileSource<Metadata>;
26
- (ref: `/public/val/${string}`, metadata?: undefined): FileSource<undefined>;
25
+ }>(ref: `${"/public/val"}/${string}`, metadata: Metadata): FileSource<Metadata>;
26
+ (ref: `${"/public/val"}/${string}`, metadata?: undefined): FileSource<undefined>;
27
27
  };
28
28
  export declare function isFile(obj: unknown): obj is FileSource;
@@ -14,6 +14,6 @@ export type ImageSource<Metadata extends ImageMetadata | undefined = ImageMetada
14
14
  readonly patch_id?: string;
15
15
  };
16
16
  export declare const initImage: (config?: ValConfig) => {
17
- (ref: `/public/val/${string}`, metadata: ImageMetadata): ImageSource<ImageMetadata>;
18
- (ref: `/public/val/${string}`, metadata?: undefined): ImageSource<undefined>;
17
+ (ref: `${"/public/val"}/${string}`, metadata: ImageMetadata): ImageSource<ImageMetadata>;
18
+ (ref: `${"/public/val"}/${string}`, metadata?: undefined): ImageSource<undefined>;
19
19
  };
@@ -1,4 +1,6 @@
1
1
  import { ImageMetadata, ImageSchema, SerializedImageSchema } from "../schema/image.js";
2
+ import { RouteSchema, SerializedRouteSchema } from "../schema/route.js";
3
+ import { StringSchema, SerializedStringSchema } from "../schema/string.js";
2
4
  import { FileSource } from "./file.js";
3
5
  import { ImageSource } from "./image.js";
4
6
  import { RemoteSource } from "./remote.js";
@@ -19,7 +21,7 @@ export type RichTextOptions = Partial<{
19
21
  ol: boolean;
20
22
  }>;
21
23
  inline: Partial<{
22
- a: boolean;
24
+ a: boolean | RouteSchema<string> | StringSchema<string>;
23
25
  img: boolean | ImageSchema<ImageSource | RemoteSource<ImageMetadata>>;
24
26
  }>;
25
27
  }>;
@@ -40,7 +42,7 @@ export type SerializedRichTextOptions = Partial<{
40
42
  ol: boolean;
41
43
  }>;
42
44
  inline: Partial<{
43
- a: boolean;
45
+ a: boolean | SerializedRouteSchema | SerializedStringSchema;
44
46
  img: boolean | SerializedImageSchema;
45
47
  }>;
46
48
  }>;
@@ -100,7 +102,7 @@ type LinkTagNode<O extends RichTextOptions> = {
100
102
  href: string;
101
103
  children: (string | SpanNode<O> | ImageNode<O> | CustomInlineNode<O>)[];
102
104
  };
103
- export type LinkNode<O extends RichTextOptions> = NonNullable<O["inline"]>["a"] extends true ? LinkTagNode<O> : never;
105
+ export type LinkNode<O extends RichTextOptions> = NonNullable<O["inline"]>["a"] extends true ? LinkTagNode<O> : NonNullable<O["inline"]>["a"] extends RouteSchema<string> | StringSchema<string> ? LinkTagNode<O> : never;
104
106
  type ListItemTagNode<O extends RichTextOptions> = {
105
107
  tag: "li";
106
108
  children: (ParagraphNode<O> | UnorderedListNode<O> | OrderedListNode<O>)[];