@valbuild/core 0.15.0 → 0.17.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 (133) hide show
  1. package/ROADMAP.md +106 -0
  2. package/dist/declarations/src/ValApi.d.ts +26 -0
  3. package/dist/declarations/src/expr/eval.d.ts +1 -1
  4. package/dist/declarations/src/future/fetchVal.d.ts +5 -0
  5. package/dist/declarations/src/index.d.ts +38 -9
  6. package/dist/declarations/src/initSchema.d.ts +2 -10
  7. package/dist/declarations/src/initVal.d.ts +3 -21
  8. package/dist/declarations/src/module.d.ts +2 -14
  9. package/dist/declarations/src/patch/index.d.ts +1 -1
  10. package/dist/declarations/src/patch/util.d.ts +2 -0
  11. package/dist/declarations/src/schema/array.d.ts +3 -2
  12. package/dist/declarations/src/schema/boolean.d.ts +3 -2
  13. package/dist/declarations/src/schema/image.d.ts +4 -3
  14. package/dist/declarations/src/schema/index.d.ts +8 -7
  15. package/dist/declarations/src/schema/keyOf.d.ts +23 -0
  16. package/dist/declarations/src/schema/literal.d.ts +3 -2
  17. package/dist/declarations/src/schema/number.d.ts +3 -2
  18. package/dist/declarations/src/schema/object.d.ts +3 -2
  19. package/dist/declarations/src/schema/record.d.ts +19 -0
  20. package/dist/declarations/src/schema/richtext.d.ts +3 -2
  21. package/dist/declarations/src/schema/string.d.ts +3 -2
  22. package/dist/declarations/src/schema/union.d.ts +4 -2
  23. package/dist/declarations/src/schema/validation/ValidationError.d.ts +14 -0
  24. package/dist/declarations/src/schema/validation/ValidationFix.d.ts +2 -0
  25. package/dist/declarations/src/selector/SelectorProxy.d.ts +7 -0
  26. package/dist/declarations/src/selector/array.d.ts +2 -13
  27. package/dist/declarations/src/selector/file.d.ts +1 -4
  28. package/dist/declarations/src/selector/future/array.d.ts +17 -0
  29. package/dist/declarations/src/selector/future/boolean.d.ts +2 -0
  30. package/dist/declarations/src/selector/future/file.d.ts +9 -0
  31. package/dist/declarations/src/selector/{i18n.d.ts → future/i18n.d.ts} +2 -2
  32. package/dist/declarations/src/selector/future/index.d.ts +81 -0
  33. package/dist/declarations/src/selector/future/number.d.ts +2 -0
  34. package/dist/declarations/src/selector/future/object.d.ts +10 -0
  35. package/dist/declarations/src/selector/future/primitive.d.ts +9 -0
  36. package/dist/declarations/src/selector/{remote.d.ts → future/remote.d.ts} +1 -1
  37. package/dist/declarations/src/selector/future/string.d.ts +2 -0
  38. package/dist/declarations/src/selector/index.d.ts +5 -32
  39. package/dist/declarations/src/selector/object.d.ts +2 -9
  40. package/dist/declarations/src/selector/primitive.d.ts +3 -9
  41. package/dist/declarations/src/source/{i18n.d.ts → future/i18n.d.ts} +2 -2
  42. package/dist/declarations/src/source/{remote.d.ts → future/remote.d.ts} +3 -3
  43. package/dist/declarations/src/source/index.d.ts +4 -3
  44. package/dist/declarations/src/val/index.d.ts +2 -2
  45. package/dist/index-369caccf.esm.js +550 -0
  46. package/dist/{index-06df0a5b.esm.js → index-3e3e839e.esm.js} +190 -555
  47. package/dist/{index-9663f28a.cjs.dev.js → index-486c7fbf.cjs.dev.js} +224 -617
  48. package/dist/{index-b2270f8f.cjs.prod.js → index-601a7d73.cjs.prod.js} +224 -617
  49. package/dist/index-8706c87e.cjs.prod.js +582 -0
  50. package/dist/index-a6e642dd.cjs.dev.js +582 -0
  51. package/dist/ops-0d09f8ee.cjs.prod.js +684 -0
  52. package/dist/ops-23a5abb2.esm.js +671 -0
  53. package/dist/ops-f3015423.cjs.dev.js +684 -0
  54. package/dist/valbuild-core.cjs.dev.js +640 -633
  55. package/dist/valbuild-core.cjs.prod.js +640 -633
  56. package/dist/valbuild-core.esm.js +578 -572
  57. package/expr/dist/valbuild-core-expr.cjs.dev.js +8 -8
  58. package/expr/dist/valbuild-core-expr.cjs.prod.js +8 -8
  59. package/expr/dist/valbuild-core-expr.esm.js +2 -2
  60. package/package.json +2 -2
  61. package/patch/dist/valbuild-core-patch.cjs.dev.js +32 -23
  62. package/patch/dist/valbuild-core-patch.cjs.prod.js +32 -23
  63. package/patch/dist/valbuild-core-patch.esm.js +12 -4
  64. package/src/ValApi.ts +85 -0
  65. package/src/expr/eval.test.ts +2 -2
  66. package/src/expr/eval.ts +2 -2
  67. package/src/expr/repl.ts +2 -2
  68. package/src/{fetchVal.test.ts → future/fetchVal.test.ts} +57 -57
  69. package/src/{fetchVal.ts → future/fetchVal.ts} +17 -22
  70. package/src/index.ts +51 -14
  71. package/src/initSchema.ts +11 -12
  72. package/src/initVal.ts +42 -52
  73. package/src/module.test.ts +40 -40
  74. package/src/module.ts +53 -43
  75. package/src/patch/deref.test.ts +1 -1
  76. package/src/patch/deref.ts +1 -1
  77. package/src/patch/index.ts +1 -0
  78. package/src/patch/json.test.ts +0 -1
  79. package/src/patch/util.ts +7 -0
  80. package/src/schema/array.ts +45 -4
  81. package/src/schema/boolean.ts +14 -3
  82. package/src/schema/{i18n.ts → future/i18n.ts} +15 -11
  83. package/src/schema/{oneOf.ts → future/oneOf.ts} +21 -18
  84. package/src/schema/image.ts +66 -6
  85. package/src/schema/index.ts +37 -13
  86. package/src/schema/keyOf.ts +167 -0
  87. package/src/schema/literal.ts +24 -3
  88. package/src/schema/number.ts +14 -3
  89. package/src/schema/object.ts +50 -7
  90. package/src/schema/record.ts +103 -0
  91. package/src/schema/richtext.ts +63 -3
  92. package/src/schema/string.ts +14 -3
  93. package/src/schema/union.ts +4 -3
  94. package/src/schema/validation/ValidationError.ts +16 -0
  95. package/src/schema/validation/ValidationFix.ts +6 -0
  96. package/src/schema/validation.test.ts +291 -0
  97. package/src/selector/SelectorProxy.ts +16 -16
  98. package/src/selector/array.ts +2 -26
  99. package/src/selector/file.ts +1 -9
  100. package/src/selector/{ExprProxy.test.ts → future/ExprProxy.test.ts} +2 -2
  101. package/src/selector/{ExprProxy.ts → future/ExprProxy.ts} +9 -2
  102. package/src/selector/{SelectorProxy.test.ts → future/SelectorProxy.test.ts} +4 -4
  103. package/src/selector/future/SelectorProxy.ts +238 -0
  104. package/src/selector/future/array.ts +37 -0
  105. package/src/selector/future/boolean.ts +4 -0
  106. package/src/selector/future/file.ts +14 -0
  107. package/src/selector/{i18n.ts → future/i18n.ts} +2 -2
  108. package/src/selector/future/index.ts +165 -0
  109. package/src/selector/future/number.ts +4 -0
  110. package/src/selector/future/object.ts +22 -0
  111. package/src/selector/future/primitive.ts +17 -0
  112. package/src/selector/{remote.ts → future/remote.ts} +1 -1
  113. package/src/selector/{selector.test.ts → future/selector.test.ts} +8 -28
  114. package/src/selector/{selectorOf.ts → future/selectorOf.ts} +1 -1
  115. package/src/selector/future/string.ts +4 -0
  116. package/src/selector/index.ts +4 -46
  117. package/src/selector/object.ts +2 -19
  118. package/src/selector/primitive.ts +3 -16
  119. package/src/source/{i18n.ts → future/i18n.ts} +2 -2
  120. package/src/source/{remote.ts → future/remote.ts} +3 -3
  121. package/src/source/index.ts +3 -2
  122. package/src/val/array.ts +1 -1
  123. package/src/val/index.ts +2 -2
  124. package/src/val/object.ts +1 -1
  125. package/dist/createClass-012eebbf.esm.js +0 -109
  126. package/dist/createClass-a436dbfe.cjs.dev.js +0 -116
  127. package/dist/createClass-de7426aa.cjs.prod.js +0 -116
  128. package/dist/declarations/src/fetchVal.d.ts +0 -5
  129. package/dist/declarations/src/schema/i18n.d.ts +0 -21
  130. package/dist/declarations/src/schema/oneOf.d.ts +0 -22
  131. package/dist/ops-6fae92a1.esm.js +0 -12
  132. package/dist/ops-87cdbafc.cjs.dev.js +0 -14
  133. package/dist/ops-ae4d1bc2.cjs.prod.js +0 -14
package/ROADMAP.md ADDED
@@ -0,0 +1,106 @@
1
+ # Planned features
2
+
3
+ ## i18n
4
+
5
+ Example:
6
+
7
+ ```tsx
8
+ // file: ./blogs.val.ts
9
+
10
+ export const schema = s.array(
11
+ s.i18n(s.object({ title: s.string(), text: s.richtext() }))
12
+ );
13
+
14
+ export default val.content("/blogs", schema, [
15
+ {
16
+ en_US: {
17
+ title: "Title 1",
18
+ text: val.richtext("Richtext 1"),
19
+ },
20
+ nb_NO: {
21
+ title: "Tittel 1",
22
+ text: val.richtext("Riktekst?"),
23
+ },
24
+ },
25
+ ]);
26
+
27
+ // file: ./components/ServerComponent.ts
28
+
29
+ import blogsVal from "./blogs.val";
30
+
31
+ export async function ServerComponent({ index }: { index: number }) {
32
+ const blogs = await fetchVal(blogVal, getLocale());
33
+
34
+ // NOTE: automatically resolves the locale
35
+ const title = blogs[index].title; // is a string
36
+ return <div>{title}</div>;
37
+ }
38
+ ```
39
+
40
+ Missing infrastructure: none in particular.
41
+
42
+ ## remote
43
+
44
+ Remote makes it possible to move content to cloud storage (and back again). It uses immutable references, so local work, branches still works.
45
+
46
+ Example:
47
+
48
+ ```tsx
49
+ // file: ./blogs.val.ts
50
+
51
+ export const schema = s
52
+ .array(s.object({ title: s.string(), text: s.richtext() }))
53
+ .remote();
54
+
55
+ export default val.content(
56
+ "/blogs",
57
+ schema,
58
+ val.remote("4ba7c33b32a60be06b1b26dff8cc5d8d967660ab") // a change in content, will result in a new reference
59
+ );
60
+
61
+ // file: ./components/ServerComponent.ts
62
+
63
+ import blogsVal from "./blogs.val";
64
+
65
+ export async function ServerComponent({ index }: { index: number }) {
66
+ const blog = await fetchVal(
67
+ blogVal[index] // only fetch the blog at index
68
+ );
69
+ const title = blog.title;
70
+ return <div>{title}</div>;
71
+ }
72
+ ```
73
+
74
+ Missing infrastructure: cloud support, patch support, selectors proxy needs to be able to switch between remote and source (see selectors/future), editor plugin to improve DX (refactors, ...)?
75
+
76
+ ## oneOf
77
+
78
+ oneOf makes it possible to reference an item in an array of in another val module.
79
+
80
+ Example:
81
+
82
+ ```ts
83
+ // file: ./employees.val.ts
84
+
85
+ export schema = s.array(s.object({ name: s.string() }));
86
+
87
+ export default val.content('/employees', schema, [{
88
+ name: 'John Smith',
89
+ }]);
90
+
91
+ // file: ./contacts.val.ts
92
+
93
+ import employeesVal from './employees.val';
94
+
95
+ export schema = s.object({
96
+ hr: s.oneOf(employeesVal),
97
+ });
98
+
99
+ export default val.content('/contacts', schema, {
100
+ hr: employeesVal[0]
101
+ });
102
+
103
+
104
+ ```
105
+
106
+ Missing infrastructure: need a change in how patches are applied for source files to handle selectors inside data.
@@ -0,0 +1,26 @@
1
+ import { ApiPatchResponse, ApiTreeResponse } from "./index.js";
2
+ import { result } from "./fp/index.js";
3
+ import { PatchJSON } from "./patch/index.js";
4
+ import { ModuleId } from "./val/index.js";
5
+ type FetchError = {
6
+ message: string;
7
+ statusCode?: number;
8
+ };
9
+ export declare class ValApi {
10
+ host: string;
11
+ constructor(host: string);
12
+ getDisableUrl(): string;
13
+ postPatches(moduleId: ModuleId, patches: PatchJSON, commit?: string, headers?: Record<string, string> | undefined): Promise<result.Result<ApiPatchResponse, FetchError>>;
14
+ getSession(): Promise<result.Result<{
15
+ mode: "proxy" | "local";
16
+ member_role: "owner" | "developer" | "editor";
17
+ }, FetchError>>;
18
+ getModules({ patch, includeSchema, includeSource, treePath, headers, }: {
19
+ patch?: boolean;
20
+ includeSchema?: boolean;
21
+ includeSource?: boolean;
22
+ treePath?: string;
23
+ headers?: Record<string, string> | undefined;
24
+ }): Promise<result.Result<ApiTreeResponse, FetchError>>;
25
+ }
26
+ export {};
@@ -1,7 +1,7 @@
1
1
  import { Expr } from "./expr.js";
2
2
  import { Source } from "../source/index.js";
3
3
  import { result } from "../fp/index.js";
4
- import { Path, SourceOrExpr } from "../selector/index.js";
4
+ import { Path, SourceOrExpr } from "../selector/future/index.js";
5
5
  import { SourcePath } from "../val/index.js";
6
6
  import { Json } from "../Json.js";
7
7
  export declare class EvalError {
@@ -0,0 +1,5 @@
1
+ import { GenericSelector, SelectorOf, SelectorSource } from "../selector/index.js";
2
+ import { JsonOfSource, Val } from "../val/index.js";
3
+ export declare function fetchVal<T extends SelectorSource>(selector: T): SelectorOf<T> extends GenericSelector<infer S> ? Promise<Val<JsonOfSource<S>>> : never;
4
+ export declare function getVal<T extends SelectorSource>(selector: T): SelectorOf<T> extends GenericSelector<infer S> ? Val<JsonOfSource<S>> : never;
5
+ export declare function serializedValOfSelectorSource<T extends SelectorSource>(selector: T): any;
@@ -4,33 +4,62 @@ export { Schema, type SerializedSchema } from "./schema/index.js";
4
4
  export type { ValModule, SerializedModule } from "./module.js";
5
5
  export type { SourceObject, SourcePrimitive, Source } from "./source/index.js";
6
6
  export type { FileSource } from "./source/file.js";
7
- export type { RemoteSource } from "./source/remote.js";
8
7
  export type { RichTextSource, RichText, TextNode, ParagraphNode, HeadingNode, ListItemNode, ListNode, } from "./source/richtext.js";
9
8
  export { type Val, type SerializedVal, type ModuleId, type ModulePath, type SourcePath, type JsonOfSource, } from "./val/index.js";
10
9
  export type { Json, JsonPrimitive } from "./Json.js";
10
+ export type { ValidationErrors, ValidationError, } from "./schema/validation/ValidationError.js";
11
+ export type { ValidationFix } from "./schema/validation/ValidationFix.js";
11
12
  export * as expr from "./expr/index.js";
12
13
  export { FILE_REF_PROP } from "./source/file.js";
13
14
  export { VAL_EXTENSION, type SourceArray } from "./source/index.js";
14
- export type { I18nSource } from "./source/i18n.js";
15
15
  export { derefPatch } from "./patch/deref.js";
16
16
  export { type SelectorSource, type SelectorOf, GenericSelector, } from "./selector/index.js";
17
- import { getVal } from "./fetchVal.js";
18
- import { getRawSource, resolvePath, splitModuleIdAndModulePath } from "./module.js";
17
+ import { getSource, resolvePath, splitModuleIdAndModulePath } from "./module.js";
19
18
  import { getSchema } from "./selector/index.js";
20
- import { getValPath, isVal } from "./val/index.js";
21
- import { fetchVal } from "./fetchVal.js";
19
+ import { ModuleId, ModulePath, getValPath, isVal } from "./val/index.js";
20
+ import { createValPathOfItem } from "./selector/SelectorProxy.js";
21
+ import { getVal } from "./future/fetchVal.js";
22
+ import { Json } from "./Json.js";
23
+ import { SerializedSchema } from "./schema/index.js";
24
+ export { ValApi } from "./ValApi.js";
25
+ export type ApiTreeResponse = {
26
+ git: {
27
+ commit?: string;
28
+ branch?: string;
29
+ };
30
+ modules: Record<ModuleId, {
31
+ schema?: SerializedSchema;
32
+ patches?: {
33
+ applied: string[];
34
+ failed?: string[];
35
+ };
36
+ source?: Json;
37
+ }>;
38
+ };
39
+ export type ApiPatchResponse = Record<ModuleId, string[]>;
22
40
  declare const Internal: {
23
- convertImageSource: (src: import("./source/file.js").FileSource<import("./schema/image.js").ImageMetadata>) => {
41
+ convertFileSource: (src: import("./source/file.js").FileSource<import("./schema/image.js").ImageMetadata>) => {
24
42
  url: string;
25
43
  metadata?: import("./schema/image.js").ImageMetadata;
26
44
  };
27
45
  getSchema: typeof getSchema;
28
46
  getValPath: typeof getValPath;
29
47
  getVal: typeof getVal;
30
- getRawSource: typeof getRawSource;
48
+ getSource: typeof getSource;
31
49
  resolvePath: typeof resolvePath;
32
50
  splitModuleIdAndModulePath: typeof splitModuleIdAndModulePath;
33
- fetchVal: typeof fetchVal;
34
51
  isVal: typeof isVal;
52
+ createValPathOfItem: typeof createValPathOfItem;
53
+ createPatchJSONPath: (modulePath: ModulePath) => string;
54
+ /**
55
+ * Enables draft mode: updates all Val modules with patches
56
+ */
57
+ VAL_DRAFT_MODE_COOKIE: string;
58
+ /**
59
+ * Enables Val: show the overlay / menu
60
+ */
61
+ VAL_ENABLE_COOKIE_NAME: string;
62
+ VAL_STATE_COOKIE: string;
63
+ VAL_SESSION_COOKIE: string;
35
64
  };
36
65
  export { Internal };
@@ -1,12 +1,9 @@
1
- import { F } from "ts-toolbelt";
2
1
  import { array } from "./schema/array.js";
3
2
  import { number } from "./schema/number.js";
4
3
  import { object } from "./schema/object.js";
5
4
  import { string } from "./schema/string.js";
6
5
  import { boolean } from "./schema/boolean.js";
7
- import { oneOf } from "./schema/oneOf.js";
8
6
  import { union } from "./schema/union.js";
9
- import { I18n } from "./schema/i18n.js";
10
7
  import { richtext } from "./schema/richtext.js";
11
8
  import { image } from "./schema/image.js";
12
9
  import { literal } from "./schema/literal.js";
@@ -17,15 +14,11 @@ export type InitSchema = {
17
14
  readonly object: typeof object;
18
15
  readonly number: typeof number;
19
16
  readonly union: typeof union;
20
- readonly oneOf: typeof oneOf;
21
17
  readonly richtext: typeof richtext;
22
18
  readonly image: typeof image;
23
19
  readonly literal: typeof literal;
24
20
  };
25
- export type InitSchemaLocalized<Locales extends readonly string[]> = {
26
- readonly i18n: I18n<Locales>;
27
- };
28
- export declare function initSchema<Locales extends readonly string[]>(locales: F.Narrow<Locales>): {
21
+ export declare function initSchema(): {
29
22
  string: <T extends string>(options?: {
30
23
  maxLength?: number | undefined;
31
24
  minLength?: number | undefined;
@@ -43,15 +36,14 @@ export declare function initSchema<Locales extends readonly string[]>(locales: F
43
36
  [x: string]: import("./source/index.js").Source;
44
37
  } & {
45
38
  fold?: undefined;
39
+ assert?: undefined;
46
40
  andThen?: undefined;
47
41
  _ref?: undefined;
48
42
  _type?: undefined;
49
43
  val?: undefined;
50
44
  valPath?: undefined;
51
45
  } & { [k in Key]: string; }>[]>(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 : never : never>;
52
- oneOf: <Src extends import("./selector/index.js").GenericSelector<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 (infer IS)[] ? IS extends import("./source/index.js").Source ? import("./selector/index.js").GenericSelector<IS, undefined> : never : never : never>;
53
46
  richtext: () => import("./schema/index.js").Schema<import("./index.js").RichTextSource>;
54
47
  image: (options?: import("./schema/image.js").ImageOptions | undefined) => import("./schema/index.js").Schema<import("./index.js").FileSource<import("./schema/image.js").ImageMetadata>>;
55
48
  literal: <T_2 extends string>(value: T_2) => import("./schema/index.js").Schema<T_2>;
56
- i18n: <S_3 extends import("./schema/index.js").Schema<import("./source/i18n.js").I18nCompatibleSource>>(schema: S_3) => import("./schema/index.js").Schema<import("./index.js").I18nSource<import("ts-toolbelt/out/Any/Try").Try<Locales, [], (Locales extends [] ? [] : never) | (Locales extends import("ts-toolbelt/out/Function/_Internal").Narrowable ? Locales : never) | { [K in keyof Locales]: Locales[K] extends Function ? Locales[K] : (Locales[K] extends infer T_3 ? T_3 extends Locales[K] ? T_3 extends [] ? [] : never : never : never) | (Locales[K] extends infer T_4 ? T_4 extends Locales[K] ? T_4 extends import("ts-toolbelt/out/Function/_Internal").Narrowable ? T_4 : never : never : never) | (Locales[K] extends infer T_5 ? { [K_1 in keyof T_5]: Locales[K][K_1] extends Function ? Locales[K][K_1] : (Locales[K][K_1] extends infer T_6 ? T_6 extends Locales[K][K_1] ? T_6 extends [] ? [] : never : never : never) | (Locales[K][K_1] extends infer T_7 ? T_7 extends Locales[K][K_1] ? T_7 extends import("ts-toolbelt/out/Function/_Internal").Narrowable ? T_7 : never : never : never) | (Locales[K][K_1] extends infer T_8 ? { [K_2 in keyof T_8]: Locales[K][K_1][K_2] extends Function ? Locales[K][K_1][K_2] : (Locales[K][K_1][K_2] extends infer T_9 ? T_9 extends Locales[K][K_1][K_2] ? T_9 extends [] ? [] : never : never : never) | (Locales[K][K_1][K_2] extends infer T_10 ? T_10 extends Locales[K][K_1][K_2] ? T_10 extends import("ts-toolbelt/out/Function/_Internal").Narrowable ? T_10 : never : never : never) | (Locales[K][K_1][K_2] extends infer T_11 ? { [K_3 in keyof T_11]: Locales[K][K_1][K_2][K_3] extends Function ? Locales[K][K_1][K_2][K_3] : (Locales[K][K_1][K_2][K_3] extends infer T_12 ? T_12 extends Locales[K][K_1][K_2][K_3] ? T_12 extends [] ? [] : never : never : never) | (Locales[K][K_1][K_2][K_3] extends infer T_13 ? T_13 extends Locales[K][K_1][K_2][K_3] ? T_13 extends import("ts-toolbelt/out/Function/_Internal").Narrowable ? T_13 : never : never : never) | (Locales[K][K_1][K_2][K_3] extends infer T_14 ? { [K_4 in keyof T_14]: Locales[K][K_1][K_2][K_3][K_4] extends Function ? Locales[K][K_1][K_2][K_3][K_4] : (Locales[K][K_1][K_2][K_3][K_4] extends infer T_15 ? T_15 extends Locales[K][K_1][K_2][K_3][K_4] ? T_15 extends [] ? [] : never : never : never) | (Locales[K][K_1][K_2][K_3][K_4] extends infer T_16 ? T_16 extends Locales[K][K_1][K_2][K_3][K_4] ? T_16 extends import("ts-toolbelt/out/Function/_Internal").Narrowable ? T_16 : never : never : never) | (Locales[K][K_1][K_2][K_3][K_4] extends infer T_17 ? { [K_5 in keyof T_17]: Locales[K][K_1][K_2][K_3][K_4][K_5] extends Function ? Locales[K][K_1][K_2][K_3][K_4][K_5] : (Locales[K][K_1][K_2][K_3][K_4][K_5] extends infer T_18 ? T_18 extends Locales[K][K_1][K_2][K_3][K_4][K_5] ? T_18 extends [] ? [] : never : never : never) | (Locales[K][K_1][K_2][K_3][K_4][K_5] extends infer T_19 ? T_19 extends Locales[K][K_1][K_2][K_3][K_4][K_5] ? T_19 extends import("ts-toolbelt/out/Function/_Internal").Narrowable ? T_19 : never : never : never) | (Locales[K][K_1][K_2][K_3][K_4][K_5] extends infer T_20 ? { [K_6 in keyof T_20]: Locales[K][K_1][K_2][K_3][K_4][K_5][K_6] extends Function ? Locales[K][K_1][K_2][K_3][K_4][K_5][K_6] : (Locales[K][K_1][K_2][K_3][K_4][K_5][K_6] extends infer T_21 ? T_21 extends Locales[K][K_1][K_2][K_3][K_4][K_5][K_6] ? T_21 extends [] ? [] : never : never : never) | (Locales[K][K_1][K_2][K_3][K_4][K_5][K_6] extends infer T_22 ? T_22 extends Locales[K][K_1][K_2][K_3][K_4][K_5][K_6] ? T_22 extends import("ts-toolbelt/out/Function/_Internal").Narrowable ? T_22 : never : never : never) | (Locales[K][K_1][K_2][K_3][K_4][K_5][K_6] extends infer T_23 ? { [K_7 in keyof T_23]: Locales[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7] extends Function ? Locales[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7] : (Locales[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7] extends infer T_24 ? T_24 extends Locales[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7] ? T_24 extends [] ? [] : never : never : never) | (Locales[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7] extends infer T_25 ? T_25 extends Locales[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7] ? T_25 extends import("ts-toolbelt/out/Function/_Internal").Narrowable ? T_25 : never : never : never) | (Locales[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7] extends infer T_26 ? { [K_8 in keyof T_26]: Locales[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8] extends Function ? Locales[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8] : (Locales[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8] extends infer T_27 ? T_27 extends Locales[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8] ? T_27 extends [] ? [] : never : never : never) | (Locales[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8] extends infer T_28 ? T_28 extends Locales[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8] ? T_28 extends import("ts-toolbelt/out/Function/_Internal").Narrowable ? T_28 : never : never : never) | (Locales[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8] extends infer T_29 ? { [K_9 in keyof T_29]: Locales[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9] extends Function ? Locales[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9] : (Locales[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9] extends infer T_30 ? T_30 extends Locales[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9] ? T_30 extends [] ? [] : never : never : never) | (Locales[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9] extends infer T_31 ? T_31 extends Locales[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9] ? T_31 extends import("ts-toolbelt/out/Function/_Internal").Narrowable ? T_31 : never : never : never) | (Locales[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9] extends infer T_32 ? { [K_10 in keyof T_32]: Locales[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9][K_10] extends Function ? Locales[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9][K_10] : (Locales[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9][K_10] extends infer T_33 ? T_33 extends Locales[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9][K_10] ? T_33 extends [] ? [] : never : never : never) | (Locales[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9][K_10] extends infer T_34 ? T_34 extends Locales[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9][K_10] ? T_34 extends import("ts-toolbelt/out/Function/_Internal").Narrowable ? T_34 : never : never : never) | any; } : never); } : never); } : never); } : never); } : never); } : never); } : never); } : never); } : never); } : never); }>, import("./schema/index.js").SchemaTypeOf<S_3>>>;
57
49
  };
@@ -1,35 +1,17 @@
1
1
  import { content } from "./module.js";
2
- import { I18n } from "./source/i18n.js";
3
- import { InitSchema, InitSchemaLocalized } from "./initSchema.js";
2
+ import { InitSchema } from "./initSchema.js";
4
3
  import { getValPath as getPath } from "./val/index.js";
5
- import { remote } from "./source/remote.js";
6
4
  import { file } from "./source/file.js";
7
5
  import { richtext } from "./source/richtext.js";
8
6
  type ValConstructor = {
9
7
  content: typeof content;
10
8
  getPath: typeof getPath;
11
- remote: typeof remote;
12
9
  file: typeof file;
13
10
  richtext: typeof richtext;
14
11
  };
15
- export type InitVal<Locales extends readonly string[] | undefined> = [
16
- Locales
17
- ] extends [readonly string[]] ? {
18
- val: ValConstructor & {
19
- i18n: I18n<Locales>;
20
- };
21
- s: InitSchema & InitSchemaLocalized<Locales>;
22
- } : {
12
+ export type InitVal = {
23
13
  val: ValConstructor;
24
14
  s: InitSchema;
25
15
  };
26
- type NarrowStrings<A> = (A extends [] ? [] : never) | (A extends string ? A : never) | {
27
- [K in keyof A]: NarrowStrings<A[K]>;
28
- };
29
- export declare const initVal: <Locales extends readonly string[] | undefined>(options?: {
30
- readonly locales?: {
31
- readonly required: NarrowStrings<Locales>;
32
- readonly fallback: NarrowStrings<Locales extends readonly string[] ? Locales[number] : never>;
33
- } | undefined;
34
- } | undefined) => InitVal<Locales>;
16
+ export declare const initVal: () => InitVal;
35
17
  export {};
@@ -3,10 +3,6 @@ import { GenericSelector, SelectorOf, SelectorSource } from "./selector/index.js
3
3
  import { Source } from "./source/index.js";
4
4
  import { ModuleId, ModulePath, SourcePath } from "./val/index.js";
5
5
  import { Json } from "./Json.js";
6
- import { SerializedRichTextSchema } from "./schema/richtext.js";
7
- import { ImageMetadata, ImageSchema, SerializedImageSchema } from "./schema/image.js";
8
- import { FileSource } from "./source/file.js";
9
- import { RichText } from "./source/richtext.js";
10
6
  declare const brand: unique symbol;
11
7
  export type ValModule<T extends SelectorSource> = SelectorOf<T> & ValModuleBrand;
12
8
  export type ValModuleBrand = {
@@ -14,20 +10,12 @@ export type ValModuleBrand = {
14
10
  };
15
11
  export type TypeOfValModule<T extends ValModule<SelectorSource>> = T extends GenericSelector<infer S> ? S : never;
16
12
  export declare function content<T extends Schema<SelectorSource>>(id: string, schema: T, source: SchemaTypeOf<T>): ValModule<SchemaTypeOf<T>>;
17
- export declare function getRawSource(valModule: ValModule<SelectorSource>): Source;
13
+ export declare function getSource(valModule: ValModule<SelectorSource>): Source;
18
14
  export declare function splitModuleIdAndModulePath(path: SourcePath): [moduleId: ModuleId, path: ModulePath];
19
15
  export declare function getSourceAtPath(modulePath: ModulePath, valModule: ValModule<SelectorSource> | Source): any;
20
16
  export declare function resolvePath(path: ModulePath, valModule: ValModule<SelectorSource> | Source, schema: Schema<SelectorSource> | SerializedSchema): {
21
17
  path: string;
22
- schema: SerializedImageSchema | ImageSchema<FileSource<ImageMetadata> | null>;
23
- source: any;
24
- } | {
25
- path: string;
26
- schema: SerializedRichTextSchema | Schema<RichText<"h1" | "h2" | "h3" | "h4" | "h5" | "h6", import("./source/richtext.js").TextNode>>;
27
- source: any;
28
- } | {
29
- path: ModulePath;
30
- schema: Schema<SelectorSource> | SerializedSchema;
18
+ schema: SerializedSchema | Schema<SelectorSource>;
31
19
  source: any;
32
20
  };
33
21
  export declare function parsePath(input: ModulePath): string[];
@@ -3,4 +3,4 @@ export { type OperationJSON, type Operation } from "./operation.js";
3
3
  export { parsePatch, parseJSONPointer, formatJSONPointer } from "./parse.js";
4
4
  export { type JSONValue, type Ops, PatchError } from "./ops.js";
5
5
  export { type PatchJSON, type Patch, applyPatch } from "./patch.js";
6
- export { isNotRoot, deepEqual, deepClone, parseAndValidateArrayIndex, } from "./util.js";
6
+ export { isNotRoot, deepEqual, deepClone, parseAndValidateArrayIndex, sourceToPatchPath, } from "./util.js";
@@ -1,6 +1,8 @@
1
1
  import { array, result } from "../fp/index.js";
2
2
  import { PatchError, ReadonlyJSONValue, ToMutable } from "./ops.js";
3
+ import { SourcePath } from "../val/index.js";
3
4
  export declare function isNotRoot(path: string[]): path is array.NonEmptyArray<string>;
4
5
  export declare function deepEqual(a: ReadonlyJSONValue, b: ReadonlyJSONValue): boolean;
5
6
  export declare function deepClone<T extends ReadonlyJSONValue>(value: T): ToMutable<T>;
6
7
  export declare function parseAndValidateArrayIndex(value: string): result.Result<number, PatchError>;
8
+ export declare function sourceToPatchPath(sourcePath: SourcePath): any[];
@@ -1,6 +1,7 @@
1
1
  import { Schema, SchemaTypeOf, SerializedSchema } from "./index.js";
2
2
  import { SelectorSource } from "../selector/index.js";
3
3
  import { SourcePath } from "../val/index.js";
4
+ import { ValidationErrors } from "./validation/ValidationError.js";
4
5
  export type SerializedArraySchema = {
5
6
  type: "array";
6
7
  item: SerializedSchema;
@@ -10,8 +11,8 @@ export declare class ArraySchema<T extends Schema<SelectorSource>> extends Schem
10
11
  readonly item: T;
11
12
  readonly opt: boolean;
12
13
  constructor(item: T, opt?: boolean);
13
- validate(src: SchemaTypeOf<T>[]): false | Record<SourcePath, string[]>;
14
- match(src: SchemaTypeOf<T>[]): boolean;
14
+ validate(path: SourcePath, src: SchemaTypeOf<T>[]): ValidationErrors;
15
+ assert(src: SchemaTypeOf<T>[]): boolean;
15
16
  optional(): Schema<SchemaTypeOf<T>[] | null>;
16
17
  serialize(): SerializedArraySchema;
17
18
  }
@@ -1,5 +1,6 @@
1
1
  import { Schema, SerializedSchema } from "./index.js";
2
2
  import { SourcePath } from "../val/index.js";
3
+ import { ValidationErrors } from "./validation/ValidationError.js";
3
4
  export type SerializedBooleanSchema = {
4
5
  type: "boolean";
5
6
  opt: boolean;
@@ -7,8 +8,8 @@ export type SerializedBooleanSchema = {
7
8
  export declare class BooleanSchema<Src extends boolean | null> extends Schema<Src> {
8
9
  readonly opt: boolean;
9
10
  constructor(opt?: boolean);
10
- validate(src: Src): false | Record<SourcePath, string[]>;
11
- match(src: Src): boolean;
11
+ validate(path: SourcePath, src: Src): ValidationErrors;
12
+ assert(src: Src): boolean;
12
13
  optional(): Schema<Src | null>;
13
14
  serialize(): SerializedSchema;
14
15
  }
@@ -1,6 +1,7 @@
1
1
  import { Schema, SerializedSchema } from "./index.js";
2
2
  import { FileSource } from "../source/file.js";
3
3
  import { SourcePath } from "../val/index.js";
4
+ import { ValidationErrors } from "./validation/ValidationError.js";
4
5
  export type ImageOptions = {
5
6
  ext: ["jpg"] | ["webp"];
6
7
  directory?: string;
@@ -20,13 +21,13 @@ export declare class ImageSchema<Src extends FileSource<ImageMetadata> | null> e
20
21
  readonly options?: ImageOptions | undefined;
21
22
  readonly opt: boolean;
22
23
  constructor(options?: ImageOptions | undefined, opt?: boolean);
23
- validate(src: Src): false | Record<SourcePath, string[]>;
24
- match(src: Src): boolean;
24
+ validate(path: SourcePath, src: Src): ValidationErrors;
25
+ assert(src: Src): boolean;
25
26
  optional(): Schema<Src | null>;
26
27
  serialize(): SerializedSchema;
27
28
  }
28
29
  export declare const image: (options?: ImageOptions) => Schema<FileSource<ImageMetadata>>;
29
- export declare const convertImageSource: (src: FileSource<ImageMetadata>) => {
30
+ export declare const convertFileSource: (src: FileSource<ImageMetadata>) => {
30
31
  url: string;
31
32
  metadata?: ImageMetadata;
32
33
  };
@@ -1,23 +1,24 @@
1
1
  import { SelectorSource } from "../selector/index.js";
2
- import { RemoteCompatibleSource, RemoteSource } from "../source/remote.js";
3
2
  import { SourcePath } from "../val/index.js";
4
3
  import { SerializedArraySchema } from "./array.js";
5
4
  import { SerializedBooleanSchema } from "./boolean.js";
6
- import { SerializedI18nSchema } from "./i18n.js";
7
5
  import { SerializedImageSchema } from "./image.js";
6
+ import { SerializedKeyOfSchema } from "./keyOf.js";
8
7
  import { SerializedLiteralSchema } from "./literal.js";
9
8
  import { SerializedNumberSchema } from "./number.js";
10
9
  import { SerializedObjectSchema } from "./object.js";
11
- import { SerializedOneOfSchema } from "./oneOf.js";
10
+ import { SerializedRecordSchema } from "./record.js";
12
11
  import { SerializedRichTextSchema } from "./richtext.js";
13
12
  import { SerializedStringSchema } from "./string.js";
14
13
  import { SerializedUnionSchema } from "./union.js";
15
- export type SerializedSchema = SerializedStringSchema | SerializedLiteralSchema | SerializedBooleanSchema | SerializedNumberSchema | SerializedObjectSchema | SerializedOneOfSchema | SerializedArraySchema | SerializedUnionSchema | SerializedRichTextSchema | SerializedImageSchema | SerializedI18nSchema;
14
+ import { ValidationErrors } from "./validation/ValidationError.js";
15
+ export type SerializedSchema = SerializedStringSchema | SerializedLiteralSchema | SerializedBooleanSchema | SerializedNumberSchema | SerializedObjectSchema | SerializedArraySchema | SerializedUnionSchema | SerializedRichTextSchema | SerializedRecordSchema | SerializedKeyOfSchema | SerializedImageSchema;
16
16
  export declare abstract class Schema<Src extends SelectorSource> {
17
- abstract validate(src: Src): false | Record<SourcePath, string[]>;
18
- abstract match(src: Src): boolean;
17
+ abstract validate(path: SourcePath, src: Src): ValidationErrors;
18
+ abstract assert(src: Src): boolean;
19
19
  abstract optional(): Schema<Src | null>;
20
20
  abstract serialize(): SerializedSchema;
21
- remote(): Src extends RemoteCompatibleSource ? Schema<RemoteSource<Src>> : never;
21
+ /** MUTATES! since internal and perf sensitive */
22
+ protected appendValidationError(current: ValidationErrors, path: SourcePath, message: string, value?: unknown): ValidationErrors;
22
23
  }
23
24
  export type SchemaTypeOf<T extends Schema<SelectorSource>> = T extends Schema<infer Src> ? Src : never;
@@ -0,0 +1,23 @@
1
+ import { Schema, SerializedSchema, SourceObject } from "../index.js";
2
+ import { ValModuleBrand } from "../module.js";
3
+ import { GenericSelector } from "../selector/index.js";
4
+ import { SourceArray } from "../source/index.js";
5
+ import { SourcePath } from "../val/index.js";
6
+ import { ValidationErrors } from "./validation/ValidationError.js";
7
+ export type SerializedKeyOfSchema = {
8
+ type: "keyOf";
9
+ selector: SourcePath;
10
+ opt: boolean;
11
+ };
12
+ type KeyOfSelector<Sel extends GenericSelector<SourceArray | SourceObject>> = Sel extends GenericSelector<infer S> ? S extends readonly any[] ? number : S extends SourceObject ? keyof S : S extends Record<string, any> ? string : never : never;
13
+ export declare class KeyOfSchema<Sel extends GenericSelector<SourceArray | SourceObject>> extends Schema<KeyOfSelector<Sel>> {
14
+ readonly selector: Sel;
15
+ readonly opt: boolean;
16
+ constructor(selector: Sel, opt?: boolean);
17
+ validate(path: SourcePath, src: KeyOfSelector<Sel>): ValidationErrors;
18
+ assert(src: KeyOfSelector<Sel>): boolean;
19
+ optional(): Schema<KeyOfSelector<Sel> | null>;
20
+ serialize(): SerializedSchema;
21
+ }
22
+ export declare const keyOf: <Src extends GenericSelector<SourceObject | SourceArray, undefined> & ValModuleBrand>(valModule: Src) => Schema<KeyOfSelector<Src>>;
23
+ export {};
@@ -1,5 +1,6 @@
1
1
  import { Schema, SerializedSchema } from "./index.js";
2
2
  import { SourcePath } from "../val/index.js";
3
+ import { ValidationErrors } from "./validation/ValidationError.js";
3
4
  export type SerializedLiteralSchema = {
4
5
  type: "literal";
5
6
  value: string;
@@ -9,8 +10,8 @@ export declare class LiteralSchema<Src extends string | null> extends Schema<Src
9
10
  readonly value: string;
10
11
  readonly opt: boolean;
11
12
  constructor(value: string, opt?: boolean);
12
- validate(src: Src): false | Record<SourcePath, string[]>;
13
- match(src: Src): boolean;
13
+ validate(path: SourcePath, src: Src): ValidationErrors;
14
+ assert(src: Src): boolean;
14
15
  optional(): Schema<Src | null>;
15
16
  serialize(): SerializedSchema;
16
17
  }
@@ -1,5 +1,6 @@
1
1
  import { Schema, SerializedSchema } from "./index.js";
2
2
  import { SourcePath } from "../val/index.js";
3
+ import { ValidationErrors } from "./validation/ValidationError.js";
3
4
  type NumberOptions = {
4
5
  max?: number;
5
6
  min?: number;
@@ -13,8 +14,8 @@ export declare class NumberSchema<Src extends number | null> extends Schema<Src>
13
14
  readonly options?: NumberOptions | undefined;
14
15
  readonly opt: boolean;
15
16
  constructor(options?: NumberOptions | undefined, opt?: boolean);
16
- validate(src: Src): false | Record<SourcePath, string[]>;
17
- match(src: Src): boolean;
17
+ validate(path: SourcePath, src: Src): ValidationErrors;
18
+ assert(src: Src): boolean;
18
19
  optional(): Schema<Src | null>;
19
20
  serialize(): SerializedSchema;
20
21
  }
@@ -1,6 +1,7 @@
1
1
  import { Schema, SchemaTypeOf, SerializedSchema } from "./index.js";
2
2
  import { SelectorSource } from "../selector/index.js";
3
3
  import { SourcePath } from "../val/index.js";
4
+ import { ValidationErrors } from "./validation/ValidationError.js";
4
5
  export type SerializedObjectSchema = {
5
6
  type: "object";
6
7
  items: Record<string, SerializedSchema>;
@@ -16,8 +17,8 @@ export declare class ObjectSchema<Props extends ObjectSchemaProps> extends Schem
16
17
  readonly items: Props;
17
18
  readonly opt: boolean;
18
19
  constructor(items: Props, opt?: boolean);
19
- validate(src: ObjectSchemaSrcOf<Props>): false | Record<SourcePath, string[]>;
20
- match(src: ObjectSchemaSrcOf<Props>): boolean;
20
+ validate(path: SourcePath, src: ObjectSchemaSrcOf<Props>): ValidationErrors;
21
+ assert(src: ObjectSchemaSrcOf<Props>): boolean;
21
22
  optional(): Schema<ObjectSchemaSrcOf<Props> | null>;
22
23
  serialize(): SerializedSchema;
23
24
  }
@@ -0,0 +1,19 @@
1
+ import { Schema, SchemaTypeOf, SerializedSchema } from "./index.js";
2
+ import { SelectorSource } from "../selector/index.js";
3
+ import { SourcePath } from "../val/index.js";
4
+ import { ValidationErrors } from "./validation/ValidationError.js";
5
+ export type SerializedRecordSchema = {
6
+ type: "record";
7
+ item: SerializedSchema;
8
+ opt: boolean;
9
+ };
10
+ export declare class RecordSchema<T extends Schema<SelectorSource>> extends Schema<Record<string, SchemaTypeOf<T>>> {
11
+ readonly item: T;
12
+ readonly opt: boolean;
13
+ constructor(item: T, opt?: boolean);
14
+ validate(path: SourcePath, src: Record<string, SchemaTypeOf<T>>): ValidationErrors;
15
+ assert(src: Record<string, SchemaTypeOf<T>>): boolean;
16
+ optional(): Schema<Record<string, SchemaTypeOf<T>> | null>;
17
+ serialize(): SerializedRecordSchema;
18
+ }
19
+ export declare const record: <S extends Schema<SelectorSource>>(schema: S) => Schema<Record<string, SchemaTypeOf<S>>>;
@@ -1,14 +1,15 @@
1
1
  import { Schema, SerializedSchema } from "./index.js";
2
2
  import { RichTextSource } from "../source/richtext.js";
3
3
  import { SourcePath } from "../val/index.js";
4
+ import { ValidationErrors } from "./validation/ValidationError.js";
4
5
  export type SerializedRichTextSchema = {
5
6
  type: "richtext";
6
7
  opt: boolean;
7
8
  };
8
9
  export declare class RichTextSchema<Src extends RichTextSource | null> extends Schema<Src> {
9
10
  readonly opt: boolean;
10
- validate(src: Src): false | Record<SourcePath, string[]>;
11
- match(src: Src): boolean;
11
+ validate(path: SourcePath, src: Src): ValidationErrors;
12
+ assert(src: Src): boolean;
12
13
  optional(): Schema<RichTextSource | null>;
13
14
  serialize(): SerializedSchema;
14
15
  constructor(opt?: boolean);
@@ -1,5 +1,6 @@
1
1
  import { Schema, SerializedSchema } from "./index.js";
2
2
  import { SourcePath } from "../val/index.js";
3
+ import { ValidationErrors } from "./validation/ValidationError.js";
3
4
  type StringOptions = {
4
5
  maxLength?: number;
5
6
  minLength?: number;
@@ -13,8 +14,8 @@ export declare class StringSchema<Src extends string | null> extends Schema<Src>
13
14
  readonly options?: StringOptions | undefined;
14
15
  readonly opt: boolean;
15
16
  constructor(options?: StringOptions | undefined, opt?: boolean);
16
- validate(src: Src): false | Record<SourcePath, string[]>;
17
- match(src: Src): boolean;
17
+ validate(path: SourcePath, src: Src): ValidationErrors;
18
+ assert(src: Src): boolean;
18
19
  optional(): Schema<Src | null>;
19
20
  serialize(): SerializedSchema;
20
21
  }
@@ -2,6 +2,7 @@ import { Schema, 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 { ValidationErrors } from "./validation/ValidationError.js";
5
6
  export type SerializedUnionSchema = {
6
7
  type: "union";
7
8
  key: string;
@@ -17,8 +18,8 @@ export declare class UnionSchema<Key extends string, T extends Schema<SourceObje
17
18
  readonly key: Key;
18
19
  readonly items: T;
19
20
  readonly opt: boolean;
20
- validate(src: SourceOf<Key, T>): false | Record<SourcePath, string[]>;
21
- match(src: SourceOf<Key, T>): boolean;
21
+ validate(path: SourcePath, src: SourceOf<Key, T>): ValidationErrors;
22
+ assert(src: SourceOf<Key, T>): boolean;
22
23
  optional(): Schema<SourceOf<Key, T> | null>;
23
24
  serialize(): SerializedSchema;
24
25
  constructor(key: Key, items: T, opt?: boolean);
@@ -27,6 +28,7 @@ export declare const union: <Key extends string, T extends Schema<{
27
28
  [x: string]: import("../source/index.js").Source;
28
29
  } & {
29
30
  fold?: undefined;
31
+ assert?: undefined;
30
32
  andThen?: undefined;
31
33
  _ref?: undefined;
32
34
  _type?: undefined;