@valbuild/core 0.21.1 → 0.22.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 (34) hide show
  1. package/dist/declarations/src/ValApi.d.ts +2 -1
  2. package/dist/declarations/src/index.d.ts +21 -3
  3. package/dist/declarations/src/module.d.ts +11 -5
  4. package/dist/declarations/src/patch/deref.d.ts +0 -3
  5. package/dist/declarations/src/patch/operation.d.ts +2 -0
  6. package/dist/declarations/src/schema/string.d.ts +5 -1
  7. package/dist/{index-75b79c89.cjs.prod.js → index-30eee5ec.cjs.prod.js} +47 -43
  8. package/dist/{index-067cff4a.cjs.prod.js → index-425d164d.cjs.prod.js} +1 -1
  9. package/dist/{index-31991dd7.cjs.dev.js → index-43369070.cjs.dev.js} +47 -43
  10. package/dist/{index-4bb14a92.esm.js → index-499b9e87.esm.js} +47 -43
  11. package/dist/{index-d17f9503.cjs.dev.js → index-a0f36fe3.cjs.dev.js} +1 -1
  12. package/dist/{index-870205b5.esm.js → index-f0475164.esm.js} +1 -1
  13. package/dist/{ops-9b396073.esm.js → ops-1225f750.esm.js} +5 -2
  14. package/dist/{ops-0f7617a0.cjs.dev.js → ops-558f07b7.cjs.dev.js} +5 -2
  15. package/dist/{ops-451ffb3f.cjs.prod.js → ops-b263963e.cjs.prod.js} +5 -2
  16. package/dist/valbuild-core.cjs.dev.js +251 -240
  17. package/dist/valbuild-core.cjs.prod.js +251 -240
  18. package/dist/valbuild-core.esm.js +252 -241
  19. package/expr/dist/valbuild-core-expr.cjs.dev.js +2 -2
  20. package/expr/dist/valbuild-core-expr.cjs.prod.js +2 -2
  21. package/expr/dist/valbuild-core-expr.esm.js +2 -2
  22. package/package.json +1 -1
  23. package/patch/dist/valbuild-core-patch.cjs.dev.js +13 -3
  24. package/patch/dist/valbuild-core-patch.cjs.prod.js +13 -3
  25. package/patch/dist/valbuild-core-patch.esm.js +14 -4
  26. package/src/ValApi.ts +9 -13
  27. package/src/index.ts +23 -3
  28. package/src/module.ts +40 -14
  29. package/src/patch/deref.test.ts +130 -132
  30. package/src/patch/deref.ts +12 -17
  31. package/src/patch/operation.ts +2 -0
  32. package/src/patch/parse.ts +15 -1
  33. package/src/schema/image.ts +5 -3
  34. package/src/schema/string.ts +27 -2
@@ -10,7 +10,8 @@ export declare class ValApi {
10
10
  host: string;
11
11
  constructor(host: string);
12
12
  getDisableUrl(): string;
13
- postPatches(moduleId: ModuleId, patches: PatchJSON, commit?: string, headers?: Record<string, string> | undefined): Promise<result.Result<ApiPatchResponse, FetchError>>;
13
+ getEditUrl(): string;
14
+ postPatches(moduleId: ModuleId, patches: PatchJSON, headers?: Record<string, string> | undefined): Promise<result.Result<ApiPatchResponse, FetchError>>;
14
15
  getSession(): Promise<result.Result<{
15
16
  mode: "proxy" | "local";
16
17
  member_role: "owner" | "developer" | "editor";
@@ -8,8 +8,9 @@ export type { SourceObject, SourcePrimitive, Source } from "./source/index.js";
8
8
  export type { FileSource } from "./source/file.js";
9
9
  export type { AnyRichTextOptions, Bold, Classes, HeadingNode, ImageNode, Italic, LineThrough, ListItemNode, LinkNode, OrderedListNode, ParagraphNode, BrNode, RichText, RichTextNode, RichTextOptions, RichTextSource, RootNode, SpanNode, UnorderedListNode, } from "./source/richtext.js";
10
10
  export { type Val, type SerializedVal, type ModuleId, type ModulePath, type SourcePath, type JsonOfSource, } from "./val/index.js";
11
- export type { Json, JsonPrimitive } from "./Json.js";
12
- export type { ValidationErrors, ValidationError, } from "./schema/validation/ValidationError.js";
11
+ export type { Json, JsonPrimitive, JsonArray, JsonObject } from "./Json.js";
12
+ export type { ValidationError, ValidationErrors, } from "./schema/validation/ValidationError.js";
13
+ import type { ValidationErrors } from "./schema/validation/ValidationError.js";
13
14
  export type { ValidationFix } from "./schema/validation/ValidationFix.js";
14
15
  export * as expr from "./expr/index.js";
15
16
  export { FILE_REF_PROP } from "./source/file.js";
@@ -21,9 +22,17 @@ import { getSchema } from "./selector/index.js";
21
22
  import { ModuleId, ModulePath, getValPath, isVal } from "./val/index.js";
22
23
  import { createValPathOfItem } from "./selector/SelectorProxy.js";
23
24
  import { getVal } from "./future/fetchVal.js";
24
- import { Json } from "./Json.js";
25
+ import type { Json } from "./Json.js";
25
26
  import { SerializedSchema } from "./schema/index.js";
26
27
  export { ValApi } from "./ValApi.js";
28
+ export type { SerializedArraySchema } from "./schema/array.js";
29
+ export type { SerializedObjectSchema } from "./schema/object.js";
30
+ export type { SerializedRecordSchema } from "./schema/record.js";
31
+ export type { SerializedStringSchema } from "./schema/string.js";
32
+ export type { SerializedNumberSchema } from "./schema/number.js";
33
+ export type { SerializedBooleanSchema } from "./schema/boolean.js";
34
+ export type { SerializedImageSchema } from "./schema/image.js";
35
+ export type { SerializedRichTextSchema } from "./schema/richtext.js";
27
36
  export type ApiTreeResponse = {
28
37
  git: {
29
38
  commit?: string;
@@ -36,6 +45,15 @@ export type ApiTreeResponse = {
36
45
  failed?: string[];
37
46
  };
38
47
  source?: Json;
48
+ errors?: false | {
49
+ invalidModuleId?: ModuleId;
50
+ validation?: ValidationErrors;
51
+ fatal?: {
52
+ message: string;
53
+ stack?: string;
54
+ type?: string;
55
+ }[];
56
+ };
39
57
  }>;
40
58
  };
41
59
  export type ApiPatchResponse = Record<ModuleId, string[]>;
@@ -3,20 +3,26 @@ 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 { RawString } from "./schema/string.js";
6
7
  declare const brand: unique symbol;
7
8
  export type ValModule<T extends SelectorSource> = SelectorOf<T> & ValModuleBrand;
8
9
  export type ValModuleBrand = {
9
10
  [brand]: "ValModule";
10
11
  };
11
12
  export type TypeOfValModule<T extends ValModule<SelectorSource>> = T extends GenericSelector<infer S> ? S : never;
12
- export declare function content<T extends Schema<SelectorSource>>(id: string, schema: T, source: SchemaTypeOf<T>): ValModule<SchemaTypeOf<T>>;
13
+ type ReplaceRawStringWithString<T extends SelectorSource> = SelectorSource extends T ? T : T extends RawString ? string : T extends {
14
+ [key in string]: SelectorSource;
15
+ } ? {
16
+ [key in keyof T]: ReplaceRawStringWithString<T[key]>;
17
+ } : T extends SelectorSource[] ? ReplaceRawStringWithString<T[number]>[] : T;
18
+ export declare function content<T extends Schema<SelectorSource>>(id: string, schema: T, source: ReplaceRawStringWithString<SchemaTypeOf<T>>): ValModule<SchemaTypeOf<T>>;
13
19
  export declare function getSource(valModule: ValModule<SelectorSource>): Source;
14
20
  export declare function splitModuleIdAndModulePath(path: SourcePath): [moduleId: ModuleId, path: ModulePath];
15
21
  export declare function getSourceAtPath(modulePath: ModulePath, valModule: ValModule<SelectorSource> | Source): any;
16
- export declare function resolvePath(path: ModulePath, valModule: ValModule<SelectorSource> | Source, schema: Schema<SelectorSource> | SerializedSchema): {
17
- path: string;
18
- schema: SerializedSchema | Schema<SelectorSource>;
19
- source: any;
22
+ export declare function resolvePath<Src extends ValModule<SelectorSource> | Source, Sch extends Schema<SelectorSource> | SerializedSchema>(path: ModulePath, valModule: Src, schema: Sch): {
23
+ path: SourcePath;
24
+ schema: Sch;
25
+ source: Src;
20
26
  };
21
27
  export declare function parsePath(input: ModulePath): string[];
22
28
  export type SerializedModule = {
@@ -7,8 +7,5 @@ export type DerefPatchResult = {
7
7
  fileUpdates: {
8
8
  [path: string]: string;
9
9
  };
10
- remotePatches: {
11
- [ref: string]: Patch;
12
- };
13
10
  };
14
11
  export declare function derefPatch<D, E>(patch: Operation[], document: D, ops: Ops<D, E>): result.Result<DerefPatchResult, E | PatchError>;
@@ -29,6 +29,7 @@ export type OperationJSON = {
29
29
  } | {
30
30
  op: "file";
31
31
  path: string;
32
+ filePath: string;
32
33
  value: JSONValue;
33
34
  };
34
35
  /**
@@ -63,5 +64,6 @@ export type Operation = {
63
64
  } | {
64
65
  op: "file";
65
66
  path: string[];
67
+ filePath: string;
66
68
  value: JSONValue;
67
69
  };
@@ -11,6 +11,10 @@ export type SerializedStringSchema = {
11
11
  opt: boolean;
12
12
  raw: boolean;
13
13
  };
14
+ declare const brand: unique symbol;
15
+ export type RawString = string & {
16
+ readonly [brand]: "raw";
17
+ };
14
18
  export declare class StringSchema<Src extends string | null> extends Schema<Src> {
15
19
  readonly options?: StringOptions | undefined;
16
20
  readonly opt: boolean;
@@ -19,7 +23,7 @@ export declare class StringSchema<Src extends string | null> extends Schema<Src>
19
23
  validate(path: SourcePath, src: Src): ValidationErrors;
20
24
  assert(src: Src): boolean;
21
25
  optional(): StringSchema<Src | null>;
22
- raw(): StringSchema<Src>;
26
+ raw(): StringSchema<Src extends null ? RawString | null : RawString>;
23
27
  serialize(): SerializedSchema;
24
28
  }
25
29
  export declare const string: <T extends string>(options?: StringOptions) => StringSchema<T>;
@@ -33,26 +33,26 @@ function _defineProperty(obj, key, value) {
33
33
  return obj;
34
34
  }
35
35
 
36
- function ownKeys(object, enumerableOnly) {
37
- var keys = Object.keys(object);
36
+ function ownKeys(e, r) {
37
+ var t = Object.keys(e);
38
38
  if (Object.getOwnPropertySymbols) {
39
- var symbols = Object.getOwnPropertySymbols(object);
40
- enumerableOnly && (symbols = symbols.filter(function (sym) {
41
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
42
- })), keys.push.apply(keys, symbols);
39
+ var o = Object.getOwnPropertySymbols(e);
40
+ r && (o = o.filter(function (r) {
41
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
42
+ })), t.push.apply(t, o);
43
43
  }
44
- return keys;
44
+ return t;
45
45
  }
46
- function _objectSpread2(target) {
47
- for (var i = 1; i < arguments.length; i++) {
48
- var source = null != arguments[i] ? arguments[i] : {};
49
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
50
- _defineProperty(target, key, source[key]);
51
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
52
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
46
+ function _objectSpread2(e) {
47
+ for (var r = 1; r < arguments.length; r++) {
48
+ var t = null != arguments[r] ? arguments[r] : {};
49
+ r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
50
+ _defineProperty(e, r, t[r]);
51
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
52
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
53
53
  });
54
54
  }
55
- return target;
55
+ return e;
56
56
  }
57
57
 
58
58
  function _arrayWithoutHoles(arr) {
@@ -71,45 +71,45 @@ function _toConsumableArray(arr) {
71
71
  return _arrayWithoutHoles(arr) || _iterableToArray(arr) || result._unsupportedIterableToArray(arr) || _nonIterableSpread();
72
72
  }
73
73
 
74
- function _typeof(obj) {
74
+ function _typeof(o) {
75
75
  "@babel/helpers - typeof";
76
76
 
77
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
78
- return typeof obj;
79
- } : function (obj) {
80
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
81
- }, _typeof(obj);
77
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
78
+ return typeof o;
79
+ } : function (o) {
80
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
81
+ }, _typeof(o);
82
82
  }
83
83
 
84
84
  function _arrayWithHoles(arr) {
85
85
  if (Array.isArray(arr)) return arr;
86
86
  }
87
87
 
88
- function _iterableToArrayLimit(arr, i) {
89
- var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
90
- if (null != _i) {
91
- var _s,
92
- _e,
93
- _x,
94
- _r,
95
- _arr = [],
96
- _n = !0,
97
- _d = !1;
88
+ function _iterableToArrayLimit(r, l) {
89
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
90
+ if (null != t) {
91
+ var e,
92
+ n,
93
+ i,
94
+ u,
95
+ a = [],
96
+ f = !0,
97
+ o = !1;
98
98
  try {
99
- if (_x = (_i = _i.call(arr)).next, 0 === i) {
100
- if (Object(_i) !== _i) return;
101
- _n = !1;
102
- } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
103
- } catch (err) {
104
- _d = !0, _e = err;
99
+ if (i = (t = t.call(r)).next, 0 === l) {
100
+ if (Object(t) !== t) return;
101
+ f = !1;
102
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
103
+ } catch (r) {
104
+ o = !0, n = r;
105
105
  } finally {
106
106
  try {
107
- if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
107
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
108
108
  } finally {
109
- if (_d) throw _e;
109
+ if (o) throw n;
110
110
  }
111
111
  }
112
- return _arr;
112
+ return a;
113
113
  }
114
114
  }
115
115
 
@@ -509,13 +509,17 @@ var image = function image(options) {
509
509
  return new ImageSchema(options);
510
510
  };
511
511
  var convertFileSource = function convertFileSource(src) {
512
- var _src$metadata;
512
+ var _src$metadata2;
513
513
  // TODO: /public should be configurable
514
514
  if (!src[FILE_REF_PROP].startsWith("/public")) {
515
- throw Error("Invalid reference: ".concat(src[FILE_REF_PROP], ". Did not start with /public"));
515
+ var _src$metadata;
516
+ return {
517
+ url: src[FILE_REF_PROP] + "?sha256=".concat((_src$metadata = src.metadata) === null || _src$metadata === void 0 ? void 0 : _src$metadata.sha256),
518
+ metadata: src.metadata
519
+ };
516
520
  }
517
521
  return {
518
- url: src[FILE_REF_PROP].slice("/public".length) + "?sha256=".concat((_src$metadata = src.metadata) === null || _src$metadata === void 0 ? void 0 : _src$metadata.sha256),
522
+ 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
523
  metadata: src.metadata
520
524
  };
521
525
  };
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index$1 = require('./index-75b79c89.cjs.prod.js');
3
+ var index$1 = require('./index-30eee5ec.cjs.prod.js');
4
4
  var result = require('./result-26f67b40.cjs.prod.js');
5
5
 
6
6
  var WHITE_SPACE = ["\n", "\r", "\t", " "];
@@ -33,26 +33,26 @@ function _defineProperty(obj, key, value) {
33
33
  return obj;
34
34
  }
35
35
 
36
- function ownKeys(object, enumerableOnly) {
37
- var keys = Object.keys(object);
36
+ function ownKeys(e, r) {
37
+ var t = Object.keys(e);
38
38
  if (Object.getOwnPropertySymbols) {
39
- var symbols = Object.getOwnPropertySymbols(object);
40
- enumerableOnly && (symbols = symbols.filter(function (sym) {
41
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
42
- })), keys.push.apply(keys, symbols);
39
+ var o = Object.getOwnPropertySymbols(e);
40
+ r && (o = o.filter(function (r) {
41
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
42
+ })), t.push.apply(t, o);
43
43
  }
44
- return keys;
44
+ return t;
45
45
  }
46
- function _objectSpread2(target) {
47
- for (var i = 1; i < arguments.length; i++) {
48
- var source = null != arguments[i] ? arguments[i] : {};
49
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
50
- _defineProperty(target, key, source[key]);
51
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
52
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
46
+ function _objectSpread2(e) {
47
+ for (var r = 1; r < arguments.length; r++) {
48
+ var t = null != arguments[r] ? arguments[r] : {};
49
+ r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
50
+ _defineProperty(e, r, t[r]);
51
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
52
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
53
53
  });
54
54
  }
55
- return target;
55
+ return e;
56
56
  }
57
57
 
58
58
  function _arrayWithoutHoles(arr) {
@@ -71,45 +71,45 @@ function _toConsumableArray(arr) {
71
71
  return _arrayWithoutHoles(arr) || _iterableToArray(arr) || result._unsupportedIterableToArray(arr) || _nonIterableSpread();
72
72
  }
73
73
 
74
- function _typeof(obj) {
74
+ function _typeof(o) {
75
75
  "@babel/helpers - typeof";
76
76
 
77
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
78
- return typeof obj;
79
- } : function (obj) {
80
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
81
- }, _typeof(obj);
77
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
78
+ return typeof o;
79
+ } : function (o) {
80
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
81
+ }, _typeof(o);
82
82
  }
83
83
 
84
84
  function _arrayWithHoles(arr) {
85
85
  if (Array.isArray(arr)) return arr;
86
86
  }
87
87
 
88
- function _iterableToArrayLimit(arr, i) {
89
- var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
90
- if (null != _i) {
91
- var _s,
92
- _e,
93
- _x,
94
- _r,
95
- _arr = [],
96
- _n = !0,
97
- _d = !1;
88
+ function _iterableToArrayLimit(r, l) {
89
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
90
+ if (null != t) {
91
+ var e,
92
+ n,
93
+ i,
94
+ u,
95
+ a = [],
96
+ f = !0,
97
+ o = !1;
98
98
  try {
99
- if (_x = (_i = _i.call(arr)).next, 0 === i) {
100
- if (Object(_i) !== _i) return;
101
- _n = !1;
102
- } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
103
- } catch (err) {
104
- _d = !0, _e = err;
99
+ if (i = (t = t.call(r)).next, 0 === l) {
100
+ if (Object(t) !== t) return;
101
+ f = !1;
102
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
103
+ } catch (r) {
104
+ o = !0, n = r;
105
105
  } finally {
106
106
  try {
107
- if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
107
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
108
108
  } finally {
109
- if (_d) throw _e;
109
+ if (o) throw n;
110
110
  }
111
111
  }
112
- return _arr;
112
+ return a;
113
113
  }
114
114
  }
115
115
 
@@ -509,13 +509,17 @@ var image = function image(options) {
509
509
  return new ImageSchema(options);
510
510
  };
511
511
  var convertFileSource = function convertFileSource(src) {
512
- var _src$metadata;
512
+ var _src$metadata2;
513
513
  // TODO: /public should be configurable
514
514
  if (!src[FILE_REF_PROP].startsWith("/public")) {
515
- throw Error("Invalid reference: ".concat(src[FILE_REF_PROP], ". Did not start with /public"));
515
+ var _src$metadata;
516
+ return {
517
+ url: src[FILE_REF_PROP] + "?sha256=".concat((_src$metadata = src.metadata) === null || _src$metadata === void 0 ? void 0 : _src$metadata.sha256),
518
+ metadata: src.metadata
519
+ };
516
520
  }
517
521
  return {
518
- url: src[FILE_REF_PROP].slice("/public".length) + "?sha256=".concat((_src$metadata = src.metadata) === null || _src$metadata === void 0 ? void 0 : _src$metadata.sha256),
522
+ 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
523
  metadata: src.metadata
520
524
  };
521
525
  };
@@ -31,26 +31,26 @@ function _defineProperty(obj, key, value) {
31
31
  return obj;
32
32
  }
33
33
 
34
- function ownKeys(object, enumerableOnly) {
35
- var keys = Object.keys(object);
34
+ function ownKeys(e, r) {
35
+ var t = Object.keys(e);
36
36
  if (Object.getOwnPropertySymbols) {
37
- var symbols = Object.getOwnPropertySymbols(object);
38
- enumerableOnly && (symbols = symbols.filter(function (sym) {
39
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
40
- })), keys.push.apply(keys, symbols);
37
+ var o = Object.getOwnPropertySymbols(e);
38
+ r && (o = o.filter(function (r) {
39
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
40
+ })), t.push.apply(t, o);
41
41
  }
42
- return keys;
42
+ return t;
43
43
  }
44
- function _objectSpread2(target) {
45
- for (var i = 1; i < arguments.length; i++) {
46
- var source = null != arguments[i] ? arguments[i] : {};
47
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
48
- _defineProperty(target, key, source[key]);
49
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
50
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
44
+ function _objectSpread2(e) {
45
+ for (var r = 1; r < arguments.length; r++) {
46
+ var t = null != arguments[r] ? arguments[r] : {};
47
+ r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
48
+ _defineProperty(e, r, t[r]);
49
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
50
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
51
51
  });
52
52
  }
53
- return target;
53
+ return e;
54
54
  }
55
55
 
56
56
  function _arrayWithoutHoles(arr) {
@@ -69,45 +69,45 @@ function _toConsumableArray(arr) {
69
69
  return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
70
70
  }
71
71
 
72
- function _typeof(obj) {
72
+ function _typeof(o) {
73
73
  "@babel/helpers - typeof";
74
74
 
75
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
76
- return typeof obj;
77
- } : function (obj) {
78
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
79
- }, _typeof(obj);
75
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
76
+ return typeof o;
77
+ } : function (o) {
78
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
79
+ }, _typeof(o);
80
80
  }
81
81
 
82
82
  function _arrayWithHoles(arr) {
83
83
  if (Array.isArray(arr)) return arr;
84
84
  }
85
85
 
86
- function _iterableToArrayLimit(arr, i) {
87
- var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
88
- if (null != _i) {
89
- var _s,
90
- _e,
91
- _x,
92
- _r,
93
- _arr = [],
94
- _n = !0,
95
- _d = !1;
86
+ function _iterableToArrayLimit(r, l) {
87
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
88
+ if (null != t) {
89
+ var e,
90
+ n,
91
+ i,
92
+ u,
93
+ a = [],
94
+ f = !0,
95
+ o = !1;
96
96
  try {
97
- if (_x = (_i = _i.call(arr)).next, 0 === i) {
98
- if (Object(_i) !== _i) return;
99
- _n = !1;
100
- } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
101
- } catch (err) {
102
- _d = !0, _e = err;
97
+ if (i = (t = t.call(r)).next, 0 === l) {
98
+ if (Object(t) !== t) return;
99
+ f = !1;
100
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
101
+ } catch (r) {
102
+ o = !0, n = r;
103
103
  } finally {
104
104
  try {
105
- if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
105
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
106
106
  } finally {
107
- if (_d) throw _e;
107
+ if (o) throw n;
108
108
  }
109
109
  }
110
- return _arr;
110
+ return a;
111
111
  }
112
112
  }
113
113
 
@@ -507,13 +507,17 @@ var image = function image(options) {
507
507
  return new ImageSchema(options);
508
508
  };
509
509
  var convertFileSource = function convertFileSource(src) {
510
- var _src$metadata;
510
+ var _src$metadata2;
511
511
  // TODO: /public should be configurable
512
512
  if (!src[FILE_REF_PROP].startsWith("/public")) {
513
- throw Error("Invalid reference: ".concat(src[FILE_REF_PROP], ". Did not start with /public"));
513
+ var _src$metadata;
514
+ return {
515
+ url: src[FILE_REF_PROP] + "?sha256=".concat((_src$metadata = src.metadata) === null || _src$metadata === void 0 ? void 0 : _src$metadata.sha256),
516
+ metadata: src.metadata
517
+ };
514
518
  }
515
519
  return {
516
- url: src[FILE_REF_PROP].slice("/public".length) + "?sha256=".concat((_src$metadata = src.metadata) === null || _src$metadata === void 0 ? void 0 : _src$metadata.sha256),
520
+ url: src[FILE_REF_PROP].slice("/public".length) + "?sha256=".concat((_src$metadata2 = src.metadata) === null || _src$metadata2 === void 0 ? void 0 : _src$metadata2.sha256),
517
521
  metadata: src.metadata
518
522
  };
519
523
  };
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index$1 = require('./index-31991dd7.cjs.dev.js');
3
+ var index$1 = require('./index-43369070.cjs.dev.js');
4
4
  var result = require('./result-48320acd.cjs.dev.js');
5
5
 
6
6
  var WHITE_SPACE = ["\n", "\r", "\t", " "];
@@ -1,4 +1,4 @@
1
- import { h as _objectSpread2, j as _slicedToArray, c as _createClass, b as _classCallCheck, r as Sym, C as Call, s as StringLiteral, t as StringTemplate, e as _typeof, m as isSerializedVal, F as FILE_REF_PROP, V as VAL_EXTENSION, n as convertFileSource, d as _defineProperty, S as Schema, E as Expr, u as _toConsumableArray, N as NilSym } from './index-4bb14a92.esm.js';
1
+ import { h as _objectSpread2, j as _slicedToArray, c as _createClass, b as _classCallCheck, r as Sym, C as Call, s as StringLiteral, t as StringTemplate, e as _typeof, m as isSerializedVal, F as FILE_REF_PROP, V as VAL_EXTENSION, n as convertFileSource, d as _defineProperty, S as Schema, E as Expr, u as _toConsumableArray, N as NilSym } from './index-499b9e87.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,4 +1,4 @@
1
- import { e as _typeof, m as isSerializedVal, F as FILE_REF_PROP, V as VAL_EXTENSION, n as convertFileSource, d as _defineProperty, l as GetSource, P as Path, G as GetSchema, S as Schema, E as Expr, _ as _inherits, a as _createSuper, b as _classCallCheck, c as _createClass, j as _slicedToArray, h as _objectSpread2, u as _toConsumableArray, I as ImageSchema } from './index-4bb14a92.esm.js';
1
+ import { e as _typeof, m as isSerializedVal, F as FILE_REF_PROP, V as VAL_EXTENSION, n as convertFileSource, d as _defineProperty, l as GetSource, P as Path, G as GetSchema, S as Schema, E as Expr, _ as _inherits, a as _createSuper, b as _classCallCheck, c as _createClass, j as _slicedToArray, h as _objectSpread2, u as _toConsumableArray, I as ImageSchema } from './index-499b9e87.esm.js';
2
2
  import { _ as _createForOfIteratorHelper } from './result-b96df128.esm.js';
3
3
 
4
4
  function hasOwn(obj, prop) {
@@ -527,6 +527,9 @@ function getSource(valModule) {
527
527
  return source;
528
528
  }
529
529
  function splitModuleIdAndModulePath(path) {
530
+ if (path.indexOf(".") === -1) {
531
+ return [path, ""];
532
+ }
530
533
  return [path.slice(0, path.indexOf(".")), path.slice(path.indexOf(".") + 1)];
531
534
  }
532
535
  function isObjectSchema(schema) {
@@ -582,7 +585,7 @@ function resolvePath(path, valModule, schema) {
582
585
  }
583
586
  if (isArraySchema(resolvedSchema)) {
584
587
  if (Number.isNaN(Number(part))) {
585
- throw Error("Invalid path: array schema ".concat(resolvedSchema, " must have ").concat(part, " a number as path"));
588
+ throw Error("Invalid path: array schema ".concat(JSON.stringify(resolvedSchema), " must have a number as path, but got ").concat(part, ". Path: ").concat(path));
586
589
  }
587
590
  if (_typeof(resolvedSource) !== "object" && !Array.isArray(resolvedSource)) {
588
591
  throw Error("Schema type error: expected source to be type of array, but got ".concat(_typeof(resolvedSource)));
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-31991dd7.cjs.dev.js');
3
+ var index = require('./index-43369070.cjs.dev.js');
4
4
  var result = require('./result-48320acd.cjs.dev.js');
5
5
 
6
6
  function hasOwn(obj, prop) {
@@ -529,6 +529,9 @@ function getSource(valModule) {
529
529
  return source;
530
530
  }
531
531
  function splitModuleIdAndModulePath(path) {
532
+ if (path.indexOf(".") === -1) {
533
+ return [path, ""];
534
+ }
532
535
  return [path.slice(0, path.indexOf(".")), path.slice(path.indexOf(".") + 1)];
533
536
  }
534
537
  function isObjectSchema(schema) {
@@ -584,7 +587,7 @@ function resolvePath(path, valModule, schema) {
584
587
  }
585
588
  if (isArraySchema(resolvedSchema)) {
586
589
  if (Number.isNaN(Number(part))) {
587
- throw Error("Invalid path: array schema ".concat(resolvedSchema, " must have ").concat(part, " a number as path"));
590
+ throw Error("Invalid path: array schema ".concat(JSON.stringify(resolvedSchema), " must have a number as path, but got ").concat(part, ". Path: ").concat(path));
588
591
  }
589
592
  if (index._typeof(resolvedSource) !== "object" && !Array.isArray(resolvedSource)) {
590
593
  throw Error("Schema type error: expected source to be type of array, but got ".concat(index._typeof(resolvedSource)));