@valbuild/core 0.77.0 → 0.78.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.
@@ -52,6 +52,7 @@ export { type SerializedRichTextSchema, RichTextSchema, } from "./schema/richtex
52
52
  export { type SerializedUnionSchema, UnionSchema, type SerializedStringUnionSchema, type SerializedObjectUnionSchema, } from "./schema/union.js";
53
53
  export { type SerializedLiteralSchema, LiteralSchema } from "./schema/literal.js";
54
54
  export { deserializeSchema } from "./schema/deserialize.js";
55
+ export { type ListRecordPreview, type ReifiedPreview } from "./preview.js";
55
56
  export declare const FATAL_ERROR_TYPES: readonly ["no-schema", "no-source", "invalid-id", "no-module", "invalid-patch"];
56
57
  export type FatalErrorType = (typeof FATAL_ERROR_TYPES)[number];
57
58
  export declare const DEFAULT_CONTENT_HOST = "https://content.val.build";
@@ -98,7 +98,7 @@ export declare function initSchema(): {
98
98
  image: (options?: import("./schema/image.js").ImageOptions | undefined) => import("./schema/image.js").ImageSchema<import("./index.js").ImageSource>;
99
99
  literal: <T_2 extends string>(value: T_2) => import("./schema/literal.js").LiteralSchema<T_2>;
100
100
  keyOf: <Src extends import("./selector/index.js").GenericSelector<import("./source/index.js").SourceObject, undefined> & import("./module.js").ValModuleBrand>(valModule: Src) => import("./schema/index.js").Schema<Src extends import("./selector/index.js").GenericSelector<infer S_2 extends import("./source/index.js").Source, undefined> ? S_2 extends readonly import("./source/index.js").Source[] ? number : S_2 extends import("./source/index.js").SourceObject ? string extends keyof S_2 ? import("./schema/string.js").RawString : keyof S_2 : S_2 extends Record<string, import("./source/index.js").Source> ? import("./schema/string.js").RawString : never : never>;
101
- record: <S_3 extends import("./schema/index.js").Schema<import("./selector/index.js").SelectorSource>>(schema: S_3) => import("./schema/index.js").Schema<Record<string, import("./schema/index.js").SelectorOfSchema<S_3>>>;
101
+ record: <S_3 extends import("./schema/index.js").Schema<import("./selector/index.js").SelectorSource>>(schema: S_3) => import("./schema/record.js").RecordSchema<S_3, Record<string, import("./schema/index.js").SelectorOfSchema<S_3>>>;
102
102
  file: (options?: import("./schema/file.js").FileOptions | undefined) => import("./schema/file.js").FileSchema<import("./index.js").FileSource<import("./schema/file.js").FileMetadata>>;
103
103
  date: (options?: Record<string, never> | undefined) => import("./schema/date.js").DateSchema<import("./schema/string.js").RawString>;
104
104
  };
@@ -0,0 +1,26 @@
1
+ import { ImageSource } from "./source/image.js";
2
+ import { ModuleFilePath, SourcePath } from "./val/index.js";
3
+ export type ListRecordPreview = {
4
+ layout: "list";
5
+ items: [
6
+ key: string,
7
+ value: {
8
+ title: string;
9
+ subtitle?: string | null;
10
+ image?: ImageSource | null;
11
+ }
12
+ ][];
13
+ };
14
+ type WithStatus<T> = {
15
+ status: "error";
16
+ message: string;
17
+ } | {
18
+ status: "loading";
19
+ data?: T;
20
+ } | {
21
+ status: "success";
22
+ data: T;
23
+ };
24
+ type PreviewTypes = ListRecordPreview;
25
+ export type ReifiedPreview = Record<SourcePath | ModuleFilePath, WithStatus<PreviewTypes>>;
26
+ export {};
@@ -1,6 +1,7 @@
1
1
  import { Schema, SchemaAssertResult, SelectorOfSchema, SerializedSchema } from "./index.js";
2
+ import { ReifiedPreview } from "../preview.js";
2
3
  import { SelectorSource } from "../selector/index.js";
3
- import { SourcePath } from "../val/index.js";
4
+ import { ModuleFilePath, SourcePath } from "../val/index.js";
4
5
  import { ValidationErrors } from "./validation/ValidationError.js";
5
6
  export type SerializedArraySchema = {
6
7
  type: "array";
@@ -15,5 +16,6 @@ export declare class ArraySchema<T extends Schema<SelectorSource>, Src extends S
15
16
  assert(path: SourcePath, src: unknown): SchemaAssertResult<Src>;
16
17
  nullable(): Schema<Src | null>;
17
18
  serialize(): SerializedArraySchema;
19
+ protected executePreview(sourcePath: SourcePath | ModuleFilePath, src: Src): ReifiedPreview;
18
20
  }
19
21
  export declare const array: <S extends Schema<SelectorSource>>(schema: S) => Schema<SelectorOfSchema<S>[]>;
@@ -1,4 +1,5 @@
1
1
  import { Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
2
+ import { ReifiedPreview } from "../preview.js";
2
3
  import { SourcePath } from "../val/index.js";
3
4
  import { ValidationErrors } from "./validation/ValidationError.js";
4
5
  export type SerializedBooleanSchema = {
@@ -12,5 +13,6 @@ export declare class BooleanSchema<Src extends boolean | null> extends Schema<Sr
12
13
  assert(path: SourcePath, src: unknown): SchemaAssertResult<Src>;
13
14
  nullable(): Schema<Src | null>;
14
15
  serialize(): SerializedSchema;
16
+ protected executePreview(): ReifiedPreview;
15
17
  }
16
18
  export declare const boolean: () => Schema<boolean>;
@@ -1,4 +1,5 @@
1
1
  import { Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
2
+ import { ReifiedPreview } from "../preview.js";
2
3
  import { SourcePath } from "../val/index.js";
3
4
  import { RawString } from "./string.js";
4
5
  import { ValidationErrors } from "./validation/ValidationError.js";
@@ -33,6 +34,7 @@ export declare class DateSchema<Src extends string | null> extends Schema<Src> {
33
34
  to(to: string): DateSchema<Src>;
34
35
  nullable(): DateSchema<Src | null>;
35
36
  serialize(): SerializedSchema;
37
+ protected executePreview(): ReifiedPreview;
36
38
  }
37
39
  export declare const date: (options?: Record<string, never>) => DateSchema<RawString>;
38
40
  export {};
@@ -4,6 +4,7 @@ import { Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
4
4
  import { SourcePath } from "../val/index.js";
5
5
  import { ValidationErrors } from "./validation/ValidationError.js";
6
6
  import { RemoteSource } from "../index.js";
7
+ import { ReifiedPreview } from "../preview.js";
7
8
  export type FileOptions = {
8
9
  accept?: string;
9
10
  };
@@ -26,6 +27,7 @@ export declare class FileSchema<Src extends FileSource<FileMetadata | undefined>
26
27
  assert(path: SourcePath, src: unknown): SchemaAssertResult<Src>;
27
28
  nullable(): Schema<Src | null>;
28
29
  serialize(): SerializedSchema;
30
+ protected executePreview(): ReifiedPreview;
29
31
  }
30
32
  export declare const file: (options?: FileOptions) => FileSchema<FileSource<FileMetadata>>;
31
33
  export declare function convertFileSource<Metadata extends {
@@ -5,6 +5,7 @@ import { SourcePath } from "../val/index.js";
5
5
  import { ValidationErrors } from "./validation/ValidationError.js";
6
6
  import { FileMetadata } from "../index.js";
7
7
  import { RemoteSource } from "../source/remote.js";
8
+ import { ReifiedPreview } from "../preview.js";
8
9
  export type ImageOptions = {
9
10
  ext?: ["jpg"] | ["webp"];
10
11
  directory?: string;
@@ -36,5 +37,6 @@ export declare class ImageSchema<Src extends FileSource<ImageMetadata | undefine
36
37
  assert(path: SourcePath, src: unknown): SchemaAssertResult<Src>;
37
38
  nullable(): Schema<Src | null>;
38
39
  serialize(): SerializedSchema;
40
+ protected executePreview(): ReifiedPreview;
39
41
  }
40
42
  export declare const image: (options?: ImageOptions) => ImageSchema<ImageSource>;
@@ -1,5 +1,5 @@
1
1
  import { SelectorSource } from "../selector/index.js";
2
- import { SourcePath } from "../val/index.js";
2
+ import { ModuleFilePath, SourcePath } from "../val/index.js";
3
3
  import { SerializedArraySchema } from "./array.js";
4
4
  import { SerializedBooleanSchema } from "./boolean.js";
5
5
  import { SerializedFileSchema } from "./file.js";
@@ -16,6 +16,7 @@ import { SerializedDateSchema } from "./date.js";
16
16
  import { ValidationErrors } from "./validation/ValidationError.js";
17
17
  import { FileSource } from "../source/file.js";
18
18
  import { GenericRichTextSourceNode, RichTextSource } from "../source/richtext.js";
19
+ import { ReifiedPreview } from "../preview.js";
19
20
  export type SerializedSchema = SerializedStringSchema | SerializedLiteralSchema | SerializedBooleanSchema | SerializedNumberSchema | SerializedObjectSchema | SerializedArraySchema | SerializedUnionSchema | SerializedRichTextSchema | SerializedRecordSchema | SerializedKeyOfSchema | SerializedFileSchema | SerializedDateSchema | SerializedImageSchema;
20
21
  type Primitives = number | string | boolean | null | FileSource;
21
22
  export type AssertError = {
@@ -60,6 +61,7 @@ export declare abstract class Schema<Src extends SelectorSource> {
60
61
  abstract assert(path: SourcePath, src: unknown): SchemaAssertResult<Src>;
61
62
  abstract nullable(): Schema<Src | null>;
62
63
  abstract serialize(): SerializedSchema;
64
+ protected abstract executePreview(sourcePath: SourcePath | ModuleFilePath, src: Src): ReifiedPreview;
63
65
  /** MUTATES! since internal and perf sensitive */
64
66
  protected appendValidationError(current: ValidationErrors, path: SourcePath, message: string, value: unknown): ValidationErrors;
65
67
  }
@@ -5,6 +5,7 @@ import { Source, SourceObject } from "../source/index.js";
5
5
  import { SourcePath } from "../val/index.js";
6
6
  import { ValidationErrors } from "./validation/ValidationError.js";
7
7
  import { RawString } from "./string.js";
8
+ import { ReifiedPreview } from "../preview.js";
8
9
  export type SerializedKeyOfSchema = {
9
10
  type: "keyOf";
10
11
  path: SourcePath;
@@ -22,6 +23,7 @@ export declare class KeyOfSchema<Sel extends GenericSelector<SourceObject>, Src
22
23
  assert(path: SourcePath, src: unknown): SchemaAssertResult<Src>;
23
24
  nullable(): Schema<Src | null>;
24
25
  serialize(): SerializedSchema;
26
+ protected executePreview(): ReifiedPreview;
25
27
  }
26
28
  export declare const keyOf: <Src extends GenericSelector<SourceObject, undefined> & ValModuleBrand>(valModule: Src) => Schema<KeyOfSelector<Src>>;
27
29
  export {};
@@ -1,4 +1,5 @@
1
1
  import { Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
2
+ import { ReifiedPreview } from "../preview.js";
2
3
  import { SourcePath } from "../val/index.js";
3
4
  import { ValidationErrors } from "./validation/ValidationError.js";
4
5
  export type SerializedLiteralSchema = {
@@ -14,5 +15,6 @@ export declare class LiteralSchema<Src extends string | null> extends Schema<Src
14
15
  assert(path: SourcePath, src: unknown): SchemaAssertResult<Src>;
15
16
  nullable(): Schema<Src | null>;
16
17
  serialize(): SerializedSchema;
18
+ protected executePreview(): ReifiedPreview;
17
19
  }
18
20
  export declare const literal: <T extends string>(value: T) => LiteralSchema<T>;
@@ -1,4 +1,5 @@
1
1
  import { Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
2
+ import { ReifiedPreview } from "../preview.js";
2
3
  import { SourcePath } from "../val/index.js";
3
4
  import { ValidationErrors } from "./validation/ValidationError.js";
4
5
  type NumberOptions = {
@@ -18,6 +19,7 @@ export declare class NumberSchema<Src extends number | null> extends Schema<Src>
18
19
  assert(path: SourcePath, src: unknown): SchemaAssertResult<Src>;
19
20
  nullable(): Schema<Src>;
20
21
  serialize(): SerializedSchema;
22
+ protected executePreview(): ReifiedPreview;
21
23
  }
22
24
  export declare const number: (options?: NumberOptions) => Schema<number>;
23
25
  export {};
@@ -1,6 +1,7 @@
1
1
  import { Schema, SchemaAssertResult, SelectorOfSchema, SerializedSchema } from "./index.js";
2
+ import { ReifiedPreview } from "../preview.js";
2
3
  import { SelectorSource } from "../selector/index.js";
3
- import { SourcePath } from "../val/index.js";
4
+ import { ModuleFilePath, SourcePath } from "../val/index.js";
4
5
  import { ValidationErrors } from "./validation/ValidationError.js";
5
6
  export type SerializedObjectSchema = {
6
7
  type: "object";
@@ -36,6 +37,7 @@ export declare class ObjectSchema<Props extends ObjectSchemaProps, Src extends O
36
37
  assert(path: SourcePath, src: unknown): SchemaAssertResult<Src>;
37
38
  nullable(): Schema<Src | null>;
38
39
  serialize(): SerializedSchema;
40
+ protected executePreview(sourcePath: SourcePath | ModuleFilePath, src: Src): ReifiedPreview;
39
41
  }
40
42
  export declare const object: <Props extends ObjectSchemaProps>(schema: Props) => Schema<{ [key in keyof Props]: SelectorOfSchema<Props[key]>; }>;
41
43
  export {};
@@ -1,6 +1,8 @@
1
1
  import { Schema, SchemaAssertResult, SelectorOfSchema, SerializedSchema } from "./index.js";
2
+ import { ReifiedPreview } from "../preview.js";
2
3
  import { SelectorSource } from "../selector/index.js";
3
- import { SourcePath } from "../val/index.js";
4
+ import { ImageSource } from "../source/image.js";
5
+ import { ModuleFilePath, SourcePath } from "../val/index.js";
4
6
  import { ValidationErrors } from "./validation/ValidationError.js";
5
7
  export type SerializedRecordSchema = {
6
8
  type: "record";
@@ -15,5 +17,20 @@ export declare class RecordSchema<T extends Schema<SelectorSource>, Src extends
15
17
  assert(path: SourcePath, src: unknown): SchemaAssertResult<Src>;
16
18
  nullable(): Schema<Src | null>;
17
19
  serialize(): SerializedRecordSchema;
20
+ private previewInput;
21
+ protected executePreview(sourcePath: SourcePath | ModuleFilePath, src: Src): ReifiedPreview;
22
+ preview(input: {
23
+ layout: "list";
24
+ prepare: (input: {
25
+ key: string;
26
+ val: PreviewSelector<T>;
27
+ }) => {
28
+ title: string;
29
+ subtitle?: string | null;
30
+ image?: ImageSource | null;
31
+ };
32
+ }): this;
18
33
  }
19
- export declare const record: <S extends Schema<SelectorSource>>(schema: S) => Schema<Record<string, SelectorOfSchema<S>>>;
34
+ type PreviewSelector<T extends Schema<SelectorSource>> = T extends Schema<infer S> ? S : never;
35
+ export declare const record: <S extends Schema<SelectorSource>>(schema: S) => RecordSchema<S, Record<string, SelectorOfSchema<S>>>;
36
+ export {};
@@ -1,4 +1,5 @@
1
1
  import { Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
2
+ import { ReifiedPreview } from "../preview.js";
2
3
  import { ImageSource } from "../source/image.js";
3
4
  import { RichTextSource, RichTextOptions, SerializedRichTextOptions } from "../source/richtext.js";
4
5
  import { SourcePath } from "../val/index.js";
@@ -25,6 +26,7 @@ export declare class RichTextSchema<O extends RichTextOptions, Src extends RichT
25
26
  private recursiveAssert;
26
27
  nullable(): Schema<Src | null>;
27
28
  serialize(): SerializedSchema;
29
+ protected executePreview(): ReifiedPreview;
28
30
  }
29
31
  export declare const richtext: <O extends Partial<{
30
32
  style: Partial<{
@@ -1,4 +1,5 @@
1
1
  import { Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
2
+ import { ReifiedPreview } from "../preview.js";
2
3
  import { SourcePath } from "../val/index.js";
3
4
  import { ValidationErrors } from "./validation/ValidationError.js";
4
5
  type StringOptions = {
@@ -44,6 +45,7 @@ export declare class StringSchema<Src extends string | null> extends Schema<Src>
44
45
  nullable(): StringSchema<Src | null>;
45
46
  raw(): StringSchema<Src extends null ? RawString | null : RawString>;
46
47
  serialize(): SerializedSchema;
48
+ protected executePreview(): ReifiedPreview;
47
49
  }
48
50
  export declare const string: <T extends string>(options?: Record<string, never>) => StringSchema<T>;
49
51
  export {};
@@ -1,7 +1,8 @@
1
1
  import { Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
2
+ import { ReifiedPreview } from "../preview.js";
2
3
  import { SelectorSource } from "../selector/index.js";
3
4
  import { SourceObject } from "../source/index.js";
4
- import { SourcePath } from "../val/index.js";
5
+ import { ModuleFilePath, SourcePath } from "../val/index.js";
5
6
  import { SerializedLiteralSchema } from "./literal.js";
6
7
  import { SerializedObjectSchema } from "./object.js";
7
8
  import { ValidationErrors } from "./validation/ValidationError.js";
@@ -32,6 +33,7 @@ export declare class UnionSchema<Key extends string | Schema<string>, T extends
32
33
  nullable(): Schema<Src | null>;
33
34
  serialize(): SerializedSchema;
34
35
  constructor(key: Key, items: T, opt?: boolean);
36
+ protected executePreview(sourcePath: SourcePath | ModuleFilePath, src: Src): ReifiedPreview;
35
37
  }
36
38
  export declare const union: <Key extends string | Schema<string>, T extends Schema<Key extends string ? {
37
39
  [x: string]: import("../source/index.js").Source;
@@ -518,6 +518,11 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
518
518
  remote: this.isRemote
519
519
  };
520
520
  }
521
+ }, {
522
+ key: "executePreview",
523
+ value: function executePreview() {
524
+ return {};
525
+ }
521
526
  }]);
522
527
  }(Schema);
523
528
  var file = function file(options) {
@@ -740,6 +745,27 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
740
745
  opt: this.opt
741
746
  };
742
747
  }
748
+ }, {
749
+ key: "executePreview",
750
+ value: function executePreview(sourcePath, src) {
751
+ var res = {};
752
+ if (src === null) {
753
+ return res;
754
+ }
755
+ for (var _key2 in this.items) {
756
+ var itemSrc = src[_key2];
757
+ if (itemSrc === null || itemSrc === undefined) {
758
+ continue;
759
+ }
760
+ var subPath = unsafeCreateSourcePath(sourcePath, _key2);
761
+ var itemResult = this.items[_key2]["executePreview"](subPath, itemSrc);
762
+ for (var keyS in itemResult) {
763
+ var _key3 = keyS;
764
+ res[_key3] = itemResult[_key3];
765
+ }
766
+ }
767
+ return res;
768
+ }
743
769
  }]);
744
770
  }(Schema);
745
771
  var object = function object(schema) {
@@ -838,6 +864,27 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
838
864
  opt: this.opt
839
865
  };
840
866
  }
867
+ }, {
868
+ key: "executePreview",
869
+ value: function executePreview(sourcePath, src) {
870
+ var res = {};
871
+ if (src === null) {
872
+ return res;
873
+ }
874
+ for (var i = 0; i < ((src === null || src === void 0 ? void 0 : src.length) || 0); i++) {
875
+ var itemSrc = src[i];
876
+ if (itemSrc === null) {
877
+ continue;
878
+ }
879
+ var subPath = unsafeCreateSourcePath(sourcePath, i);
880
+ var itemResult = this.item["executePreview"](subPath, itemSrc);
881
+ for (var keyS in itemResult) {
882
+ var key = keyS;
883
+ res[key] = itemResult[key];
884
+ }
885
+ }
886
+ return res;
887
+ }
841
888
  }]);
842
889
  }(Schema);
843
890
  var array = function array(schema) {
@@ -921,6 +968,11 @@ var LiteralSchema = /*#__PURE__*/function (_Schema) {
921
968
  opt: this.opt
922
969
  };
923
970
  }
971
+ }, {
972
+ key: "executePreview",
973
+ value: function executePreview() {
974
+ return {};
975
+ }
924
976
  }]);
925
977
  }(Schema);
926
978
  var literal = function literal(value) {
@@ -1252,11 +1304,53 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
1252
1304
  opt: this.opt
1253
1305
  };
1254
1306
  }
1307
+ }, {
1308
+ key: "executePreview",
1309
+ value: function executePreview(sourcePath, src) {
1310
+ var res = {};
1311
+ if (src === null) {
1312
+ return res;
1313
+ }
1314
+ if (this.key instanceof LiteralSchema) {
1315
+ return res;
1316
+ }
1317
+ var unionKey = this.key;
1318
+ if (typeof unionKey === "string") {
1319
+ var thisSchema = this.items.find(
1320
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1321
+ function (item) {
1322
+ if (item instanceof ObjectSchema) {
1323
+ var itemKey = item.items[unionKey];
1324
+ if (itemKey instanceof LiteralSchema) {
1325
+ return _typeof(src) === "object" && unionKey in src && itemKey.value === src[unionKey];
1326
+ }
1327
+ }
1328
+ return false;
1329
+ });
1330
+ if (thisSchema) {
1331
+ var itemResult = thisSchema["executePreview"](sourcePath, src);
1332
+ for (var keyS in itemResult) {
1333
+ var _key3 = keyS;
1334
+ res[_key3] = itemResult[_key3];
1335
+ }
1336
+ return res;
1337
+ }
1338
+ res[sourcePath] = {
1339
+ status: "error",
1340
+ message: "Could not find a matching (object) schema for the union key: ".concat(unionKey)
1341
+ };
1342
+ }
1343
+ res[sourcePath] = {
1344
+ status: "error",
1345
+ message: "The schema of this value is wrong. Expected a object union schema, but union key is not a string. Got: '".concat(JSON.stringify(unionKey, null, 2), "'")
1346
+ };
1347
+ return res;
1348
+ }
1255
1349
  }]);
1256
1350
  }(Schema);
1257
1351
  var union = function union(key) {
1258
- for (var _len = arguments.length, objects = new Array(_len > 1 ? _len - 1 : 0), _key3 = 1; _key3 < _len; _key3++) {
1259
- objects[_key3 - 1] = arguments[_key3];
1352
+ for (var _len = arguments.length, objects = new Array(_len > 1 ? _len - 1 : 0), _key4 = 1; _key4 < _len; _key4++) {
1353
+ objects[_key4 - 1] = arguments[_key4];
1260
1354
  }
1261
1355
  return new UnionSchema(key, objects);
1262
1356
  };
@@ -1460,6 +1554,11 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
1460
1554
  remote: this.isRemote
1461
1555
  };
1462
1556
  }
1557
+ }, {
1558
+ key: "executePreview",
1559
+ value: function executePreview() {
1560
+ return {};
1561
+ }
1463
1562
  }]);
1464
1563
  }(Schema);
1465
1564
  var image = function image(options) {
@@ -1900,6 +1999,11 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
1900
1999
  options: serializedOptions
1901
2000
  };
1902
2001
  }
2002
+ }, {
2003
+ key: "executePreview",
2004
+ value: function executePreview() {
2005
+ return {};
2006
+ }
1903
2007
  }]);
1904
2008
  }(Schema);
1905
2009
  var richtext = function richtext(options) {
@@ -1912,6 +2016,7 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
1912
2016
  var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1913
2017
  _classCallCheck(this, RecordSchema);
1914
2018
  _this = _callSuper(this, RecordSchema);
2019
+ _defineProperty(_this, "previewInput", null);
1915
2020
  _this.item = item;
1916
2021
  _this.opt = opt;
1917
2022
  return _this;
@@ -2006,8 +2111,80 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
2006
2111
  opt: this.opt
2007
2112
  };
2008
2113
  }
2114
+ }, {
2115
+ key: "executePreview",
2116
+ value: function executePreview(sourcePath, src) {
2117
+ var res = {};
2118
+ if (src === null) {
2119
+ return res;
2120
+ }
2121
+ for (var key in src) {
2122
+ var itemSrc = src[key];
2123
+ if (itemSrc === null || itemSrc === undefined) {
2124
+ continue;
2125
+ }
2126
+ var subPath = unsafeCreateSourcePath(sourcePath, key);
2127
+ var itemResult = this.item["executePreview"](subPath, itemSrc);
2128
+ for (var keyS in itemResult) {
2129
+ var _key = keyS;
2130
+ res[_key] = itemResult[_key];
2131
+ }
2132
+ }
2133
+ if (this.previewInput) {
2134
+ var _this$previewInput = this.previewInput,
2135
+ prepare = _this$previewInput.prepare,
2136
+ layout = _this$previewInput.layout;
2137
+ if (layout !== "list") {
2138
+ res[sourcePath] = {
2139
+ status: "error",
2140
+ message: "Unknown layout type: " + layout
2141
+ };
2142
+ }
2143
+ try {
2144
+ res[sourcePath] = {
2145
+ status: "success",
2146
+ data: {
2147
+ layout: "list",
2148
+ items: Object.entries(src).map(function (_ref6) {
2149
+ var _ref7 = _slicedToArray(_ref6, 2),
2150
+ key = _ref7[0],
2151
+ val = _ref7[1];
2152
+ // NB NB: display is actually defined by the user
2153
+ var _prepare = prepare({
2154
+ key: key,
2155
+ val: val
2156
+ }),
2157
+ title = _prepare.title,
2158
+ subtitle = _prepare.subtitle,
2159
+ image = _prepare.image;
2160
+ return [key, {
2161
+ title: title,
2162
+ subtitle: subtitle,
2163
+ image: image
2164
+ }];
2165
+ })
2166
+ }
2167
+ };
2168
+ } catch (e) {
2169
+ res[sourcePath] = {
2170
+ status: "error",
2171
+ message: e instanceof Error ? e.message : "Unknown error"
2172
+ };
2173
+ }
2174
+ }
2175
+ return res;
2176
+ }
2177
+ }, {
2178
+ key: "preview",
2179
+ value: function preview(input) {
2180
+ this.previewInput = input;
2181
+ return this;
2182
+ }
2009
2183
  }]);
2010
2184
  }(Schema);
2185
+
2186
+ // TODO: improve this so that we do not get RawString and string, only string. Are there other things?
2187
+
2011
2188
  var record = function record(schema) {
2012
2189
  return new RecordSchema(schema);
2013
2190
  };
@@ -2352,6 +2529,11 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
2352
2529
  opt: this.opt
2353
2530
  };
2354
2531
  }
2532
+ }, {
2533
+ key: "executePreview",
2534
+ value: function executePreview() {
2535
+ return {};
2536
+ }
2355
2537
  }]);
2356
2538
  }(Schema);
2357
2539
  var number = function number(options) {
@@ -2498,6 +2680,11 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
2498
2680
  raw: this.isRaw
2499
2681
  };
2500
2682
  }
2683
+ }, {
2684
+ key: "executePreview",
2685
+ value: function executePreview() {
2686
+ return {};
2687
+ }
2501
2688
  }]);
2502
2689
  }(Schema);
2503
2690
  var string = function string(options) {
@@ -2573,6 +2760,11 @@ var BooleanSchema = /*#__PURE__*/function (_Schema) {
2573
2760
  opt: this.opt
2574
2761
  };
2575
2762
  }
2763
+ }, {
2764
+ key: "executePreview",
2765
+ value: function executePreview() {
2766
+ return {};
2767
+ }
2576
2768
  }]);
2577
2769
  }(Schema);
2578
2770
  var _boolean = function _boolean() {
@@ -2743,6 +2935,11 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
2743
2935
  values: values
2744
2936
  };
2745
2937
  }
2938
+ }, {
2939
+ key: "executePreview",
2940
+ value: function executePreview() {
2941
+ return {};
2942
+ }
2746
2943
  }]);
2747
2944
  }(Schema);
2748
2945
  var keyOf = function keyOf(valModule) {
@@ -2872,6 +3069,11 @@ var DateSchema = /*#__PURE__*/function (_Schema) {
2872
3069
  options: this.options
2873
3070
  };
2874
3071
  }
3072
+ }, {
3073
+ key: "executePreview",
3074
+ value: function executePreview() {
3075
+ return {};
3076
+ }
2875
3077
  }]);
2876
3078
  }(Schema);
2877
3079
  var date = function date(options) {
@@ -518,6 +518,11 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
518
518
  remote: this.isRemote
519
519
  };
520
520
  }
521
+ }, {
522
+ key: "executePreview",
523
+ value: function executePreview() {
524
+ return {};
525
+ }
521
526
  }]);
522
527
  }(Schema);
523
528
  var file = function file(options) {
@@ -740,6 +745,27 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
740
745
  opt: this.opt
741
746
  };
742
747
  }
748
+ }, {
749
+ key: "executePreview",
750
+ value: function executePreview(sourcePath, src) {
751
+ var res = {};
752
+ if (src === null) {
753
+ return res;
754
+ }
755
+ for (var _key2 in this.items) {
756
+ var itemSrc = src[_key2];
757
+ if (itemSrc === null || itemSrc === undefined) {
758
+ continue;
759
+ }
760
+ var subPath = unsafeCreateSourcePath(sourcePath, _key2);
761
+ var itemResult = this.items[_key2]["executePreview"](subPath, itemSrc);
762
+ for (var keyS in itemResult) {
763
+ var _key3 = keyS;
764
+ res[_key3] = itemResult[_key3];
765
+ }
766
+ }
767
+ return res;
768
+ }
743
769
  }]);
744
770
  }(Schema);
745
771
  var object = function object(schema) {
@@ -838,6 +864,27 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
838
864
  opt: this.opt
839
865
  };
840
866
  }
867
+ }, {
868
+ key: "executePreview",
869
+ value: function executePreview(sourcePath, src) {
870
+ var res = {};
871
+ if (src === null) {
872
+ return res;
873
+ }
874
+ for (var i = 0; i < ((src === null || src === void 0 ? void 0 : src.length) || 0); i++) {
875
+ var itemSrc = src[i];
876
+ if (itemSrc === null) {
877
+ continue;
878
+ }
879
+ var subPath = unsafeCreateSourcePath(sourcePath, i);
880
+ var itemResult = this.item["executePreview"](subPath, itemSrc);
881
+ for (var keyS in itemResult) {
882
+ var key = keyS;
883
+ res[key] = itemResult[key];
884
+ }
885
+ }
886
+ return res;
887
+ }
841
888
  }]);
842
889
  }(Schema);
843
890
  var array = function array(schema) {
@@ -921,6 +968,11 @@ var LiteralSchema = /*#__PURE__*/function (_Schema) {
921
968
  opt: this.opt
922
969
  };
923
970
  }
971
+ }, {
972
+ key: "executePreview",
973
+ value: function executePreview() {
974
+ return {};
975
+ }
924
976
  }]);
925
977
  }(Schema);
926
978
  var literal = function literal(value) {
@@ -1252,11 +1304,53 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
1252
1304
  opt: this.opt
1253
1305
  };
1254
1306
  }
1307
+ }, {
1308
+ key: "executePreview",
1309
+ value: function executePreview(sourcePath, src) {
1310
+ var res = {};
1311
+ if (src === null) {
1312
+ return res;
1313
+ }
1314
+ if (this.key instanceof LiteralSchema) {
1315
+ return res;
1316
+ }
1317
+ var unionKey = this.key;
1318
+ if (typeof unionKey === "string") {
1319
+ var thisSchema = this.items.find(
1320
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1321
+ function (item) {
1322
+ if (item instanceof ObjectSchema) {
1323
+ var itemKey = item.items[unionKey];
1324
+ if (itemKey instanceof LiteralSchema) {
1325
+ return _typeof(src) === "object" && unionKey in src && itemKey.value === src[unionKey];
1326
+ }
1327
+ }
1328
+ return false;
1329
+ });
1330
+ if (thisSchema) {
1331
+ var itemResult = thisSchema["executePreview"](sourcePath, src);
1332
+ for (var keyS in itemResult) {
1333
+ var _key3 = keyS;
1334
+ res[_key3] = itemResult[_key3];
1335
+ }
1336
+ return res;
1337
+ }
1338
+ res[sourcePath] = {
1339
+ status: "error",
1340
+ message: "Could not find a matching (object) schema for the union key: ".concat(unionKey)
1341
+ };
1342
+ }
1343
+ res[sourcePath] = {
1344
+ status: "error",
1345
+ message: "The schema of this value is wrong. Expected a object union schema, but union key is not a string. Got: '".concat(JSON.stringify(unionKey, null, 2), "'")
1346
+ };
1347
+ return res;
1348
+ }
1255
1349
  }]);
1256
1350
  }(Schema);
1257
1351
  var union = function union(key) {
1258
- for (var _len = arguments.length, objects = new Array(_len > 1 ? _len - 1 : 0), _key3 = 1; _key3 < _len; _key3++) {
1259
- objects[_key3 - 1] = arguments[_key3];
1352
+ for (var _len = arguments.length, objects = new Array(_len > 1 ? _len - 1 : 0), _key4 = 1; _key4 < _len; _key4++) {
1353
+ objects[_key4 - 1] = arguments[_key4];
1260
1354
  }
1261
1355
  return new UnionSchema(key, objects);
1262
1356
  };
@@ -1460,6 +1554,11 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
1460
1554
  remote: this.isRemote
1461
1555
  };
1462
1556
  }
1557
+ }, {
1558
+ key: "executePreview",
1559
+ value: function executePreview() {
1560
+ return {};
1561
+ }
1463
1562
  }]);
1464
1563
  }(Schema);
1465
1564
  var image = function image(options) {
@@ -1900,6 +1999,11 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
1900
1999
  options: serializedOptions
1901
2000
  };
1902
2001
  }
2002
+ }, {
2003
+ key: "executePreview",
2004
+ value: function executePreview() {
2005
+ return {};
2006
+ }
1903
2007
  }]);
1904
2008
  }(Schema);
1905
2009
  var richtext = function richtext(options) {
@@ -1912,6 +2016,7 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
1912
2016
  var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1913
2017
  _classCallCheck(this, RecordSchema);
1914
2018
  _this = _callSuper(this, RecordSchema);
2019
+ _defineProperty(_this, "previewInput", null);
1915
2020
  _this.item = item;
1916
2021
  _this.opt = opt;
1917
2022
  return _this;
@@ -2006,8 +2111,80 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
2006
2111
  opt: this.opt
2007
2112
  };
2008
2113
  }
2114
+ }, {
2115
+ key: "executePreview",
2116
+ value: function executePreview(sourcePath, src) {
2117
+ var res = {};
2118
+ if (src === null) {
2119
+ return res;
2120
+ }
2121
+ for (var key in src) {
2122
+ var itemSrc = src[key];
2123
+ if (itemSrc === null || itemSrc === undefined) {
2124
+ continue;
2125
+ }
2126
+ var subPath = unsafeCreateSourcePath(sourcePath, key);
2127
+ var itemResult = this.item["executePreview"](subPath, itemSrc);
2128
+ for (var keyS in itemResult) {
2129
+ var _key = keyS;
2130
+ res[_key] = itemResult[_key];
2131
+ }
2132
+ }
2133
+ if (this.previewInput) {
2134
+ var _this$previewInput = this.previewInput,
2135
+ prepare = _this$previewInput.prepare,
2136
+ layout = _this$previewInput.layout;
2137
+ if (layout !== "list") {
2138
+ res[sourcePath] = {
2139
+ status: "error",
2140
+ message: "Unknown layout type: " + layout
2141
+ };
2142
+ }
2143
+ try {
2144
+ res[sourcePath] = {
2145
+ status: "success",
2146
+ data: {
2147
+ layout: "list",
2148
+ items: Object.entries(src).map(function (_ref6) {
2149
+ var _ref7 = _slicedToArray(_ref6, 2),
2150
+ key = _ref7[0],
2151
+ val = _ref7[1];
2152
+ // NB NB: display is actually defined by the user
2153
+ var _prepare = prepare({
2154
+ key: key,
2155
+ val: val
2156
+ }),
2157
+ title = _prepare.title,
2158
+ subtitle = _prepare.subtitle,
2159
+ image = _prepare.image;
2160
+ return [key, {
2161
+ title: title,
2162
+ subtitle: subtitle,
2163
+ image: image
2164
+ }];
2165
+ })
2166
+ }
2167
+ };
2168
+ } catch (e) {
2169
+ res[sourcePath] = {
2170
+ status: "error",
2171
+ message: e instanceof Error ? e.message : "Unknown error"
2172
+ };
2173
+ }
2174
+ }
2175
+ return res;
2176
+ }
2177
+ }, {
2178
+ key: "preview",
2179
+ value: function preview(input) {
2180
+ this.previewInput = input;
2181
+ return this;
2182
+ }
2009
2183
  }]);
2010
2184
  }(Schema);
2185
+
2186
+ // TODO: improve this so that we do not get RawString and string, only string. Are there other things?
2187
+
2011
2188
  var record = function record(schema) {
2012
2189
  return new RecordSchema(schema);
2013
2190
  };
@@ -2352,6 +2529,11 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
2352
2529
  opt: this.opt
2353
2530
  };
2354
2531
  }
2532
+ }, {
2533
+ key: "executePreview",
2534
+ value: function executePreview() {
2535
+ return {};
2536
+ }
2355
2537
  }]);
2356
2538
  }(Schema);
2357
2539
  var number = function number(options) {
@@ -2498,6 +2680,11 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
2498
2680
  raw: this.isRaw
2499
2681
  };
2500
2682
  }
2683
+ }, {
2684
+ key: "executePreview",
2685
+ value: function executePreview() {
2686
+ return {};
2687
+ }
2501
2688
  }]);
2502
2689
  }(Schema);
2503
2690
  var string = function string(options) {
@@ -2573,6 +2760,11 @@ var BooleanSchema = /*#__PURE__*/function (_Schema) {
2573
2760
  opt: this.opt
2574
2761
  };
2575
2762
  }
2763
+ }, {
2764
+ key: "executePreview",
2765
+ value: function executePreview() {
2766
+ return {};
2767
+ }
2576
2768
  }]);
2577
2769
  }(Schema);
2578
2770
  var _boolean = function _boolean() {
@@ -2743,6 +2935,11 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
2743
2935
  values: values
2744
2936
  };
2745
2937
  }
2938
+ }, {
2939
+ key: "executePreview",
2940
+ value: function executePreview() {
2941
+ return {};
2942
+ }
2746
2943
  }]);
2747
2944
  }(Schema);
2748
2945
  var keyOf = function keyOf(valModule) {
@@ -2872,6 +3069,11 @@ var DateSchema = /*#__PURE__*/function (_Schema) {
2872
3069
  options: this.options
2873
3070
  };
2874
3071
  }
3072
+ }, {
3073
+ key: "executePreview",
3074
+ value: function executePreview() {
3075
+ return {};
3076
+ }
2875
3077
  }]);
2876
3078
  }(Schema);
2877
3079
  var date = function date(options) {
@@ -516,6 +516,11 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
516
516
  remote: this.isRemote
517
517
  };
518
518
  }
519
+ }, {
520
+ key: "executePreview",
521
+ value: function executePreview() {
522
+ return {};
523
+ }
519
524
  }]);
520
525
  }(Schema);
521
526
  var file = function file(options) {
@@ -738,6 +743,27 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
738
743
  opt: this.opt
739
744
  };
740
745
  }
746
+ }, {
747
+ key: "executePreview",
748
+ value: function executePreview(sourcePath, src) {
749
+ var res = {};
750
+ if (src === null) {
751
+ return res;
752
+ }
753
+ for (var _key2 in this.items) {
754
+ var itemSrc = src[_key2];
755
+ if (itemSrc === null || itemSrc === undefined) {
756
+ continue;
757
+ }
758
+ var subPath = unsafeCreateSourcePath(sourcePath, _key2);
759
+ var itemResult = this.items[_key2]["executePreview"](subPath, itemSrc);
760
+ for (var keyS in itemResult) {
761
+ var _key3 = keyS;
762
+ res[_key3] = itemResult[_key3];
763
+ }
764
+ }
765
+ return res;
766
+ }
741
767
  }]);
742
768
  }(Schema);
743
769
  var object = function object(schema) {
@@ -836,6 +862,27 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
836
862
  opt: this.opt
837
863
  };
838
864
  }
865
+ }, {
866
+ key: "executePreview",
867
+ value: function executePreview(sourcePath, src) {
868
+ var res = {};
869
+ if (src === null) {
870
+ return res;
871
+ }
872
+ for (var i = 0; i < ((src === null || src === void 0 ? void 0 : src.length) || 0); i++) {
873
+ var itemSrc = src[i];
874
+ if (itemSrc === null) {
875
+ continue;
876
+ }
877
+ var subPath = unsafeCreateSourcePath(sourcePath, i);
878
+ var itemResult = this.item["executePreview"](subPath, itemSrc);
879
+ for (var keyS in itemResult) {
880
+ var key = keyS;
881
+ res[key] = itemResult[key];
882
+ }
883
+ }
884
+ return res;
885
+ }
839
886
  }]);
840
887
  }(Schema);
841
888
  var array = function array(schema) {
@@ -919,6 +966,11 @@ var LiteralSchema = /*#__PURE__*/function (_Schema) {
919
966
  opt: this.opt
920
967
  };
921
968
  }
969
+ }, {
970
+ key: "executePreview",
971
+ value: function executePreview() {
972
+ return {};
973
+ }
922
974
  }]);
923
975
  }(Schema);
924
976
  var literal = function literal(value) {
@@ -1250,11 +1302,53 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
1250
1302
  opt: this.opt
1251
1303
  };
1252
1304
  }
1305
+ }, {
1306
+ key: "executePreview",
1307
+ value: function executePreview(sourcePath, src) {
1308
+ var res = {};
1309
+ if (src === null) {
1310
+ return res;
1311
+ }
1312
+ if (this.key instanceof LiteralSchema) {
1313
+ return res;
1314
+ }
1315
+ var unionKey = this.key;
1316
+ if (typeof unionKey === "string") {
1317
+ var thisSchema = this.items.find(
1318
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1319
+ function (item) {
1320
+ if (item instanceof ObjectSchema) {
1321
+ var itemKey = item.items[unionKey];
1322
+ if (itemKey instanceof LiteralSchema) {
1323
+ return _typeof(src) === "object" && unionKey in src && itemKey.value === src[unionKey];
1324
+ }
1325
+ }
1326
+ return false;
1327
+ });
1328
+ if (thisSchema) {
1329
+ var itemResult = thisSchema["executePreview"](sourcePath, src);
1330
+ for (var keyS in itemResult) {
1331
+ var _key3 = keyS;
1332
+ res[_key3] = itemResult[_key3];
1333
+ }
1334
+ return res;
1335
+ }
1336
+ res[sourcePath] = {
1337
+ status: "error",
1338
+ message: "Could not find a matching (object) schema for the union key: ".concat(unionKey)
1339
+ };
1340
+ }
1341
+ res[sourcePath] = {
1342
+ status: "error",
1343
+ message: "The schema of this value is wrong. Expected a object union schema, but union key is not a string. Got: '".concat(JSON.stringify(unionKey, null, 2), "'")
1344
+ };
1345
+ return res;
1346
+ }
1253
1347
  }]);
1254
1348
  }(Schema);
1255
1349
  var union = function union(key) {
1256
- for (var _len = arguments.length, objects = new Array(_len > 1 ? _len - 1 : 0), _key3 = 1; _key3 < _len; _key3++) {
1257
- objects[_key3 - 1] = arguments[_key3];
1350
+ for (var _len = arguments.length, objects = new Array(_len > 1 ? _len - 1 : 0), _key4 = 1; _key4 < _len; _key4++) {
1351
+ objects[_key4 - 1] = arguments[_key4];
1258
1352
  }
1259
1353
  return new UnionSchema(key, objects);
1260
1354
  };
@@ -1458,6 +1552,11 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
1458
1552
  remote: this.isRemote
1459
1553
  };
1460
1554
  }
1555
+ }, {
1556
+ key: "executePreview",
1557
+ value: function executePreview() {
1558
+ return {};
1559
+ }
1461
1560
  }]);
1462
1561
  }(Schema);
1463
1562
  var image = function image(options) {
@@ -1898,6 +1997,11 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
1898
1997
  options: serializedOptions
1899
1998
  };
1900
1999
  }
2000
+ }, {
2001
+ key: "executePreview",
2002
+ value: function executePreview() {
2003
+ return {};
2004
+ }
1901
2005
  }]);
1902
2006
  }(Schema);
1903
2007
  var richtext = function richtext(options) {
@@ -1910,6 +2014,7 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
1910
2014
  var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1911
2015
  _classCallCheck(this, RecordSchema);
1912
2016
  _this = _callSuper(this, RecordSchema);
2017
+ _defineProperty(_this, "previewInput", null);
1913
2018
  _this.item = item;
1914
2019
  _this.opt = opt;
1915
2020
  return _this;
@@ -2004,8 +2109,80 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
2004
2109
  opt: this.opt
2005
2110
  };
2006
2111
  }
2112
+ }, {
2113
+ key: "executePreview",
2114
+ value: function executePreview(sourcePath, src) {
2115
+ var res = {};
2116
+ if (src === null) {
2117
+ return res;
2118
+ }
2119
+ for (var key in src) {
2120
+ var itemSrc = src[key];
2121
+ if (itemSrc === null || itemSrc === undefined) {
2122
+ continue;
2123
+ }
2124
+ var subPath = unsafeCreateSourcePath(sourcePath, key);
2125
+ var itemResult = this.item["executePreview"](subPath, itemSrc);
2126
+ for (var keyS in itemResult) {
2127
+ var _key = keyS;
2128
+ res[_key] = itemResult[_key];
2129
+ }
2130
+ }
2131
+ if (this.previewInput) {
2132
+ var _this$previewInput = this.previewInput,
2133
+ prepare = _this$previewInput.prepare,
2134
+ layout = _this$previewInput.layout;
2135
+ if (layout !== "list") {
2136
+ res[sourcePath] = {
2137
+ status: "error",
2138
+ message: "Unknown layout type: " + layout
2139
+ };
2140
+ }
2141
+ try {
2142
+ res[sourcePath] = {
2143
+ status: "success",
2144
+ data: {
2145
+ layout: "list",
2146
+ items: Object.entries(src).map(function (_ref6) {
2147
+ var _ref7 = _slicedToArray(_ref6, 2),
2148
+ key = _ref7[0],
2149
+ val = _ref7[1];
2150
+ // NB NB: display is actually defined by the user
2151
+ var _prepare = prepare({
2152
+ key: key,
2153
+ val: val
2154
+ }),
2155
+ title = _prepare.title,
2156
+ subtitle = _prepare.subtitle,
2157
+ image = _prepare.image;
2158
+ return [key, {
2159
+ title: title,
2160
+ subtitle: subtitle,
2161
+ image: image
2162
+ }];
2163
+ })
2164
+ }
2165
+ };
2166
+ } catch (e) {
2167
+ res[sourcePath] = {
2168
+ status: "error",
2169
+ message: e instanceof Error ? e.message : "Unknown error"
2170
+ };
2171
+ }
2172
+ }
2173
+ return res;
2174
+ }
2175
+ }, {
2176
+ key: "preview",
2177
+ value: function preview(input) {
2178
+ this.previewInput = input;
2179
+ return this;
2180
+ }
2007
2181
  }]);
2008
2182
  }(Schema);
2183
+
2184
+ // TODO: improve this so that we do not get RawString and string, only string. Are there other things?
2185
+
2009
2186
  var record = function record(schema) {
2010
2187
  return new RecordSchema(schema);
2011
2188
  };
@@ -2350,6 +2527,11 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
2350
2527
  opt: this.opt
2351
2528
  };
2352
2529
  }
2530
+ }, {
2531
+ key: "executePreview",
2532
+ value: function executePreview() {
2533
+ return {};
2534
+ }
2353
2535
  }]);
2354
2536
  }(Schema);
2355
2537
  var number = function number(options) {
@@ -2496,6 +2678,11 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
2496
2678
  raw: this.isRaw
2497
2679
  };
2498
2680
  }
2681
+ }, {
2682
+ key: "executePreview",
2683
+ value: function executePreview() {
2684
+ return {};
2685
+ }
2499
2686
  }]);
2500
2687
  }(Schema);
2501
2688
  var string = function string(options) {
@@ -2571,6 +2758,11 @@ var BooleanSchema = /*#__PURE__*/function (_Schema) {
2571
2758
  opt: this.opt
2572
2759
  };
2573
2760
  }
2761
+ }, {
2762
+ key: "executePreview",
2763
+ value: function executePreview() {
2764
+ return {};
2765
+ }
2574
2766
  }]);
2575
2767
  }(Schema);
2576
2768
  var _boolean = function _boolean() {
@@ -2741,6 +2933,11 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
2741
2933
  values: values
2742
2934
  };
2743
2935
  }
2936
+ }, {
2937
+ key: "executePreview",
2938
+ value: function executePreview() {
2939
+ return {};
2940
+ }
2744
2941
  }]);
2745
2942
  }(Schema);
2746
2943
  var keyOf = function keyOf(valModule) {
@@ -2870,6 +3067,11 @@ var DateSchema = /*#__PURE__*/function (_Schema) {
2870
3067
  options: this.options
2871
3068
  };
2872
3069
  }
3070
+ }, {
3071
+ key: "executePreview",
3072
+ value: function executePreview() {
3073
+ return {};
3074
+ }
2873
3075
  }]);
2874
3076
  }(Schema);
2875
3077
  var date = function date(options) {
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var dist_valbuildCore = require('./index-895564f9.cjs.dev.js');
5
+ var dist_valbuildCore = require('./index-2ca75670.cjs.dev.js');
6
6
  require('./result-bb1f436e.cjs.dev.js');
7
7
 
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var dist_valbuildCore = require('./index-ee3d5938.cjs.prod.js');
5
+ var dist_valbuildCore = require('./index-5d34673d.cjs.prod.js');
6
6
  require('./result-787e35f6.cjs.prod.js');
7
7
 
8
8
 
@@ -1,2 +1,2 @@
1
- export { A as ArraySchema, B as BooleanSchema, e as DEFAULT_APP_HOST, D as DEFAULT_CONTENT_HOST, f as DEFAULT_VAL_REMOTE_HOST, o as DateSchema, F as FATAL_ERROR_TYPES, g as FILE_REF_PROP, h as FILE_REF_SUBTYPE_TAG, n as FileSchema, G as GenericSelector, l as ImageSchema, I as Internal, K as KeyOfSchema, L as LiteralSchema, M as ModuleFilePathSep, N as NumberSchema, O as ObjectSchema, R as RecordSchema, p as RichTextSchema, S as Schema, k as StringSchema, U as UnionSchema, V as VAL_EXTENSION, j as derefPatch, q as deserializeSchema, i as initVal, m as modules } from './index-ba3bd117.esm.js';
1
+ export { A as ArraySchema, B as BooleanSchema, e as DEFAULT_APP_HOST, D as DEFAULT_CONTENT_HOST, f as DEFAULT_VAL_REMOTE_HOST, o as DateSchema, F as FATAL_ERROR_TYPES, g as FILE_REF_PROP, h as FILE_REF_SUBTYPE_TAG, n as FileSchema, G as GenericSelector, l as ImageSchema, I as Internal, K as KeyOfSchema, L as LiteralSchema, M as ModuleFilePathSep, N as NumberSchema, O as ObjectSchema, R as RecordSchema, p as RichTextSchema, S as Schema, k as StringSchema, U as UnionSchema, V as VAL_EXTENSION, j as derefPatch, q as deserializeSchema, i as initVal, m as modules } from './index-e30d6317.esm.js';
2
2
  import './result-daff1cae.esm.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valbuild/core",
3
- "version": "0.77.0",
3
+ "version": "0.78.0",
4
4
  "private": false,
5
5
  "description": "Val - supercharged hard-coded content",
6
6
  "scripts": {
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var dist_valbuildCore = require('../../dist/index-895564f9.cjs.dev.js');
5
+ var dist_valbuildCore = require('../../dist/index-2ca75670.cjs.dev.js');
6
6
  var result = require('../../dist/result-bb1f436e.cjs.dev.js');
7
7
  var util = require('../../dist/util-b213092b.cjs.dev.js');
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var dist_valbuildCore = require('../../dist/index-ee3d5938.cjs.prod.js');
5
+ var dist_valbuildCore = require('../../dist/index-5d34673d.cjs.prod.js');
6
6
  var result = require('../../dist/result-787e35f6.cjs.prod.js');
7
7
  var util = require('../../dist/util-030d8a1f.cjs.prod.js');
8
8
 
@@ -1,5 +1,5 @@
1
- import { _ as _typeof, a as _slicedToArray, P as PatchError, s as splitModuleFilePathAndModulePath, b as _createClass, c as _classCallCheck, d as _toConsumableArray } from '../../dist/index-ba3bd117.esm.js';
2
- export { P as PatchError } from '../../dist/index-ba3bd117.esm.js';
1
+ import { _ as _typeof, a as _slicedToArray, P as PatchError, s as splitModuleFilePathAndModulePath, b as _createClass, c as _classCallCheck, d as _toConsumableArray } from '../../dist/index-e30d6317.esm.js';
2
+ export { P as PatchError } from '../../dist/index-e30d6317.esm.js';
3
3
  import { f as isNonEmpty, e as err, o as ok, m as map, g as flatMap, i as isErr, h as flatMapReduce, j as filterOrElse, k as mapErr, l as map$1, n as all, p as flatten, q as allT } from '../../dist/result-daff1cae.esm.js';
4
4
  import { p as pipe } from '../../dist/util-18613e99.esm.js';
5
5