From b579094387aadea19a54d248f496e3c324324b4f Mon Sep 17 00:00:00 2001 From: "jonas-lt@live.dk" Date: Tue, 1 Aug 2023 16:14:04 +0200 Subject: [PATCH 1/6] update dependency --- package-lock.json | 473 ++++++++++++++++++++++++++++++++++++++++++++-- package.json | 2 +- 2 files changed, 462 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index 91bb2d039..a4fb8d603 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "@asyncapi/avro-schema-parser": "^3.0.2", "@asyncapi/generator-react-sdk": "^0.2.23", "@asyncapi/openapi-schema-parser": "^3.0.3", - "@asyncapi/parser": "^2.0.3", + "@asyncapi/parser": "^2.1.0-next-major-spec.3", "@asyncapi/raml-dt-schema-parser": "^4.0.3", "@npmcli/arborist": "^2.2.4", "ajv": "^8.12.0", @@ -105,6 +105,92 @@ "avsc": "^5.7.6" } }, + "node_modules/@asyncapi/avro-schema-parser/node_modules/@asyncapi/parser": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@asyncapi/parser/-/parser-2.0.3.tgz", + "integrity": "sha512-2gtIQOaCz8sR70JFREpg6UwgUBboC/26JcAGySkXY/f1ayjcfDoNLi4LsDvmu6G21qLrGN2lI83i8iLG1AzTAw==", + "dependencies": { + "@asyncapi/specs": "^5.1.0", + "@openapi-contrib/openapi-schema-to-json-schema": "~3.2.0", + "@stoplight/json-ref-resolver": "^3.1.5", + "@stoplight/spectral-core": "^1.16.1", + "@stoplight/spectral-functions": "^1.7.2", + "@stoplight/spectral-parsers": "^1.0.2", + "@types/json-schema": "^7.0.11", + "@types/urijs": "^1.19.19", + "ajv": "^8.11.0", + "ajv-errors": "^3.0.0", + "ajv-formats": "^2.1.1", + "avsc": "^5.7.5", + "js-yaml": "^4.1.0", + "jsonpath-plus": "^7.2.0", + "node-fetch": "2.6.7", + "ramldt2jsonschema": "^1.2.3", + "webapi-parser": "^0.5.0" + } + }, + "node_modules/@asyncapi/avro-schema-parser/node_modules/@asyncapi/specs": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@asyncapi/specs/-/specs-5.1.0.tgz", + "integrity": "sha512-yffhETqehkim43luMnPKOwzY0D0YtU4bKpORIXIaid6p5Y5kDLrMGJaEPkNieQp03HMjhjFrnUPtT8kvqe0+aQ==", + "dependencies": { + "@types/json-schema": "^7.0.11" + } + }, + "node_modules/@asyncapi/avro-schema-parser/node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" + }, + "node_modules/@asyncapi/avro-schema-parser/node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/@asyncapi/avro-schema-parser/node_modules/node-fetch": { + "version": "2.6.7", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", + "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/@asyncapi/avro-schema-parser/node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + }, + "node_modules/@asyncapi/avro-schema-parser/node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + }, + "node_modules/@asyncapi/avro-schema-parser/node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, "node_modules/@asyncapi/generator-react-sdk": { "version": "0.2.25", "resolved": "https://registry.npmjs.org/@asyncapi/generator-react-sdk/-/generator-react-sdk-0.2.25.tgz", @@ -224,7 +310,7 @@ "ajv-formats": "^2.1.1" } }, - "node_modules/@asyncapi/parser": { + "node_modules/@asyncapi/openapi-schema-parser/node_modules/@asyncapi/parser": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/@asyncapi/parser/-/parser-2.0.3.tgz", "integrity": "sha512-2gtIQOaCz8sR70JFREpg6UwgUBboC/26JcAGySkXY/f1ayjcfDoNLi4LsDvmu6G21qLrGN2lI83i8iLG1AzTAw==", @@ -248,6 +334,92 @@ "webapi-parser": "^0.5.0" } }, + "node_modules/@asyncapi/openapi-schema-parser/node_modules/@asyncapi/specs": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@asyncapi/specs/-/specs-5.1.0.tgz", + "integrity": "sha512-yffhETqehkim43luMnPKOwzY0D0YtU4bKpORIXIaid6p5Y5kDLrMGJaEPkNieQp03HMjhjFrnUPtT8kvqe0+aQ==", + "dependencies": { + "@types/json-schema": "^7.0.11" + } + }, + "node_modules/@asyncapi/openapi-schema-parser/node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" + }, + "node_modules/@asyncapi/openapi-schema-parser/node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/@asyncapi/openapi-schema-parser/node_modules/node-fetch": { + "version": "2.6.7", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", + "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/@asyncapi/openapi-schema-parser/node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + }, + "node_modules/@asyncapi/openapi-schema-parser/node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + }, + "node_modules/@asyncapi/openapi-schema-parser/node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, + "node_modules/@asyncapi/parser": { + "version": "2.1.0-next-major-spec.3", + "resolved": "https://registry.npmjs.org/@asyncapi/parser/-/parser-2.1.0-next-major-spec.3.tgz", + "integrity": "sha512-xr9SkemAJEN4sRAWyASCP4Gg6pWVaf3WW8aGX145iWeXBp6tKp0cttUmU/kR3AxhMkBKMSCDCei5HIqAWnNaBg==", + "dependencies": { + "@asyncapi/specs": "^6.0.0-next-major-spec.2", + "@openapi-contrib/openapi-schema-to-json-schema": "~3.2.0", + "@stoplight/json-ref-resolver": "^3.1.5", + "@stoplight/spectral-core": "^1.16.1", + "@stoplight/spectral-functions": "^1.7.2", + "@stoplight/spectral-parsers": "^1.0.2", + "@types/json-schema": "^7.0.11", + "@types/urijs": "^1.19.19", + "ajv": "^8.11.0", + "ajv-errors": "^3.0.0", + "ajv-formats": "^2.1.1", + "avsc": "^5.7.5", + "js-yaml": "^4.1.0", + "jsonpath-plus": "^7.2.0", + "node-fetch": "2.6.7", + "ramldt2jsonschema": "^1.2.3", + "webapi-parser": "^0.5.0" + } + }, "node_modules/@asyncapi/parser/node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", @@ -313,6 +485,38 @@ "webapi-parser": "^0.5.0" } }, + "node_modules/@asyncapi/raml-dt-schema-parser/node_modules/@asyncapi/parser": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@asyncapi/parser/-/parser-2.0.3.tgz", + "integrity": "sha512-2gtIQOaCz8sR70JFREpg6UwgUBboC/26JcAGySkXY/f1ayjcfDoNLi4LsDvmu6G21qLrGN2lI83i8iLG1AzTAw==", + "dependencies": { + "@asyncapi/specs": "^5.1.0", + "@openapi-contrib/openapi-schema-to-json-schema": "~3.2.0", + "@stoplight/json-ref-resolver": "^3.1.5", + "@stoplight/spectral-core": "^1.16.1", + "@stoplight/spectral-functions": "^1.7.2", + "@stoplight/spectral-parsers": "^1.0.2", + "@types/json-schema": "^7.0.11", + "@types/urijs": "^1.19.19", + "ajv": "^8.11.0", + "ajv-errors": "^3.0.0", + "ajv-formats": "^2.1.1", + "avsc": "^5.7.5", + "js-yaml": "^4.1.0", + "jsonpath-plus": "^7.2.0", + "node-fetch": "2.6.7", + "ramldt2jsonschema": "^1.2.3", + "webapi-parser": "^0.5.0" + } + }, + "node_modules/@asyncapi/raml-dt-schema-parser/node_modules/@asyncapi/specs": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@asyncapi/specs/-/specs-5.1.0.tgz", + "integrity": "sha512-yffhETqehkim43luMnPKOwzY0D0YtU4bKpORIXIaid6p5Y5kDLrMGJaEPkNieQp03HMjhjFrnUPtT8kvqe0+aQ==", + "dependencies": { + "@types/json-schema": "^7.0.11" + } + }, "node_modules/@asyncapi/raml-dt-schema-parser/node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", @@ -329,10 +533,48 @@ "js-yaml": "bin/js-yaml.js" } }, + "node_modules/@asyncapi/raml-dt-schema-parser/node_modules/node-fetch": { + "version": "2.6.7", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", + "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/@asyncapi/raml-dt-schema-parser/node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + }, + "node_modules/@asyncapi/raml-dt-schema-parser/node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + }, + "node_modules/@asyncapi/raml-dt-schema-parser/node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, "node_modules/@asyncapi/specs": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/@asyncapi/specs/-/specs-5.1.0.tgz", - "integrity": "sha512-yffhETqehkim43luMnPKOwzY0D0YtU4bKpORIXIaid6p5Y5kDLrMGJaEPkNieQp03HMjhjFrnUPtT8kvqe0+aQ==", + "version": "6.0.0-next-major-spec.5", + "resolved": "https://registry.npmjs.org/@asyncapi/specs/-/specs-6.0.0-next-major-spec.5.tgz", + "integrity": "sha512-r8tSBydsyd48qdbArk3cGEWGCLf4YeulFRp4yNJ4HQkXhEmXE9eApdIF3umE3nnAYzsKz5EYZMxwHb+/UEX9wA==", "dependencies": { "@types/json-schema": "^7.0.11" } @@ -14769,6 +15011,80 @@ "@asyncapi/parser": "^2.0.3", "@types/json-schema": "^7.0.11", "avsc": "^5.7.6" + }, + "dependencies": { + "@asyncapi/parser": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@asyncapi/parser/-/parser-2.0.3.tgz", + "integrity": "sha512-2gtIQOaCz8sR70JFREpg6UwgUBboC/26JcAGySkXY/f1ayjcfDoNLi4LsDvmu6G21qLrGN2lI83i8iLG1AzTAw==", + "requires": { + "@asyncapi/specs": "^5.1.0", + "@openapi-contrib/openapi-schema-to-json-schema": "~3.2.0", + "@stoplight/json-ref-resolver": "^3.1.5", + "@stoplight/spectral-core": "^1.16.1", + "@stoplight/spectral-functions": "^1.7.2", + "@stoplight/spectral-parsers": "^1.0.2", + "@types/json-schema": "^7.0.11", + "@types/urijs": "^1.19.19", + "ajv": "^8.11.0", + "ajv-errors": "^3.0.0", + "ajv-formats": "^2.1.1", + "avsc": "^5.7.5", + "js-yaml": "^4.1.0", + "jsonpath-plus": "^7.2.0", + "node-fetch": "2.6.7", + "ramldt2jsonschema": "^1.2.3", + "webapi-parser": "^0.5.0" + } + }, + "@asyncapi/specs": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@asyncapi/specs/-/specs-5.1.0.tgz", + "integrity": "sha512-yffhETqehkim43luMnPKOwzY0D0YtU4bKpORIXIaid6p5Y5kDLrMGJaEPkNieQp03HMjhjFrnUPtT8kvqe0+aQ==", + "requires": { + "@types/json-schema": "^7.0.11" + } + }, + "argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" + }, + "js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "requires": { + "argparse": "^2.0.1" + } + }, + "node-fetch": { + "version": "2.6.7", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", + "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", + "requires": { + "whatwg-url": "^5.0.0" + } + }, + "tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + }, + "webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + }, + "whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "requires": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + } } }, "@asyncapi/generator-react-sdk": { @@ -14873,14 +15189,88 @@ "ajv": "^8.11.0", "ajv-errors": "^3.0.0", "ajv-formats": "^2.1.1" + }, + "dependencies": { + "@asyncapi/parser": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@asyncapi/parser/-/parser-2.0.3.tgz", + "integrity": "sha512-2gtIQOaCz8sR70JFREpg6UwgUBboC/26JcAGySkXY/f1ayjcfDoNLi4LsDvmu6G21qLrGN2lI83i8iLG1AzTAw==", + "requires": { + "@asyncapi/specs": "^5.1.0", + "@openapi-contrib/openapi-schema-to-json-schema": "~3.2.0", + "@stoplight/json-ref-resolver": "^3.1.5", + "@stoplight/spectral-core": "^1.16.1", + "@stoplight/spectral-functions": "^1.7.2", + "@stoplight/spectral-parsers": "^1.0.2", + "@types/json-schema": "^7.0.11", + "@types/urijs": "^1.19.19", + "ajv": "^8.11.0", + "ajv-errors": "^3.0.0", + "ajv-formats": "^2.1.1", + "avsc": "^5.7.5", + "js-yaml": "^4.1.0", + "jsonpath-plus": "^7.2.0", + "node-fetch": "2.6.7", + "ramldt2jsonschema": "^1.2.3", + "webapi-parser": "^0.5.0" + } + }, + "@asyncapi/specs": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@asyncapi/specs/-/specs-5.1.0.tgz", + "integrity": "sha512-yffhETqehkim43luMnPKOwzY0D0YtU4bKpORIXIaid6p5Y5kDLrMGJaEPkNieQp03HMjhjFrnUPtT8kvqe0+aQ==", + "requires": { + "@types/json-schema": "^7.0.11" + } + }, + "argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" + }, + "js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "requires": { + "argparse": "^2.0.1" + } + }, + "node-fetch": { + "version": "2.6.7", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", + "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", + "requires": { + "whatwg-url": "^5.0.0" + } + }, + "tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + }, + "webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + }, + "whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "requires": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + } } }, "@asyncapi/parser": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@asyncapi/parser/-/parser-2.0.3.tgz", - "integrity": "sha512-2gtIQOaCz8sR70JFREpg6UwgUBboC/26JcAGySkXY/f1ayjcfDoNLi4LsDvmu6G21qLrGN2lI83i8iLG1AzTAw==", + "version": "2.1.0-next-major-spec.3", + "resolved": "https://registry.npmjs.org/@asyncapi/parser/-/parser-2.1.0-next-major-spec.3.tgz", + "integrity": "sha512-xr9SkemAJEN4sRAWyASCP4Gg6pWVaf3WW8aGX145iWeXBp6tKp0cttUmU/kR3AxhMkBKMSCDCei5HIqAWnNaBg==", "requires": { - "@asyncapi/specs": "^5.1.0", + "@asyncapi/specs": "^6.0.0-next-major-spec.2", "@openapi-contrib/openapi-schema-to-json-schema": "~3.2.0", "@stoplight/json-ref-resolver": "^3.1.5", "@stoplight/spectral-core": "^1.16.1", @@ -14952,6 +15342,38 @@ "webapi-parser": "^0.5.0" }, "dependencies": { + "@asyncapi/parser": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@asyncapi/parser/-/parser-2.0.3.tgz", + "integrity": "sha512-2gtIQOaCz8sR70JFREpg6UwgUBboC/26JcAGySkXY/f1ayjcfDoNLi4LsDvmu6G21qLrGN2lI83i8iLG1AzTAw==", + "requires": { + "@asyncapi/specs": "^5.1.0", + "@openapi-contrib/openapi-schema-to-json-schema": "~3.2.0", + "@stoplight/json-ref-resolver": "^3.1.5", + "@stoplight/spectral-core": "^1.16.1", + "@stoplight/spectral-functions": "^1.7.2", + "@stoplight/spectral-parsers": "^1.0.2", + "@types/json-schema": "^7.0.11", + "@types/urijs": "^1.19.19", + "ajv": "^8.11.0", + "ajv-errors": "^3.0.0", + "ajv-formats": "^2.1.1", + "avsc": "^5.7.5", + "js-yaml": "^4.1.0", + "jsonpath-plus": "^7.2.0", + "node-fetch": "2.6.7", + "ramldt2jsonschema": "^1.2.3", + "webapi-parser": "^0.5.0" + } + }, + "@asyncapi/specs": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@asyncapi/specs/-/specs-5.1.0.tgz", + "integrity": "sha512-yffhETqehkim43luMnPKOwzY0D0YtU4bKpORIXIaid6p5Y5kDLrMGJaEPkNieQp03HMjhjFrnUPtT8kvqe0+aQ==", + "requires": { + "@types/json-schema": "^7.0.11" + } + }, "argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", @@ -14964,13 +15386,40 @@ "requires": { "argparse": "^2.0.1" } + }, + "node-fetch": { + "version": "2.6.7", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", + "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", + "requires": { + "whatwg-url": "^5.0.0" + } + }, + "tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + }, + "webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + }, + "whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "requires": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } } } }, "@asyncapi/specs": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/@asyncapi/specs/-/specs-5.1.0.tgz", - "integrity": "sha512-yffhETqehkim43luMnPKOwzY0D0YtU4bKpORIXIaid6p5Y5kDLrMGJaEPkNieQp03HMjhjFrnUPtT8kvqe0+aQ==", + "version": "6.0.0-next-major-spec.5", + "resolved": "https://registry.npmjs.org/@asyncapi/specs/-/specs-6.0.0-next-major-spec.5.tgz", + "integrity": "sha512-r8tSBydsyd48qdbArk3cGEWGCLf4YeulFRp4yNJ4HQkXhEmXE9eApdIF3umE3nnAYzsKz5EYZMxwHb+/UEX9wA==", "requires": { "@types/json-schema": "^7.0.11" } diff --git a/package.json b/package.json index e085f34ba..bfe83e996 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@asyncapi/avro-schema-parser": "^3.0.2", "@asyncapi/generator-react-sdk": "^0.2.23", "@asyncapi/openapi-schema-parser": "^3.0.3", - "@asyncapi/parser": "^2.0.3", + "@asyncapi/parser": "^2.1.0-next-major-spec.3", "@asyncapi/raml-dt-schema-parser": "^4.0.3", "@npmcli/arborist": "^2.2.4", "ajv": "^8.12.0", From f4835fbd81ab1677310729fcc90e605c9c89477a Mon Sep 17 00:00:00 2001 From: "jonas-lt@live.dk" Date: Thu, 7 Sep 2023 14:09:22 +0200 Subject: [PATCH 2/6] update to new parser api --- docs/configuration-file.md | 2 +- docs/generator_template.md | 2 +- lib/generator.js | 4 +- lib/parser.js | 43 +++++--- lib/templateConfigValidator.js | 1 + package-lock.json | 177 ++++++++++++++++++++++++++++++++- package.json | 2 +- 7 files changed, 209 insertions(+), 22 deletions(-) diff --git a/docs/configuration-file.md b/docs/configuration-file.md index a746a3384..6e95706c7 100644 --- a/docs/configuration-file.md +++ b/docs/configuration-file.md @@ -28,7 +28,7 @@ The `generator` property from `package.json` file must contain a JSON object tha "generator": { "renderer": "react", - "apiVersion": "v1", + "apiVersion": "v2", "supportedProtocols": ["amqp", "mqtt"], "parameters": { "server": { diff --git a/docs/generator_template.md b/docs/generator_template.md index dcd75fbc6..181ba40b7 100644 --- a/docs/generator_template.md +++ b/docs/generator_template.md @@ -85,7 +85,7 @@ The **package.json** file is used to define the dependencies for your template. "description": "A template that generates a Python MQTT client using MQTT.", "generator": { "renderer": "react", - "apiVersion": "v1", + "apiVersion": "v2", "generator": ">=1.10.0 <2.0.0", "supportedProtocols": ["mqtt"] }, diff --git a/lib/generator.js b/lib/generator.js index 21851cc94..8b3e4b276 100644 --- a/lib/generator.js +++ b/lib/generator.js @@ -179,7 +179,7 @@ class Generator { validateTemplateConfig(this.templateConfig, this.templateParams, asyncapiDocument); await this.configureTemplate(); - // use new or old document API based on `templateConfig.apiVersion` value + // use the expected document API based on `templateConfig.apiVersion` value this.asyncapi = asyncapiDocument = getProperApiDocument(asyncapiDocument, this.templateConfig); if (!isReactTemplate(this.templateConfig)) { @@ -436,7 +436,7 @@ class Generator { } }); } - + if (asyncapiDocument.hasComponents()) { for (const [key, value] of Object.entries(asyncapiDocument.components().parameters())) { parameters.set(key, value); diff --git a/lib/parser.js b/lib/parser.js index 94305905c..303022732 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -1,31 +1,42 @@ const fs = require('fs'); - -const { Parser, convertToOldAPI } = require('@asyncapi/parser/cjs'); -const { OpenAPISchemaParser } = require('@asyncapi/openapi-schema-parser'); -const { AvroSchemaParser } = require('@asyncapi/avro-schema-parser'); -const { RamlDTSchemaParser } = require('@asyncapi/raml-dt-schema-parser'); +const { convertToOldAPI } = require('@asyncapi/parser/cjs'); +const { ConvertDocumentParserAPIVersion, NewParser } = require('@smoya/multi-parser'); const parser = module.exports; -const defaultParser = new Parser({ - schemaParsers: [ - OpenAPISchemaParser(), - AvroSchemaParser(), - RamlDTSchemaParser(), - ], -}); +/** + * Conver the template defined value `apiVersion: 'v1'` to only contain the numeric value `1`. + */ +function sanitizeTemplateApiVersion(apiVersion) { + if (apiVersion && apiVersion.length > 1) { + return apiVersion.substring('1'); + } + return apiVersion; +} parser.parse = (asyncapi, oldOptions, generator) => { const options = convertOldOptionsToNew(oldOptions, generator); - return defaultParser.parse(asyncapi, options); + const parser = NewParser('1', options); + return parser.parse(asyncapi, options); }; +/** + * If the template expect one of the new parser API versions, it must be above 0 + */ parser.usesNewAPI = (templateConfig = {}) => { - return templateConfig.apiVersion === 'v1'; + return Number(sanitizeTemplateApiVersion(templateConfig.apiVersion)) > 0; }; -parser.getProperApiDocument = (asyncapiDocument, templateConfig) => { - return parser.usesNewAPI(templateConfig) ? asyncapiDocument : convertToOldAPI(asyncapiDocument); +/** + * Based on the current parsed AsyncAPI document, convert it to expected API version from the template. + */ +parser.getProperApiDocument = (asyncapiDocument, templateConfig = {}) => { + const apiVersion = sanitizeTemplateApiVersion(templateConfig.apiVersion); + if (apiVersion === undefined) { + // Convert to old version + return convertToOldAPI(asyncapiDocument); + } + return ConvertDocumentParserAPIVersion(asyncapiDocument, apiVersion); }; // The new options for the v2 Parser are different from those for the v1 version, but in order not to release Generator v2, we are converting the old options of Parser to the new ones. diff --git a/lib/templateConfigValidator.js b/lib/templateConfigValidator.js index 614185d07..dab56e288 100644 --- a/lib/templateConfigValidator.js +++ b/lib/templateConfigValidator.js @@ -8,6 +8,7 @@ const ajv = new Ajv({ allErrors: true }); // See https://github.com/asyncapi/parser-api const supportedParserAPIMajorVersions = [ 'v1', + 'v2' ]; /** diff --git a/package-lock.json b/package-lock.json index 0c1055d7f..a13fc2399 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,9 +12,9 @@ "@asyncapi/avro-schema-parser": "^3.0.2", "@asyncapi/generator-react-sdk": "^0.2.23", "@asyncapi/openapi-schema-parser": "^3.0.4", - "@asyncapi/parser": "^2.1.0-next-major-spec.3", "@asyncapi/raml-dt-schema-parser": "^4.0.4", "@npmcli/arborist": "^2.2.4", + "@smoya/multi-parser": "2.0.0", "ajv": "^8.12.0", "chokidar": "^3.4.0", "commander": "^6.1.0", @@ -3041,6 +3041,15 @@ "type-detect": "4.0.8" } }, + "node_modules/@smoya/multi-parser": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@smoya/multi-parser/-/multi-parser-2.0.0.tgz", + "integrity": "sha512-Acm0hNvcxBbMN4Hr8hzEuWP3N84K1AQvSOgJn2YAm9/BDhqNWZtPM7xSplpC+np/SGp50AeCYJcKdAeueG6zPw==", + "dependencies": { + "parserv2": "npm:@asyncapi/parser@^2.1.0", + "parserv3": "npm:@asyncapi/parser@^2.2.0-next-major-spec.2" + } + }, "node_modules/@stoplight/better-ajv-errors": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/@stoplight/better-ajv-errors/-/better-ajv-errors-1.0.3.tgz", @@ -11238,6 +11247,172 @@ "integrity": "sha512-fxNG2sQjHvlVAYmzBZS9YlDp6PTSSDwa98vkD4QgVDDCAo84z5X1t5XyJQ62ImdLXx5NdIIfihey6xpum9/gRQ==", "dev": true }, + "node_modules/parserv2": { + "name": "@asyncapi/parser", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@asyncapi/parser/-/parser-2.1.0.tgz", + "integrity": "sha512-78jjN3eW4ZmgJEa6Ap15lofzADCeItO4wHcAY2Jod3qLB1xf1zFDZQdtm3VSHYLeLhwoC1A33bAtzEf7M5P2bg==", + "dependencies": { + "@asyncapi/specs": "^5.1.0", + "@openapi-contrib/openapi-schema-to-json-schema": "~3.2.0", + "@stoplight/json-ref-resolver": "^3.1.5", + "@stoplight/spectral-core": "^1.16.1", + "@stoplight/spectral-functions": "^1.7.2", + "@stoplight/spectral-parsers": "^1.0.2", + "@types/json-schema": "^7.0.11", + "@types/urijs": "^1.19.19", + "ajv": "^8.11.0", + "ajv-errors": "^3.0.0", + "ajv-formats": "^2.1.1", + "avsc": "^5.7.5", + "js-yaml": "^4.1.0", + "jsonpath-plus": "^7.2.0", + "node-fetch": "2.6.7", + "ramldt2jsonschema": "^1.2.3", + "webapi-parser": "^0.5.0" + } + }, + "node_modules/parserv2/node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" + }, + "node_modules/parserv2/node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/parserv2/node_modules/node-fetch": { + "version": "2.6.7", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", + "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/parserv2/node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + }, + "node_modules/parserv2/node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + }, + "node_modules/parserv2/node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, + "node_modules/parserv3": { + "name": "@asyncapi/parser", + "version": "2.2.0-next-major-spec.2", + "resolved": "https://registry.npmjs.org/@asyncapi/parser/-/parser-2.2.0-next-major-spec.2.tgz", + "integrity": "sha512-KkS+sPCHFFPZrFzzx4UGiYDrDfJI583AksLFg6QUKwr5Wjq8o7cIC3Hel2ptaRVv5x1nJz0o6QzFeY7VIWCc1g==", + "dependencies": { + "@asyncapi/specs": "^6.0.0-next-major-spec.6", + "@openapi-contrib/openapi-schema-to-json-schema": "~3.2.0", + "@stoplight/json-ref-resolver": "^3.1.5", + "@stoplight/spectral-core": "^1.16.1", + "@stoplight/spectral-functions": "^1.7.2", + "@stoplight/spectral-parsers": "^1.0.2", + "@types/json-schema": "^7.0.11", + "@types/urijs": "^1.19.19", + "ajv": "^8.11.0", + "ajv-errors": "^3.0.0", + "ajv-formats": "^2.1.1", + "avsc": "^5.7.5", + "js-yaml": "^4.1.0", + "jsonpath-plus": "^7.2.0", + "node-fetch": "2.6.7", + "ramldt2jsonschema": "^1.2.3", + "webapi-parser": "^0.5.0" + } + }, + "node_modules/parserv3/node_modules/@asyncapi/specs": { + "version": "6.0.0-next-major-spec.6", + "resolved": "https://registry.npmjs.org/@asyncapi/specs/-/specs-6.0.0-next-major-spec.6.tgz", + "integrity": "sha512-xYiXZetKiAZgZoh2q/sxt+Ceg8bLTK/WSCwtLvlH7JgnjpnOEtCDwKszijmmOJEYdGVSrj0OFXLPrg/dm4JANw==", + "dependencies": { + "@types/json-schema": "^7.0.11" + } + }, + "node_modules/parserv3/node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" + }, + "node_modules/parserv3/node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/parserv3/node_modules/node-fetch": { + "version": "2.6.7", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", + "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/parserv3/node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + }, + "node_modules/parserv3/node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + }, + "node_modules/parserv3/node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, "node_modules/pascalcase": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", diff --git a/package.json b/package.json index 0014aad35..c37567bf3 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@asyncapi/avro-schema-parser": "^3.0.2", "@asyncapi/generator-react-sdk": "^0.2.23", "@asyncapi/openapi-schema-parser": "^3.0.4", - "@asyncapi/parser": "^2.1.0-next-major-spec.3", + "@smoya/multi-parser": "2.0.0", "@asyncapi/raml-dt-schema-parser": "^4.0.4", "@npmcli/arborist": "^2.2.4", "ajv": "^8.12.0", From 2f9b418431612bd33ed39a6511eec3c5d91902d4 Mon Sep 17 00:00:00 2001 From: "jonas-lt@live.dk" Date: Mon, 11 Sep 2023 12:59:08 +0200 Subject: [PATCH 3/6] update implementation --- lib/generator.js | 2 +- lib/parser.js | 17 +++++---- package-lock.json | 47 +++++++++++++++++++------ package.json | 6 ++-- test/docs/dummyV3.yml | 31 +++++++++++++++++ test/parser.test.js | 80 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 161 insertions(+), 22 deletions(-) create mode 100644 test/docs/dummyV3.yml create mode 100644 test/parser.test.js diff --git a/lib/generator.js b/lib/generator.js index 8b3e4b276..2caf855ac 100644 --- a/lib/generator.js +++ b/lib/generator.js @@ -261,7 +261,7 @@ class Generator { /** @type {AsyncAPIDocument} Parsed AsyncAPI schema. See {@link https://github.com/asyncapi/parser-js/blob/master/API.md#module_@asyncapi/parser+AsyncAPIDocument|AsyncAPIDocument} for details on object structure. */ const { document, diagnostics } = await parse(asyncapiString, parseOptions, this); if (!document) { - const err = new Error('Input is not a corrent AsyncAPI document so it cannot be processed.'); + const err = new Error('Input is not a correct AsyncAPI document so it cannot be processed.'); err.diagnostics = diagnostics; throw err; } diff --git a/lib/parser.js b/lib/parser.js index 303022732..9b6fc82a5 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -1,5 +1,5 @@ const fs = require('fs'); -const { convertToOldAPI } = require('@asyncapi/parser/cjs'); +const { convertToOldAPI } = require('@asyncapi/parser'); const { ConvertDocumentParserAPIVersion, NewParser } = require('@smoya/multi-parser'); const parser = module.exports; @@ -7,16 +7,21 @@ const parser = module.exports; /** * Conver the template defined value `apiVersion: 'v1'` to only contain the numeric value `1`. */ -function sanitizeTemplateApiVersion(apiVersion) { +parser.sanitizeTemplateApiVersion = (apiVersion) => { if (apiVersion && apiVersion.length > 1) { return apiVersion.substring('1'); } return apiVersion; -} +}; parser.parse = (asyncapi, oldOptions, generator) => { + let apiVersion = this.sanitizeTemplateApiVersion(generator.templateConfig.apiVersion); + // Defaulting to v1 parser to convert it to the old parserAPI afterwards. + if (!this.usesNewAPI(generator.templateConfig)) { + apiVersion = '1'; + } const options = convertOldOptionsToNew(oldOptions, generator); - const parser = NewParser('1', options); + const parser = NewParser(apiVersion, {parserOptions: options, includeSchemaParsers: true}); return parser.parse(asyncapi, options); }; @@ -24,14 +29,14 @@ parser.parse = (asyncapi, oldOptions, generator) => { * If the template expect one of the new parser API versions, it must be above 0 */ parser.usesNewAPI = (templateConfig = {}) => { - return Number(sanitizeTemplateApiVersion(templateConfig.apiVersion)) > 0; + return Number(this.sanitizeTemplateApiVersion(templateConfig.apiVersion)) > 0; }; /** * Based on the current parsed AsyncAPI document, convert it to expected API version from the template. */ parser.getProperApiDocument = (asyncapiDocument, templateConfig = {}) => { - const apiVersion = sanitizeTemplateApiVersion(templateConfig.apiVersion); + const apiVersion = this.sanitizeTemplateApiVersion(templateConfig.apiVersion); if (apiVersion === undefined) { // Convert to old version return convertToOldAPI(asyncapiDocument); diff --git a/package-lock.json b/package-lock.json index a13fc2399..710646df3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,12 +9,10 @@ "version": "1.10.12", "license": "Apache-2.0", "dependencies": { - "@asyncapi/avro-schema-parser": "^3.0.2", "@asyncapi/generator-react-sdk": "^0.2.23", - "@asyncapi/openapi-schema-parser": "^3.0.4", - "@asyncapi/raml-dt-schema-parser": "^4.0.4", + "@asyncapi/parser": "2.1.0", "@npmcli/arborist": "^2.2.4", - "@smoya/multi-parser": "2.0.0", + "@smoya/multi-parser": "3.0.0", "ajv": "^8.12.0", "chokidar": "^3.4.0", "commander": "^6.1.0", @@ -96,11 +94,11 @@ } }, "node_modules/@asyncapi/avro-schema-parser": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@asyncapi/avro-schema-parser/-/avro-schema-parser-3.0.2.tgz", - "integrity": "sha512-TZZedLaflgyYivwidJPqTN2LMk+Lqg0IByXtdzNYQZLNpLpcyEnXCxongoW0TVYgYGLWAghN3AmMOrrsVcGGOw==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@asyncapi/avro-schema-parser/-/avro-schema-parser-3.0.3.tgz", + "integrity": "sha512-XprbDYPFJ0nc963hPCjbEmM3iu6ypKg/70EFVl0MZJCLbLw/+gBbPy95uV3Qaofm5UQgSI+aTobGhc8rMre4VA==", "dependencies": { - "@asyncapi/parser": "^2.0.3", + "@asyncapi/parser": "^2.1.0", "@types/json-schema": "^7.0.11", "avsc": "^5.7.6" } @@ -302,6 +300,16 @@ "webidl-conversions": "^3.0.0" } }, + "node_modules/@asyncapi/protobuf-schema-parser": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@asyncapi/protobuf-schema-parser/-/protobuf-schema-parser-3.0.0.tgz", + "integrity": "sha512-kjoLrll611K+xYC/iBUlSnZsCHbrhL999ItVHZhObUOjUB991XgonqbSAaihiiDXTYgceOLhJKAN5llkV/LOOA==", + "dependencies": { + "@asyncapi/parser": "^2.1.0", + "@types/protocol-buffers-schema": "^3.4.1", + "protocol-buffers-schema": "^3.6.0" + } + }, "node_modules/@asyncapi/raml-dt-schema-parser": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/@asyncapi/raml-dt-schema-parser/-/raml-dt-schema-parser-4.0.4.tgz", @@ -3042,10 +3050,14 @@ } }, "node_modules/@smoya/multi-parser": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@smoya/multi-parser/-/multi-parser-2.0.0.tgz", - "integrity": "sha512-Acm0hNvcxBbMN4Hr8hzEuWP3N84K1AQvSOgJn2YAm9/BDhqNWZtPM7xSplpC+np/SGp50AeCYJcKdAeueG6zPw==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@smoya/multi-parser/-/multi-parser-3.0.0.tgz", + "integrity": "sha512-HtA/Png8FQ2vwiKKMSOqNkYGERUFqieeekwtuMsImmgnaiacyq97itehbep179qO/TvHb+3luRZAJ433fHgIxg==", "dependencies": { + "@asyncapi/avro-schema-parser": "^3.0.3", + "@asyncapi/openapi-schema-parser": "^3.0.4", + "@asyncapi/protobuf-schema-parser": "^3.0.0", + "@asyncapi/raml-dt-schema-parser": "^4.0.4", "parserv2": "npm:@asyncapi/parser@^2.1.0", "parserv3": "npm:@asyncapi/parser@^2.2.0-next-major-spec.2" } @@ -3469,6 +3481,14 @@ "integrity": "sha512-5qOlnZscTn4xxM5MeGXAMOsIOIKIbh9e85zJWfBRVPlRMEVawzoPhINYbRGkBZCI8LxvBe7tJCdWiarA99OZfQ==", "dev": true }, + "node_modules/@types/protocol-buffers-schema": { + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/@types/protocol-buffers-schema/-/protocol-buffers-schema-3.4.1.tgz", + "integrity": "sha512-CBpqIDa1+/F3Z5EL8Uz/t+1eygIinJiMS37KP8O9TN+n38OlckYQhU+t/vYpsF7XhSDuiZS0zAJyfRrAeDKDUw==", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/stack-utils": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-1.0.1.tgz", @@ -11650,6 +11670,11 @@ "react-is": "^16.13.1" } }, + "node_modules/protocol-buffers-schema": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/protocol-buffers-schema/-/protocol-buffers-schema-3.6.0.tgz", + "integrity": "sha512-TdDRD+/QNdrCGCE7v8340QyuXd4kIWIgapsE2+n/SaGiSSbomYl4TjHlvIoCWRpE7wFt02EpB35VVA2ImcBVqw==" + }, "node_modules/psl": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", diff --git a/package.json b/package.json index c37567bf3..688cb1803 100644 --- a/package.json +++ b/package.json @@ -48,11 +48,9 @@ "license": "Apache-2.0", "homepage": "https://github.com/asyncapi/generator", "dependencies": { - "@asyncapi/avro-schema-parser": "^3.0.2", "@asyncapi/generator-react-sdk": "^0.2.23", - "@asyncapi/openapi-schema-parser": "^3.0.4", - "@smoya/multi-parser": "2.0.0", - "@asyncapi/raml-dt-schema-parser": "^4.0.4", + "@asyncapi/parser": "2.1.0", + "@smoya/multi-parser": "3.0.0", "@npmcli/arborist": "^2.2.4", "ajv": "^8.12.0", "chokidar": "^3.4.0", diff --git a/test/docs/dummyV3.yml b/test/docs/dummyV3.yml new file mode 100644 index 000000000..f72ea6ece --- /dev/null +++ b/test/docs/dummyV3.yml @@ -0,0 +1,31 @@ +asyncapi: 3.0.0 +info: + title: Account Service + version: 1.0.0 + description: This service is in charge of processing user signups +channels: + user/signedup: + address: user/signedup + messages: + subscribe.message: + $ref: '#/components/messages/UserSignedUp' +operations: + user/signedup.subscribe: + action: send + channel: + $ref: '#/channels/user~1signedup' + messages: + - $ref: '#/components/messages/UserSignedUp' +components: + messages: + UserSignedUp: + payload: + type: object + properties: + displayName: + type: string + description: Name of the user + email: + type: string + format: email + description: Email of the user diff --git a/test/parser.test.js b/test/parser.test.js new file mode 100644 index 000000000..311f465e8 --- /dev/null +++ b/test/parser.test.js @@ -0,0 +1,80 @@ +const fs = require('fs'); +const path = require('path'); +const { sanitizeTemplateApiVersion, usesNewAPI, parse } = require('../lib/parser'); +const dummyV2Document = fs.readFileSync(path.resolve(__dirname, './docs/dummy.yml'), 'utf8'); +const dummyV3Document = fs.readFileSync(path.resolve(__dirname, './docs/dummyV3.yml'), 'utf8'); + +describe('Parser', () => { + describe('sanitizeTemplateApiVersion', () => { + it('should return version number when given `v1` syntax', () => { + const rawVersion = 'v1'; + const expectedVersion = '1'; + const sanitizedVersion = sanitizeTemplateApiVersion(rawVersion); + + expect(sanitizedVersion).toStrictEqual(expectedVersion); + }); + it('should return version number when given `1` syntax', () => { + const rawVersion = '1'; + const expectedVersion = '1'; + const sanitizedVersion = sanitizeTemplateApiVersion(rawVersion); + + expect(sanitizedVersion).toStrictEqual(expectedVersion); + }); + }); + describe('usesNewAPI', () => { + it('should use new parser api if v1', () => { + const templateConfig = { + apiVersion: 'v1' + }; + const isUsingNewAPI = usesNewAPI(templateConfig); + + expect(isUsingNewAPI).toStrictEqual(true); + }); + it('should use new parser api if v2', () => { + const templateConfig = { + apiVersion: 'v2' + }; + const isUsingNewAPI = usesNewAPI(templateConfig); + + expect(isUsingNewAPI).toStrictEqual(true); + }); + it('should not use new API if no apiVersion', () => { + const templateConfig = { }; + const isUsingNewAPI = usesNewAPI(templateConfig); + + expect(isUsingNewAPI).toStrictEqual(false); + }); + }); + describe('parse', () => { + it('should be able to parse AsyncAPI v2 document for parser API v1', async () => { + const parsedDocument = await parse(dummyV2Document, {}, {templateConfig: {apiVersion: 'v1'}}); + + expect(parsedDocument).toBeDefined(); + expect(parsedDocument.document.version()).toEqual('2.3.0'); + }); + it('should be able to parse AsyncAPI v2 document for parser API v2', async () => { + const parsedDocument = await parse(dummyV2Document, {}, {templateConfig: {apiVersion: 'v2'}}); + + expect(parsedDocument).toBeDefined(); + expect(parsedDocument.document.version()).toEqual('2.3.0'); + }); + it('should not be able to parse AsyncAPI v3 document for parser API v1', async () => { + const parsedDocument = await parse(dummyV3Document, {}, {templateConfig: {apiVersion: 'v1'}}); + + expect(parsedDocument).toBeDefined(); + expect(parsedDocument.document).not.toBeDefined(); + }); + it('should not be able to parse AsyncAPI v3 document for old parser', async () => { + const parsedDocument = await parse(dummyV3Document, {}, {templateConfig: {}}); + + expect(parsedDocument).toBeDefined(); + expect(parsedDocument.document).not.toBeDefined(); + }); + it('should be able to parse AsyncAPI v3 document for parser API v2', async () => { + const parsedDocument = await parse(dummyV3Document, {}, {templateConfig: {apiVersion: 'v2'}}); + + expect(parsedDocument).toBeDefined(); + expect(parsedDocument.document.version()).toEqual('3.0.0'); + }); + }); +}); From b306a17863122ae9598131329c4ed0d68b0e8615 Mon Sep 17 00:00:00 2001 From: "jonas-lt@live.dk" Date: Thu, 14 Sep 2023 12:32:53 +0200 Subject: [PATCH 4/6] after review --- docs/configuration-file.md | 2 +- docs/generator-template.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/configuration-file.md b/docs/configuration-file.md index 6e95706c7..f8ceb2635 100644 --- a/docs/configuration-file.md +++ b/docs/configuration-file.md @@ -8,7 +8,7 @@ The `generator` property from `package.json` file must contain a JSON object tha |Name|Type|Description| |---|---|---| |`renderer`| String | Its value can be either `react` or `nunjucks` (default). -|`apiVersion`| String | Determines which **major** version of the [Parser-API](https://github.com/asyncapi/parser-api) the template uses. For example, `v1` for `v1.x.x`. If not specified, the Generator assumes the template is not compatible with the Parser-API so it will use the [Parser-JS v1 API](https://github.com/asyncapi/parser-js/tree/v1.18.1#api-documentation). If the template uses a version of the Parser-API that is not supported by the Generator, the Generator will throw an error. +|`apiVersion`| String | Determines which **major** version of the [Parser-API](https://github.com/asyncapi/parser-api) the template uses. For example, `v2` for `v2.x.x`. If not specified, the Generator assumes the template is not compatible with the Parser-API so it will use the [Parser-JS v1 API](https://github.com/asyncapi/parser-js/tree/v1.18.1#api-documentation). For templates that need to support AsyncAPI specification v3 make sure to use `v2` [Parser-API](https://github.com/asyncapi/parser-api). If the template uses a version of the Parser-API that is not supported by the Generator, the Generator will throw an error. |`supportedProtocols`| [String] | A list with all the protocols this template supports. |`parameters`| Object[String, Object] | An object with all the parameters that can be passed when generating the template. When using the command line, it's done by indicating `--param name=value` or `-p name=value`. |`parameters[param].description`| String | A user-friendly description about the parameter. diff --git a/docs/generator-template.md b/docs/generator-template.md index c05d1cf67..c6bc65c28 100644 --- a/docs/generator-template.md +++ b/docs/generator-template.md @@ -85,7 +85,7 @@ The **package.json** file is used to define the dependencies for your template. "description": "A template that generates a Python MQTT client using MQTT.", "generator": { "renderer": "react", - "apiVersion": "v2", + "apiVersion": "v1", "generator": ">=1.10.0 <2.0.0", "supportedProtocols": ["mqtt"] }, From 70371517031009f0416635ebf4bddc96fd04f87f Mon Sep 17 00:00:00 2001 From: Jonas Lagoni Date: Thu, 14 Sep 2023 15:12:01 +0200 Subject: [PATCH 5/6] Update lib/parser.js Co-authored-by: Lukasz Gornicki --- lib/parser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/parser.js b/lib/parser.js index 9b6fc82a5..b544ae822 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -16,7 +16,7 @@ parser.sanitizeTemplateApiVersion = (apiVersion) => { parser.parse = (asyncapi, oldOptions, generator) => { let apiVersion = this.sanitizeTemplateApiVersion(generator.templateConfig.apiVersion); - // Defaulting to v1 parser to convert it to the old parserAPI afterwards. + // Defaulting to apiVersion v1 to convert it to the Parser-API v1 afterwards. if (!this.usesNewAPI(generator.templateConfig)) { apiVersion = '1'; } From 1ca6188eee85aff854c5167eaffc7d8e7e65670a Mon Sep 17 00:00:00 2001 From: Jonas Lagoni Date: Thu, 14 Sep 2023 15:12:24 +0200 Subject: [PATCH 6/6] Apply suggestions from code review Co-authored-by: Lukasz Gornicki --- lib/parser.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/parser.js b/lib/parser.js index b544ae822..fadf95058 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -26,7 +26,7 @@ parser.parse = (asyncapi, oldOptions, generator) => { }; /** - * If the template expect one of the new parser API versions, it must be above 0 + * If the template expect one of the Parser-API versions, it must be above 0 */ parser.usesNewAPI = (templateConfig = {}) => { return Number(this.sanitizeTemplateApiVersion(templateConfig.apiVersion)) > 0; @@ -38,7 +38,7 @@ parser.usesNewAPI = (templateConfig = {}) => { parser.getProperApiDocument = (asyncapiDocument, templateConfig = {}) => { const apiVersion = this.sanitizeTemplateApiVersion(templateConfig.apiVersion); if (apiVersion === undefined) { - // Convert to old version + // Convert to old API from JS Parser v1 return convertToOldAPI(asyncapiDocument); } return ConvertDocumentParserAPIVersion(asyncapiDocument, apiVersion);