@valbuild/core 0.87.3 → 0.87.5
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 -1
- package/dist/declarations/src/initSchema.d.ts +1 -1
- package/dist/declarations/src/render.d.ts +6 -1
- package/dist/declarations/src/schema/record.d.ts +9 -6
- package/dist/declarations/src/schema/string.d.ts +7 -1
- package/dist/declarations/src/schema/validation/ValidationError.d.ts +1 -0
- package/dist/{index-e0c4e804.esm.js → index-11591a0b.esm.js} +74 -25
- package/dist/{index-af1d2d7a.cjs.prod.js → index-34063fba.cjs.prod.js} +74 -25
- package/dist/{index-c05b59eb.cjs.dev.js → index-eb1a6b1f.cjs.dev.js} +74 -25
- 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 +5 -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
|
@@ -52,7 +52,7 @@ export { type SerializedRichTextSchema, RichTextSchema, } from "./schema/richtex
|
|
|
52
52
|
export { type SerializedUnionSchema, UnionSchema, type SerializedStringUnionSchema, type SerializedObjectUnionSchema, } from "./schema/union.js";
|
|
53
53
|
export { type SerializedLiteralSchema, LiteralSchema } from "./schema/literal.js";
|
|
54
54
|
export { deserializeSchema } from "./schema/deserialize.js";
|
|
55
|
-
export { type ListRecordRender, type ListArrayRender, type ReifiedRender, } from "./render.js";
|
|
55
|
+
export { type ListRecordRender, type ListArrayRender, type ReifiedRender, type CodeLanguage, type CodeRender, } from "./render.js";
|
|
56
56
|
export type { ValRouter, RouteValidationError } from "./router.js";
|
|
57
57
|
export declare const FATAL_ERROR_TYPES: readonly ["no-schema", "no-source", "invalid-id", "no-module", "invalid-patch"];
|
|
58
58
|
export type FatalErrorType = (typeof FATAL_ERROR_TYPES)[number];
|
|
@@ -98,7 +98,7 @@ export declare function initSchema(): {
|
|
|
98
98
|
image: (options?: import("./schema/image.js").ImageOptions | undefined) => import("./schema/image.js").ImageSchema<import("./index.js").ImageSource>;
|
|
99
99
|
literal: <T_2 extends string>(value: T_2) => import("./schema/literal.js").LiteralSchema<T_2>;
|
|
100
100
|
keyOf: <Src extends import("./selector/index.js").GenericSelector<import("./source/index.js").SourceObject, undefined> & import("./module.js").ValModuleBrand>(valModule: Src) => import("./schema/keyOf.js").KeyOfSchema<Src, Src extends import("./selector/index.js").GenericSelector<infer S_2 extends import("./source/index.js").Source, undefined> ? S_2 extends readonly import("./source/index.js").Source[] ? number : S_2 extends import("./source/index.js").SourceObject ? string extends keyof S_2 ? import("./schema/string.js").RawString : keyof S_2 : S_2 extends Record<string, import("./source/index.js").Source> ? import("./schema/string.js").RawString : never : never>;
|
|
101
|
-
record:
|
|
101
|
+
record: typeof record;
|
|
102
102
|
file: (options?: import("./schema/file.js").FileOptions | undefined) => import("./schema/file.js").FileSchema<import("./index.js").FileSource<import("./schema/file.js").FileMetadata>>;
|
|
103
103
|
date: (options?: Record<string, never> | undefined) => import("./schema/date.js").DateSchema<import("./schema/string.js").RawString>;
|
|
104
104
|
};
|
|
@@ -28,7 +28,12 @@ export type ListArrayRender = {
|
|
|
28
28
|
export type TextareaRender = {
|
|
29
29
|
layout: "textarea";
|
|
30
30
|
};
|
|
31
|
-
type
|
|
31
|
+
export type CodeLanguage = "typescript" | "javascript" | "javascriptreact" | "typescriptreact" | "json" | "java" | "html" | "css" | "xml" | "markdown" | "sql" | "python" | "rust" | "php" | "go" | "cpp" | "sass" | "vue" | "angular";
|
|
32
|
+
export type CodeRender = {
|
|
33
|
+
layout: "code";
|
|
34
|
+
language: CodeLanguage;
|
|
35
|
+
};
|
|
36
|
+
type RenderTypes = ListRecordRender | ListArrayRender | TextareaRender | CodeRender;
|
|
32
37
|
type WithStatus<T> = {
|
|
33
38
|
status: "error";
|
|
34
39
|
message: string;
|
|
@@ -10,21 +10,23 @@ import { ValidationErrors } from "./validation/ValidationError.js";
|
|
|
10
10
|
export type SerializedRecordSchema = {
|
|
11
11
|
type: "record";
|
|
12
12
|
item: SerializedSchema;
|
|
13
|
+
key?: SerializedSchema;
|
|
13
14
|
opt: boolean;
|
|
14
15
|
router?: string;
|
|
15
16
|
customValidate?: boolean;
|
|
16
17
|
};
|
|
17
|
-
export declare class RecordSchema<T extends Schema<SelectorSource>, Src extends Record<
|
|
18
|
+
export declare class RecordSchema<T extends Schema<SelectorSource>, K extends Schema<string>, Src extends Record<SelectorOfSchema<K>, SelectorOfSchema<T>> | null> extends Schema<Src> {
|
|
18
19
|
private readonly item;
|
|
19
20
|
private readonly opt;
|
|
20
21
|
private readonly customValidateFunctions;
|
|
21
22
|
private readonly currentRouter;
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
private readonly keySchema;
|
|
24
|
+
constructor(item: T, opt?: boolean, customValidateFunctions?: CustomValidateFunction<Src>[], currentRouter?: ValRouter | null, keySchema?: Schema<string> | null);
|
|
25
|
+
validate(validationFunction: (src: Src) => false | string): RecordSchema<T, K, Src>;
|
|
24
26
|
protected executeValidate(path: SourcePath, src: Src): ValidationErrors;
|
|
25
27
|
protected executeAssert(path: SourcePath, src: unknown): SchemaAssertResult<Src>;
|
|
26
|
-
nullable(): RecordSchema<T, Src | null>;
|
|
27
|
-
router(router: ValRouter): RecordSchema<T, Src>;
|
|
28
|
+
nullable(): RecordSchema<T, K, Src | null>;
|
|
29
|
+
router(router: ValRouter): RecordSchema<T, K, Src>;
|
|
28
30
|
private getRouterValidations;
|
|
29
31
|
protected executeSerialize(): SerializedRecordSchema;
|
|
30
32
|
private renderInput;
|
|
@@ -41,4 +43,5 @@ export declare class RecordSchema<T extends Schema<SelectorSource>, Src extends
|
|
|
41
43
|
};
|
|
42
44
|
}): this;
|
|
43
45
|
}
|
|
44
|
-
export declare
|
|
46
|
+
export declare function record<K extends Schema<string>, S extends Schema<SelectorSource>>(key: K, schema: S): RecordSchema<S, K, Record<SelectorOfSchema<K>, SelectorOfSchema<S>>>;
|
|
47
|
+
export declare function record<S extends Schema<SelectorSource>>(schema: S): RecordSchema<S, Schema<string>, Record<string, SelectorOfSchema<S>>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Schema, SchemaAssertResult, SerializedSchema } from "./index.js";
|
|
2
|
-
import { ReifiedRender } from "../render.js";
|
|
2
|
+
import { CodeLanguage, ReifiedRender } from "../render.js";
|
|
3
3
|
import { ModuleFilePath, SourcePath } from "../val/index.js";
|
|
4
4
|
import { ValidationErrors } from "./validation/ValidationError.js";
|
|
5
5
|
type StringOptions = {
|
|
@@ -36,6 +36,9 @@ export declare class StringSchema<Src extends string | null> extends Schema<Src>
|
|
|
36
36
|
private readonly renderInput;
|
|
37
37
|
constructor(options?: StringOptions | undefined, opt?: boolean, isRaw?: boolean, customValidateFunctions?: ((src: Src) => false | string)[], renderInput?: {
|
|
38
38
|
as: "textarea";
|
|
39
|
+
} | {
|
|
40
|
+
as: "code";
|
|
41
|
+
language: CodeLanguage;
|
|
39
42
|
} | null);
|
|
40
43
|
/**
|
|
41
44
|
* @deprecated Use `minLength` instead
|
|
@@ -56,6 +59,9 @@ export declare class StringSchema<Src extends string | null> extends Schema<Src>
|
|
|
56
59
|
protected executeSerialize(): SerializedSchema;
|
|
57
60
|
render(input: {
|
|
58
61
|
as: "textarea";
|
|
62
|
+
} | {
|
|
63
|
+
as: "code";
|
|
64
|
+
language: CodeLanguage;
|
|
59
65
|
}): StringSchema<Src>;
|
|
60
66
|
protected executeRender(sourcePath: SourcePath | ModuleFilePath, src: Src): ReifiedRender;
|
|
61
67
|
}
|
|
@@ -832,6 +832,15 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
|
|
|
832
832
|
key: "executeRender",
|
|
833
833
|
value: function executeRender(sourcePath, src) {
|
|
834
834
|
if (this.renderInput) {
|
|
835
|
+
if (this.renderInput.as === "code") {
|
|
836
|
+
return _defineProperty({}, sourcePath, {
|
|
837
|
+
status: "success",
|
|
838
|
+
data: {
|
|
839
|
+
layout: this.renderInput.as,
|
|
840
|
+
language: this.renderInput.language
|
|
841
|
+
}
|
|
842
|
+
});
|
|
843
|
+
}
|
|
835
844
|
return _defineProperty({}, sourcePath, {
|
|
836
845
|
status: "success",
|
|
837
846
|
data: {
|
|
@@ -1516,10 +1525,10 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
|
|
|
1516
1525
|
};
|
|
1517
1526
|
}
|
|
1518
1527
|
if (this.key instanceof LiteralSchema) {
|
|
1519
|
-
var
|
|
1528
|
+
var _ref23;
|
|
1520
1529
|
var success = false;
|
|
1521
1530
|
var errors = {};
|
|
1522
|
-
var _iterator2 = _createForOfIteratorHelper((
|
|
1531
|
+
var _iterator2 = _createForOfIteratorHelper((_ref23 = [this.key]).concat.apply(_ref23, _toConsumableArray(this.items))),
|
|
1523
1532
|
_step2;
|
|
1524
1533
|
try {
|
|
1525
1534
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
@@ -2010,7 +2019,7 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2010
2019
|
_step;
|
|
2011
2020
|
try {
|
|
2012
2021
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
2013
|
-
var _this2$options$block, _this2$options$block2, _this2$options$block3, _this2$options$block4, _this2$options$block5, _this2$options$block6, _this2$options$block7, _this2$options$block8, _this2$options$block9, _this2$options$
|
|
2022
|
+
var _this2$options$block, _this2$options$block2, _this2$options$block3, _this2$options$block4, _this2$options$block5, _this2$options$block6, _this2$options$block7, _this2$options$block8, _this2$options$block9, _this2$options$block0, _this2$options$inline;
|
|
2014
2023
|
var node = _step.value;
|
|
2015
2024
|
var path = unsafeCreateSourcePath(rootPath, nodes.indexOf(node));
|
|
2016
2025
|
if (typeof node === "string") {
|
|
@@ -2065,7 +2074,7 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2065
2074
|
if (node.tag === "ul" && !((_this2$options$block8 = _this2.options.block) !== null && _this2$options$block8 !== void 0 && _this2$options$block8.ul)) {
|
|
2066
2075
|
addError(path, "'ul' block is not valid", false);
|
|
2067
2076
|
}
|
|
2068
|
-
if (node.tag === "li" && !((_this2$options$block9 = _this2.options.block) !== null && _this2$options$block9 !== void 0 && _this2$options$block9.ul) && !((_this2$options$
|
|
2077
|
+
if (node.tag === "li" && !((_this2$options$block9 = _this2.options.block) !== null && _this2$options$block9 !== void 0 && _this2$options$block9.ul) && !((_this2$options$block0 = _this2.options.block) !== null && _this2$options$block0 !== void 0 && _this2$options$block0.ol)) {
|
|
2069
2078
|
addError(path, "'li' tag is invalid since neither 'ul' nor 'ol' block is not valid", false);
|
|
2070
2079
|
}
|
|
2071
2080
|
if (node.tag === "a" && !((_this2$options$inline = _this2.options.inline) !== null && _this2$options$inline !== void 0 && _this2$options$inline.a)) {
|
|
@@ -2392,6 +2401,7 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2392
2401
|
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
2393
2402
|
var customValidateFunctions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
2394
2403
|
var currentRouter = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
|
2404
|
+
var keySchema = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
|
|
2395
2405
|
_classCallCheck(this, RecordSchema);
|
|
2396
2406
|
_this = _callSuper(this, RecordSchema);
|
|
2397
2407
|
_defineProperty(_this, "renderInput", null);
|
|
@@ -2399,13 +2409,14 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2399
2409
|
_this.opt = opt;
|
|
2400
2410
|
_this.customValidateFunctions = customValidateFunctions;
|
|
2401
2411
|
_this.currentRouter = currentRouter;
|
|
2412
|
+
_this.keySchema = keySchema;
|
|
2402
2413
|
return _this;
|
|
2403
2414
|
}
|
|
2404
2415
|
_inherits(RecordSchema, _Schema);
|
|
2405
2416
|
return _createClass(RecordSchema, [{
|
|
2406
2417
|
key: "validate",
|
|
2407
2418
|
value: function validate(validationFunction) {
|
|
2408
|
-
return new RecordSchema(this.item, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]));
|
|
2419
|
+
return new RecordSchema(this.item, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.currentRouter, this.keySchema);
|
|
2409
2420
|
}
|
|
2410
2421
|
}, {
|
|
2411
2422
|
key: "executeValidate",
|
|
@@ -2453,6 +2464,30 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2453
2464
|
var _ref6 = _slicedToArray(_ref5, 2),
|
|
2454
2465
|
key = _ref6[0],
|
|
2455
2466
|
elem = _ref6[1];
|
|
2467
|
+
if (_this2.keySchema) {
|
|
2468
|
+
var keyPath = createValPathOfItem(path, key);
|
|
2469
|
+
if (!keyPath) {
|
|
2470
|
+
throw new Error("Internal error: could not create path at ".concat(!path && typeof path === "string" ? "<empty string>" : path, " for key validation")) // Should! never happen
|
|
2471
|
+
;
|
|
2472
|
+
}
|
|
2473
|
+
var keyError = _this2.keySchema["executeValidate"](keyPath, key);
|
|
2474
|
+
if (keyError) {
|
|
2475
|
+
keyError[keyPath] = keyError[keyPath].map(function (err) {
|
|
2476
|
+
return _objectSpread2(_objectSpread2({}, err), {}, {
|
|
2477
|
+
keyError: true
|
|
2478
|
+
});
|
|
2479
|
+
});
|
|
2480
|
+
if (error) {
|
|
2481
|
+
if (error[keyPath]) {
|
|
2482
|
+
error[keyPath] = [].concat(_toConsumableArray(error[keyPath]), _toConsumableArray(keyError[keyPath]));
|
|
2483
|
+
} else {
|
|
2484
|
+
error[keyPath] = keyError[keyPath];
|
|
2485
|
+
}
|
|
2486
|
+
} else {
|
|
2487
|
+
error = keyError;
|
|
2488
|
+
}
|
|
2489
|
+
}
|
|
2490
|
+
}
|
|
2456
2491
|
var subPath = createValPathOfItem(path, key);
|
|
2457
2492
|
if (!subPath) {
|
|
2458
2493
|
error = _this2.appendValidationError(error, path, "Internal error: could not create path at ".concat(!path && typeof path === "string" ? "<empty string>" : path, " at key ").concat(elem),
|
|
@@ -2504,12 +2539,12 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2504
2539
|
}, {
|
|
2505
2540
|
key: "nullable",
|
|
2506
2541
|
value: function nullable() {
|
|
2507
|
-
return new RecordSchema(this.item, true);
|
|
2542
|
+
return new RecordSchema(this.item, true, this.customValidateFunctions, this.currentRouter, this.keySchema);
|
|
2508
2543
|
}
|
|
2509
2544
|
}, {
|
|
2510
2545
|
key: "router",
|
|
2511
2546
|
value: function router(_router) {
|
|
2512
|
-
return new RecordSchema(this.item, this.opt, this.customValidateFunctions, _router);
|
|
2547
|
+
return new RecordSchema(this.item, this.opt, this.customValidateFunctions, _router, this.keySchema);
|
|
2513
2548
|
}
|
|
2514
2549
|
}, {
|
|
2515
2550
|
key: "getRouterValidations",
|
|
@@ -2530,9 +2565,9 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2530
2565
|
schemaError: true
|
|
2531
2566
|
}]);
|
|
2532
2567
|
}
|
|
2533
|
-
var
|
|
2534
|
-
if (
|
|
2535
|
-
return Object.fromEntries(
|
|
2568
|
+
var routerValidationErrors = this.currentRouter.validate(moduleFilePath, Object.keys(src));
|
|
2569
|
+
if (routerValidationErrors.length > 0) {
|
|
2570
|
+
return Object.fromEntries(routerValidationErrors.map(function (validation) {
|
|
2536
2571
|
if (!validation.error.urlPath) {
|
|
2537
2572
|
return [path, [{
|
|
2538
2573
|
message: "Router validation error: ".concat(validation.error.message, " has no url path"),
|
|
@@ -2541,13 +2576,13 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2541
2576
|
}
|
|
2542
2577
|
var subPath = createValPathOfItem(path, validation.error.urlPath);
|
|
2543
2578
|
if (!subPath) {
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
schemaError: true
|
|
2547
|
-
}]];
|
|
2579
|
+
throw new Error("Internal error: could not create path at ".concat(!path && typeof path === "string" ? "<empty string>" : path, " for router validation")) // Should! never happen
|
|
2580
|
+
;
|
|
2548
2581
|
}
|
|
2549
2582
|
return [subPath, [{
|
|
2550
|
-
message: validation.error.message
|
|
2583
|
+
message: validation.error.message,
|
|
2584
|
+
value: validation.error.urlPath,
|
|
2585
|
+
keyError: true
|
|
2551
2586
|
}]];
|
|
2552
2587
|
}));
|
|
2553
2588
|
}
|
|
@@ -2556,10 +2591,11 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2556
2591
|
}, {
|
|
2557
2592
|
key: "executeSerialize",
|
|
2558
2593
|
value: function executeSerialize() {
|
|
2559
|
-
var _this$currentRouter, _this$customValidateF;
|
|
2594
|
+
var _this$keySchema, _this$currentRouter, _this$customValidateF;
|
|
2560
2595
|
return {
|
|
2561
2596
|
type: "record",
|
|
2562
2597
|
item: this.item["executeSerialize"](),
|
|
2598
|
+
key: (_this$keySchema = this.keySchema) === null || _this$keySchema === void 0 ? void 0 : _this$keySchema["executeSerialize"](),
|
|
2563
2599
|
opt: this.opt,
|
|
2564
2600
|
router: (_this$currentRouter = this.currentRouter) === null || _this$currentRouter === void 0 ? void 0 : _this$currentRouter.getRouterId(),
|
|
2565
2601
|
customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0
|
|
@@ -2572,16 +2608,16 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2572
2608
|
if (src === null) {
|
|
2573
2609
|
return res;
|
|
2574
2610
|
}
|
|
2575
|
-
for (var
|
|
2576
|
-
var itemSrc = src[
|
|
2611
|
+
for (var _key in src) {
|
|
2612
|
+
var itemSrc = src[_key];
|
|
2577
2613
|
if (itemSrc === null || itemSrc === undefined) {
|
|
2578
2614
|
continue;
|
|
2579
2615
|
}
|
|
2580
|
-
var subPath = unsafeCreateSourcePath(sourcePath,
|
|
2616
|
+
var subPath = unsafeCreateSourcePath(sourcePath, _key);
|
|
2581
2617
|
var itemResult = this.item["executeRender"](subPath, itemSrc);
|
|
2582
2618
|
for (var keyS in itemResult) {
|
|
2583
|
-
var
|
|
2584
|
-
res[
|
|
2619
|
+
var _key2 = keyS;
|
|
2620
|
+
res[_key2] = itemResult[_key2];
|
|
2585
2621
|
}
|
|
2586
2622
|
}
|
|
2587
2623
|
if (this.renderInput) {
|
|
@@ -2640,9 +2676,21 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2640
2676
|
}
|
|
2641
2677
|
}]);
|
|
2642
2678
|
}(Schema);
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2679
|
+
|
|
2680
|
+
// Overload: with key schema
|
|
2681
|
+
|
|
2682
|
+
// Overload: without key schema
|
|
2683
|
+
|
|
2684
|
+
// Implementation
|
|
2685
|
+
function record(keyOrSchema, schema) {
|
|
2686
|
+
if (schema) {
|
|
2687
|
+
// Two-argument call: first is key schema, second is value schema
|
|
2688
|
+
return new RecordSchema(schema, false, [], null, keyOrSchema);
|
|
2689
|
+
} else {
|
|
2690
|
+
// One-argument call: only value schema
|
|
2691
|
+
return new RecordSchema(keyOrSchema, false, [], null, null);
|
|
2692
|
+
}
|
|
2693
|
+
}
|
|
2646
2694
|
|
|
2647
2695
|
function define(
|
|
2648
2696
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -4092,6 +4140,7 @@ var N = /*#__PURE__*/function (N) {
|
|
|
4092
4140
|
N[N["inputWords"] = 16] = "inputWords";
|
|
4093
4141
|
N[N["highIndex"] = 14] = "highIndex";
|
|
4094
4142
|
N[N["lowIndex"] = 15] = "lowIndex";
|
|
4143
|
+
// eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
|
|
4095
4144
|
N[N["workWords"] = 64] = "workWords";
|
|
4096
4145
|
N[N["allocBytes"] = 80] = "allocBytes";
|
|
4097
4146
|
N[N["allocWords"] = 20] = "allocWords";
|
|
@@ -5185,7 +5234,7 @@ function deserializeSchema(serialized) {
|
|
|
5185
5234
|
return new RichTextSchema(deserializedOptions, serialized.opt);
|
|
5186
5235
|
}
|
|
5187
5236
|
case "record":
|
|
5188
|
-
return new RecordSchema(deserializeSchema(serialized.item), serialized.opt);
|
|
5237
|
+
return new RecordSchema(deserializeSchema(serialized.item), serialized.opt, [], null, serialized.key ? deserializeSchema(serialized.key) : null);
|
|
5189
5238
|
case "keyOf":
|
|
5190
5239
|
return new KeyOfSchema(serialized.schema, serialized.path, serialized.opt);
|
|
5191
5240
|
case "file":
|
|
@@ -834,6 +834,15 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
|
|
|
834
834
|
key: "executeRender",
|
|
835
835
|
value: function executeRender(sourcePath, src) {
|
|
836
836
|
if (this.renderInput) {
|
|
837
|
+
if (this.renderInput.as === "code") {
|
|
838
|
+
return _defineProperty({}, sourcePath, {
|
|
839
|
+
status: "success",
|
|
840
|
+
data: {
|
|
841
|
+
layout: this.renderInput.as,
|
|
842
|
+
language: this.renderInput.language
|
|
843
|
+
}
|
|
844
|
+
});
|
|
845
|
+
}
|
|
837
846
|
return _defineProperty({}, sourcePath, {
|
|
838
847
|
status: "success",
|
|
839
848
|
data: {
|
|
@@ -1518,10 +1527,10 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
|
|
|
1518
1527
|
};
|
|
1519
1528
|
}
|
|
1520
1529
|
if (this.key instanceof LiteralSchema) {
|
|
1521
|
-
var
|
|
1530
|
+
var _ref23;
|
|
1522
1531
|
var success = false;
|
|
1523
1532
|
var errors = {};
|
|
1524
|
-
var _iterator2 = result._createForOfIteratorHelper((
|
|
1533
|
+
var _iterator2 = result._createForOfIteratorHelper((_ref23 = [this.key]).concat.apply(_ref23, _toConsumableArray(this.items))),
|
|
1525
1534
|
_step2;
|
|
1526
1535
|
try {
|
|
1527
1536
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
@@ -2012,7 +2021,7 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2012
2021
|
_step;
|
|
2013
2022
|
try {
|
|
2014
2023
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
2015
|
-
var _this2$options$block, _this2$options$block2, _this2$options$block3, _this2$options$block4, _this2$options$block5, _this2$options$block6, _this2$options$block7, _this2$options$block8, _this2$options$block9, _this2$options$
|
|
2024
|
+
var _this2$options$block, _this2$options$block2, _this2$options$block3, _this2$options$block4, _this2$options$block5, _this2$options$block6, _this2$options$block7, _this2$options$block8, _this2$options$block9, _this2$options$block0, _this2$options$inline;
|
|
2016
2025
|
var node = _step.value;
|
|
2017
2026
|
var path = unsafeCreateSourcePath(rootPath, nodes.indexOf(node));
|
|
2018
2027
|
if (typeof node === "string") {
|
|
@@ -2067,7 +2076,7 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2067
2076
|
if (node.tag === "ul" && !((_this2$options$block8 = _this2.options.block) !== null && _this2$options$block8 !== void 0 && _this2$options$block8.ul)) {
|
|
2068
2077
|
addError(path, "'ul' block is not valid", false);
|
|
2069
2078
|
}
|
|
2070
|
-
if (node.tag === "li" && !((_this2$options$block9 = _this2.options.block) !== null && _this2$options$block9 !== void 0 && _this2$options$block9.ul) && !((_this2$options$
|
|
2079
|
+
if (node.tag === "li" && !((_this2$options$block9 = _this2.options.block) !== null && _this2$options$block9 !== void 0 && _this2$options$block9.ul) && !((_this2$options$block0 = _this2.options.block) !== null && _this2$options$block0 !== void 0 && _this2$options$block0.ol)) {
|
|
2071
2080
|
addError(path, "'li' tag is invalid since neither 'ul' nor 'ol' block is not valid", false);
|
|
2072
2081
|
}
|
|
2073
2082
|
if (node.tag === "a" && !((_this2$options$inline = _this2.options.inline) !== null && _this2$options$inline !== void 0 && _this2$options$inline.a)) {
|
|
@@ -2394,6 +2403,7 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2394
2403
|
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
2395
2404
|
var customValidateFunctions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
2396
2405
|
var currentRouter = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
|
2406
|
+
var keySchema = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
|
|
2397
2407
|
_classCallCheck(this, RecordSchema);
|
|
2398
2408
|
_this = _callSuper(this, RecordSchema);
|
|
2399
2409
|
_defineProperty(_this, "renderInput", null);
|
|
@@ -2401,13 +2411,14 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2401
2411
|
_this.opt = opt;
|
|
2402
2412
|
_this.customValidateFunctions = customValidateFunctions;
|
|
2403
2413
|
_this.currentRouter = currentRouter;
|
|
2414
|
+
_this.keySchema = keySchema;
|
|
2404
2415
|
return _this;
|
|
2405
2416
|
}
|
|
2406
2417
|
_inherits(RecordSchema, _Schema);
|
|
2407
2418
|
return _createClass(RecordSchema, [{
|
|
2408
2419
|
key: "validate",
|
|
2409
2420
|
value: function validate(validationFunction) {
|
|
2410
|
-
return new RecordSchema(this.item, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]));
|
|
2421
|
+
return new RecordSchema(this.item, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.currentRouter, this.keySchema);
|
|
2411
2422
|
}
|
|
2412
2423
|
}, {
|
|
2413
2424
|
key: "executeValidate",
|
|
@@ -2455,6 +2466,30 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2455
2466
|
var _ref6 = _slicedToArray(_ref5, 2),
|
|
2456
2467
|
key = _ref6[0],
|
|
2457
2468
|
elem = _ref6[1];
|
|
2469
|
+
if (_this2.keySchema) {
|
|
2470
|
+
var keyPath = createValPathOfItem(path, key);
|
|
2471
|
+
if (!keyPath) {
|
|
2472
|
+
throw new Error("Internal error: could not create path at ".concat(!path && typeof path === "string" ? "<empty string>" : path, " for key validation")) // Should! never happen
|
|
2473
|
+
;
|
|
2474
|
+
}
|
|
2475
|
+
var keyError = _this2.keySchema["executeValidate"](keyPath, key);
|
|
2476
|
+
if (keyError) {
|
|
2477
|
+
keyError[keyPath] = keyError[keyPath].map(function (err) {
|
|
2478
|
+
return _objectSpread2(_objectSpread2({}, err), {}, {
|
|
2479
|
+
keyError: true
|
|
2480
|
+
});
|
|
2481
|
+
});
|
|
2482
|
+
if (error) {
|
|
2483
|
+
if (error[keyPath]) {
|
|
2484
|
+
error[keyPath] = [].concat(_toConsumableArray(error[keyPath]), _toConsumableArray(keyError[keyPath]));
|
|
2485
|
+
} else {
|
|
2486
|
+
error[keyPath] = keyError[keyPath];
|
|
2487
|
+
}
|
|
2488
|
+
} else {
|
|
2489
|
+
error = keyError;
|
|
2490
|
+
}
|
|
2491
|
+
}
|
|
2492
|
+
}
|
|
2458
2493
|
var subPath = createValPathOfItem(path, key);
|
|
2459
2494
|
if (!subPath) {
|
|
2460
2495
|
error = _this2.appendValidationError(error, path, "Internal error: could not create path at ".concat(!path && typeof path === "string" ? "<empty string>" : path, " at key ").concat(elem),
|
|
@@ -2506,12 +2541,12 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2506
2541
|
}, {
|
|
2507
2542
|
key: "nullable",
|
|
2508
2543
|
value: function nullable() {
|
|
2509
|
-
return new RecordSchema(this.item, true);
|
|
2544
|
+
return new RecordSchema(this.item, true, this.customValidateFunctions, this.currentRouter, this.keySchema);
|
|
2510
2545
|
}
|
|
2511
2546
|
}, {
|
|
2512
2547
|
key: "router",
|
|
2513
2548
|
value: function router(_router) {
|
|
2514
|
-
return new RecordSchema(this.item, this.opt, this.customValidateFunctions, _router);
|
|
2549
|
+
return new RecordSchema(this.item, this.opt, this.customValidateFunctions, _router, this.keySchema);
|
|
2515
2550
|
}
|
|
2516
2551
|
}, {
|
|
2517
2552
|
key: "getRouterValidations",
|
|
@@ -2532,9 +2567,9 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2532
2567
|
schemaError: true
|
|
2533
2568
|
}]);
|
|
2534
2569
|
}
|
|
2535
|
-
var
|
|
2536
|
-
if (
|
|
2537
|
-
return Object.fromEntries(
|
|
2570
|
+
var routerValidationErrors = this.currentRouter.validate(moduleFilePath, Object.keys(src));
|
|
2571
|
+
if (routerValidationErrors.length > 0) {
|
|
2572
|
+
return Object.fromEntries(routerValidationErrors.map(function (validation) {
|
|
2538
2573
|
if (!validation.error.urlPath) {
|
|
2539
2574
|
return [path, [{
|
|
2540
2575
|
message: "Router validation error: ".concat(validation.error.message, " has no url path"),
|
|
@@ -2543,13 +2578,13 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2543
2578
|
}
|
|
2544
2579
|
var subPath = createValPathOfItem(path, validation.error.urlPath);
|
|
2545
2580
|
if (!subPath) {
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
schemaError: true
|
|
2549
|
-
}]];
|
|
2581
|
+
throw new Error("Internal error: could not create path at ".concat(!path && typeof path === "string" ? "<empty string>" : path, " for router validation")) // Should! never happen
|
|
2582
|
+
;
|
|
2550
2583
|
}
|
|
2551
2584
|
return [subPath, [{
|
|
2552
|
-
message: validation.error.message
|
|
2585
|
+
message: validation.error.message,
|
|
2586
|
+
value: validation.error.urlPath,
|
|
2587
|
+
keyError: true
|
|
2553
2588
|
}]];
|
|
2554
2589
|
}));
|
|
2555
2590
|
}
|
|
@@ -2558,10 +2593,11 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2558
2593
|
}, {
|
|
2559
2594
|
key: "executeSerialize",
|
|
2560
2595
|
value: function executeSerialize() {
|
|
2561
|
-
var _this$currentRouter, _this$customValidateF;
|
|
2596
|
+
var _this$keySchema, _this$currentRouter, _this$customValidateF;
|
|
2562
2597
|
return {
|
|
2563
2598
|
type: "record",
|
|
2564
2599
|
item: this.item["executeSerialize"](),
|
|
2600
|
+
key: (_this$keySchema = this.keySchema) === null || _this$keySchema === void 0 ? void 0 : _this$keySchema["executeSerialize"](),
|
|
2565
2601
|
opt: this.opt,
|
|
2566
2602
|
router: (_this$currentRouter = this.currentRouter) === null || _this$currentRouter === void 0 ? void 0 : _this$currentRouter.getRouterId(),
|
|
2567
2603
|
customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0
|
|
@@ -2574,16 +2610,16 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2574
2610
|
if (src === null) {
|
|
2575
2611
|
return res;
|
|
2576
2612
|
}
|
|
2577
|
-
for (var
|
|
2578
|
-
var itemSrc = src[
|
|
2613
|
+
for (var _key in src) {
|
|
2614
|
+
var itemSrc = src[_key];
|
|
2579
2615
|
if (itemSrc === null || itemSrc === undefined) {
|
|
2580
2616
|
continue;
|
|
2581
2617
|
}
|
|
2582
|
-
var subPath = unsafeCreateSourcePath(sourcePath,
|
|
2618
|
+
var subPath = unsafeCreateSourcePath(sourcePath, _key);
|
|
2583
2619
|
var itemResult = this.item["executeRender"](subPath, itemSrc);
|
|
2584
2620
|
for (var keyS in itemResult) {
|
|
2585
|
-
var
|
|
2586
|
-
res[
|
|
2621
|
+
var _key2 = keyS;
|
|
2622
|
+
res[_key2] = itemResult[_key2];
|
|
2587
2623
|
}
|
|
2588
2624
|
}
|
|
2589
2625
|
if (this.renderInput) {
|
|
@@ -2642,9 +2678,21 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2642
2678
|
}
|
|
2643
2679
|
}]);
|
|
2644
2680
|
}(Schema);
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2681
|
+
|
|
2682
|
+
// Overload: with key schema
|
|
2683
|
+
|
|
2684
|
+
// Overload: without key schema
|
|
2685
|
+
|
|
2686
|
+
// Implementation
|
|
2687
|
+
function record(keyOrSchema, schema) {
|
|
2688
|
+
if (schema) {
|
|
2689
|
+
// Two-argument call: first is key schema, second is value schema
|
|
2690
|
+
return new RecordSchema(schema, false, [], null, keyOrSchema);
|
|
2691
|
+
} else {
|
|
2692
|
+
// One-argument call: only value schema
|
|
2693
|
+
return new RecordSchema(keyOrSchema, false, [], null, null);
|
|
2694
|
+
}
|
|
2695
|
+
}
|
|
2648
2696
|
|
|
2649
2697
|
function define(
|
|
2650
2698
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -4094,6 +4142,7 @@ var N = /*#__PURE__*/function (N) {
|
|
|
4094
4142
|
N[N["inputWords"] = 16] = "inputWords";
|
|
4095
4143
|
N[N["highIndex"] = 14] = "highIndex";
|
|
4096
4144
|
N[N["lowIndex"] = 15] = "lowIndex";
|
|
4145
|
+
// eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
|
|
4097
4146
|
N[N["workWords"] = 64] = "workWords";
|
|
4098
4147
|
N[N["allocBytes"] = 80] = "allocBytes";
|
|
4099
4148
|
N[N["allocWords"] = 20] = "allocWords";
|
|
@@ -5187,7 +5236,7 @@ function deserializeSchema(serialized) {
|
|
|
5187
5236
|
return new RichTextSchema(deserializedOptions, serialized.opt);
|
|
5188
5237
|
}
|
|
5189
5238
|
case "record":
|
|
5190
|
-
return new RecordSchema(deserializeSchema(serialized.item), serialized.opt);
|
|
5239
|
+
return new RecordSchema(deserializeSchema(serialized.item), serialized.opt, [], null, serialized.key ? deserializeSchema(serialized.key) : null);
|
|
5191
5240
|
case "keyOf":
|
|
5192
5241
|
return new KeyOfSchema(serialized.schema, serialized.path, serialized.opt);
|
|
5193
5242
|
case "file":
|
|
@@ -834,6 +834,15 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
|
|
|
834
834
|
key: "executeRender",
|
|
835
835
|
value: function executeRender(sourcePath, src) {
|
|
836
836
|
if (this.renderInput) {
|
|
837
|
+
if (this.renderInput.as === "code") {
|
|
838
|
+
return _defineProperty({}, sourcePath, {
|
|
839
|
+
status: "success",
|
|
840
|
+
data: {
|
|
841
|
+
layout: this.renderInput.as,
|
|
842
|
+
language: this.renderInput.language
|
|
843
|
+
}
|
|
844
|
+
});
|
|
845
|
+
}
|
|
837
846
|
return _defineProperty({}, sourcePath, {
|
|
838
847
|
status: "success",
|
|
839
848
|
data: {
|
|
@@ -1518,10 +1527,10 @@ var UnionSchema = /*#__PURE__*/function (_Schema) {
|
|
|
1518
1527
|
};
|
|
1519
1528
|
}
|
|
1520
1529
|
if (this.key instanceof LiteralSchema) {
|
|
1521
|
-
var
|
|
1530
|
+
var _ref23;
|
|
1522
1531
|
var success = false;
|
|
1523
1532
|
var errors = {};
|
|
1524
|
-
var _iterator2 = result._createForOfIteratorHelper((
|
|
1533
|
+
var _iterator2 = result._createForOfIteratorHelper((_ref23 = [this.key]).concat.apply(_ref23, _toConsumableArray(this.items))),
|
|
1525
1534
|
_step2;
|
|
1526
1535
|
try {
|
|
1527
1536
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
@@ -2012,7 +2021,7 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2012
2021
|
_step;
|
|
2013
2022
|
try {
|
|
2014
2023
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
2015
|
-
var _this2$options$block, _this2$options$block2, _this2$options$block3, _this2$options$block4, _this2$options$block5, _this2$options$block6, _this2$options$block7, _this2$options$block8, _this2$options$block9, _this2$options$
|
|
2024
|
+
var _this2$options$block, _this2$options$block2, _this2$options$block3, _this2$options$block4, _this2$options$block5, _this2$options$block6, _this2$options$block7, _this2$options$block8, _this2$options$block9, _this2$options$block0, _this2$options$inline;
|
|
2016
2025
|
var node = _step.value;
|
|
2017
2026
|
var path = unsafeCreateSourcePath(rootPath, nodes.indexOf(node));
|
|
2018
2027
|
if (typeof node === "string") {
|
|
@@ -2067,7 +2076,7 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2067
2076
|
if (node.tag === "ul" && !((_this2$options$block8 = _this2.options.block) !== null && _this2$options$block8 !== void 0 && _this2$options$block8.ul)) {
|
|
2068
2077
|
addError(path, "'ul' block is not valid", false);
|
|
2069
2078
|
}
|
|
2070
|
-
if (node.tag === "li" && !((_this2$options$block9 = _this2.options.block) !== null && _this2$options$block9 !== void 0 && _this2$options$block9.ul) && !((_this2$options$
|
|
2079
|
+
if (node.tag === "li" && !((_this2$options$block9 = _this2.options.block) !== null && _this2$options$block9 !== void 0 && _this2$options$block9.ul) && !((_this2$options$block0 = _this2.options.block) !== null && _this2$options$block0 !== void 0 && _this2$options$block0.ol)) {
|
|
2071
2080
|
addError(path, "'li' tag is invalid since neither 'ul' nor 'ol' block is not valid", false);
|
|
2072
2081
|
}
|
|
2073
2082
|
if (node.tag === "a" && !((_this2$options$inline = _this2.options.inline) !== null && _this2$options$inline !== void 0 && _this2$options$inline.a)) {
|
|
@@ -2394,6 +2403,7 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2394
2403
|
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
2395
2404
|
var customValidateFunctions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
2396
2405
|
var currentRouter = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
|
2406
|
+
var keySchema = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
|
|
2397
2407
|
_classCallCheck(this, RecordSchema);
|
|
2398
2408
|
_this = _callSuper(this, RecordSchema);
|
|
2399
2409
|
_defineProperty(_this, "renderInput", null);
|
|
@@ -2401,13 +2411,14 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2401
2411
|
_this.opt = opt;
|
|
2402
2412
|
_this.customValidateFunctions = customValidateFunctions;
|
|
2403
2413
|
_this.currentRouter = currentRouter;
|
|
2414
|
+
_this.keySchema = keySchema;
|
|
2404
2415
|
return _this;
|
|
2405
2416
|
}
|
|
2406
2417
|
_inherits(RecordSchema, _Schema);
|
|
2407
2418
|
return _createClass(RecordSchema, [{
|
|
2408
2419
|
key: "validate",
|
|
2409
2420
|
value: function validate(validationFunction) {
|
|
2410
|
-
return new RecordSchema(this.item, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]));
|
|
2421
|
+
return new RecordSchema(this.item, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.currentRouter, this.keySchema);
|
|
2411
2422
|
}
|
|
2412
2423
|
}, {
|
|
2413
2424
|
key: "executeValidate",
|
|
@@ -2455,6 +2466,30 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2455
2466
|
var _ref6 = _slicedToArray(_ref5, 2),
|
|
2456
2467
|
key = _ref6[0],
|
|
2457
2468
|
elem = _ref6[1];
|
|
2469
|
+
if (_this2.keySchema) {
|
|
2470
|
+
var keyPath = createValPathOfItem(path, key);
|
|
2471
|
+
if (!keyPath) {
|
|
2472
|
+
throw new Error("Internal error: could not create path at ".concat(!path && typeof path === "string" ? "<empty string>" : path, " for key validation")) // Should! never happen
|
|
2473
|
+
;
|
|
2474
|
+
}
|
|
2475
|
+
var keyError = _this2.keySchema["executeValidate"](keyPath, key);
|
|
2476
|
+
if (keyError) {
|
|
2477
|
+
keyError[keyPath] = keyError[keyPath].map(function (err) {
|
|
2478
|
+
return _objectSpread2(_objectSpread2({}, err), {}, {
|
|
2479
|
+
keyError: true
|
|
2480
|
+
});
|
|
2481
|
+
});
|
|
2482
|
+
if (error) {
|
|
2483
|
+
if (error[keyPath]) {
|
|
2484
|
+
error[keyPath] = [].concat(_toConsumableArray(error[keyPath]), _toConsumableArray(keyError[keyPath]));
|
|
2485
|
+
} else {
|
|
2486
|
+
error[keyPath] = keyError[keyPath];
|
|
2487
|
+
}
|
|
2488
|
+
} else {
|
|
2489
|
+
error = keyError;
|
|
2490
|
+
}
|
|
2491
|
+
}
|
|
2492
|
+
}
|
|
2458
2493
|
var subPath = createValPathOfItem(path, key);
|
|
2459
2494
|
if (!subPath) {
|
|
2460
2495
|
error = _this2.appendValidationError(error, path, "Internal error: could not create path at ".concat(!path && typeof path === "string" ? "<empty string>" : path, " at key ").concat(elem),
|
|
@@ -2506,12 +2541,12 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2506
2541
|
}, {
|
|
2507
2542
|
key: "nullable",
|
|
2508
2543
|
value: function nullable() {
|
|
2509
|
-
return new RecordSchema(this.item, true);
|
|
2544
|
+
return new RecordSchema(this.item, true, this.customValidateFunctions, this.currentRouter, this.keySchema);
|
|
2510
2545
|
}
|
|
2511
2546
|
}, {
|
|
2512
2547
|
key: "router",
|
|
2513
2548
|
value: function router(_router) {
|
|
2514
|
-
return new RecordSchema(this.item, this.opt, this.customValidateFunctions, _router);
|
|
2549
|
+
return new RecordSchema(this.item, this.opt, this.customValidateFunctions, _router, this.keySchema);
|
|
2515
2550
|
}
|
|
2516
2551
|
}, {
|
|
2517
2552
|
key: "getRouterValidations",
|
|
@@ -2532,9 +2567,9 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2532
2567
|
schemaError: true
|
|
2533
2568
|
}]);
|
|
2534
2569
|
}
|
|
2535
|
-
var
|
|
2536
|
-
if (
|
|
2537
|
-
return Object.fromEntries(
|
|
2570
|
+
var routerValidationErrors = this.currentRouter.validate(moduleFilePath, Object.keys(src));
|
|
2571
|
+
if (routerValidationErrors.length > 0) {
|
|
2572
|
+
return Object.fromEntries(routerValidationErrors.map(function (validation) {
|
|
2538
2573
|
if (!validation.error.urlPath) {
|
|
2539
2574
|
return [path, [{
|
|
2540
2575
|
message: "Router validation error: ".concat(validation.error.message, " has no url path"),
|
|
@@ -2543,13 +2578,13 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2543
2578
|
}
|
|
2544
2579
|
var subPath = createValPathOfItem(path, validation.error.urlPath);
|
|
2545
2580
|
if (!subPath) {
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
schemaError: true
|
|
2549
|
-
}]];
|
|
2581
|
+
throw new Error("Internal error: could not create path at ".concat(!path && typeof path === "string" ? "<empty string>" : path, " for router validation")) // Should! never happen
|
|
2582
|
+
;
|
|
2550
2583
|
}
|
|
2551
2584
|
return [subPath, [{
|
|
2552
|
-
message: validation.error.message
|
|
2585
|
+
message: validation.error.message,
|
|
2586
|
+
value: validation.error.urlPath,
|
|
2587
|
+
keyError: true
|
|
2553
2588
|
}]];
|
|
2554
2589
|
}));
|
|
2555
2590
|
}
|
|
@@ -2558,10 +2593,11 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2558
2593
|
}, {
|
|
2559
2594
|
key: "executeSerialize",
|
|
2560
2595
|
value: function executeSerialize() {
|
|
2561
|
-
var _this$currentRouter, _this$customValidateF;
|
|
2596
|
+
var _this$keySchema, _this$currentRouter, _this$customValidateF;
|
|
2562
2597
|
return {
|
|
2563
2598
|
type: "record",
|
|
2564
2599
|
item: this.item["executeSerialize"](),
|
|
2600
|
+
key: (_this$keySchema = this.keySchema) === null || _this$keySchema === void 0 ? void 0 : _this$keySchema["executeSerialize"](),
|
|
2565
2601
|
opt: this.opt,
|
|
2566
2602
|
router: (_this$currentRouter = this.currentRouter) === null || _this$currentRouter === void 0 ? void 0 : _this$currentRouter.getRouterId(),
|
|
2567
2603
|
customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0
|
|
@@ -2574,16 +2610,16 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2574
2610
|
if (src === null) {
|
|
2575
2611
|
return res;
|
|
2576
2612
|
}
|
|
2577
|
-
for (var
|
|
2578
|
-
var itemSrc = src[
|
|
2613
|
+
for (var _key in src) {
|
|
2614
|
+
var itemSrc = src[_key];
|
|
2579
2615
|
if (itemSrc === null || itemSrc === undefined) {
|
|
2580
2616
|
continue;
|
|
2581
2617
|
}
|
|
2582
|
-
var subPath = unsafeCreateSourcePath(sourcePath,
|
|
2618
|
+
var subPath = unsafeCreateSourcePath(sourcePath, _key);
|
|
2583
2619
|
var itemResult = this.item["executeRender"](subPath, itemSrc);
|
|
2584
2620
|
for (var keyS in itemResult) {
|
|
2585
|
-
var
|
|
2586
|
-
res[
|
|
2621
|
+
var _key2 = keyS;
|
|
2622
|
+
res[_key2] = itemResult[_key2];
|
|
2587
2623
|
}
|
|
2588
2624
|
}
|
|
2589
2625
|
if (this.renderInput) {
|
|
@@ -2642,9 +2678,21 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
2642
2678
|
}
|
|
2643
2679
|
}]);
|
|
2644
2680
|
}(Schema);
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2681
|
+
|
|
2682
|
+
// Overload: with key schema
|
|
2683
|
+
|
|
2684
|
+
// Overload: without key schema
|
|
2685
|
+
|
|
2686
|
+
// Implementation
|
|
2687
|
+
function record(keyOrSchema, schema) {
|
|
2688
|
+
if (schema) {
|
|
2689
|
+
// Two-argument call: first is key schema, second is value schema
|
|
2690
|
+
return new RecordSchema(schema, false, [], null, keyOrSchema);
|
|
2691
|
+
} else {
|
|
2692
|
+
// One-argument call: only value schema
|
|
2693
|
+
return new RecordSchema(keyOrSchema, false, [], null, null);
|
|
2694
|
+
}
|
|
2695
|
+
}
|
|
2648
2696
|
|
|
2649
2697
|
function define(
|
|
2650
2698
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -4094,6 +4142,7 @@ var N = /*#__PURE__*/function (N) {
|
|
|
4094
4142
|
N[N["inputWords"] = 16] = "inputWords";
|
|
4095
4143
|
N[N["highIndex"] = 14] = "highIndex";
|
|
4096
4144
|
N[N["lowIndex"] = 15] = "lowIndex";
|
|
4145
|
+
// eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
|
|
4097
4146
|
N[N["workWords"] = 64] = "workWords";
|
|
4098
4147
|
N[N["allocBytes"] = 80] = "allocBytes";
|
|
4099
4148
|
N[N["allocWords"] = 20] = "allocWords";
|
|
@@ -5187,7 +5236,7 @@ function deserializeSchema(serialized) {
|
|
|
5187
5236
|
return new RichTextSchema(deserializedOptions, serialized.opt);
|
|
5188
5237
|
}
|
|
5189
5238
|
case "record":
|
|
5190
|
-
return new RecordSchema(deserializeSchema(serialized.item), serialized.opt);
|
|
5239
|
+
return new RecordSchema(deserializeSchema(serialized.item), serialized.opt, [], null, serialized.key ? deserializeSchema(serialized.key) : null);
|
|
5191
5240
|
case "keyOf":
|
|
5192
5241
|
return new KeyOfSchema(serialized.schema, serialized.path, serialized.opt);
|
|
5193
5242
|
case "file":
|
|
@@ -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-11591a0b.esm.js';
|
|
2
2
|
import './result-daff1cae.esm.js';
|
package/package.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@valbuild/core",
|
|
3
|
-
"version": "0.87.
|
|
3
|
+
"version": "0.87.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Val - supercharged hard-coded content",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/valbuild/val.git"
|
|
9
|
+
},
|
|
6
10
|
"scripts": {
|
|
7
11
|
"typecheck": "tsc --noEmit",
|
|
8
12
|
"test": "jest",
|
|
@@ -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-eb1a6b1f.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-34063fba.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-11591a0b.esm.js';
|
|
2
|
+
export { P as PatchError } from '../../dist/index-11591a0b.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
|
|