@valbuild/core 0.64.0 → 0.65.2
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/expr/expr.d.ts +2 -2
- package/dist/declarations/src/expr/parser.d.ts +2 -2
- package/dist/declarations/src/index.d.ts +38 -5
- package/dist/declarations/src/initSchema.d.ts +19 -49
- package/dist/declarations/src/initVal.d.ts +8 -3
- package/dist/declarations/src/module.d.ts +6 -2
- package/dist/declarations/src/schema/file.d.ts +0 -1
- package/dist/declarations/src/schema/image.d.ts +0 -1
- package/dist/declarations/src/schema/keyOf.d.ts +5 -5
- package/dist/declarations/src/schema/richtext.d.ts +1 -21
- package/dist/declarations/src/schema/union.d.ts +13 -14
- package/dist/declarations/src/source/file.d.ts +7 -4
- package/dist/{index-41223963.cjs.prod.js → index-48930c58.cjs.dev.js} +267 -243
- package/dist/{index-4240c6a6.esm.js → index-65ec1d74.esm.js} +267 -244
- package/dist/{index-d384ec25.cjs.dev.js → index-f1a23e6c.cjs.prod.js} +267 -243
- package/dist/{result-a8316efa.esm.js → result-168dfc1d.esm.js} +42 -46
- package/dist/{result-48320acd.cjs.dev.js → result-787e35f6.cjs.prod.js} +41 -45
- package/dist/{result-26f67b40.cjs.prod.js → result-bb1f436e.cjs.dev.js} +41 -45
- package/dist/valbuild-core.cjs.d.ts +2 -2
- package/dist/valbuild-core.cjs.dev.js +3 -2
- package/dist/valbuild-core.cjs.prod.js +3 -2
- package/dist/valbuild-core.esm.js +2 -2
- package/expr/dist/valbuild-core-expr.cjs.d.ts +2 -2
- package/expr/dist/valbuild-core-expr.cjs.dev.js +2 -2
- package/expr/dist/valbuild-core-expr.cjs.prod.js +2 -2
- package/expr/dist/valbuild-core-expr.esm.js +2 -2
- package/fp/dist/valbuild-core-fp.cjs.d.ts +2 -2
- package/fp/dist/valbuild-core-fp.cjs.dev.js +1 -1
- package/fp/dist/valbuild-core-fp.cjs.prod.js +1 -1
- package/fp/dist/valbuild-core-fp.esm.js +1 -1
- package/package.json +1 -1
- package/patch/dist/valbuild-core-patch.cjs.d.ts +2 -2
- package/patch/dist/valbuild-core-patch.cjs.dev.js +8 -9
- package/patch/dist/valbuild-core-patch.cjs.prod.js +8 -9
- package/patch/dist/valbuild-core-patch.esm.js +9 -10
- package/dist/valbuild-core.cjs.d.ts.map +0 -1
- package/expr/dist/valbuild-core-expr.cjs.d.ts.map +0 -1
- package/fp/dist/valbuild-core-fp.cjs.d.ts.map +0 -1
- package/patch/dist/valbuild-core-patch.cjs.d.ts.map +0 -1
@@ -1,21 +1,61 @@
|
|
1
|
-
import { _ as
|
1
|
+
import { _ as _unsupportedIterableToArray, a as _arrayLikeToArray, i as isErr, e as err, o as ok, b as isOk, c as _createForOfIteratorHelper } from './result-168dfc1d.esm.js';
|
2
2
|
import * as marked from 'marked';
|
3
3
|
import { VAL_EXTENSION as VAL_EXTENSION$1, FILE_REF_SUBTYPE_TAG as FILE_REF_SUBTYPE_TAG$1 } from '@valbuild/core';
|
4
4
|
|
5
|
-
function
|
6
|
-
if (Array.isArray(
|
5
|
+
function _arrayWithHoles(r) {
|
6
|
+
if (Array.isArray(r)) return r;
|
7
7
|
}
|
8
8
|
|
9
|
-
function
|
10
|
-
|
9
|
+
function _iterableToArrayLimit(r, l) {
|
10
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
11
|
+
if (null != t) {
|
12
|
+
var e,
|
13
|
+
n,
|
14
|
+
i,
|
15
|
+
u,
|
16
|
+
a = [],
|
17
|
+
f = !0,
|
18
|
+
o = !1;
|
19
|
+
try {
|
20
|
+
if (i = (t = t.call(r)).next, 0 === l) {
|
21
|
+
if (Object(t) !== t) return;
|
22
|
+
f = !1;
|
23
|
+
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
24
|
+
} catch (r) {
|
25
|
+
o = !0, n = r;
|
26
|
+
} finally {
|
27
|
+
try {
|
28
|
+
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
29
|
+
} finally {
|
30
|
+
if (o) throw n;
|
31
|
+
}
|
32
|
+
}
|
33
|
+
return a;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
function _nonIterableRest() {
|
38
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
39
|
+
}
|
40
|
+
|
41
|
+
function _slicedToArray(r, e) {
|
42
|
+
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
43
|
+
}
|
44
|
+
|
45
|
+
function _arrayWithoutHoles(r) {
|
46
|
+
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
47
|
+
}
|
48
|
+
|
49
|
+
function _iterableToArray(r) {
|
50
|
+
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
11
51
|
}
|
12
52
|
|
13
53
|
function _nonIterableSpread() {
|
14
54
|
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
55
|
}
|
16
56
|
|
17
|
-
function _toConsumableArray(
|
18
|
-
return _arrayWithoutHoles(
|
57
|
+
function _toConsumableArray(r) {
|
58
|
+
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
19
59
|
}
|
20
60
|
|
21
61
|
function _typeof(o) {
|
@@ -28,7 +68,7 @@ function _typeof(o) {
|
|
28
68
|
}, _typeof(o);
|
29
69
|
}
|
30
70
|
|
31
|
-
function
|
71
|
+
function _toPrimitive(t, r) {
|
32
72
|
if ("object" != typeof t || !t) return t;
|
33
73
|
var e = t[Symbol.toPrimitive];
|
34
74
|
if (void 0 !== e) {
|
@@ -39,24 +79,18 @@ function toPrimitive(t, r) {
|
|
39
79
|
return ("string" === r ? String : Number)(t);
|
40
80
|
}
|
41
81
|
|
42
|
-
function
|
43
|
-
var i =
|
44
|
-
return "symbol" == typeof i ? i :
|
82
|
+
function _toPropertyKey(t) {
|
83
|
+
var i = _toPrimitive(t, "string");
|
84
|
+
return "symbol" == typeof i ? i : i + "";
|
45
85
|
}
|
46
86
|
|
47
|
-
function _defineProperty(
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
writable: true
|
55
|
-
});
|
56
|
-
} else {
|
57
|
-
obj[key] = value;
|
58
|
-
}
|
59
|
-
return obj;
|
87
|
+
function _defineProperty(e, r, t) {
|
88
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
89
|
+
value: t,
|
90
|
+
enumerable: !0,
|
91
|
+
configurable: !0,
|
92
|
+
writable: !0
|
93
|
+
}) : e[r] = t, e;
|
60
94
|
}
|
61
95
|
|
62
96
|
function ownKeys(e, r) {
|
@@ -81,75 +115,26 @@ function _objectSpread2(e) {
|
|
81
115
|
return e;
|
82
116
|
}
|
83
117
|
|
84
|
-
function
|
85
|
-
if (
|
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) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
118
|
+
function _classCallCheck(a, n) {
|
119
|
+
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
122
120
|
}
|
123
121
|
|
124
|
-
function
|
125
|
-
|
126
|
-
|
122
|
+
function _defineProperties(e, r) {
|
123
|
+
for (var t = 0; t < r.length; t++) {
|
124
|
+
var o = r[t];
|
125
|
+
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
127
126
|
}
|
128
127
|
}
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
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;
|
128
|
+
function _createClass(e, r, t) {
|
129
|
+
return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
|
130
|
+
writable: !1
|
131
|
+
}), e;
|
146
132
|
}
|
147
133
|
|
148
|
-
function _getPrototypeOf(
|
149
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function
|
150
|
-
return
|
151
|
-
};
|
152
|
-
return _getPrototypeOf(o);
|
134
|
+
function _getPrototypeOf(t) {
|
135
|
+
return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
|
136
|
+
return t.__proto__ || Object.getPrototypeOf(t);
|
137
|
+
}, _getPrototypeOf(t);
|
153
138
|
}
|
154
139
|
|
155
140
|
function _isNativeReflectConstruct() {
|
@@ -161,49 +146,38 @@ function _isNativeReflectConstruct() {
|
|
161
146
|
})();
|
162
147
|
}
|
163
148
|
|
164
|
-
function _assertThisInitialized(
|
165
|
-
if (
|
166
|
-
|
167
|
-
}
|
168
|
-
return self;
|
149
|
+
function _assertThisInitialized(e) {
|
150
|
+
if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
151
|
+
return e;
|
169
152
|
}
|
170
153
|
|
171
|
-
function _possibleConstructorReturn(
|
172
|
-
if (
|
173
|
-
|
174
|
-
|
175
|
-
throw new TypeError("Derived constructors may only return object or undefined");
|
176
|
-
}
|
177
|
-
return _assertThisInitialized(self);
|
154
|
+
function _possibleConstructorReturn(t, e) {
|
155
|
+
if (e && ("object" == typeof e || "function" == typeof e)) return e;
|
156
|
+
if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
|
157
|
+
return _assertThisInitialized(t);
|
178
158
|
}
|
179
159
|
|
180
160
|
function _callSuper(t, o, e) {
|
181
161
|
return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
|
182
162
|
}
|
183
163
|
|
184
|
-
function _setPrototypeOf(
|
185
|
-
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function
|
186
|
-
|
187
|
-
|
188
|
-
};
|
189
|
-
return _setPrototypeOf(o, p);
|
164
|
+
function _setPrototypeOf(t, e) {
|
165
|
+
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
166
|
+
return t.__proto__ = e, t;
|
167
|
+
}, _setPrototypeOf(t, e);
|
190
168
|
}
|
191
169
|
|
192
|
-
function _inherits(
|
193
|
-
if (typeof
|
194
|
-
|
195
|
-
}
|
196
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
170
|
+
function _inherits(t, e) {
|
171
|
+
if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
|
172
|
+
t.prototype = Object.create(e && e.prototype, {
|
197
173
|
constructor: {
|
198
|
-
value:
|
199
|
-
writable:
|
200
|
-
configurable:
|
174
|
+
value: t,
|
175
|
+
writable: !0,
|
176
|
+
configurable: !0
|
201
177
|
}
|
202
|
-
})
|
203
|
-
|
204
|
-
|
205
|
-
});
|
206
|
-
if (superClass) _setPrototypeOf(subClass, superClass);
|
178
|
+
}), Object.defineProperty(t, "prototype", {
|
179
|
+
writable: !1
|
180
|
+
}), e && _setPrototypeOf(t, e);
|
207
181
|
}
|
208
182
|
|
209
183
|
// import { RemoteCompatibleSource, RemoteSource } from "../source/remote";
|
@@ -215,7 +189,7 @@ var Schema = /*#__PURE__*/function () {
|
|
215
189
|
function Schema() {
|
216
190
|
_classCallCheck(this, Schema);
|
217
191
|
}
|
218
|
-
_createClass(Schema, [{
|
192
|
+
return _createClass(Schema, [{
|
219
193
|
key: "appendValidationError",
|
220
194
|
value:
|
221
195
|
// remote(): Src extends RemoteCompatibleSource
|
@@ -248,7 +222,6 @@ var Schema = /*#__PURE__*/function () {
|
|
248
222
|
}
|
249
223
|
}
|
250
224
|
}]);
|
251
|
-
return Schema;
|
252
225
|
}();
|
253
226
|
|
254
227
|
// TODO: SourceError<"Could not determine type of Schema">
|
@@ -295,53 +268,51 @@ var Expr = /*#__PURE__*/_createClass(function Expr(span) {
|
|
295
268
|
this.span = span;
|
296
269
|
});
|
297
270
|
var StringLiteral = /*#__PURE__*/function (_Expr) {
|
298
|
-
_inherits(StringLiteral, _Expr);
|
299
271
|
function StringLiteral(value, span) {
|
300
272
|
var _this;
|
301
273
|
_classCallCheck(this, StringLiteral);
|
302
274
|
_this = _callSuper(this, StringLiteral, [span]);
|
303
|
-
_defineProperty(
|
275
|
+
_defineProperty(_this, "type", "StringLiteral");
|
304
276
|
_this.value = value;
|
305
277
|
return _this;
|
306
278
|
}
|
307
|
-
|
279
|
+
_inherits(StringLiteral, _Expr);
|
280
|
+
return _createClass(StringLiteral, [{
|
308
281
|
key: "transpile",
|
309
282
|
value: function transpile() {
|
310
283
|
return "'".concat(this.value, "'");
|
311
284
|
}
|
312
285
|
}]);
|
313
|
-
return StringLiteral;
|
314
286
|
}(Expr);
|
315
287
|
var Sym = /*#__PURE__*/function (_Expr2) {
|
316
|
-
_inherits(Sym, _Expr2);
|
317
288
|
function Sym(value, span) {
|
318
289
|
var _this2;
|
319
290
|
_classCallCheck(this, Sym);
|
320
291
|
_this2 = _callSuper(this, Sym, [span]);
|
321
|
-
_defineProperty(
|
292
|
+
_defineProperty(_this2, "type", "Sym");
|
322
293
|
_this2.value = value;
|
323
294
|
return _this2;
|
324
295
|
}
|
325
|
-
|
296
|
+
_inherits(Sym, _Expr2);
|
297
|
+
return _createClass(Sym, [{
|
326
298
|
key: "transpile",
|
327
299
|
value: function transpile() {
|
328
300
|
return this.value;
|
329
301
|
}
|
330
302
|
}]);
|
331
|
-
return Sym;
|
332
303
|
}(Expr);
|
333
304
|
var NilSym = new Sym("()");
|
334
305
|
var StringTemplate = /*#__PURE__*/function (_Expr3) {
|
335
|
-
_inherits(StringTemplate, _Expr3);
|
336
306
|
function StringTemplate(children, span) {
|
337
307
|
var _this3;
|
338
308
|
_classCallCheck(this, StringTemplate);
|
339
309
|
_this3 = _callSuper(this, StringTemplate, [span]);
|
340
|
-
_defineProperty(
|
310
|
+
_defineProperty(_this3, "type", "StringTemplate");
|
341
311
|
_this3.children = children;
|
342
312
|
return _this3;
|
343
313
|
}
|
344
|
-
|
314
|
+
_inherits(StringTemplate, _Expr3);
|
315
|
+
return _createClass(StringTemplate, [{
|
345
316
|
key: "transpile",
|
346
317
|
value: function transpile() {
|
347
318
|
return "'".concat(this.children.map(function (child) {
|
@@ -353,20 +324,19 @@ var StringTemplate = /*#__PURE__*/function (_Expr3) {
|
|
353
324
|
}).join(""), "'");
|
354
325
|
}
|
355
326
|
}]);
|
356
|
-
return StringTemplate;
|
357
327
|
}(Expr);
|
358
328
|
var Call = /*#__PURE__*/function (_Expr4) {
|
359
|
-
_inherits(Call, _Expr4);
|
360
329
|
function Call(children, isAnon, span) {
|
361
330
|
var _this4;
|
362
331
|
_classCallCheck(this, Call);
|
363
332
|
_this4 = _callSuper(this, Call, [span]);
|
364
|
-
_defineProperty(
|
333
|
+
_defineProperty(_this4, "type", "Call");
|
365
334
|
_this4.children = children;
|
366
335
|
_this4.isAnon = isAnon;
|
367
336
|
return _this4;
|
368
337
|
}
|
369
|
-
|
338
|
+
_inherits(Call, _Expr4);
|
339
|
+
return _createClass(Call, [{
|
370
340
|
key: "transpile",
|
371
341
|
value: function transpile() {
|
372
342
|
if (this.isAnon) {
|
@@ -379,7 +349,6 @@ var Call = /*#__PURE__*/function (_Expr4) {
|
|
379
349
|
}).join(" "), ")");
|
380
350
|
}
|
381
351
|
}]);
|
382
|
-
return Call;
|
383
352
|
}(Expr);
|
384
353
|
|
385
354
|
/* Branded extension types: file, remote, i18n */
|
@@ -406,15 +375,49 @@ var FILE_REF_SUBTYPE_TAG = "_tag"; // TODO: used earlier by c.rt.image, when we
|
|
406
375
|
*
|
407
376
|
*/
|
408
377
|
|
409
|
-
function
|
410
|
-
|
411
|
-
|
378
|
+
var initFile = function initFile(config) {
|
379
|
+
var _config$files$directo, _config$files;
|
380
|
+
(_config$files$directo = config === null || config === void 0 || (_config$files = config.files) === null || _config$files === void 0 ? void 0 : _config$files.directory) !== null && _config$files$directo !== void 0 ? _config$files$directo : "/public/val";
|
381
|
+
function file(ref, metadata) {
|
382
|
+
return _defineProperty(_defineProperty(_defineProperty({}, FILE_REF_PROP, ref), VAL_EXTENSION, "file"), "metadata", metadata);
|
383
|
+
}
|
384
|
+
return file;
|
385
|
+
};
|
386
|
+
|
387
|
+
// type Directory =
|
388
|
+
// | (typeof config extends { files: { directory: infer D } } ? D : never)
|
389
|
+
// | `/public/val`;
|
390
|
+
// console.log("path", config);
|
391
|
+
// const userSpecifiedDirectory: Directory = config ?? "/public/val";
|
392
|
+
|
393
|
+
// const directory = userSpecifiedDirectory;
|
394
|
+
|
395
|
+
// export function file<Metadata extends { readonly [key: string]: Json }>(
|
396
|
+
// ref: `${typeof directory}/${string}`,
|
397
|
+
// metadata: Metadata
|
398
|
+
// ): FileSource<Metadata>;
|
399
|
+
// export function file(
|
400
|
+
// ref: `${typeof directory}/${string}`,
|
401
|
+
// metadata?: undefined
|
402
|
+
// ): FileSource<undefined>;
|
403
|
+
// export function file<
|
404
|
+
// Metadata extends { readonly [key: string]: Json } | undefined
|
405
|
+
// >(
|
406
|
+
// ref: `${typeof directory}/${string}`,
|
407
|
+
// metadata?: Metadata
|
408
|
+
// ): FileSource<Metadata> {
|
409
|
+
// return {
|
410
|
+
// [FILE_REF_PROP]: ref,
|
411
|
+
// [VAL_EXTENSION]: "file",
|
412
|
+
// metadata,
|
413
|
+
// } as FileSource<Metadata>;
|
414
|
+
// }
|
415
|
+
|
412
416
|
function isFile(obj) {
|
413
417
|
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
418
|
}
|
415
419
|
|
416
420
|
var FileSchema = /*#__PURE__*/function (_Schema) {
|
417
|
-
_inherits(FileSchema, _Schema);
|
418
421
|
function FileSchema(options) {
|
419
422
|
var _this;
|
420
423
|
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
@@ -424,7 +427,8 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
|
|
424
427
|
_this.opt = opt;
|
425
428
|
return _this;
|
426
429
|
}
|
427
|
-
|
430
|
+
_inherits(FileSchema, _Schema);
|
431
|
+
return _createClass(FileSchema, [{
|
428
432
|
key: "validate",
|
429
433
|
value: function validate(path, src) {
|
430
434
|
if (this.opt && (src === null || src === undefined)) {
|
@@ -494,7 +498,7 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
|
|
494
498
|
}
|
495
499
|
if (src.metadata) {
|
496
500
|
return _defineProperty({}, path, [{
|
497
|
-
message: "Found metadata, but it could not be validated. File metadata must be an object with the
|
501
|
+
message: "Found metadata, but it could not be validated. File metadata must be an object with the mimeType.",
|
498
502
|
// 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.
|
499
503
|
value: src,
|
500
504
|
fixes: ["file:check-metadata"]
|
@@ -571,25 +575,26 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
|
|
571
575
|
};
|
572
576
|
}
|
573
577
|
}]);
|
574
|
-
return FileSchema;
|
575
578
|
}(Schema);
|
576
579
|
var file = function file(options) {
|
577
580
|
return new FileSchema(options);
|
578
581
|
};
|
579
582
|
function convertFileSource(src) {
|
580
|
-
var _src$metadata4, _src$metadata5, _src$metadata6;
|
581
583
|
// TODO: /public should be configurable
|
582
584
|
if (!src[FILE_REF_PROP].startsWith("/public")) {
|
583
|
-
var _src$metadata, _src$metadata2, _src$metadata3;
|
584
585
|
return {
|
585
|
-
url: src[FILE_REF_PROP] + (
|
586
|
-
|
587
|
-
|
586
|
+
url: src[FILE_REF_PROP] + (src.patch_id ? "?patch_id=".concat(src["patch_id"]) : ""),
|
587
|
+
metadata: src.metadata
|
588
|
+
};
|
589
|
+
}
|
590
|
+
if (src.patch_id) {
|
591
|
+
return {
|
592
|
+
url: "/api/val/files" + src[FILE_REF_PROP] + "?patch_id=".concat(src["patch_id"]),
|
588
593
|
metadata: src.metadata
|
589
594
|
};
|
590
595
|
}
|
591
596
|
return {
|
592
|
-
url: src[FILE_REF_PROP].slice("/public".length)
|
597
|
+
url: src[FILE_REF_PROP].slice("/public".length),
|
593
598
|
metadata: src.metadata
|
594
599
|
};
|
595
600
|
}
|
@@ -790,7 +795,6 @@ function unValify$1(valueOrSelector) {
|
|
790
795
|
}
|
791
796
|
|
792
797
|
var ObjectSchema = /*#__PURE__*/function (_Schema) {
|
793
|
-
_inherits(ObjectSchema, _Schema);
|
794
798
|
function ObjectSchema(items) {
|
795
799
|
var _this;
|
796
800
|
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
@@ -800,7 +804,8 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
|
|
800
804
|
_this.opt = opt;
|
801
805
|
return _this;
|
802
806
|
}
|
803
|
-
|
807
|
+
_inherits(ObjectSchema, _Schema);
|
808
|
+
return _createClass(ObjectSchema, [{
|
804
809
|
key: "validate",
|
805
810
|
value: function validate(path, src) {
|
806
811
|
var _this2 = this;
|
@@ -927,7 +932,6 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
|
|
927
932
|
};
|
928
933
|
}
|
929
934
|
}]);
|
930
|
-
return ObjectSchema;
|
931
935
|
}(Schema);
|
932
936
|
var object = function object(schema) {
|
933
937
|
return new ObjectSchema(schema);
|
@@ -960,7 +964,7 @@ function tokenize(input) {
|
|
960
964
|
});
|
961
965
|
cursor++;
|
962
966
|
} else if (_char === "'" || _char === "}") {
|
963
|
-
var
|
967
|
+
var start = cursor;
|
964
968
|
var value = "";
|
965
969
|
var unescapedValue = "";
|
966
970
|
var escaped = false;
|
@@ -1003,7 +1007,7 @@ function tokenize(input) {
|
|
1003
1007
|
if (value) {
|
1004
1008
|
tokens.push(_objectSpread2({
|
1005
1009
|
type: "string",
|
1006
|
-
span: [
|
1010
|
+
span: [start + 1, cursor - cursorOffset],
|
1007
1011
|
value: value
|
1008
1012
|
}, unescapedValue !== value && {
|
1009
1013
|
unescapedValue: unescapedValue
|
@@ -1021,17 +1025,17 @@ function tokenize(input) {
|
|
1021
1025
|
});
|
1022
1026
|
}
|
1023
1027
|
} else if (WHITE_SPACE.includes(_char)) {
|
1024
|
-
var
|
1028
|
+
var _start = cursor;
|
1025
1029
|
while (WHITE_SPACE.includes(input[cursor]) && cursor < input.length) {
|
1026
1030
|
cursor++;
|
1027
1031
|
}
|
1028
1032
|
tokens.push({
|
1029
1033
|
type: "ws",
|
1030
|
-
span: [
|
1034
|
+
span: [_start, cursor - 1]
|
1031
1035
|
});
|
1032
1036
|
} else {
|
1033
1037
|
var _value = "";
|
1034
|
-
var
|
1038
|
+
var _start2 = cursor;
|
1035
1039
|
do {
|
1036
1040
|
_char = input[cursor];
|
1037
1041
|
peek = input[cursor + 1];
|
@@ -1040,7 +1044,7 @@ function tokenize(input) {
|
|
1040
1044
|
} while (!WHITE_SPACE.includes(peek) && peek !== ")" && peek !== "'" && cursor < input.length);
|
1041
1045
|
tokens.push({
|
1042
1046
|
type: "token",
|
1043
|
-
span: [
|
1047
|
+
span: [_start2, cursor - 1],
|
1044
1048
|
value: _value
|
1045
1049
|
});
|
1046
1050
|
}
|
@@ -1379,13 +1383,12 @@ var EvalError = /*#__PURE__*/function () {
|
|
1379
1383
|
this.message = message;
|
1380
1384
|
this.expr = expr;
|
1381
1385
|
}
|
1382
|
-
_createClass(EvalError, [{
|
1386
|
+
return _createClass(EvalError, [{
|
1383
1387
|
key: "toString",
|
1384
1388
|
value: function toString() {
|
1385
1389
|
return "".concat(this.message, " in: ").concat(this.expr.transpile());
|
1386
1390
|
}
|
1387
1391
|
}]);
|
1388
|
-
return EvalError;
|
1389
1392
|
}();
|
1390
1393
|
var MAX_STACK_SIZE = 100; // an arbitrary semi-large number
|
1391
1394
|
function evaluateSync(expr, getSource, stack) {
|
@@ -1404,8 +1407,8 @@ function evaluateSync(expr, getSource, stack) {
|
|
1404
1407
|
throw new EvalError("cannot call 'val' as anonymous function", expr);
|
1405
1408
|
}
|
1406
1409
|
if (expr.children[1] instanceof StringLiteral) {
|
1407
|
-
var
|
1408
|
-
return newSelectorProxy(getSource(
|
1410
|
+
var path = expr.children[1].value;
|
1411
|
+
return newSelectorProxy(getSource(path), path);
|
1409
1412
|
} else {
|
1410
1413
|
throw new EvalError("argument of 'val' must be a string literal", expr);
|
1411
1414
|
}
|
@@ -1472,8 +1475,8 @@ function evaluateSync(expr, getSource, stack) {
|
|
1472
1475
|
if (expr.children[0] instanceof Sym) {
|
1473
1476
|
if (expr.children[0].value === "val") {
|
1474
1477
|
if (expr.children[1] instanceof StringLiteral) {
|
1475
|
-
var
|
1476
|
-
return newSelectorProxy(getSource(
|
1478
|
+
var _path = expr.children[1].value;
|
1479
|
+
return newSelectorProxy(getSource(_path), _path);
|
1477
1480
|
} else {
|
1478
1481
|
throw new EvalError("argument of 'val' must be a string literal", expr);
|
1479
1482
|
}
|
@@ -1563,7 +1566,6 @@ var index = /*#__PURE__*/Object.freeze({
|
|
1563
1566
|
});
|
1564
1567
|
|
1565
1568
|
var ArraySchema = /*#__PURE__*/function (_Schema) {
|
1566
|
-
_inherits(ArraySchema, _Schema);
|
1567
1569
|
function ArraySchema(item) {
|
1568
1570
|
var _this;
|
1569
1571
|
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
@@ -1573,7 +1575,8 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
|
|
1573
1575
|
_this.opt = opt;
|
1574
1576
|
return _this;
|
1575
1577
|
}
|
1576
|
-
|
1578
|
+
_inherits(ArraySchema, _Schema);
|
1579
|
+
return _createClass(ArraySchema, [{
|
1577
1580
|
key: "validate",
|
1578
1581
|
value: function validate(path, src) {
|
1579
1582
|
var assertRes = this.assert(path, src);
|
@@ -1655,14 +1658,12 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
|
|
1655
1658
|
};
|
1656
1659
|
}
|
1657
1660
|
}]);
|
1658
|
-
return ArraySchema;
|
1659
1661
|
}(Schema);
|
1660
1662
|
var array = function array(schema) {
|
1661
1663
|
return new ArraySchema(schema);
|
1662
1664
|
};
|
1663
1665
|
|
1664
1666
|
var LiteralSchema = /*#__PURE__*/function (_Schema) {
|
1665
|
-
_inherits(LiteralSchema, _Schema);
|
1666
1667
|
function LiteralSchema(value) {
|
1667
1668
|
var _this;
|
1668
1669
|
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
@@ -1672,7 +1673,8 @@ var LiteralSchema = /*#__PURE__*/function (_Schema) {
|
|
1672
1673
|
_this.opt = opt;
|
1673
1674
|
return _this;
|
1674
1675
|
}
|
1675
|
-
|
1676
|
+
_inherits(LiteralSchema, _Schema);
|
1677
|
+
return _createClass(LiteralSchema, [{
|
1676
1678
|
key: "validate",
|
1677
1679
|
value: function validate(path, src) {
|
1678
1680
|
if (this.opt && (src === null || src === undefined)) {
|
@@ -1739,14 +1741,12 @@ var LiteralSchema = /*#__PURE__*/function (_Schema) {
|
|
1739
1741
|
};
|
1740
1742
|
}
|
1741
1743
|
}]);
|
1742
|
-
return LiteralSchema;
|
1743
1744
|
}(Schema);
|
1744
1745
|
var literal = function literal(value) {
|
1745
1746
|
return new LiteralSchema(value);
|
1746
1747
|
};
|
1747
1748
|
|
1748
1749
|
var UnionSchema = /*#__PURE__*/function (_Schema) {
|
1749
|
-
_inherits(UnionSchema, _Schema);
|
1750
1750
|
function UnionSchema(key, items) {
|
1751
1751
|
var _this;
|
1752
1752
|
var opt = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
@@ -1757,7 +1757,8 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
|
|
1757
1757
|
_this.opt = opt;
|
1758
1758
|
return _this;
|
1759
1759
|
}
|
1760
|
-
|
1760
|
+
_inherits(UnionSchema, _Schema);
|
1761
|
+
return _createClass(UnionSchema, [{
|
1761
1762
|
key: "validate",
|
1762
1763
|
value: function validate(path, src) {
|
1763
1764
|
var unknownSrc = src;
|
@@ -2071,7 +2072,6 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
|
|
2071
2072
|
};
|
2072
2073
|
}
|
2073
2074
|
}]);
|
2074
|
-
return UnionSchema;
|
2075
2075
|
}(Schema);
|
2076
2076
|
var union = function union(key) {
|
2077
2077
|
for (var _len = arguments.length, objects = new Array(_len > 1 ? _len - 1 : 0), _key3 = 1; _key3 < _len; _key3++) {
|
@@ -2081,7 +2081,6 @@ var union = function union(key) {
|
|
2081
2081
|
};
|
2082
2082
|
|
2083
2083
|
var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
2084
|
-
_inherits(RichTextSchema, _Schema);
|
2085
2084
|
function RichTextSchema(options) {
|
2086
2085
|
var _this;
|
2087
2086
|
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
@@ -2091,7 +2090,8 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
2091
2090
|
_this.opt = opt;
|
2092
2091
|
return _this;
|
2093
2092
|
}
|
2094
|
-
|
2093
|
+
_inherits(RichTextSchema, _Schema);
|
2094
|
+
return _createClass(RichTextSchema, [{
|
2095
2095
|
key: "validate",
|
2096
2096
|
value: function validate(path, src) {
|
2097
2097
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
@@ -2259,14 +2259,12 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
2259
2259
|
};
|
2260
2260
|
}
|
2261
2261
|
}]);
|
2262
|
-
return RichTextSchema;
|
2263
2262
|
}(Schema);
|
2264
2263
|
var richtext$1 = function richtext(options) {
|
2265
2264
|
return new RichTextSchema(options !== null && options !== void 0 ? options : {});
|
2266
2265
|
};
|
2267
2266
|
|
2268
2267
|
var ImageSchema = /*#__PURE__*/function (_Schema) {
|
2269
|
-
_inherits(ImageSchema, _Schema);
|
2270
2268
|
function ImageSchema(options) {
|
2271
2269
|
var _this;
|
2272
2270
|
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
@@ -2276,7 +2274,8 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
|
|
2276
2274
|
_this.opt = opt;
|
2277
2275
|
return _this;
|
2278
2276
|
}
|
2279
|
-
|
2277
|
+
_inherits(ImageSchema, _Schema);
|
2278
|
+
return _createClass(ImageSchema, [{
|
2280
2279
|
key: "validate",
|
2281
2280
|
value: function validate(path, src) {
|
2282
2281
|
if (this.opt && (src === null || src === undefined)) {
|
@@ -2346,7 +2345,7 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
|
|
2346
2345
|
}
|
2347
2346
|
if (src.metadata) {
|
2348
2347
|
return _defineProperty({}, path, [{
|
2349
|
-
message: "Found metadata, but it could not be validated. Image metadata must be an object with the required props: width (positive number), height (positive number) and
|
2348
|
+
message: "Found metadata, but it could not be validated. Image metadata must be an object with the required props: width (positive number), height (positive number) and the mime type.",
|
2350
2349
|
// 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.
|
2351
2350
|
value: src,
|
2352
2351
|
fixes: ["image:replace-metadata"]
|
@@ -2423,14 +2422,12 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
|
|
2423
2422
|
};
|
2424
2423
|
}
|
2425
2424
|
}]);
|
2426
|
-
return ImageSchema;
|
2427
2425
|
}(Schema);
|
2428
2426
|
var image$1 = function image(options) {
|
2429
2427
|
return new ImageSchema(options);
|
2430
2428
|
};
|
2431
2429
|
|
2432
2430
|
var RecordSchema = /*#__PURE__*/function (_Schema) {
|
2433
|
-
_inherits(RecordSchema, _Schema);
|
2434
2431
|
function RecordSchema(item) {
|
2435
2432
|
var _this;
|
2436
2433
|
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
@@ -2440,7 +2437,8 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
2440
2437
|
_this.opt = opt;
|
2441
2438
|
return _this;
|
2442
2439
|
}
|
2443
|
-
|
2440
|
+
_inherits(RecordSchema, _Schema);
|
2441
|
+
return _createClass(RecordSchema, [{
|
2444
2442
|
key: "validate",
|
2445
2443
|
value: function validate(path, src) {
|
2446
2444
|
var _this2 = this;
|
@@ -2530,7 +2528,6 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
2530
2528
|
};
|
2531
2529
|
}
|
2532
2530
|
}]);
|
2533
|
-
return RecordSchema;
|
2534
2531
|
}(Schema);
|
2535
2532
|
var record = function record(schema) {
|
2536
2533
|
return new RecordSchema(schema);
|
@@ -2561,7 +2558,12 @@ function splitModuleFilePathAndModulePath(path) {
|
|
2561
2558
|
}
|
2562
2559
|
return [path.slice(0, pathOfSep), path.slice(pathOfSep + ModuleFilePathSep.length)];
|
2563
2560
|
}
|
2564
|
-
|
2561
|
+
function joinModuleFilePathAndModulePath(moduleFilePath, modulePath) {
|
2562
|
+
if (modulePath === "") {
|
2563
|
+
return moduleFilePath;
|
2564
|
+
}
|
2565
|
+
return "".concat(moduleFilePath).concat(ModuleFilePathSep).concat(modulePath);
|
2566
|
+
}
|
2565
2567
|
function isObjectSchema(schema) {
|
2566
2568
|
return schema instanceof ObjectSchema || _typeof(schema) === "object" && "type" in schema && schema.type === "object";
|
2567
2569
|
}
|
@@ -2605,8 +2607,7 @@ function isImageSchema(schema) {
|
|
2605
2607
|
// }
|
2606
2608
|
|
2607
2609
|
function resolvePath(path, valModule, schema) {
|
2608
|
-
|
2609
|
-
var parts = parsePath(path);
|
2610
|
+
var parts = splitModulePath(path);
|
2610
2611
|
var origParts = _toConsumableArray(parts);
|
2611
2612
|
var resolvedSchema = schema;
|
2612
2613
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
@@ -2623,10 +2624,6 @@ function resolvePath(path, valModule, schema) {
|
|
2623
2624
|
if (_typeof(resolvedSource) !== "object" && !Array.isArray(resolvedSource)) {
|
2624
2625
|
throw Error("Schema type error: expected source to be type of array, but got ".concat(_typeof(resolvedSource)));
|
2625
2626
|
}
|
2626
|
-
if (resolvedSource[part] === undefined) {
|
2627
|
-
var _resolvedSource;
|
2628
|
-
throw Error("Invalid path: array source (length: ".concat((_resolvedSource = resolvedSource) === null || _resolvedSource === void 0 ? void 0 : _resolvedSource.length, ") did not have index ").concat(part, " from path: ").concat(path));
|
2629
|
-
}
|
2630
2627
|
resolvedSource = resolvedSource[part];
|
2631
2628
|
resolvedSchema = resolvedSchema.item;
|
2632
2629
|
} else if (isRecordSchema(resolvedSchema)) {
|
@@ -2645,10 +2642,10 @@ function resolvePath(path, valModule, schema) {
|
|
2645
2642
|
if (_typeof(resolvedSource) !== "object") {
|
2646
2643
|
throw Error("Schema type error: expected source to be type of object, but got ".concat(_typeof(resolvedSource)));
|
2647
2644
|
}
|
2648
|
-
if (
|
2645
|
+
if (resolvedSource !== null && resolvedSource[part] === undefined) {
|
2649
2646
|
throw Error("Invalid path: object source did not have key ".concat(part, " from path: ").concat(path));
|
2650
2647
|
}
|
2651
|
-
resolvedSource = resolvedSource[part];
|
2648
|
+
resolvedSource = resolvedSource === null ? resolvedSource : resolvedSource[part];
|
2652
2649
|
resolvedSchema = resolvedSchema.items[part];
|
2653
2650
|
// } else if (isI18nSchema(resolvedSchema)) {
|
2654
2651
|
// if (!resolvedSchema.locales.includes(part)) {
|
@@ -2748,7 +2745,11 @@ function resolvePath(path, valModule, schema) {
|
|
2748
2745
|
source: resolvedSource
|
2749
2746
|
};
|
2750
2747
|
}
|
2751
|
-
function
|
2748
|
+
function splitModuleFilePath(input) {
|
2749
|
+
var parts = input.split("/").slice(1);
|
2750
|
+
return parts;
|
2751
|
+
}
|
2752
|
+
function splitModulePath(input) {
|
2752
2753
|
var result = [];
|
2753
2754
|
var i = 0;
|
2754
2755
|
while (i < input.length) {
|
@@ -2784,9 +2785,32 @@ function parsePath(input) {
|
|
2784
2785
|
}
|
2785
2786
|
return result;
|
2786
2787
|
}
|
2788
|
+
function splitJoinedSourcePaths(input) {
|
2789
|
+
// TODO: This is a very simple implementation that does not handle escaped commas
|
2790
|
+
return input.split(",");
|
2791
|
+
}
|
2792
|
+
function parentOfSourcePath(sourcePath) {
|
2793
|
+
var _splitModuleFilePathA = splitModuleFilePathAndModulePath(sourcePath),
|
2794
|
+
_splitModuleFilePathA2 = _slicedToArray(_splitModuleFilePathA, 2),
|
2795
|
+
moduleFilePath = _splitModuleFilePathA2[0],
|
2796
|
+
modulePath = _splitModuleFilePathA2[1];
|
2797
|
+
var modulePathParts = splitModulePath(modulePath).slice(0, -1);
|
2798
|
+
if (modulePathParts.length > 0) {
|
2799
|
+
return joinModuleFilePathAndModulePath(moduleFilePath, patchPathToModulePath(modulePathParts));
|
2800
|
+
}
|
2801
|
+
return moduleFilePath;
|
2802
|
+
}
|
2803
|
+
function patchPathToModulePath(patchPath) {
|
2804
|
+
return patchPath.map(function (segment) {
|
2805
|
+
// TODO: I am worried that something is lost here: what if the segment is a string that happens to be a parsable as a number? We could make those keys illegal?
|
2806
|
+
if (Number.isInteger(Number(segment))) {
|
2807
|
+
return segment;
|
2808
|
+
}
|
2809
|
+
return JSON.stringify(segment);
|
2810
|
+
}).join(".");
|
2811
|
+
}
|
2787
2812
|
|
2788
2813
|
var NumberSchema = /*#__PURE__*/function (_Schema) {
|
2789
|
-
_inherits(NumberSchema, _Schema);
|
2790
2814
|
function NumberSchema(options) {
|
2791
2815
|
var _this;
|
2792
2816
|
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
@@ -2796,7 +2820,8 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
2796
2820
|
_this.opt = opt;
|
2797
2821
|
return _this;
|
2798
2822
|
}
|
2799
|
-
|
2823
|
+
_inherits(NumberSchema, _Schema);
|
2824
|
+
return _createClass(NumberSchema, [{
|
2800
2825
|
key: "validate",
|
2801
2826
|
value: function validate(path, src) {
|
2802
2827
|
if (this.opt && (src === null || src === undefined)) {
|
@@ -2857,14 +2882,12 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
2857
2882
|
};
|
2858
2883
|
}
|
2859
2884
|
}]);
|
2860
|
-
return NumberSchema;
|
2861
2885
|
}(Schema);
|
2862
2886
|
var number = function number(options) {
|
2863
2887
|
return new NumberSchema(options);
|
2864
2888
|
};
|
2865
2889
|
|
2866
2890
|
var StringSchema = /*#__PURE__*/function (_Schema) {
|
2867
|
-
_inherits(StringSchema, _Schema);
|
2868
2891
|
function StringSchema(options) {
|
2869
2892
|
var _this;
|
2870
2893
|
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
@@ -2876,7 +2899,8 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
|
|
2876
2899
|
_this.isRaw = isRaw;
|
2877
2900
|
return _this;
|
2878
2901
|
}
|
2879
|
-
|
2902
|
+
_inherits(StringSchema, _Schema);
|
2903
|
+
return _createClass(StringSchema, [{
|
2880
2904
|
key: "min",
|
2881
2905
|
value: function min(minLength) {
|
2882
2906
|
return new StringSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
@@ -2986,14 +3010,12 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
|
|
2986
3010
|
};
|
2987
3011
|
}
|
2988
3012
|
}]);
|
2989
|
-
return StringSchema;
|
2990
3013
|
}(Schema);
|
2991
3014
|
var string = function string(options) {
|
2992
3015
|
return new StringSchema(options);
|
2993
3016
|
};
|
2994
3017
|
|
2995
3018
|
var BooleanSchema = /*#__PURE__*/function (_Schema) {
|
2996
|
-
_inherits(BooleanSchema, _Schema);
|
2997
3019
|
function BooleanSchema() {
|
2998
3020
|
var _this;
|
2999
3021
|
var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
@@ -3002,7 +3024,8 @@ var BooleanSchema = /*#__PURE__*/function (_Schema) {
|
|
3002
3024
|
_this.opt = opt;
|
3003
3025
|
return _this;
|
3004
3026
|
}
|
3005
|
-
|
3027
|
+
_inherits(BooleanSchema, _Schema);
|
3028
|
+
return _createClass(BooleanSchema, [{
|
3006
3029
|
key: "validate",
|
3007
3030
|
value: function validate(path, src) {
|
3008
3031
|
if (this.opt && (src === null || src === undefined)) {
|
@@ -3062,14 +3085,12 @@ var BooleanSchema = /*#__PURE__*/function (_Schema) {
|
|
3062
3085
|
};
|
3063
3086
|
}
|
3064
3087
|
}]);
|
3065
|
-
return BooleanSchema;
|
3066
3088
|
}(Schema);
|
3067
3089
|
var _boolean = function _boolean() {
|
3068
3090
|
return new BooleanSchema();
|
3069
3091
|
};
|
3070
3092
|
|
3071
3093
|
var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
3072
|
-
_inherits(KeyOfSchema, _Schema);
|
3073
3094
|
function KeyOfSchema(schema, sourcePath) {
|
3074
3095
|
var _this;
|
3075
3096
|
var opt = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
@@ -3080,7 +3101,8 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
|
3080
3101
|
_this.opt = opt;
|
3081
3102
|
return _this;
|
3082
3103
|
}
|
3083
|
-
|
3104
|
+
_inherits(KeyOfSchema, _Schema);
|
3105
|
+
return _createClass(KeyOfSchema, [{
|
3084
3106
|
key: "validate",
|
3085
3107
|
value: function validate(path, src) {
|
3086
3108
|
if (this.opt && (src === null || src === undefined)) {
|
@@ -3092,19 +3114,14 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
|
3092
3114
|
}]);
|
3093
3115
|
}
|
3094
3116
|
var serializedSchema = this.schema;
|
3095
|
-
if (!(serializedSchema.type === "
|
3117
|
+
if (!(serializedSchema.type === "object" || serializedSchema.type === "record")) {
|
3096
3118
|
return _defineProperty({}, path, [{
|
3097
|
-
message: "Schema in keyOf must be an '
|
3119
|
+
message: "Schema in keyOf must be an 'object' or 'record'. Found '".concat(serializedSchema.type, "'")
|
3098
3120
|
}]);
|
3099
3121
|
}
|
3100
3122
|
if (serializedSchema.opt && (src === null || src === undefined)) {
|
3101
3123
|
return false;
|
3102
3124
|
}
|
3103
|
-
if (serializedSchema.type === "array" && typeof src !== "number") {
|
3104
|
-
return _defineProperty({}, path, [{
|
3105
|
-
message: "Type of value in keyof (array) must be 'number'"
|
3106
|
-
}]);
|
3107
|
-
}
|
3108
3125
|
if (serializedSchema.type === "record" && typeof src !== "string") {
|
3109
3126
|
return _defineProperty({}, path, [{
|
3110
3127
|
message: "Type of value in keyof (record) must be 'string'"
|
@@ -3149,7 +3166,7 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
|
3149
3166
|
};
|
3150
3167
|
}
|
3151
3168
|
var serializedSchema = schema;
|
3152
|
-
if (!(serializedSchema.type === "
|
3169
|
+
if (!(serializedSchema.type === "object" || serializedSchema.type === "record")) {
|
3153
3170
|
return {
|
3154
3171
|
success: false,
|
3155
3172
|
errors: _defineProperty({}, path, [{
|
@@ -3158,15 +3175,6 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
|
3158
3175
|
}])
|
3159
3176
|
};
|
3160
3177
|
}
|
3161
|
-
if (serializedSchema.type === "array" && typeof src !== "number") {
|
3162
|
-
return {
|
3163
|
-
success: false,
|
3164
|
-
errors: _defineProperty({}, path, [{
|
3165
|
-
message: "Value of keyOf (array) must be 'number', got '".concat(_typeof(src), "'"),
|
3166
|
-
typeError: true
|
3167
|
-
}])
|
3168
|
-
};
|
3169
|
-
}
|
3170
3178
|
if (serializedSchema.type === "record" && typeof src !== "string") {
|
3171
3179
|
return {
|
3172
3180
|
success: false,
|
@@ -3206,7 +3214,7 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
|
3206
3214
|
value: function serialize() {
|
3207
3215
|
var path = this.sourcePath;
|
3208
3216
|
if (!path) {
|
3209
|
-
throw new Error("Cannot serialize keyOf schema with empty selector. TIP: keyOf must be used with a Val Module.");
|
3217
|
+
throw new Error("Cannot serialize keyOf schema with empty selector. TIP: keyOf must be used with a Val Module of record schema.");
|
3210
3218
|
}
|
3211
3219
|
var serializedSchema = this.schema;
|
3212
3220
|
if (!serializedSchema) {
|
@@ -3214,9 +3222,6 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
|
3214
3222
|
}
|
3215
3223
|
var values;
|
3216
3224
|
switch (serializedSchema.type) {
|
3217
|
-
case "array":
|
3218
|
-
values = "number";
|
3219
|
-
break;
|
3220
3225
|
case "record":
|
3221
3226
|
values = "string";
|
3222
3227
|
break;
|
@@ -3235,7 +3240,6 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
|
3235
3240
|
};
|
3236
3241
|
}
|
3237
3242
|
}]);
|
3238
|
-
return KeyOfSchema;
|
3239
3243
|
}(Schema);
|
3240
3244
|
var keyOf = function keyOf(valModule) {
|
3241
3245
|
var _valModule$GetSchema;
|
@@ -3243,7 +3247,6 @@ var keyOf = function keyOf(valModule) {
|
|
3243
3247
|
};
|
3244
3248
|
|
3245
3249
|
var DateSchema = /*#__PURE__*/function (_Schema) {
|
3246
|
-
_inherits(DateSchema, _Schema);
|
3247
3250
|
function DateSchema(options) {
|
3248
3251
|
var _this;
|
3249
3252
|
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
@@ -3253,7 +3256,8 @@ var DateSchema = /*#__PURE__*/function (_Schema) {
|
|
3253
3256
|
_this.opt = opt;
|
3254
3257
|
return _this;
|
3255
3258
|
}
|
3256
|
-
|
3259
|
+
_inherits(DateSchema, _Schema);
|
3260
|
+
return _createClass(DateSchema, [{
|
3257
3261
|
key: "validate",
|
3258
3262
|
value: function validate(path, src) {
|
3259
3263
|
var _this$options, _this$options2, _this$options3, _this$options4;
|
@@ -3365,7 +3369,6 @@ var DateSchema = /*#__PURE__*/function (_Schema) {
|
|
3365
3369
|
};
|
3366
3370
|
}
|
3367
3371
|
}]);
|
3368
|
-
return DateSchema;
|
3369
3372
|
}(Schema);
|
3370
3373
|
var date = function date(options) {
|
3371
3374
|
return new DateSchema(options);
|
@@ -3689,7 +3692,7 @@ var initVal = function initVal(config) {
|
|
3689
3692
|
c: {
|
3690
3693
|
define: define,
|
3691
3694
|
// remote,
|
3692
|
-
file:
|
3695
|
+
file: initFile(config),
|
3693
3696
|
richtext: richtext,
|
3694
3697
|
rt: {
|
3695
3698
|
image: image,
|
@@ -4056,7 +4059,7 @@ var Hash = /*#__PURE__*/function () {
|
|
4056
4059
|
this._word = new Int32Array(sharedBuffer, sharedOffset, N.allocWords);
|
4057
4060
|
sharedOffset += N.allocBytes;
|
4058
4061
|
}
|
4059
|
-
_createClass(Hash, [{
|
4062
|
+
return _createClass(Hash, [{
|
4060
4063
|
key: "update",
|
4061
4064
|
value: function update(data) {
|
4062
4065
|
// data: string
|
@@ -4273,7 +4276,6 @@ var Hash = /*#__PURE__*/function () {
|
|
4273
4276
|
return _byte.slice(0, 32);
|
4274
4277
|
}
|
4275
4278
|
}]);
|
4276
|
-
return Hash;
|
4277
4279
|
}();
|
4278
4280
|
var W = new Int32Array(N.workWords);
|
4279
4281
|
var sharedBuffer;
|
@@ -5092,6 +5094,7 @@ function deserializeSchema(serialized) {
|
|
5092
5094
|
}
|
5093
5095
|
}
|
5094
5096
|
|
5097
|
+
var ModuleFilePathSep = "?p=";
|
5095
5098
|
var FATAL_ERROR_TYPES = ["no-schema", "no-source", "invalid-id", "no-module", "invalid-patch"];
|
5096
5099
|
var Internal = {
|
5097
5100
|
VERSION: {
|
@@ -5111,6 +5114,7 @@ var Internal = {
|
|
5111
5114
|
getSource: getSource,
|
5112
5115
|
resolvePath: resolvePath,
|
5113
5116
|
splitModuleFilePathAndModulePath: splitModuleFilePathAndModulePath,
|
5117
|
+
joinModuleFilePathAndModulePath: joinModuleFilePathAndModulePath,
|
5114
5118
|
isVal: isVal,
|
5115
5119
|
createValPathOfItem: createValPathOfItem,
|
5116
5120
|
getSHA256Hash: getSHA256Hash,
|
@@ -5133,20 +5137,39 @@ var Internal = {
|
|
5133
5137
|
}).join("/"));
|
5134
5138
|
},
|
5135
5139
|
createPatchPath: function createPatchPath(modulePath) {
|
5136
|
-
return
|
5137
|
-
},
|
5138
|
-
patchPathToModulePath: function patchPathToModulePath(patchPath) {
|
5139
|
-
return patchPath.map(function (segment) {
|
5140
|
-
// TODO: I am worried that something is lost here: what if the segment is a string that happens to be a parsable as a number? We could make those keys illegal?
|
5141
|
-
if (Number.isInteger(Number(segment))) {
|
5142
|
-
return segment;
|
5143
|
-
}
|
5144
|
-
return JSON.stringify(segment);
|
5145
|
-
}).join(".");
|
5140
|
+
return splitModulePath(modulePath);
|
5146
5141
|
},
|
5142
|
+
splitModulePath: splitModulePath,
|
5143
|
+
splitModuleFilePath: splitModuleFilePath,
|
5144
|
+
splitJoinedSourcePaths: splitJoinedSourcePaths,
|
5145
|
+
parentOfSourcePath: parentOfSourcePath,
|
5146
|
+
patchPathToModulePath: patchPathToModulePath,
|
5147
5147
|
VAL_ENABLE_COOKIE_NAME: "val_enable",
|
5148
5148
|
VAL_STATE_COOKIE: "val_state",
|
5149
|
-
VAL_SESSION_COOKIE: "val_session"
|
5149
|
+
VAL_SESSION_COOKIE: "val_session",
|
5150
|
+
createFilename: function createFilename(data, filename, metadata, sha256) {
|
5151
|
+
var _Internal$getMimeType, _Internal$mimeTypeToF;
|
5152
|
+
if (!metadata) {
|
5153
|
+
return filename;
|
5154
|
+
}
|
5155
|
+
if (!data) {
|
5156
|
+
return filename;
|
5157
|
+
}
|
5158
|
+
var shaSuffix = sha256.slice(0, 5);
|
5159
|
+
var mimeType = (_Internal$getMimeType = Internal.getMimeType(data)) !== null && _Internal$getMimeType !== void 0 ? _Internal$getMimeType : "unknown";
|
5160
|
+
var newExt = (_Internal$mimeTypeToF = Internal.mimeTypeToFileExt(mimeType)) !== null && _Internal$mimeTypeToF !== void 0 ? _Internal$mimeTypeToF : "unknown"; // Don't trust the file extension
|
5161
|
+
if (filename) {
|
5162
|
+
var cleanFilename = filename.split(".").slice(0, -1).join(".") || filename; // remove extension if it exists
|
5163
|
+
var maybeShaSuffixPos = cleanFilename.lastIndexOf("_");
|
5164
|
+
var currentShaSuffix = cleanFilename.slice(maybeShaSuffixPos + 1, cleanFilename.length);
|
5165
|
+
if (currentShaSuffix === shaSuffix) {
|
5166
|
+
cleanFilename = cleanFilename.slice(0, maybeShaSuffixPos);
|
5167
|
+
}
|
5168
|
+
var escapedFilename = encodeURIComponent(cleanFilename).replace(/%[0-9A-Fa-f]{2}/g, "").toLowerCase();
|
5169
|
+
return "".concat(escapedFilename, "_").concat(shaSuffix, ".").concat(newExt);
|
5170
|
+
}
|
5171
|
+
return "".concat(sha256, ".").concat(newExt);
|
5172
|
+
}
|
5150
5173
|
};
|
5151
5174
|
function tryJsonParse(str) {
|
5152
5175
|
try {
|
@@ -5156,4 +5179,4 @@ function tryJsonParse(str) {
|
|
5156
5179
|
}
|
5157
5180
|
}
|
5158
5181
|
|
5159
|
-
export { ArraySchema as A, BooleanSchema as B, Call as C, DateSchema as D, Expr as E, FATAL_ERROR_TYPES as F, GenericSelector as G, Internal as I, KeyOfSchema as K, LiteralSchema as L, NilSym as N, ObjectSchema as O, PatchError as P, RT_IMAGE_TAG as R, StringLiteral as S, UnionSchema as U, VAL_EXTENSION as V, _typeof as _, _slicedToArray as a, _createClass as b, _classCallCheck as c, _toConsumableArray as d, StringTemplate as e, Sym as f, evaluate as g, initVal as h, index as i, Schema as j, FILE_REF_PROP as k, FILE_REF_SUBTYPE_TAG as l, modules as m, derefPatch as n, RecordSchema as o, parse as p, StringSchema as q, NumberSchema as r, splitModuleFilePathAndModulePath as s, ImageSchema as t, FileSchema as u, RichTextSchema as v, deserializeSchema as w };
|
5182
|
+
export { ArraySchema as A, BooleanSchema as B, Call as C, DateSchema as D, Expr as E, FATAL_ERROR_TYPES as F, GenericSelector as G, Internal as I, KeyOfSchema as K, LiteralSchema as L, ModuleFilePathSep as M, NilSym as N, ObjectSchema as O, PatchError as P, RT_IMAGE_TAG as R, StringLiteral as S, UnionSchema as U, VAL_EXTENSION as V, _typeof as _, _slicedToArray as a, _createClass as b, _classCallCheck as c, _toConsumableArray as d, StringTemplate as e, Sym as f, evaluate as g, initVal as h, index as i, Schema as j, FILE_REF_PROP as k, FILE_REF_SUBTYPE_TAG as l, modules as m, derefPatch as n, RecordSchema as o, parse as p, StringSchema as q, NumberSchema as r, splitModuleFilePathAndModulePath as s, ImageSchema as t, FileSchema as u, RichTextSchema as v, deserializeSchema as w };
|