@valbuild/core 0.63.6 → 0.65.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.
- 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 +49 -94
- package/dist/declarations/src/initSchema.d.ts +19 -49
- package/dist/declarations/src/initVal.d.ts +8 -3
- package/dist/declarations/src/mimeType/all.d.ts +4 -0
- package/dist/declarations/src/mimeType/convertMimeType.d.ts +3 -0
- package/dist/declarations/src/mimeType/index.d.ts +2 -0
- package/dist/declarations/src/module.d.ts +6 -2
- package/dist/declarations/src/schema/array.d.ts +5 -5
- package/dist/declarations/src/schema/boolean.d.ts +2 -2
- package/dist/declarations/src/schema/date.d.ts +5 -5
- package/dist/declarations/src/schema/file.d.ts +5 -4
- package/dist/declarations/src/schema/image.d.ts +4 -4
- package/dist/declarations/src/schema/index.d.ts +44 -3
- package/dist/declarations/src/schema/keyOf.d.ts +9 -9
- package/dist/declarations/src/schema/literal.d.ts +3 -3
- package/dist/declarations/src/schema/number.d.ts +3 -3
- package/dist/declarations/src/schema/object.d.ts +5 -5
- package/dist/declarations/src/schema/record.d.ts +5 -5
- package/dist/declarations/src/schema/richtext.d.ts +6 -25
- package/dist/declarations/src/schema/string.d.ts +2 -2
- package/dist/declarations/src/schema/union.d.ts +18 -19
- package/dist/declarations/src/schema/validation/ValidationError.d.ts +2 -1
- package/dist/declarations/src/selector/SelectorProxy.d.ts +1 -0
- package/dist/declarations/src/source/file.d.ts +7 -4
- package/dist/declarations/src/source/richtext.d.ts +7 -0
- package/dist/declarations/src/val/index.d.ts +1 -1
- package/dist/{index-041f75bd.cjs.prod.js → index-48930c58.cjs.dev.js} +1842 -1050
- package/dist/{index-fccba617.esm.js → index-65ec1d74.esm.js} +1840 -1049
- package/dist/{index-c67ed8f9.cjs.dev.js → index-f1a23e6c.cjs.prod.js} +1842 -1050
- package/dist/{result-a8316efa.esm.js → result-168dfc1d.esm.js} +42 -46
- package/dist/{result-26f67b40.cjs.prod.js → result-787e35f6.cjs.prod.js} +41 -45
- package/dist/{result-48320acd.cjs.dev.js → result-bb1f436e.cjs.dev.js} +41 -45
- package/dist/valbuild-core.cjs.d.ts +2 -2
- package/dist/valbuild-core.cjs.dev.js +4 -3
- package/dist/valbuild-core.cjs.prod.js +4 -3
- 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/declarations/src/ValApi.d.ts +0 -54
- 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 (
|
118
|
+
function _classCallCheck(a, n) {
|
119
|
+
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
86
120
|
}
|
87
121
|
|
88
|
-
function
|
89
|
-
var t =
|
90
|
-
|
91
|
-
|
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();
|
122
|
-
}
|
123
|
-
|
124
|
-
function _classCallCheck(instance, Constructor) {
|
125
|
-
if (!(instance instanceof Constructor)) {
|
126
|
-
throw new TypeError("Cannot call a class as a function");
|
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)) {
|
@@ -448,9 +452,53 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
|
|
448
452
|
value: src
|
449
453
|
}]);
|
450
454
|
}
|
455
|
+
var _ref4 = this.options || {},
|
456
|
+
accept = _ref4.accept;
|
457
|
+
var _ref5 = src.metadata || {},
|
458
|
+
mimeType = _ref5.mimeType;
|
459
|
+
if (accept && mimeType && !mimeType.includes("/")) {
|
460
|
+
return _defineProperty({}, path, [{
|
461
|
+
message: "Invalid mime type format. Got: ".concat(mimeType),
|
462
|
+
value: src
|
463
|
+
}]);
|
464
|
+
}
|
465
|
+
if (accept && mimeType && mimeType.includes("/")) {
|
466
|
+
var acceptedTypes = accept.split(",").map(function (type) {
|
467
|
+
return type.trim();
|
468
|
+
});
|
469
|
+
var isValidMimeType = acceptedTypes.some(function (acceptedType) {
|
470
|
+
if (acceptedType === "*/*") {
|
471
|
+
return true;
|
472
|
+
}
|
473
|
+
if (acceptedType.endsWith("/*")) {
|
474
|
+
var baseType = acceptedType.slice(0, -2);
|
475
|
+
return mimeType.startsWith(baseType);
|
476
|
+
}
|
477
|
+
return acceptedType === mimeType;
|
478
|
+
});
|
479
|
+
if (!isValidMimeType) {
|
480
|
+
return _defineProperty({}, path, [{
|
481
|
+
message: "Mime type mismatch. Found '".concat(mimeType, "' but schema accepts '").concat(accept, "'"),
|
482
|
+
value: src
|
483
|
+
}]);
|
484
|
+
}
|
485
|
+
}
|
486
|
+
var fileMimeType = Internal.filenameToMimeType(src[FILE_REF_PROP]);
|
487
|
+
if (!fileMimeType) {
|
488
|
+
return _defineProperty({}, path, [{
|
489
|
+
message: "Could not determine mime type from file extension. Got: ".concat(src[FILE_REF_PROP]),
|
490
|
+
value: src
|
491
|
+
}]);
|
492
|
+
}
|
493
|
+
if (fileMimeType !== mimeType) {
|
494
|
+
return _defineProperty({}, path, [{
|
495
|
+
message: "Mime type and file extension not matching. Mime type is '".concat(mimeType, "' but file extension is '").concat(fileMimeType, "'"),
|
496
|
+
value: src
|
497
|
+
}]);
|
498
|
+
}
|
451
499
|
if (src.metadata) {
|
452
500
|
return _defineProperty({}, path, [{
|
453
|
-
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.",
|
454
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.
|
455
503
|
value: src,
|
456
504
|
fixes: ["file:check-metadata"]
|
@@ -464,11 +512,53 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
|
|
464
512
|
}
|
465
513
|
}, {
|
466
514
|
key: "assert",
|
467
|
-
value: function assert(src) {
|
468
|
-
if (this.opt &&
|
469
|
-
return
|
515
|
+
value: function assert(path, src) {
|
516
|
+
if (this.opt && src === null) {
|
517
|
+
return {
|
518
|
+
success: true,
|
519
|
+
data: src
|
520
|
+
};
|
521
|
+
}
|
522
|
+
if (src === null) {
|
523
|
+
return {
|
524
|
+
success: false,
|
525
|
+
errors: _defineProperty({}, path, [{
|
526
|
+
message: "Expected 'object', got 'null'",
|
527
|
+
typeError: true
|
528
|
+
}])
|
529
|
+
};
|
470
530
|
}
|
471
|
-
|
531
|
+
if (_typeof(src) !== "object") {
|
532
|
+
return {
|
533
|
+
success: false,
|
534
|
+
errors: _defineProperty({}, path, [{
|
535
|
+
message: "Expected object, got '".concat(_typeof(src), "'"),
|
536
|
+
typeError: true
|
537
|
+
}])
|
538
|
+
};
|
539
|
+
}
|
540
|
+
if (!(FILE_REF_PROP in src)) {
|
541
|
+
return {
|
542
|
+
success: false,
|
543
|
+
errors: _defineProperty({}, path, [{
|
544
|
+
message: "Value of this schema must use: 'c.file' (error type: missing_ref_prop)",
|
545
|
+
typeError: true
|
546
|
+
}])
|
547
|
+
};
|
548
|
+
}
|
549
|
+
if (!(VAL_EXTENSION in src && src[VAL_EXTENSION] === "file")) {
|
550
|
+
return {
|
551
|
+
success: false,
|
552
|
+
errors: _defineProperty({}, path, [{
|
553
|
+
message: "Value of this schema must use: 'c.file' (error type: missing_file_extension)",
|
554
|
+
typeError: true
|
555
|
+
}])
|
556
|
+
};
|
557
|
+
}
|
558
|
+
return {
|
559
|
+
success: true,
|
560
|
+
data: src
|
561
|
+
};
|
472
562
|
}
|
473
563
|
}, {
|
474
564
|
key: "nullable",
|
@@ -485,25 +575,26 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
|
|
485
575
|
};
|
486
576
|
}
|
487
577
|
}]);
|
488
|
-
return FileSchema;
|
489
578
|
}(Schema);
|
490
579
|
var file = function file(options) {
|
491
580
|
return new FileSchema(options);
|
492
581
|
};
|
493
582
|
function convertFileSource(src) {
|
494
|
-
var _src$metadata4, _src$metadata5, _src$metadata6;
|
495
583
|
// TODO: /public should be configurable
|
496
584
|
if (!src[FILE_REF_PROP].startsWith("/public")) {
|
497
|
-
var _src$metadata, _src$metadata2, _src$metadata3;
|
498
585
|
return {
|
499
|
-
url: src[FILE_REF_PROP] + (
|
500
|
-
|
501
|
-
|
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"]),
|
502
593
|
metadata: src.metadata
|
503
594
|
};
|
504
595
|
}
|
505
596
|
return {
|
506
|
-
url: src[FILE_REF_PROP].slice("/public".length)
|
597
|
+
url: src[FILE_REF_PROP].slice("/public".length),
|
507
598
|
metadata: src.metadata
|
508
599
|
};
|
509
600
|
}
|
@@ -613,7 +704,7 @@ function newSelectorProxy$1(source, path, moduleSchema) {
|
|
613
704
|
return newSelectorProxy$1(a, createValPathOfItem(path, i), moduleSchema === null || moduleSchema === void 0 ? void 0 : moduleSchema.item);
|
614
705
|
}).filter(function (a) {
|
615
706
|
if (f && f instanceof Schema) {
|
616
|
-
return f.assert(unValify$1(a));
|
707
|
+
return f.assert(path || "", unValify$1(a)).success;
|
617
708
|
} else {
|
618
709
|
return unValify$1(f(a));
|
619
710
|
}
|
@@ -680,6 +771,20 @@ function createValPathOfItem(arrayPath, prop) {
|
|
680
771
|
return "".concat(arrayPath).concat(Internal.ModuleFilePathSep).concat(JSON.stringify(prop));
|
681
772
|
}
|
682
773
|
|
774
|
+
// TODO: replace createValPathOfItem everywhere with this newer implementation (that does not return undefined but throws)
|
775
|
+
function unsafeCreateSourcePath(path, itemKey) {
|
776
|
+
if (_typeof(itemKey) === "symbol") {
|
777
|
+
throw Error("Cannot create val path of array item with symbol prop: ".concat(itemKey.toString()));
|
778
|
+
}
|
779
|
+
if (!path) {
|
780
|
+
throw Error("Cannot create val path of array item of empty or missing path: ".concat(path, ". Item: ").concat(itemKey));
|
781
|
+
}
|
782
|
+
if (path.includes(Internal.ModuleFilePathSep)) {
|
783
|
+
return "".concat(path, ".").concat(JSON.stringify(itemKey));
|
784
|
+
}
|
785
|
+
return "".concat(path).concat(Internal.ModuleFilePathSep).concat(JSON.stringify(itemKey));
|
786
|
+
}
|
787
|
+
|
683
788
|
// TODO: could we do .val on the objects instead?
|
684
789
|
function unValify$1(valueOrSelector) {
|
685
790
|
if (_typeof(valueOrSelector) === "object" && (GetSource in valueOrSelector || Path$1 in valueOrSelector)) {
|
@@ -690,7 +795,6 @@ function unValify$1(valueOrSelector) {
|
|
690
795
|
}
|
691
796
|
|
692
797
|
var ObjectSchema = /*#__PURE__*/function (_Schema) {
|
693
|
-
_inherits(ObjectSchema, _Schema);
|
694
798
|
function ObjectSchema(items) {
|
695
799
|
var _this;
|
696
800
|
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
@@ -700,7 +804,8 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
|
|
700
804
|
_this.opt = opt;
|
701
805
|
return _this;
|
702
806
|
}
|
703
|
-
|
807
|
+
_inherits(ObjectSchema, _Schema);
|
808
|
+
return _createClass(ObjectSchema, [{
|
704
809
|
key: "validate",
|
705
810
|
value: function validate(path, src) {
|
706
811
|
var _this2 = this;
|
@@ -710,6 +815,11 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
|
|
710
815
|
if (this.opt && (src === null || src === undefined)) {
|
711
816
|
return false;
|
712
817
|
}
|
818
|
+
if (src === null) {
|
819
|
+
return _defineProperty({}, path, [{
|
820
|
+
message: "Expected 'object', got 'null'"
|
821
|
+
}]);
|
822
|
+
}
|
713
823
|
if (_typeof(src) !== "object") {
|
714
824
|
return _defineProperty({}, path, [{
|
715
825
|
message: "Expected 'object', got '".concat(_typeof(src), "'")
|
@@ -719,10 +829,10 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
|
|
719
829
|
message: "Expected 'object', got 'array'"
|
720
830
|
}]);
|
721
831
|
}
|
722
|
-
Object.entries(this.items).forEach(function (
|
723
|
-
var
|
724
|
-
key =
|
725
|
-
schema =
|
832
|
+
Object.entries(this.items).forEach(function (_ref4) {
|
833
|
+
var _ref5 = _slicedToArray(_ref4, 2),
|
834
|
+
key = _ref5[0],
|
835
|
+
schema = _ref5[1];
|
726
836
|
var subPath = createValPathOfItem(path, key);
|
727
837
|
if (!subPath) {
|
728
838
|
error = _this2.appendValidationError(error, path, "Internal error: could not create path at ".concat(!path && typeof path === "string" ? "<empty string>" : path, " at key ").concat(key),
|
@@ -741,22 +851,66 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
|
|
741
851
|
}
|
742
852
|
}, {
|
743
853
|
key: "assert",
|
744
|
-
value: function assert(src) {
|
745
|
-
if (this.opt &&
|
746
|
-
return
|
854
|
+
value: function assert(path, src) {
|
855
|
+
if (this.opt && src === null) {
|
856
|
+
return {
|
857
|
+
success: true,
|
858
|
+
data: src
|
859
|
+
};
|
747
860
|
}
|
748
|
-
if (
|
749
|
-
return
|
861
|
+
if (src === null) {
|
862
|
+
return {
|
863
|
+
success: false,
|
864
|
+
errors: _defineProperty({}, path, [{
|
865
|
+
message: "Expected 'object', got 'null'",
|
866
|
+
typeError: true
|
867
|
+
}])
|
868
|
+
};
|
750
869
|
}
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
870
|
+
if (_typeof(src) !== "object") {
|
871
|
+
return {
|
872
|
+
success: false,
|
873
|
+
errors: _defineProperty({}, path, [{
|
874
|
+
message: "Expected 'object', got '".concat(_typeof(src), "'"),
|
875
|
+
typeError: true
|
876
|
+
}])
|
877
|
+
};
|
878
|
+
} else if (Array.isArray(src)) {
|
879
|
+
return {
|
880
|
+
success: false,
|
881
|
+
errors: _defineProperty({}, path, [{
|
882
|
+
message: "Expected 'object', got 'array'",
|
883
|
+
typeError: true
|
884
|
+
}])
|
885
|
+
};
|
886
|
+
}
|
887
|
+
var errorsAtPath = [];
|
888
|
+
for (var _i = 0, _Object$keys = Object.keys(this.items); _i < _Object$keys.length; _i++) {
|
889
|
+
var _key = _Object$keys[_i];
|
890
|
+
var subPath = createValPathOfItem(path, _key);
|
891
|
+
if (!subPath) {
|
892
|
+
errorsAtPath.push({
|
893
|
+
message: "Internal error: could not create path at ".concat(!path && typeof path === "string" ? "<empty string>" : path, " at key ").concat(_key),
|
894
|
+
// Should! never happen
|
895
|
+
internalError: true
|
896
|
+
});
|
897
|
+
} else if (!(_key in src)) {
|
898
|
+
errorsAtPath.push({
|
899
|
+
message: "Expected key '".concat(_key, "' not found in object"),
|
900
|
+
typeError: true
|
901
|
+
});
|
757
902
|
}
|
758
903
|
}
|
759
|
-
|
904
|
+
if (errorsAtPath.length > 0) {
|
905
|
+
return {
|
906
|
+
success: false,
|
907
|
+
errors: _defineProperty({}, path, errorsAtPath)
|
908
|
+
};
|
909
|
+
}
|
910
|
+
return {
|
911
|
+
success: true,
|
912
|
+
data: src
|
913
|
+
};
|
760
914
|
}
|
761
915
|
}, {
|
762
916
|
key: "nullable",
|
@@ -768,17 +922,16 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
|
|
768
922
|
value: function serialize() {
|
769
923
|
return {
|
770
924
|
type: "object",
|
771
|
-
items: Object.fromEntries(Object.entries(this.items).map(function (
|
772
|
-
var
|
773
|
-
key =
|
774
|
-
schema =
|
925
|
+
items: Object.fromEntries(Object.entries(this.items).map(function (_ref6) {
|
926
|
+
var _ref7 = _slicedToArray(_ref6, 2),
|
927
|
+
key = _ref7[0],
|
928
|
+
schema = _ref7[1];
|
775
929
|
return [key, schema.serialize()];
|
776
930
|
})),
|
777
931
|
opt: this.opt
|
778
932
|
};
|
779
933
|
}
|
780
934
|
}]);
|
781
|
-
return ObjectSchema;
|
782
935
|
}(Schema);
|
783
936
|
var object = function object(schema) {
|
784
937
|
return new ObjectSchema(schema);
|
@@ -811,7 +964,7 @@ function tokenize(input) {
|
|
811
964
|
});
|
812
965
|
cursor++;
|
813
966
|
} else if (_char === "'" || _char === "}") {
|
814
|
-
var
|
967
|
+
var start = cursor;
|
815
968
|
var value = "";
|
816
969
|
var unescapedValue = "";
|
817
970
|
var escaped = false;
|
@@ -854,7 +1007,7 @@ function tokenize(input) {
|
|
854
1007
|
if (value) {
|
855
1008
|
tokens.push(_objectSpread2({
|
856
1009
|
type: "string",
|
857
|
-
span: [
|
1010
|
+
span: [start + 1, cursor - cursorOffset],
|
858
1011
|
value: value
|
859
1012
|
}, unescapedValue !== value && {
|
860
1013
|
unescapedValue: unescapedValue
|
@@ -872,17 +1025,17 @@ function tokenize(input) {
|
|
872
1025
|
});
|
873
1026
|
}
|
874
1027
|
} else if (WHITE_SPACE.includes(_char)) {
|
875
|
-
var
|
1028
|
+
var _start = cursor;
|
876
1029
|
while (WHITE_SPACE.includes(input[cursor]) && cursor < input.length) {
|
877
1030
|
cursor++;
|
878
1031
|
}
|
879
1032
|
tokens.push({
|
880
1033
|
type: "ws",
|
881
|
-
span: [
|
1034
|
+
span: [_start, cursor - 1]
|
882
1035
|
});
|
883
1036
|
} else {
|
884
1037
|
var _value = "";
|
885
|
-
var
|
1038
|
+
var _start2 = cursor;
|
886
1039
|
do {
|
887
1040
|
_char = input[cursor];
|
888
1041
|
peek = input[cursor + 1];
|
@@ -891,7 +1044,7 @@ function tokenize(input) {
|
|
891
1044
|
} while (!WHITE_SPACE.includes(peek) && peek !== ")" && peek !== "'" && cursor < input.length);
|
892
1045
|
tokens.push({
|
893
1046
|
type: "token",
|
894
|
-
span: [
|
1047
|
+
span: [_start2, cursor - 1],
|
895
1048
|
value: _value
|
896
1049
|
});
|
897
1050
|
}
|
@@ -1034,7 +1187,7 @@ function parseTokens$1(inputTokens) {
|
|
1034
1187
|
}
|
1035
1188
|
return res;
|
1036
1189
|
}
|
1037
|
-
function parse
|
1190
|
+
function parse(input) {
|
1038
1191
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
1039
1192
|
var _tokenize = tokenize(input),
|
1040
1193
|
_tokenize2 = _slicedToArray(_tokenize, 2),
|
@@ -1160,7 +1313,7 @@ function newSelectorProxy(source, path, moduleSchema) {
|
|
1160
1313
|
return newSelectorProxy(a, createValPathOfItem(path, i), moduleSchema === null || moduleSchema === void 0 ? void 0 : moduleSchema.item);
|
1161
1314
|
}).filter(function (a) {
|
1162
1315
|
if (f && f instanceof Schema) {
|
1163
|
-
return f.assert(unValify(a));
|
1316
|
+
return f.assert(path || "", unValify(a)).success;
|
1164
1317
|
} else {
|
1165
1318
|
return unValify(f(a));
|
1166
1319
|
}
|
@@ -1230,13 +1383,12 @@ var EvalError = /*#__PURE__*/function () {
|
|
1230
1383
|
this.message = message;
|
1231
1384
|
this.expr = expr;
|
1232
1385
|
}
|
1233
|
-
_createClass(EvalError, [{
|
1386
|
+
return _createClass(EvalError, [{
|
1234
1387
|
key: "toString",
|
1235
1388
|
value: function toString() {
|
1236
1389
|
return "".concat(this.message, " in: ").concat(this.expr.transpile());
|
1237
1390
|
}
|
1238
1391
|
}]);
|
1239
|
-
return EvalError;
|
1240
1392
|
}();
|
1241
1393
|
var MAX_STACK_SIZE = 100; // an arbitrary semi-large number
|
1242
1394
|
function evaluateSync(expr, getSource, stack) {
|
@@ -1255,8 +1407,8 @@ function evaluateSync(expr, getSource, stack) {
|
|
1255
1407
|
throw new EvalError("cannot call 'val' as anonymous function", expr);
|
1256
1408
|
}
|
1257
1409
|
if (expr.children[1] instanceof StringLiteral) {
|
1258
|
-
var
|
1259
|
-
return newSelectorProxy(getSource(
|
1410
|
+
var path = expr.children[1].value;
|
1411
|
+
return newSelectorProxy(getSource(path), path);
|
1260
1412
|
} else {
|
1261
1413
|
throw new EvalError("argument of 'val' must be a string literal", expr);
|
1262
1414
|
}
|
@@ -1323,8 +1475,8 @@ function evaluateSync(expr, getSource, stack) {
|
|
1323
1475
|
if (expr.children[0] instanceof Sym) {
|
1324
1476
|
if (expr.children[0].value === "val") {
|
1325
1477
|
if (expr.children[1] instanceof StringLiteral) {
|
1326
|
-
var
|
1327
|
-
return newSelectorProxy(getSource(
|
1478
|
+
var _path = expr.children[1].value;
|
1479
|
+
return newSelectorProxy(getSource(_path), _path);
|
1328
1480
|
} else {
|
1329
1481
|
throw new EvalError("argument of 'val' must be a string literal", expr);
|
1330
1482
|
}
|
@@ -1403,7 +1555,7 @@ function evaluate(expr, source, stack) {
|
|
1403
1555
|
|
1404
1556
|
var index = /*#__PURE__*/Object.freeze({
|
1405
1557
|
__proto__: null,
|
1406
|
-
parse: parse
|
1558
|
+
parse: parse,
|
1407
1559
|
Call: Call,
|
1408
1560
|
Expr: Expr,
|
1409
1561
|
NilSym: NilSym,
|
@@ -1414,7 +1566,6 @@ var index = /*#__PURE__*/Object.freeze({
|
|
1414
1566
|
});
|
1415
1567
|
|
1416
1568
|
var ArraySchema = /*#__PURE__*/function (_Schema) {
|
1417
|
-
_inherits(ArraySchema, _Schema);
|
1418
1569
|
function ArraySchema(item) {
|
1419
1570
|
var _this;
|
1420
1571
|
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
@@ -1424,60 +1575,73 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
|
|
1424
1575
|
_this.opt = opt;
|
1425
1576
|
return _this;
|
1426
1577
|
}
|
1427
|
-
|
1578
|
+
_inherits(ArraySchema, _Schema);
|
1579
|
+
return _createClass(ArraySchema, [{
|
1428
1580
|
key: "validate",
|
1429
1581
|
value: function validate(path, src) {
|
1430
|
-
var
|
1431
|
-
|
1432
|
-
|
1433
|
-
return false;
|
1582
|
+
var assertRes = this.assert(path, src);
|
1583
|
+
if (!assertRes.success) {
|
1584
|
+
return assertRes.errors;
|
1434
1585
|
}
|
1435
|
-
if (
|
1436
|
-
return
|
1437
|
-
message: "Expected 'array', got '".concat(_typeof(src), "'")
|
1438
|
-
}]);
|
1586
|
+
if (assertRes.data === null) {
|
1587
|
+
return false;
|
1439
1588
|
}
|
1440
|
-
|
1441
|
-
|
1442
|
-
|
1443
|
-
|
1444
|
-
|
1445
|
-
|
1446
|
-
|
1447
|
-
|
1448
|
-
|
1449
|
-
|
1450
|
-
} else if (subError) {
|
1451
|
-
error = subError;
|
1452
|
-
}
|
1589
|
+
var error = {};
|
1590
|
+
for (var _i = 0, _Object$entries = Object.entries(assertRes.data); _i < _Object$entries.length; _i++) {
|
1591
|
+
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
1592
|
+
idx = _Object$entries$_i[0],
|
1593
|
+
i = _Object$entries$_i[1];
|
1594
|
+
var subPath = unsafeCreateSourcePath(path, Number(idx));
|
1595
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
1596
|
+
var subError = this.item.validate(subPath, i);
|
1597
|
+
if (subError) {
|
1598
|
+
error = _objectSpread2(_objectSpread2({}, subError), error);
|
1453
1599
|
}
|
1454
|
-
}
|
1600
|
+
}
|
1601
|
+
if (Object.keys(error).length === 0) {
|
1602
|
+
return false;
|
1603
|
+
}
|
1455
1604
|
return error;
|
1456
1605
|
}
|
1457
1606
|
}, {
|
1458
1607
|
key: "assert",
|
1459
|
-
value: function assert(src) {
|
1460
|
-
if (
|
1461
|
-
return
|
1608
|
+
value: function assert(path, src) {
|
1609
|
+
if (src === null && this.opt) {
|
1610
|
+
return {
|
1611
|
+
success: true,
|
1612
|
+
data: src
|
1613
|
+
};
|
1462
1614
|
}
|
1463
|
-
if (
|
1464
|
-
return
|
1615
|
+
if (src === null) {
|
1616
|
+
return {
|
1617
|
+
success: false,
|
1618
|
+
errors: _defineProperty({}, path, [{
|
1619
|
+
message: "Expected 'array', got 'null'",
|
1620
|
+
typeError: true
|
1621
|
+
}])
|
1622
|
+
};
|
1465
1623
|
}
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
|
1472
|
-
|
1473
|
-
|
1474
|
-
|
1475
|
-
|
1476
|
-
|
1477
|
-
|
1478
|
-
|
1624
|
+
if (_typeof(src) !== "object") {
|
1625
|
+
return {
|
1626
|
+
success: false,
|
1627
|
+
errors: _defineProperty({}, path, [{
|
1628
|
+
message: "Expected 'object', got '".concat(_typeof(src), "'"),
|
1629
|
+
typeError: true
|
1630
|
+
}])
|
1631
|
+
};
|
1632
|
+
} else if (!Array.isArray(src)) {
|
1633
|
+
return {
|
1634
|
+
success: false,
|
1635
|
+
errors: _defineProperty({}, path, [{
|
1636
|
+
message: "Expected object of type 'array'",
|
1637
|
+
typeError: true
|
1638
|
+
}])
|
1639
|
+
};
|
1479
1640
|
}
|
1480
|
-
return
|
1641
|
+
return {
|
1642
|
+
success: true,
|
1643
|
+
data: src
|
1644
|
+
};
|
1481
1645
|
}
|
1482
1646
|
}, {
|
1483
1647
|
key: "nullable",
|
@@ -1494,14 +1658,12 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
|
|
1494
1658
|
};
|
1495
1659
|
}
|
1496
1660
|
}]);
|
1497
|
-
return ArraySchema;
|
1498
1661
|
}(Schema);
|
1499
1662
|
var array = function array(schema) {
|
1500
1663
|
return new ArraySchema(schema);
|
1501
1664
|
};
|
1502
1665
|
|
1503
1666
|
var LiteralSchema = /*#__PURE__*/function (_Schema) {
|
1504
|
-
_inherits(LiteralSchema, _Schema);
|
1505
1667
|
function LiteralSchema(value) {
|
1506
1668
|
var _this;
|
1507
1669
|
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
@@ -1511,7 +1673,8 @@ var LiteralSchema = /*#__PURE__*/function (_Schema) {
|
|
1511
1673
|
_this.opt = opt;
|
1512
1674
|
return _this;
|
1513
1675
|
}
|
1514
|
-
|
1676
|
+
_inherits(LiteralSchema, _Schema);
|
1677
|
+
return _createClass(LiteralSchema, [{
|
1515
1678
|
key: "validate",
|
1516
1679
|
value: function validate(path, src) {
|
1517
1680
|
if (this.opt && (src === null || src === undefined)) {
|
@@ -1533,11 +1696,35 @@ var LiteralSchema = /*#__PURE__*/function (_Schema) {
|
|
1533
1696
|
}
|
1534
1697
|
}, {
|
1535
1698
|
key: "assert",
|
1536
|
-
value: function assert(src) {
|
1537
|
-
if (this.opt &&
|
1538
|
-
return
|
1699
|
+
value: function assert(path, src) {
|
1700
|
+
if (this.opt && src === null) {
|
1701
|
+
return {
|
1702
|
+
success: true,
|
1703
|
+
data: src
|
1704
|
+
};
|
1705
|
+
}
|
1706
|
+
if (src === null) {
|
1707
|
+
return {
|
1708
|
+
success: false,
|
1709
|
+
errors: _defineProperty({}, path, [{
|
1710
|
+
message: "Expected 'string', got 'null'",
|
1711
|
+
typeError: true
|
1712
|
+
}])
|
1713
|
+
};
|
1539
1714
|
}
|
1540
|
-
|
1715
|
+
if (typeof src === "string" && src === this.value) {
|
1716
|
+
return {
|
1717
|
+
success: true,
|
1718
|
+
data: src
|
1719
|
+
};
|
1720
|
+
}
|
1721
|
+
return {
|
1722
|
+
success: false,
|
1723
|
+
errors: _defineProperty({}, path, [{
|
1724
|
+
message: "Expected literal '".concat(this.value, "', got '").concat(src, "'"),
|
1725
|
+
typeError: true
|
1726
|
+
}])
|
1727
|
+
};
|
1541
1728
|
}
|
1542
1729
|
}, {
|
1543
1730
|
key: "nullable",
|
@@ -1554,14 +1741,12 @@ var LiteralSchema = /*#__PURE__*/function (_Schema) {
|
|
1554
1741
|
};
|
1555
1742
|
}
|
1556
1743
|
}]);
|
1557
|
-
return LiteralSchema;
|
1558
1744
|
}(Schema);
|
1559
1745
|
var literal = function literal(value) {
|
1560
1746
|
return new LiteralSchema(value);
|
1561
1747
|
};
|
1562
1748
|
|
1563
1749
|
var UnionSchema = /*#__PURE__*/function (_Schema) {
|
1564
|
-
_inherits(UnionSchema, _Schema);
|
1565
1750
|
function UnionSchema(key, items) {
|
1566
1751
|
var _this;
|
1567
1752
|
var opt = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
@@ -1572,25 +1757,26 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
|
|
1572
1757
|
_this.opt = opt;
|
1573
1758
|
return _this;
|
1574
1759
|
}
|
1575
|
-
|
1760
|
+
_inherits(UnionSchema, _Schema);
|
1761
|
+
return _createClass(UnionSchema, [{
|
1576
1762
|
key: "validate",
|
1577
1763
|
value: function validate(path, src) {
|
1578
1764
|
var unknownSrc = src;
|
1579
1765
|
var errors = false;
|
1580
|
-
if (this.opt &&
|
1581
|
-
// TODO: src should never be undefined
|
1766
|
+
if (this.opt && unknownSrc === null) {
|
1582
1767
|
return false;
|
1583
1768
|
}
|
1584
1769
|
if (!this.key) {
|
1585
1770
|
return _defineProperty({}, path, [{
|
1586
|
-
message: "Missing required first argument in union"
|
1771
|
+
message: "Missing required first argument in union",
|
1772
|
+
schemaError: true
|
1587
1773
|
}]);
|
1588
1774
|
}
|
1589
1775
|
var key = this.key;
|
1590
1776
|
if (!Array.isArray(this.items)) {
|
1591
1777
|
return _defineProperty({}, path, [{
|
1592
1778
|
message: "A union schema must take more than 1 schema arguments",
|
1593
|
-
|
1779
|
+
schemaError: true
|
1594
1780
|
}]);
|
1595
1781
|
}
|
1596
1782
|
if (typeof key === "string") {
|
@@ -1600,7 +1786,7 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
|
|
1600
1786
|
})) {
|
1601
1787
|
return _defineProperty({}, path, [{
|
1602
1788
|
message: "Key is a string, so all schema items must be objects",
|
1603
|
-
|
1789
|
+
schemaError: true
|
1604
1790
|
}]);
|
1605
1791
|
}
|
1606
1792
|
var objectSchemas = this.items;
|
@@ -1613,7 +1799,7 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
|
|
1613
1799
|
if (illegalSchemas.length > 0) {
|
1614
1800
|
return _defineProperty({}, path, [{
|
1615
1801
|
message: "All schema items must be objects with a key: ".concat(key, " that is a literal schema. Found: ").concat(JSON.stringify(illegalSchemas, null, 2)),
|
1616
|
-
|
1802
|
+
schemaError: true
|
1617
1803
|
}]);
|
1618
1804
|
}
|
1619
1805
|
var serializedObjectSchemas = serializedSchemas;
|
@@ -1623,18 +1809,20 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
|
|
1623
1809
|
if (optionalLiterals.length > 1) {
|
1624
1810
|
return _defineProperty({}, path, [{
|
1625
1811
|
message: "Schema cannot have an optional keys: ".concat(key),
|
1626
|
-
|
1812
|
+
schemaError: true
|
1627
1813
|
}]);
|
1628
1814
|
}
|
1629
1815
|
if (_typeof(unknownSrc) !== "object") {
|
1630
1816
|
return _defineProperty({}, path, [{
|
1631
|
-
message: "Expected an object"
|
1817
|
+
message: "Expected an object",
|
1818
|
+
typeError: true
|
1632
1819
|
}]);
|
1633
1820
|
}
|
1634
1821
|
var objectSrc = unknownSrc;
|
1635
1822
|
if (objectSrc[key] === undefined) {
|
1636
1823
|
return _defineProperty({}, path, [{
|
1637
|
-
message: "Missing required key: ".concat(key)
|
1824
|
+
message: "Missing required key: ".concat(key),
|
1825
|
+
typeError: true
|
1638
1826
|
}]);
|
1639
1827
|
}
|
1640
1828
|
var foundSchemaLiterals = [];
|
@@ -1650,7 +1838,7 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
|
|
1650
1838
|
} else {
|
1651
1839
|
return _defineProperty({}, path, [{
|
1652
1840
|
message: "Found duplicate key in schema: ".concat(schemaKey.value),
|
1653
|
-
|
1841
|
+
schemaError: true
|
1654
1842
|
}]);
|
1655
1843
|
}
|
1656
1844
|
}
|
@@ -1690,7 +1878,7 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
|
|
1690
1878
|
})) {
|
1691
1879
|
return _defineProperty({}, path, [{
|
1692
1880
|
message: "Key is a literal schema, so all schema items must be literals",
|
1693
|
-
|
1881
|
+
typeError: true
|
1694
1882
|
}]);
|
1695
1883
|
}
|
1696
1884
|
var literalItems = [key].concat(_toConsumableArray(this.items));
|
@@ -1715,8 +1903,146 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
|
|
1715
1903
|
}
|
1716
1904
|
}, {
|
1717
1905
|
key: "assert",
|
1718
|
-
value: function assert(src) {
|
1719
|
-
|
1906
|
+
value: function assert(path, src) {
|
1907
|
+
if (this.opt && src === null) {
|
1908
|
+
return {
|
1909
|
+
success: true,
|
1910
|
+
data: src
|
1911
|
+
};
|
1912
|
+
}
|
1913
|
+
if (src === null) {
|
1914
|
+
return {
|
1915
|
+
success: false,
|
1916
|
+
errors: _defineProperty({}, path, [{
|
1917
|
+
message: "Expected 'object', got 'null'",
|
1918
|
+
typeError: true
|
1919
|
+
}])
|
1920
|
+
};
|
1921
|
+
}
|
1922
|
+
if (!this.key) {
|
1923
|
+
return {
|
1924
|
+
success: false,
|
1925
|
+
errors: _defineProperty({}, path, [{
|
1926
|
+
message: "Missing required first argument in union schema",
|
1927
|
+
schemaError: true
|
1928
|
+
}])
|
1929
|
+
};
|
1930
|
+
}
|
1931
|
+
if (!Array.isArray(this.items)) {
|
1932
|
+
return {
|
1933
|
+
success: false,
|
1934
|
+
errors: _defineProperty({}, path, [{
|
1935
|
+
message: "The schema of this value is wrong. Schema is neither a union of literals nor a tagged union (of objects)",
|
1936
|
+
schemaError: true
|
1937
|
+
}])
|
1938
|
+
};
|
1939
|
+
}
|
1940
|
+
if (this.key instanceof LiteralSchema) {
|
1941
|
+
var _ref13;
|
1942
|
+
var success = false;
|
1943
|
+
var errors = {};
|
1944
|
+
var _iterator2 = _createForOfIteratorHelper((_ref13 = [this.key]).concat.apply(_ref13, _toConsumableArray(this.items))),
|
1945
|
+
_step2;
|
1946
|
+
try {
|
1947
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
1948
|
+
var itemSchema = _step2.value;
|
1949
|
+
if (!(itemSchema instanceof LiteralSchema)) {
|
1950
|
+
return {
|
1951
|
+
success: false,
|
1952
|
+
errors: _defineProperty({}, path, [{
|
1953
|
+
message: "Schema of value is a union of string, so all schema items must be literals",
|
1954
|
+
schemaError: true
|
1955
|
+
}])
|
1956
|
+
};
|
1957
|
+
}
|
1958
|
+
if (typeof src !== "string") {
|
1959
|
+
errors[path] = [{
|
1960
|
+
message: "Expected 'string', got '".concat(_typeof(src), "'"),
|
1961
|
+
typeError: true
|
1962
|
+
}];
|
1963
|
+
continue;
|
1964
|
+
}
|
1965
|
+
var res = itemSchema.assert(path, src);
|
1966
|
+
if (res.success) {
|
1967
|
+
success = true;
|
1968
|
+
break;
|
1969
|
+
} else {
|
1970
|
+
for (var _i = 0, _Object$entries = Object.entries(res.errors); _i < _Object$entries.length; _i++) {
|
1971
|
+
var _errors5;
|
1972
|
+
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
1973
|
+
_key = _Object$entries$_i[0],
|
1974
|
+
value = _Object$entries$_i[1];
|
1975
|
+
if (!errors[_key]) {
|
1976
|
+
errors[_key] = [];
|
1977
|
+
}
|
1978
|
+
(_errors5 = errors[_key]).push.apply(_errors5, _toConsumableArray(value));
|
1979
|
+
}
|
1980
|
+
}
|
1981
|
+
}
|
1982
|
+
} catch (err) {
|
1983
|
+
_iterator2.e(err);
|
1984
|
+
} finally {
|
1985
|
+
_iterator2.f();
|
1986
|
+
}
|
1987
|
+
if (!success) {
|
1988
|
+
return {
|
1989
|
+
success: false,
|
1990
|
+
errors: errors
|
1991
|
+
};
|
1992
|
+
}
|
1993
|
+
return {
|
1994
|
+
success: true,
|
1995
|
+
data: src
|
1996
|
+
};
|
1997
|
+
} else if (typeof this.key === "string") {
|
1998
|
+
var _success = false;
|
1999
|
+
var _errors6 = {};
|
2000
|
+
var _iterator3 = _createForOfIteratorHelper(this.items),
|
2001
|
+
_step3;
|
2002
|
+
try {
|
2003
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
2004
|
+
var _itemSchema = _step3.value;
|
2005
|
+
var _res = _itemSchema.assert(path, src);
|
2006
|
+
if (_res.success) {
|
2007
|
+
_success = true;
|
2008
|
+
break;
|
2009
|
+
} else {
|
2010
|
+
for (var _i2 = 0, _Object$entries2 = Object.entries(_res.errors); _i2 < _Object$entries2.length; _i2++) {
|
2011
|
+
var _errors7;
|
2012
|
+
var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2),
|
2013
|
+
_key2 = _Object$entries2$_i[0],
|
2014
|
+
_value = _Object$entries2$_i[1];
|
2015
|
+
if (!_errors6[_key2]) {
|
2016
|
+
_errors6[_key2] = [];
|
2017
|
+
}
|
2018
|
+
(_errors7 = _errors6[_key2]).push.apply(_errors7, _toConsumableArray(_value)); // by appending all type errors, we most likely get a lot of duplicate errors. Currently we believe this is correct though, but should probably be handled in when showing the errors to users
|
2019
|
+
}
|
2020
|
+
}
|
2021
|
+
}
|
2022
|
+
} catch (err) {
|
2023
|
+
_iterator3.e(err);
|
2024
|
+
} finally {
|
2025
|
+
_iterator3.f();
|
2026
|
+
}
|
2027
|
+
if (!_success) {
|
2028
|
+
return {
|
2029
|
+
success: false,
|
2030
|
+
errors: _errors6
|
2031
|
+
};
|
2032
|
+
}
|
2033
|
+
return {
|
2034
|
+
success: true,
|
2035
|
+
data: src
|
2036
|
+
};
|
2037
|
+
} else {
|
2038
|
+
return {
|
2039
|
+
success: false,
|
2040
|
+
errors: _defineProperty({}, path, [{
|
2041
|
+
message: "The schema of this value is wrong. Schema is neither a union of literals nor a tagged union (of objects)",
|
2042
|
+
schemaError: true
|
2043
|
+
}])
|
2044
|
+
};
|
2045
|
+
}
|
1720
2046
|
}
|
1721
2047
|
}, {
|
1722
2048
|
key: "nullable",
|
@@ -1746,17 +2072,15 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
|
|
1746
2072
|
};
|
1747
2073
|
}
|
1748
2074
|
}]);
|
1749
|
-
return UnionSchema;
|
1750
2075
|
}(Schema);
|
1751
2076
|
var union = function union(key) {
|
1752
|
-
for (var _len = arguments.length, objects = new Array(_len > 1 ? _len - 1 : 0),
|
1753
|
-
objects[
|
2077
|
+
for (var _len = arguments.length, objects = new Array(_len > 1 ? _len - 1 : 0), _key3 = 1; _key3 < _len; _key3++) {
|
2078
|
+
objects[_key3 - 1] = arguments[_key3];
|
1754
2079
|
}
|
1755
2080
|
return new UnionSchema(key, objects);
|
1756
2081
|
};
|
1757
2082
|
|
1758
2083
|
var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
1759
|
-
_inherits(RichTextSchema, _Schema);
|
1760
2084
|
function RichTextSchema(options) {
|
1761
2085
|
var _this;
|
1762
2086
|
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
@@ -1766,7 +2090,8 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
1766
2090
|
_this.opt = opt;
|
1767
2091
|
return _this;
|
1768
2092
|
}
|
1769
|
-
|
2093
|
+
_inherits(RichTextSchema, _Schema);
|
2094
|
+
return _createClass(RichTextSchema, [{
|
1770
2095
|
key: "validate",
|
1771
2096
|
value: function validate(path, src) {
|
1772
2097
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
@@ -1777,12 +2102,147 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
1777
2102
|
fixes: ["fix:deprecated-richtext"]
|
1778
2103
|
}]);
|
1779
2104
|
}
|
1780
|
-
|
2105
|
+
var assertRes = this.assert(path, src);
|
2106
|
+
if (!assertRes.success) {
|
2107
|
+
return _defineProperty({}, path, assertRes.errors[path]);
|
2108
|
+
}
|
2109
|
+
// TODO validate options
|
2110
|
+
return false;
|
1781
2111
|
}
|
1782
2112
|
}, {
|
1783
2113
|
key: "assert",
|
1784
|
-
value: function assert(src) {
|
1785
|
-
|
2114
|
+
value: function assert(path, src) {
|
2115
|
+
if (this.opt && src === null) {
|
2116
|
+
return {
|
2117
|
+
success: true,
|
2118
|
+
data: src
|
2119
|
+
};
|
2120
|
+
}
|
2121
|
+
if (!Array.isArray(src)) {
|
2122
|
+
return {
|
2123
|
+
success: false,
|
2124
|
+
errors: _defineProperty({}, path, [{
|
2125
|
+
message: "Expected 'array', got '".concat(_typeof(src), "'"),
|
2126
|
+
typeError: true
|
2127
|
+
}])
|
2128
|
+
};
|
2129
|
+
}
|
2130
|
+
var errors = {};
|
2131
|
+
for (var i = 0; i < src.length; i++) {
|
2132
|
+
this.recursiveAssert(unsafeCreateSourcePath(path, i), src[i], errors);
|
2133
|
+
}
|
2134
|
+
if (Object.keys(errors).length > 0) {
|
2135
|
+
return {
|
2136
|
+
success: false,
|
2137
|
+
errors: errors
|
2138
|
+
};
|
2139
|
+
}
|
2140
|
+
// TODO: validate options
|
2141
|
+
return {
|
2142
|
+
success: true,
|
2143
|
+
data: src
|
2144
|
+
};
|
2145
|
+
}
|
2146
|
+
}, {
|
2147
|
+
key: "recursiveAssert",
|
2148
|
+
value: function recursiveAssert(path, node, errors) {
|
2149
|
+
if (_typeof(node) !== "object") {
|
2150
|
+
if (!errors[path]) {
|
2151
|
+
errors[path] = [];
|
2152
|
+
}
|
2153
|
+
errors[path].push({
|
2154
|
+
message: "Expected 'object', got '".concat(_typeof(node), "'"),
|
2155
|
+
typeError: true
|
2156
|
+
});
|
2157
|
+
return;
|
2158
|
+
}
|
2159
|
+
if (Array.isArray(node)) {
|
2160
|
+
if (!errors[path]) {
|
2161
|
+
errors[path] = [];
|
2162
|
+
}
|
2163
|
+
errors[path].push({
|
2164
|
+
message: "Expected 'object', got 'array'",
|
2165
|
+
typeError: true
|
2166
|
+
});
|
2167
|
+
return;
|
2168
|
+
}
|
2169
|
+
if (node === null) {
|
2170
|
+
if (!errors[path]) {
|
2171
|
+
errors[path] = [];
|
2172
|
+
}
|
2173
|
+
errors[path].push({
|
2174
|
+
message: "Expected 'object', got 'null'",
|
2175
|
+
typeError: true
|
2176
|
+
});
|
2177
|
+
return;
|
2178
|
+
}
|
2179
|
+
if ("tag" in node) {
|
2180
|
+
if (typeof node.tag !== "string") {
|
2181
|
+
if (!errors[path]) {
|
2182
|
+
errors[path] = [];
|
2183
|
+
}
|
2184
|
+
errors[path].push({
|
2185
|
+
message: "Expected 'string', got '".concat(_typeof(node.tag), "'"),
|
2186
|
+
typeError: true
|
2187
|
+
});
|
2188
|
+
return;
|
2189
|
+
}
|
2190
|
+
}
|
2191
|
+
if ("children" in node) {
|
2192
|
+
if (!Array.isArray(node.children)) {
|
2193
|
+
if (!errors[path]) {
|
2194
|
+
errors[path] = [];
|
2195
|
+
}
|
2196
|
+
errors[path].push({
|
2197
|
+
message: "Expected 'array', got '".concat(_typeof(node.children), "'"),
|
2198
|
+
typeError: true
|
2199
|
+
});
|
2200
|
+
return;
|
2201
|
+
} else {
|
2202
|
+
for (var i = 0; i < node.children.length; i++) {
|
2203
|
+
var child = node.children[i];
|
2204
|
+
var pathAtError = unsafeCreateSourcePath(unsafeCreateSourcePath(path, "children"), i);
|
2205
|
+
if (_typeof(child) === "object") {
|
2206
|
+
this.recursiveAssert(pathAtError, child, errors);
|
2207
|
+
} else if (typeof child === "string") {
|
2208
|
+
continue;
|
2209
|
+
} else {
|
2210
|
+
if (!errors[pathAtError]) {
|
2211
|
+
errors[pathAtError] = [];
|
2212
|
+
}
|
2213
|
+
errors[pathAtError].push({
|
2214
|
+
message: "Expected 'object' or 'string', got '".concat(_typeof(child), "'"),
|
2215
|
+
typeError: true
|
2216
|
+
});
|
2217
|
+
}
|
2218
|
+
}
|
2219
|
+
}
|
2220
|
+
}
|
2221
|
+
if ("styles" in node) {
|
2222
|
+
if (!Array.isArray(node.styles)) {
|
2223
|
+
if (!errors[path]) {
|
2224
|
+
errors[path] = [];
|
2225
|
+
}
|
2226
|
+
errors[path].push({
|
2227
|
+
message: "Expected 'array', got '".concat(_typeof(node.styles), "'"),
|
2228
|
+
typeError: true
|
2229
|
+
});
|
2230
|
+
} else {
|
2231
|
+
for (var _i = 0; _i < node.styles.length; _i++) {
|
2232
|
+
var style = node.styles[_i];
|
2233
|
+
if (typeof style !== "string") {
|
2234
|
+
var _pathAtError = unsafeCreateSourcePath(path, _i);
|
2235
|
+
if (!errors[_pathAtError]) {
|
2236
|
+
errors[_pathAtError] = [];
|
2237
|
+
}
|
2238
|
+
errors[_pathAtError].push({
|
2239
|
+
message: "Expected 'string', got '".concat(_typeof(style), "'"),
|
2240
|
+
typeError: true
|
2241
|
+
});
|
2242
|
+
}
|
2243
|
+
}
|
2244
|
+
}
|
2245
|
+
}
|
1786
2246
|
}
|
1787
2247
|
}, {
|
1788
2248
|
key: "nullable",
|
@@ -1799,14 +2259,12 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
1799
2259
|
};
|
1800
2260
|
}
|
1801
2261
|
}]);
|
1802
|
-
return RichTextSchema;
|
1803
2262
|
}(Schema);
|
1804
2263
|
var richtext$1 = function richtext(options) {
|
1805
2264
|
return new RichTextSchema(options !== null && options !== void 0 ? options : {});
|
1806
2265
|
};
|
1807
2266
|
|
1808
2267
|
var ImageSchema = /*#__PURE__*/function (_Schema) {
|
1809
|
-
_inherits(ImageSchema, _Schema);
|
1810
2268
|
function ImageSchema(options) {
|
1811
2269
|
var _this;
|
1812
2270
|
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
@@ -1816,7 +2274,8 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
|
|
1816
2274
|
_this.opt = opt;
|
1817
2275
|
return _this;
|
1818
2276
|
}
|
1819
|
-
|
2277
|
+
_inherits(ImageSchema, _Schema);
|
2278
|
+
return _createClass(ImageSchema, [{
|
1820
2279
|
key: "validate",
|
1821
2280
|
value: function validate(path, src) {
|
1822
2281
|
if (this.opt && (src === null || src === undefined)) {
|
@@ -1840,9 +2299,53 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
|
|
1840
2299
|
value: src
|
1841
2300
|
}]);
|
1842
2301
|
}
|
2302
|
+
var _ref4 = this.options || {},
|
2303
|
+
accept = _ref4.accept;
|
2304
|
+
var _ref5 = src.metadata || {},
|
2305
|
+
mimeType = _ref5.mimeType;
|
2306
|
+
if (accept && mimeType && !mimeType.includes("/")) {
|
2307
|
+
return _defineProperty({}, path, [{
|
2308
|
+
message: "Invalid mime type format. Got: '".concat(mimeType, "'"),
|
2309
|
+
value: src
|
2310
|
+
}]);
|
2311
|
+
}
|
2312
|
+
if (accept && mimeType && mimeType.includes("/")) {
|
2313
|
+
var acceptedTypes = accept.split(",").map(function (type) {
|
2314
|
+
return type.trim();
|
2315
|
+
});
|
2316
|
+
var isValidMimeType = acceptedTypes.some(function (acceptedType) {
|
2317
|
+
if (acceptedType === "*/*") {
|
2318
|
+
return true;
|
2319
|
+
}
|
2320
|
+
if (acceptedType.endsWith("/*")) {
|
2321
|
+
var baseType = acceptedType.slice(0, -2);
|
2322
|
+
return mimeType.startsWith(baseType);
|
2323
|
+
}
|
2324
|
+
return acceptedType === mimeType;
|
2325
|
+
});
|
2326
|
+
if (!isValidMimeType) {
|
2327
|
+
return _defineProperty({}, path, [{
|
2328
|
+
message: "Mime type mismatch. Found '".concat(mimeType, "' but schema accepts '").concat(accept, "'"),
|
2329
|
+
value: src
|
2330
|
+
}]);
|
2331
|
+
}
|
2332
|
+
}
|
2333
|
+
var fileMimeType = Internal.filenameToMimeType(src[FILE_REF_PROP]);
|
2334
|
+
if (!fileMimeType) {
|
2335
|
+
return _defineProperty({}, path, [{
|
2336
|
+
message: "Could not determine mime type from file extension. Got: ".concat(src[FILE_REF_PROP]),
|
2337
|
+
value: src
|
2338
|
+
}]);
|
2339
|
+
}
|
2340
|
+
if (fileMimeType && mimeType && fileMimeType !== mimeType) {
|
2341
|
+
return _defineProperty({}, path, [{
|
2342
|
+
message: "Mime type and file extension not matching. Mime type is '".concat(mimeType, "' but file extension is '").concat(fileMimeType, "'"),
|
2343
|
+
value: src
|
2344
|
+
}]);
|
2345
|
+
}
|
1843
2346
|
if (src.metadata) {
|
1844
2347
|
return _defineProperty({}, path, [{
|
1845
|
-
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.",
|
1846
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.
|
1847
2350
|
value: src,
|
1848
2351
|
fixes: ["image:replace-metadata"]
|
@@ -1856,11 +2359,53 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
|
|
1856
2359
|
}
|
1857
2360
|
}, {
|
1858
2361
|
key: "assert",
|
1859
|
-
value: function assert(src) {
|
1860
|
-
if (this.opt &&
|
1861
|
-
return
|
2362
|
+
value: function assert(path, src) {
|
2363
|
+
if (this.opt && src === null) {
|
2364
|
+
return {
|
2365
|
+
success: true,
|
2366
|
+
data: src
|
2367
|
+
};
|
2368
|
+
}
|
2369
|
+
if (src === null) {
|
2370
|
+
return {
|
2371
|
+
success: false,
|
2372
|
+
errors: _defineProperty({}, path, [{
|
2373
|
+
message: "Expected 'object', got 'null'",
|
2374
|
+
typeError: true
|
2375
|
+
}])
|
2376
|
+
};
|
1862
2377
|
}
|
1863
|
-
|
2378
|
+
if (_typeof(src) !== "object") {
|
2379
|
+
return {
|
2380
|
+
success: false,
|
2381
|
+
errors: _defineProperty({}, path, [{
|
2382
|
+
message: "Expected 'object', got '".concat(_typeof(src), "'"),
|
2383
|
+
typeError: true
|
2384
|
+
}])
|
2385
|
+
};
|
2386
|
+
}
|
2387
|
+
if (!(FILE_REF_PROP in src)) {
|
2388
|
+
return {
|
2389
|
+
success: false,
|
2390
|
+
errors: _defineProperty({}, path, [{
|
2391
|
+
message: "Value of this schema must use: 'c.image' (error type: missing_ref_prop)",
|
2392
|
+
typeError: true
|
2393
|
+
}])
|
2394
|
+
};
|
2395
|
+
}
|
2396
|
+
if (!(VAL_EXTENSION in src && src[VAL_EXTENSION] === "file")) {
|
2397
|
+
return {
|
2398
|
+
success: false,
|
2399
|
+
errors: _defineProperty({}, path, [{
|
2400
|
+
message: "Value of this schema must use: 'c.image' (error type: missing_file_extension)",
|
2401
|
+
typeError: true
|
2402
|
+
}])
|
2403
|
+
};
|
2404
|
+
}
|
2405
|
+
return {
|
2406
|
+
success: true,
|
2407
|
+
data: src
|
2408
|
+
};
|
1864
2409
|
}
|
1865
2410
|
}, {
|
1866
2411
|
key: "nullable",
|
@@ -1877,14 +2422,12 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
|
|
1877
2422
|
};
|
1878
2423
|
}
|
1879
2424
|
}]);
|
1880
|
-
return ImageSchema;
|
1881
2425
|
}(Schema);
|
1882
2426
|
var image$1 = function image(options) {
|
1883
2427
|
return new ImageSchema(options);
|
1884
2428
|
};
|
1885
2429
|
|
1886
2430
|
var RecordSchema = /*#__PURE__*/function (_Schema) {
|
1887
|
-
_inherits(RecordSchema, _Schema);
|
1888
2431
|
function RecordSchema(item) {
|
1889
2432
|
var _this;
|
1890
2433
|
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
@@ -1894,7 +2437,8 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
1894
2437
|
_this.opt = opt;
|
1895
2438
|
return _this;
|
1896
2439
|
}
|
1897
|
-
|
2440
|
+
_inherits(RecordSchema, _Schema);
|
2441
|
+
return _createClass(RecordSchema, [{
|
1898
2442
|
key: "validate",
|
1899
2443
|
value: function validate(path, src) {
|
1900
2444
|
var _this2 = this;
|
@@ -1902,6 +2446,11 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
1902
2446
|
if (this.opt && (src === null || src === undefined)) {
|
1903
2447
|
return false;
|
1904
2448
|
}
|
2449
|
+
if (src === null) {
|
2450
|
+
return _defineProperty({}, path, [{
|
2451
|
+
message: "Expected 'object', got 'null'"
|
2452
|
+
}]);
|
2453
|
+
}
|
1905
2454
|
if (_typeof(src) !== "object") {
|
1906
2455
|
return _defineProperty({}, path, [{
|
1907
2456
|
message: "Expected 'object', got '".concat(_typeof(src), "'")
|
@@ -1912,10 +2461,10 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
1912
2461
|
message: "Expected 'object', got 'array'"
|
1913
2462
|
}]);
|
1914
2463
|
}
|
1915
|
-
Object.entries(src).forEach(function (
|
1916
|
-
var
|
1917
|
-
key =
|
1918
|
-
elem =
|
2464
|
+
Object.entries(src).forEach(function (_ref4) {
|
2465
|
+
var _ref5 = _slicedToArray(_ref4, 2),
|
2466
|
+
key = _ref5[0],
|
2467
|
+
elem = _ref5[1];
|
1919
2468
|
var subPath = createValPathOfItem(path, key);
|
1920
2469
|
if (!subPath) {
|
1921
2470
|
error = _this2.appendValidationError(error, path, "Internal error: could not create path at ".concat(!path && typeof path === "string" ? "<empty string>" : path, " at key ").concat(elem),
|
@@ -1934,21 +2483,35 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
1934
2483
|
}
|
1935
2484
|
}, {
|
1936
2485
|
key: "assert",
|
1937
|
-
value: function assert(src) {
|
1938
|
-
if (this.opt &&
|
1939
|
-
return
|
2486
|
+
value: function assert(path, src) {
|
2487
|
+
if (this.opt && src === null) {
|
2488
|
+
return {
|
2489
|
+
success: true,
|
2490
|
+
data: src
|
2491
|
+
};
|
1940
2492
|
}
|
1941
|
-
if (
|
1942
|
-
return
|
2493
|
+
if (_typeof(src) !== "object") {
|
2494
|
+
return {
|
2495
|
+
success: false,
|
2496
|
+
errors: _defineProperty({}, path, [{
|
2497
|
+
message: "Expected 'object', got '".concat(_typeof(src), "'"),
|
2498
|
+
typeError: true
|
2499
|
+
}])
|
2500
|
+
};
|
1943
2501
|
}
|
1944
|
-
|
1945
|
-
|
1946
|
-
|
1947
|
-
|
1948
|
-
|
1949
|
-
|
2502
|
+
if (Array.isArray(src)) {
|
2503
|
+
return {
|
2504
|
+
success: false,
|
2505
|
+
errors: _defineProperty({}, path, [{
|
2506
|
+
message: "Expected 'object', got 'array'",
|
2507
|
+
typeError: true
|
2508
|
+
}])
|
2509
|
+
};
|
1950
2510
|
}
|
1951
|
-
return
|
2511
|
+
return {
|
2512
|
+
success: true,
|
2513
|
+
data: src
|
2514
|
+
};
|
1952
2515
|
}
|
1953
2516
|
}, {
|
1954
2517
|
key: "nullable",
|
@@ -1965,7 +2528,6 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
1965
2528
|
};
|
1966
2529
|
}
|
1967
2530
|
}]);
|
1968
|
-
return RecordSchema;
|
1969
2531
|
}(Schema);
|
1970
2532
|
var record = function record(schema) {
|
1971
2533
|
return new RecordSchema(schema);
|
@@ -1996,7 +2558,12 @@ function splitModuleFilePathAndModulePath(path) {
|
|
1996
2558
|
}
|
1997
2559
|
return [path.slice(0, pathOfSep), path.slice(pathOfSep + ModuleFilePathSep.length)];
|
1998
2560
|
}
|
1999
|
-
|
2561
|
+
function joinModuleFilePathAndModulePath(moduleFilePath, modulePath) {
|
2562
|
+
if (modulePath === "") {
|
2563
|
+
return moduleFilePath;
|
2564
|
+
}
|
2565
|
+
return "".concat(moduleFilePath).concat(ModuleFilePathSep).concat(modulePath);
|
2566
|
+
}
|
2000
2567
|
function isObjectSchema(schema) {
|
2001
2568
|
return schema instanceof ObjectSchema || _typeof(schema) === "object" && "type" in schema && schema.type === "object";
|
2002
2569
|
}
|
@@ -2016,7 +2583,9 @@ function isArraySchema(schema) {
|
|
2016
2583
|
// );
|
2017
2584
|
// }
|
2018
2585
|
|
2019
|
-
function isUnionSchema(schema
|
2586
|
+
function isUnionSchema(schema
|
2587
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
2588
|
+
) {
|
2020
2589
|
return schema instanceof UnionSchema || _typeof(schema) === "object" && "type" in schema && schema.type === "union";
|
2021
2590
|
}
|
2022
2591
|
|
@@ -2038,7 +2607,7 @@ function isImageSchema(schema) {
|
|
2038
2607
|
// }
|
2039
2608
|
|
2040
2609
|
function resolvePath(path, valModule, schema) {
|
2041
|
-
var parts =
|
2610
|
+
var parts = splitModulePath(path);
|
2042
2611
|
var origParts = _toConsumableArray(parts);
|
2043
2612
|
var resolvedSchema = schema;
|
2044
2613
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
@@ -2055,10 +2624,6 @@ function resolvePath(path, valModule, schema) {
|
|
2055
2624
|
if (_typeof(resolvedSource) !== "object" && !Array.isArray(resolvedSource)) {
|
2056
2625
|
throw Error("Schema type error: expected source to be type of array, but got ".concat(_typeof(resolvedSource)));
|
2057
2626
|
}
|
2058
|
-
if (resolvedSource[part] === undefined) {
|
2059
|
-
var _resolvedSource;
|
2060
|
-
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));
|
2061
|
-
}
|
2062
2627
|
resolvedSource = resolvedSource[part];
|
2063
2628
|
resolvedSchema = resolvedSchema.item;
|
2064
2629
|
} else if (isRecordSchema(resolvedSchema)) {
|
@@ -2077,10 +2642,10 @@ function resolvePath(path, valModule, schema) {
|
|
2077
2642
|
if (_typeof(resolvedSource) !== "object") {
|
2078
2643
|
throw Error("Schema type error: expected source to be type of object, but got ".concat(_typeof(resolvedSource)));
|
2079
2644
|
}
|
2080
|
-
if (
|
2645
|
+
if (resolvedSource !== null && resolvedSource[part] === undefined) {
|
2081
2646
|
throw Error("Invalid path: object source did not have key ".concat(part, " from path: ").concat(path));
|
2082
2647
|
}
|
2083
|
-
resolvedSource = resolvedSource[part];
|
2648
|
+
resolvedSource = resolvedSource === null ? resolvedSource : resolvedSource[part];
|
2084
2649
|
resolvedSchema = resolvedSchema.items[part];
|
2085
2650
|
// } else if (isI18nSchema(resolvedSchema)) {
|
2086
2651
|
// if (!resolvedSchema.locales.includes(part)) {
|
@@ -2132,6 +2697,7 @@ function resolvePath(path, valModule, schema) {
|
|
2132
2697
|
if (!keyValue) {
|
2133
2698
|
throw Error("Invalid path: union source ".concat(resolvedSchema, " did not have required key ").concat(_key, " in path: ").concat(path));
|
2134
2699
|
}
|
2700
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
2135
2701
|
var schemaOfUnionKey = resolvedSchema.items.find(
|
2136
2702
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
2137
2703
|
function (child) {
|
@@ -2179,7 +2745,11 @@ function resolvePath(path, valModule, schema) {
|
|
2179
2745
|
source: resolvedSource
|
2180
2746
|
};
|
2181
2747
|
}
|
2182
|
-
function
|
2748
|
+
function splitModuleFilePath(input) {
|
2749
|
+
var parts = input.split("/").slice(1);
|
2750
|
+
return parts;
|
2751
|
+
}
|
2752
|
+
function splitModulePath(input) {
|
2183
2753
|
var result = [];
|
2184
2754
|
var i = 0;
|
2185
2755
|
while (i < input.length) {
|
@@ -2215,9 +2785,32 @@ function parsePath(input) {
|
|
2215
2785
|
}
|
2216
2786
|
return result;
|
2217
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
|
+
}
|
2218
2812
|
|
2219
2813
|
var NumberSchema = /*#__PURE__*/function (_Schema) {
|
2220
|
-
_inherits(NumberSchema, _Schema);
|
2221
2814
|
function NumberSchema(options) {
|
2222
2815
|
var _this;
|
2223
2816
|
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
@@ -2227,7 +2820,8 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
2227
2820
|
_this.opt = opt;
|
2228
2821
|
return _this;
|
2229
2822
|
}
|
2230
|
-
|
2823
|
+
_inherits(NumberSchema, _Schema);
|
2824
|
+
return _createClass(NumberSchema, [{
|
2231
2825
|
key: "validate",
|
2232
2826
|
value: function validate(path, src) {
|
2233
2827
|
if (this.opt && (src === null || src === undefined)) {
|
@@ -2243,11 +2837,35 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
2243
2837
|
}
|
2244
2838
|
}, {
|
2245
2839
|
key: "assert",
|
2246
|
-
value: function assert(src) {
|
2247
|
-
if (this.opt &&
|
2248
|
-
return
|
2840
|
+
value: function assert(path, src) {
|
2841
|
+
if (this.opt && src === null) {
|
2842
|
+
return {
|
2843
|
+
success: true,
|
2844
|
+
data: src
|
2845
|
+
};
|
2846
|
+
}
|
2847
|
+
if (src === null) {
|
2848
|
+
return {
|
2849
|
+
success: false,
|
2850
|
+
errors: _defineProperty({}, path, [{
|
2851
|
+
message: "Expected 'number', got 'null'",
|
2852
|
+
typeError: true
|
2853
|
+
}])
|
2854
|
+
};
|
2855
|
+
}
|
2856
|
+
if (typeof src === "number") {
|
2857
|
+
return {
|
2858
|
+
success: true,
|
2859
|
+
data: src
|
2860
|
+
};
|
2249
2861
|
}
|
2250
|
-
return
|
2862
|
+
return {
|
2863
|
+
success: false,
|
2864
|
+
errors: _defineProperty({}, path, [{
|
2865
|
+
message: "Expected 'number', got '".concat(_typeof(src), "'"),
|
2866
|
+
typeError: true
|
2867
|
+
}])
|
2868
|
+
};
|
2251
2869
|
}
|
2252
2870
|
}, {
|
2253
2871
|
key: "nullable",
|
@@ -2264,14 +2882,12 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
2264
2882
|
};
|
2265
2883
|
}
|
2266
2884
|
}]);
|
2267
|
-
return NumberSchema;
|
2268
2885
|
}(Schema);
|
2269
2886
|
var number = function number(options) {
|
2270
2887
|
return new NumberSchema(options);
|
2271
2888
|
};
|
2272
2889
|
|
2273
2890
|
var StringSchema = /*#__PURE__*/function (_Schema) {
|
2274
|
-
_inherits(StringSchema, _Schema);
|
2275
2891
|
function StringSchema(options) {
|
2276
2892
|
var _this;
|
2277
2893
|
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
@@ -2283,7 +2899,8 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
|
|
2283
2899
|
_this.isRaw = isRaw;
|
2284
2900
|
return _this;
|
2285
2901
|
}
|
2286
|
-
|
2902
|
+
_inherits(StringSchema, _Schema);
|
2903
|
+
return _createClass(StringSchema, [{
|
2287
2904
|
key: "min",
|
2288
2905
|
value: function min(minLength) {
|
2289
2906
|
return new StringSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
@@ -2343,11 +2960,26 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
|
|
2343
2960
|
}
|
2344
2961
|
}, {
|
2345
2962
|
key: "assert",
|
2346
|
-
value: function assert(src) {
|
2347
|
-
if (this.opt &&
|
2348
|
-
return
|
2963
|
+
value: function assert(path, src) {
|
2964
|
+
if (this.opt && src === null) {
|
2965
|
+
return {
|
2966
|
+
success: true,
|
2967
|
+
data: src
|
2968
|
+
};
|
2969
|
+
}
|
2970
|
+
if (typeof src === "string") {
|
2971
|
+
return {
|
2972
|
+
success: true,
|
2973
|
+
data: src
|
2974
|
+
};
|
2349
2975
|
}
|
2350
|
-
return
|
2976
|
+
return {
|
2977
|
+
success: false,
|
2978
|
+
errors: _defineProperty({}, path, [{
|
2979
|
+
message: "Expected 'string', got '".concat(_typeof(src), "'"),
|
2980
|
+
typeError: true
|
2981
|
+
}])
|
2982
|
+
};
|
2351
2983
|
}
|
2352
2984
|
}, {
|
2353
2985
|
key: "nullable",
|
@@ -2378,14 +3010,12 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
|
|
2378
3010
|
};
|
2379
3011
|
}
|
2380
3012
|
}]);
|
2381
|
-
return StringSchema;
|
2382
3013
|
}(Schema);
|
2383
3014
|
var string = function string(options) {
|
2384
3015
|
return new StringSchema(options);
|
2385
3016
|
};
|
2386
3017
|
|
2387
3018
|
var BooleanSchema = /*#__PURE__*/function (_Schema) {
|
2388
|
-
_inherits(BooleanSchema, _Schema);
|
2389
3019
|
function BooleanSchema() {
|
2390
3020
|
var _this;
|
2391
3021
|
var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
@@ -2394,7 +3024,8 @@ var BooleanSchema = /*#__PURE__*/function (_Schema) {
|
|
2394
3024
|
_this.opt = opt;
|
2395
3025
|
return _this;
|
2396
3026
|
}
|
2397
|
-
|
3027
|
+
_inherits(BooleanSchema, _Schema);
|
3028
|
+
return _createClass(BooleanSchema, [{
|
2398
3029
|
key: "validate",
|
2399
3030
|
value: function validate(path, src) {
|
2400
3031
|
if (this.opt && (src === null || src === undefined)) {
|
@@ -2410,11 +3041,35 @@ var BooleanSchema = /*#__PURE__*/function (_Schema) {
|
|
2410
3041
|
}
|
2411
3042
|
}, {
|
2412
3043
|
key: "assert",
|
2413
|
-
value: function assert(src) {
|
2414
|
-
if (this.opt &&
|
2415
|
-
return
|
3044
|
+
value: function assert(path, src) {
|
3045
|
+
if (this.opt && src === null) {
|
3046
|
+
return {
|
3047
|
+
success: true,
|
3048
|
+
data: src
|
3049
|
+
};
|
3050
|
+
}
|
3051
|
+
if (src === null) {
|
3052
|
+
return {
|
3053
|
+
success: false,
|
3054
|
+
errors: _defineProperty({}, path, [{
|
3055
|
+
message: "Expected 'boolean', got 'null'",
|
3056
|
+
typeError: true
|
3057
|
+
}])
|
3058
|
+
};
|
2416
3059
|
}
|
2417
|
-
|
3060
|
+
if (typeof src !== "boolean") {
|
3061
|
+
return {
|
3062
|
+
success: false,
|
3063
|
+
errors: _defineProperty({}, path, [{
|
3064
|
+
message: "Expected 'boolean', got '".concat(_typeof(src), "'"),
|
3065
|
+
typeError: true
|
3066
|
+
}])
|
3067
|
+
};
|
3068
|
+
}
|
3069
|
+
return {
|
3070
|
+
success: true,
|
3071
|
+
data: src
|
3072
|
+
};
|
2418
3073
|
}
|
2419
3074
|
}, {
|
2420
3075
|
key: "nullable",
|
@@ -2430,14 +3085,12 @@ var BooleanSchema = /*#__PURE__*/function (_Schema) {
|
|
2430
3085
|
};
|
2431
3086
|
}
|
2432
3087
|
}]);
|
2433
|
-
return BooleanSchema;
|
2434
3088
|
}(Schema);
|
2435
3089
|
var _boolean = function _boolean() {
|
2436
3090
|
return new BooleanSchema();
|
2437
3091
|
};
|
2438
3092
|
|
2439
3093
|
var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
2440
|
-
_inherits(KeyOfSchema, _Schema);
|
2441
3094
|
function KeyOfSchema(schema, sourcePath) {
|
2442
3095
|
var _this;
|
2443
3096
|
var opt = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
@@ -2448,7 +3101,8 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
|
2448
3101
|
_this.opt = opt;
|
2449
3102
|
return _this;
|
2450
3103
|
}
|
2451
|
-
|
3104
|
+
_inherits(KeyOfSchema, _Schema);
|
3105
|
+
return _createClass(KeyOfSchema, [{
|
2452
3106
|
key: "validate",
|
2453
3107
|
value: function validate(path, src) {
|
2454
3108
|
if (this.opt && (src === null || src === undefined)) {
|
@@ -2460,19 +3114,14 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
|
2460
3114
|
}]);
|
2461
3115
|
}
|
2462
3116
|
var serializedSchema = this.schema;
|
2463
|
-
if (!(serializedSchema.type === "
|
3117
|
+
if (!(serializedSchema.type === "object" || serializedSchema.type === "record")) {
|
2464
3118
|
return _defineProperty({}, path, [{
|
2465
|
-
message: "Schema in keyOf must be an '
|
3119
|
+
message: "Schema in keyOf must be an 'object' or 'record'. Found '".concat(serializedSchema.type, "'")
|
2466
3120
|
}]);
|
2467
3121
|
}
|
2468
3122
|
if (serializedSchema.opt && (src === null || src === undefined)) {
|
2469
3123
|
return false;
|
2470
3124
|
}
|
2471
|
-
if (serializedSchema.type === "array" && typeof src !== "number") {
|
2472
|
-
return _defineProperty({}, path, [{
|
2473
|
-
message: "Type of value in keyof (array) must be 'number'"
|
2474
|
-
}]);
|
2475
|
-
}
|
2476
3125
|
if (serializedSchema.type === "record" && typeof src !== "string") {
|
2477
3126
|
return _defineProperty({}, path, [{
|
2478
3127
|
message: "Type of value in keyof (record) must be 'string'"
|
@@ -2490,34 +3139,70 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
|
2490
3139
|
}
|
2491
3140
|
}, {
|
2492
3141
|
key: "assert",
|
2493
|
-
value: function assert(src) {
|
2494
|
-
if (this.opt &&
|
2495
|
-
return
|
3142
|
+
value: function assert(path, src) {
|
3143
|
+
if (this.opt && src === null) {
|
3144
|
+
return {
|
3145
|
+
success: true,
|
3146
|
+
data: src
|
3147
|
+
};
|
3148
|
+
}
|
3149
|
+
if (src === null) {
|
3150
|
+
return {
|
3151
|
+
success: false,
|
3152
|
+
errors: _defineProperty({}, path, [{
|
3153
|
+
message: "Expected 'string', got 'null'",
|
3154
|
+
typeError: true
|
3155
|
+
}])
|
3156
|
+
};
|
2496
3157
|
}
|
2497
3158
|
var schema = this.schema;
|
2498
3159
|
if (!schema) {
|
2499
|
-
return
|
3160
|
+
return {
|
3161
|
+
success: false,
|
3162
|
+
errors: _defineProperty({}, path, [{
|
3163
|
+
message: "Neither key nor schema was found. keyOf is missing an argument.",
|
3164
|
+
typeError: true
|
3165
|
+
}])
|
3166
|
+
};
|
2500
3167
|
}
|
2501
3168
|
var serializedSchema = schema;
|
2502
|
-
if (!(serializedSchema.type === "
|
2503
|
-
return
|
2504
|
-
|
2505
|
-
|
2506
|
-
|
2507
|
-
|
2508
|
-
|
2509
|
-
|
3169
|
+
if (!(serializedSchema.type === "object" || serializedSchema.type === "record")) {
|
3170
|
+
return {
|
3171
|
+
success: false,
|
3172
|
+
errors: _defineProperty({}, path, [{
|
3173
|
+
message: "Schema of first argument must be either: 'array', 'object' or 'record'. Found '".concat(serializedSchema.type, "'"),
|
3174
|
+
typeError: true
|
3175
|
+
}])
|
3176
|
+
};
|
2510
3177
|
}
|
2511
3178
|
if (serializedSchema.type === "record" && typeof src !== "string") {
|
2512
|
-
return
|
3179
|
+
return {
|
3180
|
+
success: false,
|
3181
|
+
errors: _defineProperty({}, path, [{
|
3182
|
+
message: "Value of keyOf (record) must be 'string', got '".concat(_typeof(src), "'"),
|
3183
|
+
typeError: true
|
3184
|
+
}])
|
3185
|
+
};
|
2513
3186
|
}
|
3187
|
+
// We check actual value here, since TypeScript also does this. Literals are used in other types (unions),
|
3188
|
+
// and there it also makes sense to check the actual string values (i.e. that it is not just a string) since
|
3189
|
+
// missing one would lead to a runtime error. At least this is what we are thinking currently.
|
2514
3190
|
if (serializedSchema.type === "object") {
|
2515
3191
|
var keys = Object.keys(serializedSchema.items);
|
2516
3192
|
if (!keys.includes(src)) {
|
2517
|
-
return
|
3193
|
+
return {
|
3194
|
+
success: false,
|
3195
|
+
errors: _defineProperty({}, path, [{
|
3196
|
+
message: "Value of keyOf (object) must be: ".concat(keys.join(", "), ". Found: ").concat(src),
|
3197
|
+
typeError: true
|
3198
|
+
}])
|
3199
|
+
};
|
2518
3200
|
}
|
2519
3201
|
}
|
2520
|
-
return
|
3202
|
+
return {
|
3203
|
+
success: true,
|
3204
|
+
data: src
|
3205
|
+
};
|
2521
3206
|
}
|
2522
3207
|
}, {
|
2523
3208
|
key: "nullable",
|
@@ -2529,7 +3214,7 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
|
2529
3214
|
value: function serialize() {
|
2530
3215
|
var path = this.sourcePath;
|
2531
3216
|
if (!path) {
|
2532
|
-
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.");
|
2533
3218
|
}
|
2534
3219
|
var serializedSchema = this.schema;
|
2535
3220
|
if (!serializedSchema) {
|
@@ -2537,9 +3222,6 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
|
2537
3222
|
}
|
2538
3223
|
var values;
|
2539
3224
|
switch (serializedSchema.type) {
|
2540
|
-
case "array":
|
2541
|
-
values = "number";
|
2542
|
-
break;
|
2543
3225
|
case "record":
|
2544
3226
|
values = "string";
|
2545
3227
|
break;
|
@@ -2558,7 +3240,6 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
|
2558
3240
|
};
|
2559
3241
|
}
|
2560
3242
|
}]);
|
2561
|
-
return KeyOfSchema;
|
2562
3243
|
}(Schema);
|
2563
3244
|
var keyOf = function keyOf(valModule) {
|
2564
3245
|
var _valModule$GetSchema;
|
@@ -2566,19 +3247,17 @@ var keyOf = function keyOf(valModule) {
|
|
2566
3247
|
};
|
2567
3248
|
|
2568
3249
|
var DateSchema = /*#__PURE__*/function (_Schema) {
|
2569
|
-
_inherits(DateSchema, _Schema);
|
2570
3250
|
function DateSchema(options) {
|
2571
3251
|
var _this;
|
2572
3252
|
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
2573
|
-
var isRaw = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
2574
3253
|
_classCallCheck(this, DateSchema);
|
2575
3254
|
_this = _callSuper(this, DateSchema);
|
2576
3255
|
_this.options = options;
|
2577
3256
|
_this.opt = opt;
|
2578
|
-
_this.isRaw = isRaw;
|
2579
3257
|
return _this;
|
2580
3258
|
}
|
2581
|
-
|
3259
|
+
_inherits(DateSchema, _Schema);
|
3260
|
+
return _createClass(DateSchema, [{
|
2582
3261
|
key: "validate",
|
2583
3262
|
value: function validate(path, src) {
|
2584
3263
|
var _this$options, _this$options2, _this$options3, _this$options4;
|
@@ -2596,7 +3275,7 @@ var DateSchema = /*#__PURE__*/function (_Schema) {
|
|
2596
3275
|
return _defineProperty({}, path, [{
|
2597
3276
|
message: "From date ".concat(this.options.from, " is after to date ").concat(this.options.to),
|
2598
3277
|
value: src,
|
2599
|
-
|
3278
|
+
typeError: true
|
2600
3279
|
}]);
|
2601
3280
|
}
|
2602
3281
|
if (src < this.options.from || src > this.options.to) {
|
@@ -2631,30 +3310,54 @@ var DateSchema = /*#__PURE__*/function (_Schema) {
|
|
2631
3310
|
}
|
2632
3311
|
}, {
|
2633
3312
|
key: "assert",
|
2634
|
-
value: function assert(src) {
|
2635
|
-
if (this.opt &&
|
2636
|
-
return
|
3313
|
+
value: function assert(path, src) {
|
3314
|
+
if (this.opt && src === null) {
|
3315
|
+
return {
|
3316
|
+
success: true,
|
3317
|
+
data: src
|
3318
|
+
};
|
3319
|
+
}
|
3320
|
+
if (src === null) {
|
3321
|
+
return {
|
3322
|
+
success: false,
|
3323
|
+
errors: _defineProperty({}, path, [{
|
3324
|
+
message: "Expected 'string', got 'null'",
|
3325
|
+
typeError: true
|
3326
|
+
}])
|
3327
|
+
};
|
3328
|
+
}
|
3329
|
+
if (typeof src !== "string") {
|
3330
|
+
return {
|
3331
|
+
success: false,
|
3332
|
+
errors: _defineProperty({}, path, [{
|
3333
|
+
message: "Expected 'string', got '".concat(_typeof(src), "'"),
|
3334
|
+
typeError: true
|
3335
|
+
}])
|
3336
|
+
};
|
2637
3337
|
}
|
2638
|
-
return
|
3338
|
+
return {
|
3339
|
+
success: true,
|
3340
|
+
data: src
|
3341
|
+
};
|
2639
3342
|
}
|
2640
3343
|
}, {
|
2641
3344
|
key: "from",
|
2642
3345
|
value: function from(_from) {
|
2643
3346
|
return new DateSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
2644
3347
|
from: _from
|
2645
|
-
}), this.opt
|
3348
|
+
}), this.opt);
|
2646
3349
|
}
|
2647
3350
|
}, {
|
2648
3351
|
key: "to",
|
2649
3352
|
value: function to(_to) {
|
2650
3353
|
return new DateSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
2651
3354
|
to: _to
|
2652
|
-
}), this.opt
|
3355
|
+
}), this.opt);
|
2653
3356
|
}
|
2654
3357
|
}, {
|
2655
3358
|
key: "nullable",
|
2656
3359
|
value: function nullable() {
|
2657
|
-
return new DateSchema(this.options, true
|
3360
|
+
return new DateSchema(this.options, true);
|
2658
3361
|
}
|
2659
3362
|
}, {
|
2660
3363
|
key: "serialize",
|
@@ -2666,7 +3369,6 @@ var DateSchema = /*#__PURE__*/function (_Schema) {
|
|
2666
3369
|
};
|
2667
3370
|
}
|
2668
3371
|
}]);
|
2669
|
-
return DateSchema;
|
2670
3372
|
}(Schema);
|
2671
3373
|
var date = function date(options) {
|
2672
3374
|
return new DateSchema(options);
|
@@ -2990,7 +3692,7 @@ var initVal = function initVal(config) {
|
|
2990
3692
|
c: {
|
2991
3693
|
define: define,
|
2992
3694
|
// remote,
|
2993
|
-
file:
|
3695
|
+
file: initFile(config),
|
2994
3696
|
richtext: richtext,
|
2995
3697
|
rt: {
|
2996
3698
|
image: image,
|
@@ -3357,7 +4059,7 @@ var Hash = /*#__PURE__*/function () {
|
|
3357
4059
|
this._word = new Int32Array(sharedBuffer, sharedOffset, N.allocWords);
|
3358
4060
|
sharedOffset += N.allocBytes;
|
3359
4061
|
}
|
3360
|
-
_createClass(Hash, [{
|
4062
|
+
return _createClass(Hash, [{
|
3361
4063
|
key: "update",
|
3362
4064
|
value: function update(data) {
|
3363
4065
|
// data: string
|
@@ -3574,7 +4276,6 @@ var Hash = /*#__PURE__*/function () {
|
|
3574
4276
|
return _byte.slice(0, 32);
|
3575
4277
|
}
|
3576
4278
|
}]);
|
3577
|
-
return Hash;
|
3578
4279
|
}();
|
3579
4280
|
var W = new Int32Array(N.workWords);
|
3580
4281
|
var sharedBuffer;
|
@@ -3615,6 +4316,728 @@ var getSHA256Hash = function getSHA256Hash(bits) {
|
|
3615
4316
|
return createHash().update(bits).digest("hex");
|
3616
4317
|
};
|
3617
4318
|
|
4319
|
+
var EXT_TO_MIME_TYPES = {
|
4320
|
+
x3d: "application/vnd.hzn-3d-crossword",
|
4321
|
+
"3gp": "video/3gpp",
|
4322
|
+
"3g2": "video/3gpp2",
|
4323
|
+
mseq: "application/vnd.mseq",
|
4324
|
+
pwn: "application/vnd.3m.post-it-notes",
|
4325
|
+
plb: "application/vnd.3gpp.pic-bw-large",
|
4326
|
+
psb: "application/vnd.3gpp.pic-bw-small",
|
4327
|
+
pvb: "application/vnd.3gpp.pic-bw-var",
|
4328
|
+
tcap: "application/vnd.3gpp2.tcap",
|
4329
|
+
"7z": "application/x-7z-compressed",
|
4330
|
+
abw: "application/x-abiword",
|
4331
|
+
ace: "application/x-ace-compressed",
|
4332
|
+
acc: "application/vnd.americandynamics.acc",
|
4333
|
+
acu: "application/vnd.acucobol",
|
4334
|
+
atc: "application/vnd.acucorp",
|
4335
|
+
adp: "audio/adpcm",
|
4336
|
+
aab: "application/x-authorware-bin",
|
4337
|
+
aam: "application/x-authorware-map",
|
4338
|
+
aas: "application/x-authorware-seg",
|
4339
|
+
air: "application/vnd.adobe.air-application-installer-package+zip",
|
4340
|
+
swf: "application/x-shockwave-flash",
|
4341
|
+
fxp: "application/vnd.adobe.fxp",
|
4342
|
+
pdf: "application/pdf",
|
4343
|
+
ppd: "application/vnd.cups-ppd",
|
4344
|
+
dir: "application/x-director",
|
4345
|
+
xdp: "application/vnd.adobe.xdp+xml",
|
4346
|
+
xfdf: "application/vnd.adobe.xfdf",
|
4347
|
+
aac: "audio/x-aac",
|
4348
|
+
ahead: "application/vnd.ahead.space",
|
4349
|
+
azf: "application/vnd.airzip.filesecure.azf",
|
4350
|
+
azs: "application/vnd.airzip.filesecure.azs",
|
4351
|
+
azw: "application/vnd.amazon.ebook",
|
4352
|
+
ami: "application/vnd.amiga.ami",
|
4353
|
+
"N/A": "application/andrew-inset",
|
4354
|
+
apk: "application/vnd.android.package-archive",
|
4355
|
+
cii: "application/vnd.anser-web-certificate-issue-initiation",
|
4356
|
+
fti: "application/vnd.anser-web-funds-transfer-initiation",
|
4357
|
+
atx: "application/vnd.antix.game-component",
|
4358
|
+
dmg: "application/x-apple-diskimage",
|
4359
|
+
mpkg: "application/vnd.apple.installer+xml",
|
4360
|
+
aw: "application/applixware",
|
4361
|
+
mp3: "audio/mpeg",
|
4362
|
+
les: "application/vnd.hhe.lesson-player",
|
4363
|
+
swi: "application/vnd.aristanetworks.swi",
|
4364
|
+
s: "text/x-asm",
|
4365
|
+
atomcat: "application/atomcat+xml",
|
4366
|
+
atomsvc: "application/atomsvc+xml",
|
4367
|
+
atom: "application/atom+xml",
|
4368
|
+
ac: "application/pkix-attr-cert",
|
4369
|
+
aif: "audio/x-aiff",
|
4370
|
+
avi: "video/x-msvideo",
|
4371
|
+
aep: "application/vnd.audiograph",
|
4372
|
+
dxf: "image/vnd.dxf",
|
4373
|
+
dwf: "model/vnd.dwf",
|
4374
|
+
par: "text/plain-bas",
|
4375
|
+
bcpio: "application/x-bcpio",
|
4376
|
+
bin: "application/octet-stream",
|
4377
|
+
bmp: "image/bmp",
|
4378
|
+
torrent: "application/x-bittorrent",
|
4379
|
+
cod: "application/vnd.rim.cod",
|
4380
|
+
mpm: "application/vnd.blueice.multipass",
|
4381
|
+
bmi: "application/vnd.bmi",
|
4382
|
+
sh: "application/x-sh",
|
4383
|
+
btif: "image/prs.btif",
|
4384
|
+
rep: "application/vnd.businessobjects",
|
4385
|
+
bz: "application/x-bzip",
|
4386
|
+
bz2: "application/x-bzip2",
|
4387
|
+
csh: "application/x-csh",
|
4388
|
+
c: "text/x-c",
|
4389
|
+
cdxml: "application/vnd.chemdraw+xml",
|
4390
|
+
css: "text/css",
|
4391
|
+
cdx: "chemical/x-cdx",
|
4392
|
+
cml: "chemical/x-cml",
|
4393
|
+
csml: "chemical/x-csml",
|
4394
|
+
cdbcmsg: "application/vnd.contact.cmsg",
|
4395
|
+
cla: "application/vnd.claymore",
|
4396
|
+
c4g: "application/vnd.clonk.c4group",
|
4397
|
+
sub: "image/vnd.dvb.subtitle",
|
4398
|
+
cdmia: "application/cdmi-capability",
|
4399
|
+
cdmic: "application/cdmi-container",
|
4400
|
+
cdmid: "application/cdmi-domain",
|
4401
|
+
cdmio: "application/cdmi-object",
|
4402
|
+
cdmiq: "application/cdmi-queue",
|
4403
|
+
c11amc: "application/vnd.cluetrust.cartomobile-config",
|
4404
|
+
c11amz: "application/vnd.cluetrust.cartomobile-config-pkg",
|
4405
|
+
ras: "image/x-cmu-raster",
|
4406
|
+
dae: "model/vnd.collada+xml",
|
4407
|
+
csv: "text/csv",
|
4408
|
+
cpt: "application/mac-compactpro",
|
4409
|
+
wmlc: "application/vnd.wap.wmlc",
|
4410
|
+
cgm: "image/cgm",
|
4411
|
+
ice: "x-conference/x-cooltalk",
|
4412
|
+
cmx: "image/x-cmx",
|
4413
|
+
xar: "application/vnd.xara",
|
4414
|
+
cmc: "application/vnd.cosmocaller",
|
4415
|
+
cpio: "application/x-cpio",
|
4416
|
+
clkx: "application/vnd.crick.clicker",
|
4417
|
+
clkk: "application/vnd.crick.clicker.keyboard",
|
4418
|
+
clkp: "application/vnd.crick.clicker.palette",
|
4419
|
+
clkt: "application/vnd.crick.clicker.template",
|
4420
|
+
clkw: "application/vnd.crick.clicker.wordbank",
|
4421
|
+
wbs: "application/vnd.criticaltools.wbs+xml",
|
4422
|
+
cryptonote: "application/vnd.rig.cryptonote",
|
4423
|
+
cif: "chemical/x-cif",
|
4424
|
+
cmdf: "chemical/x-cmdf",
|
4425
|
+
cu: "application/cu-seeme",
|
4426
|
+
cww: "application/prs.cww",
|
4427
|
+
curl: "text/vnd.curl",
|
4428
|
+
dcurl: "text/vnd.curl.dcurl",
|
4429
|
+
mcurl: "text/vnd.curl.mcurl",
|
4430
|
+
scurl: "text/vnd.curl.scurl",
|
4431
|
+
car: "application/vnd.curl.car",
|
4432
|
+
pcurl: "application/vnd.curl.pcurl",
|
4433
|
+
cmp: "application/vnd.yellowriver-custom-menu",
|
4434
|
+
dssc: "application/dssc+der",
|
4435
|
+
xdssc: "application/dssc+xml",
|
4436
|
+
deb: "application/x-debian-package",
|
4437
|
+
uva: "audio/vnd.dece.audio",
|
4438
|
+
uvi: "image/vnd.dece.graphic",
|
4439
|
+
uvh: "video/vnd.dece.hd",
|
4440
|
+
uvm: "video/vnd.dece.mobile",
|
4441
|
+
uvu: "video/vnd.uvvu.mp4",
|
4442
|
+
uvp: "video/vnd.dece.pd",
|
4443
|
+
uvs: "video/vnd.dece.sd",
|
4444
|
+
uvv: "video/vnd.dece.video",
|
4445
|
+
dvi: "application/x-dvi",
|
4446
|
+
seed: "application/vnd.fdsn.seed",
|
4447
|
+
dtb: "application/x-dtbook+xml",
|
4448
|
+
res: "application/x-dtbresource+xml",
|
4449
|
+
ait: "application/vnd.dvb.ait",
|
4450
|
+
svc: "application/vnd.dvb.service",
|
4451
|
+
eol: "audio/vnd.digital-winds",
|
4452
|
+
djvu: "image/vnd.djvu",
|
4453
|
+
dtd: "application/xml-dtd",
|
4454
|
+
mlp: "application/vnd.dolby.mlp",
|
4455
|
+
wad: "application/x-doom",
|
4456
|
+
dpg: "application/vnd.dpgraph",
|
4457
|
+
dra: "audio/vnd.dra",
|
4458
|
+
dfac: "application/vnd.dreamfactory",
|
4459
|
+
dts: "audio/vnd.dts",
|
4460
|
+
dtshd: "audio/vnd.dts.hd",
|
4461
|
+
dwg: "image/vnd.dwg",
|
4462
|
+
geo: "application/vnd.dynageo",
|
4463
|
+
es: "application/ecmascript",
|
4464
|
+
mag: "application/vnd.ecowin.chart",
|
4465
|
+
mmr: "image/vnd.fujixerox.edmics-mmr",
|
4466
|
+
rlc: "image/vnd.fujixerox.edmics-rlc",
|
4467
|
+
exi: "application/exi",
|
4468
|
+
mgz: "application/vnd.proteus.magazine",
|
4469
|
+
epub: "application/epub+zip",
|
4470
|
+
eml: "message/rfc822",
|
4471
|
+
nml: "application/vnd.enliven",
|
4472
|
+
xpr: "application/vnd.is-xpr",
|
4473
|
+
xif: "image/vnd.xiff",
|
4474
|
+
xfdl: "application/vnd.xfdl",
|
4475
|
+
emma: "application/emma+xml",
|
4476
|
+
ez2: "application/vnd.ezpix-album",
|
4477
|
+
ez3: "application/vnd.ezpix-package",
|
4478
|
+
fst: "image/vnd.fst",
|
4479
|
+
fvt: "video/vnd.fvt",
|
4480
|
+
fbs: "image/vnd.fastbidsheet",
|
4481
|
+
fe_launch: "application/vnd.denovo.fcselayout-link",
|
4482
|
+
f4v: "video/x-f4v",
|
4483
|
+
flv: "video/x-flv",
|
4484
|
+
fpx: "image/vnd.fpx",
|
4485
|
+
npx: "image/vnd.net-fpx",
|
4486
|
+
flx: "text/vnd.fmi.flexstor",
|
4487
|
+
fli: "video/x-fli",
|
4488
|
+
ftc: "application/vnd.fluxtime.clip",
|
4489
|
+
fdf: "application/vnd.fdf",
|
4490
|
+
f: "text/x-fortran",
|
4491
|
+
mif: "application/vnd.mif",
|
4492
|
+
fm: "application/vnd.framemaker",
|
4493
|
+
fh: "image/x-freehand",
|
4494
|
+
fsc: "application/vnd.fsc.weblaunch",
|
4495
|
+
fnc: "application/vnd.frogans.fnc",
|
4496
|
+
ltf: "application/vnd.frogans.ltf",
|
4497
|
+
ddd: "application/vnd.fujixerox.ddd",
|
4498
|
+
xdw: "application/vnd.fujixerox.docuworks",
|
4499
|
+
xbd: "application/vnd.fujixerox.docuworks.binder",
|
4500
|
+
oas: "application/vnd.fujitsu.oasys",
|
4501
|
+
oa2: "application/vnd.fujitsu.oasys2",
|
4502
|
+
oa3: "application/vnd.fujitsu.oasys3",
|
4503
|
+
fg5: "application/vnd.fujitsu.oasysgp",
|
4504
|
+
bh2: "application/vnd.fujitsu.oasysprs",
|
4505
|
+
spl: "application/x-futuresplash",
|
4506
|
+
fzs: "application/vnd.fuzzysheet",
|
4507
|
+
g3: "image/g3fax",
|
4508
|
+
gmx: "application/vnd.gmx",
|
4509
|
+
gtw: "model/vnd.gtw",
|
4510
|
+
txd: "application/vnd.genomatix.tuxedo",
|
4511
|
+
ggb: "application/vnd.geogebra.file",
|
4512
|
+
ggt: "application/vnd.geogebra.tool",
|
4513
|
+
gdl: "model/vnd.gdl",
|
4514
|
+
gex: "application/vnd.geometry-explorer",
|
4515
|
+
gxt: "application/vnd.geonext",
|
4516
|
+
g2w: "application/vnd.geoplan",
|
4517
|
+
g3w: "application/vnd.geospace",
|
4518
|
+
gsf: "application/x-font-ghostscript",
|
4519
|
+
bdf: "application/x-font-bdf",
|
4520
|
+
gtar: "application/x-gtar",
|
4521
|
+
texinfo: "application/x-texinfo",
|
4522
|
+
gnumeric: "application/x-gnumeric",
|
4523
|
+
kml: "application/vnd.google-earth.kml+xml",
|
4524
|
+
kmz: "application/vnd.google-earth.kmz",
|
4525
|
+
gqf: "application/vnd.grafeq",
|
4526
|
+
gif: "image/gif",
|
4527
|
+
gv: "text/vnd.graphviz",
|
4528
|
+
gac: "application/vnd.groove-account",
|
4529
|
+
ghf: "application/vnd.groove-help",
|
4530
|
+
gim: "application/vnd.groove-identity-message",
|
4531
|
+
grv: "application/vnd.groove-injector",
|
4532
|
+
gtm: "application/vnd.groove-tool-message",
|
4533
|
+
tpl: "application/vnd.groove-tool-template",
|
4534
|
+
vcg: "application/vnd.groove-vcard",
|
4535
|
+
h261: "video/h261",
|
4536
|
+
h263: "video/h263",
|
4537
|
+
h264: "video/h264",
|
4538
|
+
hpid: "application/vnd.hp-hpid",
|
4539
|
+
hps: "application/vnd.hp-hps",
|
4540
|
+
hdf: "application/x-hdf",
|
4541
|
+
rip: "audio/vnd.rip",
|
4542
|
+
hbci: "application/vnd.hbci",
|
4543
|
+
jlt: "application/vnd.hp-jlyt",
|
4544
|
+
pcl: "application/vnd.hp-pcl",
|
4545
|
+
hpgl: "application/vnd.hp-hpgl",
|
4546
|
+
hvs: "application/vnd.yamaha.hv-script",
|
4547
|
+
hvd: "application/vnd.yamaha.hv-dic",
|
4548
|
+
hvp: "application/vnd.yamaha.hv-voice",
|
4549
|
+
"sfd-hdstx": "application/vnd.hydrostatix.sof-data",
|
4550
|
+
stk: "application/hyperstudio",
|
4551
|
+
hal: "application/vnd.hal+xml",
|
4552
|
+
html: "text/html",
|
4553
|
+
irm: "application/vnd.ibm.rights-management",
|
4554
|
+
sc: "application/vnd.ibm.secure-container",
|
4555
|
+
ics: "text/calendar",
|
4556
|
+
icc: "application/vnd.iccprofile",
|
4557
|
+
ico: "image/x-icon",
|
4558
|
+
igl: "application/vnd.igloader",
|
4559
|
+
ief: "image/ief",
|
4560
|
+
ivp: "application/vnd.immervision-ivp",
|
4561
|
+
ivu: "application/vnd.immervision-ivu",
|
4562
|
+
rif: "application/reginfo+xml",
|
4563
|
+
"3dml": "text/vnd.in3d.3dml",
|
4564
|
+
spot: "text/vnd.in3d.spot",
|
4565
|
+
igs: "model/iges",
|
4566
|
+
i2g: "application/vnd.intergeo",
|
4567
|
+
cdy: "application/vnd.cinderella",
|
4568
|
+
xpw: "application/vnd.intercon.formnet",
|
4569
|
+
fcs: "application/vnd.isac.fcs",
|
4570
|
+
ipfix: "application/ipfix",
|
4571
|
+
cer: "application/pkix-cert",
|
4572
|
+
pki: "application/pkixcmp",
|
4573
|
+
crl: "application/pkix-crl",
|
4574
|
+
pkipath: "application/pkix-pkipath",
|
4575
|
+
igm: "application/vnd.insors.igm",
|
4576
|
+
rcprofile: "application/vnd.ipunplugged.rcprofile",
|
4577
|
+
irp: "application/vnd.irepository.package+xml",
|
4578
|
+
jad: "text/vnd.sun.j2me.app-descriptor",
|
4579
|
+
jar: "application/java-archive",
|
4580
|
+
"class": "application/java-vm",
|
4581
|
+
jnlp: "application/x-java-jnlp-file",
|
4582
|
+
ser: "application/java-serialized-object",
|
4583
|
+
java: "text/x-java-source,java",
|
4584
|
+
js: "application/javascript",
|
4585
|
+
json: "application/json",
|
4586
|
+
joda: "application/vnd.joost.joda-archive",
|
4587
|
+
jpm: "video/jpm",
|
4588
|
+
jpeg: "image/jpeg",
|
4589
|
+
jpg: "image/jpeg",
|
4590
|
+
pjpeg: "image/pjpeg",
|
4591
|
+
jpgv: "video/jpeg",
|
4592
|
+
ktz: "application/vnd.kahootz",
|
4593
|
+
mmd: "application/vnd.chipnuts.karaoke-mmd",
|
4594
|
+
karbon: "application/vnd.kde.karbon",
|
4595
|
+
chrt: "application/vnd.kde.kchart",
|
4596
|
+
kfo: "application/vnd.kde.kformula",
|
4597
|
+
flw: "application/vnd.kde.kivio",
|
4598
|
+
kon: "application/vnd.kde.kontour",
|
4599
|
+
kpr: "application/vnd.kde.kpresenter",
|
4600
|
+
ksp: "application/vnd.kde.kspread",
|
4601
|
+
kwd: "application/vnd.kde.kword",
|
4602
|
+
htke: "application/vnd.kenameaapp",
|
4603
|
+
kia: "application/vnd.kidspiration",
|
4604
|
+
kne: "application/vnd.kinar",
|
4605
|
+
sse: "application/vnd.kodak-descriptor",
|
4606
|
+
lasxml: "application/vnd.las.las+xml",
|
4607
|
+
latex: "application/x-latex",
|
4608
|
+
lbd: "application/vnd.llamagraphics.life-balance.desktop",
|
4609
|
+
lbe: "application/vnd.llamagraphics.life-balance.exchange+xml",
|
4610
|
+
jam: "application/vnd.jam",
|
4611
|
+
"123": "application/vnd.lotus-1-2-3",
|
4612
|
+
apr: "application/vnd.lotus-approach",
|
4613
|
+
pre: "application/vnd.lotus-freelance",
|
4614
|
+
nsf: "application/vnd.lotus-notes",
|
4615
|
+
org: "application/vnd.lotus-organizer",
|
4616
|
+
scm: "application/vnd.lotus-screencam",
|
4617
|
+
lwp: "application/vnd.lotus-wordpro",
|
4618
|
+
lvp: "audio/vnd.lucent.voice",
|
4619
|
+
m3u: "audio/x-mpegurl",
|
4620
|
+
m4v: "video/x-m4v",
|
4621
|
+
hqx: "application/mac-binhex40",
|
4622
|
+
portpkg: "application/vnd.macports.portpkg",
|
4623
|
+
mgp: "application/vnd.osgeo.mapguide.package",
|
4624
|
+
mrc: "application/marc",
|
4625
|
+
mrcx: "application/marcxml+xml",
|
4626
|
+
mxf: "application/mxf",
|
4627
|
+
nbp: "application/vnd.wolfram.player",
|
4628
|
+
ma: "application/mathematica",
|
4629
|
+
mathml: "application/mathml+xml",
|
4630
|
+
mbox: "application/mbox",
|
4631
|
+
mc1: "application/vnd.medcalcdata",
|
4632
|
+
mscml: "application/mediaservercontrol+xml",
|
4633
|
+
cdkey: "application/vnd.mediastation.cdkey",
|
4634
|
+
mwf: "application/vnd.mfer",
|
4635
|
+
mfm: "application/vnd.mfmp",
|
4636
|
+
msh: "model/mesh",
|
4637
|
+
mads: "application/mads+xml",
|
4638
|
+
mets: "application/mets+xml",
|
4639
|
+
mods: "application/mods+xml",
|
4640
|
+
meta4: "application/metalink4+xml",
|
4641
|
+
mcd: "application/vnd.mcd",
|
4642
|
+
flo: "application/vnd.micrografx.flo",
|
4643
|
+
igx: "application/vnd.micrografx.igx",
|
4644
|
+
es3: "application/vnd.eszigno3+xml",
|
4645
|
+
mdb: "application/x-msaccess",
|
4646
|
+
asf: "video/x-ms-asf",
|
4647
|
+
exe: "application/x-msdownload",
|
4648
|
+
cil: "application/vnd.ms-artgalry",
|
4649
|
+
cab: "application/vnd.ms-cab-compressed",
|
4650
|
+
ims: "application/vnd.ms-ims",
|
4651
|
+
application: "application/x-ms-application",
|
4652
|
+
clp: "application/x-msclip",
|
4653
|
+
mdi: "image/vnd.ms-modi",
|
4654
|
+
eot: "application/vnd.ms-fontobject",
|
4655
|
+
xls: "application/vnd.ms-excel",
|
4656
|
+
xlam: "application/vnd.ms-excel.addin.macroenabled.12",
|
4657
|
+
xlsb: "application/vnd.ms-excel.sheet.binary.macroenabled.12",
|
4658
|
+
xltm: "application/vnd.ms-excel.template.macroenabled.12",
|
4659
|
+
xlsm: "application/vnd.ms-excel.sheet.macroenabled.12",
|
4660
|
+
chm: "application/vnd.ms-htmlhelp",
|
4661
|
+
crd: "application/x-mscardfile",
|
4662
|
+
lrm: "application/vnd.ms-lrm",
|
4663
|
+
mvb: "application/x-msmediaview",
|
4664
|
+
mny: "application/x-msmoney",
|
4665
|
+
pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
4666
|
+
sldx: "application/vnd.openxmlformats-officedocument.presentationml.slide",
|
4667
|
+
ppsx: "application/vnd.openxmlformats-officedocument.presentationml.slideshow",
|
4668
|
+
potx: "application/vnd.openxmlformats-officedocument.presentationml.template",
|
4669
|
+
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
4670
|
+
xltx: "application/vnd.openxmlformats-officedocument.spreadsheetml.template",
|
4671
|
+
docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
4672
|
+
dotx: "application/vnd.openxmlformats-officedocument.wordprocessingml.template",
|
4673
|
+
obd: "application/x-msbinder",
|
4674
|
+
thmx: "application/vnd.ms-officetheme",
|
4675
|
+
onetoc: "application/onenote",
|
4676
|
+
pya: "audio/vnd.ms-playready.media.pya",
|
4677
|
+
pyv: "video/vnd.ms-playready.media.pyv",
|
4678
|
+
ppt: "application/vnd.ms-powerpoint",
|
4679
|
+
ppam: "application/vnd.ms-powerpoint.addin.macroenabled.12",
|
4680
|
+
sldm: "application/vnd.ms-powerpoint.slide.macroenabled.12",
|
4681
|
+
pptm: "application/vnd.ms-powerpoint.presentation.macroenabled.12",
|
4682
|
+
ppsm: "application/vnd.ms-powerpoint.slideshow.macroenabled.12",
|
4683
|
+
potm: "application/vnd.ms-powerpoint.template.macroenabled.12",
|
4684
|
+
mpp: "application/vnd.ms-project",
|
4685
|
+
pub: "application/x-mspublisher",
|
4686
|
+
scd: "application/x-msschedule",
|
4687
|
+
xap: "application/x-silverlight-app",
|
4688
|
+
stl: "application/vnd.ms-pki.stl",
|
4689
|
+
cat: "application/vnd.ms-pki.seccat",
|
4690
|
+
vsd: "application/vnd.visio",
|
4691
|
+
vsdx: "application/vnd.visio2013",
|
4692
|
+
wm: "video/x-ms-wm",
|
4693
|
+
wma: "audio/x-ms-wma",
|
4694
|
+
wax: "audio/x-ms-wax",
|
4695
|
+
wmx: "video/x-ms-wmx",
|
4696
|
+
wmd: "application/x-ms-wmd",
|
4697
|
+
wpl: "application/vnd.ms-wpl",
|
4698
|
+
wmz: "application/x-ms-wmz",
|
4699
|
+
wmv: "video/x-ms-wmv",
|
4700
|
+
wvx: "video/x-ms-wvx",
|
4701
|
+
wmf: "application/x-msmetafile",
|
4702
|
+
trm: "application/x-msterminal",
|
4703
|
+
doc: "application/msword",
|
4704
|
+
docm: "application/vnd.ms-word.document.macroenabled.12",
|
4705
|
+
dotm: "application/vnd.ms-word.template.macroenabled.12",
|
4706
|
+
wri: "application/x-mswrite",
|
4707
|
+
wps: "application/vnd.ms-works",
|
4708
|
+
xbap: "application/x-ms-xbap",
|
4709
|
+
xps: "application/vnd.ms-xpsdocument",
|
4710
|
+
mid: "audio/midi",
|
4711
|
+
mpy: "application/vnd.ibm.minipay",
|
4712
|
+
afp: "application/vnd.ibm.modcap",
|
4713
|
+
rms: "application/vnd.jcp.javame.midlet-rms",
|
4714
|
+
tmo: "application/vnd.tmobile-livetv",
|
4715
|
+
prc: "application/x-mobipocket-ebook",
|
4716
|
+
mbk: "application/vnd.mobius.mbk",
|
4717
|
+
dis: "application/vnd.mobius.dis",
|
4718
|
+
plc: "application/vnd.mobius.plc",
|
4719
|
+
mqy: "application/vnd.mobius.mqy",
|
4720
|
+
msl: "application/vnd.mobius.msl",
|
4721
|
+
txf: "application/vnd.mobius.txf",
|
4722
|
+
daf: "application/vnd.mobius.daf",
|
4723
|
+
fly: "text/vnd.fly",
|
4724
|
+
mpc: "application/vnd.mophun.certificate",
|
4725
|
+
mpn: "application/vnd.mophun.application",
|
4726
|
+
mj2: "video/mj2",
|
4727
|
+
mpga: "audio/mpeg",
|
4728
|
+
mxu: "video/vnd.mpegurl",
|
4729
|
+
mpeg: "video/mpeg",
|
4730
|
+
m21: "application/mp21",
|
4731
|
+
mp4a: "audio/mp4",
|
4732
|
+
mp4: "video/mp4",
|
4733
|
+
m3u8: "application/vnd.apple.mpegurl",
|
4734
|
+
mus: "application/vnd.musician",
|
4735
|
+
msty: "application/vnd.muvee.style",
|
4736
|
+
mxml: "application/xv+xml",
|
4737
|
+
ngdat: "application/vnd.nokia.n-gage.data",
|
4738
|
+
"n-gage": "application/vnd.nokia.n-gage.symbian.install",
|
4739
|
+
ncx: "application/x-dtbncx+xml",
|
4740
|
+
nc: "application/x-netcdf",
|
4741
|
+
nlu: "application/vnd.neurolanguage.nlu",
|
4742
|
+
dna: "application/vnd.dna",
|
4743
|
+
nnd: "application/vnd.noblenet-directory",
|
4744
|
+
nns: "application/vnd.noblenet-sealer",
|
4745
|
+
nnw: "application/vnd.noblenet-web",
|
4746
|
+
rpst: "application/vnd.nokia.radio-preset",
|
4747
|
+
rpss: "application/vnd.nokia.radio-presets",
|
4748
|
+
n3: "text/n3",
|
4749
|
+
edm: "application/vnd.novadigm.edm",
|
4750
|
+
edx: "application/vnd.novadigm.edx",
|
4751
|
+
ext: "application/vnd.novadigm.ext",
|
4752
|
+
gph: "application/vnd.flographit",
|
4753
|
+
ecelp4800: "audio/vnd.nuera.ecelp4800",
|
4754
|
+
ecelp7470: "audio/vnd.nuera.ecelp7470",
|
4755
|
+
ecelp9600: "audio/vnd.nuera.ecelp9600",
|
4756
|
+
oda: "application/oda",
|
4757
|
+
ogx: "application/ogg",
|
4758
|
+
oga: "audio/ogg",
|
4759
|
+
ogv: "video/ogg",
|
4760
|
+
dd2: "application/vnd.oma.dd2+xml",
|
4761
|
+
oth: "application/vnd.oasis.opendocument.text-web",
|
4762
|
+
opf: "application/oebps-package+xml",
|
4763
|
+
qbo: "application/vnd.intu.qbo",
|
4764
|
+
oxt: "application/vnd.openofficeorg.extension",
|
4765
|
+
osf: "application/vnd.yamaha.openscoreformat",
|
4766
|
+
weba: "audio/webm",
|
4767
|
+
webm: "video/webm",
|
4768
|
+
odc: "application/vnd.oasis.opendocument.chart",
|
4769
|
+
otc: "application/vnd.oasis.opendocument.chart-template",
|
4770
|
+
odb: "application/vnd.oasis.opendocument.database",
|
4771
|
+
odf: "application/vnd.oasis.opendocument.formula",
|
4772
|
+
odft: "application/vnd.oasis.opendocument.formula-template",
|
4773
|
+
odg: "application/vnd.oasis.opendocument.graphics",
|
4774
|
+
otg: "application/vnd.oasis.opendocument.graphics-template",
|
4775
|
+
odi: "application/vnd.oasis.opendocument.image",
|
4776
|
+
oti: "application/vnd.oasis.opendocument.image-template",
|
4777
|
+
odp: "application/vnd.oasis.opendocument.presentation",
|
4778
|
+
otp: "application/vnd.oasis.opendocument.presentation-template",
|
4779
|
+
ods: "application/vnd.oasis.opendocument.spreadsheet",
|
4780
|
+
ots: "application/vnd.oasis.opendocument.spreadsheet-template",
|
4781
|
+
odt: "application/vnd.oasis.opendocument.text",
|
4782
|
+
odm: "application/vnd.oasis.opendocument.text-master",
|
4783
|
+
ott: "application/vnd.oasis.opendocument.text-template",
|
4784
|
+
ktx: "image/ktx",
|
4785
|
+
sxc: "application/vnd.sun.xml.calc",
|
4786
|
+
stc: "application/vnd.sun.xml.calc.template",
|
4787
|
+
sxd: "application/vnd.sun.xml.draw",
|
4788
|
+
std: "application/vnd.sun.xml.draw.template",
|
4789
|
+
sxi: "application/vnd.sun.xml.impress",
|
4790
|
+
sti: "application/vnd.sun.xml.impress.template",
|
4791
|
+
sxm: "application/vnd.sun.xml.math",
|
4792
|
+
sxw: "application/vnd.sun.xml.writer",
|
4793
|
+
sxg: "application/vnd.sun.xml.writer.global",
|
4794
|
+
stw: "application/vnd.sun.xml.writer.template",
|
4795
|
+
otf: "application/x-font-otf",
|
4796
|
+
osfpvg: "application/vnd.yamaha.openscoreformat.osfpvg+xml",
|
4797
|
+
dp: "application/vnd.osgi.dp",
|
4798
|
+
pdb: "application/vnd.palm",
|
4799
|
+
p: "text/x-pascal",
|
4800
|
+
paw: "application/vnd.pawaafile",
|
4801
|
+
pclxl: "application/vnd.hp-pclxl",
|
4802
|
+
efif: "application/vnd.picsel",
|
4803
|
+
pcx: "image/x-pcx",
|
4804
|
+
psd: "image/vnd.adobe.photoshop",
|
4805
|
+
prf: "application/pics-rules",
|
4806
|
+
pic: "image/x-pict",
|
4807
|
+
chat: "application/x-chat",
|
4808
|
+
p10: "application/pkcs10",
|
4809
|
+
p12: "application/x-pkcs12",
|
4810
|
+
p7m: "application/pkcs7-mime",
|
4811
|
+
p7s: "application/pkcs7-signature",
|
4812
|
+
p7r: "application/x-pkcs7-certreqresp",
|
4813
|
+
p7b: "application/x-pkcs7-certificates",
|
4814
|
+
p8: "application/pkcs8",
|
4815
|
+
plf: "application/vnd.pocketlearn",
|
4816
|
+
pnm: "image/x-portable-anymap",
|
4817
|
+
pbm: "image/x-portable-bitmap",
|
4818
|
+
pcf: "application/x-font-pcf",
|
4819
|
+
pfr: "application/font-tdpfr",
|
4820
|
+
pgn: "application/x-chess-pgn",
|
4821
|
+
pgm: "image/x-portable-graymap",
|
4822
|
+
png: "image/png",
|
4823
|
+
ppm: "image/x-portable-pixmap",
|
4824
|
+
pskcxml: "application/pskc+xml",
|
4825
|
+
pml: "application/vnd.ctc-posml",
|
4826
|
+
ai: "application/postscript",
|
4827
|
+
pfa: "application/x-font-type1",
|
4828
|
+
pbd: "application/vnd.powerbuilder6",
|
4829
|
+
pgp: "application/pgp-signature",
|
4830
|
+
box: "application/vnd.previewsystems.box",
|
4831
|
+
ptid: "application/vnd.pvi.ptid1",
|
4832
|
+
pls: "application/pls+xml",
|
4833
|
+
str: "application/vnd.pg.format",
|
4834
|
+
ei6: "application/vnd.pg.osasli",
|
4835
|
+
dsc: "text/prs.lines.tag",
|
4836
|
+
psf: "application/x-font-linux-psf",
|
4837
|
+
qps: "application/vnd.publishare-delta-tree",
|
4838
|
+
wg: "application/vnd.pmi.widget",
|
4839
|
+
qxd: "application/vnd.quark.quarkxpress",
|
4840
|
+
esf: "application/vnd.epson.esf",
|
4841
|
+
msf: "application/vnd.epson.msf",
|
4842
|
+
ssf: "application/vnd.epson.ssf",
|
4843
|
+
qam: "application/vnd.epson.quickanime",
|
4844
|
+
qfx: "application/vnd.intu.qfx",
|
4845
|
+
qt: "video/quicktime",
|
4846
|
+
rar: "application/x-rar-compressed",
|
4847
|
+
ram: "audio/x-pn-realaudio",
|
4848
|
+
rmp: "audio/x-pn-realaudio-plugin",
|
4849
|
+
rsd: "application/rsd+xml",
|
4850
|
+
rm: "application/vnd.rn-realmedia",
|
4851
|
+
bed: "application/vnd.realvnc.bed",
|
4852
|
+
mxl: "application/vnd.recordare.musicxml",
|
4853
|
+
musicxml: "application/vnd.recordare.musicxml+xml",
|
4854
|
+
rnc: "application/relax-ng-compact-syntax",
|
4855
|
+
rdz: "application/vnd.data-vision.rdz",
|
4856
|
+
rdf: "application/rdf+xml",
|
4857
|
+
rp9: "application/vnd.cloanto.rp9",
|
4858
|
+
jisp: "application/vnd.jisp",
|
4859
|
+
rtf: "application/rtf",
|
4860
|
+
rtx: "text/richtext",
|
4861
|
+
link66: "application/vnd.route66.link66+xml",
|
4862
|
+
rss: "application/rss+xml",
|
4863
|
+
shf: "application/shf+xml",
|
4864
|
+
st: "application/vnd.sailingtracker.track",
|
4865
|
+
svg: "image/svg+xml",
|
4866
|
+
sus: "application/vnd.sus-calendar",
|
4867
|
+
sru: "application/sru+xml",
|
4868
|
+
setpay: "application/set-payment-initiation",
|
4869
|
+
setreg: "application/set-registration-initiation",
|
4870
|
+
sema: "application/vnd.sema",
|
4871
|
+
semd: "application/vnd.semd",
|
4872
|
+
semf: "application/vnd.semf",
|
4873
|
+
see: "application/vnd.seemail",
|
4874
|
+
snf: "application/x-font-snf",
|
4875
|
+
spq: "application/scvp-vp-request",
|
4876
|
+
spp: "application/scvp-vp-response",
|
4877
|
+
scq: "application/scvp-cv-request",
|
4878
|
+
scs: "application/scvp-cv-response",
|
4879
|
+
sdp: "application/sdp",
|
4880
|
+
etx: "text/x-setext",
|
4881
|
+
movie: "video/x-sgi-movie",
|
4882
|
+
ifm: "application/vnd.shana.informed.formdata",
|
4883
|
+
itp: "application/vnd.shana.informed.formtemplate",
|
4884
|
+
iif: "application/vnd.shana.informed.interchange",
|
4885
|
+
ipk: "application/vnd.shana.informed.package",
|
4886
|
+
tfi: "application/thraud+xml",
|
4887
|
+
shar: "application/x-shar",
|
4888
|
+
rgb: "image/x-rgb",
|
4889
|
+
slt: "application/vnd.epson.salt",
|
4890
|
+
aso: "application/vnd.accpac.simply.aso",
|
4891
|
+
imp: "application/vnd.accpac.simply.imp",
|
4892
|
+
twd: "application/vnd.simtech-mindmapper",
|
4893
|
+
csp: "application/vnd.commonspace",
|
4894
|
+
saf: "application/vnd.yamaha.smaf-audio",
|
4895
|
+
mmf: "application/vnd.smaf",
|
4896
|
+
spf: "application/vnd.yamaha.smaf-phrase",
|
4897
|
+
teacher: "application/vnd.smart.teacher",
|
4898
|
+
svd: "application/vnd.svd",
|
4899
|
+
rq: "application/sparql-query",
|
4900
|
+
srx: "application/sparql-results+xml",
|
4901
|
+
gram: "application/srgs",
|
4902
|
+
grxml: "application/srgs+xml",
|
4903
|
+
ssml: "application/ssml+xml",
|
4904
|
+
skp: "application/vnd.koan",
|
4905
|
+
sgml: "text/sgml",
|
4906
|
+
sdc: "application/vnd.stardivision.calc",
|
4907
|
+
sda: "application/vnd.stardivision.draw",
|
4908
|
+
sdd: "application/vnd.stardivision.impress",
|
4909
|
+
smf: "application/vnd.stardivision.math",
|
4910
|
+
sdw: "application/vnd.stardivision.writer",
|
4911
|
+
sgl: "application/vnd.stardivision.writer-global",
|
4912
|
+
sm: "application/vnd.stepmania.stepchart",
|
4913
|
+
sit: "application/x-stuffit",
|
4914
|
+
sitx: "application/x-stuffitx",
|
4915
|
+
sdkm: "application/vnd.solent.sdkm+xml",
|
4916
|
+
xo: "application/vnd.olpc-sugar",
|
4917
|
+
au: "audio/basic",
|
4918
|
+
wqd: "application/vnd.wqd",
|
4919
|
+
sis: "application/vnd.symbian.install",
|
4920
|
+
smi: "application/smil+xml",
|
4921
|
+
xsm: "application/vnd.syncml+xml",
|
4922
|
+
bdm: "application/vnd.syncml.dm+wbxml",
|
4923
|
+
xdm: "application/vnd.syncml.dm+xml",
|
4924
|
+
sv4cpio: "application/x-sv4cpio",
|
4925
|
+
sv4crc: "application/x-sv4crc",
|
4926
|
+
sbml: "application/sbml+xml",
|
4927
|
+
tsv: "text/tab-separated-values",
|
4928
|
+
tiff: "image/tiff",
|
4929
|
+
tao: "application/vnd.tao.intent-module-archive",
|
4930
|
+
tar: "application/x-tar",
|
4931
|
+
tcl: "application/x-tcl",
|
4932
|
+
tex: "application/x-tex",
|
4933
|
+
tfm: "application/x-tex-tfm",
|
4934
|
+
tei: "application/tei+xml",
|
4935
|
+
txt: "text/plain",
|
4936
|
+
dxp: "application/vnd.spotfire.dxp",
|
4937
|
+
sfs: "application/vnd.spotfire.sfs",
|
4938
|
+
tsd: "application/timestamped-data",
|
4939
|
+
tpt: "application/vnd.trid.tpt",
|
4940
|
+
mxs: "application/vnd.triscape.mxs",
|
4941
|
+
t: "text/troff",
|
4942
|
+
tra: "application/vnd.trueapp",
|
4943
|
+
ttf: "application/x-font-ttf",
|
4944
|
+
ttl: "text/turtle",
|
4945
|
+
umj: "application/vnd.umajin",
|
4946
|
+
uoml: "application/vnd.uoml+xml",
|
4947
|
+
unityweb: "application/vnd.unity",
|
4948
|
+
ufd: "application/vnd.ufdl",
|
4949
|
+
uri: "text/uri-list",
|
4950
|
+
utz: "application/vnd.uiq.theme",
|
4951
|
+
ustar: "application/x-ustar",
|
4952
|
+
uu: "text/x-uuencode",
|
4953
|
+
vcs: "text/x-vcalendar",
|
4954
|
+
vcf: "text/x-vcard",
|
4955
|
+
vcd: "application/x-cdlink",
|
4956
|
+
vsf: "application/vnd.vsf",
|
4957
|
+
wrl: "model/vrml",
|
4958
|
+
vcx: "application/vnd.vcx",
|
4959
|
+
mts: "model/vnd.mts",
|
4960
|
+
vtu: "model/vnd.vtu",
|
4961
|
+
vis: "application/vnd.visionary",
|
4962
|
+
viv: "video/vnd.vivo",
|
4963
|
+
ccxml: "application/ccxml+xml,",
|
4964
|
+
vxml: "application/voicexml+xml",
|
4965
|
+
src: "application/x-wais-source",
|
4966
|
+
wbxml: "application/vnd.wap.wbxml",
|
4967
|
+
wbmp: "image/vnd.wap.wbmp",
|
4968
|
+
wav: "audio/x-wav",
|
4969
|
+
davmount: "application/davmount+xml",
|
4970
|
+
woff: "application/x-font-woff",
|
4971
|
+
wspolicy: "application/wspolicy+xml",
|
4972
|
+
webp: "image/webp",
|
4973
|
+
wtb: "application/vnd.webturbo",
|
4974
|
+
wgt: "application/widget",
|
4975
|
+
hlp: "application/winhlp",
|
4976
|
+
wml: "text/vnd.wap.wml",
|
4977
|
+
wmls: "text/vnd.wap.wmlscript",
|
4978
|
+
wmlsc: "application/vnd.wap.wmlscriptc",
|
4979
|
+
wpd: "application/vnd.wordperfect",
|
4980
|
+
stf: "application/vnd.wt.stf",
|
4981
|
+
wsdl: "application/wsdl+xml",
|
4982
|
+
xbm: "image/x-xbitmap",
|
4983
|
+
xpm: "image/x-xpixmap",
|
4984
|
+
xwd: "image/x-xwindowdump",
|
4985
|
+
der: "application/x-x509-ca-cert",
|
4986
|
+
fig: "application/x-xfig",
|
4987
|
+
xhtml: "application/xhtml+xml",
|
4988
|
+
xml: "application/xml",
|
4989
|
+
xdf: "application/xcap-diff+xml",
|
4990
|
+
xenc: "application/xenc+xml",
|
4991
|
+
xer: "application/patch-ops-error+xml",
|
4992
|
+
rl: "application/resource-lists+xml",
|
4993
|
+
rs: "application/rls-services+xml",
|
4994
|
+
rld: "application/resource-lists-diff+xml",
|
4995
|
+
xslt: "application/xslt+xml",
|
4996
|
+
xop: "application/xop+xml",
|
4997
|
+
xpi: "application/x-xpinstall",
|
4998
|
+
xspf: "application/xspf+xml",
|
4999
|
+
xul: "application/vnd.mozilla.xul+xml",
|
5000
|
+
xyz: "chemical/x-xyz",
|
5001
|
+
yaml: "text/yaml",
|
5002
|
+
yang: "application/yang",
|
5003
|
+
yin: "application/yin+xml",
|
5004
|
+
zir: "application/vnd.zul",
|
5005
|
+
zip: "application/zip",
|
5006
|
+
zmm: "application/vnd.handheld-entertainment+xml",
|
5007
|
+
zaz: "application/vnd.zzazz.deck+xml"
|
5008
|
+
};
|
5009
|
+
|
5010
|
+
// TODO: write this out to avoid compute
|
5011
|
+
var MIME_TYPES_TO_EXT = Object.fromEntries(Object.entries(EXT_TO_MIME_TYPES).map(function (_ref) {
|
5012
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
5013
|
+
k = _ref2[0],
|
5014
|
+
v = _ref2[1];
|
5015
|
+
return [v, k];
|
5016
|
+
}));
|
5017
|
+
|
5018
|
+
var MIME_TYPE_REGEX = /^data:(.*?);base64,/;
|
5019
|
+
function getMimeType(base64Url) {
|
5020
|
+
var match = MIME_TYPE_REGEX.exec(base64Url);
|
5021
|
+
if (match && match[1]) {
|
5022
|
+
return match[1];
|
5023
|
+
}
|
5024
|
+
return;
|
5025
|
+
}
|
5026
|
+
function mimeTypeToFileExt(mimeType) {
|
5027
|
+
var recognizedMimeType = MIME_TYPES_TO_EXT[mimeType];
|
5028
|
+
if (recognizedMimeType) {
|
5029
|
+
return recognizedMimeType;
|
5030
|
+
}
|
5031
|
+
return mimeType.split("/")[1];
|
5032
|
+
}
|
5033
|
+
function filenameToMimeType(filename) {
|
5034
|
+
var ext = filename.split(".").pop();
|
5035
|
+
var recognizedExt = ext && EXT_TO_MIME_TYPES[ext];
|
5036
|
+
if (recognizedExt) {
|
5037
|
+
return recognizedExt;
|
5038
|
+
}
|
5039
|
+
}
|
5040
|
+
|
3618
5041
|
function deserializeSchema(serialized) {
|
3619
5042
|
var _serialized$options;
|
3620
5043
|
switch (serialized.type) {
|
@@ -3638,9 +5061,16 @@ function deserializeSchema(serialized) {
|
|
3638
5061
|
case "array":
|
3639
5062
|
return new ArraySchema(deserializeSchema(serialized.item), serialized.opt);
|
3640
5063
|
case "union":
|
3641
|
-
return new UnionSchema(typeof serialized.key === "string" ? serialized.key :
|
5064
|
+
return new UnionSchema(typeof serialized.key === "string" ? serialized.key :
|
5065
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
5066
|
+
deserializeSchema(serialized.key),
|
5067
|
+
// TODO: we do not really need any here - right?
|
5068
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
5069
|
+
serialized.items.map(deserializeSchema),
|
5070
|
+
// TODO: we do not really need any here - right?
|
5071
|
+
serialized.opt);
|
3642
5072
|
case "richtext":
|
3643
|
-
return new RichTextSchema(serialized.options, serialized.opt);
|
5073
|
+
return new RichTextSchema(serialized.options || {}, serialized.opt);
|
3644
5074
|
case "record":
|
3645
5075
|
return new RecordSchema(deserializeSchema(serialized.item), serialized.opt);
|
3646
5076
|
case "keyOf":
|
@@ -3664,671 +5094,7 @@ function deserializeSchema(serialized) {
|
|
3664
5094
|
}
|
3665
5095
|
}
|
3666
5096
|
|
3667
|
-
|
3668
|
-
_regeneratorRuntime = function () {
|
3669
|
-
return e;
|
3670
|
-
};
|
3671
|
-
var t,
|
3672
|
-
e = {},
|
3673
|
-
r = Object.prototype,
|
3674
|
-
n = r.hasOwnProperty,
|
3675
|
-
o = Object.defineProperty || function (t, e, r) {
|
3676
|
-
t[e] = r.value;
|
3677
|
-
},
|
3678
|
-
i = "function" == typeof Symbol ? Symbol : {},
|
3679
|
-
a = i.iterator || "@@iterator",
|
3680
|
-
c = i.asyncIterator || "@@asyncIterator",
|
3681
|
-
u = i.toStringTag || "@@toStringTag";
|
3682
|
-
function define(t, e, r) {
|
3683
|
-
return Object.defineProperty(t, e, {
|
3684
|
-
value: r,
|
3685
|
-
enumerable: !0,
|
3686
|
-
configurable: !0,
|
3687
|
-
writable: !0
|
3688
|
-
}), t[e];
|
3689
|
-
}
|
3690
|
-
try {
|
3691
|
-
define({}, "");
|
3692
|
-
} catch (t) {
|
3693
|
-
define = function (t, e, r) {
|
3694
|
-
return t[e] = r;
|
3695
|
-
};
|
3696
|
-
}
|
3697
|
-
function wrap(t, e, r, n) {
|
3698
|
-
var i = e && e.prototype instanceof Generator ? e : Generator,
|
3699
|
-
a = Object.create(i.prototype),
|
3700
|
-
c = new Context(n || []);
|
3701
|
-
return o(a, "_invoke", {
|
3702
|
-
value: makeInvokeMethod(t, r, c)
|
3703
|
-
}), a;
|
3704
|
-
}
|
3705
|
-
function tryCatch(t, e, r) {
|
3706
|
-
try {
|
3707
|
-
return {
|
3708
|
-
type: "normal",
|
3709
|
-
arg: t.call(e, r)
|
3710
|
-
};
|
3711
|
-
} catch (t) {
|
3712
|
-
return {
|
3713
|
-
type: "throw",
|
3714
|
-
arg: t
|
3715
|
-
};
|
3716
|
-
}
|
3717
|
-
}
|
3718
|
-
e.wrap = wrap;
|
3719
|
-
var h = "suspendedStart",
|
3720
|
-
l = "suspendedYield",
|
3721
|
-
f = "executing",
|
3722
|
-
s = "completed",
|
3723
|
-
y = {};
|
3724
|
-
function Generator() {}
|
3725
|
-
function GeneratorFunction() {}
|
3726
|
-
function GeneratorFunctionPrototype() {}
|
3727
|
-
var p = {};
|
3728
|
-
define(p, a, function () {
|
3729
|
-
return this;
|
3730
|
-
});
|
3731
|
-
var d = Object.getPrototypeOf,
|
3732
|
-
v = d && d(d(values([])));
|
3733
|
-
v && v !== r && n.call(v, a) && (p = v);
|
3734
|
-
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
3735
|
-
function defineIteratorMethods(t) {
|
3736
|
-
["next", "throw", "return"].forEach(function (e) {
|
3737
|
-
define(t, e, function (t) {
|
3738
|
-
return this._invoke(e, t);
|
3739
|
-
});
|
3740
|
-
});
|
3741
|
-
}
|
3742
|
-
function AsyncIterator(t, e) {
|
3743
|
-
function invoke(r, o, i, a) {
|
3744
|
-
var c = tryCatch(t[r], t, o);
|
3745
|
-
if ("throw" !== c.type) {
|
3746
|
-
var u = c.arg,
|
3747
|
-
h = u.value;
|
3748
|
-
return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
|
3749
|
-
invoke("next", t, i, a);
|
3750
|
-
}, function (t) {
|
3751
|
-
invoke("throw", t, i, a);
|
3752
|
-
}) : e.resolve(h).then(function (t) {
|
3753
|
-
u.value = t, i(u);
|
3754
|
-
}, function (t) {
|
3755
|
-
return invoke("throw", t, i, a);
|
3756
|
-
});
|
3757
|
-
}
|
3758
|
-
a(c.arg);
|
3759
|
-
}
|
3760
|
-
var r;
|
3761
|
-
o(this, "_invoke", {
|
3762
|
-
value: function (t, n) {
|
3763
|
-
function callInvokeWithMethodAndArg() {
|
3764
|
-
return new e(function (e, r) {
|
3765
|
-
invoke(t, n, e, r);
|
3766
|
-
});
|
3767
|
-
}
|
3768
|
-
return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
3769
|
-
}
|
3770
|
-
});
|
3771
|
-
}
|
3772
|
-
function makeInvokeMethod(e, r, n) {
|
3773
|
-
var o = h;
|
3774
|
-
return function (i, a) {
|
3775
|
-
if (o === f) throw new Error("Generator is already running");
|
3776
|
-
if (o === s) {
|
3777
|
-
if ("throw" === i) throw a;
|
3778
|
-
return {
|
3779
|
-
value: t,
|
3780
|
-
done: !0
|
3781
|
-
};
|
3782
|
-
}
|
3783
|
-
for (n.method = i, n.arg = a;;) {
|
3784
|
-
var c = n.delegate;
|
3785
|
-
if (c) {
|
3786
|
-
var u = maybeInvokeDelegate(c, n);
|
3787
|
-
if (u) {
|
3788
|
-
if (u === y) continue;
|
3789
|
-
return u;
|
3790
|
-
}
|
3791
|
-
}
|
3792
|
-
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
3793
|
-
if (o === h) throw o = s, n.arg;
|
3794
|
-
n.dispatchException(n.arg);
|
3795
|
-
} else "return" === n.method && n.abrupt("return", n.arg);
|
3796
|
-
o = f;
|
3797
|
-
var p = tryCatch(e, r, n);
|
3798
|
-
if ("normal" === p.type) {
|
3799
|
-
if (o = n.done ? s : l, p.arg === y) continue;
|
3800
|
-
return {
|
3801
|
-
value: p.arg,
|
3802
|
-
done: n.done
|
3803
|
-
};
|
3804
|
-
}
|
3805
|
-
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
|
3806
|
-
}
|
3807
|
-
};
|
3808
|
-
}
|
3809
|
-
function maybeInvokeDelegate(e, r) {
|
3810
|
-
var n = r.method,
|
3811
|
-
o = e.iterator[n];
|
3812
|
-
if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
|
3813
|
-
var i = tryCatch(o, e.iterator, r.arg);
|
3814
|
-
if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
|
3815
|
-
var a = i.arg;
|
3816
|
-
return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
|
3817
|
-
}
|
3818
|
-
function pushTryEntry(t) {
|
3819
|
-
var e = {
|
3820
|
-
tryLoc: t[0]
|
3821
|
-
};
|
3822
|
-
1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
|
3823
|
-
}
|
3824
|
-
function resetTryEntry(t) {
|
3825
|
-
var e = t.completion || {};
|
3826
|
-
e.type = "normal", delete e.arg, t.completion = e;
|
3827
|
-
}
|
3828
|
-
function Context(t) {
|
3829
|
-
this.tryEntries = [{
|
3830
|
-
tryLoc: "root"
|
3831
|
-
}], t.forEach(pushTryEntry, this), this.reset(!0);
|
3832
|
-
}
|
3833
|
-
function values(e) {
|
3834
|
-
if (e || "" === e) {
|
3835
|
-
var r = e[a];
|
3836
|
-
if (r) return r.call(e);
|
3837
|
-
if ("function" == typeof e.next) return e;
|
3838
|
-
if (!isNaN(e.length)) {
|
3839
|
-
var o = -1,
|
3840
|
-
i = function next() {
|
3841
|
-
for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
|
3842
|
-
return next.value = t, next.done = !0, next;
|
3843
|
-
};
|
3844
|
-
return i.next = i;
|
3845
|
-
}
|
3846
|
-
}
|
3847
|
-
throw new TypeError(typeof e + " is not iterable");
|
3848
|
-
}
|
3849
|
-
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
|
3850
|
-
value: GeneratorFunctionPrototype,
|
3851
|
-
configurable: !0
|
3852
|
-
}), o(GeneratorFunctionPrototype, "constructor", {
|
3853
|
-
value: GeneratorFunction,
|
3854
|
-
configurable: !0
|
3855
|
-
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
|
3856
|
-
var e = "function" == typeof t && t.constructor;
|
3857
|
-
return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
|
3858
|
-
}, e.mark = function (t) {
|
3859
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
|
3860
|
-
}, e.awrap = function (t) {
|
3861
|
-
return {
|
3862
|
-
__await: t
|
3863
|
-
};
|
3864
|
-
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
|
3865
|
-
return this;
|
3866
|
-
}), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
|
3867
|
-
void 0 === i && (i = Promise);
|
3868
|
-
var a = new AsyncIterator(wrap(t, r, n, o), i);
|
3869
|
-
return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
|
3870
|
-
return t.done ? t.value : a.next();
|
3871
|
-
});
|
3872
|
-
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
|
3873
|
-
return this;
|
3874
|
-
}), define(g, "toString", function () {
|
3875
|
-
return "[object Generator]";
|
3876
|
-
}), e.keys = function (t) {
|
3877
|
-
var e = Object(t),
|
3878
|
-
r = [];
|
3879
|
-
for (var n in e) r.push(n);
|
3880
|
-
return r.reverse(), function next() {
|
3881
|
-
for (; r.length;) {
|
3882
|
-
var t = r.pop();
|
3883
|
-
if (t in e) return next.value = t, next.done = !1, next;
|
3884
|
-
}
|
3885
|
-
return next.done = !0, next;
|
3886
|
-
};
|
3887
|
-
}, e.values = values, Context.prototype = {
|
3888
|
-
constructor: Context,
|
3889
|
-
reset: function (e) {
|
3890
|
-
if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
|
3891
|
-
},
|
3892
|
-
stop: function () {
|
3893
|
-
this.done = !0;
|
3894
|
-
var t = this.tryEntries[0].completion;
|
3895
|
-
if ("throw" === t.type) throw t.arg;
|
3896
|
-
return this.rval;
|
3897
|
-
},
|
3898
|
-
dispatchException: function (e) {
|
3899
|
-
if (this.done) throw e;
|
3900
|
-
var r = this;
|
3901
|
-
function handle(n, o) {
|
3902
|
-
return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
|
3903
|
-
}
|
3904
|
-
for (var o = this.tryEntries.length - 1; o >= 0; --o) {
|
3905
|
-
var i = this.tryEntries[o],
|
3906
|
-
a = i.completion;
|
3907
|
-
if ("root" === i.tryLoc) return handle("end");
|
3908
|
-
if (i.tryLoc <= this.prev) {
|
3909
|
-
var c = n.call(i, "catchLoc"),
|
3910
|
-
u = n.call(i, "finallyLoc");
|
3911
|
-
if (c && u) {
|
3912
|
-
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
3913
|
-
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
3914
|
-
} else if (c) {
|
3915
|
-
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
3916
|
-
} else {
|
3917
|
-
if (!u) throw new Error("try statement without catch or finally");
|
3918
|
-
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
3919
|
-
}
|
3920
|
-
}
|
3921
|
-
}
|
3922
|
-
},
|
3923
|
-
abrupt: function (t, e) {
|
3924
|
-
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
3925
|
-
var o = this.tryEntries[r];
|
3926
|
-
if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
|
3927
|
-
var i = o;
|
3928
|
-
break;
|
3929
|
-
}
|
3930
|
-
}
|
3931
|
-
i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
|
3932
|
-
var a = i ? i.completion : {};
|
3933
|
-
return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
|
3934
|
-
},
|
3935
|
-
complete: function (t, e) {
|
3936
|
-
if ("throw" === t.type) throw t.arg;
|
3937
|
-
return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
|
3938
|
-
},
|
3939
|
-
finish: function (t) {
|
3940
|
-
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
3941
|
-
var r = this.tryEntries[e];
|
3942
|
-
if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
|
3943
|
-
}
|
3944
|
-
},
|
3945
|
-
catch: function (t) {
|
3946
|
-
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
3947
|
-
var r = this.tryEntries[e];
|
3948
|
-
if (r.tryLoc === t) {
|
3949
|
-
var n = r.completion;
|
3950
|
-
if ("throw" === n.type) {
|
3951
|
-
var o = n.arg;
|
3952
|
-
resetTryEntry(r);
|
3953
|
-
}
|
3954
|
-
return o;
|
3955
|
-
}
|
3956
|
-
}
|
3957
|
-
throw new Error("illegal catch attempt");
|
3958
|
-
},
|
3959
|
-
delegateYield: function (e, r, n) {
|
3960
|
-
return this.delegate = {
|
3961
|
-
iterator: values(e),
|
3962
|
-
resultName: r,
|
3963
|
-
nextLoc: n
|
3964
|
-
}, "next" === this.method && (this.arg = t), y;
|
3965
|
-
}
|
3966
|
-
}, e;
|
3967
|
-
}
|
3968
|
-
|
3969
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
3970
|
-
try {
|
3971
|
-
var info = gen[key](arg);
|
3972
|
-
var value = info.value;
|
3973
|
-
} catch (error) {
|
3974
|
-
reject(error);
|
3975
|
-
return;
|
3976
|
-
}
|
3977
|
-
if (info.done) {
|
3978
|
-
resolve(value);
|
3979
|
-
} else {
|
3980
|
-
Promise.resolve(value).then(_next, _throw);
|
3981
|
-
}
|
3982
|
-
}
|
3983
|
-
function _asyncToGenerator(fn) {
|
3984
|
-
return function () {
|
3985
|
-
var self = this,
|
3986
|
-
args = arguments;
|
3987
|
-
return new Promise(function (resolve, reject) {
|
3988
|
-
var gen = fn.apply(self, args);
|
3989
|
-
function _next(value) {
|
3990
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
3991
|
-
}
|
3992
|
-
function _throw(err) {
|
3993
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
3994
|
-
}
|
3995
|
-
_next(undefined);
|
3996
|
-
});
|
3997
|
-
};
|
3998
|
-
}
|
3999
|
-
|
4000
|
-
// TODO: move this to internal, only reason this is here is that react, ui and server all depend on it
|
4001
|
-
var ValApi = /*#__PURE__*/function () {
|
4002
|
-
function ValApi(host) {
|
4003
|
-
_classCallCheck(this, ValApi);
|
4004
|
-
this.host = host;
|
4005
|
-
}
|
4006
|
-
_createClass(ValApi, [{
|
4007
|
-
key: "getDisableUrl",
|
4008
|
-
value: function getDisableUrl(redirectTo) {
|
4009
|
-
return "".concat(this.host, "/disable?redirect_to=").concat(encodeURIComponent(redirectTo));
|
4010
|
-
}
|
4011
|
-
}, {
|
4012
|
-
key: "getLoginUrl",
|
4013
|
-
value: function getLoginUrl(redirectTo) {
|
4014
|
-
return "".concat(this.host, "/authorize?redirect_to=").concat(encodeURIComponent(redirectTo));
|
4015
|
-
}
|
4016
|
-
}, {
|
4017
|
-
key: "getEnableUrl",
|
4018
|
-
value: function getEnableUrl(redirectTo) {
|
4019
|
-
return "".concat(this.host, "/enable?redirect_to=").concat(encodeURIComponent(redirectTo));
|
4020
|
-
}
|
4021
|
-
}, {
|
4022
|
-
key: "getPatches",
|
4023
|
-
value: function () {
|
4024
|
-
var _getPatches = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(filters) {
|
4025
|
-
var params, _iterator, _step, patchId, _iterator2, _step2, author, _iterator3, _step3, moduleFilePath, searchParams;
|
4026
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
4027
|
-
while (1) switch (_context.prev = _context.next) {
|
4028
|
-
case 0:
|
4029
|
-
params = [];
|
4030
|
-
if (filters) {
|
4031
|
-
if (filters.patchIds) {
|
4032
|
-
_iterator = _createForOfIteratorHelper(filters.patchIds);
|
4033
|
-
try {
|
4034
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
4035
|
-
patchId = _step.value;
|
4036
|
-
params.push(["patch_id", patchId]);
|
4037
|
-
}
|
4038
|
-
} catch (err) {
|
4039
|
-
_iterator.e(err);
|
4040
|
-
} finally {
|
4041
|
-
_iterator.f();
|
4042
|
-
}
|
4043
|
-
}
|
4044
|
-
if (filters.authors) {
|
4045
|
-
_iterator2 = _createForOfIteratorHelper(filters.authors);
|
4046
|
-
try {
|
4047
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
4048
|
-
author = _step2.value;
|
4049
|
-
params.push(["author", author]);
|
4050
|
-
}
|
4051
|
-
} catch (err) {
|
4052
|
-
_iterator2.e(err);
|
4053
|
-
} finally {
|
4054
|
-
_iterator2.f();
|
4055
|
-
}
|
4056
|
-
}
|
4057
|
-
if (filters.moduleFilePaths) {
|
4058
|
-
_iterator3 = _createForOfIteratorHelper(filters.moduleFilePaths);
|
4059
|
-
try {
|
4060
|
-
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
4061
|
-
moduleFilePath = _step3.value;
|
4062
|
-
params.push(["module_file_path", moduleFilePath]);
|
4063
|
-
}
|
4064
|
-
} catch (err) {
|
4065
|
-
_iterator3.e(err);
|
4066
|
-
} finally {
|
4067
|
-
_iterator3.f();
|
4068
|
-
}
|
4069
|
-
}
|
4070
|
-
if (filters.omitPatches) {
|
4071
|
-
params.push(["omit_patches", "true"]);
|
4072
|
-
}
|
4073
|
-
}
|
4074
|
-
searchParams = new URLSearchParams(params);
|
4075
|
-
return _context.abrupt("return", fetch("".concat(this.host, "/patches/~").concat(searchParams.size > 0 ? "?".concat(searchParams.toString()) : ""), {
|
4076
|
-
headers: {
|
4077
|
-
"Content-Type": "application/json"
|
4078
|
-
}
|
4079
|
-
}).then(function (res) {
|
4080
|
-
return parse(res);
|
4081
|
-
})["catch"](createError));
|
4082
|
-
case 4:
|
4083
|
-
case "end":
|
4084
|
-
return _context.stop();
|
4085
|
-
}
|
4086
|
-
}, _callee, this);
|
4087
|
-
}));
|
4088
|
-
function getPatches(_x) {
|
4089
|
-
return _getPatches.apply(this, arguments);
|
4090
|
-
}
|
4091
|
-
return getPatches;
|
4092
|
-
}()
|
4093
|
-
}, {
|
4094
|
-
key: "deletePatches",
|
4095
|
-
value: function () {
|
4096
|
-
var _deletePatches = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(ids, headers) {
|
4097
|
-
var params;
|
4098
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
4099
|
-
while (1) switch (_context2.prev = _context2.next) {
|
4100
|
-
case 0:
|
4101
|
-
params = new URLSearchParams();
|
4102
|
-
ids.forEach(function (id) {
|
4103
|
-
return params.append("id", id);
|
4104
|
-
});
|
4105
|
-
return _context2.abrupt("return", fetch("".concat(this.host, "/patches/~?").concat(params), {
|
4106
|
-
method: "DELETE",
|
4107
|
-
headers: headers || {
|
4108
|
-
"Content-Type": "application/json"
|
4109
|
-
}
|
4110
|
-
}).then(function (res) {
|
4111
|
-
return parse(res);
|
4112
|
-
})["catch"](createError));
|
4113
|
-
case 3:
|
4114
|
-
case "end":
|
4115
|
-
return _context2.stop();
|
4116
|
-
}
|
4117
|
-
}, _callee2, this);
|
4118
|
-
}));
|
4119
|
-
function deletePatches(_x2, _x3) {
|
4120
|
-
return _deletePatches.apply(this, arguments);
|
4121
|
-
}
|
4122
|
-
return deletePatches;
|
4123
|
-
}()
|
4124
|
-
}, {
|
4125
|
-
key: "getEditUrl",
|
4126
|
-
value: function getEditUrl() {
|
4127
|
-
// TODO: make route configurable
|
4128
|
-
return "/val/~";
|
4129
|
-
}
|
4130
|
-
}, {
|
4131
|
-
key: "getSession",
|
4132
|
-
value: function getSession() {
|
4133
|
-
return fetch("".concat(this.host, "/session")).then(function (res) {
|
4134
|
-
return parse(res)["catch"](createError);
|
4135
|
-
});
|
4136
|
-
}
|
4137
|
-
}, {
|
4138
|
-
key: "getSchema",
|
4139
|
-
value: function getSchema(_ref) {
|
4140
|
-
var headers = _ref.headers;
|
4141
|
-
return fetch("".concat(this.host, "/schema"), {
|
4142
|
-
method: "GET",
|
4143
|
-
headers: headers
|
4144
|
-
}).then(function (res) {
|
4145
|
-
return parse(res);
|
4146
|
-
})["catch"](createError);
|
4147
|
-
}
|
4148
|
-
}, {
|
4149
|
-
key: "putTree",
|
4150
|
-
value: function putTree(_ref2) {
|
4151
|
-
var _ref2$treePath = _ref2.treePath,
|
4152
|
-
treePath = _ref2$treePath === void 0 ? "/" : _ref2$treePath,
|
4153
|
-
patchIds = _ref2.patchIds,
|
4154
|
-
addPatch = _ref2.addPatch,
|
4155
|
-
validateAll = _ref2.validateAll,
|
4156
|
-
validateSource = _ref2.validateSource,
|
4157
|
-
validateBinaryFiles = _ref2.validateBinaryFiles,
|
4158
|
-
headers = _ref2.headers;
|
4159
|
-
var params = new URLSearchParams();
|
4160
|
-
var textEncoder = new TextEncoder();
|
4161
|
-
var patchesSha = getSHA256Hash(textEncoder.encode((patchIds || []).concat(JSON.stringify(addPatch || {})).join(";")));
|
4162
|
-
params.set("patches_sha", patchesSha);
|
4163
|
-
params.set("validate_all", (validateAll || false).toString());
|
4164
|
-
params.set("validate_source", (validateSource || false).toString());
|
4165
|
-
params.set("validate_binary_files", (validateBinaryFiles || false).toString());
|
4166
|
-
return fetch("".concat(this.host, "/tree/~").concat(treePath, "?").concat(params.toString()), {
|
4167
|
-
method: "PUT",
|
4168
|
-
body: JSON.stringify({
|
4169
|
-
patchIds: patchIds,
|
4170
|
-
addPatch: addPatch
|
4171
|
-
}),
|
4172
|
-
headers: headers
|
4173
|
-
}).then(function (res) {
|
4174
|
-
return parse(res);
|
4175
|
-
})["catch"](createError);
|
4176
|
-
}
|
4177
|
-
}, {
|
4178
|
-
key: "postSave",
|
4179
|
-
value: function postSave(_ref3) {
|
4180
|
-
var patchIds = _ref3.patchIds;
|
4181
|
-
return fetch("".concat(this.host, "/save"), {
|
4182
|
-
method: "POST",
|
4183
|
-
body: JSON.stringify({
|
4184
|
-
patchIds: patchIds
|
4185
|
-
}),
|
4186
|
-
headers: {
|
4187
|
-
"Content-Type": "application/json"
|
4188
|
-
}
|
4189
|
-
}).then( /*#__PURE__*/function () {
|
4190
|
-
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(res) {
|
4191
|
-
var jsonRes;
|
4192
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
4193
|
-
while (1) switch (_context3.prev = _context3.next) {
|
4194
|
-
case 0:
|
4195
|
-
if (!res.ok) {
|
4196
|
-
_context3.next = 4;
|
4197
|
-
break;
|
4198
|
-
}
|
4199
|
-
return _context3.abrupt("return", parse(res));
|
4200
|
-
case 4:
|
4201
|
-
if (!(res.status === 400 && res.headers.get("content-type") === "application/json")) {
|
4202
|
-
_context3.next = 9;
|
4203
|
-
break;
|
4204
|
-
}
|
4205
|
-
_context3.next = 7;
|
4206
|
-
return res.json();
|
4207
|
-
case 7:
|
4208
|
-
jsonRes = _context3.sent;
|
4209
|
-
alert(JSON.stringify(jsonRes));
|
4210
|
-
case 9:
|
4211
|
-
return _context3.abrupt("return", parse(res));
|
4212
|
-
case 10:
|
4213
|
-
case "end":
|
4214
|
-
return _context3.stop();
|
4215
|
-
}
|
4216
|
-
}, _callee3);
|
4217
|
-
}));
|
4218
|
-
return function (_x4) {
|
4219
|
-
return _ref4.apply(this, arguments);
|
4220
|
-
};
|
4221
|
-
}())["catch"](createError);
|
4222
|
-
}
|
4223
|
-
}, {
|
4224
|
-
key: "postValidate",
|
4225
|
-
value: function postValidate(_ref5) {
|
4226
|
-
var patches = _ref5.patches,
|
4227
|
-
headers = _ref5.headers;
|
4228
|
-
return fetch("".concat(this.host, "/validate"), {
|
4229
|
-
method: "POST",
|
4230
|
-
body: JSON.stringify({
|
4231
|
-
patches: patches
|
4232
|
-
}),
|
4233
|
-
headers: headers || {
|
4234
|
-
"Content-Type": "application/json"
|
4235
|
-
}
|
4236
|
-
}).then( /*#__PURE__*/function () {
|
4237
|
-
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(res) {
|
4238
|
-
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
4239
|
-
while (1) switch (_context4.prev = _context4.next) {
|
4240
|
-
case 0:
|
4241
|
-
return _context4.abrupt("return", parse(res));
|
4242
|
-
case 1:
|
4243
|
-
case "end":
|
4244
|
-
return _context4.stop();
|
4245
|
-
}
|
4246
|
-
}, _callee4);
|
4247
|
-
}));
|
4248
|
-
return function (_x5) {
|
4249
|
-
return _ref6.apply(this, arguments);
|
4250
|
-
};
|
4251
|
-
}())["catch"](createError);
|
4252
|
-
}
|
4253
|
-
}]);
|
4254
|
-
return ValApi;
|
4255
|
-
}();
|
4256
|
-
function createError(err$1) {
|
4257
|
-
return err({
|
4258
|
-
statusCode: 500,
|
4259
|
-
message: err$1 instanceof Error ? err$1.message : _typeof(err$1) === "object" && err$1 && "message" in err$1 && typeof err$1.message === "string" ? err$1.message : "Unknown error",
|
4260
|
-
details: _typeof(err$1) === "object" && err$1 && "details" in err$1 ? err$1.details : undefined
|
4261
|
-
});
|
4262
|
-
}
|
4263
|
-
|
4264
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
4265
|
-
function formatError(status, json, statusText) {
|
4266
|
-
return err({
|
4267
|
-
statusCode: status,
|
4268
|
-
message: json.message || statusText,
|
4269
|
-
details: json.details || Object.fromEntries(Object.entries(json).filter(function (_ref7) {
|
4270
|
-
var _ref8 = _slicedToArray(_ref7, 1),
|
4271
|
-
key = _ref8[0];
|
4272
|
-
return key !== "message";
|
4273
|
-
}))
|
4274
|
-
});
|
4275
|
-
}
|
4276
|
-
|
4277
|
-
// TODO: validate
|
4278
|
-
function parse(_x6) {
|
4279
|
-
return _parse.apply(this, arguments);
|
4280
|
-
}
|
4281
|
-
function _parse() {
|
4282
|
-
_parse = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(res) {
|
4283
|
-
var json;
|
4284
|
-
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
4285
|
-
while (1) switch (_context5.prev = _context5.next) {
|
4286
|
-
case 0:
|
4287
|
-
_context5.prev = 0;
|
4288
|
-
if (!res.ok) {
|
4289
|
-
_context5.next = 9;
|
4290
|
-
break;
|
4291
|
-
}
|
4292
|
-
_context5.t0 = result;
|
4293
|
-
_context5.next = 5;
|
4294
|
-
return res.json();
|
4295
|
-
case 5:
|
4296
|
-
_context5.t1 = _context5.sent;
|
4297
|
-
return _context5.abrupt("return", _context5.t0.ok.call(_context5.t0, _context5.t1));
|
4298
|
-
case 9:
|
4299
|
-
_context5.prev = 9;
|
4300
|
-
_context5.next = 12;
|
4301
|
-
return res.json();
|
4302
|
-
case 12:
|
4303
|
-
json = _context5.sent;
|
4304
|
-
return _context5.abrupt("return", formatError(res.status, json, res.statusText));
|
4305
|
-
case 16:
|
4306
|
-
_context5.prev = 16;
|
4307
|
-
_context5.t2 = _context5["catch"](9);
|
4308
|
-
return _context5.abrupt("return", err({
|
4309
|
-
statusCode: res.status,
|
4310
|
-
message: res.statusText
|
4311
|
-
}));
|
4312
|
-
case 19:
|
4313
|
-
_context5.next = 24;
|
4314
|
-
break;
|
4315
|
-
case 21:
|
4316
|
-
_context5.prev = 21;
|
4317
|
-
_context5.t3 = _context5["catch"](0);
|
4318
|
-
return _context5.abrupt("return", err({
|
4319
|
-
message: _context5.t3 instanceof Error ? _context5.t3.message : "Unknown error"
|
4320
|
-
}));
|
4321
|
-
case 24:
|
4322
|
-
case "end":
|
4323
|
-
return _context5.stop();
|
4324
|
-
}
|
4325
|
-
}, _callee5, null, [[0, 21], [9, 16]]);
|
4326
|
-
}));
|
4327
|
-
return _parse.apply(this, arguments);
|
4328
|
-
}
|
4329
|
-
|
4330
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
4331
|
-
|
5097
|
+
var ModuleFilePathSep = "?p=";
|
4332
5098
|
var FATAL_ERROR_TYPES = ["no-schema", "no-source", "invalid-id", "no-module", "invalid-patch"];
|
4333
5099
|
var Internal = {
|
4334
5100
|
VERSION: {
|
@@ -4348,10 +5114,16 @@ var Internal = {
|
|
4348
5114
|
getSource: getSource,
|
4349
5115
|
resolvePath: resolvePath,
|
4350
5116
|
splitModuleFilePathAndModulePath: splitModuleFilePathAndModulePath,
|
5117
|
+
joinModuleFilePathAndModulePath: joinModuleFilePathAndModulePath,
|
4351
5118
|
isVal: isVal,
|
4352
5119
|
createValPathOfItem: createValPathOfItem,
|
4353
5120
|
getSHA256Hash: getSHA256Hash,
|
4354
5121
|
initSchema: initSchema,
|
5122
|
+
getMimeType: getMimeType,
|
5123
|
+
mimeTypeToFileExt: mimeTypeToFileExt,
|
5124
|
+
filenameToMimeType: filenameToMimeType,
|
5125
|
+
EXT_TO_MIME_TYPES: EXT_TO_MIME_TYPES,
|
5126
|
+
MIME_TYPES_TO_EXT: MIME_TYPES_TO_EXT,
|
4355
5127
|
ModuleFilePathSep: ModuleFilePathSep,
|
4356
5128
|
notFileOp: function notFileOp(op) {
|
4357
5129
|
return op.op !== "file";
|
@@ -4365,20 +5137,39 @@ var Internal = {
|
|
4365
5137
|
}).join("/"));
|
4366
5138
|
},
|
4367
5139
|
createPatchPath: function createPatchPath(modulePath) {
|
4368
|
-
return
|
4369
|
-
},
|
4370
|
-
patchPathToModulePath: function patchPathToModulePath(patchPath) {
|
4371
|
-
return patchPath.map(function (segment) {
|
4372
|
-
// 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?
|
4373
|
-
if (Number.isInteger(Number(segment))) {
|
4374
|
-
return segment;
|
4375
|
-
}
|
4376
|
-
return JSON.stringify(segment);
|
4377
|
-
}).join(".");
|
5140
|
+
return splitModulePath(modulePath);
|
4378
5141
|
},
|
5142
|
+
splitModulePath: splitModulePath,
|
5143
|
+
splitModuleFilePath: splitModuleFilePath,
|
5144
|
+
splitJoinedSourcePaths: splitJoinedSourcePaths,
|
5145
|
+
parentOfSourcePath: parentOfSourcePath,
|
5146
|
+
patchPathToModulePath: patchPathToModulePath,
|
4379
5147
|
VAL_ENABLE_COOKIE_NAME: "val_enable",
|
4380
5148
|
VAL_STATE_COOKIE: "val_state",
|
4381
|
-
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
|
+
}
|
4382
5173
|
};
|
4383
5174
|
function tryJsonParse(str) {
|
4384
5175
|
try {
|
@@ -4388,4 +5179,4 @@ function tryJsonParse(str) {
|
|
4388
5179
|
}
|
4389
5180
|
}
|
4390
5181
|
|
4391
|
-
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, 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
|
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 };
|