X-Git-Url: https://git.josue.xyz/?p=dotfiles%2F.git;a=blobdiff_plain;f=.config%2Fcoc%2Fextensions%2Fnode_modules%2Fcoc-prettier%2Fnode_modules%2Ftable%2Fnode_modules%2Fajv%2Fdist%2Fcompile%2Fvalidate%2Findex.js;h=708c6922c712455a864b99efa111606cfd02e021;hp=074ff49b89b9292f2556ed9ffb1d5a8cb009fb1a;hb=3be0a9efc698a9570a44456009afc6014812625a;hpb=d2f432cc757f42f0318fdddcab8c00b240d47088 diff --git a/.config/coc/extensions/node_modules/coc-prettier/node_modules/table/node_modules/ajv/dist/compile/validate/index.js b/.config/coc/extensions/node_modules/coc-prettier/node_modules/table/node_modules/ajv/dist/compile/validate/index.js index 074ff49b..708c6922 100644 --- a/.config/coc/extensions/node_modules/coc-prettier/node_modules/table/node_modules/ajv/dist/compile/validate/index.js +++ b/.config/coc/extensions/node_modules/coc-prettier/node_modules/table/node_modules/ajv/dist/compile/validate/index.js @@ -22,39 +22,39 @@ function validateFunctionCode(it) { return; } } - validateFunction(it, () => boolSchema_1.topBoolOrEmptySchema(it)); + validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it)); } exports.validateFunctionCode = validateFunctionCode; function validateFunction({ gen, validateName, schema, schemaEnv, opts }, body) { if (opts.code.es5) { - gen.func(validateName, codegen_1._ `${names_1.default.data}, ${names_1.default.valCxt}`, schemaEnv.$async, () => { - gen.code(codegen_1._ `"use strict"; ${funcSourceUrl(schema, opts)}`); + gen.func(validateName, (0, codegen_1._) `${names_1.default.data}, ${names_1.default.valCxt}`, schemaEnv.$async, () => { + gen.code((0, codegen_1._) `"use strict"; ${funcSourceUrl(schema, opts)}`); destructureValCxtES5(gen, opts); gen.code(body); }); } else { - gen.func(validateName, codegen_1._ `${names_1.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body)); + gen.func(validateName, (0, codegen_1._) `${names_1.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body)); } } function destructureValCxt(opts) { - return codegen_1._ `{${names_1.default.instancePath}="", ${names_1.default.parentData}, ${names_1.default.parentDataProperty}, ${names_1.default.rootData}=${names_1.default.data}${opts.dynamicRef ? codegen_1._ `, ${names_1.default.dynamicAnchors}={}` : codegen_1.nil}}={}`; + return (0, codegen_1._) `{${names_1.default.instancePath}="", ${names_1.default.parentData}, ${names_1.default.parentDataProperty}, ${names_1.default.rootData}=${names_1.default.data}${opts.dynamicRef ? (0, codegen_1._) `, ${names_1.default.dynamicAnchors}={}` : codegen_1.nil}}={}`; } function destructureValCxtES5(gen, opts) { gen.if(names_1.default.valCxt, () => { - gen.var(names_1.default.instancePath, codegen_1._ `${names_1.default.valCxt}.${names_1.default.instancePath}`); - gen.var(names_1.default.parentData, codegen_1._ `${names_1.default.valCxt}.${names_1.default.parentData}`); - gen.var(names_1.default.parentDataProperty, codegen_1._ `${names_1.default.valCxt}.${names_1.default.parentDataProperty}`); - gen.var(names_1.default.rootData, codegen_1._ `${names_1.default.valCxt}.${names_1.default.rootData}`); + gen.var(names_1.default.instancePath, (0, codegen_1._) `${names_1.default.valCxt}.${names_1.default.instancePath}`); + gen.var(names_1.default.parentData, (0, codegen_1._) `${names_1.default.valCxt}.${names_1.default.parentData}`); + gen.var(names_1.default.parentDataProperty, (0, codegen_1._) `${names_1.default.valCxt}.${names_1.default.parentDataProperty}`); + gen.var(names_1.default.rootData, (0, codegen_1._) `${names_1.default.valCxt}.${names_1.default.rootData}`); if (opts.dynamicRef) - gen.var(names_1.default.dynamicAnchors, codegen_1._ `${names_1.default.valCxt}.${names_1.default.dynamicAnchors}`); + gen.var(names_1.default.dynamicAnchors, (0, codegen_1._) `${names_1.default.valCxt}.${names_1.default.dynamicAnchors}`); }, () => { - gen.var(names_1.default.instancePath, codegen_1._ `""`); - gen.var(names_1.default.parentData, codegen_1._ `undefined`); - gen.var(names_1.default.parentDataProperty, codegen_1._ `undefined`); + gen.var(names_1.default.instancePath, (0, codegen_1._) `""`); + gen.var(names_1.default.parentData, (0, codegen_1._) `undefined`); + gen.var(names_1.default.parentDataProperty, (0, codegen_1._) `undefined`); gen.var(names_1.default.rootData, names_1.default.data); if (opts.dynamicRef) - gen.var(names_1.default.dynamicAnchors, codegen_1._ `{}`); + gen.var(names_1.default.dynamicAnchors, (0, codegen_1._) `{}`); }); } function topSchemaObjCode(it) { @@ -75,14 +75,13 @@ function topSchemaObjCode(it) { function resetEvaluated(it) { // TODO maybe some hook to execute it in the end to check whether props/items are Name, as in assignEvaluated const { gen, validateName } = it; - it.evaluated = gen.const("evaluated", codegen_1._ `${validateName}.evaluated`); - gen.if(codegen_1._ `${it.evaluated}.dynamicProps`, () => gen.assign(codegen_1._ `${it.evaluated}.props`, codegen_1._ `undefined`)); - gen.if(codegen_1._ `${it.evaluated}.dynamicItems`, () => gen.assign(codegen_1._ `${it.evaluated}.items`, codegen_1._ `undefined`)); + it.evaluated = gen.const("evaluated", (0, codegen_1._) `${validateName}.evaluated`); + gen.if((0, codegen_1._) `${it.evaluated}.dynamicProps`, () => gen.assign((0, codegen_1._) `${it.evaluated}.props`, (0, codegen_1._) `undefined`)); + gen.if((0, codegen_1._) `${it.evaluated}.dynamicItems`, () => gen.assign((0, codegen_1._) `${it.evaluated}.items`, (0, codegen_1._) `undefined`)); } function funcSourceUrl(schema, opts) { - return typeof schema == "object" && schema.$id && (opts.code.source || opts.code.process) - ? codegen_1._ `/*# sourceURL=${schema.$id} */` - : codegen_1.nil; + const schId = typeof schema == "object" && schema[opts.schemaId]; + return schId && (opts.code.source || opts.code.process) ? (0, codegen_1._) `/*# sourceURL=${schId} */` : codegen_1.nil; } // schema compilation - this function is used recursively to generate code for sub-schemas function subschemaCode(it, valid) { @@ -93,7 +92,7 @@ function subschemaCode(it, valid) { return; } } - boolSchema_1.boolOrEmptySchema(it, valid); + (0, boolSchema_1.boolOrEmptySchema)(it, valid); } function schemaCxtHasRules({ schema, self }) { if (typeof schema == "boolean") @@ -115,34 +114,35 @@ function subSchemaObjCode(it, valid) { const errsCount = gen.const("_errs", names_1.default.errors); typeAndKeywords(it, errsCount); // TODO var - gen.var(valid, codegen_1._ `${errsCount} === ${names_1.default.errors}`); + gen.var(valid, (0, codegen_1._) `${errsCount} === ${names_1.default.errors}`); } function checkKeywords(it) { - util_1.checkUnknownRules(it); + (0, util_1.checkUnknownRules)(it); checkRefsAndKeywords(it); } function typeAndKeywords(it, errsCount) { if (it.opts.jtd) return schemaKeywords(it, [], false, errsCount); - const types = dataType_1.getSchemaTypes(it.schema); - const checkedTypes = dataType_1.coerceAndCheckDataType(it, types); + const types = (0, dataType_1.getSchemaTypes)(it.schema); + const checkedTypes = (0, dataType_1.coerceAndCheckDataType)(it, types); schemaKeywords(it, types, !checkedTypes, errsCount); } function checkRefsAndKeywords(it) { const { schema, errSchemaPath, opts, self } = it; - if (schema.$ref && opts.ignoreKeywordsWithRef && util_1.schemaHasRulesButRef(schema, self.RULES)) { + if (schema.$ref && opts.ignoreKeywordsWithRef && (0, util_1.schemaHasRulesButRef)(schema, self.RULES)) { self.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`); } } function checkNoDefault(it) { const { schema, opts } = it; if (schema.default !== undefined && opts.useDefaults && opts.strictSchema) { - util_1.checkStrictMode(it, "default is ignored in the schema root"); + (0, util_1.checkStrictMode)(it, "default is ignored in the schema root"); } } function updateContext(it) { - if (it.schema.$id) - it.baseId = resolve_1.resolveUrl(it.baseId, it.schema.$id); + const schId = it.schema[it.opts.schemaId]; + if (schId) + it.baseId = (0, resolve_1.resolveUrl)(it.baseId, schId); } function checkAsyncSchema(it) { if (it.schema.$async && !it.schemaEnv.$async) @@ -151,37 +151,37 @@ function checkAsyncSchema(it) { function commentKeyword({ gen, schemaEnv, schema, errSchemaPath, opts }) { const msg = schema.$comment; if (opts.$comment === true) { - gen.code(codegen_1._ `${names_1.default.self}.logger.log(${msg})`); + gen.code((0, codegen_1._) `${names_1.default.self}.logger.log(${msg})`); } else if (typeof opts.$comment == "function") { - const schemaPath = codegen_1.str `${errSchemaPath}/$comment`; + const schemaPath = (0, codegen_1.str) `${errSchemaPath}/$comment`; const rootName = gen.scopeValue("root", { ref: schemaEnv.root }); - gen.code(codegen_1._ `${names_1.default.self}.opts.$comment(${msg}, ${schemaPath}, ${rootName}.schema)`); + gen.code((0, codegen_1._) `${names_1.default.self}.opts.$comment(${msg}, ${schemaPath}, ${rootName}.schema)`); } } function returnResults(it) { const { gen, schemaEnv, validateName, ValidationError, opts } = it; if (schemaEnv.$async) { // TODO assign unevaluated - gen.if(codegen_1._ `${names_1.default.errors} === 0`, () => gen.return(names_1.default.data), () => gen.throw(codegen_1._ `new ${ValidationError}(${names_1.default.vErrors})`)); + gen.if((0, codegen_1._) `${names_1.default.errors} === 0`, () => gen.return(names_1.default.data), () => gen.throw((0, codegen_1._) `new ${ValidationError}(${names_1.default.vErrors})`)); } else { - gen.assign(codegen_1._ `${validateName}.errors`, names_1.default.vErrors); + gen.assign((0, codegen_1._) `${validateName}.errors`, names_1.default.vErrors); if (opts.unevaluated) assignEvaluated(it); - gen.return(codegen_1._ `${names_1.default.errors} === 0`); + gen.return((0, codegen_1._) `${names_1.default.errors} === 0`); } } function assignEvaluated({ gen, evaluated, props, items }) { if (props instanceof codegen_1.Name) - gen.assign(codegen_1._ `${evaluated}.props`, props); + gen.assign((0, codegen_1._) `${evaluated}.props`, props); if (items instanceof codegen_1.Name) - gen.assign(codegen_1._ `${evaluated}.items`, items); + gen.assign((0, codegen_1._) `${evaluated}.items`, items); } function schemaKeywords(it, types, typeErrors, errsCount) { const { gen, schema, data, allErrors, opts, self } = it; const { RULES } = self; - if (schema.$ref && (opts.ignoreKeywordsWithRef || !util_1.schemaHasRulesButRef(schema, RULES))) { + if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1.schemaHasRulesButRef)(schema, RULES))) { gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition)); // TODO typecast return; } @@ -193,14 +193,14 @@ function schemaKeywords(it, types, typeErrors, errsCount) { groupKeywords(RULES.post); }); function groupKeywords(group) { - if (!applicability_1.shouldUseGroup(schema, group)) + if (!(0, applicability_1.shouldUseGroup)(schema, group)) return; if (group.type) { - gen.if(dataType_2.checkDataType(group.type, data, opts.strictNumbers)); + gen.if((0, dataType_2.checkDataType)(group.type, data, opts.strictNumbers)); iterateKeywords(it, group); if (types.length === 1 && types[0] === group.type && typeErrors) { gen.else(); - dataType_2.reportTypeError(it); + (0, dataType_2.reportTypeError)(it); } gen.endIf(); } @@ -209,16 +209,16 @@ function schemaKeywords(it, types, typeErrors, errsCount) { } // TODO make it "ok" call? if (!allErrors) - gen.if(codegen_1._ `${names_1.default.errors} === ${errsCount || 0}`); + gen.if((0, codegen_1._) `${names_1.default.errors} === ${errsCount || 0}`); } } function iterateKeywords(it, group) { const { gen, schema, opts: { useDefaults }, } = it; if (useDefaults) - defaults_1.assignDefaults(it, group.type); + (0, defaults_1.assignDefaults)(it, group.type); gen.block(() => { for (const rule of group.rules) { - if (applicability_1.shouldUseRule(schema, rule)) { + if ((0, applicability_1.shouldUseRule)(schema, rule)) { keywordCode(it, rule.keyword, rule.definition, group.type); } } @@ -255,7 +255,7 @@ function checkKeywordTypes(it, ts) { const rules = it.self.RULES.all; for (const keyword in rules) { const rule = rules[keyword]; - if (typeof rule == "object" && applicability_1.shouldUseRule(it.schema, rule)) { + if (typeof rule == "object" && (0, applicability_1.shouldUseRule)(it.schema, rule)) { const { type } = rule.definition; if (type.length && !type.some((t) => hasApplicableType(ts, t))) { strictTypesError(it, `missing type "${type.join(",")}" for keyword "${keyword}"`); @@ -272,18 +272,18 @@ function includesType(ts, t) { function strictTypesError(it, msg) { const schemaPath = it.schemaEnv.baseId + it.errSchemaPath; msg += ` at "${schemaPath}" (strictTypes)`; - util_1.checkStrictMode(it, msg, it.opts.strictTypes); + (0, util_1.checkStrictMode)(it, msg, it.opts.strictTypes); } class KeywordCxt { constructor(it, def, keyword) { - keyword_1.validateKeywordUsage(it, def, keyword); + (0, keyword_1.validateKeywordUsage)(it, def, keyword); this.gen = it.gen; this.allErrors = it.allErrors; this.keyword = keyword; this.data = it.data; this.schema = it.schema[keyword]; this.$data = def.$data && it.opts.$data && this.schema && this.schema.$data; - this.schemaValue = util_1.schemaRefOrVal(it, this.schema, keyword, this.$data); + this.schemaValue = (0, util_1.schemaRefOrVal)(it, this.schema, keyword, this.$data); this.schemaType = def.schemaType; this.parentSchema = it.schema; this.params = {}; @@ -294,7 +294,7 @@ class KeywordCxt { } else { this.schemaCode = this.schemaValue; - if (!keyword_1.validSchemaType(this.schema, def.schemaType, def.allowUndefined)) { + if (!(0, keyword_1.validSchemaType)(this.schema, def.schemaType, def.allowUndefined)) { throw new Error(`${keyword} value must be ${JSON.stringify(def.schemaType)}`); } } @@ -303,7 +303,10 @@ class KeywordCxt { } } result(condition, successAction, failAction) { - this.gen.if(codegen_1.not(condition)); + this.failResult((0, codegen_1.not)(condition), successAction, failAction); + } + failResult(condition, successAction, failAction) { + this.gen.if(condition); if (failAction) failAction(); else @@ -322,7 +325,7 @@ class KeywordCxt { } } pass(condition, failAction) { - this.result(condition, undefined, failAction); + this.failResult((0, codegen_1.not)(condition), undefined, failAction); } fail(condition) { if (condition === undefined) { @@ -342,7 +345,7 @@ class KeywordCxt { if (!this.$data) return this.fail(condition); const { schemaCode } = this; - this.fail(codegen_1._ `${schemaCode} !== undefined && (${codegen_1.or(this.invalid$data(), condition)})`); + this.fail((0, codegen_1._) `${schemaCode} !== undefined && (${(0, codegen_1.or)(this.invalid$data(), condition)})`); } error(append, errorParams, errorPaths) { if (errorParams) { @@ -358,12 +361,12 @@ class KeywordCxt { (append ? errors_1.reportExtraError : errors_1.reportError)(this, this.def.error, errorPaths); } $dataError() { - errors_1.reportError(this, this.def.$dataError || errors_1.keyword$DataError); + (0, errors_1.reportError)(this, this.def.$dataError || errors_1.keyword$DataError); } reset() { if (this.errsCount === undefined) throw new Error('add "trackErrors" to keyword definition'); - errors_1.resetErrorsCount(this.gen, this.errsCount); + (0, errors_1.resetErrorsCount)(this.gen, this.errsCount); } ok(cond) { if (!this.allErrors) @@ -385,7 +388,7 @@ class KeywordCxt { if (!this.$data) return; const { gen, schemaCode, schemaType, def } = this; - gen.if(codegen_1.or(codegen_1._ `${schemaCode} === undefined`, $dataValid)); + gen.if((0, codegen_1.or)((0, codegen_1._) `${schemaCode} === undefined`, $dataValid)); if (valid !== codegen_1.nil) gen.assign(valid, true); if (schemaType.length || def.validateSchema) { @@ -398,29 +401,29 @@ class KeywordCxt { } invalid$data() { const { gen, schemaCode, schemaType, def, it } = this; - return codegen_1.or(wrong$DataType(), invalid$DataSchema()); + return (0, codegen_1.or)(wrong$DataType(), invalid$DataSchema()); function wrong$DataType() { if (schemaType.length) { /* istanbul ignore if */ if (!(schemaCode instanceof codegen_1.Name)) throw new Error("ajv implementation error"); const st = Array.isArray(schemaType) ? schemaType : [schemaType]; - return codegen_1._ `${dataType_2.checkDataTypes(st, schemaCode, it.opts.strictNumbers, dataType_2.DataType.Wrong)}`; + return (0, codegen_1._) `${(0, dataType_2.checkDataTypes)(st, schemaCode, it.opts.strictNumbers, dataType_2.DataType.Wrong)}`; } return codegen_1.nil; } function invalid$DataSchema() { if (def.validateSchema) { const validateSchemaRef = gen.scopeValue("validate$data", { ref: def.validateSchema }); // TODO value.code for standalone - return codegen_1._ `!${validateSchemaRef}(${schemaCode})`; + return (0, codegen_1._) `!${validateSchemaRef}(${schemaCode})`; } return codegen_1.nil; } } subschema(appl, valid) { - const subschema = subschema_1.getSubschema(this.it, appl); - subschema_1.extendSubschemaData(subschema, this.it, appl); - subschema_1.extendSubschemaMode(subschema, appl); + const subschema = (0, subschema_1.getSubschema)(this.it, appl); + (0, subschema_1.extendSubschemaData)(subschema, this.it, appl); + (0, subschema_1.extendSubschemaMode)(subschema, appl); const nextContext = { ...this.it, ...subschema, items: undefined, props: undefined }; subschemaCode(nextContext, valid); return nextContext; @@ -451,13 +454,13 @@ function keywordCode(it, keyword, def, ruleType) { def.code(cxt, ruleType); } else if (cxt.$data && def.validate) { - keyword_1.funcKeywordCode(cxt, def); + (0, keyword_1.funcKeywordCode)(cxt, def); } else if ("macro" in def) { - keyword_1.macroKeywordCode(cxt, def); + (0, keyword_1.macroKeywordCode)(cxt, def); } else if (def.compile || def.validate) { - keyword_1.funcKeywordCode(cxt, def); + (0, keyword_1.funcKeywordCode)(cxt, def); } } const JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/; @@ -494,8 +497,8 @@ function getData($data, { dataLevel, dataNames, dataPathArr }) { const segments = jsonPointer.split("/"); for (const segment of segments) { if (segment) { - data = codegen_1._ `${data}${codegen_1.getProperty(util_1.unescapeJsonPointer(segment))}`; - expr = codegen_1._ `${expr} && ${data}`; + data = (0, codegen_1._) `${data}${(0, codegen_1.getProperty)((0, util_1.unescapeJsonPointer)(segment))}`; + expr = (0, codegen_1._) `${expr} && ${data}`; } } return expr;