@valbuild/core 0.61.0 → 0.62.1
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.
- package/dist/declarations/src/ValApi.d.ts +18 -15
- package/dist/declarations/src/index.d.ts +36 -42
- package/dist/declarations/src/initVal.d.ts +1 -1
- package/dist/declarations/src/module.d.ts +3 -2
- package/dist/declarations/src/source/file.d.ts +1 -0
- package/dist/declarations/src/val/index.d.ts +4 -4
- package/dist/index-316f5dd8.esm.js +4016 -0
- package/dist/index-3193efd5.cjs.dev.js +4057 -0
- package/dist/index-596f28bb.cjs.prod.js +4057 -0
- package/dist/{result-b96df128.esm.js → result-a8316efa.esm.js} +1 -1
- package/dist/valbuild-core.cjs.dev.js +29 -1844
- package/dist/valbuild-core.cjs.prod.js +29 -1844
- package/dist/valbuild-core.esm.js +2 -1823
- package/expr/dist/valbuild-core-expr.cjs.dev.js +7 -8
- package/expr/dist/valbuild-core-expr.cjs.prod.js +7 -8
- package/expr/dist/valbuild-core-expr.esm.js +2 -3
- package/fp/dist/valbuild-core-fp.esm.js +1 -1
- package/package.json +1 -1
- package/patch/dist/valbuild-core-patch.cjs.dev.js +46 -50
- package/patch/dist/valbuild-core-patch.cjs.prod.js +46 -50
- package/patch/dist/valbuild-core-patch.esm.js +6 -10
- package/dist/index-051c34f3.esm.js +0 -539
- package/dist/index-0df230ef.cjs.dev.js +0 -572
- package/dist/index-2dfaf8f7.cjs.prod.js +0 -643
- package/dist/index-e8ab2166.cjs.dev.js +0 -643
- package/dist/index-ed5767a3.esm.js +0 -639
- package/dist/index-f2552460.cjs.prod.js +0 -572
- package/dist/ops-34737ef0.cjs.dev.js +0 -1068
- package/dist/ops-92570725.cjs.prod.js +0 -1068
- package/dist/ops-9262cf01.esm.js +0 -1044
@@ -1,572 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
var result = require('./result-48320acd.cjs.dev.js');
|
4
|
-
|
5
|
-
function _arrayWithoutHoles(arr) {
|
6
|
-
if (Array.isArray(arr)) return result._arrayLikeToArray(arr);
|
7
|
-
}
|
8
|
-
|
9
|
-
function _iterableToArray(iter) {
|
10
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
11
|
-
}
|
12
|
-
|
13
|
-
function _nonIterableSpread() {
|
14
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
15
|
-
}
|
16
|
-
|
17
|
-
function _toConsumableArray(arr) {
|
18
|
-
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || result._unsupportedIterableToArray(arr) || _nonIterableSpread();
|
19
|
-
}
|
20
|
-
|
21
|
-
function _typeof(o) {
|
22
|
-
"@babel/helpers - typeof";
|
23
|
-
|
24
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
25
|
-
return typeof o;
|
26
|
-
} : function (o) {
|
27
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
28
|
-
}, _typeof(o);
|
29
|
-
}
|
30
|
-
|
31
|
-
function toPrimitive(t, r) {
|
32
|
-
if ("object" != typeof t || !t) return t;
|
33
|
-
var e = t[Symbol.toPrimitive];
|
34
|
-
if (void 0 !== e) {
|
35
|
-
var i = e.call(t, r || "default");
|
36
|
-
if ("object" != typeof i) return i;
|
37
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
38
|
-
}
|
39
|
-
return ("string" === r ? String : Number)(t);
|
40
|
-
}
|
41
|
-
|
42
|
-
function toPropertyKey(t) {
|
43
|
-
var i = toPrimitive(t, "string");
|
44
|
-
return "symbol" == typeof i ? i : String(i);
|
45
|
-
}
|
46
|
-
|
47
|
-
function _defineProperty(obj, key, value) {
|
48
|
-
key = toPropertyKey(key);
|
49
|
-
if (key in obj) {
|
50
|
-
Object.defineProperty(obj, key, {
|
51
|
-
value: value,
|
52
|
-
enumerable: true,
|
53
|
-
configurable: true,
|
54
|
-
writable: true
|
55
|
-
});
|
56
|
-
} else {
|
57
|
-
obj[key] = value;
|
58
|
-
}
|
59
|
-
return obj;
|
60
|
-
}
|
61
|
-
|
62
|
-
function ownKeys(e, r) {
|
63
|
-
var t = Object.keys(e);
|
64
|
-
if (Object.getOwnPropertySymbols) {
|
65
|
-
var o = Object.getOwnPropertySymbols(e);
|
66
|
-
r && (o = o.filter(function (r) {
|
67
|
-
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
68
|
-
})), t.push.apply(t, o);
|
69
|
-
}
|
70
|
-
return t;
|
71
|
-
}
|
72
|
-
function _objectSpread2(e) {
|
73
|
-
for (var r = 1; r < arguments.length; r++) {
|
74
|
-
var t = null != arguments[r] ? arguments[r] : {};
|
75
|
-
r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
|
76
|
-
_defineProperty(e, r, t[r]);
|
77
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
78
|
-
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
79
|
-
});
|
80
|
-
}
|
81
|
-
return e;
|
82
|
-
}
|
83
|
-
|
84
|
-
function _arrayWithHoles(arr) {
|
85
|
-
if (Array.isArray(arr)) return arr;
|
86
|
-
}
|
87
|
-
|
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
|
-
try {
|
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
|
-
} finally {
|
106
|
-
try {
|
107
|
-
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
108
|
-
} finally {
|
109
|
-
if (o) throw n;
|
110
|
-
}
|
111
|
-
}
|
112
|
-
return a;
|
113
|
-
}
|
114
|
-
}
|
115
|
-
|
116
|
-
function _nonIterableRest() {
|
117
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
118
|
-
}
|
119
|
-
|
120
|
-
function _slicedToArray(arr, i) {
|
121
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || result._unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
122
|
-
}
|
123
|
-
|
124
|
-
function _classCallCheck(instance, Constructor) {
|
125
|
-
if (!(instance instanceof Constructor)) {
|
126
|
-
throw new TypeError("Cannot call a class as a function");
|
127
|
-
}
|
128
|
-
}
|
129
|
-
|
130
|
-
function _defineProperties(target, props) {
|
131
|
-
for (var i = 0; i < props.length; i++) {
|
132
|
-
var descriptor = props[i];
|
133
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
134
|
-
descriptor.configurable = true;
|
135
|
-
if ("value" in descriptor) descriptor.writable = true;
|
136
|
-
Object.defineProperty(target, toPropertyKey(descriptor.key), descriptor);
|
137
|
-
}
|
138
|
-
}
|
139
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
140
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
141
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
142
|
-
Object.defineProperty(Constructor, "prototype", {
|
143
|
-
writable: false
|
144
|
-
});
|
145
|
-
return Constructor;
|
146
|
-
}
|
147
|
-
|
148
|
-
function _getPrototypeOf(o) {
|
149
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
150
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
151
|
-
};
|
152
|
-
return _getPrototypeOf(o);
|
153
|
-
}
|
154
|
-
|
155
|
-
function _isNativeReflectConstruct() {
|
156
|
-
try {
|
157
|
-
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
158
|
-
} catch (t) {}
|
159
|
-
return (_isNativeReflectConstruct = function () {
|
160
|
-
return !!t;
|
161
|
-
})();
|
162
|
-
}
|
163
|
-
|
164
|
-
function _assertThisInitialized(self) {
|
165
|
-
if (self === void 0) {
|
166
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
167
|
-
}
|
168
|
-
return self;
|
169
|
-
}
|
170
|
-
|
171
|
-
function _possibleConstructorReturn(self, call) {
|
172
|
-
if (call && (typeof call === "object" || typeof call === "function")) {
|
173
|
-
return call;
|
174
|
-
} else if (call !== void 0) {
|
175
|
-
throw new TypeError("Derived constructors may only return object or undefined");
|
176
|
-
}
|
177
|
-
return _assertThisInitialized(self);
|
178
|
-
}
|
179
|
-
|
180
|
-
function _callSuper(t, o, e) {
|
181
|
-
return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
|
182
|
-
}
|
183
|
-
|
184
|
-
function _setPrototypeOf(o, p) {
|
185
|
-
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
186
|
-
o.__proto__ = p;
|
187
|
-
return o;
|
188
|
-
};
|
189
|
-
return _setPrototypeOf(o, p);
|
190
|
-
}
|
191
|
-
|
192
|
-
function _inherits(subClass, superClass) {
|
193
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
194
|
-
throw new TypeError("Super expression must either be null or a function");
|
195
|
-
}
|
196
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
197
|
-
constructor: {
|
198
|
-
value: subClass,
|
199
|
-
writable: true,
|
200
|
-
configurable: true
|
201
|
-
}
|
202
|
-
});
|
203
|
-
Object.defineProperty(subClass, "prototype", {
|
204
|
-
writable: false
|
205
|
-
});
|
206
|
-
if (superClass) _setPrototypeOf(subClass, superClass);
|
207
|
-
}
|
208
|
-
|
209
|
-
// import { RemoteCompatibleSource, RemoteSource } from "../source/remote";
|
210
|
-
|
211
|
-
// import { SerializedI18nSchema } from "./future/i18n";
|
212
|
-
// import { SerializedOneOfSchema } from "./future/oneOf";
|
213
|
-
|
214
|
-
var Schema = /*#__PURE__*/function () {
|
215
|
-
function Schema() {
|
216
|
-
_classCallCheck(this, Schema);
|
217
|
-
}
|
218
|
-
_createClass(Schema, [{
|
219
|
-
key: "appendValidationError",
|
220
|
-
value:
|
221
|
-
// remote(): Src extends RemoteCompatibleSource
|
222
|
-
// ? Schema<RemoteSource<Src>>
|
223
|
-
// : never {
|
224
|
-
// // TODO: Schema<never, "Cannot create remote schema from non-remote source.">
|
225
|
-
// throw new Error("You need Val Ultra to use .remote()");
|
226
|
-
// }
|
227
|
-
|
228
|
-
/** MUTATES! since internal and perf sensitive */
|
229
|
-
function appendValidationError(current, path, message, value) {
|
230
|
-
if (current) {
|
231
|
-
if (current[path]) {
|
232
|
-
current[path].push({
|
233
|
-
message: message,
|
234
|
-
value: value
|
235
|
-
});
|
236
|
-
} else {
|
237
|
-
current[path] = [{
|
238
|
-
message: message,
|
239
|
-
value: value
|
240
|
-
}];
|
241
|
-
}
|
242
|
-
return current;
|
243
|
-
} else {
|
244
|
-
return _defineProperty({}, path, [{
|
245
|
-
message: message,
|
246
|
-
value: value
|
247
|
-
}]);
|
248
|
-
}
|
249
|
-
}
|
250
|
-
}]);
|
251
|
-
return Schema;
|
252
|
-
}();
|
253
|
-
|
254
|
-
// TODO: SourceError<"Could not determine type of Schema">
|
255
|
-
|
256
|
-
/**
|
257
|
-
* @internal
|
258
|
-
*/
|
259
|
-
var GetSchema = Symbol("GetSchema");
|
260
|
-
/**
|
261
|
-
/**
|
262
|
-
* @internal
|
263
|
-
*/
|
264
|
-
var Path = Symbol("Path");
|
265
|
-
/**
|
266
|
-
* @internal
|
267
|
-
*/
|
268
|
-
var GetSource = Symbol("GetSource");
|
269
|
-
/**
|
270
|
-
* @internal
|
271
|
-
*/
|
272
|
-
var ValError = Symbol("ValError");
|
273
|
-
var GenericSelector = /*#__PURE__*/_createClass(function GenericSelector(valOrExpr, path, schema, error) {
|
274
|
-
_classCallCheck(this, GenericSelector);
|
275
|
-
this[Path] = path;
|
276
|
-
this[GetSource] = valOrExpr;
|
277
|
-
this[ValError] = error;
|
278
|
-
this[GetSchema] = schema;
|
279
|
-
});
|
280
|
-
|
281
|
-
/**
|
282
|
-
* Use this type to convert types that accepts both Source and Selectors
|
283
|
-
*
|
284
|
-
* An example would be where literals are supported like in most higher order functions (e.g. map in array)
|
285
|
-
**/
|
286
|
-
|
287
|
-
function getSchema(selector) {
|
288
|
-
return selector[GetSchema];
|
289
|
-
}
|
290
|
-
|
291
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
292
|
-
|
293
|
-
var Expr = /*#__PURE__*/_createClass(function Expr(span) {
|
294
|
-
_classCallCheck(this, Expr);
|
295
|
-
this.span = span;
|
296
|
-
});
|
297
|
-
var StringLiteral = /*#__PURE__*/function (_Expr) {
|
298
|
-
_inherits(StringLiteral, _Expr);
|
299
|
-
function StringLiteral(value, span) {
|
300
|
-
var _this;
|
301
|
-
_classCallCheck(this, StringLiteral);
|
302
|
-
_this = _callSuper(this, StringLiteral, [span]);
|
303
|
-
_defineProperty(_assertThisInitialized(_this), "type", "StringLiteral");
|
304
|
-
_this.value = value;
|
305
|
-
return _this;
|
306
|
-
}
|
307
|
-
_createClass(StringLiteral, [{
|
308
|
-
key: "transpile",
|
309
|
-
value: function transpile() {
|
310
|
-
return "'".concat(this.value, "'");
|
311
|
-
}
|
312
|
-
}]);
|
313
|
-
return StringLiteral;
|
314
|
-
}(Expr);
|
315
|
-
var Sym = /*#__PURE__*/function (_Expr2) {
|
316
|
-
_inherits(Sym, _Expr2);
|
317
|
-
function Sym(value, span) {
|
318
|
-
var _this2;
|
319
|
-
_classCallCheck(this, Sym);
|
320
|
-
_this2 = _callSuper(this, Sym, [span]);
|
321
|
-
_defineProperty(_assertThisInitialized(_this2), "type", "Sym");
|
322
|
-
_this2.value = value;
|
323
|
-
return _this2;
|
324
|
-
}
|
325
|
-
_createClass(Sym, [{
|
326
|
-
key: "transpile",
|
327
|
-
value: function transpile() {
|
328
|
-
return this.value;
|
329
|
-
}
|
330
|
-
}]);
|
331
|
-
return Sym;
|
332
|
-
}(Expr);
|
333
|
-
var NilSym = new Sym("()");
|
334
|
-
var StringTemplate = /*#__PURE__*/function (_Expr3) {
|
335
|
-
_inherits(StringTemplate, _Expr3);
|
336
|
-
function StringTemplate(children, span) {
|
337
|
-
var _this3;
|
338
|
-
_classCallCheck(this, StringTemplate);
|
339
|
-
_this3 = _callSuper(this, StringTemplate, [span]);
|
340
|
-
_defineProperty(_assertThisInitialized(_this3), "type", "StringTemplate");
|
341
|
-
_this3.children = children;
|
342
|
-
return _this3;
|
343
|
-
}
|
344
|
-
_createClass(StringTemplate, [{
|
345
|
-
key: "transpile",
|
346
|
-
value: function transpile() {
|
347
|
-
return "'".concat(this.children.map(function (child) {
|
348
|
-
if (child instanceof StringLiteral) {
|
349
|
-
return child.value;
|
350
|
-
} else {
|
351
|
-
return "${".concat(child.transpile(), "}");
|
352
|
-
}
|
353
|
-
}).join(""), "'");
|
354
|
-
}
|
355
|
-
}]);
|
356
|
-
return StringTemplate;
|
357
|
-
}(Expr);
|
358
|
-
var Call = /*#__PURE__*/function (_Expr4) {
|
359
|
-
_inherits(Call, _Expr4);
|
360
|
-
function Call(children, isAnon, span) {
|
361
|
-
var _this4;
|
362
|
-
_classCallCheck(this, Call);
|
363
|
-
_this4 = _callSuper(this, Call, [span]);
|
364
|
-
_defineProperty(_assertThisInitialized(_this4), "type", "Call");
|
365
|
-
_this4.children = children;
|
366
|
-
_this4.isAnon = isAnon;
|
367
|
-
return _this4;
|
368
|
-
}
|
369
|
-
_createClass(Call, [{
|
370
|
-
key: "transpile",
|
371
|
-
value: function transpile() {
|
372
|
-
if (this.isAnon) {
|
373
|
-
return "!(".concat(this.children.map(function (child) {
|
374
|
-
return child.transpile();
|
375
|
-
}).join(" "), ")");
|
376
|
-
}
|
377
|
-
return "(".concat(this.children.map(function (child) {
|
378
|
-
return child.transpile();
|
379
|
-
}).join(" "), ")");
|
380
|
-
}
|
381
|
-
}]);
|
382
|
-
return Call;
|
383
|
-
}(Expr);
|
384
|
-
|
385
|
-
/* Branded extension types: file, remote, i18n */
|
386
|
-
var VAL_EXTENSION = "_type";
|
387
|
-
|
388
|
-
/**
|
389
|
-
* A phantom type parameter is one that doesn't show up at runtime, but is checked statically (and only) at compile time.
|
390
|
-
*
|
391
|
-
* An example where this is useful is remote types, where the type of the remote source is known at compile time,
|
392
|
-
* but the value is not there before it is fetched.
|
393
|
-
*
|
394
|
-
* @example
|
395
|
-
* type Example<T> = string & PhantomType<T>;
|
396
|
-
*
|
397
|
-
**/
|
398
|
-
|
399
|
-
var FILE_REF_PROP = "_ref";
|
400
|
-
var FILE_REF_SUBTYPE_TAG = "_tag";
|
401
|
-
|
402
|
-
/**
|
403
|
-
* A file source represents the path to a (local) file.
|
404
|
-
*
|
405
|
-
* It will be resolved into a Asset object.
|
406
|
-
*
|
407
|
-
*/
|
408
|
-
|
409
|
-
function file$1(ref, metadata) {
|
410
|
-
return _defineProperty(_defineProperty(_defineProperty({}, FILE_REF_PROP, ref), VAL_EXTENSION, "file"), "metadata", metadata);
|
411
|
-
}
|
412
|
-
function isFile(obj) {
|
413
|
-
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";
|
414
|
-
}
|
415
|
-
|
416
|
-
var FileSchema = /*#__PURE__*/function (_Schema) {
|
417
|
-
_inherits(FileSchema, _Schema);
|
418
|
-
function FileSchema(options) {
|
419
|
-
var _this;
|
420
|
-
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
421
|
-
_classCallCheck(this, FileSchema);
|
422
|
-
_this = _callSuper(this, FileSchema);
|
423
|
-
_this.options = options;
|
424
|
-
_this.opt = opt;
|
425
|
-
return _this;
|
426
|
-
}
|
427
|
-
_createClass(FileSchema, [{
|
428
|
-
key: "validate",
|
429
|
-
value: function validate(path, src) {
|
430
|
-
if (this.opt && (src === null || src === undefined)) {
|
431
|
-
return false;
|
432
|
-
}
|
433
|
-
if (src === null || src === undefined) {
|
434
|
-
return _defineProperty({}, path, [{
|
435
|
-
message: "Non-optional file was null or undefined.",
|
436
|
-
value: src
|
437
|
-
}]);
|
438
|
-
}
|
439
|
-
if (typeof src[FILE_REF_PROP] !== "string") {
|
440
|
-
return _defineProperty({}, path, [{
|
441
|
-
message: "File did not have a file reference string. Got: ".concat(_typeof(src[FILE_REF_PROP])),
|
442
|
-
value: src
|
443
|
-
}]);
|
444
|
-
}
|
445
|
-
if (src[VAL_EXTENSION] !== "file") {
|
446
|
-
return _defineProperty({}, path, [{
|
447
|
-
message: "File did not have the valid file extension type. Got: ".concat(src[VAL_EXTENSION]),
|
448
|
-
value: src
|
449
|
-
}]);
|
450
|
-
}
|
451
|
-
if (src.metadata) {
|
452
|
-
return _defineProperty({}, path, [{
|
453
|
-
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).",
|
454
|
-
// 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.
|
455
|
-
value: src,
|
456
|
-
fixes: ["file:check-metadata"]
|
457
|
-
}]);
|
458
|
-
}
|
459
|
-
return _defineProperty({}, path, [{
|
460
|
-
message: "Missing File metadata.",
|
461
|
-
value: src,
|
462
|
-
fixes: ["file:add-metadata"]
|
463
|
-
}]);
|
464
|
-
}
|
465
|
-
}, {
|
466
|
-
key: "assert",
|
467
|
-
value: function assert(src) {
|
468
|
-
if (this.opt && (src === null || src === undefined)) {
|
469
|
-
return true;
|
470
|
-
}
|
471
|
-
return (src === null || src === void 0 ? void 0 : src[FILE_REF_PROP]) === "file" && (src === null || src === void 0 ? void 0 : src[VAL_EXTENSION]) === "file";
|
472
|
-
}
|
473
|
-
}, {
|
474
|
-
key: "nullable",
|
475
|
-
value: function nullable() {
|
476
|
-
return new FileSchema(this.options, true);
|
477
|
-
}
|
478
|
-
}, {
|
479
|
-
key: "serialize",
|
480
|
-
value: function serialize() {
|
481
|
-
return {
|
482
|
-
type: "file",
|
483
|
-
options: this.options,
|
484
|
-
opt: this.opt
|
485
|
-
};
|
486
|
-
}
|
487
|
-
}]);
|
488
|
-
return FileSchema;
|
489
|
-
}(Schema);
|
490
|
-
var file = function file(options) {
|
491
|
-
return new FileSchema(options);
|
492
|
-
};
|
493
|
-
function convertFileSource(src) {
|
494
|
-
var _src$metadata3, _src$metadata4;
|
495
|
-
// TODO: /public should be configurable
|
496
|
-
if (!src[FILE_REF_PROP].startsWith("/public")) {
|
497
|
-
var _src$metadata, _src$metadata2;
|
498
|
-
return {
|
499
|
-
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) : ""),
|
500
|
-
metadata: src.metadata
|
501
|
-
};
|
502
|
-
}
|
503
|
-
return {
|
504
|
-
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) : ""),
|
505
|
-
metadata: src.metadata
|
506
|
-
};
|
507
|
-
}
|
508
|
-
|
509
|
-
function isSerializedVal(val) {
|
510
|
-
return _typeof(val) === "object" && val !== null && val !== undefined && ("val" in val || "valPath" in val);
|
511
|
-
}
|
512
|
-
function isVal(val) {
|
513
|
-
return _typeof(val) === "object" && val !== null && val !== undefined && Path in val && "val" in val;
|
514
|
-
}
|
515
|
-
|
516
|
-
/**
|
517
|
-
* The path of the source value.
|
518
|
-
*
|
519
|
-
* @example
|
520
|
-
* '/app/blogs.0.text' // the text property of the first element of the /app/blogs module
|
521
|
-
*/
|
522
|
-
|
523
|
-
/**
|
524
|
-
* The path inside the module.
|
525
|
-
*
|
526
|
-
* @example
|
527
|
-
* '0."text"' // the text property of the first element of the module
|
528
|
-
*/
|
529
|
-
|
530
|
-
/**
|
531
|
-
* The id of the module.
|
532
|
-
*
|
533
|
-
* @example
|
534
|
-
* '/app/blogs' // the /app/blogs module
|
535
|
-
*/
|
536
|
-
|
537
|
-
function getValPath(valOrSelector) {
|
538
|
-
return valOrSelector[Path];
|
539
|
-
}
|
540
|
-
|
541
|
-
exports.Call = Call;
|
542
|
-
exports.Expr = Expr;
|
543
|
-
exports.FILE_REF_PROP = FILE_REF_PROP;
|
544
|
-
exports.FILE_REF_SUBTYPE_TAG = FILE_REF_SUBTYPE_TAG;
|
545
|
-
exports.FileSchema = FileSchema;
|
546
|
-
exports.GenericSelector = GenericSelector;
|
547
|
-
exports.GetSchema = GetSchema;
|
548
|
-
exports.GetSource = GetSource;
|
549
|
-
exports.NilSym = NilSym;
|
550
|
-
exports.Path = Path;
|
551
|
-
exports.Schema = Schema;
|
552
|
-
exports.StringLiteral = StringLiteral;
|
553
|
-
exports.StringTemplate = StringTemplate;
|
554
|
-
exports.Sym = Sym;
|
555
|
-
exports.VAL_EXTENSION = VAL_EXTENSION;
|
556
|
-
exports._callSuper = _callSuper;
|
557
|
-
exports._classCallCheck = _classCallCheck;
|
558
|
-
exports._createClass = _createClass;
|
559
|
-
exports._defineProperty = _defineProperty;
|
560
|
-
exports._inherits = _inherits;
|
561
|
-
exports._objectSpread2 = _objectSpread2;
|
562
|
-
exports._slicedToArray = _slicedToArray;
|
563
|
-
exports._toConsumableArray = _toConsumableArray;
|
564
|
-
exports._typeof = _typeof;
|
565
|
-
exports.convertFileSource = convertFileSource;
|
566
|
-
exports.file = file;
|
567
|
-
exports.file$1 = file$1;
|
568
|
-
exports.getSchema = getSchema;
|
569
|
-
exports.getValPath = getValPath;
|
570
|
-
exports.isFile = isFile;
|
571
|
-
exports.isSerializedVal = isSerializedVal;
|
572
|
-
exports.isVal = isVal;
|