Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@asyncapi/parser

Package Overview
Dependencies
Maintainers
3
Versions
170
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@asyncapi/parser - npm Package Compare versions

Comparing version 1.3.0 to 1.3.1

38

lib/parser.js

@@ -18,2 +18,3 @@ const path = require('path');

const xParserCircle = 'x-parser-circular';
const xParserMessageParsed = 'x-parser-message-parsed';

@@ -173,6 +174,7 @@ /**

if (!parsedJSON.channels) return;
validateChannels(parsedJSON, asyncapiYAMLorJSON, initialFormat);
validateOperationId(parsedJSON, asyncapiYAMLorJSON, initialFormat, OPERATIONS);
await customComponentsMsgOperations(parsedJSON, asyncapiYAMLorJSON, initialFormat, options);
await customChannelsOperations(parsedJSON, asyncapiYAMLorJSON, initialFormat, options);

@@ -182,2 +184,5 @@ }

async function validateAndConvertMessage(msg, originalAsyncAPIDocument, fileFormat, parsedAsyncAPIDocument, pathToPayload) {
//check if the message has been parsed before
if (xParserMessageParsed in msg && msg[String(xParserMessageParsed)] === true) return;
const schemaFormat = msg.schemaFormat || DEFAULT_SCHEMA_FORMAT;

@@ -196,2 +201,3 @@

msg.schemaFormat = DEFAULT_SCHEMA_FORMAT;
msg[String(xParserMessageParsed)] = true;
}

@@ -238,3 +244,3 @@

* @param {String} asyncapiYAMLorJSON AsyncAPI document in string
* @param {String} initialFormat information of the document was oryginally JSON or YAML
* @param {String} initialFormat information of the document was originally JSON or YAML
* @param {Object} options Configuration options.

@@ -261,2 +267,28 @@ */

await Promise.all(promisesArray);
}
}
/**
* Triggers additional operations on the AsyncAPI messages located in the components section of the document. It triggers operations like traits application, validation and conversion
*
* @private
*
* @param {Object} parsedJSON parsed AsyncAPI document
* @param {String} asyncapiYAMLorJSON AsyncAPI document in string
* @param {String} initialFormat information of the document was originally JSON or YAML
* @param {Object} options Configuration options.
*/
async function customComponentsMsgOperations(parsedJSON, asyncapiYAMLorJSON, initialFormat, options) {
if (!parsedJSON.components || !parsedJSON.components.messages) return;
const promisesArray = [];
Object.entries(parsedJSON.components.messages).forEach(([messageName, message]) => {
if (options.applyTraits) {
applyTraits(message);
}
const pathToPayload = `/components/messages/${messageName}/payload`;
promisesArray.push(validateAndConvertMessage(message, asyncapiYAMLorJSON, initialFormat, parsedJSON, pathToPayload));
});
await Promise.all(promisesArray);
}

5

package.json
{
"name": "@asyncapi/parser",
"version": "1.3.0",
"version": "1.3.1",
"description": "JavaScript AsyncAPI parser.",

@@ -22,3 +22,4 @@ "main": "lib/index.js",

"test-lib": "nyc --reporter=html --reporter=text mocha --exclude test/browser_test.js --recursive",
"test-browser": "npm run bundle && cp dist/bundle.js test/sample_browser/ && start-server-and-test 'http-server test/sample_browser --cors -s' 8080 'mocha --timeout 3000 test/browser_test.js' && rimraf test/sample_browser/bundle.js"
"test-browser": "npm run test-browser-cleanup && npm run bundle && cp dist/bundle.js test/sample_browser/ && start-server-and-test 'http-server test/sample_browser --cors -s' 8080 'mocha --timeout 3000 test/browser_test.js' && npm run test-browser-cleanup",
"test-browser-cleanup": "rimraf test/sample_browser/bundle.js"
},

@@ -25,0 +26,0 @@ "bugs": {

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc