@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) {
|
@@ -1,2 +1,2 @@
|
|
1
|
-
export { A as ArraySchema, B as BooleanSchema, e as DEFAULT_APP_HOST, D as DEFAULT_CONTENT_HOST, f as DEFAULT_VAL_REMOTE_HOST, o as DateSchema, F as FATAL_ERROR_TYPES, g as FILE_REF_PROP, h as FILE_REF_SUBTYPE_TAG, n as FileSchema, G as GenericSelector, l as ImageSchema, I as Internal, K as KeyOfSchema, L as LiteralSchema, M as ModuleFilePathSep, N as NumberSchema, O as ObjectSchema, R as RecordSchema, p as RichTextSchema, S as Schema, k as StringSchema, U as UnionSchema, V as VAL_EXTENSION, j as derefPatch, q as deserializeSchema, i as initVal, m as modules } from './index-
|
1
|
+
export { A as ArraySchema, B as BooleanSchema, e as DEFAULT_APP_HOST, D as DEFAULT_CONTENT_HOST, f as DEFAULT_VAL_REMOTE_HOST, o as DateSchema, F as FATAL_ERROR_TYPES, g as FILE_REF_PROP, h as FILE_REF_SUBTYPE_TAG, n as FileSchema, G as GenericSelector, l as ImageSchema, I as Internal, K as KeyOfSchema, L as LiteralSchema, M as ModuleFilePathSep, N as NumberSchema, O as ObjectSchema, R as RecordSchema, p as RichTextSchema, S as Schema, k as StringSchema, U as UnionSchema, V as VAL_EXTENSION, j as derefPatch, q as deserializeSchema, i as initVal, m as modules } from './index-24c8829d.esm.js';
|
2
2
|
import './result-daff1cae.esm.js';
|
package/package.json
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var dist_valbuildCore = require('../../dist/index-
|
5
|
+
var dist_valbuildCore = require('../../dist/index-beacdff9.cjs.dev.js');
|
6
6
|
var result = require('../../dist/result-bb1f436e.cjs.dev.js');
|
7
7
|
var util = require('../../dist/util-b213092b.cjs.dev.js');
|
8
8
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var dist_valbuildCore = require('../../dist/index-
|
5
|
+
var dist_valbuildCore = require('../../dist/index-1061d844.cjs.prod.js');
|
6
6
|
var result = require('../../dist/result-787e35f6.cjs.prod.js');
|
7
7
|
var util = require('../../dist/util-030d8a1f.cjs.prod.js');
|
8
8
|
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { _ as _typeof, a as _slicedToArray, P as PatchError, s as splitModuleFilePathAndModulePath, b as _createClass, c as _classCallCheck, d as _toConsumableArray } from '../../dist/index-
|
2
|
-
export { P as PatchError } from '../../dist/index-
|
1
|
+
import { _ as _typeof, a as _slicedToArray, P as PatchError, s as splitModuleFilePathAndModulePath, b as _createClass, c as _classCallCheck, d as _toConsumableArray } from '../../dist/index-24c8829d.esm.js';
|
2
|
+
export { P as PatchError } from '../../dist/index-24c8829d.esm.js';
|
3
3
|
import { f as isNonEmpty, e as err, o as ok, m as map, g as flatMap, i as isErr, h as flatMapReduce, j as filterOrElse, k as mapErr, l as map$1, n as all, p as flatten, q as allT } from '../../dist/result-daff1cae.esm.js';
|
4
4
|
import { p as pipe } from '../../dist/util-18613e99.esm.js';
|
5
5
|
|