Enhance refactor commands with controller-aware Route() updates and fix code quality violations
Add semantic token highlighting for 'that' variable and comment file references in VS Code extension Add Phone_Text_Input and Currency_Input components with formatting utilities Implement client widgets, form standardization, and soft delete functionality Add modal scroll lock and update documentation Implement comprehensive modal system with form integration and validation Fix modal component instantiation using jQuery plugin API Implement modal system with responsive sizing, queuing, and validation support Implement form submission with validation, error handling, and loading states Implement country/state selectors with dynamic data loading and Bootstrap styling Revert Rsx::Route() highlighting in Blade/PHP files Target specific PHP scopes for Rsx::Route() highlighting in Blade Expand injection selector for Rsx::Route() highlighting Add custom syntax highlighting for Rsx::Route() and Rsx.Route() calls Update jqhtml packages to v2.2.165 Add bundle path validation for common mistakes (development mode only) Create Ajax_Select_Input widget and Rsx_Reference_Data controller Create Country_Select_Input widget with default country support Initialize Tom Select on Select_Input widgets Add Tom Select bundle for enhanced select dropdowns Implement ISO 3166 geographic data system for country/region selection Implement widget-based form system with disabled state support 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
4
node_modules/webpack-dev-server/node_modules/schema-utils/README.md
generated
vendored
4
node_modules/webpack-dev-server/node_modules/schema-utils/README.md
generated
vendored
@@ -1,7 +1,7 @@
|
||||
<div align="center">
|
||||
<a href="http://json-schema.org">
|
||||
<img width="160" height="160"
|
||||
src="https://raw.githubusercontent.com/webpack-contrib/schema-utils/master/.github/assets/logo.png">
|
||||
src="https://raw.githubusercontent.com/webpack-contrib/schema-utils/main/.github/assets/logo.png">
|
||||
</a>
|
||||
<a href="https://github.com/webpack/webpack">
|
||||
<img width="200" height="200"
|
||||
@@ -309,7 +309,7 @@ Please take a moment to read our contributing guidelines if you haven't yet done
|
||||
[node-url]: https://nodejs.org
|
||||
[tests]: https://github.com/webpack/schema-utils/workflows/schema-utils/badge.svg
|
||||
[tests-url]: https://github.com/webpack/schema-utils/actions
|
||||
[cover]: https://codecov.io/gh/webpack/schema-utils/branch/master/graph/badge.svg
|
||||
[cover]: https://codecov.io/gh/webpack/schema-utils/branch/main/graph/badge.svg
|
||||
[cover-url]: https://codecov.io/gh/webpack/schema-utils
|
||||
[discussion]: https://img.shields.io/github/discussions/webpack/webpack
|
||||
[discussion-url]: https://github.com/webpack/webpack/discussions
|
||||
|
||||
46
node_modules/webpack-dev-server/node_modules/schema-utils/declarations/ValidationError.d.ts
generated
vendored
Executable file → Normal file
46
node_modules/webpack-dev-server/node_modules/schema-utils/declarations/ValidationError.d.ts
generated
vendored
Executable file → Normal file
@@ -8,14 +8,14 @@ export type PostFormatter = import("./validate").PostFormatter;
|
||||
export type SchemaUtilErrorObject = import("./validate").SchemaUtilErrorObject;
|
||||
declare class ValidationError extends Error {
|
||||
/**
|
||||
* @param {Array<SchemaUtilErrorObject>} errors
|
||||
* @param {Schema} schema
|
||||
* @param {ValidationErrorConfiguration} configuration
|
||||
* @param {Array<SchemaUtilErrorObject>} errors array of error objects
|
||||
* @param {Schema} schema schema
|
||||
* @param {ValidationErrorConfiguration} configuration configuration
|
||||
*/
|
||||
constructor(
|
||||
errors: Array<SchemaUtilErrorObject>,
|
||||
schema: Schema,
|
||||
configuration?: ValidationErrorConfiguration
|
||||
configuration?: ValidationErrorConfiguration,
|
||||
);
|
||||
/** @type {Array<SchemaUtilErrorObject>} */
|
||||
errors: Array<SchemaUtilErrorObject>;
|
||||
@@ -28,47 +28,47 @@ declare class ValidationError extends Error {
|
||||
/** @type {PostFormatter | null} */
|
||||
postFormatter: PostFormatter | null;
|
||||
/**
|
||||
* @param {string} path
|
||||
* @returns {Schema}
|
||||
* @param {string} path path
|
||||
* @returns {Schema} schema
|
||||
*/
|
||||
getSchemaPart(path: string): Schema;
|
||||
/**
|
||||
* @param {Schema} schema
|
||||
* @param {boolean} logic
|
||||
* @param {Array<Object>} prevSchemas
|
||||
* @returns {string}
|
||||
* @param {Schema} schema schema
|
||||
* @param {boolean} logic logic
|
||||
* @param {Array<object>} prevSchemas prev schemas
|
||||
* @returns {string} formatted schema
|
||||
*/
|
||||
formatSchema(
|
||||
schema: Schema,
|
||||
logic?: boolean,
|
||||
prevSchemas?: Array<Object>
|
||||
prevSchemas?: Array<object>,
|
||||
): string;
|
||||
/**
|
||||
* @param {Schema=} schemaPart
|
||||
* @param {(boolean | Array<string>)=} additionalPath
|
||||
* @param {boolean=} needDot
|
||||
* @param {boolean=} logic
|
||||
* @returns {string}
|
||||
* @param {Schema=} schemaPart schema part
|
||||
* @param {(boolean | Array<string>)=} additionalPath additional path
|
||||
* @param {boolean=} needDot true when need dot
|
||||
* @param {boolean=} logic logic
|
||||
* @returns {string} schema part text
|
||||
*/
|
||||
getSchemaPartText(
|
||||
schemaPart?: Schema | undefined,
|
||||
additionalPath?: (boolean | Array<string>) | undefined,
|
||||
needDot?: boolean | undefined,
|
||||
logic?: boolean | undefined
|
||||
logic?: boolean | undefined,
|
||||
): string;
|
||||
/**
|
||||
* @param {Schema=} schemaPart
|
||||
* @returns {string}
|
||||
* @param {Schema=} schemaPart schema part
|
||||
* @returns {string} schema part description
|
||||
*/
|
||||
getSchemaPartDescription(schemaPart?: Schema | undefined): string;
|
||||
/**
|
||||
* @param {SchemaUtilErrorObject} error
|
||||
* @returns {string}
|
||||
* @param {SchemaUtilErrorObject} error error object
|
||||
* @returns {string} formatted error object
|
||||
*/
|
||||
formatValidationError(error: SchemaUtilErrorObject): string;
|
||||
/**
|
||||
* @param {Array<SchemaUtilErrorObject>} errors
|
||||
* @returns {string}
|
||||
* @param {Array<SchemaUtilErrorObject>} errors errors
|
||||
* @returns {string} formatted errors
|
||||
*/
|
||||
formatValidationErrors(errors: Array<SchemaUtilErrorObject>): string;
|
||||
}
|
||||
|
||||
2
node_modules/webpack-dev-server/node_modules/schema-utils/declarations/index.d.ts
generated
vendored
Executable file → Normal file
2
node_modules/webpack-dev-server/node_modules/schema-utils/declarations/index.d.ts
generated
vendored
Executable file → Normal file
@@ -3,6 +3,8 @@ export type JSONSchema4 = import("./validate").JSONSchema4;
|
||||
export type JSONSchema6 = import("./validate").JSONSchema6;
|
||||
export type JSONSchema7 = import("./validate").JSONSchema7;
|
||||
export type ExtendedSchema = import("./validate").ExtendedSchema;
|
||||
export type ValidationErrorConfiguration =
|
||||
import("./validate").ValidationErrorConfiguration;
|
||||
import { validate } from "./validate";
|
||||
import { ValidationError } from "./validate";
|
||||
import { enableValidation } from "./validate";
|
||||
|
||||
5
node_modules/webpack-dev-server/node_modules/schema-utils/declarations/keywords/absolutePath.d.ts
generated
vendored
Executable file → Normal file
5
node_modules/webpack-dev-server/node_modules/schema-utils/declarations/keywords/absolutePath.d.ts
generated
vendored
Executable file → Normal file
@@ -4,8 +4,7 @@ export type SchemaValidateFunction = import("ajv").SchemaValidateFunction;
|
||||
export type AnySchemaObject = import("ajv").AnySchemaObject;
|
||||
export type SchemaUtilErrorObject = import("../validate").SchemaUtilErrorObject;
|
||||
/**
|
||||
*
|
||||
* @param {Ajv} ajv
|
||||
* @returns {Ajv}
|
||||
* @param {Ajv} ajv ajv
|
||||
* @returns {Ajv} configured ajv
|
||||
*/
|
||||
declare function addAbsolutePathKeyword(ajv: Ajv): Ajv;
|
||||
|
||||
4
node_modules/webpack-dev-server/node_modules/schema-utils/declarations/keywords/limit.d.ts
generated
vendored
Executable file → Normal file
4
node_modules/webpack-dev-server/node_modules/schema-utils/declarations/keywords/limit.d.ts
generated
vendored
Executable file → Normal file
@@ -8,7 +8,7 @@ export type KeywordErrorDefinition = import("ajv").KeywordErrorDefinition;
|
||||
/** @typedef {import("ajv").Name} Name */
|
||||
/** @typedef {import("ajv").KeywordErrorDefinition} KeywordErrorDefinition */
|
||||
/**
|
||||
* @param {Ajv} ajv
|
||||
* @returns {Ajv}
|
||||
* @param {Ajv} ajv ajv
|
||||
* @returns {Ajv} ajv with limit keyword
|
||||
*/
|
||||
declare function addLimitKeyword(ajv: Ajv): Ajv;
|
||||
|
||||
5
node_modules/webpack-dev-server/node_modules/schema-utils/declarations/keywords/undefinedAsNull.d.ts
generated
vendored
Executable file → Normal file
5
node_modules/webpack-dev-server/node_modules/schema-utils/declarations/keywords/undefinedAsNull.d.ts
generated
vendored
Executable file → Normal file
@@ -8,8 +8,7 @@ export type ValidateFunction = import("ajv").ValidateFunction;
|
||||
/** @typedef {import("ajv").AnySchemaObject} AnySchemaObject */
|
||||
/** @typedef {import("ajv").ValidateFunction} ValidateFunction */
|
||||
/**
|
||||
*
|
||||
* @param {Ajv} ajv
|
||||
* @returns {Ajv}
|
||||
* @param {Ajv} ajv ajv
|
||||
* @returns {Ajv} configured ajv
|
||||
*/
|
||||
declare function addUndefinedAsNullKeyword(ajv: Ajv): Ajv;
|
||||
|
||||
34
node_modules/webpack-dev-server/node_modules/schema-utils/declarations/util/Range.d.ts
generated
vendored
Executable file → Normal file
34
node_modules/webpack-dev-server/node_modules/schema-utils/declarations/util/Range.d.ts
generated
vendored
Executable file → Normal file
@@ -9,26 +9,26 @@ export = Range;
|
||||
*/
|
||||
declare class Range {
|
||||
/**
|
||||
* @param {"left" | "right"} side
|
||||
* @param {boolean} exclusive
|
||||
* @returns {">" | ">=" | "<" | "<="}
|
||||
* @param {"left" | "right"} side side
|
||||
* @param {boolean} exclusive exclusive
|
||||
* @returns {">" | ">=" | "<" | "<="} operator
|
||||
*/
|
||||
static getOperator(
|
||||
side: "left" | "right",
|
||||
exclusive: boolean
|
||||
exclusive: boolean,
|
||||
): ">" | ">=" | "<" | "<=";
|
||||
/**
|
||||
* @param {number} value
|
||||
* @param {number} value value
|
||||
* @param {boolean} logic is not logic applied
|
||||
* @param {boolean} exclusive is range exclusive
|
||||
* @returns {string}
|
||||
* @returns {string} formatted right
|
||||
*/
|
||||
static formatRight(value: number, logic: boolean, exclusive: boolean): string;
|
||||
/**
|
||||
* @param {number} value
|
||||
* @param {number} value value
|
||||
* @param {boolean} logic is not logic applied
|
||||
* @param {boolean} exclusive is range exclusive
|
||||
* @returns {string}
|
||||
* @returns {string} formatted left
|
||||
*/
|
||||
static formatLeft(value: number, logic: boolean, exclusive: boolean): string;
|
||||
/**
|
||||
@@ -37,19 +37,19 @@ declare class Range {
|
||||
* @param {boolean} startExclusive is range exclusive from left side
|
||||
* @param {boolean} endExclusive is range exclusive from right side
|
||||
* @param {boolean} logic is not logic applied
|
||||
* @returns {string}
|
||||
* @returns {string} formatted range
|
||||
*/
|
||||
static formatRange(
|
||||
start: number,
|
||||
end: number,
|
||||
startExclusive: boolean,
|
||||
endExclusive: boolean,
|
||||
logic: boolean
|
||||
logic: boolean,
|
||||
): string;
|
||||
/**
|
||||
* @param {Array<RangeValue>} values
|
||||
* @param {Array<RangeValue>} values values
|
||||
* @param {boolean} logic is not logic applied
|
||||
* @return {RangeValue} computed value and it's exclusive flag
|
||||
* @returns {RangeValue} computed value and it's exclusive flag
|
||||
*/
|
||||
static getRangeValue(values: Array<RangeValue>, logic: boolean): RangeValue;
|
||||
/** @type {Array<RangeValue>} */
|
||||
@@ -57,18 +57,18 @@ declare class Range {
|
||||
/** @type {Array<RangeValue>} */
|
||||
_right: Array<RangeValue>;
|
||||
/**
|
||||
* @param {number} value
|
||||
* @param {boolean=} exclusive
|
||||
* @param {number} value value
|
||||
* @param {boolean=} exclusive true when exclusive, otherwise false
|
||||
*/
|
||||
left(value: number, exclusive?: boolean | undefined): void;
|
||||
/**
|
||||
* @param {number} value
|
||||
* @param {boolean=} exclusive
|
||||
* @param {number} value value
|
||||
* @param {boolean=} exclusive true when exclusive, otherwise false
|
||||
*/
|
||||
right(value: number, exclusive?: boolean | undefined): void;
|
||||
/**
|
||||
* @param {boolean} logic is not logic applied
|
||||
* @return {string} "smart" range string representation
|
||||
* @returns {string} "smart" range string representation
|
||||
*/
|
||||
format(logic?: boolean): string;
|
||||
}
|
||||
|
||||
0
node_modules/webpack-dev-server/node_modules/schema-utils/declarations/util/hints.d.ts
generated
vendored
Executable file → Normal file
0
node_modules/webpack-dev-server/node_modules/schema-utils/declarations/util/hints.d.ts
generated
vendored
Executable file → Normal file
11
node_modules/webpack-dev-server/node_modules/schema-utils/declarations/util/memorize.d.ts
generated
vendored
Executable file → Normal file
11
node_modules/webpack-dev-server/node_modules/schema-utils/declarations/util/memorize.d.ts
generated
vendored
Executable file → Normal file
@@ -1,7 +1,12 @@
|
||||
export default memoize;
|
||||
export type FunctionReturning<T> = () => T;
|
||||
/**
|
||||
* @template T
|
||||
* @param fn {(function(): any) | undefined}
|
||||
* @returns {function(): T}
|
||||
* @typedef {() => T} FunctionReturning
|
||||
*/
|
||||
declare function memoize<T>(fn: (() => any) | undefined): () => T;
|
||||
/**
|
||||
* @template T
|
||||
* @param {FunctionReturning<T>} fn memorized function
|
||||
* @returns {FunctionReturning<T>} new function
|
||||
*/
|
||||
declare function memoize<T>(fn: FunctionReturning<T>): FunctionReturning<T>;
|
||||
|
||||
49
node_modules/webpack-dev-server/node_modules/schema-utils/declarations/validate.d.ts
generated
vendored
Executable file → Normal file
49
node_modules/webpack-dev-server/node_modules/schema-utils/declarations/validate.d.ts
generated
vendored
Executable file → Normal file
@@ -1,13 +1,32 @@
|
||||
export { default as ValidationError } from "./ValidationError";
|
||||
export type JSONSchema4 = import("json-schema").JSONSchema4;
|
||||
export type JSONSchema6 = import("json-schema").JSONSchema6;
|
||||
export type JSONSchema7 = import("json-schema").JSONSchema7;
|
||||
export type ErrorObject = import("ajv").ErrorObject;
|
||||
export type ExtendedSchema = {
|
||||
/**
|
||||
* format minimum
|
||||
*/
|
||||
formatMinimum?: (string | number) | undefined;
|
||||
/**
|
||||
* format maximum
|
||||
*/
|
||||
formatMaximum?: (string | number) | undefined;
|
||||
/**
|
||||
* format exclusive minimum
|
||||
*/
|
||||
formatExclusiveMinimum?: (string | boolean) | undefined;
|
||||
/**
|
||||
* format exclusive maximum
|
||||
*/
|
||||
formatExclusiveMaximum?: (string | boolean) | undefined;
|
||||
/**
|
||||
* link
|
||||
*/
|
||||
link?: string | undefined;
|
||||
/**
|
||||
* undefined will be resolved as null
|
||||
*/
|
||||
undefinedAsNull?: boolean | undefined;
|
||||
};
|
||||
export type Extend = ExtendedSchema;
|
||||
@@ -17,26 +36,42 @@ export type SchemaUtilErrorObject = ErrorObject & {
|
||||
};
|
||||
export type PostFormatter = (
|
||||
formattedError: string,
|
||||
error: SchemaUtilErrorObject
|
||||
error: SchemaUtilErrorObject,
|
||||
) => string;
|
||||
export type ValidationErrorConfiguration = {
|
||||
/**
|
||||
* name
|
||||
*/
|
||||
name?: string | undefined;
|
||||
/**
|
||||
* base data path
|
||||
*/
|
||||
baseDataPath?: string | undefined;
|
||||
/**
|
||||
* post formatter
|
||||
*/
|
||||
postFormatter?: PostFormatter | undefined;
|
||||
};
|
||||
/**
|
||||
* @param {Schema} schema
|
||||
* @param {Array<object> | object} options
|
||||
* @param {ValidationErrorConfiguration=} configuration
|
||||
* @param {Schema} schema schema
|
||||
* @param {Array<object> | object} options options
|
||||
* @param {ValidationErrorConfiguration=} configuration configuration
|
||||
* @returns {void}
|
||||
*/
|
||||
export function validate(
|
||||
schema: Schema,
|
||||
options: Array<object> | object,
|
||||
configuration?: ValidationErrorConfiguration | undefined
|
||||
configuration?: ValidationErrorConfiguration | undefined,
|
||||
): void;
|
||||
/**
|
||||
* @returns {void}
|
||||
*/
|
||||
export function enableValidation(): void;
|
||||
/**
|
||||
* @returns {void}
|
||||
*/
|
||||
export function disableValidation(): void;
|
||||
/**
|
||||
* @returns {boolean} true when need validate, otherwise false
|
||||
*/
|
||||
export function needValidate(): boolean;
|
||||
import ValidationError from "./ValidationError";
|
||||
export { ValidationError };
|
||||
|
||||
346
node_modules/webpack-dev-server/node_modules/schema-utils/dist/ValidationError.js
generated
vendored
Executable file → Normal file
346
node_modules/webpack-dev-server/node_modules/schema-utils/dist/ValidationError.js
generated
vendored
Executable file → Normal file
@@ -51,18 +51,17 @@ const SPECIFICITY = {
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} value
|
||||
* @returns {value is number}
|
||||
* @param {string} value value
|
||||
* @returns {value is number} true when is number, otherwise false
|
||||
*/
|
||||
function isNumeric(value) {
|
||||
return /^-?\d+$/.test(value);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {Array<SchemaUtilErrorObject>} array
|
||||
* @param {(item: SchemaUtilErrorObject) => number} fn
|
||||
* @returns {Array<SchemaUtilErrorObject>}
|
||||
* @param {Array<SchemaUtilErrorObject>} array array of error objects
|
||||
* @param {(item: SchemaUtilErrorObject) => number} fn function
|
||||
* @returns {Array<SchemaUtilErrorObject>} filtered max
|
||||
*/
|
||||
function filterMax(array, fn) {
|
||||
const evaluatedMax = array.reduce((max, item) => Math.max(max, fn(item)), 0);
|
||||
@@ -70,58 +69,30 @@ function filterMax(array, fn) {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {Array<SchemaUtilErrorObject>} children
|
||||
* @returns {Array<SchemaUtilErrorObject>}
|
||||
* @param {Array<SchemaUtilErrorObject>} children children
|
||||
* @returns {Array<SchemaUtilErrorObject>} filtered children
|
||||
*/
|
||||
function filterChildren(children) {
|
||||
let newChildren = children;
|
||||
newChildren = filterMax(newChildren,
|
||||
/**
|
||||
*
|
||||
* @param {SchemaUtilErrorObject} error
|
||||
* @returns {number}
|
||||
* @param {SchemaUtilErrorObject} error error object
|
||||
* @returns {number} result
|
||||
*/
|
||||
error => error.instancePath ? error.instancePath.length : 0);
|
||||
newChildren = filterMax(newChildren,
|
||||
/**
|
||||
* @param {SchemaUtilErrorObject} error
|
||||
* @returns {number}
|
||||
* @param {SchemaUtilErrorObject} error error object
|
||||
* @returns {number} result
|
||||
*/
|
||||
error => SPECIFICITY[(/** @type {keyof typeof SPECIFICITY} */error.keyword)] || 2);
|
||||
return newChildren;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find all children errors
|
||||
* @param {Array<SchemaUtilErrorObject>} children
|
||||
* @param {Array<string>} schemaPaths
|
||||
* @return {number} returns index of first child
|
||||
*/
|
||||
function findAllChildren(children, schemaPaths) {
|
||||
let i = children.length - 1;
|
||||
const predicate =
|
||||
/**
|
||||
* @param {string} schemaPath
|
||||
* @returns {boolean}
|
||||
*/
|
||||
schemaPath => children[i].schemaPath.indexOf(schemaPath) !== 0;
|
||||
while (i > -1 && !schemaPaths.every(predicate)) {
|
||||
if (children[i].keyword === "anyOf" || children[i].keyword === "oneOf") {
|
||||
const refs = extractRefs(children[i]);
|
||||
const childrenStart = findAllChildren(children.slice(0, i), refs.concat(children[i].schemaPath));
|
||||
i = childrenStart - 1;
|
||||
} else {
|
||||
i -= 1;
|
||||
}
|
||||
}
|
||||
return i + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts all refs from schema
|
||||
* @param {SchemaUtilErrorObject} error
|
||||
* @return {Array<string>}
|
||||
* @param {SchemaUtilErrorObject} error error object
|
||||
* @returns {Array<string>} extracted refs
|
||||
*/
|
||||
function extractRefs(error) {
|
||||
const {
|
||||
@@ -132,13 +103,39 @@ function extractRefs(error) {
|
||||
}
|
||||
return schema.map(({
|
||||
$ref
|
||||
}) => $ref).filter(s => s);
|
||||
}) => $ref).filter(Boolean);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find all children errors
|
||||
* @param {Array<SchemaUtilErrorObject>} children children
|
||||
* @param {Array<string>} schemaPaths schema paths
|
||||
* @returns {number} returns index of first child
|
||||
*/
|
||||
function findAllChildren(children, schemaPaths) {
|
||||
let i = children.length - 1;
|
||||
const predicate =
|
||||
/**
|
||||
* @param {string} schemaPath schema path
|
||||
* @returns {boolean} predicate
|
||||
*/
|
||||
schemaPath => children[i].schemaPath.indexOf(schemaPath) !== 0;
|
||||
while (i > -1 && !schemaPaths.every(predicate)) {
|
||||
if (children[i].keyword === "anyOf" || children[i].keyword === "oneOf") {
|
||||
const refs = extractRefs(children[i]);
|
||||
const childrenStart = findAllChildren(children.slice(0, i), [...refs, children[i].schemaPath]);
|
||||
i = childrenStart - 1;
|
||||
} else {
|
||||
i -= 1;
|
||||
}
|
||||
}
|
||||
return i + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Groups children by their first level parent (assuming that error is root)
|
||||
* @param {Array<SchemaUtilErrorObject>} children
|
||||
* @return {Array<SchemaUtilErrorObject>}
|
||||
* @param {Array<SchemaUtilErrorObject>} children children
|
||||
* @returns {Array<SchemaUtilErrorObject>} grouped children
|
||||
*/
|
||||
function groupChildrenByFirstChild(children) {
|
||||
const result = [];
|
||||
@@ -147,11 +144,12 @@ function groupChildrenByFirstChild(children) {
|
||||
const child = children[i];
|
||||
if (child.keyword === "anyOf" || child.keyword === "oneOf") {
|
||||
const refs = extractRefs(child);
|
||||
const childrenStart = findAllChildren(children.slice(0, i), refs.concat(child.schemaPath));
|
||||
const childrenStart = findAllChildren(children.slice(0, i), [...refs, child.schemaPath]);
|
||||
if (childrenStart !== i) {
|
||||
result.push(Object.assign({}, child, {
|
||||
result.push({
|
||||
...child,
|
||||
children: children.slice(childrenStart, i)
|
||||
}));
|
||||
});
|
||||
i = childrenStart;
|
||||
} else {
|
||||
result.push(child);
|
||||
@@ -168,25 +166,25 @@ function groupChildrenByFirstChild(children) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} str
|
||||
* @param {string} prefix
|
||||
* @returns {string}
|
||||
* @param {string} str string
|
||||
* @param {string} prefix prefix
|
||||
* @returns {string} string with indent and prefix
|
||||
*/
|
||||
function indent(str, prefix) {
|
||||
return str.replace(/\n(?!$)/g, `\n${prefix}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Schema} schema
|
||||
* @returns {schema is (Schema & {not: Schema})}
|
||||
* @param {Schema} schema schema
|
||||
* @returns {schema is (Schema & {not: Schema})} true when `not` in schema, otherwise false
|
||||
*/
|
||||
function hasNotInSchema(schema) {
|
||||
return !!schema.not;
|
||||
return Boolean(schema.not);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Schema} schema
|
||||
* @return {Schema}
|
||||
* @param {Schema} schema schema
|
||||
* @returns {Schema} first typed schema
|
||||
*/
|
||||
function findFirstTypedSchema(schema) {
|
||||
if (hasNotInSchema(schema)) {
|
||||
@@ -196,81 +194,82 @@ function findFirstTypedSchema(schema) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Schema} schema
|
||||
* @return {boolean}
|
||||
*/
|
||||
function canApplyNot(schema) {
|
||||
const typedSchema = findFirstTypedSchema(schema);
|
||||
return likeNumber(typedSchema) || likeInteger(typedSchema) || likeString(typedSchema) || likeNull(typedSchema) || likeBoolean(typedSchema);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} maybeObj
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function isObject(maybeObj) {
|
||||
return typeof maybeObj === "object" && !Array.isArray(maybeObj) && maybeObj !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Schema} schema
|
||||
* @returns {boolean}
|
||||
* @param {Schema} schema schema
|
||||
* @returns {boolean} true when schema type is number, otherwise false
|
||||
*/
|
||||
function likeNumber(schema) {
|
||||
return schema.type === "number" || typeof schema.minimum !== "undefined" || typeof schema.exclusiveMinimum !== "undefined" || typeof schema.maximum !== "undefined" || typeof schema.exclusiveMaximum !== "undefined" || typeof schema.multipleOf !== "undefined";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Schema} schema
|
||||
* @returns {boolean}
|
||||
* @param {Schema} schema schema
|
||||
* @returns {boolean} true when schema type is integer, otherwise false
|
||||
*/
|
||||
function likeInteger(schema) {
|
||||
return schema.type === "integer" || typeof schema.minimum !== "undefined" || typeof schema.exclusiveMinimum !== "undefined" || typeof schema.maximum !== "undefined" || typeof schema.exclusiveMaximum !== "undefined" || typeof schema.multipleOf !== "undefined";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Schema} schema
|
||||
* @returns {boolean}
|
||||
* @param {Schema} schema schema
|
||||
* @returns {boolean} true when schema type is string, otherwise false
|
||||
*/
|
||||
function likeString(schema) {
|
||||
return schema.type === "string" || typeof schema.minLength !== "undefined" || typeof schema.maxLength !== "undefined" || typeof schema.pattern !== "undefined" || typeof schema.format !== "undefined" || typeof schema.formatMinimum !== "undefined" || typeof schema.formatMaximum !== "undefined";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Schema} schema
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function likeBoolean(schema) {
|
||||
return schema.type === "boolean";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Schema} schema
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function likeArray(schema) {
|
||||
return schema.type === "array" || typeof schema.minItems === "number" || typeof schema.maxItems === "number" || typeof schema.uniqueItems !== "undefined" || typeof schema.items !== "undefined" || typeof schema.additionalItems !== "undefined" || typeof schema.contains !== "undefined";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Schema & {patternRequired?: Array<string>}} schema
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function likeObject(schema) {
|
||||
return schema.type === "object" || typeof schema.minProperties !== "undefined" || typeof schema.maxProperties !== "undefined" || typeof schema.required !== "undefined" || typeof schema.properties !== "undefined" || typeof schema.patternProperties !== "undefined" || typeof schema.additionalProperties !== "undefined" || typeof schema.dependencies !== "undefined" || typeof schema.propertyNames !== "undefined" || typeof schema.patternRequired !== "undefined";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Schema} schema
|
||||
* @returns {boolean}
|
||||
* @param {Schema} schema schema
|
||||
* @returns {boolean} true when null, otherwise false
|
||||
*/
|
||||
function likeNull(schema) {
|
||||
return schema.type === "null";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} type
|
||||
* @returns {string}
|
||||
* @param {Schema} schema schema
|
||||
* @returns {boolean} true when schema type is boolean, otherwise false
|
||||
*/
|
||||
function likeBoolean(schema) {
|
||||
return schema.type === "boolean";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Schema} schema schema
|
||||
* @returns {boolean} true when can apply not, otherwise false
|
||||
*/
|
||||
function canApplyNot(schema) {
|
||||
const typedSchema = findFirstTypedSchema(schema);
|
||||
return likeNumber(typedSchema) || likeInteger(typedSchema) || likeString(typedSchema) || likeNull(typedSchema) || likeBoolean(typedSchema);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line jsdoc/no-restricted-syntax
|
||||
/**
|
||||
* @param {any} maybeObj maybe obj
|
||||
* @returns {boolean} true when value is object, otherwise false
|
||||
*/
|
||||
function isObject(maybeObj) {
|
||||
return typeof maybeObj === "object" && !Array.isArray(maybeObj) && maybeObj !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Schema} schema schema
|
||||
* @returns {boolean} true when schema type is array, otherwise false
|
||||
*/
|
||||
function likeArray(schema) {
|
||||
return schema.type === "array" || typeof schema.minItems === "number" || typeof schema.maxItems === "number" || typeof schema.uniqueItems !== "undefined" || typeof schema.items !== "undefined" || typeof schema.additionalItems !== "undefined" || typeof schema.contains !== "undefined";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Schema & {patternRequired?: Array<string>}} schema schema
|
||||
* @returns {boolean} true when schema type is object, otherwise false
|
||||
*/
|
||||
function likeObject(schema) {
|
||||
return schema.type === "object" || typeof schema.minProperties !== "undefined" || typeof schema.maxProperties !== "undefined" || typeof schema.required !== "undefined" || typeof schema.properties !== "undefined" || typeof schema.patternProperties !== "undefined" || typeof schema.additionalProperties !== "undefined" || typeof schema.dependencies !== "undefined" || typeof schema.propertyNames !== "undefined" || typeof schema.patternRequired !== "undefined";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} type type
|
||||
* @returns {string} article
|
||||
*/
|
||||
function getArticle(type) {
|
||||
if (/^[aeiou]/i.test(type)) {
|
||||
@@ -280,8 +279,8 @@ function getArticle(type) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Schema=} schema
|
||||
* @returns {string}
|
||||
* @param {Schema=} schema schema
|
||||
* @returns {string} schema non types
|
||||
*/
|
||||
function getSchemaNonTypes(schema) {
|
||||
if (!schema) {
|
||||
@@ -305,20 +304,18 @@ function getSchemaNonTypes(schema) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Array<string>} hints
|
||||
* @returns {string}
|
||||
* @param {Array<string>} hints hints
|
||||
* @returns {string} formatted hints
|
||||
*/
|
||||
function formatHints(hints) {
|
||||
return hints.length > 0 ? `(${hints.join(", ")})` : "";
|
||||
}
|
||||
const getUtilHints = (0, _memorize.default)(() =>
|
||||
// eslint-disable-next-line global-require
|
||||
require("./util/hints"));
|
||||
const getUtilHints = (0, _memorize.default)(() => require("./util/hints"));
|
||||
|
||||
/**
|
||||
* @param {Schema} schema
|
||||
* @param {boolean} logic
|
||||
* @returns {string[]}
|
||||
* @param {Schema} schema schema
|
||||
* @param {boolean} logic logic
|
||||
* @returns {string[]} array of hints
|
||||
*/
|
||||
function getHints(schema, logic) {
|
||||
if (likeNumber(schema) || likeInteger(schema)) {
|
||||
@@ -332,9 +329,9 @@ function getHints(schema, logic) {
|
||||
}
|
||||
class ValidationError extends Error {
|
||||
/**
|
||||
* @param {Array<SchemaUtilErrorObject>} errors
|
||||
* @param {Schema} schema
|
||||
* @param {ValidationErrorConfiguration} configuration
|
||||
* @param {Array<SchemaUtilErrorObject>} errors array of error objects
|
||||
* @param {Schema} schema schema
|
||||
* @param {ValidationErrorConfiguration} configuration configuration
|
||||
*/
|
||||
constructor(errors, schema, configuration = {}) {
|
||||
super();
|
||||
@@ -374,8 +371,8 @@ class ValidationError extends Error {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} path
|
||||
* @returns {Schema}
|
||||
* @param {string} path path
|
||||
* @returns {Schema} schema
|
||||
*/
|
||||
getSchemaPart(path) {
|
||||
const newPath = path.split("/");
|
||||
@@ -391,19 +388,18 @@ class ValidationError extends Error {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Schema} schema
|
||||
* @param {boolean} logic
|
||||
* @param {Array<Object>} prevSchemas
|
||||
* @returns {string}
|
||||
* @param {Schema} schema schema
|
||||
* @param {boolean} logic logic
|
||||
* @param {Array<object>} prevSchemas prev schemas
|
||||
* @returns {string} formatted schema
|
||||
*/
|
||||
formatSchema(schema, logic = true, prevSchemas = []) {
|
||||
let newLogic = logic;
|
||||
const formatInnerSchema =
|
||||
/**
|
||||
*
|
||||
* @param {Object} innerSchema
|
||||
* @param {boolean=} addSelf
|
||||
* @returns {string}
|
||||
* @param {Schema} innerSchema inner schema
|
||||
* @param {boolean=} addSelf true when need to add self
|
||||
* @returns {string} formatted schema
|
||||
*/
|
||||
(innerSchema, addSelf) => {
|
||||
if (!addSelf) {
|
||||
@@ -412,7 +408,7 @@ class ValidationError extends Error {
|
||||
if (prevSchemas.includes(innerSchema)) {
|
||||
return "(recursive)";
|
||||
}
|
||||
return this.formatSchema(innerSchema, newLogic, prevSchemas.concat(schema));
|
||||
return this.formatSchema(innerSchema, newLogic, [...prevSchemas, schema]);
|
||||
};
|
||||
if (hasNotInSchema(schema) && !likeObject(schema)) {
|
||||
if (canApplyNot(schema.not)) {
|
||||
@@ -424,19 +420,21 @@ class ValidationError extends Error {
|
||||
newLogic = !logic;
|
||||
return needApplyLogicHere ? prefix + formatInnerSchema(schema.not) : formatInnerSchema(schema.not);
|
||||
}
|
||||
if (/** @type {Schema & {instanceof: string | Array<string>}} */schema.instanceof) {
|
||||
if (/** @type {Schema & {instanceof: string | Array<string>}} */
|
||||
schema.instanceof) {
|
||||
const {
|
||||
instanceof: value
|
||||
} = /** @type {Schema & {instanceof: string | Array<string>}} */schema;
|
||||
const values = !Array.isArray(value) ? [value] : value;
|
||||
return values.map(
|
||||
/**
|
||||
* @param {string} item
|
||||
* @returns {string}
|
||||
* @param {string} item item
|
||||
* @returns {string} result
|
||||
*/
|
||||
item => item === "Function" ? "function" : item).join(" | ");
|
||||
}
|
||||
if (schema.enum) {
|
||||
// eslint-disable-next-line jsdoc/no-restricted-syntax
|
||||
const enumValues = /** @type {Array<any>} */schema.enum.map(item => {
|
||||
if (item === null && schema.undefinedAsNull) {
|
||||
return `${JSON.stringify(item)} | undefined`;
|
||||
@@ -463,7 +461,7 @@ class ValidationError extends Error {
|
||||
then: thenValue,
|
||||
else: elseValue
|
||||
} = /** @type {JSONSchema7} */schema;
|
||||
return `${ifValue ? `if ${formatInnerSchema(ifValue)}` : ""}${thenValue ? ` then ${formatInnerSchema(thenValue)}` : ""}${elseValue ? ` else ${formatInnerSchema(elseValue)}` : ""}`;
|
||||
return `${ifValue ? `if ${ifValue === true ? "true" : formatInnerSchema(ifValue)}` : ""}${thenValue ? ` then ${thenValue === true ? "true" : formatInnerSchema(thenValue)}` : ""}${elseValue ? ` else ${elseValue === true ? "true" : formatInnerSchema(elseValue)}` : ""}`;
|
||||
}
|
||||
if (schema.$ref) {
|
||||
return formatInnerSchema(this.getSchemaPart(schema.$ref), true);
|
||||
@@ -499,12 +497,10 @@ class ValidationError extends Error {
|
||||
if (schema.items) {
|
||||
if (Array.isArray(schema.items) && schema.items.length > 0) {
|
||||
items = `${/** @type {Array<Schema>} */schema.items.map(item => formatInnerSchema(item)).join(", ")}`;
|
||||
if (hasAdditionalItems) {
|
||||
if (schema.additionalItems && isObject(schema.additionalItems) && Object.keys(schema.additionalItems).length > 0) {
|
||||
hints.push(`additional items should be ${formatInnerSchema(schema.additionalItems)}`);
|
||||
}
|
||||
if (hasAdditionalItems && schema.additionalItems && isObject(schema.additionalItems) && Object.keys(schema.additionalItems).length > 0) {
|
||||
hints.push(`additional items should be ${schema.additionalItems === true ? "added" : formatInnerSchema(schema.additionalItems)}`);
|
||||
}
|
||||
} else if (schema.items && Object.keys(schema.items).length > 0) {
|
||||
} else if (schema.items && Object.keys(schema.items).length > 0 && schema.items !== true) {
|
||||
// "additionalItems" is ignored
|
||||
items = `${formatInnerSchema(schema.items)}`;
|
||||
} else {
|
||||
@@ -535,31 +531,30 @@ class ValidationError extends Error {
|
||||
hints.push(`additional property names should match pattern${patternProperties.length > 1 ? "s" : ""} ${patternProperties.map(pattern => JSON.stringify(pattern)).join(" | ")}`);
|
||||
}
|
||||
const properties = schema.properties ? Object.keys(schema.properties) : [];
|
||||
/** @type {Array<string>} */
|
||||
// @ts-ignore
|
||||
const required = schema.required ? schema.required : [];
|
||||
const allProperties = [...new Set(/** @type {Array<string>} */[].concat(required).concat(properties))];
|
||||
const objectStructure = allProperties.map(property => {
|
||||
const required = /** @type {string[]} */
|
||||
schema.required ? schema.required : [];
|
||||
const allProperties = [...new Set(/** @type {Array<string>} */[...required, ...properties])];
|
||||
const objectStructure = [...allProperties.map(property => {
|
||||
const isRequired = required.includes(property);
|
||||
|
||||
// Some properties need quotes, maybe we should add check
|
||||
// Maybe we should output type of property (`foo: string`), but it is looks very unreadable
|
||||
return `${property}${isRequired ? "" : "?"}`;
|
||||
}).concat(typeof schema.additionalProperties === "undefined" || Boolean(schema.additionalProperties) ? schema.additionalProperties && isObject(schema.additionalProperties) ? [`<key>: ${formatInnerSchema(schema.additionalProperties)}`] : ["…"] : []).join(", ");
|
||||
}), ...(typeof schema.additionalProperties === "undefined" || Boolean(schema.additionalProperties) ? schema.additionalProperties && isObject(schema.additionalProperties) && schema.additionalProperties !== true ? [`<key>: ${formatInnerSchema(schema.additionalProperties)}`] : ["…"] : [])].join(", ");
|
||||
const {
|
||||
dependencies,
|
||||
propertyNames,
|
||||
patternRequired
|
||||
} = /** @type {Schema & {patternRequired?: Array<string>;}} */schema;
|
||||
if (dependencies) {
|
||||
Object.keys(dependencies).forEach(dependencyName => {
|
||||
for (const dependencyName of Object.keys(dependencies)) {
|
||||
const dependency = dependencies[dependencyName];
|
||||
if (Array.isArray(dependency)) {
|
||||
hints.push(`should have ${dependency.length > 1 ? "properties" : "property"} ${dependency.map(dep => `'${dep}'`).join(", ")} when property '${dependencyName}' is present`);
|
||||
} else {
|
||||
hints.push(`should be valid according to the schema ${formatInnerSchema(dependency)} when property '${dependencyName}' is present`);
|
||||
hints.push(`should be valid according to the schema ${typeof dependency === "boolean" ? `${dependency}` : formatInnerSchema(dependency)} when property '${dependencyName}' is present`);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
if (propertyNames && Object.keys(propertyNames).length > 0) {
|
||||
hints.push(`each property name should match format ${JSON.stringify(schema.propertyNames.format)}`);
|
||||
@@ -567,8 +562,8 @@ class ValidationError extends Error {
|
||||
if (patternRequired && patternRequired.length > 0) {
|
||||
hints.push(`should have property matching pattern ${patternRequired.map(
|
||||
/**
|
||||
* @param {string} item
|
||||
* @returns {string}
|
||||
* @param {string} item item
|
||||
* @returns {string} stringified item
|
||||
*/
|
||||
item => JSON.stringify(item))}`);
|
||||
}
|
||||
@@ -589,11 +584,11 @@ class ValidationError extends Error {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Schema=} schemaPart
|
||||
* @param {(boolean | Array<string>)=} additionalPath
|
||||
* @param {boolean=} needDot
|
||||
* @param {boolean=} logic
|
||||
* @returns {string}
|
||||
* @param {Schema=} schemaPart schema part
|
||||
* @param {(boolean | Array<string>)=} additionalPath additional path
|
||||
* @param {boolean=} needDot true when need dot
|
||||
* @param {boolean=} logic logic
|
||||
* @returns {string} schema part text
|
||||
*/
|
||||
getSchemaPartText(schemaPart, additionalPath, needDot = false, logic = true) {
|
||||
if (!schemaPart) {
|
||||
@@ -604,7 +599,6 @@ class ValidationError extends Error {
|
||||
/** @type {Schema | undefined} */
|
||||
const inner = schemaPart[(/** @type {keyof Schema} */additionalPath[i])];
|
||||
if (inner) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
schemaPart = inner;
|
||||
} else {
|
||||
break;
|
||||
@@ -612,7 +606,6 @@ class ValidationError extends Error {
|
||||
}
|
||||
}
|
||||
while (schemaPart.$ref) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
schemaPart = this.getSchemaPart(schemaPart.$ref);
|
||||
}
|
||||
let schemaText = `${this.formatSchema(schemaPart, logic)}${needDot ? "." : ""}`;
|
||||
@@ -626,15 +619,14 @@ class ValidationError extends Error {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Schema=} schemaPart
|
||||
* @returns {string}
|
||||
* @param {Schema=} schemaPart schema part
|
||||
* @returns {string} schema part description
|
||||
*/
|
||||
getSchemaPartDescription(schemaPart) {
|
||||
if (!schemaPart) {
|
||||
return "";
|
||||
}
|
||||
while (schemaPart.$ref) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
schemaPart = this.getSchemaPart(schemaPart.$ref);
|
||||
}
|
||||
let schemaText = "";
|
||||
@@ -648,8 +640,8 @@ class ValidationError extends Error {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {SchemaUtilErrorObject} error
|
||||
* @returns {string}
|
||||
* @param {SchemaUtilErrorObject} error error object
|
||||
* @returns {string} formatted error object
|
||||
*/
|
||||
formatValidationError(error) {
|
||||
const {
|
||||
@@ -875,7 +867,9 @@ class ValidationError extends Error {
|
||||
const {
|
||||
i
|
||||
} = params;
|
||||
return `${instancePath} should not contain the item '${/** @type {{ data: Array<any> }} **/
|
||||
return `${instancePath} should not contain the item '${
|
||||
// eslint-disable-next-line jsdoc/no-restricted-syntax
|
||||
/** @type {{ data: Array<any> }} * */
|
||||
error.data[i]}' twice${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`;
|
||||
}
|
||||
case "additionalItems":
|
||||
@@ -931,8 +925,8 @@ class ValidationError extends Error {
|
||||
} = params;
|
||||
const dependencies = deps.split(",").map(
|
||||
/**
|
||||
* @param {string} dep
|
||||
* @returns {string}
|
||||
* @param {string} dep dependency
|
||||
* @returns {string} normalized dependency
|
||||
*/
|
||||
dep => `'${dep.trim()}'`).join(", ");
|
||||
return `${instancePath} should have properties ${dependencies} when property '${property}' is present${getSchemaNonTypes(parentSchema)}.${this.getSchemaPartDescription(parentSchema)}`;
|
||||
@@ -991,11 +985,15 @@ class ValidationError extends Error {
|
||||
if (children && children.length > 0) {
|
||||
if (error.schema.length === 1) {
|
||||
const lastChild = children[children.length - 1];
|
||||
const remainingChildren = children.slice(0, children.length - 1);
|
||||
return this.formatValidationError(Object.assign({}, lastChild, {
|
||||
const remainingChildren = children.slice(0, -1);
|
||||
return this.formatValidationError({
|
||||
...lastChild,
|
||||
children: remainingChildren,
|
||||
parentSchema: Object.assign({}, parentSchema, lastChild.parentSchema)
|
||||
}));
|
||||
parentSchema: {
|
||||
...parentSchema,
|
||||
...lastChild.parentSchema
|
||||
}
|
||||
});
|
||||
}
|
||||
let filteredChildren = filterChildren(children);
|
||||
if (filteredChildren.length === 1) {
|
||||
@@ -1004,8 +1002,8 @@ class ValidationError extends Error {
|
||||
filteredChildren = groupChildrenByFirstChild(filteredChildren);
|
||||
return `${instancePath} should be one of these:\n${this.getSchemaPartText(parentSchema)}\nDetails:\n${filteredChildren.map(
|
||||
/**
|
||||
* @param {SchemaUtilErrorObject} nestedError
|
||||
* @returns {string}
|
||||
* @param {SchemaUtilErrorObject} nestedError nested error
|
||||
* @returns {string} formatted errors
|
||||
*/
|
||||
nestedError => ` * ${indent(this.formatValidationError(nestedError), " ")}`).join("\n")}`;
|
||||
}
|
||||
@@ -1047,8 +1045,8 @@ class ValidationError extends Error {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Array<SchemaUtilErrorObject>} errors
|
||||
* @returns {string}
|
||||
* @param {Array<SchemaUtilErrorObject>} errors errors
|
||||
* @returns {string} formatted errors
|
||||
*/
|
||||
formatValidationErrors(errors) {
|
||||
return errors.map(error => {
|
||||
|
||||
1
node_modules/webpack-dev-server/node_modules/schema-utils/dist/index.js
generated
vendored
Executable file → Normal file
1
node_modules/webpack-dev-server/node_modules/schema-utils/dist/index.js
generated
vendored
Executable file → Normal file
@@ -5,6 +5,7 @@
|
||||
/** @typedef {import("./validate").JSONSchema6} JSONSchema6 */
|
||||
/** @typedef {import("./validate").JSONSchema7} JSONSchema7 */
|
||||
/** @typedef {import("./validate").ExtendedSchema} ExtendedSchema */
|
||||
/** @typedef {import("./validate").ValidationErrorConfiguration} ValidationErrorConfiguration */
|
||||
|
||||
const {
|
||||
validate,
|
||||
|
||||
32
node_modules/webpack-dev-server/node_modules/schema-utils/dist/keywords/absolutePath.js
generated
vendored
Executable file → Normal file
32
node_modules/webpack-dev-server/node_modules/schema-utils/dist/keywords/absolutePath.js
generated
vendored
Executable file → Normal file
@@ -10,18 +10,15 @@ exports.default = void 0;
|
||||
/** @typedef {import("../validate").SchemaUtilErrorObject} SchemaUtilErrorObject */
|
||||
|
||||
/**
|
||||
* @param {string} message
|
||||
* @param {object} schema
|
||||
* @param {string} data
|
||||
* @returns {SchemaUtilErrorObject}
|
||||
* @param {string} message message
|
||||
* @param {object} schema schema
|
||||
* @param {string} data data
|
||||
* @returns {SchemaUtilErrorObject} error object
|
||||
*/
|
||||
function errorMessage(message, schema, data) {
|
||||
return {
|
||||
// @ts-ignore
|
||||
// eslint-disable-next-line no-undefined
|
||||
dataPath: undefined,
|
||||
// @ts-ignore
|
||||
// eslint-disable-next-line no-undefined
|
||||
// @ts-expect-error
|
||||
schemaPath: undefined,
|
||||
keyword: "absolutePath",
|
||||
params: {
|
||||
@@ -33,10 +30,10 @@ function errorMessage(message, schema, data) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {boolean} shouldBeAbsolute
|
||||
* @param {object} schema
|
||||
* @param {string} data
|
||||
* @returns {SchemaUtilErrorObject}
|
||||
* @param {boolean} shouldBeAbsolute true when should be absolute path, otherwise false
|
||||
* @param {object} schema schema
|
||||
* @param {string} data data
|
||||
* @returns {SchemaUtilErrorObject} error object
|
||||
*/
|
||||
function getErrorFor(shouldBeAbsolute, schema, data) {
|
||||
const message = shouldBeAbsolute ? `The provided value ${JSON.stringify(data)} is not an absolute path!` : `A relative path is expected. However, the provided value ${JSON.stringify(data)} is an absolute path!`;
|
||||
@@ -44,9 +41,8 @@ function getErrorFor(shouldBeAbsolute, schema, data) {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {Ajv} ajv
|
||||
* @returns {Ajv}
|
||||
* @param {Ajv} ajv ajv
|
||||
* @returns {Ajv} configured ajv
|
||||
*/
|
||||
function addAbsolutePathKeyword(ajv) {
|
||||
ajv.addKeyword({
|
||||
@@ -54,9 +50,9 @@ function addAbsolutePathKeyword(ajv) {
|
||||
type: "string",
|
||||
errors: true,
|
||||
/**
|
||||
* @param {boolean} schema
|
||||
* @param {AnySchemaObject} parentSchema
|
||||
* @returns {SchemaValidateFunction}
|
||||
* @param {boolean} schema schema
|
||||
* @param {AnySchemaObject} parentSchema parent schema
|
||||
* @returns {SchemaValidateFunction} validate function
|
||||
*/
|
||||
compile(schema, parentSchema) {
|
||||
/** @type {SchemaValidateFunction} */
|
||||
|
||||
43
node_modules/webpack-dev-server/node_modules/schema-utils/dist/keywords/limit.js
generated
vendored
Executable file → Normal file
43
node_modules/webpack-dev-server/node_modules/schema-utils/dist/keywords/limit.js
generated
vendored
Executable file → Normal file
@@ -10,11 +10,10 @@ exports.default = void 0;
|
||||
/** @typedef {import("ajv").KeywordErrorDefinition} KeywordErrorDefinition */
|
||||
|
||||
/**
|
||||
* @param {Ajv} ajv
|
||||
* @returns {Ajv}
|
||||
* @param {Ajv} ajv ajv
|
||||
* @returns {Ajv} ajv with limit keyword
|
||||
*/
|
||||
function addLimitKeyword(ajv) {
|
||||
// eslint-disable-next-line global-require
|
||||
const {
|
||||
_,
|
||||
str,
|
||||
@@ -24,34 +23,34 @@ function addLimitKeyword(ajv) {
|
||||
} = require("ajv");
|
||||
|
||||
/**
|
||||
* @param {Code | Name} x
|
||||
* @returns {Code | Name}
|
||||
* @param {Code | Name} nameOrCode name or code
|
||||
* @returns {Code | Name} name or code
|
||||
*/
|
||||
function par(x) {
|
||||
return x instanceof Name ? x : _`(${x})`;
|
||||
function par(nameOrCode) {
|
||||
return nameOrCode instanceof Name ? nameOrCode : _`(${nameOrCode})`;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Code} op
|
||||
* @returns {function(Code, Code): Code}
|
||||
* @param {Code} op op
|
||||
* @returns {(xValue: Code, yValue: Code) => Code} code
|
||||
*/
|
||||
function mappend(op) {
|
||||
return (x, y) => x === nil ? y : y === nil ? x : _`${par(x)} ${op} ${par(y)}`;
|
||||
return (xValue, yValue) => xValue === nil ? yValue : yValue === nil ? xValue : _`${par(xValue)} ${op} ${par(yValue)}`;
|
||||
}
|
||||
const orCode = mappend(_`||`);
|
||||
|
||||
// boolean OR (||) expression with the passed arguments
|
||||
/**
|
||||
* @param {...Code} args
|
||||
* @returns {Code}
|
||||
* @param {...Code} args args
|
||||
* @returns {Code} code
|
||||
*/
|
||||
function or(...args) {
|
||||
return args.reduce(orCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string | number} key
|
||||
* @returns {Code}
|
||||
* @param {string | number} key key
|
||||
* @returns {Code} property
|
||||
*/
|
||||
function getProperty(key) {
|
||||
return _`[${key}]`;
|
||||
@@ -110,16 +109,22 @@ function addLimitKeyword(ajv) {
|
||||
self
|
||||
} = it;
|
||||
if (!opts.validateFormats) return;
|
||||
const fCxt = new KeywordCxt(it, /** @type {any} */
|
||||
const fCxt = new KeywordCxt(it,
|
||||
// eslint-disable-next-line jsdoc/no-restricted-syntax
|
||||
/** @type {any} */
|
||||
self.RULES.all.format.definition, "format");
|
||||
|
||||
/**
|
||||
* @param {Name} fmt
|
||||
* @returns {Code}
|
||||
* @param {Name} fmt fmt
|
||||
* @returns {Code} code
|
||||
*/
|
||||
function compareCode(fmt) {
|
||||
return _`${fmt}.compare(${data}, ${schemaCode}) ${keywords[(/** @type {keyof typeof keywords} */keyword)].fail} 0`;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {void}
|
||||
*/
|
||||
function validate$DataFormat() {
|
||||
const fmts = gen.scopeValue("formats", {
|
||||
ref: self.formats,
|
||||
@@ -128,6 +133,10 @@ function addLimitKeyword(ajv) {
|
||||
const fmt = gen.const("fmt", _`${fmts}[${fCxt.schemaCode}]`);
|
||||
cxt.fail$data(or(_`typeof ${fmt} != "object"`, _`${fmt} instanceof RegExp`, _`typeof ${fmt}.compare != "function"`, compareCode(fmt)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {void}
|
||||
*/
|
||||
function validateFormat() {
|
||||
const format = fCxt.schema;
|
||||
const fmtDef = self.formats[format];
|
||||
|
||||
6
node_modules/webpack-dev-server/node_modules/schema-utils/dist/keywords/undefinedAsNull.js
generated
vendored
Executable file → Normal file
6
node_modules/webpack-dev-server/node_modules/schema-utils/dist/keywords/undefinedAsNull.js
generated
vendored
Executable file → Normal file
@@ -10,9 +10,8 @@ exports.default = void 0;
|
||||
/** @typedef {import("ajv").ValidateFunction} ValidateFunction */
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {Ajv} ajv
|
||||
* @returns {Ajv}
|
||||
* @param {Ajv} ajv ajv
|
||||
* @returns {Ajv} configured ajv
|
||||
*/
|
||||
function addUndefinedAsNullKeyword(ajv) {
|
||||
ajv.addKeyword({
|
||||
@@ -24,7 +23,6 @@ function addUndefinedAsNullKeyword(ajv) {
|
||||
if (kwVal && dataCxt && metadata && typeof metadata.enum !== "undefined") {
|
||||
const idx = dataCxt.parentDataProperty;
|
||||
if (typeof dataCxt.parentData[idx] === "undefined") {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
dataCxt.parentData[dataCxt.parentDataProperty] = null;
|
||||
}
|
||||
}
|
||||
|
||||
30
node_modules/webpack-dev-server/node_modules/schema-utils/dist/util/Range.js
generated
vendored
Executable file → Normal file
30
node_modules/webpack-dev-server/node_modules/schema-utils/dist/util/Range.js
generated
vendored
Executable file → Normal file
@@ -12,9 +12,9 @@
|
||||
|
||||
class Range {
|
||||
/**
|
||||
* @param {"left" | "right"} side
|
||||
* @param {boolean} exclusive
|
||||
* @returns {">" | ">=" | "<" | "<="}
|
||||
* @param {"left" | "right"} side side
|
||||
* @param {boolean} exclusive exclusive
|
||||
* @returns {">" | ">=" | "<" | "<="} operator
|
||||
*/
|
||||
static getOperator(side, exclusive) {
|
||||
if (side === "left") {
|
||||
@@ -24,10 +24,10 @@ class Range {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} value
|
||||
* @param {number} value value
|
||||
* @param {boolean} logic is not logic applied
|
||||
* @param {boolean} exclusive is range exclusive
|
||||
* @returns {string}
|
||||
* @returns {string} formatted right
|
||||
*/
|
||||
static formatRight(value, logic, exclusive) {
|
||||
if (logic === false) {
|
||||
@@ -37,10 +37,10 @@ class Range {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} value
|
||||
* @param {number} value value
|
||||
* @param {boolean} logic is not logic applied
|
||||
* @param {boolean} exclusive is range exclusive
|
||||
* @returns {string}
|
||||
* @returns {string} formatted left
|
||||
*/
|
||||
static formatLeft(value, logic, exclusive) {
|
||||
if (logic === false) {
|
||||
@@ -55,7 +55,7 @@ class Range {
|
||||
* @param {boolean} startExclusive is range exclusive from left side
|
||||
* @param {boolean} endExclusive is range exclusive from right side
|
||||
* @param {boolean} logic is not logic applied
|
||||
* @returns {string}
|
||||
* @returns {string} formatted range
|
||||
*/
|
||||
static formatRange(start, end, startExclusive, endExclusive, logic) {
|
||||
let result = "should be";
|
||||
@@ -66,9 +66,9 @@ class Range {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Array<RangeValue>} values
|
||||
* @param {Array<RangeValue>} values values
|
||||
* @param {boolean} logic is not logic applied
|
||||
* @return {RangeValue} computed value and it's exclusive flag
|
||||
* @returns {RangeValue} computed value and it's exclusive flag
|
||||
*/
|
||||
static getRangeValue(values, logic) {
|
||||
let minMax = logic ? Infinity : -Infinity;
|
||||
@@ -95,16 +95,16 @@ class Range {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} value
|
||||
* @param {boolean=} exclusive
|
||||
* @param {number} value value
|
||||
* @param {boolean=} exclusive true when exclusive, otherwise false
|
||||
*/
|
||||
left(value, exclusive = false) {
|
||||
this._left.push([value, exclusive]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} value
|
||||
* @param {boolean=} exclusive
|
||||
* @param {number} value value
|
||||
* @param {boolean=} exclusive true when exclusive, otherwise false
|
||||
*/
|
||||
right(value, exclusive = false) {
|
||||
this._right.push([value, exclusive]);
|
||||
@@ -112,7 +112,7 @@ class Range {
|
||||
|
||||
/**
|
||||
* @param {boolean} logic is not logic applied
|
||||
* @return {string} "smart" range string representation
|
||||
* @returns {string} "smart" range string representation
|
||||
*/
|
||||
format(logic = true) {
|
||||
const [start, leftExclusive] = Range.getRangeValue(this._left, logic);
|
||||
|
||||
14
node_modules/webpack-dev-server/node_modules/schema-utils/dist/util/hints.js
generated
vendored
Executable file → Normal file
14
node_modules/webpack-dev-server/node_modules/schema-utils/dist/util/hints.js
generated
vendored
Executable file → Normal file
@@ -5,9 +5,9 @@ const Range = require("./Range");
|
||||
/** @typedef {import("../validate").Schema} Schema */
|
||||
|
||||
/**
|
||||
* @param {Schema} schema
|
||||
* @param {boolean} logic
|
||||
* @return {string[]}
|
||||
* @param {Schema} schema schema
|
||||
* @param {boolean} logic logic
|
||||
* @returns {string[]} array of hints
|
||||
*/
|
||||
module.exports.stringHints = function stringHints(schema, logic) {
|
||||
const hints = [];
|
||||
@@ -51,13 +51,13 @@ module.exports.stringHints = function stringHints(schema, logic) {
|
||||
if (currentSchema.formatMaximum) {
|
||||
hints.push(`should be ${currentSchema.formatExclusiveMaximum ? "<" : "<="} ${JSON.stringify(currentSchema.formatMaximum)}`);
|
||||
}
|
||||
return [type].concat(hints);
|
||||
return [type, ...hints];
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Schema} schema
|
||||
* @param {boolean} logic
|
||||
* @return {string[]}
|
||||
* @param {Schema} schema schema
|
||||
* @param {boolean} logic logic
|
||||
* @returns {string[]} array of hints
|
||||
*/
|
||||
module.exports.numberHints = function numberHints(schema, logic) {
|
||||
const hints = [schema.type === "integer" ? "integer" : "number"];
|
||||
|
||||
13
node_modules/webpack-dev-server/node_modules/schema-utils/dist/util/memorize.js
generated
vendored
Executable file → Normal file
13
node_modules/webpack-dev-server/node_modules/schema-utils/dist/util/memorize.js
generated
vendored
Executable file → Normal file
@@ -6,8 +6,13 @@ Object.defineProperty(exports, "__esModule", {
|
||||
exports.default = void 0;
|
||||
/**
|
||||
* @template T
|
||||
* @param fn {(function(): any) | undefined}
|
||||
* @returns {function(): T}
|
||||
* @typedef {() => T} FunctionReturning
|
||||
*/
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @param {FunctionReturning<T>} fn memorized function
|
||||
* @returns {FunctionReturning<T>} new function
|
||||
*/
|
||||
const memoize = fn => {
|
||||
let cache = false;
|
||||
@@ -17,11 +22,11 @@ const memoize = fn => {
|
||||
if (cache) {
|
||||
return result;
|
||||
}
|
||||
result = /** @type {function(): any} */fn();
|
||||
result = fn();
|
||||
cache = true;
|
||||
// Allow to clean up memory for fn
|
||||
// and all dependent resources
|
||||
// eslint-disable-next-line no-undefined, no-param-reassign
|
||||
/** @type {FunctionReturning<T> | undefined} */
|
||||
fn = undefined;
|
||||
return result;
|
||||
};
|
||||
|
||||
150
node_modules/webpack-dev-server/node_modules/schema-utils/dist/validate.js
generated
vendored
Executable file → Normal file
150
node_modules/webpack-dev-server/node_modules/schema-utils/dist/validate.js
generated
vendored
Executable file → Normal file
@@ -18,11 +18,9 @@ var _memorize = _interopRequireDefault(require("./util/memorize"));
|
||||
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
||||
const getAjv = (0, _memorize.default)(() => {
|
||||
// Use CommonJS require for ajv libs so TypeScript consumers aren't locked into esModuleInterop (see #110).
|
||||
// eslint-disable-next-line global-require
|
||||
|
||||
const Ajv = require("ajv").default;
|
||||
// eslint-disable-next-line global-require
|
||||
const ajvKeywords = require("ajv-keywords").default;
|
||||
// eslint-disable-next-line global-require
|
||||
const addFormats = require("ajv-formats").default;
|
||||
|
||||
/**
|
||||
@@ -41,16 +39,12 @@ const getAjv = (0, _memorize.default)(() => {
|
||||
});
|
||||
|
||||
// Custom keywords
|
||||
// eslint-disable-next-line global-require
|
||||
|
||||
const addAbsolutePathKeyword = require("./keywords/absolutePath").default;
|
||||
addAbsolutePathKeyword(ajv);
|
||||
|
||||
// eslint-disable-next-line global-require
|
||||
const addLimitKeyword = require("./keywords/limit").default;
|
||||
addLimitKeyword(ajv);
|
||||
const addUndefinedAsNullKeyword =
|
||||
// eslint-disable-next-line global-require
|
||||
require("./keywords/undefinedAsNull").default;
|
||||
const addUndefinedAsNullKeyword = require("./keywords/undefinedAsNull").default;
|
||||
addUndefinedAsNullKeyword(ajv);
|
||||
return ajv;
|
||||
});
|
||||
@@ -61,13 +55,13 @@ const getAjv = (0, _memorize.default)(() => {
|
||||
/** @typedef {import("ajv").ErrorObject} ErrorObject */
|
||||
|
||||
/**
|
||||
* @typedef {Object} ExtendedSchema
|
||||
* @property {(string | number)=} formatMinimum
|
||||
* @property {(string | number)=} formatMaximum
|
||||
* @property {(string | boolean)=} formatExclusiveMinimum
|
||||
* @property {(string | boolean)=} formatExclusiveMaximum
|
||||
* @property {string=} link
|
||||
* @property {boolean=} undefinedAsNull
|
||||
* @typedef {object} ExtendedSchema
|
||||
* @property {(string | number)=} formatMinimum format minimum
|
||||
* @property {(string | number)=} formatMaximum format maximum
|
||||
* @property {(string | boolean)=} formatExclusiveMinimum format exclusive minimum
|
||||
* @property {(string | boolean)=} formatExclusiveMaximum format exclusive maximum
|
||||
* @property {string=} link link
|
||||
* @property {boolean=} undefinedAsNull undefined will be resolved as null
|
||||
*/
|
||||
|
||||
// TODO remove me in the next major release
|
||||
@@ -85,22 +79,21 @@ const getAjv = (0, _memorize.default)(() => {
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ValidationErrorConfiguration
|
||||
* @property {string=} name
|
||||
* @property {string=} baseDataPath
|
||||
* @property {PostFormatter=} postFormatter
|
||||
* @typedef {object} ValidationErrorConfiguration
|
||||
* @property {string=} name name
|
||||
* @property {string=} baseDataPath base data path
|
||||
* @property {PostFormatter=} postFormatter post formatter
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {SchemaUtilErrorObject} error
|
||||
* @param {number} idx
|
||||
* @returns {SchemaUtilErrorObject}
|
||||
* @param {SchemaUtilErrorObject} error error
|
||||
* @param {number} idx idx
|
||||
* @returns {SchemaUtilErrorObject} error object with idx
|
||||
*/
|
||||
function applyPrefix(error, idx) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
error.instancePath = `[${idx}]${error.instancePath}`;
|
||||
if (error.children) {
|
||||
error.children.forEach(err => applyPrefix(err, idx));
|
||||
for (const err of error.children) applyPrefix(err, idx);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
@@ -110,6 +103,9 @@ let skipValidation = false;
|
||||
// so we want to disable it globally, `process.env` doesn't supported by browsers, so we have the local `skipValidation` variables
|
||||
|
||||
// Enable validation
|
||||
/**
|
||||
* @returns {void}
|
||||
*/
|
||||
function enableValidation() {
|
||||
skipValidation = false;
|
||||
|
||||
@@ -120,6 +116,9 @@ function enableValidation() {
|
||||
}
|
||||
|
||||
// Disable validation
|
||||
/**
|
||||
* @returns {void}
|
||||
*/
|
||||
function disableValidation() {
|
||||
skipValidation = true;
|
||||
if (process && process.env) {
|
||||
@@ -128,6 +127,9 @@ function disableValidation() {
|
||||
}
|
||||
|
||||
// Check if we need to confirm
|
||||
/**
|
||||
* @returns {boolean} true when need validate, otherwise false
|
||||
*/
|
||||
function needValidate() {
|
||||
if (skipValidation) {
|
||||
return false;
|
||||
@@ -145,9 +147,54 @@ function needValidate() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Schema} schema
|
||||
* @param {Array<object> | object} options
|
||||
* @param {ValidationErrorConfiguration=} configuration
|
||||
* @param {Array<ErrorObject>} errors array of error objects
|
||||
* @returns {Array<SchemaUtilErrorObject>} filtered array of objects
|
||||
*/
|
||||
function filterErrors(errors) {
|
||||
/** @type {Array<SchemaUtilErrorObject>} */
|
||||
let newErrors = [];
|
||||
for (const error of (/** @type {Array<SchemaUtilErrorObject>} */errors)) {
|
||||
const {
|
||||
instancePath
|
||||
} = error;
|
||||
/** @type {Array<SchemaUtilErrorObject>} */
|
||||
let children = [];
|
||||
newErrors = newErrors.filter(oldError => {
|
||||
if (oldError.instancePath.includes(instancePath)) {
|
||||
if (oldError.children) {
|
||||
children = [...children, ...oldError.children];
|
||||
}
|
||||
oldError.children = undefined;
|
||||
children.push(oldError);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
if (children.length) {
|
||||
error.children = children;
|
||||
}
|
||||
newErrors.push(error);
|
||||
}
|
||||
return newErrors;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Schema} schema schema
|
||||
* @param {Array<object> | object} options options
|
||||
* @returns {Array<SchemaUtilErrorObject>} array of error objects
|
||||
*/
|
||||
function validateObject(schema, options) {
|
||||
// Not need to cache, because `ajv@8` has built-in cache
|
||||
const compiledSchema = getAjv().compile(schema);
|
||||
const valid = compiledSchema(options);
|
||||
if (valid) return [];
|
||||
return compiledSchema.errors ? filterErrors(compiledSchema.errors) : [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Schema} schema schema
|
||||
* @param {Array<object> | object} options options
|
||||
* @param {ValidationErrorConfiguration=} configuration configuration
|
||||
* @returns {void}
|
||||
*/
|
||||
function validate(schema, options, configuration) {
|
||||
@@ -165,51 +212,4 @@ function validate(schema, options, configuration) {
|
||||
if (errors.length > 0) {
|
||||
throw new _ValidationError.default(errors, schema, configuration);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Schema} schema
|
||||
* @param {Array<object> | object} options
|
||||
* @returns {Array<SchemaUtilErrorObject>}
|
||||
*/
|
||||
function validateObject(schema, options) {
|
||||
// Not need to cache, because `ajv@8` has built-in cache
|
||||
const compiledSchema = getAjv().compile(schema);
|
||||
const valid = compiledSchema(options);
|
||||
if (valid) return [];
|
||||
return compiledSchema.errors ? filterErrors(compiledSchema.errors) : [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Array<ErrorObject>} errors
|
||||
* @returns {Array<SchemaUtilErrorObject>}
|
||||
*/
|
||||
function filterErrors(errors) {
|
||||
/** @type {Array<SchemaUtilErrorObject>} */
|
||||
let newErrors = [];
|
||||
for (const error of (/** @type {Array<SchemaUtilErrorObject>} */errors)) {
|
||||
const {
|
||||
instancePath
|
||||
} = error;
|
||||
/** @type {Array<SchemaUtilErrorObject>} */
|
||||
let children = [];
|
||||
newErrors = newErrors.filter(oldError => {
|
||||
if (oldError.instancePath.includes(instancePath)) {
|
||||
if (oldError.children) {
|
||||
children = children.concat(oldError.children.slice(0));
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-undefined, no-param-reassign
|
||||
oldError.children = undefined;
|
||||
children.push(oldError);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
if (children.length) {
|
||||
error.children = children;
|
||||
}
|
||||
newErrors.push(error);
|
||||
}
|
||||
return newErrors;
|
||||
}
|
||||
42
node_modules/webpack-dev-server/node_modules/schema-utils/package.json
generated
vendored
42
node_modules/webpack-dev-server/node_modules/schema-utils/package.json
generated
vendored
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "schema-utils",
|
||||
"version": "4.3.2",
|
||||
"version": "4.3.3",
|
||||
"description": "webpack Validation Utils",
|
||||
"license": "MIT",
|
||||
"repository": "webpack/schema-utils",
|
||||
@@ -21,18 +21,18 @@
|
||||
"clean": "del-cli dist declarations",
|
||||
"prebuild": "npm run clean",
|
||||
"build:types": "tsc --declaration --emitDeclarationOnly --outDir declarations && prettier \"declarations/**/*.ts\" --write",
|
||||
"build:code": "cross-env NODE_ENV=production babel src -d dist --copy-files",
|
||||
"build:code": "babel src -d dist --copy-files",
|
||||
"build": "npm-run-all -p \"build:**\"",
|
||||
"commitlint": "commitlint --from=master",
|
||||
"commitlint": "commitlint --from=main",
|
||||
"security": "npm audit --production",
|
||||
"fmt:check": "prettier \"{**/*,*}.{js,json,md,yml,css,ts}\" --list-different",
|
||||
"lint:js": "eslint --cache .",
|
||||
"lint:code": "eslint --cache .",
|
||||
"lint:types": "tsc --pretty --noEmit",
|
||||
"lint": "npm-run-all lint:js lint:types fmt:check",
|
||||
"lint": "npm-run-all lint:code lint:types fmt:check",
|
||||
"fmt": "npm run fmt:check -- --write",
|
||||
"fix:js": "npm run lint:js -- --fix",
|
||||
"fix:js": "npm run lint:code -- --fix",
|
||||
"fix": "npm-run-all fix:js fmt",
|
||||
"test:only": "cross-env NODE_ENV=test jest",
|
||||
"test:only": "jest",
|
||||
"test:watch": "npm run test:only -- --watch",
|
||||
"test:coverage": "npm run test:only -- --collectCoverageFrom=\"src/**/*.js\" --coverage",
|
||||
"pretest": "npm run lint",
|
||||
@@ -51,27 +51,37 @@
|
||||
"ajv-keywords": "^5.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.28.0",
|
||||
"@eslint/markdown": "^6.5.0",
|
||||
"@babel/cli": "^7.17.0",
|
||||
"@babel/core": "^7.17.0",
|
||||
"@babel/preset-env": "^7.16.11",
|
||||
"@commitlint/cli": "^17.6.1",
|
||||
"@commitlint/config-conventional": "^16.0.0",
|
||||
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
|
||||
"@types/node": "^22.15.19",
|
||||
"@stylistic/eslint-plugin": "^4.4.1",
|
||||
"babel-jest": "^27.4.6",
|
||||
"cross-env": "^7.0.3",
|
||||
"del": "^6.0.0",
|
||||
"del-cli": "^4.0.1",
|
||||
"eslint": "^8.8.0",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-plugin-import": "^2.25.4",
|
||||
"globals": "^16.2.0",
|
||||
"eslint": "^9.28.0",
|
||||
"eslint-config-webpack": "^4.0.2",
|
||||
"eslint-config-prettier": "^10.1.5",
|
||||
"eslint-plugin-import": "^2.31.0",
|
||||
"eslint-plugin-jest": "^28.12.0",
|
||||
"eslint-plugin-jsdoc": "^50.7.1",
|
||||
"eslint-plugin-n": "^17.19.0",
|
||||
"eslint-plugin-prettier": "^5.4.1",
|
||||
"eslint-plugin-unicorn": "^59.0.1",
|
||||
"husky": "^7.0.4",
|
||||
"jest": "^27.4.7",
|
||||
"lint-staged": "^13.2.1",
|
||||
"lint-staged": "^16.0.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^2.5.1",
|
||||
"prettier": "^3.5.3",
|
||||
"prettier-2": "npm:prettier@^2",
|
||||
"standard-version": "^9.3.2",
|
||||
"typescript": "^4.9.5",
|
||||
"webpack": "^5.97.1"
|
||||
"typescript": "^5.8.3",
|
||||
"webpack": "^5.99.8"
|
||||
},
|
||||
"keywords": [
|
||||
"webpack"
|
||||
|
||||
Reference in New Issue
Block a user