refactor: update all

This commit is contained in:
openstappsbot
2021-12-14 08:12:29 +00:00
committed by Rainer Killinger
parent 8cf40900bb
commit 0ca252b221
5 changed files with 1060 additions and 761 deletions

1746
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -45,53 +45,54 @@
"lint": "eslint -c .eslintrc.json --ignore-path .eslintignore --ext .ts src/"
},
"dependencies": {
"@openstapps/logger": "0.7.0",
"ajv": "8.6.3",
"better-ajv-errors": "0.7.0",
"@openstapps/logger": "0.8.0",
"ajv": "8.8.2",
"better-ajv-errors": "1.1.2",
"chai": "4.3.4",
"commander": "8.2.0",
"commander": "8.3.0",
"deepmerge": "4.2.2",
"del": "6.0.0",
"eslint": "7.32.0",
"flatted": "3.2.2",
"eslint": "8.4.1",
"flatted": "3.2.4",
"fs-extra": "10.0.0",
"glob": "7.2.0",
"got": "11.8.2",
"humanize-string": "2.1.0",
"json-schema": "0.3.0",
"got": "11.8.3",
"humanize-string": "3.0.0",
"json-schema": "0.4.0",
"lodash": "4.17.21",
"mustache": "4.2.0",
"openapi-types": "9.3.0",
"openapi-types": "10.0.0",
"plantuml-encoder": "1.4.0",
"re2": "1.17.1",
"toposort": "2.0.2",
"ts-json-schema-generator": "0.95.0",
"ts-node": "10.2.1",
"ts-json-schema-generator": "0.97.0",
"ts-node": "10.4.0",
"typescript": "4.4.3"
},
"devDependencies": {
"@openstapps/configuration": "0.28.1",
"@testdeck/mocha": "0.1.2",
"@types/chai": "4.2.22",
"@openstapps/configuration": "0.29.0",
"@testdeck/mocha": "0.2.0",
"@types/chai": "4.3.0",
"@types/fs-extra": "9.0.13",
"@types/glob": "7.1.4",
"@types/glob": "7.2.0",
"@types/json-schema": "7.0.9",
"@types/lodash": "4.14.175",
"@types/lodash": "4.14.178",
"@types/mocha": "9.0.0",
"@types/mustache": "4.1.2",
"@types/node": "14.17.19",
"@types/node": "14.18.0",
"@types/rimraf": "3.0.2",
"@typescript-eslint/eslint-plugin": "4.32.0",
"@typescript-eslint/parser": "4.32.0",
"@typescript-eslint/eslint-plugin": "5.7.0",
"@typescript-eslint/parser": "5.7.0",
"conventional-changelog-cli": "2.1.1",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-jsdoc": "36.1.0",
"eslint-plugin-jsdoc": "37.2.0",
"eslint-plugin-prettier": "4.0.0",
"eslint-plugin-unicorn": "36.0.0",
"mocha": "9.1.2",
"nock": "13.1.3",
"eslint-plugin-unicorn": "39.0.0",
"mocha": "9.1.3",
"nock": "13.2.1",
"prepend-file-cli": "1.0.6",
"prettier": "2.4.1",
"prettier": "2.5.1",
"rimraf": "3.0.2",
"typedoc": "0.22.4"
"typedoc": "0.22.10"
}
}

View File

@@ -24,6 +24,7 @@ import {definitionsOf} from './easy-ast/ast-util';
import {lightweightProjectFromPath} from './easy-ast/easy-ast';
import {isSchemaWithDefinitions} from './util/guards';
import path from 'path';
import re2 from './types/re2';
/**
* StAppsCore converter
@@ -65,7 +66,7 @@ export class Converter {
this.generator = new SchemaGenerator(program, createParser(program, config), createFormatter(config));
// create Ajv instance
this.schemaValidator = new Ajv();
this.schemaValidator = new Ajv({code: {regExp: re2}});
// eslint-disable-next-line @typescript-eslint/no-var-requires,unicorn/prefer-module
this.schemaValidator.addMetaSchema(require('ajv/lib/refs/json-schema-draft-06.json'));
}

6
src/types/re2.ts Normal file
View File

@@ -0,0 +1,6 @@
import re2 from 're2';
type Re2 = typeof re2 & {code: string};
(re2 as Re2).code = 'require("lib/types/re2").default';
export default re2 as Re2;

View File

@@ -23,6 +23,7 @@ import {globPromisified, readFilePromisified, writeFilePromisified} from './comm
import {ExpectedValidationErrors, ValidationError, ValidationResult} from './types/validator';
import {isThingWithType} from './util/guards';
import path from 'path';
import re2 from './types/re2';
/**
* StAppsCore validator
@@ -31,7 +32,11 @@ export class Validator {
/**
* JSON Schema Validator
*/
private readonly ajv = new Ajv({verbose: true});
private readonly ajv = new Ajv({
verbose: true,
ignoreKeywordsWithRef: true,
code: {regExp: re2},
});
/**
* Map of schema names to schemas
@@ -133,7 +138,7 @@ function fromAjvResult(
const betterErrorObject: betterAjvErrors.IOutputError[] | undefined = betterAjvErrors(
schema,
instance,
ajvInstance.errors,
ajvInstance.errors ?? [],
// eslint-disable-next-line unicorn/no-null
{format: 'js', indent: null},
);
@@ -145,10 +150,10 @@ function fromAjvResult(
dataPath: ajvError.instancePath,
instance: instance,
// eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
message: betterErrorObject?.[index].error!,
message: betterErrorObject?.[index]?.error! ?? ajvError.message,
name: ajvError.keyword,
schemaPath: ajvError.schemaPath,
suggestion: betterErrorObject?.[index].suggestion,
suggestion: betterErrorObject?.[index]?.suggestion,
};
// (validationError as ValidationError).humanReadableError = betterErrorCLI?.[index] as unknown as string;