mirror of
https://github.com/nodejs/node.git
synced 2026-11-29 14:27:57 -05:00
tools: update ESLint to 7.20.0
Update ESLint to 7.20.0 PR-URL: https://github.com/nodejs/node/pull/37339 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
1 parent
c160d88c9e
commit
b2b64113b1
60 files changed
+6408
-1026
No files matched your search
+3
-3
@@ -280,10 +280,10 @@ The following companies, organizations, and individuals support ESLint's ongoing
|
||||
<!-- NOTE: This section is autogenerated. Do not manually edit.-->
|
||||
<!--sponsorsstart-->
|
||||
<h3>Platinum Sponsors</h3>
|
||||
<p><a href="https://automattic.com"><img src="https://images.opencollective.com/photomatt/ff91f0b/logo.png" alt="Automattic" height="undefined"></a></p><h3>Gold Sponsors</h3>
|
||||
<p><a href="https://google.com/chrome"><img src="https://images.opencollective.com/chrome/dc55bd4/logo.png" alt="Chrome's Web Framework & Tools Performance Fund" height="96"></a> <a href="https://www.shopify.com"><img src="https://images.opencollective.com/shopify/e780cd4/logo.png" alt="Shopify" height="96"></a> <a href="https://www.salesforce.com"><img src="https://images.opencollective.com/salesforce/ca8f997/logo.png" alt="Salesforce" height="96"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="96"></a> <a href="https://aka.ms/microsoftfossfund"><img src="https://avatars.githubusercontent.com/u/67931232?u=7fddc652a464d7151b97e8f108392af7d54fa3e8&v=4" alt="Microsoft FOSS Fund Sponsorships" height="96"></a></p><h3>Silver Sponsors</h3>
|
||||
<p><a href="https://automattic.com"><img src="https://images.opencollective.com/photomatt/d0ef3e1/logo.png" alt="Automattic" height="undefined"></a></p><h3>Gold Sponsors</h3>
|
||||
<p><a href="https://nx.dev"><img src="https://images.opencollective.com/nx/0efbe42/logo.png" alt="Nx (by Nrwl)" height="96"></a> <a href="https://google.com/chrome"><img src="https://images.opencollective.com/chrome/dc55bd4/logo.png" alt="Chrome's Web Framework & Tools Performance Fund" height="96"></a> <a href="https://www.shopify.com"><img src="https://images.opencollective.com/shopify/e780cd4/logo.png" alt="Shopify" height="96"></a> <a href="https://www.salesforce.com"><img src="https://images.opencollective.com/salesforce/ca8f997/logo.png" alt="Salesforce" height="96"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="96"></a> <a href="https://aka.ms/microsoftfossfund"><img src="https://avatars.githubusercontent.com/u/67931232?u=7fddc652a464d7151b97e8f108392af7d54fa3e8&v=4" alt="Microsoft FOSS Fund Sponsorships" height="96"></a></p><h3>Silver Sponsors</h3>
|
||||
<p><a href="https://retool.com/"><img src="https://images.opencollective.com/retool/98ea68e/logo.png" alt="Retool" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/5c4fa84/logo.png" alt="Liftoff" height="64"></a> <a href="https://www.ampproject.org/"><img src="https://images.opencollective.com/amp/c8a3b25/logo.png" alt="AMP Project" height="64"></a></p><h3>Bronze Sponsors</h3>
|
||||
<p><a href="https://streamat.se"><img src="https://images.opencollective.com/streamat/46890db/logo.png" alt="Streamat" height="32"></a> <a href="https://thestandarddaily.com/"><img src="https://images.opencollective.com/eric-watson/db4e598/avatar.png" alt="The Standard Daily" height="32"></a> <a href="https://writersperhour.com"><img src="https://images.opencollective.com/writersperhour/5787d4b/logo.png" alt="Writers Per Hour" height="32"></a> <a href="https://www.betacalendars.com/february-calendar.html"><img src="https://images.opencollective.com/betacalendars/9334b33/logo.png" alt="February 2021 calendar" height="32"></a> <a href="https://buy.fineproxy.org/eng/"><img src="https://images.opencollective.com/buy-fineproxy-org/b282e39/logo.png" alt="Buy.Fineproxy.Org" height="32"></a> <a href="https://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" height="32"></a> <a href="null"><img src="https://images.opencollective.com/bugsnag-stability-monitoring/c2cef36/logo.png" alt="Bugsnag Stability Monitoring" height="32"></a> <a href="https://mixpanel.com"><img src="https://images.opencollective.com/mixpanel/cd682f7/logo.png" alt="Mixpanel" height="32"></a> <a href="https://www.vpsserver.com"><img src="https://images.opencollective.com/vpsservercom/logo.png" alt="VPS Server" height="32"></a> <a href="https://icons8.com"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8: free icons, photos, illustrations, and music" height="32"></a> <a href="https://discordapp.com"><img src="https://images.opencollective.com/discordapp/7e3d9a9/logo.png" alt="Discord" height="32"></a> <a href="https://themeisle.com"><img src="https://images.opencollective.com/themeisle/d5592fe/logo.png" alt="ThemeIsle" height="32"></a> <a href="https://www.firesticktricks.com"><img src="https://images.opencollective.com/fire-stick-tricks/b8fbe2c/logo.png" alt="Fire Stick Tricks" height="32"></a></p>
|
||||
<p><a href="https://writersperhour.com"><img src="https://images.opencollective.com/writersperhour/5787d4b/logo.png" alt="Writers Per Hour" height="32"></a> <a href="https://www.betacalendars.com/march-calendar.html"><img src="https://images.opencollective.com/betacalendars/9334b33/logo.png" alt="March 2021 calendar" height="32"></a> <a href="https://buy.fineproxy.org/eng/"><img src="https://images.opencollective.com/buy-fineproxy-org/b282e39/logo.png" alt="Buy.Fineproxy.Org" height="32"></a> <a href="https://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" height="32"></a> <a href="null"><img src="https://images.opencollective.com/bugsnag-stability-monitoring/c2cef36/logo.png" alt="Bugsnag Stability Monitoring" height="32"></a> <a href="https://mixpanel.com"><img src="https://images.opencollective.com/mixpanel/cd682f7/logo.png" alt="Mixpanel" height="32"></a> <a href="https://www.vpsserver.com"><img src="https://images.opencollective.com/vpsservercom/logo.png" alt="VPS Server" height="32"></a> <a href="https://icons8.com"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8: free icons, photos, illustrations, and music" height="32"></a> <a href="https://discordapp.com"><img src="https://images.opencollective.com/discordapp/7e3d9a9/logo.png" alt="Discord" height="32"></a> <a href="https://themeisle.com"><img src="https://images.opencollective.com/themeisle/d5592fe/logo.png" alt="ThemeIsle" height="32"></a> <a href="https://www.firesticktricks.com"><img src="https://images.opencollective.com/fire-stick-tricks/b8fbe2c/logo.png" alt="Fire Stick Tricks" height="32"></a></p>
|
||||
<!--sponsorsend-->
|
||||
|
||||
## <a name="technology-sponsors"></a>Technology Sponsors
|
||||
|
||||
+1
-1
@@ -531,7 +531,7 @@ function directoryExists(resolvedPath) {
|
||||
try {
|
||||
return fs.statSync(resolvedPath).isDirectory();
|
||||
} catch (error) {
|
||||
if (error && error.code === "ENOENT") {
|
||||
if (error && (error.code === "ENOENT" || error.code === "ENOTDIR")) {
|
||||
return false;
|
||||
}
|
||||
throw error;
|
||||
|
||||
+1
-1
@@ -85,7 +85,7 @@ class Registry {
|
||||
* @returns {void}
|
||||
*/
|
||||
populateFromCoreRules() {
|
||||
const rulesConfig = configRule.createCoreRuleConfigs();
|
||||
const rulesConfig = configRule.createCoreRuleConfigs(/* noDeprecated = */ true);
|
||||
|
||||
this.rules = makeRegistryItems(rulesConfig);
|
||||
}
|
||||
|
||||
+3
-1
@@ -942,7 +942,9 @@ function runRules(sourceCode, configuredRules, ruleMapper, parserOptions, parser
|
||||
});
|
||||
|
||||
// only run code path analyzer if the top level node is "Program", skip otherwise
|
||||
const eventGenerator = nodeQueue[0].node.type === "Program" ? new CodePathAnalyzer(new NodeEventGenerator(emitter)) : new NodeEventGenerator(emitter);
|
||||
const eventGenerator = nodeQueue[0].node.type === "Program"
|
||||
? new CodePathAnalyzer(new NodeEventGenerator(emitter, { visitorKeys: sourceCode.visitorKeys, fallback: Traverser.getKeys }))
|
||||
: new NodeEventGenerator(emitter, { visitorKeys: sourceCode.visitorKeys, fallback: Traverser.getKeys });
|
||||
|
||||
nodeQueue.forEach(traversalInfo => {
|
||||
currentNode = traversalInfo.node;
|
||||
|
||||
+4
-2
@@ -208,10 +208,12 @@ class NodeEventGenerator {
|
||||
* An SafeEmitter which is the destination of events. This emitter must already
|
||||
* have registered listeners for all of the events that it needs to listen for.
|
||||
* (See lib/linter/safe-emitter.js for more details on `SafeEmitter`.)
|
||||
* @param {ESQueryOptions} esqueryOptions `esquery` options for traversing custom nodes.
|
||||
* @returns {NodeEventGenerator} new instance
|
||||
*/
|
||||
constructor(emitter) {
|
||||
constructor(emitter, esqueryOptions) {
|
||||
this.emitter = emitter;
|
||||
this.esqueryOptions = esqueryOptions;
|
||||
this.currentAncestry = [];
|
||||
this.enterSelectorsByNodeType = new Map();
|
||||
this.exitSelectorsByNodeType = new Map();
|
||||
@@ -250,7 +252,7 @@ class NodeEventGenerator {
|
||||
* @returns {void}
|
||||
*/
|
||||
applySelector(node, selector) {
|
||||
if (esquery.matches(node, selector.parsedSelector, this.currentAncestry)) {
|
||||
if (esquery.matches(node, selector.parsedSelector, this.currentAncestry, this.esqueryOptions)) {
|
||||
this.emitter.emit(selector.rawSelector, node);
|
||||
}
|
||||
}
|
||||
|
||||
+12
-1
@@ -50,6 +50,10 @@ module.exports = {
|
||||
allowTaggedTemplates: {
|
||||
type: "boolean",
|
||||
default: false
|
||||
},
|
||||
enforceForJSX: {
|
||||
type: "boolean",
|
||||
default: false
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
@@ -65,7 +69,8 @@ module.exports = {
|
||||
const config = context.options[0] || {},
|
||||
allowShortCircuit = config.allowShortCircuit || false,
|
||||
allowTernary = config.allowTernary || false,
|
||||
allowTaggedTemplates = config.allowTaggedTemplates || false;
|
||||
allowTaggedTemplates = config.allowTaggedTemplates || false,
|
||||
enforceForJSX = config.enforceForJSX || false;
|
||||
|
||||
// eslint-disable-next-line jsdoc/require-description
|
||||
/**
|
||||
@@ -140,6 +145,12 @@ module.exports = {
|
||||
},
|
||||
FunctionExpression: alwaysTrue,
|
||||
Identifier: alwaysTrue,
|
||||
JSXElement() {
|
||||
return enforceForJSX;
|
||||
},
|
||||
JSXFragment() {
|
||||
return enforceForJSX;
|
||||
},
|
||||
Literal: alwaysTrue,
|
||||
LogicalExpression(node) {
|
||||
if (allowShortCircuit) {
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
> Syntax highlight JavaScript strings for output in terminals.
|
||||
|
||||
See our website [@babel/highlight](https://babeljs.io/docs/en/next/babel-highlight.html) for more information.
|
||||
See our website [@babel/highlight](https://babeljs.io/docs/en/babel-highlight) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
|
||||
+49
-26
@@ -7,7 +7,7 @@ exports.shouldHighlight = shouldHighlight;
|
||||
exports.getChalk = getChalk;
|
||||
exports.default = highlight;
|
||||
|
||||
var _jsTokens = _interopRequireWildcard(require("js-tokens"));
|
||||
var jsTokensNs = _interopRequireWildcard(require("js-tokens"));
|
||||
|
||||
var _helperValidatorIdentifier = require("@babel/helper-validator-identifier");
|
||||
|
||||
@@ -19,11 +19,13 @@ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
||||
|
||||
const sometimesKeywords = new Set(["as", "async", "from", "get", "of", "set"]);
|
||||
|
||||
function getDefs(chalk) {
|
||||
return {
|
||||
keyword: chalk.cyan,
|
||||
capitalized: chalk.yellow,
|
||||
jsx_tag: chalk.yellow,
|
||||
jsxIdentifier: chalk.yellow,
|
||||
punctuator: chalk.yellow,
|
||||
number: chalk.magenta,
|
||||
string: chalk.green,
|
||||
@@ -34,49 +36,70 @@ function getDefs(chalk) {
|
||||
}
|
||||
|
||||
const NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
|
||||
const JSX_TAG = /^[a-z][\w-]*$/i;
|
||||
const BRACKET = /^[()[\]{}]$/;
|
||||
let tokenize;
|
||||
{
|
||||
const {
|
||||
matchToToken
|
||||
} = jsTokensNs;
|
||||
const JSX_TAG = /^[a-z][\w-]*$/i;
|
||||
|
||||
function getTokenType(match) {
|
||||
const [offset, text] = match.slice(-2);
|
||||
const token = (0, _jsTokens.matchToToken)(match);
|
||||
const getTokenType = function (token, offset, text) {
|
||||
if (token.type === "name") {
|
||||
if ((0, _helperValidatorIdentifier.isKeyword)(token.value) || (0, _helperValidatorIdentifier.isStrictReservedWord)(token.value, true) || sometimesKeywords.has(token.value)) {
|
||||
return "keyword";
|
||||
}
|
||||
|
||||
if (token.type === "name") {
|
||||
if ((0, _helperValidatorIdentifier.isKeyword)(token.value) || (0, _helperValidatorIdentifier.isReservedWord)(token.value)) {
|
||||
return "keyword";
|
||||
if (JSX_TAG.test(token.value) && (text[offset - 1] === "<" || text.substr(offset - 2, 2) == "</")) {
|
||||
return "jsxIdentifier";
|
||||
}
|
||||
|
||||
if (token.value[0] !== token.value[0].toLowerCase()) {
|
||||
return "capitalized";
|
||||
}
|
||||
}
|
||||
|
||||
if (JSX_TAG.test(token.value) && (text[offset - 1] === "<" || text.substr(offset - 2, 2) == "</")) {
|
||||
return "jsx_tag";
|
||||
if (token.type === "punctuator" && BRACKET.test(token.value)) {
|
||||
return "bracket";
|
||||
}
|
||||
|
||||
if (token.value[0] !== token.value[0].toLowerCase()) {
|
||||
return "capitalized";
|
||||
if (token.type === "invalid" && (token.value === "@" || token.value === "#")) {
|
||||
return "punctuator";
|
||||
}
|
||||
}
|
||||
|
||||
if (token.type === "punctuator" && BRACKET.test(token.value)) {
|
||||
return "bracket";
|
||||
}
|
||||
return token.type;
|
||||
};
|
||||
|
||||
if (token.type === "invalid" && (token.value === "@" || token.value === "#")) {
|
||||
return "punctuator";
|
||||
}
|
||||
tokenize = function* (text) {
|
||||
let match;
|
||||
|
||||
return token.type;
|
||||
while (match = jsTokensNs.default.exec(text)) {
|
||||
const token = matchToToken(match);
|
||||
yield {
|
||||
type: getTokenType(token, match.index, text),
|
||||
value: token.value
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function highlightTokens(defs, text) {
|
||||
return text.replace(_jsTokens.default, function (...args) {
|
||||
const type = getTokenType(args);
|
||||
let highlighted = "";
|
||||
|
||||
for (const {
|
||||
type,
|
||||
value
|
||||
} of tokenize(text)) {
|
||||
const colorize = defs[type];
|
||||
|
||||
if (colorize) {
|
||||
return args[0].split(NEWLINE).map(str => colorize(str)).join("\n");
|
||||
highlighted += value.split(NEWLINE).map(str => colorize(str)).join("\n");
|
||||
} else {
|
||||
return args[0];
|
||||
highlighted += value;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return highlighted;
|
||||
}
|
||||
|
||||
function shouldHighlight(options) {
|
||||
|
||||
+3
-4
@@ -8,7 +8,7 @@
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"@babel/helper-validator-identifier": "^7.10.4",
|
||||
"@babel/helper-validator-identifier": "^7.12.11",
|
||||
"chalk": "^2.0.0",
|
||||
"js-tokens": "^4.0.0"
|
||||
},
|
||||
@@ -17,8 +17,7 @@
|
||||
"devDependencies": {
|
||||
"strip-ansi": "^4.0.0"
|
||||
},
|
||||
"gitHead": "7fd40d86a0d03ff0e9c3ea16b29689945433d4df",
|
||||
"homepage": "https://babeljs.io/",
|
||||
"homepage": "https://babel.dev/docs/en/next/babel-highlight",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"name": "@babel/highlight",
|
||||
@@ -30,5 +29,5 @@
|
||||
"url": "git+https://github.com/babel/babel.git",
|
||||
"directory": "packages/babel-highlight"
|
||||
},
|
||||
"version": "7.10.4"
|
||||
"version": "7.12.13"
|
||||
}
|
||||
+2
-2
@@ -4,8 +4,8 @@
|
||||
"email": "ariya.hidayat@gmail.com"
|
||||
},
|
||||
"bin": {
|
||||
"esparse": "./bin/esparse.js",
|
||||
"esvalidate": "./bin/esvalidate.js"
|
||||
"esparse": "bin/esparse.js",
|
||||
"esvalidate": "bin/esvalidate.js"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/jquery/esprima/issues"
|
||||
|
||||
+575
-327
File diff suppressed because it is too large.
Load diff
+1
-1
@@ -1,2 +1,2 @@
|
||||
function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,o=!1,a=void 0;try{for(var s,i=e[Symbol.iterator]();!(n=(s=i.next()).done)&&(r.push(s.value),!t||r.length!==t);n=!0);}catch(e){o=!0,a=e}finally{try{n||null==i.return||i.return()}finally{if(o)throw a}}return r}(e,t)||n(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||n(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(e,t){if(e){if("string"==typeof e)return o(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(r):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(e,t):void 0}}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function a(e,t){return e(t={exports:{}},t.exports),t.exports}var s=a((function(e,t){!function e(t){var r,n,o,a,s,i;function l(e){var t,r,n={};for(t in e)e.hasOwnProperty(t)&&(r=e[t],n[t]="object"==typeof r&&null!==r?l(r):r);return n}function u(e,t){this.parent=e,this.key=t}function c(e,t,r,n){this.node=e,this.path=t,this.wrap=r,this.ref=n}function p(){}function f(e){return null!=e&&("object"==typeof e&&"string"==typeof e.type)}function h(e,t){return(e===r.ObjectExpression||e===r.ObjectPattern)&&"properties"===t}function d(e,t){for(var r=e.length-1;r>=0;--r)if(e[r].node===t)return!0;return!1}function y(e,t){return(new p).traverse(e,t)}function m(e,t){var r;return r=function(e,t){var r,n,o,a;for(n=e.length,o=0;n;)t(e[a=o+(r=n>>>1)])?n=r:(o=a+1,n-=r+1);return o}(t,(function(t){return t.range[0]>e.range[0]})),e.extendedRange=[e.range[0],e.range[1]],r!==t.length&&(e.extendedRange[1]=t[r].range[0]),(r-=1)>=0&&(e.extendedRange[0]=t[r].range[1]),e}return r={AssignmentExpression:"AssignmentExpression",AssignmentPattern:"AssignmentPattern",ArrayExpression:"ArrayExpression",ArrayPattern:"ArrayPattern",ArrowFunctionExpression:"ArrowFunctionExpression",AwaitExpression:"AwaitExpression",BlockStatement:"BlockStatement",BinaryExpression:"BinaryExpression",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ClassBody:"ClassBody",ClassDeclaration:"ClassDeclaration",ClassExpression:"ClassExpression",ComprehensionBlock:"ComprehensionBlock",ComprehensionExpression:"ComprehensionExpression",ConditionalExpression:"ConditionalExpression",ContinueStatement:"ContinueStatement",DebuggerStatement:"DebuggerStatement",DirectiveStatement:"DirectiveStatement",DoWhileStatement:"DoWhileStatement",EmptyStatement:"EmptyStatement",ExportAllDeclaration:"ExportAllDeclaration",ExportDefaultDeclaration:"ExportDefaultDeclaration",ExportNamedDeclaration:"ExportNamedDeclaration",ExportSpecifier:"ExportSpecifier",ExpressionStatement:"ExpressionStatement",ForStatement:"ForStatement",ForInStatement:"ForInStatement",ForOfStatement:"ForOfStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",GeneratorExpression:"GeneratorExpression",Identifier:"Identifier",IfStatement:"IfStatement",ImportExpression:"ImportExpression",ImportDeclaration:"ImportDeclaration",ImportDefaultSpecifier:"ImportDefaultSpecifier",ImportNamespaceSpecifier:"ImportNamespaceSpecifier",ImportSpecifier:"ImportSpecifier",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",MetaProperty:"MetaProperty",MethodDefinition:"MethodDefinition",ModuleSpecifier:"ModuleSpecifier",NewExpression:"NewExpression",ObjectExpression:"ObjectExpression",ObjectPattern:"ObjectPattern",Program:"Program",Property:"Property",RestElement:"RestElement",ReturnStatement:"ReturnStatement",SequenceExpression:"SequenceExpression",SpreadElement:"SpreadElement",Super:"Super",SwitchStatement:"SwitchStatement",SwitchCase:"SwitchCase",TaggedTemplateExpression:"TaggedTemplateExpression",TemplateElement:"TemplateElement",TemplateLiteral:"TemplateLiteral",ThisExpression:"ThisExpression",ThrowStatement:"ThrowStatement",TryStatement:"TryStatement",UnaryExpression:"UnaryExpression",UpdateExpression:"UpdateExpression",VariableDeclaration:"VariablLine truncated
|
||||
function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,a=!1,o=void 0;try{for(var i,s=e[Symbol.iterator]();!(n=(i=s.next()).done)&&(r.push(i.value),!t||r.length!==t);n=!0);}catch(e){a=!0,o=e}finally{try{n||null==s.return||s.return()}finally{if(a)throw o}}return r}(e,t)||n(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e){return function(e){if(Array.isArray(e))return a(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||n(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(e,t){if(e){if("string"==typeof e)return a(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(e,t):void 0}}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function o(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=n(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var a=0,o=function(){};return{s:o,n:function(){return a>=e.length?{done:!0}:{done:!1,value:e[a++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,s=!0,l=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return s=e.done,e},e:function(e){l=!0,i=e},f:function(){try{s||null==r.return||r.return()}finally{if(l)throw i}}}}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function i(e,t){return e(t={exports:{}},t.exports),t.exports}var s=i((function(e,t){!function e(t){var r,n,a,o,i,s;function l(e){var t,r,n={};for(t in e)e.hasOwnProperty(t)&&(r=e[t],n[t]="object"==typeof r&&null!==r?l(r):r);return n}function u(e,t){this.parent=e,this.key=t}function c(e,t,r,n){this.node=e,this.path=t,this.wrap=r,this.ref=n}function f(){}function p(e){return null!=e&&("object"==typeof e&&"string"==typeof e.type)}function h(e,t){return(e===r.ObjectExpression||e===r.ObjectPattern)&&"properties"===t}function y(e,t){for(var r=e.length-1;r>=0;--r)if(e[r].node===t)return!0;return!1}function d(e,t){return(new f).traverse(e,t)}function m(e,t){var r;return r=function(e,t){var r,n,a,o;for(n=e.length,a=0;n;)t(e[o=a+(r=n>>>1)])?n=r:(a=o+1,n-=r+1);return a}(t,(function(t){return t.range[0]>e.range[0]})),e.extendedRange=[e.range[0],e.range[1]],r!==t.length&&(e.extendedRange[1]=t[r].range[0]),(r-=1)>=0&&(e.extendedRange[0]=t[r].range[1]),e}return r={AssignmentExpression:"AssignmentExpression",AssignmentPattern:"AssignmentPattern",ArrayExpression:"ArrayExpression",ArrayPattern:"ArrayPattern",ArrowFunctionExpression:"ArrowFunctionExpression",AwaitExpression:"AwaitExpression",BlockStatement:"BlockStatement",BinaryExpression:"BinaryExpression",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ChainExpression:"ChainExpression",ClassBody:"ClassBody",ClassDeclaration:"ClassDeclaration",ClassExpression:"ClassExpression",ComprehensionBlock:"ComprehensionBlock",ComprehensionExpression:"ComprehensionExpression",ConditionalExpression:"ConditionalExpression",ContinueStatement:"ContinueStatement",DebuggerStatement:"DebuggerStatement",DirectiveStatement:"DirectiveStatement",DoWhileStatement:"DoWhileStatement",EmptyStatement:"EmptyStatement",ExportAllDeclaration:"ExportAllDeclaration",ExportDefaultDeclaration:"ExportDefaultDeclaration",ExportNamedDeclaration:"ExportNamedDeclaration",ExportSpecifier:"ExportSpecifier",ExpressionStatement:"ExpressionStatement",ForStatement:"ForStatement",ForInStatement:"ForInStatement",ForOfStatement:"ForOfStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",GeneratorExpression:"GeneratorExpression",Identifier:"Identifier",IfStatement:"IfStatement",ImportExpression:"ImportExpression",ImportDeclaration:"ImportDeclaration",ImportDefaultSpecifier:"ImportDefaultSpecifier",ImportNamespaceSpecifier:"ImportNamespaceSpecifier",ImportSpecifier:"ImportSpecifier",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",MetaProperty:"MetaProperty",MethodDefinition:"MethodDefinition",ModuleSLine truncated
|
||||
//# sourceMappingURL=esquery.esm.min.js.map
|
||||
+575
-327
File diff suppressed because it is too large.
Load diff
+3995
File diff suppressed because it is too large.
Load diff
+2
@@ -0,0 +1,2 @@
|
||||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("estraverse")):"function"==typeof define&&define.amd?define(["estraverse"],e):(t=t||self).esquery=e(t.estraverse)}(this,(function(t){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var r=[],n=!0,a=!1,o=void 0;try{for(var u,s=t[Symbol.iterator]();!(n=(u=s.next()).done)&&(r.push(u.value),!e||r.length!==e);n=!0);}catch(t){a=!0,o=t}finally{try{n||null==s.return||s.return()}finally{if(a)throw o}}return r}(t,e)||a(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(t){return function(t){if(Array.isArray(t))return o(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||a(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(t,e){if(t){if("string"==typeof t)return o(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(t,e):void 0}}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function u(t,e){var r;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(r=a(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var u,s=!0,c=!1;return{s:function(){r=t[Symbol.iterator]()},n:function(){var t=r.next();return s=t.done,t},e:function(t){c=!0,u=t},f:function(){try{s||null==r.return||r.return()}finally{if(c)throw u}}}}t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t;"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var s=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t){t.exports&&(t.exports=function(){function t(e,r,n,a){this.message=e,this.expected=r,this.found=n,this.location=a,this.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,t)}return function(t,e){function r(){this.constructor=t}r.prototype=e.prototype,t.prototype=new r}(t,Error),t.buildMessage=function(t,e){var r={literal:function(t){return'"'+a(t.text)+'"'},class:function(t){var e,r="";for(e=0;e<t.parts.length;e++)r+=t.parts[e]instanceof Array?o(t.parts[e][0])+"-"+o(t.parts[e][1]):o(t.parts[e]);return"["+(t.inverted?"^":"")+r+"]"},any:function(t){return"any character"},end:function(t){return"end of input"},other:function(t){return t.description}};function n(t){return t.charCodeAt(0).toString(16).toUpperCase()}function a(t){return t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(t){return"\\x0"+n(t)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(t){return"\\x"+n(t)}))}function o(t){return t.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(t){return"\\x0"+n(t)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(t){return"\\x"+n(t)}))}return"Expected "+function(t){var e,n,a,o=new Array(t.length);for(e=0;e<t.length;e++)o[e]=(a=t[e],r[a.type](a));if(o.sort(),o.length>0){for(e=1,n=1;e<o.length;e++)o[e-1]!==o[e]&&(o[n]=o[e],n++);o.length=n}switch(o.length){case 1:return o[0];case 2:return o[0]+" or "+o[1];default:return o.slice(0,-1).join(", ")+", or "+o[o.length-1]}}(t)+" but "+function(t){return t?'"'+a(t)+'"':"end of input"}(e)+" found."},{SyntaxError:t,parse:function(e,r){r=void 0!==r?r:{};var n,a,o,u,s={},c={start:bt},i=bt,l=vt(" ",!1),f=/^[^ [\],():#!=><~+.]/,h=dt([" ","[","]",",","(",")",":","#","!","=",">","<","~","+","."],!0,!1),p=vt(">",!1),y=vt("~",!1),v=vt("+",!1),d=vt(",",!1),A=vt("!",!1),x=vt("*",!1),g=vt("#",!1),b=vt("[",!1),m=vt("]",!1),P=/^[><!]/,w=dt([">","<","!"],!1,!1),C=vt("=",!1),j=function(t){return(t||"")+"="},S=/^[><]/,E=dt([">","<"],!1,!1),I=vt(".",!1),k=function(t,e,r){return{type:"attribute",name:t,operator:e,value:r}},F=vt('"',!1),T=/^[^\\"]/,L=dt(["\\",Line truncated
|
||||
//# sourceMappingURL=esquery.lite.min.js.map
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).esquery=t()}(this,(function(){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,o=!1,a=void 0;try{for(var s,i=e[Symbol.iterator]();!(n=(s=i.next()).done)&&(r.push(s.value),!t||r.length!==t);n=!0);}catch(e){o=!0,a=e}finally{try{n||null==i.return||i.return()}finally{if(o)throw a}}return r}(e,t)||n(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||n(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(e,t){if(e){if("string"==typeof e)return o(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(r):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(e,t):void 0}}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function a(e,t){return e(t={exports:{}},t.exports),t.exports}var s=a((function(e,t){!function e(t){var r,n,o,a,s,i;function l(e){var t,r,n={};for(t in e)e.hasOwnProperty(t)&&(r=e[t],n[t]="object"==typeof r&&null!==r?l(r):r);return n}function u(e,t){this.parent=e,this.key=t}function c(e,t,r,n){this.node=e,this.path=t,this.wrap=r,this.ref=n}function f(){}function p(e){return null!=e&&("object"==typeof e&&"string"==typeof e.type)}function h(e,t){return(e===r.ObjectExpression||e===r.ObjectPattern)&&"properties"===t}function d(e,t){for(var r=e.length-1;r>=0;--r)if(e[r].node===t)return!0;return!1}function y(e,t){return(new f).traverse(e,t)}function m(e,t){var r;return r=function(e,t){var r,n,o,a;for(n=e.length,o=0;n;)t(e[a=o+(r=n>>>1)])?n=r:(o=a+1,n-=r+1);return o}(t,(function(t){return t.range[0]>e.range[0]})),e.extendedRange=[e.range[0],e.range[1]],r!==t.length&&(e.extendedRange[1]=t[r].range[0]),(r-=1)>=0&&(e.extendedRange[0]=t[r].range[1]),e}return r={AssignmentExpression:"AssignmentExpression",AssignmentPattern:"AssignmentPattern",ArrayExpression:"ArrayExpression",ArrayPattern:"ArrayPattern",ArrowFunctionExpression:"ArrowFunctionExpression",AwaitExpression:"AwaitExpression",BlockStatement:"BlockStatement",BinaryExpression:"BinaryExpression",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ClassBody:"ClassBody",ClassDeclaration:"ClassDeclaration",ClassExpression:"ClassExpression",ComprehensionBlock:"ComprehensionBlock",ComprehensionExpression:"ComprehensionExpression",ConditionalExpression:"ConditionalExpression",ContinueStatement:"ContinueStatement",DebuggerStatement:"DebuggerStatement",DirectiveStatement:"DirectiveStatement",DoWhileStatement:"DoWhileStatement",EmptyStatement:"EmptyStatement",ExportAllDeclaration:"ExportAllDeclaration",ExportDefaultDeclaration:"ExportDefaultDeclaration",ExportNamedDeclaration:"ExportNamedDeclaration",ExportSpecifier:"ExportSpecifier",ExpressionStatement:"ExpressionStatement",ForStatement:"ForStatement",ForInStatement:"ForInStatement",ForOfStatement:"ForOfStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",GeneratorExpression:"GeneratorExpression",Identifier:"Identifier",IfStatement:"IfStatement",ImportExpression:"ImportExpression",ImportDeclaration:"ImportDeclaration",ImportDefaultSpecifier:"ImportDefaultSpecifier",ImportNamespaceSpecifier:"ImportNamespaceSpecifier",ImportSpecifier:"ImportSpecifier",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",MetaProperty:"MetaProperty",MethodDefinition:"MethodDefinition",ModuleSpecifier:"ModuleSpecifier",NewExpression:"NewExpression",ObjectExpression:"ObjectExpression",ObjectPattern:"ObjectPattern",Program:"Program",Property:"Property",RestElement:"RestElement",ReturnStatement:"ReturnStatement",SequenceExpression:"SequenceExpression",SpreadElement:"SpreadElement",Super:"Super",SwitchStatement:"SwitchStatement",SwitchCase:"SwitchCase",TaggedTemplateExpression:"TaggedTemplateExpression",TemplateElement:"TemplateElement",TemplateLiteral:"TemplateLiteral",Line truncated
|
||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).esquery=t()}(this,(function(){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,o=!1,a=void 0;try{for(var i,s=e[Symbol.iterator]();!(n=(i=s.next()).done)&&(r.push(i.value),!t||r.length!==t);n=!0);}catch(e){o=!0,a=e}finally{try{n||null==s.return||s.return()}finally{if(o)throw a}}return r}(e,t)||n(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||n(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(e,t){if(e){if("string"==typeof e)return o(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(e,t):void 0}}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function a(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=n(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var o=0,a=function(){};return{s:a,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,s=!0,l=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return s=e.done,e},e:function(e){l=!0,i=e},f:function(){try{s||null==r.return||r.return()}finally{if(l)throw i}}}}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function i(e,t){return e(t={exports:{}},t.exports),t.exports}var s=i((function(e,t){!function e(t){var r,n,o,a,i,s;function l(e){var t,r,n={};for(t in e)e.hasOwnProperty(t)&&(r=e[t],n[t]="object"==typeof r&&null!==r?l(r):r);return n}function u(e,t){this.parent=e,this.key=t}function c(e,t,r,n){this.node=e,this.path=t,this.wrap=r,this.ref=n}function f(){}function p(e){return null!=e&&("object"==typeof e&&"string"==typeof e.type)}function h(e,t){return(e===r.ObjectExpression||e===r.ObjectPattern)&&"properties"===t}function y(e,t){for(var r=e.length-1;r>=0;--r)if(e[r].node===t)return!0;return!1}function d(e,t){return(new f).traverse(e,t)}function m(e,t){var r;return r=function(e,t){var r,n,o,a;for(n=e.length,o=0;n;)t(e[a=o+(r=n>>>1)])?n=r:(o=a+1,n-=r+1);return o}(t,(function(t){return t.range[0]>e.range[0]})),e.extendedRange=[e.range[0],e.range[1]],r!==t.length&&(e.extendedRange[1]=t[r].range[0]),(r-=1)>=0&&(e.extendedRange[0]=t[r].range[1]),e}return r={AssignmentExpression:"AssignmentExpression",AssignmentPattern:"AssignmentPattern",ArrayExpression:"ArrayExpression",ArrayPattern:"ArrayPattern",ArrowFunctionExpression:"ArrowFunctionExpression",AwaitExpression:"AwaitExpression",BlockStatement:"BlockStatement",BinaryExpression:"BinaryExpression",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ChainExpression:"ChainExpression",ClassBody:"ClassBody",ClassDeclaration:"ClassDeclaration",ClassExpression:"ClassExpression",ComprehensionBlock:"ComprehensionBlock",ComprehensionExpression:"ComprehensionExpression",ConditionalExpression:"ConditionalExpression",ContinueStatement:"ContinueStatement",DebuggerStatement:"DebuggerStatement",DirectiveStatement:"DirectiveStatement",DoWhileStatement:"DoWhileStatement",EmptyStatement:"EmptyStatement",ExportAllDeclaration:"ExportAllDeclaration",ExportDefaultDeclaration:"ExportDefaultDeclaration",ExportNamedDeclaration:"ExportNamedDeclaration",ExportSpecifier:"ExportSpecifier",ExpressionStatement:"ExpressionStatement",ForStatement:"ForStatement",ForInStatement:"ForInStatement",ForOfStatement:"ForOfStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",GeneratorExpression:"GeneratorExpression",Identifier:"Identifier",IfStatement:"IfStatement",ImportExpression:"ImportExpression",ImportDeclaration:"ImportDeclaration",ImportDefaultSpecifier:"ImportDefaultSpecifier",ImportNamespaceSpecifier:"ImportNamespaceSpecifier",ImportSpecifier:"ImportSpecifier",Literal:"Line truncated
|
||||
//# sourceMappingURL=esquery.min.js.map
|
||||
+1
-1
@@ -81,5 +81,5 @@
|
||||
"test": "nyc npm run mocha && npm run lint",
|
||||
"test:ci": "npm run mocha"
|
||||
},
|
||||
"version": "1.3.1"
|
||||
"version": "1.4.0"
|
||||
}
|
||||
+251
-221
File diff suppressed because it is too large.
Load diff
+97
-6
@@ -1,8 +1,8 @@
|
||||
<img align="right" alt="Ajv logo" width="160" src="https://ajv.js.org/images/ajv_logo.png">
|
||||
|
||||
# Ajv: Another JSON Schema Validator
|
||||
# Ajv: Another JSON schema validator
|
||||
|
||||
The fastest JSON Schema validator for Node.js and browser. Supports draft-06/07/2019-09 (draft-04 is supported in [version 6](https://github.com/ajv-validator/ajv/tree/v6)).
|
||||
The fastest JSON schema validator for Node.js and browser. Supports JSON Schema draft-06/07/2019-09 (draft-04 is supported in [version 6](https://github.com/ajv-validator/ajv/tree/v6)) and JSON Type Definition [RFC8927](https://datatracker.ietf.org/doc/rfc8927/).
|
||||
|
||||
[](https://github.com/ajv-validator/ajv/actions?query=workflow%3Abuild)
|
||||
[](https://www.npmjs.com/package/ajv)
|
||||
@@ -17,9 +17,10 @@ The fastest JSON Schema validator for Node.js and browser. Supports draft-06/07/
|
||||
|
||||
## Using version 7
|
||||
|
||||
Ajv version 7 is released with these changes:
|
||||
Ajv version 7 has these new features:
|
||||
|
||||
- support of JSON Schema draft-2019-09 features: [`unevaluatedProperties`](./docs/json-schema.md#unevaluatedproperties) and [`unevaluatedItems`](./docs/json-schema.md#unevaluateditems), [dynamic recursive references](./docs/validation.md#extending-recursive-schemas) and other [additional keywords](./docs/json-schema.md#json-schema-draft-2019-09).
|
||||
- NEW: support of JSON Type Definition [RFC8927](https://datatracker.ietf.org/doc/rfc8927/) (from [v7.1.0](https://github.com/ajv-validator/ajv-keywords/releases/tag/v7.1.0))
|
||||
- to reduce the mistakes in JSON schemas and unexpected validation results, [strict mode](./docs/strict-mode.md) is added - it prohibits ignored or ambiguous JSON Schema elements.
|
||||
- to make code injection from untrusted schemas impossible, [code generation](./docs/codegen.md) is fully re-written to be safe and to allow code optimization (compiled schema code size is reduced by more than 10%).
|
||||
- to simplify Ajv extensions, the new keyword API that is used by pre-defined keywords is available to user-defined keywords - it is much easier to define any keywords now, especially with subschemas. [ajv-keywords](https://github.com/ajv-validator/ajv-keywords) package was updated to use the new API (in [v4.0.0](https://github.com/ajv-validator/ajv-keywords/releases/tag/v4.0.0))
|
||||
@@ -71,6 +72,9 @@ Please review [Contributing guidelines](./CONTRIBUTING.md) and [Code components]
|
||||
- [Performance](#performance)
|
||||
- [Features](#features)
|
||||
- [Getting started](#usage)
|
||||
- [Choosing schema language](#choosing-schema-language)
|
||||
- [JSON Schema](#json-schema)
|
||||
- [JSON Type Definition](#json-type-definition)
|
||||
- [Frequently Asked Questions](./docs/faq.md)
|
||||
- [Using in browser](#using-in-browser)
|
||||
- [Content Security Policy](./docs/security.md#content-security-policy)
|
||||
@@ -166,7 +170,7 @@ Performance of different validators by [json-schema-benchmark](https://github.co
|
||||
|
||||
## Features
|
||||
|
||||
- Ajv implements full JSON Schema [draft-06/07](http://json-schema.org/) standards (draft-04 is supported in v6):
|
||||
- Ajv implements JSON Schema [draft-06/07/2019-09](http://json-schema.org/) standards (draft-04 is supported in v6):
|
||||
- all validation keywords (see [JSON Schema validation keywords](./docs/json-schema.md))
|
||||
- keyword "nullable" from [Open API 3 specification](https://swagger.io/docs/specification/data-models/data-types/).
|
||||
- full support of remote references (remote schemas have to be added with `addSchema` or compiled to be available)
|
||||
@@ -174,6 +178,10 @@ Performance of different validators by [json-schema-benchmark](https://github.co
|
||||
- correct string lengths for strings with unicode pairs
|
||||
- [formats](#formats) defined by JSON Schema draft-07 standard (with [ajv-formats](https://github.com/ajv-validator/ajv-formats) plugin) and additional formats (can be turned off)
|
||||
- [validates schemas against meta-schema](./docs/api.md#api-validateschema)
|
||||
- NEW: supports [JSON Type Definition](https://datatracker.ietf.org/doc/rfc8927/):
|
||||
- all forms (see [JSON Type Definition schema forms](./docs/json-type-definition.md))
|
||||
- meta-schema for JTD schemas
|
||||
- "union" keyword and user-defined keywords (can be used inside "metadata" member of the schema)
|
||||
- supports [browsers](#using-in-browser) and Node.js 0.10-14.x
|
||||
- [asynchronous loading](./docs/validation.md#asynchronous-schema-compilation) of referenced schemas during compilation
|
||||
- "All errors" validation mode with [option allErrors](./docs/api.md#options)
|
||||
@@ -262,6 +270,26 @@ if (validate(data)) {
|
||||
}
|
||||
```
|
||||
|
||||
With JSON Type Definition schema:
|
||||
|
||||
```javascript
|
||||
const Ajv = require("ajv").default
|
||||
|
||||
const ajv = new Ajv() // options can be passed, e.g. {allErrors: true}
|
||||
const schema = {
|
||||
properties: {
|
||||
foo: {type: "float64"},
|
||||
},
|
||||
}
|
||||
const validate = ajv.compile(schema)
|
||||
const valid = validate({foo: 1}) // true
|
||||
if (!valid) console.log(validate.errors)
|
||||
// Unlike JSON Schema:
|
||||
const valid1 = validate(1) // false, bot an object
|
||||
const valid2 = validate({}) // false, foo is required
|
||||
const valid3 = validate({foo: 1, bar: 2}) // false, bar is additional
|
||||
```
|
||||
|
||||
See [this test](./spec/types/json-schema.spec.ts) for an advanced example, [API reference](./docs/api.md) and [Options](./docs/api.md#options) for more details.
|
||||
|
||||
Ajv compiles schemas to functions and caches them in all cases (using schema itself as a key for Map) or another function passed via options), so that the next time the same schema is used (not necessarily the same object instance) it won't be compiled again.
|
||||
@@ -290,7 +318,7 @@ Then you need to load Ajv with support of JSON Schema draft-07 in the browser:
|
||||
</script>
|
||||
```
|
||||
|
||||
or to load the bundle that supports JSONSchema draft-2019-09:
|
||||
To load the bundle that supports JSON Schema draft-2019-09:
|
||||
|
||||
```html
|
||||
<script src="bundle/ajv2019.min.js"></script>
|
||||
@@ -302,12 +330,75 @@ or to load the bundle that supports JSONSchema draft-2019-09:
|
||||
</script>
|
||||
```
|
||||
|
||||
To load the bundle that supports JSON Type Definition:
|
||||
|
||||
```html
|
||||
<script src="bundle/ajvJTD.min.js"></script>
|
||||
<script>
|
||||
;(function () {
|
||||
const Ajv = window.ajvJTD.default
|
||||
const ajv = new Ajv()
|
||||
})()
|
||||
</script>
|
||||
```
|
||||
|
||||
This bundle can be used with different module systems; it creates global `ajv` (or `ajv2019`) if no module system is found.
|
||||
|
||||
The browser bundle is available on [cdnjs](https://cdnjs.com/libraries/ajv).
|
||||
|
||||
**Please note**: some frameworks, e.g. Dojo, may redefine global require in a way that is not compatible with CommonJS module format. In this case Ajv bundle has to be loaded before the framework and then you can use global `ajv` (see issue [#234](https://github.com/ajv-validator/ajv/issues/234)).
|
||||
|
||||
## Choosing schema language
|
||||
|
||||
Both JSON Schema and JSON Type Definition are cross-platform specifications with implementations in multiple programming languages that help you define the shape and requirements to your JSON data.
|
||||
|
||||
This section compares their pros/cons to help decide which specification fits your application better.
|
||||
|
||||
### JSON Schema
|
||||
|
||||
- Pros
|
||||
- Wide specification adoption.
|
||||
- Used as part of OpenAPI specification.
|
||||
- Support of complex validation scenarios:
|
||||
- untagged unions and boolean logic
|
||||
- conditional schemas and dependencies
|
||||
- restrictions on the number ranges and the size of strings, arrays and objects
|
||||
- semantic validation with formats, patterns and content keywords
|
||||
- distribute strict record definitions across multiple schemas (with unevaluatedProperties)
|
||||
- Can be effectively used for validation of any JavaScript objects and configuration files.
|
||||
- Cons
|
||||
- Defines the collection of restrictions on the data, rather than the shape of the data.
|
||||
- No standard support for tagged unions.
|
||||
- Complex and error prone for the new users (Ajv has [strict mode](./docs/strict-mode) to compensate for it, but it is not cross-platform).
|
||||
- Some parts of specification are difficult to implement, creating the risk of implementations divergence:
|
||||
- reference resolution model
|
||||
- unevaluatedProperties/unevaluatedItems
|
||||
- dynamic recursive references
|
||||
- Internet draft status (rather than RFC)
|
||||
|
||||
See [JSON Schema](./docs/json-schema.md) for the list of defined keywords.
|
||||
|
||||
### JSON Type Definition
|
||||
|
||||
- Pros:
|
||||
- Aligned with type systems of many languages - can be used to generate type definitions and efficient parsers and serializers to/from these types.
|
||||
- Very simple, enforcing the best practices for cross-platform JSON API modelling.
|
||||
- Simple to implement, ensuring consistency across implementations.
|
||||
- Defines the shape of JSON data via strictly defined schema forms (rather than the collection of restrictions).
|
||||
- Effective support for tagged unions.
|
||||
- Designed to protect against user mistakes.
|
||||
- Approved as [RFC8927](https://datatracker.ietf.org/doc/rfc8927/)
|
||||
- Cons:
|
||||
- Limited, compared with JSON Schema - no support for untagged unions<sup>\*</sup>, conditionals, references between different schema files<sup>\*\*</sup>, etc.
|
||||
- No meta-schema in the specification<sup>\*</sup>.
|
||||
- Brand new - limited industry adoption (as of January 2021).
|
||||
|
||||
<sup>\*</sup> Ajv defines meta-schema for JTD schemas and non-standard keyword "union" that can be used inside "metadata" object.
|
||||
|
||||
<sup>\*\*</sup> You can still combine schemas from multiple files in the application code.
|
||||
|
||||
See [JSON Type Definition](./docs/json-type-definition.md) for the list of defined schema forms.
|
||||
|
||||
## Using in ES5 environment
|
||||
|
||||
You need to:
|
||||
@@ -334,7 +425,7 @@ CLI is available as a separate npm package [ajv-cli](https://github.com/ajv-vali
|
||||
- user-defined meta-schemas, validation keywords and formats
|
||||
- files in JSON, JSON5, YAML, and JavaScript format
|
||||
- all Ajv options
|
||||
- reporting changes in data after validation in [JSON-patch](https://tools.ietf.org/html/rfc6902) format
|
||||
- reporting changes in data after validation in [JSON-patch](https://datatracker.ietf.org/doc/rfc6902/) format
|
||||
|
||||
## Extending Ajv
|
||||
|
||||
|
||||
+2
-3
@@ -22,10 +22,9 @@ class Ajv extends core_1.default {
|
||||
}
|
||||
_addDefaultMetaSchema() {
|
||||
super._addDefaultMetaSchema();
|
||||
const { $data, meta } = this.opts;
|
||||
if (!meta)
|
||||
if (!this.opts.meta)
|
||||
return;
|
||||
const metaSchema = $data
|
||||
const metaSchema = this.opts.$data
|
||||
? this.$dataMetaSchema(draft7MetaSchema, META_SUPPORT_DATA)
|
||||
: draft7MetaSchema;
|
||||
this.addMetaSchema(metaSchema, META_SCHEMA_ID, false);
|
||||
|
||||
Generated
Vendored
+9
-3
@@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ValueScope = exports.ValueScopeName = exports.Scope = exports.varKinds = void 0;
|
||||
exports.ValueScope = exports.ValueScopeName = exports.Scope = exports.varKinds = exports.UsedValueState = void 0;
|
||||
const code_1 = require("./code");
|
||||
class ValueError extends Error {
|
||||
constructor(name) {
|
||||
@@ -8,6 +8,11 @@ class ValueError extends Error {
|
||||
this.value = name.value;
|
||||
}
|
||||
}
|
||||
var UsedValueState;
|
||||
(function (UsedValueState) {
|
||||
UsedValueState[UsedValueState["Started"] = 0] = "Started";
|
||||
UsedValueState[UsedValueState["Completed"] = 1] = "Completed";
|
||||
})(UsedValueState = exports.UsedValueState || (exports.UsedValueState = {}));
|
||||
exports.varKinds = {
|
||||
const: new code_1.Name("const"),
|
||||
let: new code_1.Name("let"),
|
||||
@@ -112,11 +117,11 @@ class ValueScope extends Scope {
|
||||
const vs = values[prefix];
|
||||
if (!vs)
|
||||
continue;
|
||||
const nameSet = (usedValues[prefix] = usedValues[prefix] || new Set());
|
||||
const nameSet = (usedValues[prefix] = usedValues[prefix] || new Map());
|
||||
vs.forEach((name) => {
|
||||
if (nameSet.has(name))
|
||||
return;
|
||||
nameSet.add(name);
|
||||
nameSet.set(name, UsedValueState.Started);
|
||||
let c = valueCode(name);
|
||||
if (c) {
|
||||
const def = this.opts.es5 ? exports.varKinds.var : exports.varKinds.const;
|
||||
@@ -128,6 +133,7 @@ class ValueScope extends Scope {
|
||||
else {
|
||||
throw new ValueError(name);
|
||||
}
|
||||
nameSet.set(name, UsedValueState.Completed);
|
||||
});
|
||||
}
|
||||
return code;
|
||||
|
||||
Generated
Vendored
+1
-1
@@ -79,7 +79,7 @@ class KeywordCxt {
|
||||
}
|
||||
error(append) {
|
||||
;
|
||||
(append ? errors_1.reportExtraError : errors_1.reportError)(this, this.def.error || errors_1.keywordError);
|
||||
(append ? errors_1.reportExtraError : errors_1.reportError)(this, this.def.error);
|
||||
}
|
||||
$dataError() {
|
||||
errors_1.reportError(this, this.def.$dataError || errors_1.keyword$DataError);
|
||||
|
||||
Generated
Vendored
+2
-2
@@ -11,8 +11,8 @@ class ValidationError extends Error {
|
||||
}
|
||||
exports.ValidationError = ValidationError;
|
||||
class MissingRefError extends Error {
|
||||
constructor(baseId, ref) {
|
||||
super(`can't resolve reference ${ref} from id ${baseId}`);
|
||||
constructor(baseId, ref, msg) {
|
||||
super(msg || `can't resolve reference ${ref} from id ${baseId}`);
|
||||
this.missingRef = resolve_1.resolveUrl(baseId, ref);
|
||||
this.missingSchema = resolve_1.normalizeId(resolve_1.getFullPath(this.missingRef));
|
||||
}
|
||||
|
||||
Generated
Vendored
+24
-6
@@ -11,7 +11,7 @@ exports.keyword$DataError = {
|
||||
? codegen_1.str `"${keyword}" keyword must be ${schemaType} ($data)`
|
||||
: codegen_1.str `"${keyword}" keyword is invalid ($data)`,
|
||||
};
|
||||
function reportError(cxt, error, overrideAllErrors) {
|
||||
function reportError(cxt, error = exports.keywordError, overrideAllErrors) {
|
||||
const { it } = cxt;
|
||||
const { gen, compositeRule, allErrors } = it;
|
||||
const errObj = errorObjectCode(cxt, error);
|
||||
@@ -23,7 +23,7 @@ function reportError(cxt, error, overrideAllErrors) {
|
||||
}
|
||||
}
|
||||
exports.reportError = reportError;
|
||||
function reportExtraError(cxt, error) {
|
||||
function reportExtraError(cxt, error = exports.keywordError) {
|
||||
const { it } = cxt;
|
||||
const { gen, compositeRule, allErrors } = it;
|
||||
const errObj = errorObjectCode(cxt, error);
|
||||
@@ -77,11 +77,30 @@ const E = {
|
||||
message: new codegen_1.Name("message"),
|
||||
schema: new codegen_1.Name("schema"),
|
||||
parentSchema: new codegen_1.Name("parentSchema"),
|
||||
// JTD error properties
|
||||
instancePath: new codegen_1.Name("instancePath"),
|
||||
};
|
||||
function errorObjectCode(cxt, error) {
|
||||
const { keyword, data, schemaValue, it: { gen, createErrors, topSchemaRef, schemaPath, errorPath, errSchemaPath, propertyName, opts }, } = cxt;
|
||||
const { createErrors, opts } = cxt.it;
|
||||
if (createErrors === false)
|
||||
return codegen_1._ `{}`;
|
||||
return (opts.jtd && !opts.ajvErrors ? jtdErrorObject : ajvErrorObject)(cxt, error);
|
||||
}
|
||||
function jtdErrorObject(cxt, { message }) {
|
||||
const { gen, keyword, it } = cxt;
|
||||
const { errorPath, errSchemaPath, opts } = it;
|
||||
const keyValues = [
|
||||
[E.instancePath, codegen_1.strConcat(names_1.default.dataPath, errorPath)],
|
||||
[E.schemaPath, codegen_1.str `${errSchemaPath}/${keyword}`],
|
||||
];
|
||||
if (opts.messages) {
|
||||
keyValues.push([E.message, typeof message == "function" ? message(cxt) : message]);
|
||||
}
|
||||
return gen.object(...keyValues);
|
||||
}
|
||||
function ajvErrorObject(cxt, error) {
|
||||
const { gen, keyword, data, schemaValue, it } = cxt;
|
||||
const { topSchemaRef, schemaPath, errorPath, errSchemaPath, propertyName, opts } = it;
|
||||
const { params, message } = error;
|
||||
const keyValues = [
|
||||
[E.keyword, keyword],
|
||||
@@ -91,9 +110,8 @@ function errorObjectCode(cxt, error) {
|
||||
];
|
||||
if (propertyName)
|
||||
keyValues.push([E.propertyName, propertyName]);
|
||||
if (opts.messages !== false) {
|
||||
const msg = typeof message == "function" ? message(cxt) : message;
|
||||
keyValues.push([E.message, msg]);
|
||||
if (opts.messages) {
|
||||
keyValues.push([E.message, typeof message == "function" ? message(cxt) : message]);
|
||||
}
|
||||
if (opts.verbose) {
|
||||
keyValues.push([E.schema, schemaValue], [E.parentSchema, codegen_1._ `${topSchemaRef}${schemaPath}`], [names_1.default.data, data]);
|
||||
|
||||
Generated
Vendored
+8
-5
@@ -64,11 +64,10 @@ function compileSchema(sch) {
|
||||
ValidationError: _ValidationError,
|
||||
schema: sch.schema,
|
||||
schemaEnv: sch,
|
||||
strictSchema: true,
|
||||
rootId,
|
||||
baseId: sch.baseId || rootId,
|
||||
schemaPath: codegen_1.nil,
|
||||
errSchemaPath: "#",
|
||||
errSchemaPath: this.opts.jtd ? "" : "#",
|
||||
errorPath: codegen_1._ `""`,
|
||||
opts: this.opts,
|
||||
self: this,
|
||||
@@ -171,7 +170,7 @@ ref // reference to resolve
|
||||
) {
|
||||
const p = URI.parse(ref);
|
||||
const refPath = resolve_1._getFullPath(p);
|
||||
const baseId = resolve_1.getFullPath(root.baseId);
|
||||
let baseId = resolve_1.getFullPath(root.baseId);
|
||||
// TODO `Object.keys(root.schema).length > 0` should not be needed - but removing breaks 2 tests
|
||||
if (Object.keys(root.schema).length > 0 && refPath === baseId) {
|
||||
return getJsonPointer.call(this, p, root);
|
||||
@@ -188,8 +187,12 @@ ref // reference to resolve
|
||||
return;
|
||||
if (!schOrRef.validate)
|
||||
compileSchema.call(this, schOrRef);
|
||||
if (id === resolve_1.normalizeId(ref))
|
||||
return new SchemaEnv({ schema: schOrRef.schema, root, baseId });
|
||||
if (id === resolve_1.normalizeId(ref)) {
|
||||
const { schema } = schOrRef;
|
||||
if (schema.$id)
|
||||
baseId = resolve_1.resolveUrl(baseId, schema.$id);
|
||||
return new SchemaEnv({ schema, root, baseId });
|
||||
}
|
||||
return getJsonPointer.call(this, p, schOrRef);
|
||||
}
|
||||
exports.resolveSchema = resolveSchema;
|
||||
|
||||
Generated
Vendored
+2
-2
@@ -18,8 +18,8 @@ function getRules() {
|
||||
types: { ...groups, integer: true, boolean: true, null: true },
|
||||
rules: [{ rules: [] }, groups.number, groups.string, groups.array, groups.object],
|
||||
post: { rules: [] },
|
||||
all: { type: true, $comment: true },
|
||||
keywords: { type: true, $comment: true },
|
||||
all: {},
|
||||
keywords: {},
|
||||
};
|
||||
}
|
||||
exports.getRules = getRules;
|
||||
|
||||
Generated
Vendored
+4
-4
@@ -18,7 +18,7 @@ function applySubschema(it, appl, valid) {
|
||||
return nextContext;
|
||||
}
|
||||
exports.applySubschema = applySubschema;
|
||||
function getSubschema(it, { keyword, schemaProp, schema, strictSchema, schemaPath, errSchemaPath, topSchemaRef, }) {
|
||||
function getSubschema(it, { keyword, schemaProp, schema, schemaPath, errSchemaPath, topSchemaRef }) {
|
||||
if (keyword !== undefined && schema !== undefined) {
|
||||
throw new Error('both "keyword" and "schema" passed, only one allowed');
|
||||
}
|
||||
@@ -42,7 +42,6 @@ function getSubschema(it, { keyword, schemaProp, schema, strictSchema, schemaPat
|
||||
}
|
||||
return {
|
||||
schema,
|
||||
strictSchema,
|
||||
schemaPath,
|
||||
topSchemaRef,
|
||||
errSchemaPath,
|
||||
@@ -80,14 +79,15 @@ function extendSubschemaData(subschema, it, { dataProp, dataPropType: dpType, da
|
||||
subschema.dataNames = [...it.dataNames, _nextData];
|
||||
}
|
||||
}
|
||||
function extendSubschemaMode(subschema, { compositeRule, createErrors, allErrors, strictSchema }) {
|
||||
function extendSubschemaMode(subschema, { jtdDiscriminator, jtdMetadata, compositeRule, createErrors, allErrors }) {
|
||||
if (compositeRule !== undefined)
|
||||
subschema.compositeRule = compositeRule;
|
||||
if (createErrors !== undefined)
|
||||
subschema.createErrors = createErrors;
|
||||
if (allErrors !== undefined)
|
||||
subschema.allErrors = allErrors;
|
||||
subschema.strictSchema = strictSchema; // not inherited
|
||||
subschema.jtdDiscriminator = jtdDiscriminator; // not inherited
|
||||
subschema.jtdMetadata = jtdMetadata; // not inherited
|
||||
}
|
||||
function getErrorPath(dataProp, dataPropType, jsPropertySyntax) {
|
||||
// let path
|
||||
|
||||
Generated
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const DATE_TIME = /^(\d\d\d\d)-(\d\d)-(\d\d)(?:t|\s)(\d\d):(\d\d):(\d\d)(?:\.\d+)?(?:z|([+-]\d\d)(?::?(\d\d))?)$/i;
|
||||
const DAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
||||
function validTimestamp(str) {
|
||||
// http://tools.ietf.org/html/rfc3339#section-5.6
|
||||
const matches = DATE_TIME.exec(str);
|
||||
if (!matches)
|
||||
return false;
|
||||
const y = +matches[1];
|
||||
const m = +matches[2];
|
||||
const d = +matches[3];
|
||||
const hr = +matches[4];
|
||||
const min = +matches[5];
|
||||
const sec = +matches[6];
|
||||
const tzH = +(matches[7] || 0);
|
||||
const tzM = +(matches[8] || 0);
|
||||
return (m >= 1 &&
|
||||
m <= 12 &&
|
||||
d >= 1 &&
|
||||
(d <= DAYS[m] ||
|
||||
// leap year: https://tools.ietf.org/html/rfc3339#appendix-C
|
||||
(m === 2 && d === 29 && (y % 100 === 0 ? y % 400 === 0 : y % 4 === 0))) &&
|
||||
((hr <= 23 && min <= 59 && sec <= 59) ||
|
||||
// leap second
|
||||
(hr - tzH === 23 && min - tzM === 59 && sec === 60)));
|
||||
}
|
||||
exports.default = validTimestamp;
|
||||
//# sourceMappingURL=timestamp.js.map
|
||||
Generated
Vendored
+2
@@ -119,6 +119,8 @@ function checkKeywords(it) {
|
||||
checkRefsAndKeywords(it);
|
||||
}
|
||||
function typeAndKeywords(it, errsCount) {
|
||||
if (it.opts.jtd)
|
||||
return iterate_1.schemaKeywords(it, [], false, errsCount);
|
||||
const types = dataType_1.getSchemaTypes(it.schema);
|
||||
const checkedTypes = dataType_1.coerceAndCheckDataType(it, types);
|
||||
iterate_1.schemaKeywords(it, types, !checkedTypes, errsCount);
|
||||
|
||||
Generated
Vendored
+2
-1
@@ -16,7 +16,8 @@ function schemaKeywords(it, types, typeErrors, errsCount) {
|
||||
gen.block(() => keyword_1.keywordCode(it, "$ref", RULES.all.$ref.definition)); // TODO typecast
|
||||
return;
|
||||
}
|
||||
checkStrictTypes(it, types);
|
||||
if (!opts.jtd)
|
||||
checkStrictTypes(it, types);
|
||||
gen.block(() => {
|
||||
for (const group of RULES.rules)
|
||||
groupKeywords(group);
|
||||
|
||||
+6
-3
@@ -409,8 +409,11 @@ class Ajv {
|
||||
}
|
||||
}
|
||||
_addSchema(schema, meta, validateSchema = this.opts.validateSchema, addSchema = this.opts.addUsedSchema) {
|
||||
if (typeof schema != "object" && typeof schema != "boolean") {
|
||||
throw new Error("schema must be object or boolean");
|
||||
if (typeof schema != "object") {
|
||||
if (this.opts.jtd)
|
||||
throw new Error("schema must be object");
|
||||
else if (typeof schema != "boolean")
|
||||
throw new Error("schema must be object or boolean");
|
||||
}
|
||||
let sch = this._cache.get(schema);
|
||||
if (sch !== undefined)
|
||||
@@ -515,7 +518,7 @@ function getLogger(logger) {
|
||||
return logger;
|
||||
throw new Error("logger must implement log, warn and error methods");
|
||||
}
|
||||
const KEYWORD_NAME = /^[a-z_$][a-z0-9_$-]*$/i;
|
||||
const KEYWORD_NAME = /^[a-z_$][a-z0-9_$-:]*$/i;
|
||||
function checkKeyword(keyword, def) {
|
||||
const { RULES } = this;
|
||||
util_1.eachItem(keyword, (kwd) => {
|
||||
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = void 0;
|
||||
const context_1 = require("./compile/context");
|
||||
exports.KeywordCxt = context_1.default;
|
||||
// export {DefinedError} from "./vocabularies/errors"
|
||||
var codegen_1 = require("./compile/codegen");
|
||||
Object.defineProperty(exports, "_", { enumerable: true, get: function () { return codegen_1._; } });
|
||||
Object.defineProperty(exports, "str", { enumerable: true, get: function () { return codegen_1.str; } });
|
||||
Object.defineProperty(exports, "stringify", { enumerable: true, get: function () { return codegen_1.stringify; } });
|
||||
Object.defineProperty(exports, "nil", { enumerable: true, get: function () { return codegen_1.nil; } });
|
||||
Object.defineProperty(exports, "Name", { enumerable: true, get: function () { return codegen_1.Name; } });
|
||||
Object.defineProperty(exports, "CodeGen", { enumerable: true, get: function () { return codegen_1.CodeGen; } });
|
||||
const core_1 = require("./core");
|
||||
const jtd_1 = require("./vocabularies/jtd");
|
||||
const jtd_schema_1 = require("./refs/jtd-schema");
|
||||
// const META_SUPPORT_DATA = ["/properties"]
|
||||
const META_SCHEMA_ID = "JTD-meta-schema";
|
||||
class Ajv extends core_1.default {
|
||||
constructor(opts = {}) {
|
||||
var _a;
|
||||
super({
|
||||
...opts,
|
||||
jtd: true,
|
||||
messages: (_a = opts.messages) !== null && _a !== void 0 ? _a : false,
|
||||
});
|
||||
}
|
||||
_addVocabularies() {
|
||||
super._addVocabularies();
|
||||
this.addVocabulary(jtd_1.default);
|
||||
}
|
||||
_addDefaultMetaSchema() {
|
||||
super._addDefaultMetaSchema();
|
||||
if (!this.opts.meta)
|
||||
return;
|
||||
this.addMetaSchema(jtd_schema_1.default, META_SCHEMA_ID, false);
|
||||
}
|
||||
defaultMeta() {
|
||||
return (this.opts.defaultMeta =
|
||||
super.defaultMeta() || (this.getSchema(META_SCHEMA_ID) ? META_SCHEMA_ID : undefined));
|
||||
}
|
||||
}
|
||||
exports.default = Ajv;
|
||||
//# sourceMappingURL=jtd.js.map
|
||||
Generated
Vendored
+118
@@ -0,0 +1,118 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const shared = (root) => {
|
||||
const sch = {
|
||||
nullable: { type: "boolean" },
|
||||
metadata: {
|
||||
optionalProperties: {
|
||||
union: { elements: { ref: "schema" } },
|
||||
},
|
||||
additionalProperties: true,
|
||||
},
|
||||
};
|
||||
if (root)
|
||||
sch.definitions = { values: { ref: "schema" } };
|
||||
return sch;
|
||||
};
|
||||
const emptyForm = (root) => ({
|
||||
optionalProperties: shared(root),
|
||||
});
|
||||
const refForm = (root) => ({
|
||||
properties: {
|
||||
ref: { type: "string" },
|
||||
},
|
||||
optionalProperties: shared(root),
|
||||
});
|
||||
const typeForm = (root) => ({
|
||||
properties: {
|
||||
type: {
|
||||
enum: [
|
||||
"boolean",
|
||||
"timestamp",
|
||||
"string",
|
||||
"float32",
|
||||
"float64",
|
||||
"int8",
|
||||
"uint8",
|
||||
"int16",
|
||||
"uint16",
|
||||
"int32",
|
||||
"uint32",
|
||||
],
|
||||
},
|
||||
},
|
||||
optionalProperties: shared(root),
|
||||
});
|
||||
const enumForm = (root) => ({
|
||||
properties: {
|
||||
enum: { elements: { type: "string" } },
|
||||
},
|
||||
optionalProperties: shared(root),
|
||||
});
|
||||
const elementsForm = (root) => ({
|
||||
properties: {
|
||||
elements: { ref: "schema" },
|
||||
},
|
||||
optionalProperties: shared(root),
|
||||
});
|
||||
const propertiesForm = (root) => ({
|
||||
properties: {
|
||||
properties: { values: { ref: "schema" } },
|
||||
},
|
||||
optionalProperties: {
|
||||
optionalProperties: { values: { ref: "schema" } },
|
||||
additionalProperties: { type: "boolean" },
|
||||
...shared(root),
|
||||
},
|
||||
});
|
||||
const optionalPropertiesForm = (root) => ({
|
||||
properties: {
|
||||
optionalProperties: { values: { ref: "schema" } },
|
||||
},
|
||||
optionalProperties: {
|
||||
additionalProperties: { type: "boolean" },
|
||||
...shared(root),
|
||||
},
|
||||
});
|
||||
const discriminatorForm = (root) => ({
|
||||
properties: {
|
||||
discriminator: { type: "string" },
|
||||
mapping: {
|
||||
values: {
|
||||
metadata: {
|
||||
union: [propertiesForm(false), optionalPropertiesForm(false)],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
optionalProperties: shared(root),
|
||||
});
|
||||
const valuesForm = (root) => ({
|
||||
properties: {
|
||||
values: { ref: "schema" },
|
||||
},
|
||||
optionalProperties: shared(root),
|
||||
});
|
||||
const schema = (root) => ({
|
||||
metadata: {
|
||||
union: [
|
||||
emptyForm,
|
||||
refForm,
|
||||
typeForm,
|
||||
enumForm,
|
||||
elementsForm,
|
||||
propertiesForm,
|
||||
optionalPropertiesForm,
|
||||
discriminatorForm,
|
||||
valuesForm,
|
||||
].map((s) => s(root)),
|
||||
},
|
||||
});
|
||||
const jtdMetaSchema = {
|
||||
definitions: {
|
||||
schema: schema(false),
|
||||
},
|
||||
...schema(true),
|
||||
};
|
||||
exports.default = jtdMetaSchema;
|
||||
//# sourceMappingURL=jtd-schema.js.map
|
||||
Generated
Vendored
+19
-5
@@ -40,9 +40,9 @@ function standaloneCode(ajv, refsOrFunc) {
|
||||
function validateCode(usedValues, s) {
|
||||
if (!s)
|
||||
throw new Error('moduleCode: function does not have "source" property');
|
||||
const { prefix } = s.validateName;
|
||||
const nameSet = (usedValues[prefix] = usedValues[prefix] || new Set());
|
||||
nameSet.add(s.validateName);
|
||||
if (usedState(s.validateName) === scope_1.UsedValueState.Completed)
|
||||
return code_1.nil;
|
||||
setUsedState(s.validateName, scope_1.UsedValueState.Started);
|
||||
const scopeCode = ajv.scope.scopeCode(s.scopeValues, usedValues, refValidateCode);
|
||||
const code = new code_1._Code(`${scopeCode}${_n}${s.validateCode}`);
|
||||
return s.evaluated ? code_1._ `${code}${s.validateName}.evaluated = ${s.evaluated};${_n}` : code;
|
||||
@@ -55,12 +55,26 @@ function standaloneCode(ajv, refsOrFunc) {
|
||||
}
|
||||
else if ((n.prefix === "root" || n.prefix === "wrapper") && typeof vRef == "object") {
|
||||
const { validate, validateName } = vRef;
|
||||
const vCode = validateCode(usedValues, validate === null || validate === void 0 ? void 0 : validate.source);
|
||||
if (!validateName)
|
||||
throw new Error("ajv internal error");
|
||||
const def = ajv.opts.code.es5 ? scope_1.varKinds.var : scope_1.varKinds.const;
|
||||
return code_1._ `${def} ${n} = {validate: ${validateName}};${_n}${vCode}`;
|
||||
const wrapper = code_1._ `${def} ${n} = {validate: ${validateName}};`;
|
||||
if (usedState(validateName) === scope_1.UsedValueState.Started)
|
||||
return wrapper;
|
||||
const vCode = validateCode(usedValues, validate === null || validate === void 0 ? void 0 : validate.source);
|
||||
return code_1._ `${wrapper}${_n}${vCode}`;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
function usedState(name) {
|
||||
var _a;
|
||||
return (_a = usedValues[name.prefix]) === null || _a === void 0 ? void 0 : _a.get(name);
|
||||
}
|
||||
function setUsedState(name, state) {
|
||||
const { prefix } = name;
|
||||
const names = (usedValues[prefix] = usedValues[prefix] || new Map());
|
||||
names.set(name, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.default = standaloneCode;
|
||||
|
||||
Generated
Vendored
+7
-3
@@ -41,8 +41,13 @@ const def = {
|
||||
let definedProp;
|
||||
if (props.length > 8) {
|
||||
// TODO maybe an option instead of hard-coded 8?
|
||||
const hasProp = gen.scopeValue("func", {
|
||||
// eslint-disable-next-line @typescript-eslint/unbound-method
|
||||
ref: Object.prototype.hasOwnProperty,
|
||||
code: codegen_1._ `Object.prototype.hasOwnProperty`,
|
||||
});
|
||||
const propsSchema = util_1.schemaRefOrVal(it, parentSchema.properties, "properties");
|
||||
definedProp = codegen_1._ `${propsSchema}.hasOwnProperty(${key})`;
|
||||
definedProp = codegen_1._ `${hasProp}.call(${propsSchema}, ${key})`;
|
||||
}
|
||||
else if (props.length) {
|
||||
definedProp = codegen_1.or(...props.map((p) => codegen_1._ `${key} === ${p}`));
|
||||
@@ -53,7 +58,7 @@ const def = {
|
||||
if (patProps.length) {
|
||||
definedProp = codegen_1.or(definedProp, ...patProps.map((p) => codegen_1._ `${code_1.usePattern(gen, p)}.test(${key})`));
|
||||
}
|
||||
return codegen_1._ `!(${definedProp})`;
|
||||
return codegen_1.not(definedProp);
|
||||
}
|
||||
function deleteAdditional(key) {
|
||||
gen.code(codegen_1._ `delete ${data}[${key}]`);
|
||||
@@ -91,7 +96,6 @@ const def = {
|
||||
keyword: "additionalProperties",
|
||||
dataProp: key,
|
||||
dataPropType: subschema_1.Type.Str,
|
||||
strictSchema: it.strictSchema,
|
||||
};
|
||||
if (errors === false) {
|
||||
Object.assign(subschema, {
|
||||
|
||||
Generated
Vendored
+2
-27
@@ -1,36 +1,11 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const codegen_1 = require("../../compile/codegen");
|
||||
const util_1 = require("../../compile/util");
|
||||
const code_1 = require("../code");
|
||||
const def = {
|
||||
keyword: "anyOf",
|
||||
schemaType: "array",
|
||||
trackErrors: true,
|
||||
code(cxt) {
|
||||
const { gen, schema, it } = cxt;
|
||||
/* istanbul ignore if */
|
||||
if (!Array.isArray(schema))
|
||||
throw new Error("ajv implementation error");
|
||||
const alwaysValid = schema.some((sch) => util_1.alwaysValidSchema(it, sch));
|
||||
if (alwaysValid && !it.opts.unevaluated)
|
||||
return;
|
||||
const valid = gen.let("valid", false);
|
||||
const schValid = gen.name("_valid");
|
||||
gen.block(() => schema.forEach((_sch, i) => {
|
||||
const schCxt = cxt.subschema({
|
||||
keyword: "anyOf",
|
||||
schemaProp: i,
|
||||
compositeRule: true,
|
||||
}, schValid);
|
||||
gen.assign(valid, codegen_1._ `${valid} || ${schValid}`);
|
||||
const merged = cxt.mergeValidEvaluated(schCxt, schValid);
|
||||
// can short-circuit if `unevaluatedProperties/Items` not supported (opts.unevaluated !== true)
|
||||
// or if all properties and items were evaluated (it.props === true && it.items === true)
|
||||
if (!merged)
|
||||
gen.if(codegen_1.not(valid));
|
||||
}));
|
||||
cxt.result(valid, () => cxt.reset(), () => cxt.error(true));
|
||||
},
|
||||
code: code_1.validateUnion,
|
||||
error: {
|
||||
message: "should match some schema in anyOf",
|
||||
},
|
||||
|
||||
Generated
Vendored
+8
-21
@@ -1,17 +1,16 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const codegen_1 = require("../../compile/codegen");
|
||||
const subschema_1 = require("../../compile/subschema");
|
||||
const util_1 = require("../../compile/util");
|
||||
const validate_1 = require("../../compile/validate");
|
||||
const code_1 = require("../code");
|
||||
const def = {
|
||||
keyword: "items",
|
||||
type: "array",
|
||||
schemaType: ["object", "array", "boolean"],
|
||||
before: "uniqueItems",
|
||||
code(cxt) {
|
||||
const { gen, schema, parentSchema, data, it } = cxt;
|
||||
const len = gen.const("len", codegen_1._ `${data}.length`);
|
||||
const { gen, schema, it } = cxt;
|
||||
if (Array.isArray(schema)) {
|
||||
if (it.opts.unevaluated && schema.length && it.items !== true) {
|
||||
it.items = util_1.mergeEvaluated.items(gen, schema.length, it.items);
|
||||
@@ -20,15 +19,18 @@ const def = {
|
||||
}
|
||||
else {
|
||||
it.items = true;
|
||||
if (!util_1.alwaysValidSchema(it, schema))
|
||||
validateArray();
|
||||
if (util_1.alwaysValidSchema(it, schema))
|
||||
return;
|
||||
cxt.ok(code_1.validateArray(cxt));
|
||||
}
|
||||
function validateTuple(schArr) {
|
||||
if (it.opts.strictTuples && !fullTupleSchema(schema.length, parentSchema)) {
|
||||
const { parentSchema, data } = cxt;
|
||||
if (it.opts.strictTuples && !fullTupleSchema(schArr.length, parentSchema)) {
|
||||
const msg = `"items" is ${schArr.length}-tuple, but minItems or maxItems/additionalItems are not specified or different`;
|
||||
validate_1.checkStrictMode(it, msg, it.opts.strictTuples);
|
||||
}
|
||||
const valid = gen.name("valid");
|
||||
const len = gen.const("len", codegen_1._ `${data}.length`);
|
||||
schArr.forEach((sch, i) => {
|
||||
if (util_1.alwaysValidSchema(it, sch))
|
||||
return;
|
||||
@@ -36,25 +38,10 @@ const def = {
|
||||
keyword: "items",
|
||||
schemaProp: i,
|
||||
dataProp: i,
|
||||
strictSchema: it.strictSchema,
|
||||
}, valid));
|
||||
cxt.ok(valid);
|
||||
});
|
||||
}
|
||||
function validateArray() {
|
||||
const valid = gen.name("valid");
|
||||
gen.forRange("i", 0, len, (i) => {
|
||||
cxt.subschema({
|
||||
keyword: "items",
|
||||
dataProp: i,
|
||||
dataPropType: subschema_1.Type.Num,
|
||||
strictSchema: it.strictSchema,
|
||||
}, valid);
|
||||
if (!it.allErrors)
|
||||
gen.if(codegen_1.not(valid), () => gen.break());
|
||||
});
|
||||
cxt.ok(valid);
|
||||
}
|
||||
},
|
||||
};
|
||||
function fullTupleSchema(len, sch) {
|
||||
|
||||
Generated
Vendored
-1
@@ -52,7 +52,6 @@ const def = {
|
||||
schemaProp: pat,
|
||||
dataProp: key,
|
||||
dataPropType: subschema_1.Type.Str,
|
||||
strictSchema: it.strictSchema,
|
||||
}, valid);
|
||||
if (it.opts.unevaluated && props !== true) {
|
||||
gen.assign(codegen_1._ `${props}[${key}]`, true);
|
||||
|
||||
Generated
Vendored
-1
@@ -42,7 +42,6 @@ const def = {
|
||||
keyword: "properties",
|
||||
schemaProp: prop,
|
||||
dataProp: prop,
|
||||
strictSchema: it.strictSchema,
|
||||
}, valid);
|
||||
}
|
||||
},
|
||||
|
||||
Generated
Vendored
-1
@@ -24,7 +24,6 @@ const def = {
|
||||
dataTypes: ["string"],
|
||||
propertyName: key,
|
||||
compositeRule: true,
|
||||
strictSchema: it.strictSchema,
|
||||
}, valid);
|
||||
gen.if(codegen_1.not(valid), () => {
|
||||
cxt.error(true);
|
||||
|
||||
Generated
Vendored
+52
-1
@@ -1,8 +1,9 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.usePattern = exports.callValidateCode = exports.schemaProperties = exports.allSchemaProperties = exports.noPropertyInData = exports.propertyInData = exports.reportMissingProp = exports.checkMissingProp = exports.checkReportMissingProp = void 0;
|
||||
exports.validateUnion = exports.validateArray = exports.usePattern = exports.callValidateCode = exports.schemaProperties = exports.allSchemaProperties = exports.noPropertyInData = exports.propertyInData = exports.reportMissingProp = exports.checkMissingProp = exports.checkReportMissingProp = void 0;
|
||||
const codegen_1 = require("../compile/codegen");
|
||||
const util_1 = require("../compile/util");
|
||||
const subschema_1 = require("../compile/subschema");
|
||||
const names_1 = require("../compile/names");
|
||||
function checkReportMissingProp(cxt, prop) {
|
||||
const { gen, data, it } = cxt;
|
||||
@@ -64,4 +65,54 @@ function usePattern(gen, pattern) {
|
||||
});
|
||||
}
|
||||
exports.usePattern = usePattern;
|
||||
function validateArray(cxt) {
|
||||
const { gen, data, keyword, it } = cxt;
|
||||
const valid = gen.name("valid");
|
||||
if (it.allErrors) {
|
||||
const validArr = gen.let("valid", true);
|
||||
validateItems(() => gen.assign(validArr, false));
|
||||
return validArr;
|
||||
}
|
||||
gen.var(valid, true);
|
||||
validateItems(() => gen.break());
|
||||
return valid;
|
||||
function validateItems(notValid) {
|
||||
const len = gen.const("len", codegen_1._ `${data}.length`);
|
||||
gen.forRange("i", 0, len, (i) => {
|
||||
cxt.subschema({
|
||||
keyword,
|
||||
dataProp: i,
|
||||
dataPropType: subschema_1.Type.Num,
|
||||
}, valid);
|
||||
gen.if(codegen_1.not(valid), notValid);
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.validateArray = validateArray;
|
||||
function validateUnion(cxt) {
|
||||
const { gen, schema, keyword, it } = cxt;
|
||||
/* istanbul ignore if */
|
||||
if (!Array.isArray(schema))
|
||||
throw new Error("ajv implementation error");
|
||||
const alwaysValid = schema.some((sch) => util_1.alwaysValidSchema(it, sch));
|
||||
if (alwaysValid && !it.opts.unevaluated)
|
||||
return;
|
||||
const valid = gen.let("valid", false);
|
||||
const schValid = gen.name("_valid");
|
||||
gen.block(() => schema.forEach((_sch, i) => {
|
||||
const schCxt = cxt.subschema({
|
||||
keyword,
|
||||
schemaProp: i,
|
||||
compositeRule: true,
|
||||
}, schValid);
|
||||
gen.assign(valid, codegen_1._ `${valid} || ${schValid}`);
|
||||
const merged = cxt.mergeValidEvaluated(schCxt, schValid);
|
||||
// can short-circuit if `unevaluatedProperties/Items` not supported (opts.unevaluated !== true)
|
||||
// or if all properties and items were evaluated (it.props === true && it.items === true)
|
||||
if (!merged)
|
||||
gen.if(codegen_1.not(valid));
|
||||
}));
|
||||
cxt.result(valid, () => cxt.reset(), () => cxt.error(true));
|
||||
}
|
||||
exports.validateUnion = validateUnion;
|
||||
//# sourceMappingURL=code.js.map
|
||||
Generated
Vendored
+1
@@ -7,6 +7,7 @@ const core = [
|
||||
"$id",
|
||||
"$defs",
|
||||
"$vocabulary",
|
||||
{ keyword: "$comment" },
|
||||
"definitions",
|
||||
id_1.default,
|
||||
ref_1.default,
|
||||
|
||||
Generated
Vendored
-1
@@ -38,7 +38,6 @@ const def = {
|
||||
const valid = gen.name("valid");
|
||||
const schCxt = cxt.subschema({
|
||||
schema: sch,
|
||||
strictSchema: true,
|
||||
dataTypes: [],
|
||||
schemaPath: codegen_1.nil,
|
||||
topSchemaRef: schName,
|
||||
|
||||
tools/node_modules/eslint/node_modules/table/node_modules/ajv/dist/vocabularies/jtd/discriminator.js
Generated
Vendored
+38
@@ -0,0 +1,38 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const codegen_1 = require("../../compile/codegen");
|
||||
const metadata_1 = require("./metadata");
|
||||
const nullable_1 = require("./nullable");
|
||||
const def = {
|
||||
keyword: "discriminator",
|
||||
schemaType: "string",
|
||||
implements: ["mapping"],
|
||||
code(cxt) {
|
||||
metadata_1.checkMetadata(cxt);
|
||||
const { gen, data, schema, parentSchema } = cxt;
|
||||
const [valid, cond] = nullable_1.checkNullableObject(cxt, data);
|
||||
gen.if(cond, () => {
|
||||
const tag = gen.const("tag", codegen_1._ `${data}${codegen_1.getProperty(schema)}`);
|
||||
gen.if(codegen_1._ `typeof ${tag} == "string"`, () => {
|
||||
gen.if(false);
|
||||
for (const tagValue in parentSchema.mapping) {
|
||||
gen.elseIf(codegen_1._ `${tag} === ${tagValue}`);
|
||||
gen.assign(valid, applyTagSchema(tagValue));
|
||||
}
|
||||
gen.endIf();
|
||||
});
|
||||
});
|
||||
cxt.pass(valid);
|
||||
function applyTagSchema(schemaProp) {
|
||||
const _valid = gen.name("valid");
|
||||
cxt.subschema({
|
||||
keyword: "mapping",
|
||||
schemaProp,
|
||||
jtdDiscriminator: schema,
|
||||
}, _valid);
|
||||
return _valid;
|
||||
}
|
||||
},
|
||||
};
|
||||
exports.default = def;
|
||||
//# sourceMappingURL=discriminator.js.map
|
||||
Generated
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const util_1 = require("../../compile/util");
|
||||
const code_1 = require("../code");
|
||||
const codegen_1 = require("../../compile/codegen");
|
||||
const metadata_1 = require("./metadata");
|
||||
const nullable_1 = require("./nullable");
|
||||
const def = {
|
||||
keyword: "elements",
|
||||
schemaType: "object",
|
||||
code(cxt) {
|
||||
metadata_1.checkMetadata(cxt);
|
||||
const { gen, data, schema, it } = cxt;
|
||||
if (util_1.alwaysValidSchema(it, schema))
|
||||
return;
|
||||
const [valid, cond] = nullable_1.checkNullable(cxt, codegen_1.nil);
|
||||
gen.if(codegen_1.and(cond, codegen_1._ `Array.isArray(${data})`), () => gen.assign(valid, code_1.validateArray(cxt)));
|
||||
cxt.pass(valid);
|
||||
},
|
||||
};
|
||||
exports.default = def;
|
||||
//# sourceMappingURL=elements.js.map
|
||||
Generated
Vendored
+41
@@ -0,0 +1,41 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const codegen_1 = require("../../compile/codegen");
|
||||
const metadata_1 = require("./metadata");
|
||||
const def = {
|
||||
keyword: "enum",
|
||||
schemaType: "array",
|
||||
code(cxt) {
|
||||
metadata_1.checkMetadata(cxt);
|
||||
const { gen, data, schema, schemaValue, parentSchema, it } = cxt;
|
||||
if (schema.length === 0)
|
||||
throw new Error("enum must have non-empty array");
|
||||
if (schema.length !== new Set(schema).size)
|
||||
throw new Error("enum items must be unique");
|
||||
let valid;
|
||||
if (schema.length >= it.opts.loopEnum) {
|
||||
if (parentSchema.nullable) {
|
||||
valid = gen.let("valid", codegen_1._ `${data} === null`);
|
||||
gen.if(codegen_1.not(valid), loopEnum);
|
||||
}
|
||||
else {
|
||||
valid = gen.let("valid", false);
|
||||
loopEnum();
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* istanbul ignore if */
|
||||
if (!Array.isArray(schema))
|
||||
throw new Error("ajv implementation error");
|
||||
valid = codegen_1.or(...schema.map((value) => codegen_1._ `${data} === ${value}`));
|
||||
if (parentSchema.nullable)
|
||||
valid = codegen_1.or(codegen_1._ `${data} === null`, valid);
|
||||
}
|
||||
cxt.pass(valid);
|
||||
function loopEnum() {
|
||||
gen.forOf("v", schemaValue, (v) => gen.if(codegen_1._ `${valid} = ${data} === ${v}`, () => gen.break()));
|
||||
}
|
||||
},
|
||||
};
|
||||
exports.default = def;
|
||||
//# sourceMappingURL=enum.js.map
|
||||
Generated
Vendored
+30
@@ -0,0 +1,30 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
// import definitions from "./definitions"
|
||||
const ref_1 = require("./ref");
|
||||
const type_1 = require("./type");
|
||||
const enum_1 = require("./enum");
|
||||
const elements_1 = require("./elements");
|
||||
const properties_1 = require("./properties");
|
||||
const optionalProperties_1 = require("./optionalProperties");
|
||||
const discriminator_1 = require("./discriminator");
|
||||
const values_1 = require("./values");
|
||||
const union_1 = require("./union");
|
||||
const metadata_1 = require("./metadata");
|
||||
const jtdVocabulary = [
|
||||
"definitions",
|
||||
ref_1.default,
|
||||
type_1.default,
|
||||
enum_1.default,
|
||||
elements_1.default,
|
||||
properties_1.default,
|
||||
optionalProperties_1.default,
|
||||
discriminator_1.default,
|
||||
values_1.default,
|
||||
union_1.default,
|
||||
metadata_1.default,
|
||||
{ keyword: "additionalProperties", schemaType: "boolean" },
|
||||
{ keyword: "nullable", schemaType: "boolean" },
|
||||
];
|
||||
exports.default = jtdVocabulary;
|
||||
//# sourceMappingURL=index.js.map
|
||||
Generated
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.checkMetadata = void 0;
|
||||
const util_1 = require("../../compile/util");
|
||||
const def = {
|
||||
keyword: "metadata",
|
||||
schemaType: "object",
|
||||
code(cxt) {
|
||||
checkMetadata(cxt);
|
||||
const { gen, schema, it } = cxt;
|
||||
if (util_1.alwaysValidSchema(it, schema))
|
||||
return;
|
||||
const valid = gen.name("valid");
|
||||
cxt.subschema({ keyword: "metadata", jtdMetadata: true }, valid);
|
||||
cxt.ok(valid);
|
||||
},
|
||||
};
|
||||
function checkMetadata({ it, keyword }, metadata) {
|
||||
if (it.jtdMetadata !== metadata) {
|
||||
throw new Error(`JTD: "${keyword}" cannot be used in this schema location`);
|
||||
}
|
||||
}
|
||||
exports.checkMetadata = checkMetadata;
|
||||
exports.default = def;
|
||||
//# sourceMappingURL=metadata.js.map
|
||||
Generated
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.checkNullableObject = exports.checkNullable = void 0;
|
||||
const codegen_1 = require("../../compile/codegen");
|
||||
function checkNullable({ gen, data, parentSchema }, cond) {
|
||||
const valid = gen.name("valid");
|
||||
if (parentSchema.nullable) {
|
||||
gen.let(valid, codegen_1._ `${data} === null`);
|
||||
cond = codegen_1.not(valid);
|
||||
}
|
||||
else {
|
||||
gen.let(valid, false);
|
||||
}
|
||||
return [valid, cond];
|
||||
}
|
||||
exports.checkNullable = checkNullable;
|
||||
function checkNullableObject(cxt, cond) {
|
||||
const [valid, cond_] = checkNullable(cxt, cond);
|
||||
return [valid, codegen_1._ `${cond_} && typeof ${cxt.data} == "object" && !Array.isArray(${cxt.data})`];
|
||||
}
|
||||
exports.checkNullableObject = checkNullableObject;
|
||||
//# sourceMappingURL=nullable.js.map
|
||||
Generated
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const properties_1 = require("./properties");
|
||||
const def = {
|
||||
keyword: "optionalProperties",
|
||||
schemaType: "object",
|
||||
code(cxt) {
|
||||
if (cxt.parentSchema.properties)
|
||||
return;
|
||||
properties_1.validateProperties(cxt);
|
||||
},
|
||||
};
|
||||
exports.default = def;
|
||||
//# sourceMappingURL=optionalProperties.js.map
|
||||
Generated
Vendored
+123
@@ -0,0 +1,123 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.validateProperties = void 0;
|
||||
const code_1 = require("../code");
|
||||
const util_1 = require("../../compile/util");
|
||||
const codegen_1 = require("../../compile/codegen");
|
||||
const metadata_1 = require("./metadata");
|
||||
const nullable_1 = require("./nullable");
|
||||
const def = {
|
||||
keyword: "properties",
|
||||
schemaType: "object",
|
||||
code: validateProperties,
|
||||
};
|
||||
function validateProperties(cxt) {
|
||||
metadata_1.checkMetadata(cxt);
|
||||
const { gen, data, parentSchema, it } = cxt;
|
||||
const { additionalProperties, nullable } = parentSchema;
|
||||
if (it.jtdDiscriminator && nullable)
|
||||
throw new Error("JTD: nullable inside discriminator mapping");
|
||||
if (commonProperties()) {
|
||||
throw new Error("JTD: properties and optionalProperties have common members");
|
||||
}
|
||||
const [allProps, properties] = schemaProperties("properties");
|
||||
const [allOptProps, optProperties] = schemaProperties("optionalProperties");
|
||||
if (properties.length === 0 && optProperties.length === 0 && additionalProperties) {
|
||||
return;
|
||||
}
|
||||
const [valid, cond] = it.jtdDiscriminator === undefined
|
||||
? nullable_1.checkNullableObject(cxt, data)
|
||||
: [gen.let("valid", false), true];
|
||||
gen.if(cond, () => gen.assign(valid, true).block(() => {
|
||||
validateProps(properties, "properties", true);
|
||||
validateProps(optProperties, "optionalProperties");
|
||||
if (!additionalProperties)
|
||||
validateAdditional();
|
||||
}));
|
||||
cxt.pass(valid);
|
||||
function commonProperties() {
|
||||
const props = parentSchema.properties;
|
||||
const optProps = parentSchema.optionalProperties;
|
||||
if (!(props && optProps))
|
||||
return false;
|
||||
for (const p in props) {
|
||||
if (Object.prototype.hasOwnProperty.call(optProps, p))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function schemaProperties(keyword) {
|
||||
const schema = parentSchema[keyword];
|
||||
const allPs = schema ? code_1.allSchemaProperties(schema) : [];
|
||||
if (it.jtdDiscriminator && allPs.some((p) => p === it.jtdDiscriminator)) {
|
||||
throw new Error(`JTD: discriminator tag used in ${keyword}`);
|
||||
}
|
||||
const ps = allPs.filter((p) => !util_1.alwaysValidSchema(it, schema[p]));
|
||||
return [allPs, ps];
|
||||
}
|
||||
function validateProps(props, keyword, required) {
|
||||
const _valid = gen.var("valid");
|
||||
for (const prop of props) {
|
||||
gen.if(code_1.propertyInData(data, prop, it.opts.ownProperties), () => applyPropertySchema(prop, keyword, _valid), missingProperty);
|
||||
cxt.ok(_valid);
|
||||
}
|
||||
function missingProperty() {
|
||||
if (required) {
|
||||
gen.assign(_valid, false);
|
||||
cxt.error();
|
||||
}
|
||||
else {
|
||||
gen.assign(_valid, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
function applyPropertySchema(prop, keyword, _valid) {
|
||||
cxt.subschema({
|
||||
keyword,
|
||||
schemaProp: prop,
|
||||
dataProp: prop,
|
||||
}, _valid);
|
||||
}
|
||||
function validateAdditional() {
|
||||
gen.forIn("key", data, (key) => {
|
||||
const _allProps = it.jtdDiscriminator === undefined ? allProps : [it.jtdDiscriminator].concat(allProps);
|
||||
const addProp = isAdditional(key, _allProps, "properties");
|
||||
const addOptProp = isAdditional(key, allOptProps, "optionalProperties");
|
||||
const extra = addProp === true ? addOptProp : addOptProp === true ? addProp : codegen_1.and(addProp, addOptProp);
|
||||
gen.if(extra, () => {
|
||||
if (it.opts.removeAdditional) {
|
||||
gen.code(codegen_1._ `delete ${data}[${key}]`);
|
||||
}
|
||||
else {
|
||||
// cxt.setParams({additionalProperty: key})
|
||||
cxt.error();
|
||||
if (!it.opts.allErrors)
|
||||
gen.break();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
function isAdditional(key, props, keyword) {
|
||||
let additional;
|
||||
if (props.length > 8) {
|
||||
// TODO maybe an option instead of hard-coded 8?
|
||||
const propsSchema = util_1.schemaRefOrVal(it, parentSchema[keyword], keyword);
|
||||
const hasProp = gen.scopeValue("func", {
|
||||
// eslint-disable-next-line @typescript-eslint/unbound-method
|
||||
ref: Object.prototype.hasOwnProperty,
|
||||
code: codegen_1._ `Object.prototype.hasOwnProperty`,
|
||||
});
|
||||
additional = codegen_1._ `!${hasProp}.call(${propsSchema}, ${key})`;
|
||||
}
|
||||
else if (props.length) {
|
||||
additional = codegen_1.and(...props.map((p) => codegen_1._ `${key} !== ${p}`));
|
||||
}
|
||||
else {
|
||||
additional = true;
|
||||
}
|
||||
return additional;
|
||||
}
|
||||
}
|
||||
exports.validateProperties = validateProperties;
|
||||
exports.default = def;
|
||||
//# sourceMappingURL=properties.js.map
|
||||
Generated
Vendored
+64
@@ -0,0 +1,64 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const compile_1 = require("../../compile");
|
||||
const codegen_1 = require("../../compile/codegen");
|
||||
const error_classes_1 = require("../../compile/error_classes");
|
||||
const names_1 = require("../../compile/names");
|
||||
const ref_1 = require("../core/ref");
|
||||
const metadata_1 = require("./metadata");
|
||||
const def = {
|
||||
keyword: "ref",
|
||||
schemaType: "string",
|
||||
code(cxt) {
|
||||
metadata_1.checkMetadata(cxt);
|
||||
const { gen, data, schema: ref, parentSchema, it } = cxt;
|
||||
const { schemaEnv: { root }, } = it;
|
||||
const valid = gen.name("valid");
|
||||
if (parentSchema.nullable) {
|
||||
gen.var(valid, codegen_1._ `${data} === null`);
|
||||
gen.if(codegen_1.not(valid), validateJtdRef);
|
||||
}
|
||||
else {
|
||||
gen.var(valid, false);
|
||||
validateJtdRef();
|
||||
}
|
||||
cxt.ok(valid);
|
||||
function validateJtdRef() {
|
||||
var _a;
|
||||
const refSchema = (_a = root.schema.definitions) === null || _a === void 0 ? void 0 : _a[ref];
|
||||
if (!refSchema)
|
||||
throw new error_classes_1.MissingRefError("", ref, `No definition ${ref}`);
|
||||
if (hasRef(refSchema) || !it.opts.inlineRefs)
|
||||
callValidate(refSchema);
|
||||
else
|
||||
inlineRefSchema(refSchema);
|
||||
}
|
||||
function callValidate(schema) {
|
||||
const sch = compile_1.compileSchema.call(it.self, new compile_1.SchemaEnv({ schema, root }));
|
||||
const v = ref_1.getValidate(cxt, sch);
|
||||
const errsCount = gen.const("_errs", names_1.default.errors);
|
||||
ref_1.callRef(cxt, v, sch, sch.$async);
|
||||
gen.assign(valid, codegen_1._ `${errsCount} === ${names_1.default.errors}`);
|
||||
}
|
||||
function inlineRefSchema(schema) {
|
||||
const schName = gen.scopeValue("schema", it.opts.code.source === true ? { ref: schema, code: codegen_1.stringify(schema) } : { ref: schema });
|
||||
cxt.subschema({
|
||||
schema,
|
||||
dataTypes: [],
|
||||
schemaPath: codegen_1.nil,
|
||||
topSchemaRef: schName,
|
||||
errSchemaPath: `/definitions/${ref}`,
|
||||
}, valid);
|
||||
}
|
||||
function hasRef(schema) {
|
||||
for (const key in schema) {
|
||||
let sch;
|
||||
if (key === "ref" || (typeof (sch = schema[key]) == "object" && hasRef(sch)))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
},
|
||||
};
|
||||
exports.default = def;
|
||||
//# sourceMappingURL=ref.js.map
|
||||
Generated
Vendored
+47
@@ -0,0 +1,47 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const codegen_1 = require("../../compile/codegen");
|
||||
const timestamp_1 = require("../../compile/timestamp");
|
||||
const metadata_1 = require("./metadata");
|
||||
const intRange = {
|
||||
int8: [-128, 127],
|
||||
uint8: [0, 255],
|
||||
int16: [-32768, 32767],
|
||||
uint16: [0, 65535],
|
||||
int32: [-2147483648, 2147483647],
|
||||
uint32: [0, 4294967295],
|
||||
};
|
||||
const def = {
|
||||
keyword: "type",
|
||||
schemaType: "string",
|
||||
code(cxt) {
|
||||
metadata_1.checkMetadata(cxt);
|
||||
const { gen, data, schema, parentSchema } = cxt;
|
||||
let cond;
|
||||
switch (schema) {
|
||||
case "boolean":
|
||||
case "string":
|
||||
cond = codegen_1._ `typeof ${data} == ${schema}`;
|
||||
break;
|
||||
case "timestamp": {
|
||||
const vts = gen.scopeValue("func", {
|
||||
ref: timestamp_1.default,
|
||||
code: codegen_1._ `require("ajv/dist/compile/timestamp").default`,
|
||||
});
|
||||
cond = codegen_1._ `${data} instanceof Date || (typeof ${data} == "string" && ${vts}(${data}))`;
|
||||
break;
|
||||
}
|
||||
case "float32":
|
||||
case "float64":
|
||||
cond = codegen_1._ `typeof ${data} == "number"`;
|
||||
break;
|
||||
default: {
|
||||
const [min, max] = intRange[schema];
|
||||
cond = codegen_1._ `typeof ${data} == "number" && isFinite(${data}) && ${data} >= ${min} && ${data} <= ${max} && !(${data} % 1)`;
|
||||
}
|
||||
}
|
||||
cxt.pass(parentSchema.nullable ? codegen_1.or(codegen_1._ `${data} === null`, cond) : cond);
|
||||
},
|
||||
};
|
||||
exports.default = def;
|
||||
//# sourceMappingURL=type.js.map
|
||||
Generated
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const code_1 = require("../code");
|
||||
const def = {
|
||||
keyword: "union",
|
||||
schemaType: "array",
|
||||
trackErrors: true,
|
||||
code: code_1.validateUnion,
|
||||
};
|
||||
exports.default = def;
|
||||
//# sourceMappingURL=union.js.map
|
||||
Generated
Vendored
+43
@@ -0,0 +1,43 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const subschema_1 = require("../../compile/subschema");
|
||||
const util_1 = require("../../compile/util");
|
||||
const codegen_1 = require("../../compile/codegen");
|
||||
const metadata_1 = require("./metadata");
|
||||
const nullable_1 = require("./nullable");
|
||||
const def = {
|
||||
keyword: "values",
|
||||
schemaType: "object",
|
||||
code(cxt) {
|
||||
metadata_1.checkMetadata(cxt);
|
||||
const { gen, data, schema, it } = cxt;
|
||||
if (util_1.alwaysValidSchema(it, schema))
|
||||
return;
|
||||
const [valid, cond] = nullable_1.checkNullableObject(cxt, data);
|
||||
gen.if(cond, () => gen.assign(valid, validateMap()));
|
||||
cxt.pass(valid);
|
||||
function validateMap() {
|
||||
const _valid = gen.name("valid");
|
||||
if (it.allErrors) {
|
||||
const validMap = gen.let("valid", true);
|
||||
validateValues(() => gen.assign(validMap, false));
|
||||
return validMap;
|
||||
}
|
||||
gen.var(_valid, true);
|
||||
validateValues(() => gen.break());
|
||||
return _valid;
|
||||
function validateValues(notValid) {
|
||||
gen.forIn("key", data, (key) => {
|
||||
cxt.subschema({
|
||||
keyword: "values",
|
||||
dataProp: key,
|
||||
dataPropType: subschema_1.Type.Str,
|
||||
}, _valid);
|
||||
gen.if(codegen_1.not(_valid), notValid);
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
exports.default = def;
|
||||
//# sourceMappingURL=values.js.map
|
||||
Generated
Vendored
-1
@@ -44,7 +44,6 @@ const def = {
|
||||
keyword: "unevaluatedProperties",
|
||||
dataProp: key,
|
||||
dataPropType: subschema_1.Type.Str,
|
||||
strictSchema: it.strictSchema,
|
||||
}, valid);
|
||||
if (!allErrors)
|
||||
gen.if(codegen_1.not(valid), () => gen.break());
|
||||
|
||||
Generated
Vendored
+1
@@ -24,6 +24,7 @@ const validation = [
|
||||
limitItems_1.default,
|
||||
uniqueItems_1.default,
|
||||
// any
|
||||
{ keyword: "type", schemaType: ["string", "array"] },
|
||||
{ keyword: "nullable", schemaType: "boolean" },
|
||||
const_1.default,
|
||||
enum_1.default,
|
||||
|
||||
+4
-4
@@ -33,7 +33,7 @@
|
||||
"eslint": "^7.8.1",
|
||||
"eslint-config-prettier": "^7.0.0",
|
||||
"glob": "^7.0.0",
|
||||
"husky": "^4.2.5",
|
||||
"husky": "^5.0.9",
|
||||
"if-node-version": "^1.0.0",
|
||||
"js-beautify": "^1.7.3",
|
||||
"json-schema-test": "^2.0.0",
|
||||
@@ -98,8 +98,8 @@
|
||||
"url": "git+https://github.com/ajv-validator/ajv.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rm -rf dist && tsc && cp -r lib/refs dist && rm dist/refs/json-schema-2019-09/index.ts",
|
||||
"bundle": "rm -rf bundle && node ./scripts/bundle.js ajv ajv7 ajv7 && node ./scripts/bundle.js 2019 ajv2019 ajv2019",
|
||||
"build": "rm -rf dist && tsc && cp -r lib/refs dist && rm dist/refs/json-schema-2019-09/index.ts && rm dist/refs/jtd-schema.ts",
|
||||
"bundle": "rm -rf bundle && node ./scripts/bundle.js ajv ajv7 ajv7 && node ./scripts/bundle.js 2019 ajv2019 ajv2019 && node ./scripts/bundle.js jtd ajvJTD ajvJTD",
|
||||
"eslint": "eslint \"lib/**/*.ts\" \"spec/**/*.*s\" scripts --ignore-pattern spec/JSON-Schema-Test-Suite",
|
||||
"json-tests": "rm -rf spec/_json/*.js && node scripts/jsontests",
|
||||
"prepublish": "npm run build",
|
||||
@@ -117,5 +117,5 @@
|
||||
},
|
||||
"tonicExampleFilename": ".tonic_example.js",
|
||||
"types": "dist/ajv.d.ts",
|
||||
"version": "7.0.3"
|
||||
"version": "7.1.0"
|
||||
}
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
"url": "http://blog.izs.me"
|
||||
},
|
||||
"bin": {
|
||||
"node-which": "./bin/node-which"
|
||||
"node-which": "bin/node-which"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/isaacs/node-which/issues"
|
||||
|
||||
+3
-3
@@ -11,7 +11,7 @@
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"@babel/code-frame": "^7.0.0",
|
||||
"@babel/code-frame": "7.12.11",
|
||||
"@eslint/eslintrc": "^0.3.0",
|
||||
"ajv": "^6.10.0",
|
||||
"chalk": "^4.0.0",
|
||||
@@ -24,7 +24,7 @@
|
||||
"eslint-utils": "^2.1.0",
|
||||
"eslint-visitor-keys": "^2.0.0",
|
||||
"espree": "^7.3.1",
|
||||
"esquery": "^1.2.0",
|
||||
"esquery": "^1.4.0",
|
||||
"esutils": "^2.0.2",
|
||||
"file-entry-cache": "^6.0.0",
|
||||
"functional-red-black-tree": "^1.0.1",
|
||||
@@ -154,5 +154,5 @@
|
||||
"test:cli": "mocha",
|
||||
"webpack": "node Makefile.js webpack"
|
||||
},
|
||||
"version": "7.19.0"
|
||||
"version": "7.20.0"
|
||||
}
|
||||
Reference in new issue
Block a user