@valbuild/core 0.99.0 → 0.100.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/index.d.ts +5 -0
- package/dist/declarations/src/initVal.d.ts +2 -0
- package/dist/declarations/src/schema/array.d.ts +16 -13
- package/dist/declarations/src/schema/boolean.d.ts +2 -1
- package/dist/declarations/src/schema/date.d.ts +2 -1
- package/dist/declarations/src/schema/datetime.d.ts +2 -1
- package/dist/declarations/src/schema/file.d.ts +2 -1
- package/dist/declarations/src/schema/image.d.ts +2 -1
- package/dist/declarations/src/schema/index.d.ts +22 -0
- package/dist/declarations/src/schema/keyOf.d.ts +2 -1
- package/dist/declarations/src/schema/literal.d.ts +2 -1
- package/dist/declarations/src/schema/number.d.ts +2 -1
- package/dist/declarations/src/schema/object.d.ts +2 -1
- package/dist/declarations/src/schema/record.d.ts +59 -5
- package/dist/declarations/src/schema/richtext.d.ts +2 -1
- package/dist/declarations/src/schema/route.d.ts +2 -1
- package/dist/declarations/src/schema/string.d.ts +2 -1
- package/dist/declarations/src/schema/union.d.ts +9 -1
- package/dist/declarations/src/schema/validation/ValidationFix.d.ts +1 -1
- package/dist/declarations/src/selector/index.d.ts +3 -2
- package/dist/declarations/src/source/index.d.ts +3 -2
- package/dist/declarations/src/source/json.d.ts +73 -0
- package/dist/{index-233a49d6.cjs.dev.js → index-202e48a3.cjs.dev.js} +750 -310
- package/dist/{index-11f47a61.cjs.prod.js → index-92ba715b.cjs.prod.js} +750 -310
- package/dist/{index-d152e3e2.esm.js → index-c9241d81.esm.js} +750 -310
- package/dist/valbuild-core.cjs.dev.js +1 -1
- package/dist/valbuild-core.cjs.prod.js +1 -1
- package/dist/valbuild-core.esm.js +1 -1
- package/package.json +1 -1
- package/patch/dist/valbuild-core-patch.cjs.dev.js +1 -1
- package/patch/dist/valbuild-core-patch.cjs.prod.js +1 -1
- package/patch/dist/valbuild-core-patch.esm.js +2 -2
|
@@ -654,6 +654,13 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
|
|
|
654
654
|
value: function hidden() {
|
|
655
655
|
return new FileSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, true, this.description);
|
|
656
656
|
}
|
|
657
|
+
}, {
|
|
658
|
+
key: "executeCustomValidateAt",
|
|
659
|
+
value: function executeCustomValidateAt(path, src) {
|
|
660
|
+
return this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
|
|
661
|
+
path: path
|
|
662
|
+
});
|
|
663
|
+
}
|
|
657
664
|
}, {
|
|
658
665
|
key: "executeSerialize",
|
|
659
666
|
value: function executeSerialize() {
|
|
@@ -902,6 +909,13 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
|
|
|
902
909
|
value: function raw() {
|
|
903
910
|
return new StringSchema(this.options, this.opt, true, this.customValidateFunctions, this.renderInput, this.isReadonly, this.isHidden, this.description);
|
|
904
911
|
}
|
|
912
|
+
}, {
|
|
913
|
+
key: "executeCustomValidateAt",
|
|
914
|
+
value: function executeCustomValidateAt(path, src) {
|
|
915
|
+
return this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
|
|
916
|
+
path: path
|
|
917
|
+
});
|
|
918
|
+
}
|
|
905
919
|
}, {
|
|
906
920
|
key: "executeSerialize",
|
|
907
921
|
value: function executeSerialize() {
|
|
@@ -1118,6 +1132,13 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
|
|
|
1118
1132
|
value: function hidden() {
|
|
1119
1133
|
return new ObjectSchema(this.items, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
|
|
1120
1134
|
}
|
|
1135
|
+
}, {
|
|
1136
|
+
key: "executeCustomValidateAt",
|
|
1137
|
+
value: function executeCustomValidateAt(path, src) {
|
|
1138
|
+
return this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
|
|
1139
|
+
path: path
|
|
1140
|
+
});
|
|
1141
|
+
}
|
|
1121
1142
|
}, {
|
|
1122
1143
|
key: "executeSerialize",
|
|
1123
1144
|
value: function executeSerialize() {
|
|
@@ -1177,27 +1198,28 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
|
|
|
1177
1198
|
var isReadonly = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
1178
1199
|
var isHidden = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
1179
1200
|
var description = arguments.length > 5 ? arguments[5] : undefined;
|
|
1201
|
+
var renderInput = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
|
|
1180
1202
|
_classCallCheck(this, ArraySchema);
|
|
1181
1203
|
_this = _callSuper(this, ArraySchema);
|
|
1182
|
-
_defineProperty(_this, "renderInput", null);
|
|
1183
1204
|
_this.item = item;
|
|
1184
1205
|
_this.opt = opt;
|
|
1185
1206
|
_this.customValidateFunctions = customValidateFunctions;
|
|
1186
1207
|
_this.isReadonly = isReadonly;
|
|
1187
1208
|
_this.isHidden = isHidden;
|
|
1188
1209
|
_this.description = description;
|
|
1210
|
+
_this.renderInput = renderInput;
|
|
1189
1211
|
return _this;
|
|
1190
1212
|
}
|
|
1191
1213
|
_inherits(ArraySchema, _Schema);
|
|
1192
1214
|
return _createClass(ArraySchema, [{
|
|
1193
1215
|
key: "describe",
|
|
1194
1216
|
value: function describe(description) {
|
|
1195
|
-
return new ArraySchema(this.item, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined);
|
|
1217
|
+
return new ArraySchema(this.item, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.renderInput);
|
|
1196
1218
|
}
|
|
1197
1219
|
}, {
|
|
1198
1220
|
key: "validate",
|
|
1199
1221
|
value: function validate(validationFunction) {
|
|
1200
|
-
return new ArraySchema(this.item, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description);
|
|
1222
|
+
return new ArraySchema(this.item, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description, this.renderInput);
|
|
1201
1223
|
}
|
|
1202
1224
|
}, {
|
|
1203
1225
|
key: "executeValidate",
|
|
@@ -1264,17 +1286,24 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
|
|
|
1264
1286
|
}, {
|
|
1265
1287
|
key: "nullable",
|
|
1266
1288
|
value: function nullable() {
|
|
1267
|
-
return new ArraySchema(this.item, true, [], this.isReadonly, this.isHidden, this.description);
|
|
1289
|
+
return new ArraySchema(this.item, true, [], this.isReadonly, this.isHidden, this.description, this.renderInput);
|
|
1268
1290
|
}
|
|
1269
1291
|
}, {
|
|
1270
1292
|
key: "readonly",
|
|
1271
1293
|
value: function readonly() {
|
|
1272
|
-
return new ArraySchema(this.item, this.opt, this.customValidateFunctions, true, this.isHidden, this.description);
|
|
1294
|
+
return new ArraySchema(this.item, this.opt, this.customValidateFunctions, true, this.isHidden, this.description, this.renderInput);
|
|
1273
1295
|
}
|
|
1274
1296
|
}, {
|
|
1275
1297
|
key: "hidden",
|
|
1276
1298
|
value: function hidden() {
|
|
1277
|
-
return new ArraySchema(this.item, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
|
|
1299
|
+
return new ArraySchema(this.item, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description, this.renderInput);
|
|
1300
|
+
}
|
|
1301
|
+
}, {
|
|
1302
|
+
key: "executeCustomValidateAt",
|
|
1303
|
+
value: function executeCustomValidateAt(path, src) {
|
|
1304
|
+
return this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
|
|
1305
|
+
path: path
|
|
1306
|
+
});
|
|
1278
1307
|
}
|
|
1279
1308
|
}, {
|
|
1280
1309
|
key: "executeSerialize",
|
|
@@ -1354,8 +1383,7 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
|
|
|
1354
1383
|
}, {
|
|
1355
1384
|
key: "render",
|
|
1356
1385
|
value: function render(input) {
|
|
1357
|
-
this.
|
|
1358
|
-
return this;
|
|
1386
|
+
return new ArraySchema(this.item, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, input);
|
|
1359
1387
|
}
|
|
1360
1388
|
}]);
|
|
1361
1389
|
}(Schema);
|
|
@@ -1465,6 +1493,13 @@ var LiteralSchema = /*#__PURE__*/function (_Schema) {
|
|
|
1465
1493
|
value: function hidden() {
|
|
1466
1494
|
return new LiteralSchema(this.value, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
|
|
1467
1495
|
}
|
|
1496
|
+
}, {
|
|
1497
|
+
key: "executeCustomValidateAt",
|
|
1498
|
+
value: function executeCustomValidateAt(path, src) {
|
|
1499
|
+
return this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
|
|
1500
|
+
path: path
|
|
1501
|
+
});
|
|
1502
|
+
}
|
|
1468
1503
|
}, {
|
|
1469
1504
|
key: "executeSerialize",
|
|
1470
1505
|
value: function executeSerialize() {
|
|
@@ -1823,6 +1858,64 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
|
|
|
1823
1858
|
value: function hidden() {
|
|
1824
1859
|
return new UnionSchema(this.key, this.items, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
|
|
1825
1860
|
}
|
|
1861
|
+
}, {
|
|
1862
|
+
key: "executeCustomValidateAt",
|
|
1863
|
+
value: function executeCustomValidateAt(path, src) {
|
|
1864
|
+
var errors = this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
|
|
1865
|
+
path: path
|
|
1866
|
+
});
|
|
1867
|
+
// A tagged union's variants share the union's path, so `Internal.resolvePath`
|
|
1868
|
+
// stops here and a variant's OWN validator would never be reached. Dispatch
|
|
1869
|
+
// into the variant this value takes — the union is the only node that knows
|
|
1870
|
+
// which one that is.
|
|
1871
|
+
var matched = this.matchedVariant(src);
|
|
1872
|
+
if (matched) {
|
|
1873
|
+
errors.push.apply(errors, _toConsumableArray(matched["executeCustomValidateAt"](path, src)));
|
|
1874
|
+
}
|
|
1875
|
+
return errors;
|
|
1876
|
+
}
|
|
1877
|
+
|
|
1878
|
+
/**
|
|
1879
|
+
* The variant schema a value takes, for a TAGGED union (string `key`). `null`
|
|
1880
|
+
* for a literal union (its variants are leaves with nothing to descend into) or
|
|
1881
|
+
* when the value matches none of them — a structural error `executeValidate`
|
|
1882
|
+
* already reports.
|
|
1883
|
+
*/
|
|
1884
|
+
}, {
|
|
1885
|
+
key: "matchedVariant",
|
|
1886
|
+
value: function matchedVariant(src) {
|
|
1887
|
+
var key = this.key;
|
|
1888
|
+
if (typeof key !== "string" || !Array.isArray(this.items)) {
|
|
1889
|
+
return null;
|
|
1890
|
+
}
|
|
1891
|
+
if (src === null || _typeof(src) !== "object" || Array.isArray(src)) {
|
|
1892
|
+
return null;
|
|
1893
|
+
}
|
|
1894
|
+
var tag = src[key];
|
|
1895
|
+
if (typeof tag !== "string") {
|
|
1896
|
+
return null;
|
|
1897
|
+
}
|
|
1898
|
+
var objectSchemas = this.items;
|
|
1899
|
+
var _iterator4 = result._createForOfIteratorHelper(objectSchemas),
|
|
1900
|
+
_step4;
|
|
1901
|
+
try {
|
|
1902
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
1903
|
+
var item = _step4.value;
|
|
1904
|
+
if (!(item instanceof ObjectSchema)) {
|
|
1905
|
+
continue;
|
|
1906
|
+
}
|
|
1907
|
+
var tagSchema = item["items"][key];
|
|
1908
|
+
if (tagSchema instanceof LiteralSchema && tagSchema["value"] === tag) {
|
|
1909
|
+
return item;
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
} catch (err) {
|
|
1913
|
+
_iterator4.e(err);
|
|
1914
|
+
} finally {
|
|
1915
|
+
_iterator4.f();
|
|
1916
|
+
}
|
|
1917
|
+
return null;
|
|
1918
|
+
}
|
|
1826
1919
|
}, {
|
|
1827
1920
|
key: "executeSerialize",
|
|
1828
1921
|
value: function executeSerialize() {
|
|
@@ -2134,6 +2227,13 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2134
2227
|
value: function hidden() {
|
|
2135
2228
|
return new ImageSchema(this.options, this.opt, this.isRemote, this.customValidateFunctions, this.moduleMetadata, this.isReadonly, true, this.description);
|
|
2136
2229
|
}
|
|
2230
|
+
}, {
|
|
2231
|
+
key: "executeCustomValidateAt",
|
|
2232
|
+
value: function executeCustomValidateAt(path, src) {
|
|
2233
|
+
return this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
|
|
2234
|
+
path: path
|
|
2235
|
+
});
|
|
2236
|
+
}
|
|
2137
2237
|
}, {
|
|
2138
2238
|
key: "executeSerialize",
|
|
2139
2239
|
value: function executeSerialize() {
|
|
@@ -2309,6 +2409,13 @@ var RouteSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2309
2409
|
value: function hidden() {
|
|
2310
2410
|
return new RouteSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
|
|
2311
2411
|
}
|
|
2412
|
+
}, {
|
|
2413
|
+
key: "executeCustomValidateAt",
|
|
2414
|
+
value: function executeCustomValidateAt(path, src) {
|
|
2415
|
+
return this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
|
|
2416
|
+
path: path
|
|
2417
|
+
});
|
|
2418
|
+
}
|
|
2312
2419
|
}, {
|
|
2313
2420
|
key: "executeSerialize",
|
|
2314
2421
|
value: function executeSerialize() {
|
|
@@ -2847,6 +2954,13 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2847
2954
|
value: function hidden() {
|
|
2848
2955
|
return new RichTextSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
|
|
2849
2956
|
}
|
|
2957
|
+
}, {
|
|
2958
|
+
key: "executeCustomValidateAt",
|
|
2959
|
+
value: function executeCustomValidateAt(path, src) {
|
|
2960
|
+
return this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
|
|
2961
|
+
path: path
|
|
2962
|
+
});
|
|
2963
|
+
}
|
|
2850
2964
|
}, {
|
|
2851
2965
|
key: "executeSerialize",
|
|
2852
2966
|
value: function executeSerialize() {
|
|
@@ -2896,6 +3010,290 @@ var richtext = function richtext(options) {
|
|
|
2896
3010
|
return new RichTextSchema(options !== null && options !== void 0 ? options : {});
|
|
2897
3011
|
};
|
|
2898
3012
|
|
|
3013
|
+
function _regeneratorDefine(e, r, n, t) {
|
|
3014
|
+
var i = Object.defineProperty;
|
|
3015
|
+
try {
|
|
3016
|
+
i({}, "", {});
|
|
3017
|
+
} catch (e) {
|
|
3018
|
+
i = 0;
|
|
3019
|
+
}
|
|
3020
|
+
_regeneratorDefine = function (e, r, n, t) {
|
|
3021
|
+
function o(r, n) {
|
|
3022
|
+
_regeneratorDefine(e, r, function (e) {
|
|
3023
|
+
return this._invoke(r, n, e);
|
|
3024
|
+
});
|
|
3025
|
+
}
|
|
3026
|
+
r ? i ? i(e, r, {
|
|
3027
|
+
value: n,
|
|
3028
|
+
enumerable: !t,
|
|
3029
|
+
configurable: !t,
|
|
3030
|
+
writable: !t
|
|
3031
|
+
}) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
|
|
3032
|
+
}, _regeneratorDefine(e, r, n, t);
|
|
3033
|
+
}
|
|
3034
|
+
|
|
3035
|
+
function _regenerator() {
|
|
3036
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
3037
|
+
var e,
|
|
3038
|
+
t,
|
|
3039
|
+
r = "function" == typeof Symbol ? Symbol : {},
|
|
3040
|
+
n = r.iterator || "@@iterator",
|
|
3041
|
+
o = r.toStringTag || "@@toStringTag";
|
|
3042
|
+
function i(r, n, o, i) {
|
|
3043
|
+
var c = n && n.prototype instanceof Generator ? n : Generator,
|
|
3044
|
+
u = Object.create(c.prototype);
|
|
3045
|
+
return _regeneratorDefine(u, "_invoke", function (r, n, o) {
|
|
3046
|
+
var i,
|
|
3047
|
+
c,
|
|
3048
|
+
u,
|
|
3049
|
+
f = 0,
|
|
3050
|
+
p = o || [],
|
|
3051
|
+
y = !1,
|
|
3052
|
+
G = {
|
|
3053
|
+
p: 0,
|
|
3054
|
+
n: 0,
|
|
3055
|
+
v: e,
|
|
3056
|
+
a: d,
|
|
3057
|
+
f: d.bind(e, 4),
|
|
3058
|
+
d: function (t, r) {
|
|
3059
|
+
return i = t, c = 0, u = e, G.n = r, a;
|
|
3060
|
+
}
|
|
3061
|
+
};
|
|
3062
|
+
function d(r, n) {
|
|
3063
|
+
for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
|
|
3064
|
+
var o,
|
|
3065
|
+
i = p[t],
|
|
3066
|
+
d = G.p,
|
|
3067
|
+
l = i[2];
|
|
3068
|
+
r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
|
|
3069
|
+
}
|
|
3070
|
+
if (o || r > 1) return a;
|
|
3071
|
+
throw y = !0, n;
|
|
3072
|
+
}
|
|
3073
|
+
return function (o, p, l) {
|
|
3074
|
+
if (f > 1) throw TypeError("Generator is already running");
|
|
3075
|
+
for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
|
|
3076
|
+
i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
|
|
3077
|
+
try {
|
|
3078
|
+
if (f = 2, i) {
|
|
3079
|
+
if (c || (o = "next"), t = i[o]) {
|
|
3080
|
+
if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
|
|
3081
|
+
if (!t.done) return t;
|
|
3082
|
+
u = t.value, c < 2 && (c = 0);
|
|
3083
|
+
} else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
|
|
3084
|
+
i = e;
|
|
3085
|
+
} else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
|
|
3086
|
+
} catch (t) {
|
|
3087
|
+
i = e, c = 1, u = t;
|
|
3088
|
+
} finally {
|
|
3089
|
+
f = 1;
|
|
3090
|
+
}
|
|
3091
|
+
}
|
|
3092
|
+
return {
|
|
3093
|
+
value: t,
|
|
3094
|
+
done: y
|
|
3095
|
+
};
|
|
3096
|
+
};
|
|
3097
|
+
}(r, o, i), !0), u;
|
|
3098
|
+
}
|
|
3099
|
+
var a = {};
|
|
3100
|
+
function Generator() {}
|
|
3101
|
+
function GeneratorFunction() {}
|
|
3102
|
+
function GeneratorFunctionPrototype() {}
|
|
3103
|
+
t = Object.getPrototypeOf;
|
|
3104
|
+
var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
|
|
3105
|
+
return this;
|
|
3106
|
+
}), t),
|
|
3107
|
+
u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
|
|
3108
|
+
function f(e) {
|
|
3109
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
|
|
3110
|
+
}
|
|
3111
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
|
|
3112
|
+
return this;
|
|
3113
|
+
}), _regeneratorDefine(u, "toString", function () {
|
|
3114
|
+
return "[object Generator]";
|
|
3115
|
+
}), (_regenerator = function () {
|
|
3116
|
+
return {
|
|
3117
|
+
w: i,
|
|
3118
|
+
m: f
|
|
3119
|
+
};
|
|
3120
|
+
})();
|
|
3121
|
+
}
|
|
3122
|
+
|
|
3123
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
3124
|
+
try {
|
|
3125
|
+
var i = n[a](c),
|
|
3126
|
+
u = i.value;
|
|
3127
|
+
} catch (n) {
|
|
3128
|
+
return void e(n);
|
|
3129
|
+
}
|
|
3130
|
+
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
3131
|
+
}
|
|
3132
|
+
function _asyncToGenerator(n) {
|
|
3133
|
+
return function () {
|
|
3134
|
+
var t = this,
|
|
3135
|
+
e = arguments;
|
|
3136
|
+
return new Promise(function (r, o) {
|
|
3137
|
+
var a = n.apply(t, e);
|
|
3138
|
+
function _next(n) {
|
|
3139
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
3140
|
+
}
|
|
3141
|
+
function _throw(n) {
|
|
3142
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
3143
|
+
}
|
|
3144
|
+
_next(void 0);
|
|
3145
|
+
});
|
|
3146
|
+
};
|
|
3147
|
+
}
|
|
3148
|
+
|
|
3149
|
+
/**
|
|
3150
|
+
* The string used as the `_type` discriminator of a {@link JsonSource}.
|
|
3151
|
+
*/
|
|
3152
|
+
var JSON_VAL_EXTENSION_TAG = "json";
|
|
3153
|
+
|
|
3154
|
+
/**
|
|
3155
|
+
* The lazy import thunk a {@link JsonSource} carries at runtime. It is NOT part
|
|
3156
|
+
* of the {@link JsonSource} type because `Source` must stay JSON-serializable
|
|
3157
|
+
* (it is sent over the wire as `Json`); the thunk is a runtime-only detail,
|
|
3158
|
+
* read via {@link getJsonImport}.
|
|
3159
|
+
*/
|
|
3160
|
+
|
|
3161
|
+
/**
|
|
3162
|
+
* A JSON source represents a record/router entry whose value is stored in a
|
|
3163
|
+
* separate `*.val.json` file and loaded lazily via a dynamic `import()` thunk.
|
|
3164
|
+
*
|
|
3165
|
+
* This is what `c.json(() => import("./entry.val.json"))` returns.
|
|
3166
|
+
*
|
|
3167
|
+
* The *type* is a pure-JSON marker (`{ _type: "json", patch_id? }`) so that
|
|
3168
|
+
* `Source` stays JSON-serializable. At runtime the value additionally carries a
|
|
3169
|
+
* lazy import thunk (read via {@link getJsonImport}); over the wire only the
|
|
3170
|
+
* marker is sent.
|
|
3171
|
+
*
|
|
3172
|
+
* The phantom type parameter `T` is the (loosened, see {@link JsonOf}) type of
|
|
3173
|
+
* the value the JSON file resolves to. It is covariant: a `JsonSource` of a
|
|
3174
|
+
* narrower value type is assignable to a `JsonSource` of a wider one.
|
|
3175
|
+
*/
|
|
3176
|
+
|
|
3177
|
+
function json(importThunk) {
|
|
3178
|
+
return _defineProperty(_defineProperty({}, VAL_EXTENSION, JSON_VAL_EXTENSION_TAG), "_import", importThunk);
|
|
3179
|
+
}
|
|
3180
|
+
function isJson(obj) {
|
|
3181
|
+
return _typeof(obj) === "object" && obj !== null && VAL_EXTENSION in obj && obj[VAL_EXTENSION] === JSON_VAL_EXTENSION_TAG;
|
|
3182
|
+
}
|
|
3183
|
+
|
|
3184
|
+
/**
|
|
3185
|
+
* Reads the runtime-only lazy import thunk from a {@link JsonSource}. Returns
|
|
3186
|
+
* `undefined` for a transport marker (sent over the wire without the thunk).
|
|
3187
|
+
*/
|
|
3188
|
+
function getJsonImport(source) {
|
|
3189
|
+
var candidate = source._import;
|
|
3190
|
+
return typeof candidate === "function" ? candidate : undefined;
|
|
3191
|
+
}
|
|
3192
|
+
|
|
3193
|
+
/**
|
|
3194
|
+
* Recursively resolves every {@link JsonSource} marker in a source tree by
|
|
3195
|
+
* invoking its lazy import thunk, returning a fully-inlined source. This backs
|
|
3196
|
+
* the eager `fetchVal`/`useVal` path (load everything).
|
|
3197
|
+
*
|
|
3198
|
+
* Markers without a runtime thunk (transport markers received over the wire)
|
|
3199
|
+
* are left as-is — there is nothing to load from them locally. Other branded
|
|
3200
|
+
* leaf sources (file/image/remote/richtext) are returned untouched.
|
|
3201
|
+
*/
|
|
3202
|
+
function resolveJsonValues(_x) {
|
|
3203
|
+
return _resolveJsonValues.apply(this, arguments);
|
|
3204
|
+
}
|
|
3205
|
+
|
|
3206
|
+
/**
|
|
3207
|
+
* Loosens a (strict) schema source type `T` into the type that a
|
|
3208
|
+
* `resolveJsonModule` import of the backing `*.val.json` can actually satisfy.
|
|
3209
|
+
*
|
|
3210
|
+
* Why this is needed: TypeScript widens literals when it infers the type of a
|
|
3211
|
+
* JSON module (e.g. `"a"` becomes `string`, `1` becomes `number`, and a branded
|
|
3212
|
+
* `_type: "file"` becomes `_type: string`). A strict schema type (with literal
|
|
3213
|
+
* unions, `RawString` brands, etc.) would therefore reject a perfectly valid
|
|
3214
|
+
* JSON file. `JsonOf<T>` performs the same widening at the type level so the
|
|
3215
|
+
* JSON content typechecks against the schema as strictly as JSON allows. Runtime
|
|
3216
|
+
* validation enforces the rest.
|
|
3217
|
+
*
|
|
3218
|
+
* The transform distributes over unions and recurses through objects/arrays,
|
|
3219
|
+
* preserving structure while widening every leaf literal. Val object-unions are
|
|
3220
|
+
* always discriminated, so distribute-and-recurse is sufficient (the discriminant
|
|
3221
|
+
* literal widens to its base type, but the per-variant shape stays distinct and a
|
|
3222
|
+
* concrete JSON value still matches exactly one variant).
|
|
3223
|
+
*/
|
|
3224
|
+
function _resolveJsonValues() {
|
|
3225
|
+
_resolveJsonValues = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(source) {
|
|
3226
|
+
var thunk, loaded, entries;
|
|
3227
|
+
return _regenerator().w(function (_context2) {
|
|
3228
|
+
while (1) switch (_context2.n) {
|
|
3229
|
+
case 0:
|
|
3230
|
+
if (!isJson(source)) {
|
|
3231
|
+
_context2.n = 3;
|
|
3232
|
+
break;
|
|
3233
|
+
}
|
|
3234
|
+
thunk = getJsonImport(source);
|
|
3235
|
+
if (thunk) {
|
|
3236
|
+
_context2.n = 1;
|
|
3237
|
+
break;
|
|
3238
|
+
}
|
|
3239
|
+
return _context2.a(2, source);
|
|
3240
|
+
case 1:
|
|
3241
|
+
_context2.n = 2;
|
|
3242
|
+
return thunk();
|
|
3243
|
+
case 2:
|
|
3244
|
+
loaded = _context2.v["default"];
|
|
3245
|
+
return _context2.a(2, resolveJsonValues(loaded));
|
|
3246
|
+
case 3:
|
|
3247
|
+
if (!Array.isArray(source)) {
|
|
3248
|
+
_context2.n = 4;
|
|
3249
|
+
break;
|
|
3250
|
+
}
|
|
3251
|
+
return _context2.a(2, Promise.all(source.map(function (item) {
|
|
3252
|
+
return resolveJsonValues(item);
|
|
3253
|
+
})));
|
|
3254
|
+
case 4:
|
|
3255
|
+
if (!(source !== null && _typeof(source) === "object")) {
|
|
3256
|
+
_context2.n = 7;
|
|
3257
|
+
break;
|
|
3258
|
+
}
|
|
3259
|
+
if (!(VAL_EXTENSION in source)) {
|
|
3260
|
+
_context2.n = 5;
|
|
3261
|
+
break;
|
|
3262
|
+
}
|
|
3263
|
+
return _context2.a(2, source);
|
|
3264
|
+
case 5:
|
|
3265
|
+
_context2.n = 6;
|
|
3266
|
+
return Promise.all(Object.entries(source).map(/*#__PURE__*/function () {
|
|
3267
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref2) {
|
|
3268
|
+
var _ref4, key, value, _t, _t2;
|
|
3269
|
+
return _regenerator().w(function (_context) {
|
|
3270
|
+
while (1) switch (_context.n) {
|
|
3271
|
+
case 0:
|
|
3272
|
+
_ref4 = _slicedToArray(_ref2, 2), key = _ref4[0], value = _ref4[1];
|
|
3273
|
+
_t = key;
|
|
3274
|
+
_context.n = 1;
|
|
3275
|
+
return resolveJsonValues(value);
|
|
3276
|
+
case 1:
|
|
3277
|
+
_t2 = _context.v;
|
|
3278
|
+
return _context.a(2, [_t, _t2]);
|
|
3279
|
+
}
|
|
3280
|
+
}, _callee);
|
|
3281
|
+
}));
|
|
3282
|
+
return function (_x2) {
|
|
3283
|
+
return _ref3.apply(this, arguments);
|
|
3284
|
+
};
|
|
3285
|
+
}()));
|
|
3286
|
+
case 6:
|
|
3287
|
+
entries = _context2.v;
|
|
3288
|
+
return _context2.a(2, Object.fromEntries(entries));
|
|
3289
|
+
case 7:
|
|
3290
|
+
return _context2.a(2, source);
|
|
3291
|
+
}
|
|
3292
|
+
}, _callee2);
|
|
3293
|
+
}));
|
|
3294
|
+
return _resolveJsonValues.apply(this, arguments);
|
|
3295
|
+
}
|
|
3296
|
+
|
|
2899
3297
|
var RegEx = /^(https?:\/\/[^/]+)\/file\/p\/([^/]+)\/b\/([^/]+)\/v\/([^/]+)\/h\/([^/]+)\/f\/([^/]+)\/p\/(.+)$/;
|
|
2900
3298
|
function splitRemoteRef(ref) {
|
|
2901
3299
|
if (ref[0] === "/") {
|
|
@@ -2937,6 +3335,20 @@ function splitRemoteRef(ref) {
|
|
|
2937
3335
|
};
|
|
2938
3336
|
}
|
|
2939
3337
|
|
|
3338
|
+
/**
|
|
3339
|
+
* The source type of a `.jsonValues()` record: every entry value is EITHER a
|
|
3340
|
+
* lazily loaded {@link JsonSource} whose resolved content is the (loosened, see
|
|
3341
|
+
* {@link JsonOf}) item type, OR the item value written inline.
|
|
3342
|
+
*
|
|
3343
|
+
* Inline values are accepted by the TYPE on purpose: hand-authoring an entry
|
|
3344
|
+
* directly in the `.val.ts` (or copying one in from a non-jsonValues record) is
|
|
3345
|
+
* the natural first thing to write, and a type error there is a dead end — the
|
|
3346
|
+
* author cannot see what to write instead. Validation reports the inline entry
|
|
3347
|
+
* (`jsonValues:extract-entry`) and `val validate --fix` moves it into its own
|
|
3348
|
+
* `*.val.json`, so the mistake is caught and repaired instead of blocking
|
|
3349
|
+
* authoring.
|
|
3350
|
+
*/
|
|
3351
|
+
|
|
2940
3352
|
var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
2941
3353
|
function RecordSchema(item) {
|
|
2942
3354
|
var _this;
|
|
@@ -2948,9 +3360,10 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2948
3360
|
var isReadonly = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
2949
3361
|
var isHidden = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
|
|
2950
3362
|
var description = arguments.length > 8 ? arguments[8] : undefined;
|
|
3363
|
+
var isJsonValues = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : false;
|
|
3364
|
+
var renderInput = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : null;
|
|
2951
3365
|
_classCallCheck(this, RecordSchema);
|
|
2952
3366
|
_this = _callSuper(this, RecordSchema);
|
|
2953
|
-
_defineProperty(_this, "renderInput", null);
|
|
2954
3367
|
_this.item = item;
|
|
2955
3368
|
_this.opt = opt;
|
|
2956
3369
|
_this.customValidateFunctions = customValidateFunctions;
|
|
@@ -2960,18 +3373,20 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2960
3373
|
_this.isReadonly = isReadonly;
|
|
2961
3374
|
_this.isHidden = isHidden;
|
|
2962
3375
|
_this.description = description;
|
|
3376
|
+
_this.isJsonValues = isJsonValues;
|
|
3377
|
+
_this.renderInput = renderInput;
|
|
2963
3378
|
return _this;
|
|
2964
3379
|
}
|
|
2965
3380
|
_inherits(RecordSchema, _Schema);
|
|
2966
3381
|
return _createClass(RecordSchema, [{
|
|
2967
3382
|
key: "describe",
|
|
2968
3383
|
value: function describe(description) {
|
|
2969
|
-
return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined);
|
|
3384
|
+
return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.isJsonValues, this.renderInput);
|
|
2970
3385
|
}
|
|
2971
3386
|
}, {
|
|
2972
3387
|
key: "validate",
|
|
2973
3388
|
value: function validate(validationFunction) {
|
|
2974
|
-
return new RecordSchema(this.item, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description);
|
|
3389
|
+
return new RecordSchema(this.item, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, this.isJsonValues, this.renderInput);
|
|
2975
3390
|
}
|
|
2976
3391
|
}, {
|
|
2977
3392
|
key: "executeValidate",
|
|
@@ -3086,7 +3501,10 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3086
3501
|
_this2.markKeyErrorsAtPath(entryErr, subPath);
|
|
3087
3502
|
}
|
|
3088
3503
|
error = _this2.mergeValidationErrors(error, entryErr);
|
|
3089
|
-
} else {
|
|
3504
|
+
} else if (_this2.isJsonValues && isJson(elem)) ; else {
|
|
3505
|
+
// Falls through for a jsonValues record whose entry content is inlined
|
|
3506
|
+
// (loaded in the UI, or hand-authored): same as a plain record — validate
|
|
3507
|
+
// the value against the item schema.
|
|
3090
3508
|
var subError = _this2.item["executeValidate"](subPath, elem);
|
|
3091
3509
|
error = _this2.mergeValidationErrors(error, subError);
|
|
3092
3510
|
}
|
|
@@ -3327,29 +3745,61 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3327
3745
|
}, {
|
|
3328
3746
|
key: "nullable",
|
|
3329
3747
|
value: function nullable() {
|
|
3330
|
-
return new RecordSchema(this.item, true, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description);
|
|
3748
|
+
return new RecordSchema(this.item, true, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, this.isJsonValues, this.renderInput);
|
|
3331
3749
|
}
|
|
3332
3750
|
}, {
|
|
3333
3751
|
key: "readonly",
|
|
3334
3752
|
value: function readonly() {
|
|
3335
|
-
return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, true, this.isHidden, this.description);
|
|
3753
|
+
return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, true, this.isHidden, this.description, this.isJsonValues, this.renderInput);
|
|
3336
3754
|
}
|
|
3337
3755
|
}, {
|
|
3338
3756
|
key: "hidden",
|
|
3339
3757
|
value: function hidden() {
|
|
3340
|
-
return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, true, this.description);
|
|
3758
|
+
return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, true, this.description, this.isJsonValues, this.renderInput);
|
|
3341
3759
|
}
|
|
3342
3760
|
}, {
|
|
3343
3761
|
key: "router",
|
|
3344
3762
|
value: function router(_router) {
|
|
3345
|
-
return new RecordSchema(this.item, this.opt, this.customValidateFunctions, _router, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description);
|
|
3763
|
+
return new RecordSchema(this.item, this.opt, this.customValidateFunctions, _router, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, this.isJsonValues, this.renderInput);
|
|
3346
3764
|
}
|
|
3347
3765
|
}, {
|
|
3348
3766
|
key: "remote",
|
|
3349
3767
|
value: function remote() {
|
|
3350
3768
|
return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions ? _objectSpread2(_objectSpread2({}, this.mediaOptions), {}, {
|
|
3351
3769
|
remote: true
|
|
3352
|
-
}) : undefined, this.isReadonly, this.isHidden, this.description);
|
|
3770
|
+
}) : undefined, this.isReadonly, this.isHidden, this.description, this.isJsonValues, this.renderInput);
|
|
3771
|
+
}
|
|
3772
|
+
|
|
3773
|
+
/**
|
|
3774
|
+
* Store each entry's value in its own lazily-loaded `*.val.json` file instead
|
|
3775
|
+
* of inlining it in the `.val.ts` module. Entry values become
|
|
3776
|
+
* {@link JsonSource} thunks (`c.json(() => import("./entry.val.json"))`),
|
|
3777
|
+
* which lets the runtime, the Studio and validation work one entry at a time
|
|
3778
|
+
* so a record/router can scale to many thousands of entries.
|
|
3779
|
+
*
|
|
3780
|
+
* Not supported on image/file galleries (`s.images()` / `s.files()`).
|
|
3781
|
+
*
|
|
3782
|
+
* Only supported on a module's ROOT record/router — a `.jsonValues()` record
|
|
3783
|
+
* nested inside an object/array/record is rejected at startup with a module
|
|
3784
|
+
* error, because the single-entry fetch endpoint, the Studio's content
|
|
3785
|
+
* substitution and content validation are all root-only.
|
|
3786
|
+
*/
|
|
3787
|
+
}, {
|
|
3788
|
+
key: "jsonValues",
|
|
3789
|
+
value: function jsonValues() {
|
|
3790
|
+
if (this.mediaOptions) {
|
|
3791
|
+
throw new Error(".jsonValues() cannot be used with image/file galleries (s.images()/s.files())");
|
|
3792
|
+
}
|
|
3793
|
+
if (this.customValidateFunctions.length > 0) {
|
|
3794
|
+
// `.jsonValues()` changes the source shape to JsonSource entries, so a
|
|
3795
|
+
// validator typed against the previous Src cannot be carried over. Refusing
|
|
3796
|
+
// is the point: silently dropping it left the developer looking at a
|
|
3797
|
+
// `.validate(...)` in their source file that never ran anywhere.
|
|
3798
|
+
throw new Error(".jsonValues() must come BEFORE .validate(): a validator added first is typed against the un-lazy source shape and cannot be carried over. Write s.record(...).jsonValues().validate(...) instead.");
|
|
3799
|
+
}
|
|
3800
|
+
return new RecordSchema(this.item, this.opt,
|
|
3801
|
+
// Empty by construction: the guard above rejects any that were registered.
|
|
3802
|
+
[], this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, true, this.renderInput);
|
|
3353
3803
|
}
|
|
3354
3804
|
}, {
|
|
3355
3805
|
key: "getRouterValidations",
|
|
@@ -3393,6 +3843,13 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3393
3843
|
}
|
|
3394
3844
|
return false;
|
|
3395
3845
|
}
|
|
3846
|
+
}, {
|
|
3847
|
+
key: "executeCustomValidateAt",
|
|
3848
|
+
value: function executeCustomValidateAt(path, src) {
|
|
3849
|
+
return this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
|
|
3850
|
+
path: path
|
|
3851
|
+
});
|
|
3852
|
+
}
|
|
3396
3853
|
}, {
|
|
3397
3854
|
key: "executeSerialize",
|
|
3398
3855
|
value: function executeSerialize() {
|
|
@@ -3404,6 +3861,7 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3404
3861
|
opt: this.opt,
|
|
3405
3862
|
router: (_this$currentRouter = this.currentRouter) === null || _this$currentRouter === void 0 ? void 0 : _this$currentRouter.getRouterId(),
|
|
3406
3863
|
customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0,
|
|
3864
|
+
jsonValues: this.isJsonValues ? true : undefined,
|
|
3407
3865
|
readonly: this.isReadonly,
|
|
3408
3866
|
hidden: this.isHidden,
|
|
3409
3867
|
description: this.description
|
|
@@ -3419,6 +3877,18 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3419
3877
|
}
|
|
3420
3878
|
return result;
|
|
3421
3879
|
}
|
|
3880
|
+
|
|
3881
|
+
/**
|
|
3882
|
+
* Validate the loaded content of a single `.jsonValues()` entry against the
|
|
3883
|
+
* item schema. The server calls this once it has loaded the backing
|
|
3884
|
+
* `*.val.json` for an entry (the deep validation that `executeValidate`
|
|
3885
|
+
* defers).
|
|
3886
|
+
*/
|
|
3887
|
+
}, {
|
|
3888
|
+
key: "validateJsonEntryContent",
|
|
3889
|
+
value: function validateJsonEntryContent(path, content) {
|
|
3890
|
+
return this.item["executeValidate"](path, content);
|
|
3891
|
+
}
|
|
3422
3892
|
}, {
|
|
3423
3893
|
key: "executeRender",
|
|
3424
3894
|
value: function executeRender(sourcePath, src) {
|
|
@@ -3431,6 +3901,13 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3431
3901
|
if (itemSrc === null || itemSrc === undefined) {
|
|
3432
3902
|
continue;
|
|
3433
3903
|
}
|
|
3904
|
+
if (isJson(itemSrc)) {
|
|
3905
|
+
// An un-loaded `.jsonValues()` entry: an opaque marker, not the item this
|
|
3906
|
+
// schema describes. Skipping it is what makes rendering a partially
|
|
3907
|
+
// loaded record work — the result comes out covering exactly the loaded
|
|
3908
|
+
// keys, and the caller renders a placeholder for the rest.
|
|
3909
|
+
continue;
|
|
3910
|
+
}
|
|
3434
3911
|
var subPath = unsafeCreateSourcePath(sourcePath, _key);
|
|
3435
3912
|
var itemResult = this.item["executeRender"](subPath, itemSrc);
|
|
3436
3913
|
for (var keyS in itemResult) {
|
|
@@ -3448,49 +3925,55 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
3448
3925
|
message: "Unknown layout type: " + layout
|
|
3449
3926
|
};
|
|
3450
3927
|
}
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
};
|
|
3928
|
+
var items = [];
|
|
3929
|
+
for (var _i = 0, _Object$entries = Object.entries(src); _i < _Object$entries.length; _i++) {
|
|
3930
|
+
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
3931
|
+
_key3 = _Object$entries$_i[0],
|
|
3932
|
+
val = _Object$entries$_i[1];
|
|
3933
|
+
if (isJson(val)) {
|
|
3934
|
+
continue; // as above: nothing to select from an un-loaded entry
|
|
3935
|
+
}
|
|
3936
|
+
// Per KEY, not per record: `select` is user code, and one entry whose
|
|
3937
|
+
// data trips it up must not take out the whole list.
|
|
3938
|
+
try {
|
|
3939
|
+
// NB NB: display is actually defined by the user
|
|
3940
|
+
var _prepare = prepare({
|
|
3941
|
+
key: _key3,
|
|
3942
|
+
val: val
|
|
3943
|
+
}),
|
|
3944
|
+
title = _prepare.title,
|
|
3945
|
+
subtitle = _prepare.subtitle,
|
|
3946
|
+
image = _prepare.image;
|
|
3947
|
+
items.push([_key3, {
|
|
3948
|
+
title: title,
|
|
3949
|
+
subtitle: subtitle,
|
|
3950
|
+
image: image
|
|
3951
|
+
}]);
|
|
3952
|
+
} catch (e) {
|
|
3953
|
+
res[unsafeCreateSourcePath(sourcePath, _key3)] = {
|
|
3954
|
+
status: "error",
|
|
3955
|
+
message: e instanceof Error ? e.message : "Unknown error"
|
|
3956
|
+
};
|
|
3957
|
+
}
|
|
3482
3958
|
}
|
|
3959
|
+
res[sourcePath] = {
|
|
3960
|
+
status: "success",
|
|
3961
|
+
data: {
|
|
3962
|
+
layout: "list",
|
|
3963
|
+
parent: "record",
|
|
3964
|
+
items: items
|
|
3965
|
+
}
|
|
3966
|
+
};
|
|
3483
3967
|
}
|
|
3484
3968
|
return res;
|
|
3485
3969
|
}
|
|
3486
3970
|
}, {
|
|
3487
3971
|
key: "render",
|
|
3488
3972
|
value: function render(input) {
|
|
3489
|
-
this.
|
|
3973
|
+
return new RecordSchema(this.item, this.opt, this.customValidateFunctions, this.currentRouter, this.keySchema, this.mediaOptions, this.isReadonly, this.isHidden, this.description, this.isJsonValues, {
|
|
3490
3974
|
layout: input.as,
|
|
3491
3975
|
select: input.select
|
|
3492
|
-
};
|
|
3493
|
-
return this;
|
|
3976
|
+
});
|
|
3494
3977
|
}
|
|
3495
3978
|
}]);
|
|
3496
3979
|
}(Schema);
|
|
@@ -3605,6 +4088,13 @@ function resolvePath(path, valModule, schema) {
|
|
|
3605
4088
|
}
|
|
3606
4089
|
resolvedSource = resolvedSource[part];
|
|
3607
4090
|
resolvedSchema = resolvedSchema instanceof RecordSchema ? (_resolvedSchema2 = resolvedSchema) === null || _resolvedSchema2 === void 0 ? void 0 : _resolvedSchema2["item"] : resolvedSchema.item;
|
|
4091
|
+
// A `.jsonValues()` entry value is a lazily-loaded JsonSource marker. We
|
|
4092
|
+
// can resolve the entry itself (schema is now `item`), but we cannot
|
|
4093
|
+
// descend deeper until the backing `*.val.json` content has been loaded
|
|
4094
|
+
// and substituted into the source tree (done by the UI/server layer).
|
|
4095
|
+
if (isJson(resolvedSource) && parts.length > 0) {
|
|
4096
|
+
throw Error("Cannot resolve path into a jsonValues entry until its content is loaded. Path: ".concat(path));
|
|
4097
|
+
}
|
|
3608
4098
|
} else if (isObjectSchema(resolvedSchema)) {
|
|
3609
4099
|
if (_typeof(resolvedSource) !== "object") {
|
|
3610
4100
|
throw Error("Schema type error: expected source to be type of object, but got ".concat(_typeof(resolvedSource)));
|
|
@@ -3809,6 +4299,16 @@ function safeResolvePath(path, valModule, schema) {
|
|
|
3809
4299
|
}
|
|
3810
4300
|
resolvedSource = resolvedSource[part];
|
|
3811
4301
|
resolvedSchema = resolvedSchema instanceof RecordSchema ? (_resolvedSchema4 = resolvedSchema) === null || _resolvedSchema4 === void 0 ? void 0 : _resolvedSchema4["item"] : resolvedSchema.item;
|
|
4302
|
+
// jsonValues entry: cannot descend deeper until the backing `*.val.json`
|
|
4303
|
+
// content is loaded into the source tree.
|
|
4304
|
+
if (isJson(resolvedSource) && parts.length > 0) {
|
|
4305
|
+
return {
|
|
4306
|
+
v: {
|
|
4307
|
+
status: "error",
|
|
4308
|
+
message: "Cannot resolve path into a jsonValues entry until its content is loaded. Path: ".concat(path)
|
|
4309
|
+
}
|
|
4310
|
+
};
|
|
4311
|
+
}
|
|
3812
4312
|
} else if (isObjectSchema(resolvedSchema)) {
|
|
3813
4313
|
if (resolvedSource === undefined) {
|
|
3814
4314
|
return {
|
|
@@ -4144,6 +4644,13 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4144
4644
|
min: _min
|
|
4145
4645
|
}), this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description);
|
|
4146
4646
|
}
|
|
4647
|
+
}, {
|
|
4648
|
+
key: "executeCustomValidateAt",
|
|
4649
|
+
value: function executeCustomValidateAt(path, src) {
|
|
4650
|
+
return this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
|
|
4651
|
+
path: path
|
|
4652
|
+
});
|
|
4653
|
+
}
|
|
4147
4654
|
}, {
|
|
4148
4655
|
key: "executeSerialize",
|
|
4149
4656
|
value: function executeSerialize() {
|
|
@@ -4258,6 +4765,13 @@ var BooleanSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4258
4765
|
value: function hidden() {
|
|
4259
4766
|
return new BooleanSchema(this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
|
|
4260
4767
|
}
|
|
4768
|
+
}, {
|
|
4769
|
+
key: "executeCustomValidateAt",
|
|
4770
|
+
value: function executeCustomValidateAt(path, src) {
|
|
4771
|
+
return this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
|
|
4772
|
+
path: path
|
|
4773
|
+
});
|
|
4774
|
+
}
|
|
4261
4775
|
}, {
|
|
4262
4776
|
key: "executeSerialize",
|
|
4263
4777
|
value: function executeSerialize() {
|
|
@@ -4452,6 +4966,13 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4452
4966
|
value: function hidden() {
|
|
4453
4967
|
return new KeyOfSchema(this.schema, this.sourcePath, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
|
|
4454
4968
|
}
|
|
4969
|
+
}, {
|
|
4970
|
+
key: "executeCustomValidateAt",
|
|
4971
|
+
value: function executeCustomValidateAt(path, src) {
|
|
4972
|
+
return this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
|
|
4973
|
+
path: path
|
|
4974
|
+
});
|
|
4975
|
+
}
|
|
4455
4976
|
}, {
|
|
4456
4977
|
key: "executeSerialize",
|
|
4457
4978
|
value: function executeSerialize() {
|
|
@@ -4697,6 +5218,13 @@ var DateSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4697
5218
|
value: function hidden() {
|
|
4698
5219
|
return new DateSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
|
|
4699
5220
|
}
|
|
5221
|
+
}, {
|
|
5222
|
+
key: "executeCustomValidateAt",
|
|
5223
|
+
value: function executeCustomValidateAt(path, src) {
|
|
5224
|
+
return this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
|
|
5225
|
+
path: path
|
|
5226
|
+
});
|
|
5227
|
+
}
|
|
4700
5228
|
}, {
|
|
4701
5229
|
key: "executeSerialize",
|
|
4702
5230
|
value: function executeSerialize() {
|
|
@@ -4894,6 +5422,13 @@ var DateTimeSchema = /*#__PURE__*/function (_Schema) {
|
|
|
4894
5422
|
value: function hidden() {
|
|
4895
5423
|
return new DateTimeSchema(this.options, this.opt, this.customValidateFunctions, this.isReadonly, true, this.description);
|
|
4896
5424
|
}
|
|
5425
|
+
}, {
|
|
5426
|
+
key: "executeCustomValidateAt",
|
|
5427
|
+
value: function executeCustomValidateAt(path, src) {
|
|
5428
|
+
return this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
|
|
5429
|
+
path: path
|
|
5430
|
+
});
|
|
5431
|
+
}
|
|
4897
5432
|
}, {
|
|
4898
5433
|
key: "executeSerialize",
|
|
4899
5434
|
value: function executeSerialize() {
|
|
@@ -5135,7 +5670,8 @@ var initVal = function initVal(config) {
|
|
|
5135
5670
|
define: define,
|
|
5136
5671
|
remote: initRemote(),
|
|
5137
5672
|
file: initFile(config),
|
|
5138
|
-
image: initImage(config)
|
|
5673
|
+
image: initImage(config),
|
|
5674
|
+
json: json
|
|
5139
5675
|
},
|
|
5140
5676
|
s: s,
|
|
5141
5677
|
config: config
|
|
@@ -5162,160 +5698,6 @@ function modules(config, modules) {
|
|
|
5162
5698
|
};
|
|
5163
5699
|
}
|
|
5164
5700
|
|
|
5165
|
-
function _regeneratorValues(e) {
|
|
5166
|
-
if (null != e) {
|
|
5167
|
-
var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"],
|
|
5168
|
-
r = 0;
|
|
5169
|
-
if (t) return t.call(e);
|
|
5170
|
-
if ("function" == typeof e.next) return e;
|
|
5171
|
-
if (!isNaN(e.length)) return {
|
|
5172
|
-
next: function () {
|
|
5173
|
-
return e && r >= e.length && (e = void 0), {
|
|
5174
|
-
value: e && e[r++],
|
|
5175
|
-
done: !e
|
|
5176
|
-
};
|
|
5177
|
-
}
|
|
5178
|
-
};
|
|
5179
|
-
}
|
|
5180
|
-
throw new TypeError(typeof e + " is not iterable");
|
|
5181
|
-
}
|
|
5182
|
-
|
|
5183
|
-
function _regeneratorDefine(e, r, n, t) {
|
|
5184
|
-
var i = Object.defineProperty;
|
|
5185
|
-
try {
|
|
5186
|
-
i({}, "", {});
|
|
5187
|
-
} catch (e) {
|
|
5188
|
-
i = 0;
|
|
5189
|
-
}
|
|
5190
|
-
_regeneratorDefine = function (e, r, n, t) {
|
|
5191
|
-
function o(r, n) {
|
|
5192
|
-
_regeneratorDefine(e, r, function (e) {
|
|
5193
|
-
return this._invoke(r, n, e);
|
|
5194
|
-
});
|
|
5195
|
-
}
|
|
5196
|
-
r ? i ? i(e, r, {
|
|
5197
|
-
value: n,
|
|
5198
|
-
enumerable: !t,
|
|
5199
|
-
configurable: !t,
|
|
5200
|
-
writable: !t
|
|
5201
|
-
}) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
|
|
5202
|
-
}, _regeneratorDefine(e, r, n, t);
|
|
5203
|
-
}
|
|
5204
|
-
|
|
5205
|
-
function _regenerator() {
|
|
5206
|
-
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
5207
|
-
var e,
|
|
5208
|
-
t,
|
|
5209
|
-
r = "function" == typeof Symbol ? Symbol : {},
|
|
5210
|
-
n = r.iterator || "@@iterator",
|
|
5211
|
-
o = r.toStringTag || "@@toStringTag";
|
|
5212
|
-
function i(r, n, o, i) {
|
|
5213
|
-
var c = n && n.prototype instanceof Generator ? n : Generator,
|
|
5214
|
-
u = Object.create(c.prototype);
|
|
5215
|
-
return _regeneratorDefine(u, "_invoke", function (r, n, o) {
|
|
5216
|
-
var i,
|
|
5217
|
-
c,
|
|
5218
|
-
u,
|
|
5219
|
-
f = 0,
|
|
5220
|
-
p = o || [],
|
|
5221
|
-
y = !1,
|
|
5222
|
-
G = {
|
|
5223
|
-
p: 0,
|
|
5224
|
-
n: 0,
|
|
5225
|
-
v: e,
|
|
5226
|
-
a: d,
|
|
5227
|
-
f: d.bind(e, 4),
|
|
5228
|
-
d: function (t, r) {
|
|
5229
|
-
return i = t, c = 0, u = e, G.n = r, a;
|
|
5230
|
-
}
|
|
5231
|
-
};
|
|
5232
|
-
function d(r, n) {
|
|
5233
|
-
for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
|
|
5234
|
-
var o,
|
|
5235
|
-
i = p[t],
|
|
5236
|
-
d = G.p,
|
|
5237
|
-
l = i[2];
|
|
5238
|
-
r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
|
|
5239
|
-
}
|
|
5240
|
-
if (o || r > 1) return a;
|
|
5241
|
-
throw y = !0, n;
|
|
5242
|
-
}
|
|
5243
|
-
return function (o, p, l) {
|
|
5244
|
-
if (f > 1) throw TypeError("Generator is already running");
|
|
5245
|
-
for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
|
|
5246
|
-
i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
|
|
5247
|
-
try {
|
|
5248
|
-
if (f = 2, i) {
|
|
5249
|
-
if (c || (o = "next"), t = i[o]) {
|
|
5250
|
-
if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
|
|
5251
|
-
if (!t.done) return t;
|
|
5252
|
-
u = t.value, c < 2 && (c = 0);
|
|
5253
|
-
} else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
|
|
5254
|
-
i = e;
|
|
5255
|
-
} else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
|
|
5256
|
-
} catch (t) {
|
|
5257
|
-
i = e, c = 1, u = t;
|
|
5258
|
-
} finally {
|
|
5259
|
-
f = 1;
|
|
5260
|
-
}
|
|
5261
|
-
}
|
|
5262
|
-
return {
|
|
5263
|
-
value: t,
|
|
5264
|
-
done: y
|
|
5265
|
-
};
|
|
5266
|
-
};
|
|
5267
|
-
}(r, o, i), !0), u;
|
|
5268
|
-
}
|
|
5269
|
-
var a = {};
|
|
5270
|
-
function Generator() {}
|
|
5271
|
-
function GeneratorFunction() {}
|
|
5272
|
-
function GeneratorFunctionPrototype() {}
|
|
5273
|
-
t = Object.getPrototypeOf;
|
|
5274
|
-
var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
|
|
5275
|
-
return this;
|
|
5276
|
-
}), t),
|
|
5277
|
-
u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
|
|
5278
|
-
function f(e) {
|
|
5279
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
|
|
5280
|
-
}
|
|
5281
|
-
return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
|
|
5282
|
-
return this;
|
|
5283
|
-
}), _regeneratorDefine(u, "toString", function () {
|
|
5284
|
-
return "[object Generator]";
|
|
5285
|
-
}), (_regenerator = function () {
|
|
5286
|
-
return {
|
|
5287
|
-
w: i,
|
|
5288
|
-
m: f
|
|
5289
|
-
};
|
|
5290
|
-
})();
|
|
5291
|
-
}
|
|
5292
|
-
|
|
5293
|
-
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
5294
|
-
try {
|
|
5295
|
-
var i = n[a](c),
|
|
5296
|
-
u = i.value;
|
|
5297
|
-
} catch (n) {
|
|
5298
|
-
return void e(n);
|
|
5299
|
-
}
|
|
5300
|
-
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
5301
|
-
}
|
|
5302
|
-
function _asyncToGenerator(n) {
|
|
5303
|
-
return function () {
|
|
5304
|
-
var t = this,
|
|
5305
|
-
e = arguments;
|
|
5306
|
-
return new Promise(function (r, o) {
|
|
5307
|
-
var a = n.apply(t, e);
|
|
5308
|
-
function _next(n) {
|
|
5309
|
-
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
5310
|
-
}
|
|
5311
|
-
function _throw(n) {
|
|
5312
|
-
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
5313
|
-
}
|
|
5314
|
-
_next(void 0);
|
|
5315
|
-
});
|
|
5316
|
-
};
|
|
5317
|
-
}
|
|
5318
|
-
|
|
5319
5701
|
/**
|
|
5320
5702
|
* From: https://github.com/kawanet/sha256-uint8array/commit/a035f83824c319d01ca1e7559fdcf1632c0cd6c4
|
|
5321
5703
|
*
|
|
@@ -5661,6 +6043,29 @@ function getTextEncoder() {
|
|
|
5661
6043
|
}
|
|
5662
6044
|
return textEncoder;
|
|
5663
6045
|
}
|
|
6046
|
+
function errorMessage(e) {
|
|
6047
|
+
// NOT `e instanceof Error`. Val modules are evaluated inside a `node:vm`
|
|
6048
|
+
// context, so an error thrown from inside the sandbox is built from THAT
|
|
6049
|
+
// realm's Error constructor and fails the instanceof check - and
|
|
6050
|
+
// JSON.stringify flattens it to "{}", throwing away the only useful part.
|
|
6051
|
+
// Duck-type the message instead (the same reason the schema check below
|
|
6052
|
+
// avoids `instanceof Schema`).
|
|
6053
|
+
if (_typeof(e) === "object" && e !== null && "message" in e) {
|
|
6054
|
+
var message = e.message;
|
|
6055
|
+
if (typeof message === "string") {
|
|
6056
|
+
return message;
|
|
6057
|
+
}
|
|
6058
|
+
}
|
|
6059
|
+
if (typeof e === "string") {
|
|
6060
|
+
return e;
|
|
6061
|
+
}
|
|
6062
|
+
try {
|
|
6063
|
+
var _JSON$stringify;
|
|
6064
|
+
return (_JSON$stringify = JSON.stringify(e)) !== null && _JSON$stringify !== void 0 ? _JSON$stringify : String(e);
|
|
6065
|
+
} catch (_unused) {
|
|
6066
|
+
return String(e);
|
|
6067
|
+
}
|
|
6068
|
+
}
|
|
5664
6069
|
function hash(input) {
|
|
5665
6070
|
if (_typeof(input) === "object") {
|
|
5666
6071
|
return hashObject(input);
|
|
@@ -5715,127 +6120,159 @@ function extractValModules(_x) {
|
|
|
5715
6120
|
}
|
|
5716
6121
|
function _extractValModules() {
|
|
5717
6122
|
_extractValModules = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(valModules) {
|
|
5718
|
-
var moduleErrors, addModuleError, sources, schemas, serializedSchemas, configSha, sourcesSha, baseSha, schemaSha,
|
|
5719
|
-
return _regenerator().w(function (
|
|
5720
|
-
while (1) switch (
|
|
6123
|
+
var moduleErrors, addModuleError, sources, schemas, serializedSchemas, configSha, sourcesSha, baseSha, schemaSha, moduleIdx, module, at, value, path, schema, source, serializedSchema, pathM, _t, _t2;
|
|
6124
|
+
return _regenerator().w(function (_context) {
|
|
6125
|
+
while (1) switch (_context.p = _context.n) {
|
|
5721
6126
|
case 0:
|
|
5722
|
-
moduleErrors = [];
|
|
5723
|
-
|
|
5724
|
-
|
|
6127
|
+
moduleErrors = []; // NOTE: push (not index assignment) - a sparse array makes consumers that
|
|
6128
|
+
// use Array.prototype.find (which visits holes) crash on undefined entries.
|
|
6129
|
+
addModuleError = function addModuleError(message, path) {
|
|
6130
|
+
moduleErrors.push({
|
|
5725
6131
|
message: message,
|
|
5726
6132
|
path: path
|
|
5727
|
-
};
|
|
6133
|
+
});
|
|
5728
6134
|
};
|
|
5729
6135
|
sources = {};
|
|
5730
6136
|
schemas = {};
|
|
5731
6137
|
serializedSchemas = {};
|
|
5732
6138
|
configSha = hash(JSON.stringify(valModules.config));
|
|
5733
6139
|
sourcesSha = "";
|
|
5734
|
-
baseSha = configSha;
|
|
5735
|
-
|
|
5736
|
-
|
|
5737
|
-
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
_context.n = 1;
|
|
5744
|
-
break;
|
|
5745
|
-
}
|
|
5746
|
-
addModuleError("val.modules is missing 'def' property", moduleIdx);
|
|
5747
|
-
return _context.a(2, 0);
|
|
5748
|
-
case 1:
|
|
5749
|
-
if (!(typeof module.def !== "function")) {
|
|
5750
|
-
_context.n = 2;
|
|
5751
|
-
break;
|
|
5752
|
-
}
|
|
5753
|
-
addModuleError("val.modules 'def' property is not a function", moduleIdx);
|
|
5754
|
-
return _context.a(2, 0);
|
|
5755
|
-
case 2:
|
|
5756
|
-
_context.n = 3;
|
|
5757
|
-
return module.def().then(function (value) {
|
|
5758
|
-
if (!value) {
|
|
5759
|
-
addModuleError("val.modules 'def' did not return a value", moduleIdx);
|
|
5760
|
-
return;
|
|
5761
|
-
}
|
|
5762
|
-
if (!value["default"]) {
|
|
5763
|
-
addModuleError("val.modules 'def' did not return a default export", moduleIdx);
|
|
5764
|
-
return;
|
|
5765
|
-
}
|
|
5766
|
-
var path = getValPath(value["default"]);
|
|
5767
|
-
if (path === undefined) {
|
|
5768
|
-
addModuleError("path is undefined", moduleIdx);
|
|
5769
|
-
return;
|
|
5770
|
-
}
|
|
5771
|
-
var schema = getSchema(value["default"]);
|
|
5772
|
-
if (schema === undefined) {
|
|
5773
|
-
addModuleError("schema in path '".concat(path, "' is undefined"), moduleIdx, path);
|
|
5774
|
-
return;
|
|
5775
|
-
}
|
|
5776
|
-
// Avoid `schema instanceof Schema` — the editor SPA and the host
|
|
5777
|
-
// Next.js bundle each ship their own copy of @valbuild/core, so the
|
|
5778
|
-
// `Schema` class identity differs between them and the instanceof
|
|
5779
|
-
// check would fail for cross-bundle modules. The executeSerialize
|
|
5780
|
-
// check below is the actual contract we depend on.
|
|
5781
|
-
if (typeof schema["executeSerialize"] !== "function") {
|
|
5782
|
-
addModuleError("schema.serialize in path '".concat(path, "' is not a function"), moduleIdx, path);
|
|
5783
|
-
return;
|
|
5784
|
-
}
|
|
5785
|
-
var source = getSource(value["default"]);
|
|
5786
|
-
if (source === undefined) {
|
|
5787
|
-
addModuleError("source in ".concat(path, " is undefined"), moduleIdx, path);
|
|
5788
|
-
return;
|
|
5789
|
-
}
|
|
5790
|
-
var serializedSchema;
|
|
5791
|
-
try {
|
|
5792
|
-
serializedSchema = schema["executeSerialize"]();
|
|
5793
|
-
} catch (e) {
|
|
5794
|
-
var message = e instanceof Error ? e.message : JSON.stringify(e);
|
|
5795
|
-
addModuleError("Could not serialize module: '".concat(path, "'. Error: ").concat(message), moduleIdx, path);
|
|
5796
|
-
return;
|
|
5797
|
-
}
|
|
5798
|
-
var pathM = path;
|
|
5799
|
-
sources[pathM] = source;
|
|
5800
|
-
schemas[pathM] = schema;
|
|
5801
|
-
serializedSchemas[pathM] = serializedSchema;
|
|
5802
|
-
sourcesSha = hash(sourcesSha + JSON.stringify({
|
|
5803
|
-
path: path,
|
|
5804
|
-
source: source
|
|
5805
|
-
}));
|
|
5806
|
-
baseSha = hash(baseSha + JSON.stringify({
|
|
5807
|
-
path: path,
|
|
5808
|
-
schema: serializedSchema,
|
|
5809
|
-
source: source,
|
|
5810
|
-
modulesErrors: moduleErrors
|
|
5811
|
-
}));
|
|
5812
|
-
schemaSha = hash(schemaSha + JSON.stringify(serializedSchema));
|
|
5813
|
-
});
|
|
5814
|
-
case 3:
|
|
5815
|
-
return _context.a(2);
|
|
5816
|
-
}
|
|
5817
|
-
}, _loop);
|
|
5818
|
-
});
|
|
6140
|
+
baseSha = configSha; // NOTE: schemaSha is deliberately NOT seeded with configSha. It is compared
|
|
6141
|
+
// across bundles (the server extracts from the Node bundle, the editor SPA
|
|
6142
|
+
// from the browser bundle) to detect that a new version has been deployed.
|
|
6143
|
+
// The config contains values that are not part of the schema and that differ
|
|
6144
|
+
// between those two bundles - most notably the documented
|
|
6145
|
+
// `gitCommit: process.env.VERCEL_GIT_COMMIT_SHA` / `gitBranch`, which are
|
|
6146
|
+
// server-only env vars and therefore `undefined` in the browser. Seeding with
|
|
6147
|
+
// them made the two sides disagree on every production load.
|
|
6148
|
+
schemaSha = "";
|
|
5819
6149
|
moduleIdx = 0;
|
|
5820
6150
|
case 1:
|
|
5821
6151
|
if (!(moduleIdx < valModules.modules.length)) {
|
|
5822
|
-
|
|
6152
|
+
_context.n = 18;
|
|
6153
|
+
break;
|
|
6154
|
+
}
|
|
6155
|
+
module = valModules.modules[moduleIdx]; // NOTE: `at index N` refers to the module's position in the val.modules
|
|
6156
|
+
// array, which is all we can name when the module never loaded.
|
|
6157
|
+
at = "at index ".concat(moduleIdx);
|
|
6158
|
+
if (module.def) {
|
|
6159
|
+
_context.n = 2;
|
|
5823
6160
|
break;
|
|
5824
6161
|
}
|
|
5825
|
-
|
|
6162
|
+
addModuleError("val.modules ".concat(at, " is missing 'def' property"));
|
|
6163
|
+
return _context.a(3, 17);
|
|
5826
6164
|
case 2:
|
|
5827
|
-
|
|
5828
|
-
|
|
5829
|
-
_context2.n = 3;
|
|
6165
|
+
if (!(typeof module.def !== "function")) {
|
|
6166
|
+
_context.n = 3;
|
|
5830
6167
|
break;
|
|
5831
6168
|
}
|
|
5832
|
-
|
|
6169
|
+
addModuleError("val.modules ".concat(at, " 'def' property is not a function"));
|
|
6170
|
+
return _context.a(3, 17);
|
|
5833
6171
|
case 3:
|
|
6172
|
+
value = void 0;
|
|
6173
|
+
_context.p = 4;
|
|
6174
|
+
_context.n = 5;
|
|
6175
|
+
return module.def();
|
|
6176
|
+
case 5:
|
|
6177
|
+
value = _context.v;
|
|
6178
|
+
_context.n = 7;
|
|
6179
|
+
break;
|
|
6180
|
+
case 6:
|
|
6181
|
+
_context.p = 6;
|
|
6182
|
+
_t = _context.v;
|
|
6183
|
+
// A module that throws while importing (a syntax error, a throwing
|
|
6184
|
+
// top-level statement, a missing file) has to be reported like any other
|
|
6185
|
+
// module error. Letting it reject aborts the whole extraction, which on
|
|
6186
|
+
// the server means ValOps.initSources rejects and /stat, /schema and
|
|
6187
|
+
// /sources/~ all fail opaquely instead of naming the broken module.
|
|
6188
|
+
addModuleError("val.modules 'def' ".concat(at, " could not be loaded. Error: ").concat(errorMessage(_t)));
|
|
6189
|
+
return _context.a(3, 17);
|
|
6190
|
+
case 7:
|
|
6191
|
+
if (value) {
|
|
6192
|
+
_context.n = 8;
|
|
6193
|
+
break;
|
|
6194
|
+
}
|
|
6195
|
+
addModuleError("val.modules 'def' ".concat(at, " did not return a value"));
|
|
6196
|
+
return _context.a(3, 17);
|
|
6197
|
+
case 8:
|
|
6198
|
+
if (value["default"]) {
|
|
6199
|
+
_context.n = 9;
|
|
6200
|
+
break;
|
|
6201
|
+
}
|
|
6202
|
+
addModuleError("val.modules 'def' ".concat(at, " did not return a default export"));
|
|
6203
|
+
return _context.a(3, 17);
|
|
6204
|
+
case 9:
|
|
6205
|
+
path = getValPath(value["default"]);
|
|
6206
|
+
if (!(path === undefined)) {
|
|
6207
|
+
_context.n = 10;
|
|
6208
|
+
break;
|
|
6209
|
+
}
|
|
6210
|
+
addModuleError("path is undefined for val.modules 'def' ".concat(at));
|
|
6211
|
+
return _context.a(3, 17);
|
|
6212
|
+
case 10:
|
|
6213
|
+
schema = getSchema(value["default"]);
|
|
6214
|
+
if (!(schema === undefined)) {
|
|
6215
|
+
_context.n = 11;
|
|
6216
|
+
break;
|
|
6217
|
+
}
|
|
6218
|
+
addModuleError("schema in path '".concat(path, "' is undefined"), path);
|
|
6219
|
+
return _context.a(3, 17);
|
|
6220
|
+
case 11:
|
|
6221
|
+
if (!(typeof schema["executeSerialize"] !== "function")) {
|
|
6222
|
+
_context.n = 12;
|
|
6223
|
+
break;
|
|
6224
|
+
}
|
|
6225
|
+
addModuleError("schema.serialize in path '".concat(path, "' is not a function"), path);
|
|
6226
|
+
return _context.a(3, 17);
|
|
6227
|
+
case 12:
|
|
6228
|
+
source = getSource(value["default"]);
|
|
6229
|
+
if (!(source === undefined)) {
|
|
6230
|
+
_context.n = 13;
|
|
6231
|
+
break;
|
|
6232
|
+
}
|
|
6233
|
+
addModuleError("source in ".concat(path, " is undefined"), path);
|
|
6234
|
+
return _context.a(3, 17);
|
|
6235
|
+
case 13:
|
|
6236
|
+
serializedSchema = void 0;
|
|
6237
|
+
_context.p = 14;
|
|
6238
|
+
serializedSchema = schema["executeSerialize"]();
|
|
6239
|
+
_context.n = 16;
|
|
6240
|
+
break;
|
|
6241
|
+
case 15:
|
|
6242
|
+
_context.p = 15;
|
|
6243
|
+
_t2 = _context.v;
|
|
6244
|
+
addModuleError("Could not serialize module: '".concat(path, "'. Error: ").concat(errorMessage(_t2)), path);
|
|
6245
|
+
return _context.a(3, 17);
|
|
6246
|
+
case 16:
|
|
6247
|
+
pathM = path;
|
|
6248
|
+
sources[pathM] = source;
|
|
6249
|
+
schemas[pathM] = schema;
|
|
6250
|
+
serializedSchemas[pathM] = serializedSchema;
|
|
6251
|
+
sourcesSha = hash(sourcesSha + JSON.stringify({
|
|
6252
|
+
path: path,
|
|
6253
|
+
source: source
|
|
6254
|
+
}));
|
|
6255
|
+
baseSha = hash(baseSha + JSON.stringify({
|
|
6256
|
+
path: path,
|
|
6257
|
+
schema: serializedSchema,
|
|
6258
|
+
source: source,
|
|
6259
|
+
modulesErrors: moduleErrors
|
|
6260
|
+
}));
|
|
6261
|
+
// The PATH is part of the schema set, not just the schema: renaming a
|
|
6262
|
+
// module while leaving its schema byte-identical still changes which paths
|
|
6263
|
+
// exist, and an open client keyed its schema cache by the old path. Hashing
|
|
6264
|
+
// the schema alone left this SHA unchanged, so with no commitSha to fall
|
|
6265
|
+
// back on the client never refetched /schema.
|
|
6266
|
+
schemaSha = hash(schemaSha + JSON.stringify({
|
|
6267
|
+
path: path,
|
|
6268
|
+
schema: serializedSchema
|
|
6269
|
+
}));
|
|
6270
|
+
case 17:
|
|
5834
6271
|
moduleIdx++;
|
|
5835
|
-
|
|
6272
|
+
_context.n = 1;
|
|
5836
6273
|
break;
|
|
5837
|
-
case
|
|
5838
|
-
return
|
|
6274
|
+
case 18:
|
|
6275
|
+
return _context.a(2, {
|
|
5839
6276
|
sources: sources,
|
|
5840
6277
|
schemas: schemas,
|
|
5841
6278
|
serializedSchemas: serializedSchemas,
|
|
@@ -5846,7 +6283,7 @@ function _extractValModules() {
|
|
|
5846
6283
|
moduleErrors: moduleErrors
|
|
5847
6284
|
});
|
|
5848
6285
|
}
|
|
5849
|
-
}, _callee);
|
|
6286
|
+
}, _callee, null, [[14, 15], [4, 6]]);
|
|
5850
6287
|
}));
|
|
5851
6288
|
return _extractValModules.apply(this, arguments);
|
|
5852
6289
|
}
|
|
@@ -6760,7 +7197,7 @@ function deserializeSchema(serialized) {
|
|
|
6760
7197
|
return schema;
|
|
6761
7198
|
}
|
|
6762
7199
|
function deserializeSchemaImpl(serialized) {
|
|
6763
|
-
var _serialized$options, _serialized$options2, _serialized$accept, _serialized$directory, _serialized$remote;
|
|
7200
|
+
var _serialized$options, _serialized$options2, _serialized$accept, _serialized$directory, _serialized$remote, _serialized$jsonValue;
|
|
6764
7201
|
switch (serialized.type) {
|
|
6765
7202
|
case "string":
|
|
6766
7203
|
return new StringSchema(_objectSpread2(_objectSpread2({}, serialized.options), {}, {
|
|
@@ -6809,7 +7246,7 @@ function deserializeSchemaImpl(serialized) {
|
|
|
6809
7246
|
directory: (_serialized$directory = serialized.directory) !== null && _serialized$directory !== void 0 ? _serialized$directory : "/public/val",
|
|
6810
7247
|
remote: (_serialized$remote = serialized.remote) !== null && _serialized$remote !== void 0 ? _serialized$remote : false,
|
|
6811
7248
|
altSchema: serialized.alt ? deserializeSchema(serialized.alt) : undefined
|
|
6812
|
-
} : undefined, false, false, serialized.description);
|
|
7249
|
+
} : undefined, false, false, serialized.description, (_serialized$jsonValue = serialized.jsonValues) !== null && _serialized$jsonValue !== void 0 ? _serialized$jsonValue : false);
|
|
6813
7250
|
case "keyOf":
|
|
6814
7251
|
return new KeyOfSchema(serialized.schema, serialized.path, serialized.opt, [], false, false, serialized.description);
|
|
6815
7252
|
case "route":
|
|
@@ -7128,6 +7565,9 @@ var Internal = {
|
|
|
7128
7565
|
},
|
|
7129
7566
|
isVal: isVal,
|
|
7130
7567
|
isFile: isFile,
|
|
7568
|
+
isJson: isJson,
|
|
7569
|
+
getJsonImport: getJsonImport,
|
|
7570
|
+
resolveJsonValues: resolveJsonValues,
|
|
7131
7571
|
createValPathOfItem: createValPathOfItem,
|
|
7132
7572
|
getSHA256Hash: getSHA256Hash,
|
|
7133
7573
|
initSchema: initSchema,
|