@valbuild/core 0.48.0 → 0.49.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.
@@ -2,6 +2,7 @@ export { initVal } from "./initVal.js";
2
2
  export type { InitVal, ValConfig, ValConstructor } from "./initVal.js";
3
3
  export { Schema, type SerializedSchema, type SelectorOfSchema } from "./schema/index.js";
4
4
  export type { ImageMetadata } from "./schema/image.js";
5
+ export type { FileMetadata } from "./schema/file.js";
5
6
  export type { LinkSource } from "./source/link.js";
6
7
  export type { ValModule, SerializedModule, InferValModuleType } from "./module.js";
7
8
  export type { SourceObject, SourcePrimitive, Source } from "./source/index.js";
@@ -36,6 +37,7 @@ export { type SerializedStringSchema, StringSchema } from "./schema/string.js";
36
37
  export { type SerializedNumberSchema, NumberSchema } from "./schema/number.js";
37
38
  export { type SerializedBooleanSchema, BooleanSchema } from "./schema/boolean.js";
38
39
  export { type SerializedImageSchema, ImageSchema } from "./schema/image.js";
40
+ export { type SerializedFileSchema, FileSchema } from "./schema/file.js";
39
41
  export { type SerializedRichTextSchema, RichTextSchema, } from "./schema/richtext.js";
40
42
  export { type SerializedUnionSchema, UnionSchema } from "./schema/union.js";
41
43
  export { type SerializedLiteralSchema, LiteralSchema } from "./schema/literal.js";
@@ -9,6 +9,7 @@ import { image } from "./schema/image.js";
9
9
  import { literal } from "./schema/literal.js";
10
10
  import { keyOf } from "./schema/keyOf.js";
11
11
  import { record } from "./schema/record.js";
12
+ import { file } from "./schema/file.js";
12
13
  export type InitSchema = {
13
14
  readonly string: typeof string;
14
15
  readonly boolean: typeof boolean;
@@ -21,6 +22,7 @@ export type InitSchema = {
21
22
  readonly literal: typeof literal;
22
23
  readonly keyOf: typeof keyOf;
23
24
  readonly record: typeof record;
25
+ readonly file: typeof file;
24
26
  };
25
27
  export declare function initSchema(): {
26
28
  string: <T extends string>(options?: {
@@ -53,4 +55,5 @@ export declare function initSchema(): {
53
55
  literal: <T_2 extends string>(value: T_2) => import("./schema/index.js").Schema<T_2>;
54
56
  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 any[] ? number : S_2 extends import("./source/index.js").SourceObject ? keyof S_2 : S_2 extends Record<string, any> ? string : never : never>;
55
57
  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>>>;
58
+ file: (options?: import("./schema/file.js").FileOptions | undefined) => import("./schema/index.js").Schema<import("./index.js").FileSource<import("./schema/file.js").FileMetadata>>;
56
59
  };
@@ -1,5 +1,28 @@
1
1
  import { Json } from "../Json.js";
2
2
  import { FileSource } from "../source/file.js";
3
+ import { Schema, SerializedSchema } from "./index.js";
4
+ import { SourcePath } from "../val/index.js";
5
+ import { ValidationErrors } from "./validation/ValidationError.js";
6
+ export type FileOptions = Record<string, never>;
7
+ export type SerializedFileSchema = {
8
+ type: "file";
9
+ options?: FileOptions;
10
+ opt: boolean;
11
+ };
12
+ export type FileMetadata = {
13
+ sha256: string;
14
+ mimeType?: string;
15
+ };
16
+ export declare class FileSchema<Src extends FileSource<FileMetadata | undefined> | null> extends Schema<Src> {
17
+ readonly options?: FileOptions | undefined;
18
+ readonly opt: boolean;
19
+ constructor(options?: FileOptions | undefined, opt?: boolean);
20
+ validate(path: SourcePath, src: Src): ValidationErrors;
21
+ assert(src: Src): boolean;
22
+ optional(): Schema<Src | null>;
23
+ serialize(): SerializedSchema;
24
+ }
25
+ export declare const file: (options?: FileOptions) => Schema<FileSource<FileMetadata>>;
3
26
  export declare function convertFileSource<Metadata extends {
4
27
  readonly [key: string]: Json;
5
28
  } | undefined = {
@@ -2,6 +2,7 @@ import { SelectorSource } from "../selector/index.js";
2
2
  import { SourcePath } from "../val/index.js";
3
3
  import { SerializedArraySchema } from "./array.js";
4
4
  import { SerializedBooleanSchema } from "./boolean.js";
5
+ import { SerializedFileSchema } from "./file.js";
5
6
  import { SerializedImageSchema } from "./image.js";
6
7
  import { SerializedKeyOfSchema } from "./keyOf.js";
7
8
  import { SerializedLiteralSchema } from "./literal.js";
@@ -12,7 +13,7 @@ import { SerializedRichTextSchema } from "./richtext.js";
12
13
  import { SerializedStringSchema } from "./string.js";
13
14
  import { SerializedUnionSchema } from "./union.js";
14
15
  import { ValidationErrors } from "./validation/ValidationError.js";
15
- export type SerializedSchema = SerializedStringSchema | SerializedLiteralSchema | SerializedBooleanSchema | SerializedNumberSchema | SerializedObjectSchema | SerializedArraySchema | SerializedUnionSchema | SerializedRichTextSchema | SerializedRecordSchema | SerializedKeyOfSchema | SerializedImageSchema;
16
+ export type SerializedSchema = SerializedStringSchema | SerializedLiteralSchema | SerializedBooleanSchema | SerializedNumberSchema | SerializedObjectSchema | SerializedArraySchema | SerializedUnionSchema | SerializedRichTextSchema | SerializedRecordSchema | SerializedKeyOfSchema | SerializedFileSchema | SerializedImageSchema;
16
17
  export declare abstract class Schema<Src extends SelectorSource> {
17
18
  abstract validate(path: SourcePath, src: Src): ValidationErrors;
18
19
  abstract assert(src: Src): boolean;
@@ -1,2 +1,2 @@
1
- export declare const ValidationFix: readonly ["image:add-metadata", "image:replace-metadata"];
1
+ export declare const ValidationFix: readonly ["image:add-metadata", "image:replace-metadata", "file:add-metadata", "file:check-metadata"];
2
2
  export type ValidationFix = (typeof ValidationFix)[number];
@@ -1,4 +1,4 @@
1
- import { p as _objectSpread2, h as _slicedToArray, c as _createClass, b as _classCallCheck, q as Sym, C as Call, r as StringLiteral, s as StringTemplate, e as _typeof, k as isSerializedVal, F as FILE_REF_PROP, V as VAL_EXTENSION, l as convertFileSource, d as _defineProperty, E as Expr, S as Schema, t as _toConsumableArray, N as NilSym } from './index-5750c299.esm.js';
1
+ import { r as _objectSpread2, i as _slicedToArray, c as _createClass, b as _classCallCheck, s as Sym, C as Call, t as StringLiteral, u as StringTemplate, e as _typeof, l as isSerializedVal, F as FILE_REF_PROP, V as VAL_EXTENSION, m as convertFileSource, d as _defineProperty, E as Expr, S as Schema, v as _toConsumableArray, N as NilSym } from './index-6cea0f23.esm.js';
2
2
  import { i as isErr, e as err, o as ok, a as isOk } from './result-b96df128.esm.js';
3
3
 
4
4
  var WHITE_SPACE = ["\n", "\r", "\t", " "];
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index$1 = require('./index-7b467ee6.cjs.prod.js');
3
+ var index$1 = require('./index-af44930c.cjs.prod.js');
4
4
  var result = require('./result-26f67b40.cjs.prod.js');
5
5
 
6
6
  var WHITE_SPACE = ["\n", "\r", "\t", " "];
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index$1 = require('./index-d23e237a.cjs.dev.js');
3
+ var index$1 = require('./index-e8fbff39.cjs.dev.js');
4
4
  var result = require('./result-48320acd.cjs.dev.js');
5
5
 
6
6
  var WHITE_SPACE = ["\n", "\r", "\t", " "];
@@ -420,25 +420,103 @@ var FILE_REF_PROP = "_ref";
420
420
  *
421
421
  */
422
422
 
423
- function file(ref, metadata) {
423
+ function file$1(ref, metadata) {
424
424
  return _defineProperty(_defineProperty(_defineProperty({}, FILE_REF_PROP, ref), VAL_EXTENSION, "file"), "metadata", metadata);
425
425
  }
426
426
  function isFile(obj) {
427
427
  return _typeof(obj) === "object" && obj !== null && VAL_EXTENSION in obj && obj[VAL_EXTENSION] === "file" && FILE_REF_PROP in obj && typeof obj[FILE_REF_PROP] === "string";
428
428
  }
429
429
 
430
+ var FileSchema = /*#__PURE__*/function (_Schema) {
431
+ _inherits(FileSchema, _Schema);
432
+ var _super = _createSuper(FileSchema);
433
+ function FileSchema(options) {
434
+ var _this;
435
+ var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
436
+ _classCallCheck(this, FileSchema);
437
+ _this = _super.call(this);
438
+ _this.options = options;
439
+ _this.opt = opt;
440
+ return _this;
441
+ }
442
+ _createClass(FileSchema, [{
443
+ key: "validate",
444
+ value: function validate(path, src) {
445
+ if (this.opt && (src === null || src === undefined)) {
446
+ return false;
447
+ }
448
+ if (src === null || src === undefined) {
449
+ return _defineProperty({}, path, [{
450
+ message: "Non-optional file was null or undefined.",
451
+ value: src
452
+ }]);
453
+ }
454
+ if (typeof src[FILE_REF_PROP] !== "string") {
455
+ return _defineProperty({}, path, [{
456
+ message: "File did not have a file reference string. Got: ".concat(_typeof(src[FILE_REF_PROP])),
457
+ value: src
458
+ }]);
459
+ }
460
+ if (src[VAL_EXTENSION] !== "file") {
461
+ return _defineProperty({}, path, [{
462
+ message: "File did not have the valid file extension type. Got: ".concat(src[VAL_EXTENSION]),
463
+ value: src
464
+ }]);
465
+ }
466
+ if (src.metadata) {
467
+ return _defineProperty({}, path, [{
468
+ message: "Found metadata, but it could not be validated. File metadata must be an object with the required props: width (positive number), height (positive number) and sha256 (string of length 64 of the base16 hash).",
469
+ // These validation errors will have to be picked up by logic outside of this package and revalidated. Reasons: 1) we have to read files to verify the metadata, which is handled differently in different runtimes (Browser, QuickJS, Node.js); 2) we want to keep this package dependency free.
470
+ value: src,
471
+ fixes: ["file:check-metadata"]
472
+ }]);
473
+ }
474
+ return _defineProperty({}, path, [{
475
+ message: "Missing File metadata.",
476
+ value: src,
477
+ fixes: ["file:add-metadata"]
478
+ }]);
479
+ }
480
+ }, {
481
+ key: "assert",
482
+ value: function assert(src) {
483
+ if (this.opt && (src === null || src === undefined)) {
484
+ return true;
485
+ }
486
+ return (src === null || src === void 0 ? void 0 : src[FILE_REF_PROP]) === "file" && (src === null || src === void 0 ? void 0 : src[VAL_EXTENSION]) === "file";
487
+ }
488
+ }, {
489
+ key: "optional",
490
+ value: function optional() {
491
+ return new FileSchema(this.options, true);
492
+ }
493
+ }, {
494
+ key: "serialize",
495
+ value: function serialize() {
496
+ return {
497
+ type: "file",
498
+ options: this.options,
499
+ opt: this.opt
500
+ };
501
+ }
502
+ }]);
503
+ return FileSchema;
504
+ }(Schema);
505
+ var file = function file(options) {
506
+ return new FileSchema(options);
507
+ };
430
508
  function convertFileSource(src) {
431
- var _src$metadata2;
509
+ var _src$metadata3, _src$metadata4;
432
510
  // TODO: /public should be configurable
433
511
  if (!src[FILE_REF_PROP].startsWith("/public")) {
434
- var _src$metadata;
512
+ var _src$metadata, _src$metadata2;
435
513
  return {
436
- url: src[FILE_REF_PROP] + "?sha256=".concat((_src$metadata = src.metadata) === null || _src$metadata === void 0 ? void 0 : _src$metadata.sha256),
514
+ url: src[FILE_REF_PROP] + ((_src$metadata = src.metadata) !== null && _src$metadata !== void 0 && _src$metadata.sha256 ? "?sha256=".concat((_src$metadata2 = src.metadata) === null || _src$metadata2 === void 0 ? void 0 : _src$metadata2.sha256) : ""),
437
515
  metadata: src.metadata
438
516
  };
439
517
  }
440
518
  return {
441
- url: src[FILE_REF_PROP].slice("/public".length) + "?sha256=".concat((_src$metadata2 = src.metadata) === null || _src$metadata2 === void 0 ? void 0 : _src$metadata2.sha256),
519
+ url: src[FILE_REF_PROP].slice("/public".length) + ((_src$metadata3 = src.metadata) !== null && _src$metadata3 !== void 0 && _src$metadata3.sha256 ? "?sha256=".concat((_src$metadata4 = src.metadata) === null || _src$metadata4 === void 0 ? void 0 : _src$metadata4.sha256) : ""),
442
520
  metadata: src.metadata
443
521
  };
444
522
  }
@@ -475,4 +553,4 @@ function getValPath(valOrSelector) {
475
553
  return valOrSelector[Path];
476
554
  }
477
555
 
478
- export { Call as C, Expr as E, FILE_REF_PROP as F, GetSchema as G, NilSym as N, Path as P, Schema as S, VAL_EXTENSION as V, _inherits as _, _createSuper as a, _classCallCheck as b, _createClass as c, _defineProperty as d, _typeof as e, file as f, getValPath as g, _slicedToArray as h, isFile as i, GetSource as j, isSerializedVal as k, convertFileSource as l, getSchema as m, isVal as n, GenericSelector as o, _objectSpread2 as p, Sym as q, StringLiteral as r, StringTemplate as s, _toConsumableArray as t };
556
+ export { Call as C, Expr as E, FILE_REF_PROP as F, GetSchema as G, NilSym as N, Path as P, Schema as S, VAL_EXTENSION as V, _inherits as _, _createSuper as a, _classCallCheck as b, _createClass as c, _defineProperty as d, _typeof as e, file as f, getValPath as g, file$1 as h, _slicedToArray as i, isFile as j, GetSource as k, isSerializedVal as l, convertFileSource as m, getSchema as n, isVal as o, GenericSelector as p, FileSchema as q, _objectSpread2 as r, Sym as s, StringLiteral as t, StringTemplate as u, _toConsumableArray as v };
@@ -422,25 +422,103 @@ var FILE_REF_PROP = "_ref";
422
422
  *
423
423
  */
424
424
 
425
- function file(ref, metadata) {
425
+ function file$1(ref, metadata) {
426
426
  return _defineProperty(_defineProperty(_defineProperty({}, FILE_REF_PROP, ref), VAL_EXTENSION, "file"), "metadata", metadata);
427
427
  }
428
428
  function isFile(obj) {
429
429
  return _typeof(obj) === "object" && obj !== null && VAL_EXTENSION in obj && obj[VAL_EXTENSION] === "file" && FILE_REF_PROP in obj && typeof obj[FILE_REF_PROP] === "string";
430
430
  }
431
431
 
432
+ var FileSchema = /*#__PURE__*/function (_Schema) {
433
+ _inherits(FileSchema, _Schema);
434
+ var _super = _createSuper(FileSchema);
435
+ function FileSchema(options) {
436
+ var _this;
437
+ var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
438
+ _classCallCheck(this, FileSchema);
439
+ _this = _super.call(this);
440
+ _this.options = options;
441
+ _this.opt = opt;
442
+ return _this;
443
+ }
444
+ _createClass(FileSchema, [{
445
+ key: "validate",
446
+ value: function validate(path, src) {
447
+ if (this.opt && (src === null || src === undefined)) {
448
+ return false;
449
+ }
450
+ if (src === null || src === undefined) {
451
+ return _defineProperty({}, path, [{
452
+ message: "Non-optional file was null or undefined.",
453
+ value: src
454
+ }]);
455
+ }
456
+ if (typeof src[FILE_REF_PROP] !== "string") {
457
+ return _defineProperty({}, path, [{
458
+ message: "File did not have a file reference string. Got: ".concat(_typeof(src[FILE_REF_PROP])),
459
+ value: src
460
+ }]);
461
+ }
462
+ if (src[VAL_EXTENSION] !== "file") {
463
+ return _defineProperty({}, path, [{
464
+ message: "File did not have the valid file extension type. Got: ".concat(src[VAL_EXTENSION]),
465
+ value: src
466
+ }]);
467
+ }
468
+ if (src.metadata) {
469
+ return _defineProperty({}, path, [{
470
+ message: "Found metadata, but it could not be validated. File metadata must be an object with the required props: width (positive number), height (positive number) and sha256 (string of length 64 of the base16 hash).",
471
+ // These validation errors will have to be picked up by logic outside of this package and revalidated. Reasons: 1) we have to read files to verify the metadata, which is handled differently in different runtimes (Browser, QuickJS, Node.js); 2) we want to keep this package dependency free.
472
+ value: src,
473
+ fixes: ["file:check-metadata"]
474
+ }]);
475
+ }
476
+ return _defineProperty({}, path, [{
477
+ message: "Missing File metadata.",
478
+ value: src,
479
+ fixes: ["file:add-metadata"]
480
+ }]);
481
+ }
482
+ }, {
483
+ key: "assert",
484
+ value: function assert(src) {
485
+ if (this.opt && (src === null || src === undefined)) {
486
+ return true;
487
+ }
488
+ return (src === null || src === void 0 ? void 0 : src[FILE_REF_PROP]) === "file" && (src === null || src === void 0 ? void 0 : src[VAL_EXTENSION]) === "file";
489
+ }
490
+ }, {
491
+ key: "optional",
492
+ value: function optional() {
493
+ return new FileSchema(this.options, true);
494
+ }
495
+ }, {
496
+ key: "serialize",
497
+ value: function serialize() {
498
+ return {
499
+ type: "file",
500
+ options: this.options,
501
+ opt: this.opt
502
+ };
503
+ }
504
+ }]);
505
+ return FileSchema;
506
+ }(Schema);
507
+ var file = function file(options) {
508
+ return new FileSchema(options);
509
+ };
432
510
  function convertFileSource(src) {
433
- var _src$metadata2;
511
+ var _src$metadata3, _src$metadata4;
434
512
  // TODO: /public should be configurable
435
513
  if (!src[FILE_REF_PROP].startsWith("/public")) {
436
- var _src$metadata;
514
+ var _src$metadata, _src$metadata2;
437
515
  return {
438
- url: src[FILE_REF_PROP] + "?sha256=".concat((_src$metadata = src.metadata) === null || _src$metadata === void 0 ? void 0 : _src$metadata.sha256),
516
+ url: src[FILE_REF_PROP] + ((_src$metadata = src.metadata) !== null && _src$metadata !== void 0 && _src$metadata.sha256 ? "?sha256=".concat((_src$metadata2 = src.metadata) === null || _src$metadata2 === void 0 ? void 0 : _src$metadata2.sha256) : ""),
439
517
  metadata: src.metadata
440
518
  };
441
519
  }
442
520
  return {
443
- url: src[FILE_REF_PROP].slice("/public".length) + "?sha256=".concat((_src$metadata2 = src.metadata) === null || _src$metadata2 === void 0 ? void 0 : _src$metadata2.sha256),
521
+ url: src[FILE_REF_PROP].slice("/public".length) + ((_src$metadata3 = src.metadata) !== null && _src$metadata3 !== void 0 && _src$metadata3.sha256 ? "?sha256=".concat((_src$metadata4 = src.metadata) === null || _src$metadata4 === void 0 ? void 0 : _src$metadata4.sha256) : ""),
444
522
  metadata: src.metadata
445
523
  };
446
524
  }
@@ -480,6 +558,7 @@ function getValPath(valOrSelector) {
480
558
  exports.Call = Call;
481
559
  exports.Expr = Expr;
482
560
  exports.FILE_REF_PROP = FILE_REF_PROP;
561
+ exports.FileSchema = FileSchema;
483
562
  exports.GenericSelector = GenericSelector;
484
563
  exports.GetSchema = GetSchema;
485
564
  exports.GetSource = GetSource;
@@ -501,6 +580,7 @@ exports._toConsumableArray = _toConsumableArray;
501
580
  exports._typeof = _typeof;
502
581
  exports.convertFileSource = convertFileSource;
503
582
  exports.file = file;
583
+ exports.file$1 = file$1;
504
584
  exports.getSchema = getSchema;
505
585
  exports.getValPath = getValPath;
506
586
  exports.isFile = isFile;
@@ -422,25 +422,103 @@ var FILE_REF_PROP = "_ref";
422
422
  *
423
423
  */
424
424
 
425
- function file(ref, metadata) {
425
+ function file$1(ref, metadata) {
426
426
  return _defineProperty(_defineProperty(_defineProperty({}, FILE_REF_PROP, ref), VAL_EXTENSION, "file"), "metadata", metadata);
427
427
  }
428
428
  function isFile(obj) {
429
429
  return _typeof(obj) === "object" && obj !== null && VAL_EXTENSION in obj && obj[VAL_EXTENSION] === "file" && FILE_REF_PROP in obj && typeof obj[FILE_REF_PROP] === "string";
430
430
  }
431
431
 
432
+ var FileSchema = /*#__PURE__*/function (_Schema) {
433
+ _inherits(FileSchema, _Schema);
434
+ var _super = _createSuper(FileSchema);
435
+ function FileSchema(options) {
436
+ var _this;
437
+ var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
438
+ _classCallCheck(this, FileSchema);
439
+ _this = _super.call(this);
440
+ _this.options = options;
441
+ _this.opt = opt;
442
+ return _this;
443
+ }
444
+ _createClass(FileSchema, [{
445
+ key: "validate",
446
+ value: function validate(path, src) {
447
+ if (this.opt && (src === null || src === undefined)) {
448
+ return false;
449
+ }
450
+ if (src === null || src === undefined) {
451
+ return _defineProperty({}, path, [{
452
+ message: "Non-optional file was null or undefined.",
453
+ value: src
454
+ }]);
455
+ }
456
+ if (typeof src[FILE_REF_PROP] !== "string") {
457
+ return _defineProperty({}, path, [{
458
+ message: "File did not have a file reference string. Got: ".concat(_typeof(src[FILE_REF_PROP])),
459
+ value: src
460
+ }]);
461
+ }
462
+ if (src[VAL_EXTENSION] !== "file") {
463
+ return _defineProperty({}, path, [{
464
+ message: "File did not have the valid file extension type. Got: ".concat(src[VAL_EXTENSION]),
465
+ value: src
466
+ }]);
467
+ }
468
+ if (src.metadata) {
469
+ return _defineProperty({}, path, [{
470
+ message: "Found metadata, but it could not be validated. File metadata must be an object with the required props: width (positive number), height (positive number) and sha256 (string of length 64 of the base16 hash).",
471
+ // These validation errors will have to be picked up by logic outside of this package and revalidated. Reasons: 1) we have to read files to verify the metadata, which is handled differently in different runtimes (Browser, QuickJS, Node.js); 2) we want to keep this package dependency free.
472
+ value: src,
473
+ fixes: ["file:check-metadata"]
474
+ }]);
475
+ }
476
+ return _defineProperty({}, path, [{
477
+ message: "Missing File metadata.",
478
+ value: src,
479
+ fixes: ["file:add-metadata"]
480
+ }]);
481
+ }
482
+ }, {
483
+ key: "assert",
484
+ value: function assert(src) {
485
+ if (this.opt && (src === null || src === undefined)) {
486
+ return true;
487
+ }
488
+ return (src === null || src === void 0 ? void 0 : src[FILE_REF_PROP]) === "file" && (src === null || src === void 0 ? void 0 : src[VAL_EXTENSION]) === "file";
489
+ }
490
+ }, {
491
+ key: "optional",
492
+ value: function optional() {
493
+ return new FileSchema(this.options, true);
494
+ }
495
+ }, {
496
+ key: "serialize",
497
+ value: function serialize() {
498
+ return {
499
+ type: "file",
500
+ options: this.options,
501
+ opt: this.opt
502
+ };
503
+ }
504
+ }]);
505
+ return FileSchema;
506
+ }(Schema);
507
+ var file = function file(options) {
508
+ return new FileSchema(options);
509
+ };
432
510
  function convertFileSource(src) {
433
- var _src$metadata2;
511
+ var _src$metadata3, _src$metadata4;
434
512
  // TODO: /public should be configurable
435
513
  if (!src[FILE_REF_PROP].startsWith("/public")) {
436
- var _src$metadata;
514
+ var _src$metadata, _src$metadata2;
437
515
  return {
438
- url: src[FILE_REF_PROP] + "?sha256=".concat((_src$metadata = src.metadata) === null || _src$metadata === void 0 ? void 0 : _src$metadata.sha256),
516
+ url: src[FILE_REF_PROP] + ((_src$metadata = src.metadata) !== null && _src$metadata !== void 0 && _src$metadata.sha256 ? "?sha256=".concat((_src$metadata2 = src.metadata) === null || _src$metadata2 === void 0 ? void 0 : _src$metadata2.sha256) : ""),
439
517
  metadata: src.metadata
440
518
  };
441
519
  }
442
520
  return {
443
- url: src[FILE_REF_PROP].slice("/public".length) + "?sha256=".concat((_src$metadata2 = src.metadata) === null || _src$metadata2 === void 0 ? void 0 : _src$metadata2.sha256),
521
+ url: src[FILE_REF_PROP].slice("/public".length) + ((_src$metadata3 = src.metadata) !== null && _src$metadata3 !== void 0 && _src$metadata3.sha256 ? "?sha256=".concat((_src$metadata4 = src.metadata) === null || _src$metadata4 === void 0 ? void 0 : _src$metadata4.sha256) : ""),
444
522
  metadata: src.metadata
445
523
  };
446
524
  }
@@ -480,6 +558,7 @@ function getValPath(valOrSelector) {
480
558
  exports.Call = Call;
481
559
  exports.Expr = Expr;
482
560
  exports.FILE_REF_PROP = FILE_REF_PROP;
561
+ exports.FileSchema = FileSchema;
483
562
  exports.GenericSelector = GenericSelector;
484
563
  exports.GetSchema = GetSchema;
485
564
  exports.GetSource = GetSource;
@@ -501,6 +580,7 @@ exports._toConsumableArray = _toConsumableArray;
501
580
  exports._typeof = _typeof;
502
581
  exports.convertFileSource = convertFileSource;
503
582
  exports.file = file;
583
+ exports.file$1 = file$1;
504
584
  exports.getSchema = getSchema;
505
585
  exports.getValPath = getValPath;
506
586
  exports.isFile = isFile;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-7b467ee6.cjs.prod.js');
3
+ var index = require('./index-af44930c.cjs.prod.js');
4
4
  var result = require('./result-26f67b40.cjs.prod.js');
5
5
 
6
6
  function hasOwn(obj, prop) {
@@ -1,4 +1,4 @@
1
- import { e as _typeof, k as isSerializedVal, F as FILE_REF_PROP, V as VAL_EXTENSION, l as convertFileSource, d as _defineProperty, G as GetSchema, j as GetSource, E as Expr, P as Path, S as Schema, _ as _inherits, a as _createSuper, b as _classCallCheck, c as _createClass, h as _slicedToArray, p as _objectSpread2, t as _toConsumableArray } from './index-5750c299.esm.js';
1
+ import { e as _typeof, l as isSerializedVal, F as FILE_REF_PROP, V as VAL_EXTENSION, m as convertFileSource, d as _defineProperty, G as GetSchema, k as GetSource, E as Expr, P as Path, S as Schema, _ as _inherits, a as _createSuper, b as _classCallCheck, c as _createClass, i as _slicedToArray, r as _objectSpread2, v as _toConsumableArray } from './index-6cea0f23.esm.js';
2
2
  import { _ as _createForOfIteratorHelper } from './result-b96df128.esm.js';
3
3
 
4
4
  function hasOwn(obj, prop) {
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-d23e237a.cjs.dev.js');
3
+ var index = require('./index-e8fbff39.cjs.dev.js');
4
4
  var result = require('./result-48320acd.cjs.dev.js');
5
5
 
6
6
  function hasOwn(obj, prop) {
@@ -2,9 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var ops = require('./ops-74e62ffe.cjs.dev.js');
6
- var index = require('./index-d23e237a.cjs.dev.js');
7
- var expr_dist_valbuildCoreExpr = require('./index-00276955.cjs.dev.js');
5
+ var ops = require('./ops-ca9f0095.cjs.dev.js');
6
+ var index = require('./index-e8fbff39.cjs.dev.js');
7
+ var expr_dist_valbuildCoreExpr = require('./index-690d965d.cjs.dev.js');
8
8
  var result = require('./result-48320acd.cjs.dev.js');
9
9
 
10
10
  var NumberSchema = /*#__PURE__*/function (_Schema) {
@@ -358,7 +358,8 @@ function initSchema() {
358
358
  image: ops.image,
359
359
  literal: ops.literal,
360
360
  keyOf: keyOf,
361
- record: ops.record
361
+ record: ops.record,
362
+ file: index.file
362
363
  // i18n: i18n(locales),
363
364
  };
364
365
  }
@@ -435,7 +436,7 @@ var initVal = function initVal() {
435
436
  content: ops.content,
436
437
  // remote,
437
438
  getPath: index.getValPath,
438
- file: index.file,
439
+ file: index.file$1,
439
440
  richtext: richtext,
440
441
  link: link
441
442
  },
@@ -1584,6 +1585,7 @@ exports.RecordSchema = ops.RecordSchema;
1584
1585
  exports.RichTextSchema = ops.RichTextSchema;
1585
1586
  exports.UnionSchema = ops.UnionSchema;
1586
1587
  exports.FILE_REF_PROP = index.FILE_REF_PROP;
1588
+ exports.FileSchema = index.FileSchema;
1587
1589
  exports.GenericSelector = index.GenericSelector;
1588
1590
  exports.Schema = index.Schema;
1589
1591
  exports.VAL_EXTENSION = index.VAL_EXTENSION;
@@ -2,9 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var ops = require('./ops-c0e7e3a8.cjs.prod.js');
6
- var index = require('./index-7b467ee6.cjs.prod.js');
7
- var expr_dist_valbuildCoreExpr = require('./index-db60fc1d.cjs.prod.js');
5
+ var ops = require('./ops-7b8073b5.cjs.prod.js');
6
+ var index = require('./index-af44930c.cjs.prod.js');
7
+ var expr_dist_valbuildCoreExpr = require('./index-686d8832.cjs.prod.js');
8
8
  var result = require('./result-26f67b40.cjs.prod.js');
9
9
 
10
10
  var NumberSchema = /*#__PURE__*/function (_Schema) {
@@ -358,7 +358,8 @@ function initSchema() {
358
358
  image: ops.image,
359
359
  literal: ops.literal,
360
360
  keyOf: keyOf,
361
- record: ops.record
361
+ record: ops.record,
362
+ file: index.file
362
363
  // i18n: i18n(locales),
363
364
  };
364
365
  }
@@ -435,7 +436,7 @@ var initVal = function initVal() {
435
436
  content: ops.content,
436
437
  // remote,
437
438
  getPath: index.getValPath,
438
- file: index.file,
439
+ file: index.file$1,
439
440
  richtext: richtext,
440
441
  link: link
441
442
  },
@@ -1584,6 +1585,7 @@ exports.RecordSchema = ops.RecordSchema;
1584
1585
  exports.RichTextSchema = ops.RichTextSchema;
1585
1586
  exports.UnionSchema = ops.UnionSchema;
1586
1587
  exports.FILE_REF_PROP = index.FILE_REF_PROP;
1588
+ exports.FileSchema = index.FileSchema;
1587
1589
  exports.GenericSelector = index.GenericSelector;
1588
1590
  exports.Schema = index.Schema;
1589
1591
  exports.VAL_EXTENSION = index.VAL_EXTENSION;
@@ -1,8 +1,8 @@
1
- import { a as array, o as object, u as union, r as richtext$1, i as image, l as literal, b as record, c as content, P as PatchError, n as newSelectorProxy, d as createValPathOfItem, e as isSelector, g as getSource, f as resolvePath, s as splitModuleIdAndModulePath } from './ops-ffed3406.esm.js';
2
- export { A as ArraySchema, I as ImageSchema, L as LiteralSchema, O as ObjectSchema, R as RecordSchema, h as RichTextSchema, U as UnionSchema } from './ops-ffed3406.esm.js';
3
- import { _ as _inherits, a as _createSuper, b as _classCallCheck, c as _createClass, d as _defineProperty, e as _typeof, S as Schema, G as GetSchema, g as getValPath, V as VAL_EXTENSION, f as file, h as _slicedToArray, i as isFile, F as FILE_REF_PROP, P as Path, j as GetSource, k as isSerializedVal, l as convertFileSource, m as getSchema, n as isVal } from './index-5750c299.esm.js';
4
- export { F as FILE_REF_PROP, o as GenericSelector, S as Schema, V as VAL_EXTENSION } from './index-5750c299.esm.js';
5
- export { i as expr } from './index-799bcf49.esm.js';
1
+ import { a as array, o as object, u as union, r as richtext$1, i as image, l as literal, b as record, c as content, P as PatchError, n as newSelectorProxy, d as createValPathOfItem, e as isSelector, g as getSource, f as resolvePath, s as splitModuleIdAndModulePath } from './ops-8387575e.esm.js';
2
+ export { A as ArraySchema, I as ImageSchema, L as LiteralSchema, O as ObjectSchema, R as RecordSchema, h as RichTextSchema, U as UnionSchema } from './ops-8387575e.esm.js';
3
+ import { _ as _inherits, a as _createSuper, b as _classCallCheck, c as _createClass, d as _defineProperty, e as _typeof, S as Schema, G as GetSchema, g as getValPath, f as file, V as VAL_EXTENSION, h as file$1, i as _slicedToArray, j as isFile, F as FILE_REF_PROP, P as Path, k as GetSource, l as isSerializedVal, m as convertFileSource, n as getSchema, o as isVal } from './index-6cea0f23.esm.js';
4
+ export { F as FILE_REF_PROP, q as FileSchema, p as GenericSelector, S as Schema, V as VAL_EXTENSION } from './index-6cea0f23.esm.js';
5
+ export { i as expr } from './index-4c303f7c.esm.js';
6
6
  import { _ as _createForOfIteratorHelper, i as isErr, a as isOk, e as err, o as ok, r as result } from './result-b96df128.esm.js';
7
7
 
8
8
  var NumberSchema = /*#__PURE__*/function (_Schema) {
@@ -356,7 +356,8 @@ function initSchema() {
356
356
  image: image,
357
357
  literal: literal,
358
358
  keyOf: keyOf,
359
- record: record
359
+ record: record,
360
+ file: file
360
361
  // i18n: i18n(locales),
361
362
  };
362
363
  }
@@ -433,7 +434,7 @@ var initVal = function initVal() {
433
434
  content: content,
434
435
  // remote,
435
436
  getPath: getValPath,
436
- file: file,
437
+ file: file$1,
437
438
  richtext: richtext,
438
439
  link: link
439
440
  },
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var expr_dist_valbuildCoreExpr = require('../../dist/index-00276955.cjs.dev.js');
6
- var index = require('../../dist/index-d23e237a.cjs.dev.js');
5
+ var expr_dist_valbuildCoreExpr = require('../../dist/index-690d965d.cjs.dev.js');
6
+ var index = require('../../dist/index-e8fbff39.cjs.dev.js');
7
7
  require('../../dist/result-48320acd.cjs.dev.js');
8
8
 
9
9
 
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var expr_dist_valbuildCoreExpr = require('../../dist/index-db60fc1d.cjs.prod.js');
6
- var index = require('../../dist/index-7b467ee6.cjs.prod.js');
5
+ var expr_dist_valbuildCoreExpr = require('../../dist/index-686d8832.cjs.prod.js');
6
+ var index = require('../../dist/index-af44930c.cjs.prod.js');
7
7
  require('../../dist/result-26f67b40.cjs.prod.js');
8
8
 
9
9
 
@@ -1,3 +1,3 @@
1
- export { e as evaluate, p as parse } from '../../dist/index-799bcf49.esm.js';
2
- export { C as Call, E as Expr, N as NilSym, r as StringLiteral, s as StringTemplate, q as Sym } from '../../dist/index-5750c299.esm.js';
1
+ export { e as evaluate, p as parse } from '../../dist/index-4c303f7c.esm.js';
2
+ export { C as Call, E as Expr, N as NilSym, t as StringLiteral, u as StringTemplate, s as Sym } from '../../dist/index-6cea0f23.esm.js';
3
3
  import '../../dist/result-b96df128.esm.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valbuild/core",
3
- "version": "0.48.0",
3
+ "version": "0.49.0",
4
4
  "private": false,
5
5
  "description": "Val - supercharged hard-coded content",
6
6
  "scripts": {
@@ -2,10 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('../../dist/index-d23e237a.cjs.dev.js');
5
+ var index = require('../../dist/index-e8fbff39.cjs.dev.js');
6
6
  var result = require('../../dist/result-48320acd.cjs.dev.js');
7
7
  var util = require('../../dist/util-b213092b.cjs.dev.js');
8
- var ops = require('../../dist/ops-74e62ffe.cjs.dev.js');
8
+ var ops = require('../../dist/ops-ca9f0095.cjs.dev.js');
9
9
 
10
10
  function isNotRoot(path) {
11
11
  return result.isNonEmpty(path);
@@ -2,10 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('../../dist/index-7b467ee6.cjs.prod.js');
5
+ var index = require('../../dist/index-af44930c.cjs.prod.js');
6
6
  var result = require('../../dist/result-26f67b40.cjs.prod.js');
7
7
  var util = require('../../dist/util-030d8a1f.cjs.prod.js');
8
- var ops = require('../../dist/ops-c0e7e3a8.cjs.prod.js');
8
+ var ops = require('../../dist/ops-7b8073b5.cjs.prod.js');
9
9
 
10
10
  function isNotRoot(path) {
11
11
  return result.isNonEmpty(path);
@@ -1,8 +1,8 @@
1
- import { e as _typeof, h as _slicedToArray, c as _createClass, b as _classCallCheck, t as _toConsumableArray } from '../../dist/index-5750c299.esm.js';
1
+ import { e as _typeof, i as _slicedToArray, c as _createClass, b as _classCallCheck, v as _toConsumableArray } from '../../dist/index-6cea0f23.esm.js';
2
2
  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-b96df128.esm.js';
3
3
  import { p as pipe } from '../../dist/util-18613e99.esm.js';
4
- import { P as PatchError, s as splitModuleIdAndModulePath } from '../../dist/ops-ffed3406.esm.js';
5
- export { P as PatchError } from '../../dist/ops-ffed3406.esm.js';
4
+ import { P as PatchError, s as splitModuleIdAndModulePath } from '../../dist/ops-8387575e.esm.js';
5
+ export { P as PatchError } from '../../dist/ops-8387575e.esm.js';
6
6
 
7
7
  function isNotRoot(path) {
8
8
  return isNonEmpty(path);