@valbuild/core 0.64.0 → 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.
Files changed (39) hide show
  1. package/dist/declarations/src/expr/expr.d.ts +2 -2
  2. package/dist/declarations/src/expr/parser.d.ts +2 -2
  3. package/dist/declarations/src/index.d.ts +38 -5
  4. package/dist/declarations/src/initSchema.d.ts +19 -49
  5. package/dist/declarations/src/initVal.d.ts +8 -3
  6. package/dist/declarations/src/module.d.ts +6 -2
  7. package/dist/declarations/src/schema/file.d.ts +0 -1
  8. package/dist/declarations/src/schema/image.d.ts +0 -1
  9. package/dist/declarations/src/schema/keyOf.d.ts +5 -5
  10. package/dist/declarations/src/schema/richtext.d.ts +1 -21
  11. package/dist/declarations/src/schema/union.d.ts +13 -14
  12. package/dist/declarations/src/source/file.d.ts +7 -4
  13. package/dist/{index-41223963.cjs.prod.js → index-48930c58.cjs.dev.js} +267 -243
  14. package/dist/{index-4240c6a6.esm.js → index-65ec1d74.esm.js} +267 -244
  15. package/dist/{index-d384ec25.cjs.dev.js → index-f1a23e6c.cjs.prod.js} +267 -243
  16. package/dist/{result-a8316efa.esm.js → result-168dfc1d.esm.js} +42 -46
  17. package/dist/{result-48320acd.cjs.dev.js → result-787e35f6.cjs.prod.js} +41 -45
  18. package/dist/{result-26f67b40.cjs.prod.js → result-bb1f436e.cjs.dev.js} +41 -45
  19. package/dist/valbuild-core.cjs.d.ts +2 -2
  20. package/dist/valbuild-core.cjs.dev.js +3 -2
  21. package/dist/valbuild-core.cjs.prod.js +3 -2
  22. package/dist/valbuild-core.esm.js +2 -2
  23. package/expr/dist/valbuild-core-expr.cjs.d.ts +2 -2
  24. package/expr/dist/valbuild-core-expr.cjs.dev.js +2 -2
  25. package/expr/dist/valbuild-core-expr.cjs.prod.js +2 -2
  26. package/expr/dist/valbuild-core-expr.esm.js +2 -2
  27. package/fp/dist/valbuild-core-fp.cjs.d.ts +2 -2
  28. package/fp/dist/valbuild-core-fp.cjs.dev.js +1 -1
  29. package/fp/dist/valbuild-core-fp.cjs.prod.js +1 -1
  30. package/fp/dist/valbuild-core-fp.esm.js +1 -1
  31. package/package.json +1 -1
  32. package/patch/dist/valbuild-core-patch.cjs.d.ts +2 -2
  33. package/patch/dist/valbuild-core-patch.cjs.dev.js +8 -9
  34. package/patch/dist/valbuild-core-patch.cjs.prod.js +8 -9
  35. package/patch/dist/valbuild-core-patch.esm.js +9 -10
  36. package/dist/valbuild-core.cjs.d.ts.map +0 -1
  37. package/expr/dist/valbuild-core-expr.cjs.d.ts.map +0 -1
  38. package/fp/dist/valbuild-core-fp.cjs.d.ts.map +0 -1
  39. 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, (number | undefined)?] | undefined;
2
+ readonly span?: [number, number?] | undefined;
3
3
  abstract type: "StringLiteral" | "Sym" | "StringTemplate" | "Call";
4
4
  abstract transpile(): string;
5
- constructor(span?: [number, (number | undefined)?] | undefined);
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, (number | undefined)?] | undefined;
6
- constructor(message: string, span?: [number, (number | undefined)?] | undefined);
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";
@@ -21,7 +21,9 @@ export { FILE_REF_PROP, FILE_REF_SUBTYPE_TAG } from "./source/file.js";
21
21
  export { VAL_EXTENSION, type SourceArray } from "./source/index.js";
22
22
  export { derefPatch } from "./patch/deref.js";
23
23
  export { type SelectorSource, type SelectorOf, GenericSelector, } from "./selector/index.js";
24
- 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 };
25
27
  import { getSchema } from "./selector/index.js";
26
28
  import { ModulePath, getValPath, isVal } from "./val/index.js";
27
29
  import { convertFileSource } from "./schema/file.js";
@@ -30,6 +32,8 @@ import { getVal } from "./future/fetchVal.js";
30
32
  import { Operation } from "./patch/index.js";
31
33
  import { initSchema } from "./initSchema.js";
32
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";
33
37
  export { type SerializedArraySchema, ArraySchema } from "./schema/array.js";
34
38
  export { type SerializedObjectSchema, ObjectSchema } from "./schema/object.js";
35
39
  export { type SerializedRecordSchema, RecordSchema } from "./schema/record.js";
@@ -41,7 +45,7 @@ export { type SerializedFileSchema, FileSchema } from "./schema/file.js";
41
45
  export { type SerializedDateSchema, DateSchema } from "./schema/date.js";
42
46
  export { type SerializedKeyOfSchema, KeyOfSchema } from "./schema/keyOf.js";
43
47
  export { type SerializedRichTextSchema, RichTextSchema, } from "./schema/richtext.js";
44
- export { type SerializedUnionSchema, UnionSchema } from "./schema/union.js";
48
+ export { type SerializedUnionSchema, UnionSchema, type SerializedStringUnionSchema, type SerializedObjectUnionSchema, } from "./schema/union.js";
45
49
  export { type SerializedLiteralSchema, LiteralSchema } from "./schema/literal.js";
46
50
  export { deserializeSchema } from "./schema/deserialize.js";
47
51
  export declare const FATAL_ERROR_TYPES: readonly ["no-schema", "no-source", "invalid-id", "no-module", "invalid-patch"];
@@ -57,6 +61,7 @@ declare const Internal: {
57
61
  getSource: typeof getSource;
58
62
  resolvePath: typeof resolvePath;
59
63
  splitModuleFilePathAndModulePath: typeof splitModuleFilePathAndModulePath;
64
+ joinModuleFilePathAndModulePath: typeof joinModuleFilePathAndModulePath;
60
65
  isVal: typeof isVal;
61
66
  createValPathOfItem: typeof createValPathOfItem;
62
67
  getSHA256Hash: (bits: Uint8Array) => string;
@@ -69,7 +74,30 @@ declare const Internal: {
69
74
  [k: string]: string;
70
75
  };
71
76
  ModuleFilePathSep: string;
72
- notFileOp: (op: Operation) => boolean;
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
+ };
73
101
  isFileOp: (op: Operation) => op is {
74
102
  op: "file";
75
103
  path: string[];
@@ -78,9 +106,14 @@ declare const Internal: {
78
106
  };
79
107
  createPatchJSONPath: (modulePath: ModulePath) => string;
80
108
  createPatchPath: (modulePath: ModulePath) => string[];
81
- patchPathToModulePath: (patchPath: string[]) => ModulePath;
109
+ splitModulePath: typeof splitModulePath;
110
+ splitModuleFilePath: typeof splitModuleFilePath;
111
+ splitJoinedSourcePaths: typeof splitJoinedSourcePaths;
112
+ parentOfSourcePath: typeof parentOfSourcePath;
113
+ patchPathToModulePath: typeof patchPathToModulePath;
82
114
  VAL_ENABLE_COOKIE_NAME: "val_enable";
83
115
  VAL_STATE_COOKIE: "val_state";
84
116
  VAL_SESSION_COOKIE: "val_session";
117
+ createFilename: (data: string | null, filename: string | null, metadata: FileMetadata | ImageMetadata | undefined, sha256: string) => string | null;
85
118
  };
86
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> | undefined) => import("./schema/string.js").StringSchema<T>;
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?: undefined;
37
- val?: undefined;
38
- _type?: undefined;
39
- _ref?: undefined;
40
- andThen?: undefined;
41
- assert?: undefined;
42
- fold?: undefined;
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 | undefined;
46
- min?: number | undefined;
47
- } | undefined) => import("./schema/index.js").Schema<number>;
48
- union: <Key extends string | import("./schema/index.js").Schema<string>, T_1 extends import("./schema/index.js").Schema<Key extends string ? {
49
- [x: string]: import("./source/index.js").Source;
50
- } & {
51
- fold?: undefined;
52
- assert?: undefined;
53
- andThen?: undefined;
54
- _ref?: undefined;
55
- _type?: undefined;
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/literal.js").LiteralSchema<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: (options?: Record<string, never> | undefined) => import("./schema/date.js").DateSchema<import("./schema/string.js").RawString>;
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 { file } from "./source/file.js";
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 file;
9
+ file: ReturnType<typeof initFile>;
10
10
  rt: {
11
- image: typeof file;
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 const ModuleFilePathSep = "?p=";
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 parsePath(input: ModulePath): string[];
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;
@@ -12,7 +12,6 @@ export type SerializedFileSchema = {
12
12
  opt: boolean;
13
13
  };
14
14
  export type FileMetadata = {
15
- sha256: string;
16
15
  mimeType?: string;
17
16
  };
18
17
  export declare class FileSchema<Src extends FileSource<FileMetadata | undefined> | null> extends Schema<Src> {
@@ -17,7 +17,6 @@ export type SerializedImageSchema = {
17
17
  export type ImageMetadata = {
18
18
  width: number;
19
19
  height: number;
20
- sha256: string;
21
20
  mimeType: string;
22
21
  hotspot?: {
23
22
  x: number;
@@ -1,7 +1,7 @@
1
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, SourceArray, SourceObject } from "../source/index.js";
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,10 +10,10 @@ export type SerializedKeyOfSchema = {
10
10
  path: SourcePath;
11
11
  schema: SerializedSchema;
12
12
  opt: boolean;
13
- values: "string" | "number" | string[];
13
+ values: "string" | string[];
14
14
  };
15
- type KeyOfSelector<Sel extends GenericSelector<SourceArray | 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<SourceArray | SourceObject>, Src extends KeyOfSelector<Sel> | null> extends Schema<Src> {
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;
@@ -23,5 +23,5 @@ export declare class KeyOfSchema<Sel extends GenericSelector<SourceArray | Sourc
23
23
  nullable(): Schema<Src | null>;
24
24
  serialize(): SerializedSchema;
25
25
  }
26
- export declare const keyOf: <Src extends GenericSelector<SourceObject | SourceArray, undefined> & ValModuleBrand>(valModule: Src) => Schema<KeyOfSelector<Src>>;
26
+ export declare const keyOf: <Src extends GenericSelector<SourceObject> & ValModuleBrand>(valModule: Src) => Schema<KeyOfSelector<Src>>;
27
27
  export {};
@@ -17,24 +17,4 @@ export declare class RichTextSchema<O extends RichTextOptions, Src extends RichT
17
17
  nullable(): Schema<Src | null>;
18
18
  serialize(): SerializedSchema;
19
19
  }
20
- export declare const richtext: <O extends Partial<{
21
- style: Partial<{
22
- bold: boolean;
23
- italic: boolean;
24
- lineThrough: boolean;
25
- }>;
26
- block: Partial<{
27
- h1: boolean;
28
- h2: boolean;
29
- h3: boolean;
30
- h4: boolean;
31
- h5: boolean;
32
- h6: boolean;
33
- ul: boolean;
34
- ol: boolean;
35
- }>;
36
- inline: Partial<{
37
- a: boolean;
38
- img: boolean;
39
- }>;
40
- }>>(options?: O | undefined) => Schema<RichTextSource<O>>;
20
+ export declare const richtext: <O extends RichTextOptions>(options?: O) => Schema<RichTextSource<O>>;
@@ -2,11 +2,20 @@ import { Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
2
2
  import { SelectorSource } from "../selector/index.js";
3
3
  import { SourceObject } from "../source/index.js";
4
4
  import { SourcePath } from "../val/index.js";
5
+ import { SerializedLiteralSchema } from "./literal.js";
6
+ import { SerializedObjectSchema } from "./object.js";
5
7
  import { ValidationErrors } from "./validation/ValidationError.js";
6
- export type SerializedUnionSchema = {
8
+ export type SerializedUnionSchema = SerializedStringUnionSchema | SerializedObjectUnionSchema;
9
+ export type SerializedStringUnionSchema = {
7
10
  type: "union";
8
- key: string | SerializedSchema;
9
- items: SerializedSchema[];
11
+ key: SerializedLiteralSchema;
12
+ items: SerializedLiteralSchema[];
13
+ opt: boolean;
14
+ };
15
+ export type SerializedObjectUnionSchema = {
16
+ type: "union";
17
+ key: string;
18
+ items: SerializedObjectSchema[];
10
19
  opt: boolean;
11
20
  };
12
21
  type SourceOf<Key extends string | Schema<string>, T extends Schema<Key extends string ? SourceObject & {
@@ -24,15 +33,5 @@ export declare class UnionSchema<Key extends string | Schema<string>, T extends
24
33
  serialize(): SerializedSchema;
25
34
  constructor(key: Key, items: T, opt?: boolean);
26
35
  }
27
- export declare const union: <Key extends string | Schema<string>, T extends Schema<Key extends string ? {
28
- [x: string]: import("../source/index.js").Source;
29
- } & {
30
- fold?: undefined;
31
- assert?: undefined;
32
- andThen?: undefined;
33
- _ref?: undefined;
34
- _type?: undefined;
35
- val?: undefined;
36
- valPath?: undefined;
37
- } & { [k in Key]: string; } : Key extends Schema<string> ? string : unknown>[]>(key: Key, ...objects: T) => Schema<SourceOf<Key, T>>;
36
+ 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) => Schema<SourceOf<Key, T>>;
38
37
  export {};
@@ -1,4 +1,5 @@
1
1
  import { VAL_EXTENSION } from "./index.js";
2
+ import { ValConfig } from "../initVal.js";
2
3
  import { Json } from "../Json.js";
3
4
  export declare const FILE_REF_PROP: "_ref";
4
5
  export declare const FILE_REF_SUBTYPE_TAG: "_tag";
@@ -18,8 +19,10 @@ export type FileSource<Metadata extends FileMetadata | undefined = FileMetadata
18
19
  readonly metadata?: Metadata;
19
20
  readonly patch_id?: string;
20
21
  };
21
- export declare function file<Metadata extends {
22
- readonly [key: string]: Json;
23
- }>(ref: `/public/${string}`, metadata: Metadata): FileSource<Metadata>;
24
- export declare function file(ref: `/public/${string}`, metadata?: undefined): FileSource<undefined>;
22
+ export declare const initFile: (config?: ValConfig) => {
23
+ <Metadata extends {
24
+ readonly [key: string]: Json;
25
+ }>(ref: `${`/public/${string}`}/${string}`, metadata: Metadata): FileSource<Metadata>;
26
+ (ref: `${`/public/${string}`}/${string}`, metadata?: undefined): FileSource<undefined>;
27
+ };
25
28
  export declare function isFile(obj: unknown): obj is FileSource;