@valbuild/core 0.77.1 → 0.78.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/declarations/src/index.d.ts +1 -0
- package/dist/declarations/src/initSchema.d.ts +2 -2
- package/dist/declarations/src/preview.d.ts +39 -0
- package/dist/declarations/src/schema/array.d.ts +16 -2
- package/dist/declarations/src/schema/boolean.d.ts +2 -0
- package/dist/declarations/src/schema/date.d.ts +2 -0
- package/dist/declarations/src/schema/file.d.ts +2 -0
- package/dist/declarations/src/schema/image.d.ts +2 -0
- package/dist/declarations/src/schema/index.d.ts +3 -1
- package/dist/declarations/src/schema/keyOf.d.ts +2 -0
- package/dist/declarations/src/schema/literal.d.ts +2 -0
- package/dist/declarations/src/schema/number.d.ts +2 -0
- package/dist/declarations/src/schema/object.d.ts +3 -1
- package/dist/declarations/src/schema/record.d.ts +17 -2
- package/dist/declarations/src/schema/richtext.d.ts +2 -0
- package/dist/declarations/src/schema/string.d.ts +2 -0
- package/dist/declarations/src/schema/union.d.ts +3 -1
- package/dist/{index-ee3d5938.cjs.prod.js → index-1061d844.cjs.prod.js} +248 -2
- package/dist/{index-ba3bd117.esm.js → index-24c8829d.esm.js} +248 -2
- package/dist/{index-895564f9.cjs.dev.js → index-beacdff9.cjs.dev.js} +248 -2
- 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
@@ -518,6 +518,11 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
|
|
518
518
|
remote: this.isRemote
|
519
519
|
};
|
520
520
|
}
|
521
|
+
}, {
|
522
|
+
key: "executePreview",
|
523
|
+
value: function executePreview() {
|
524
|
+
return {};
|
525
|
+
}
|
521
526
|
}]);
|
522
527
|
}(Schema);
|
523
528
|
var file = function file(options) {
|
@@ -740,6 +745,27 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
|
|
740
745
|
opt: this.opt
|
741
746
|
};
|
742
747
|
}
|
748
|
+
}, {
|
749
|
+
key: "executePreview",
|
750
|
+
value: function executePreview(sourcePath, src) {
|
751
|
+
var res = {};
|
752
|
+
if (src === null) {
|
753
|
+
return res;
|
754
|
+
}
|
755
|
+
for (var _key2 in this.items) {
|
756
|
+
var itemSrc = src[_key2];
|
757
|
+
if (itemSrc === null || itemSrc === undefined) {
|
758
|
+
continue;
|
759
|
+
}
|
760
|
+
var subPath = unsafeCreateSourcePath(sourcePath, _key2);
|
761
|
+
var itemResult = this.items[_key2]["executePreview"](subPath, itemSrc);
|
762
|
+
for (var keyS in itemResult) {
|
763
|
+
var _key3 = keyS;
|
764
|
+
res[_key3] = itemResult[_key3];
|
765
|
+
}
|
766
|
+
}
|
767
|
+
return res;
|
768
|
+
}
|
743
769
|
}]);
|
744
770
|
}(Schema);
|
745
771
|
var object = function object(schema) {
|
@@ -752,6 +778,7 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
|
|
752
778
|
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
753
779
|
_classCallCheck(this, ArraySchema);
|
754
780
|
_this = _callSuper(this, ArraySchema);
|
781
|
+
_defineProperty(_this, "previewInput", null);
|
755
782
|
_this.item = item;
|
756
783
|
_this.opt = opt;
|
757
784
|
return _this;
|
@@ -838,6 +865,72 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
|
|
838
865
|
opt: this.opt
|
839
866
|
};
|
840
867
|
}
|
868
|
+
}, {
|
869
|
+
key: "executePreview",
|
870
|
+
value: function executePreview(sourcePath, src) {
|
871
|
+
var res = {};
|
872
|
+
if (src === null) {
|
873
|
+
return res;
|
874
|
+
}
|
875
|
+
for (var key in src) {
|
876
|
+
var itemSrc = src[key];
|
877
|
+
if (itemSrc === null || itemSrc === undefined) {
|
878
|
+
continue;
|
879
|
+
}
|
880
|
+
var subPath = unsafeCreateSourcePath(sourcePath, key);
|
881
|
+
var itemResult = this.item["executePreview"](subPath, itemSrc);
|
882
|
+
for (var keyS in itemResult) {
|
883
|
+
var _key = keyS;
|
884
|
+
res[_key] = itemResult[_key];
|
885
|
+
}
|
886
|
+
}
|
887
|
+
if (this.previewInput) {
|
888
|
+
var _this$previewInput = this.previewInput,
|
889
|
+
prepare = _this$previewInput.prepare,
|
890
|
+
layout = _this$previewInput.layout;
|
891
|
+
if (layout !== "list") {
|
892
|
+
res[sourcePath] = {
|
893
|
+
status: "error",
|
894
|
+
message: "Unknown layout type: " + layout
|
895
|
+
};
|
896
|
+
}
|
897
|
+
try {
|
898
|
+
res[sourcePath] = {
|
899
|
+
status: "success",
|
900
|
+
data: {
|
901
|
+
layout: "list",
|
902
|
+
parent: "array",
|
903
|
+
items: src.map(function (val) {
|
904
|
+
// NB NB: display is actually defined by the user
|
905
|
+
var _prepare = prepare({
|
906
|
+
val: val
|
907
|
+
}),
|
908
|
+
title = _prepare.title,
|
909
|
+
subtitle = _prepare.subtitle,
|
910
|
+
image = _prepare.image;
|
911
|
+
return {
|
912
|
+
title: title,
|
913
|
+
subtitle: subtitle,
|
914
|
+
image: image
|
915
|
+
};
|
916
|
+
})
|
917
|
+
}
|
918
|
+
};
|
919
|
+
} catch (e) {
|
920
|
+
res[sourcePath] = {
|
921
|
+
status: "error",
|
922
|
+
message: e instanceof Error ? e.message : "Unknown error"
|
923
|
+
};
|
924
|
+
}
|
925
|
+
}
|
926
|
+
return res;
|
927
|
+
}
|
928
|
+
}, {
|
929
|
+
key: "preview",
|
930
|
+
value: function preview(input) {
|
931
|
+
this.previewInput = input;
|
932
|
+
return this;
|
933
|
+
}
|
841
934
|
}]);
|
842
935
|
}(Schema);
|
843
936
|
var array = function array(schema) {
|
@@ -921,6 +1014,11 @@ var LiteralSchema = /*#__PURE__*/function (_Schema) {
|
|
921
1014
|
opt: this.opt
|
922
1015
|
};
|
923
1016
|
}
|
1017
|
+
}, {
|
1018
|
+
key: "executePreview",
|
1019
|
+
value: function executePreview() {
|
1020
|
+
return {};
|
1021
|
+
}
|
924
1022
|
}]);
|
925
1023
|
}(Schema);
|
926
1024
|
var literal = function literal(value) {
|
@@ -1252,11 +1350,53 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
|
|
1252
1350
|
opt: this.opt
|
1253
1351
|
};
|
1254
1352
|
}
|
1353
|
+
}, {
|
1354
|
+
key: "executePreview",
|
1355
|
+
value: function executePreview(sourcePath, src) {
|
1356
|
+
var res = {};
|
1357
|
+
if (src === null) {
|
1358
|
+
return res;
|
1359
|
+
}
|
1360
|
+
if (this.key instanceof LiteralSchema) {
|
1361
|
+
return res;
|
1362
|
+
}
|
1363
|
+
var unionKey = this.key;
|
1364
|
+
if (typeof unionKey === "string") {
|
1365
|
+
var thisSchema = this.items.find(
|
1366
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
1367
|
+
function (item) {
|
1368
|
+
if (item instanceof ObjectSchema) {
|
1369
|
+
var itemKey = item.items[unionKey];
|
1370
|
+
if (itemKey instanceof LiteralSchema) {
|
1371
|
+
return _typeof(src) === "object" && unionKey in src && itemKey.value === src[unionKey];
|
1372
|
+
}
|
1373
|
+
}
|
1374
|
+
return false;
|
1375
|
+
});
|
1376
|
+
if (thisSchema) {
|
1377
|
+
var itemResult = thisSchema["executePreview"](sourcePath, src);
|
1378
|
+
for (var keyS in itemResult) {
|
1379
|
+
var _key3 = keyS;
|
1380
|
+
res[_key3] = itemResult[_key3];
|
1381
|
+
}
|
1382
|
+
return res;
|
1383
|
+
}
|
1384
|
+
res[sourcePath] = {
|
1385
|
+
status: "error",
|
1386
|
+
message: "Could not find a matching (object) schema for the union key: ".concat(unionKey)
|
1387
|
+
};
|
1388
|
+
}
|
1389
|
+
res[sourcePath] = {
|
1390
|
+
status: "error",
|
1391
|
+
message: "The schema of this value is wrong. Expected a object union schema, but union key is not a string. Got: '".concat(JSON.stringify(unionKey, null, 2), "'")
|
1392
|
+
};
|
1393
|
+
return res;
|
1394
|
+
}
|
1255
1395
|
}]);
|
1256
1396
|
}(Schema);
|
1257
1397
|
var union = function union(key) {
|
1258
|
-
for (var _len = arguments.length, objects = new Array(_len > 1 ? _len - 1 : 0),
|
1259
|
-
objects[
|
1398
|
+
for (var _len = arguments.length, objects = new Array(_len > 1 ? _len - 1 : 0), _key4 = 1; _key4 < _len; _key4++) {
|
1399
|
+
objects[_key4 - 1] = arguments[_key4];
|
1260
1400
|
}
|
1261
1401
|
return new UnionSchema(key, objects);
|
1262
1402
|
};
|
@@ -1460,6 +1600,11 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
|
|
1460
1600
|
remote: this.isRemote
|
1461
1601
|
};
|
1462
1602
|
}
|
1603
|
+
}, {
|
1604
|
+
key: "executePreview",
|
1605
|
+
value: function executePreview() {
|
1606
|
+
return {};
|
1607
|
+
}
|
1463
1608
|
}]);
|
1464
1609
|
}(Schema);
|
1465
1610
|
var image = function image(options) {
|
@@ -1900,6 +2045,11 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
1900
2045
|
options: serializedOptions
|
1901
2046
|
};
|
1902
2047
|
}
|
2048
|
+
}, {
|
2049
|
+
key: "executePreview",
|
2050
|
+
value: function executePreview() {
|
2051
|
+
return {};
|
2052
|
+
}
|
1903
2053
|
}]);
|
1904
2054
|
}(Schema);
|
1905
2055
|
var richtext = function richtext(options) {
|
@@ -1912,6 +2062,7 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
1912
2062
|
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
1913
2063
|
_classCallCheck(this, RecordSchema);
|
1914
2064
|
_this = _callSuper(this, RecordSchema);
|
2065
|
+
_defineProperty(_this, "previewInput", null);
|
1915
2066
|
_this.item = item;
|
1916
2067
|
_this.opt = opt;
|
1917
2068
|
return _this;
|
@@ -2006,6 +2157,76 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
2006
2157
|
opt: this.opt
|
2007
2158
|
};
|
2008
2159
|
}
|
2160
|
+
}, {
|
2161
|
+
key: "executePreview",
|
2162
|
+
value: function executePreview(sourcePath, src) {
|
2163
|
+
var res = {};
|
2164
|
+
if (src === null) {
|
2165
|
+
return res;
|
2166
|
+
}
|
2167
|
+
for (var key in src) {
|
2168
|
+
var itemSrc = src[key];
|
2169
|
+
if (itemSrc === null || itemSrc === undefined) {
|
2170
|
+
continue;
|
2171
|
+
}
|
2172
|
+
var subPath = unsafeCreateSourcePath(sourcePath, key);
|
2173
|
+
var itemResult = this.item["executePreview"](subPath, itemSrc);
|
2174
|
+
for (var keyS in itemResult) {
|
2175
|
+
var _key = keyS;
|
2176
|
+
res[_key] = itemResult[_key];
|
2177
|
+
}
|
2178
|
+
}
|
2179
|
+
if (this.previewInput) {
|
2180
|
+
var _this$previewInput = this.previewInput,
|
2181
|
+
prepare = _this$previewInput.prepare,
|
2182
|
+
layout = _this$previewInput.layout;
|
2183
|
+
if (layout !== "list") {
|
2184
|
+
res[sourcePath] = {
|
2185
|
+
status: "error",
|
2186
|
+
message: "Unknown layout type: " + layout
|
2187
|
+
};
|
2188
|
+
}
|
2189
|
+
try {
|
2190
|
+
res[sourcePath] = {
|
2191
|
+
status: "success",
|
2192
|
+
data: {
|
2193
|
+
layout: "list",
|
2194
|
+
parent: "record",
|
2195
|
+
items: Object.entries(src).map(function (_ref6) {
|
2196
|
+
var _ref7 = _slicedToArray(_ref6, 2),
|
2197
|
+
key = _ref7[0],
|
2198
|
+
val = _ref7[1];
|
2199
|
+
// NB NB: display is actually defined by the user
|
2200
|
+
var _prepare = prepare({
|
2201
|
+
key: key,
|
2202
|
+
val: val
|
2203
|
+
}),
|
2204
|
+
title = _prepare.title,
|
2205
|
+
subtitle = _prepare.subtitle,
|
2206
|
+
image = _prepare.image;
|
2207
|
+
return [key, {
|
2208
|
+
title: title,
|
2209
|
+
subtitle: subtitle,
|
2210
|
+
image: image
|
2211
|
+
}];
|
2212
|
+
})
|
2213
|
+
}
|
2214
|
+
};
|
2215
|
+
} catch (e) {
|
2216
|
+
res[sourcePath] = {
|
2217
|
+
status: "error",
|
2218
|
+
message: e instanceof Error ? e.message : "Unknown error"
|
2219
|
+
};
|
2220
|
+
}
|
2221
|
+
}
|
2222
|
+
return res;
|
2223
|
+
}
|
2224
|
+
}, {
|
2225
|
+
key: "preview",
|
2226
|
+
value: function preview(input) {
|
2227
|
+
this.previewInput = input;
|
2228
|
+
return this;
|
2229
|
+
}
|
2009
2230
|
}]);
|
2010
2231
|
}(Schema);
|
2011
2232
|
var record = function record(schema) {
|
@@ -2352,6 +2573,11 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
2352
2573
|
opt: this.opt
|
2353
2574
|
};
|
2354
2575
|
}
|
2576
|
+
}, {
|
2577
|
+
key: "executePreview",
|
2578
|
+
value: function executePreview() {
|
2579
|
+
return {};
|
2580
|
+
}
|
2355
2581
|
}]);
|
2356
2582
|
}(Schema);
|
2357
2583
|
var number = function number(options) {
|
@@ -2498,6 +2724,11 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
|
|
2498
2724
|
raw: this.isRaw
|
2499
2725
|
};
|
2500
2726
|
}
|
2727
|
+
}, {
|
2728
|
+
key: "executePreview",
|
2729
|
+
value: function executePreview() {
|
2730
|
+
return {};
|
2731
|
+
}
|
2501
2732
|
}]);
|
2502
2733
|
}(Schema);
|
2503
2734
|
var string = function string(options) {
|
@@ -2573,6 +2804,11 @@ var BooleanSchema = /*#__PURE__*/function (_Schema) {
|
|
2573
2804
|
opt: this.opt
|
2574
2805
|
};
|
2575
2806
|
}
|
2807
|
+
}, {
|
2808
|
+
key: "executePreview",
|
2809
|
+
value: function executePreview() {
|
2810
|
+
return {};
|
2811
|
+
}
|
2576
2812
|
}]);
|
2577
2813
|
}(Schema);
|
2578
2814
|
var _boolean = function _boolean() {
|
@@ -2743,6 +2979,11 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
|
2743
2979
|
values: values
|
2744
2980
|
};
|
2745
2981
|
}
|
2982
|
+
}, {
|
2983
|
+
key: "executePreview",
|
2984
|
+
value: function executePreview() {
|
2985
|
+
return {};
|
2986
|
+
}
|
2746
2987
|
}]);
|
2747
2988
|
}(Schema);
|
2748
2989
|
var keyOf = function keyOf(valModule) {
|
@@ -2872,6 +3113,11 @@ var DateSchema = /*#__PURE__*/function (_Schema) {
|
|
2872
3113
|
options: this.options
|
2873
3114
|
};
|
2874
3115
|
}
|
3116
|
+
}, {
|
3117
|
+
key: "executePreview",
|
3118
|
+
value: function executePreview() {
|
3119
|
+
return {};
|
3120
|
+
}
|
2875
3121
|
}]);
|
2876
3122
|
}(Schema);
|
2877
3123
|
var date = function date(options) {
|
@@ -516,6 +516,11 @@ var FileSchema = /*#__PURE__*/function (_Schema) {
|
|
516
516
|
remote: this.isRemote
|
517
517
|
};
|
518
518
|
}
|
519
|
+
}, {
|
520
|
+
key: "executePreview",
|
521
|
+
value: function executePreview() {
|
522
|
+
return {};
|
523
|
+
}
|
519
524
|
}]);
|
520
525
|
}(Schema);
|
521
526
|
var file = function file(options) {
|
@@ -738,6 +743,27 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
|
|
738
743
|
opt: this.opt
|
739
744
|
};
|
740
745
|
}
|
746
|
+
}, {
|
747
|
+
key: "executePreview",
|
748
|
+
value: function executePreview(sourcePath, src) {
|
749
|
+
var res = {};
|
750
|
+
if (src === null) {
|
751
|
+
return res;
|
752
|
+
}
|
753
|
+
for (var _key2 in this.items) {
|
754
|
+
var itemSrc = src[_key2];
|
755
|
+
if (itemSrc === null || itemSrc === undefined) {
|
756
|
+
continue;
|
757
|
+
}
|
758
|
+
var subPath = unsafeCreateSourcePath(sourcePath, _key2);
|
759
|
+
var itemResult = this.items[_key2]["executePreview"](subPath, itemSrc);
|
760
|
+
for (var keyS in itemResult) {
|
761
|
+
var _key3 = keyS;
|
762
|
+
res[_key3] = itemResult[_key3];
|
763
|
+
}
|
764
|
+
}
|
765
|
+
return res;
|
766
|
+
}
|
741
767
|
}]);
|
742
768
|
}(Schema);
|
743
769
|
var object = function object(schema) {
|
@@ -750,6 +776,7 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
|
|
750
776
|
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
751
777
|
_classCallCheck(this, ArraySchema);
|
752
778
|
_this = _callSuper(this, ArraySchema);
|
779
|
+
_defineProperty(_this, "previewInput", null);
|
753
780
|
_this.item = item;
|
754
781
|
_this.opt = opt;
|
755
782
|
return _this;
|
@@ -836,6 +863,72 @@ var ArraySchema = /*#__PURE__*/function (_Schema) {
|
|
836
863
|
opt: this.opt
|
837
864
|
};
|
838
865
|
}
|
866
|
+
}, {
|
867
|
+
key: "executePreview",
|
868
|
+
value: function executePreview(sourcePath, src) {
|
869
|
+
var res = {};
|
870
|
+
if (src === null) {
|
871
|
+
return res;
|
872
|
+
}
|
873
|
+
for (var key in src) {
|
874
|
+
var itemSrc = src[key];
|
875
|
+
if (itemSrc === null || itemSrc === undefined) {
|
876
|
+
continue;
|
877
|
+
}
|
878
|
+
var subPath = unsafeCreateSourcePath(sourcePath, key);
|
879
|
+
var itemResult = this.item["executePreview"](subPath, itemSrc);
|
880
|
+
for (var keyS in itemResult) {
|
881
|
+
var _key = keyS;
|
882
|
+
res[_key] = itemResult[_key];
|
883
|
+
}
|
884
|
+
}
|
885
|
+
if (this.previewInput) {
|
886
|
+
var _this$previewInput = this.previewInput,
|
887
|
+
prepare = _this$previewInput.prepare,
|
888
|
+
layout = _this$previewInput.layout;
|
889
|
+
if (layout !== "list") {
|
890
|
+
res[sourcePath] = {
|
891
|
+
status: "error",
|
892
|
+
message: "Unknown layout type: " + layout
|
893
|
+
};
|
894
|
+
}
|
895
|
+
try {
|
896
|
+
res[sourcePath] = {
|
897
|
+
status: "success",
|
898
|
+
data: {
|
899
|
+
layout: "list",
|
900
|
+
parent: "array",
|
901
|
+
items: src.map(function (val) {
|
902
|
+
// NB NB: display is actually defined by the user
|
903
|
+
var _prepare = prepare({
|
904
|
+
val: val
|
905
|
+
}),
|
906
|
+
title = _prepare.title,
|
907
|
+
subtitle = _prepare.subtitle,
|
908
|
+
image = _prepare.image;
|
909
|
+
return {
|
910
|
+
title: title,
|
911
|
+
subtitle: subtitle,
|
912
|
+
image: image
|
913
|
+
};
|
914
|
+
})
|
915
|
+
}
|
916
|
+
};
|
917
|
+
} catch (e) {
|
918
|
+
res[sourcePath] = {
|
919
|
+
status: "error",
|
920
|
+
message: e instanceof Error ? e.message : "Unknown error"
|
921
|
+
};
|
922
|
+
}
|
923
|
+
}
|
924
|
+
return res;
|
925
|
+
}
|
926
|
+
}, {
|
927
|
+
key: "preview",
|
928
|
+
value: function preview(input) {
|
929
|
+
this.previewInput = input;
|
930
|
+
return this;
|
931
|
+
}
|
839
932
|
}]);
|
840
933
|
}(Schema);
|
841
934
|
var array = function array(schema) {
|
@@ -919,6 +1012,11 @@ var LiteralSchema = /*#__PURE__*/function (_Schema) {
|
|
919
1012
|
opt: this.opt
|
920
1013
|
};
|
921
1014
|
}
|
1015
|
+
}, {
|
1016
|
+
key: "executePreview",
|
1017
|
+
value: function executePreview() {
|
1018
|
+
return {};
|
1019
|
+
}
|
922
1020
|
}]);
|
923
1021
|
}(Schema);
|
924
1022
|
var literal = function literal(value) {
|
@@ -1250,11 +1348,53 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
|
|
1250
1348
|
opt: this.opt
|
1251
1349
|
};
|
1252
1350
|
}
|
1351
|
+
}, {
|
1352
|
+
key: "executePreview",
|
1353
|
+
value: function executePreview(sourcePath, src) {
|
1354
|
+
var res = {};
|
1355
|
+
if (src === null) {
|
1356
|
+
return res;
|
1357
|
+
}
|
1358
|
+
if (this.key instanceof LiteralSchema) {
|
1359
|
+
return res;
|
1360
|
+
}
|
1361
|
+
var unionKey = this.key;
|
1362
|
+
if (typeof unionKey === "string") {
|
1363
|
+
var thisSchema = this.items.find(
|
1364
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
1365
|
+
function (item) {
|
1366
|
+
if (item instanceof ObjectSchema) {
|
1367
|
+
var itemKey = item.items[unionKey];
|
1368
|
+
if (itemKey instanceof LiteralSchema) {
|
1369
|
+
return _typeof(src) === "object" && unionKey in src && itemKey.value === src[unionKey];
|
1370
|
+
}
|
1371
|
+
}
|
1372
|
+
return false;
|
1373
|
+
});
|
1374
|
+
if (thisSchema) {
|
1375
|
+
var itemResult = thisSchema["executePreview"](sourcePath, src);
|
1376
|
+
for (var keyS in itemResult) {
|
1377
|
+
var _key3 = keyS;
|
1378
|
+
res[_key3] = itemResult[_key3];
|
1379
|
+
}
|
1380
|
+
return res;
|
1381
|
+
}
|
1382
|
+
res[sourcePath] = {
|
1383
|
+
status: "error",
|
1384
|
+
message: "Could not find a matching (object) schema for the union key: ".concat(unionKey)
|
1385
|
+
};
|
1386
|
+
}
|
1387
|
+
res[sourcePath] = {
|
1388
|
+
status: "error",
|
1389
|
+
message: "The schema of this value is wrong. Expected a object union schema, but union key is not a string. Got: '".concat(JSON.stringify(unionKey, null, 2), "'")
|
1390
|
+
};
|
1391
|
+
return res;
|
1392
|
+
}
|
1253
1393
|
}]);
|
1254
1394
|
}(Schema);
|
1255
1395
|
var union = function union(key) {
|
1256
|
-
for (var _len = arguments.length, objects = new Array(_len > 1 ? _len - 1 : 0),
|
1257
|
-
objects[
|
1396
|
+
for (var _len = arguments.length, objects = new Array(_len > 1 ? _len - 1 : 0), _key4 = 1; _key4 < _len; _key4++) {
|
1397
|
+
objects[_key4 - 1] = arguments[_key4];
|
1258
1398
|
}
|
1259
1399
|
return new UnionSchema(key, objects);
|
1260
1400
|
};
|
@@ -1458,6 +1598,11 @@ var ImageSchema = /*#__PURE__*/function (_Schema) {
|
|
1458
1598
|
remote: this.isRemote
|
1459
1599
|
};
|
1460
1600
|
}
|
1601
|
+
}, {
|
1602
|
+
key: "executePreview",
|
1603
|
+
value: function executePreview() {
|
1604
|
+
return {};
|
1605
|
+
}
|
1461
1606
|
}]);
|
1462
1607
|
}(Schema);
|
1463
1608
|
var image = function image(options) {
|
@@ -1898,6 +2043,11 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
1898
2043
|
options: serializedOptions
|
1899
2044
|
};
|
1900
2045
|
}
|
2046
|
+
}, {
|
2047
|
+
key: "executePreview",
|
2048
|
+
value: function executePreview() {
|
2049
|
+
return {};
|
2050
|
+
}
|
1901
2051
|
}]);
|
1902
2052
|
}(Schema);
|
1903
2053
|
var richtext = function richtext(options) {
|
@@ -1910,6 +2060,7 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
1910
2060
|
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
1911
2061
|
_classCallCheck(this, RecordSchema);
|
1912
2062
|
_this = _callSuper(this, RecordSchema);
|
2063
|
+
_defineProperty(_this, "previewInput", null);
|
1913
2064
|
_this.item = item;
|
1914
2065
|
_this.opt = opt;
|
1915
2066
|
return _this;
|
@@ -2004,6 +2155,76 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
2004
2155
|
opt: this.opt
|
2005
2156
|
};
|
2006
2157
|
}
|
2158
|
+
}, {
|
2159
|
+
key: "executePreview",
|
2160
|
+
value: function executePreview(sourcePath, src) {
|
2161
|
+
var res = {};
|
2162
|
+
if (src === null) {
|
2163
|
+
return res;
|
2164
|
+
}
|
2165
|
+
for (var key in src) {
|
2166
|
+
var itemSrc = src[key];
|
2167
|
+
if (itemSrc === null || itemSrc === undefined) {
|
2168
|
+
continue;
|
2169
|
+
}
|
2170
|
+
var subPath = unsafeCreateSourcePath(sourcePath, key);
|
2171
|
+
var itemResult = this.item["executePreview"](subPath, itemSrc);
|
2172
|
+
for (var keyS in itemResult) {
|
2173
|
+
var _key = keyS;
|
2174
|
+
res[_key] = itemResult[_key];
|
2175
|
+
}
|
2176
|
+
}
|
2177
|
+
if (this.previewInput) {
|
2178
|
+
var _this$previewInput = this.previewInput,
|
2179
|
+
prepare = _this$previewInput.prepare,
|
2180
|
+
layout = _this$previewInput.layout;
|
2181
|
+
if (layout !== "list") {
|
2182
|
+
res[sourcePath] = {
|
2183
|
+
status: "error",
|
2184
|
+
message: "Unknown layout type: " + layout
|
2185
|
+
};
|
2186
|
+
}
|
2187
|
+
try {
|
2188
|
+
res[sourcePath] = {
|
2189
|
+
status: "success",
|
2190
|
+
data: {
|
2191
|
+
layout: "list",
|
2192
|
+
parent: "record",
|
2193
|
+
items: Object.entries(src).map(function (_ref6) {
|
2194
|
+
var _ref7 = _slicedToArray(_ref6, 2),
|
2195
|
+
key = _ref7[0],
|
2196
|
+
val = _ref7[1];
|
2197
|
+
// NB NB: display is actually defined by the user
|
2198
|
+
var _prepare = prepare({
|
2199
|
+
key: key,
|
2200
|
+
val: val
|
2201
|
+
}),
|
2202
|
+
title = _prepare.title,
|
2203
|
+
subtitle = _prepare.subtitle,
|
2204
|
+
image = _prepare.image;
|
2205
|
+
return [key, {
|
2206
|
+
title: title,
|
2207
|
+
subtitle: subtitle,
|
2208
|
+
image: image
|
2209
|
+
}];
|
2210
|
+
})
|
2211
|
+
}
|
2212
|
+
};
|
2213
|
+
} catch (e) {
|
2214
|
+
res[sourcePath] = {
|
2215
|
+
status: "error",
|
2216
|
+
message: e instanceof Error ? e.message : "Unknown error"
|
2217
|
+
};
|
2218
|
+
}
|
2219
|
+
}
|
2220
|
+
return res;
|
2221
|
+
}
|
2222
|
+
}, {
|
2223
|
+
key: "preview",
|
2224
|
+
value: function preview(input) {
|
2225
|
+
this.previewInput = input;
|
2226
|
+
return this;
|
2227
|
+
}
|
2007
2228
|
}]);
|
2008
2229
|
}(Schema);
|
2009
2230
|
var record = function record(schema) {
|
@@ -2350,6 +2571,11 @@ var NumberSchema = /*#__PURE__*/function (_Schema) {
|
|
2350
2571
|
opt: this.opt
|
2351
2572
|
};
|
2352
2573
|
}
|
2574
|
+
}, {
|
2575
|
+
key: "executePreview",
|
2576
|
+
value: function executePreview() {
|
2577
|
+
return {};
|
2578
|
+
}
|
2353
2579
|
}]);
|
2354
2580
|
}(Schema);
|
2355
2581
|
var number = function number(options) {
|
@@ -2496,6 +2722,11 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
|
|
2496
2722
|
raw: this.isRaw
|
2497
2723
|
};
|
2498
2724
|
}
|
2725
|
+
}, {
|
2726
|
+
key: "executePreview",
|
2727
|
+
value: function executePreview() {
|
2728
|
+
return {};
|
2729
|
+
}
|
2499
2730
|
}]);
|
2500
2731
|
}(Schema);
|
2501
2732
|
var string = function string(options) {
|
@@ -2571,6 +2802,11 @@ var BooleanSchema = /*#__PURE__*/function (_Schema) {
|
|
2571
2802
|
opt: this.opt
|
2572
2803
|
};
|
2573
2804
|
}
|
2805
|
+
}, {
|
2806
|
+
key: "executePreview",
|
2807
|
+
value: function executePreview() {
|
2808
|
+
return {};
|
2809
|
+
}
|
2574
2810
|
}]);
|
2575
2811
|
}(Schema);
|
2576
2812
|
var _boolean = function _boolean() {
|
@@ -2741,6 +2977,11 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
|
2741
2977
|
values: values
|
2742
2978
|
};
|
2743
2979
|
}
|
2980
|
+
}, {
|
2981
|
+
key: "executePreview",
|
2982
|
+
value: function executePreview() {
|
2983
|
+
return {};
|
2984
|
+
}
|
2744
2985
|
}]);
|
2745
2986
|
}(Schema);
|
2746
2987
|
var keyOf = function keyOf(valModule) {
|
@@ -2870,6 +3111,11 @@ var DateSchema = /*#__PURE__*/function (_Schema) {
|
|
2870
3111
|
options: this.options
|
2871
3112
|
};
|
2872
3113
|
}
|
3114
|
+
}, {
|
3115
|
+
key: "executePreview",
|
3116
|
+
value: function executePreview() {
|
3117
|
+
return {};
|
3118
|
+
}
|
2873
3119
|
}]);
|
2874
3120
|
}(Schema);
|
2875
3121
|
var date = function date(options) {
|