@asyncapi/parser
Advanced tools
Comparing version 2.1.0-next-major-spec.8 to 2.1.0-next-major-spec.9
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Message = void 0; | ||
const channel_1 = require("./channel"); | ||
const channels_1 = require("./channels"); | ||
@@ -46,9 +47,11 @@ const operations_1 = require("./operations"); | ||
channels() { | ||
var _a, _b; | ||
const channels = []; | ||
const channelData = []; | ||
const channelsData = []; | ||
this.operations().forEach(operation => { | ||
operation.channels().forEach(channel => { | ||
const channelsData = channel.json(); | ||
if (!channelData.includes(channelsData)) { | ||
channelData.push(channelsData); | ||
const channelData = channel.json(); | ||
// Comparing with the data (JSON) because same channel could exist but it will include the ID based on where it is declared. For example, asyncapi.channels contain ID field. | ||
if (!channelsData.includes(channelData)) { | ||
channelsData.push(channelData); | ||
channels.push(channel); | ||
@@ -58,2 +61,9 @@ } | ||
}); | ||
Object.entries(((_b = (_a = this._meta.asyncapi) === null || _a === void 0 ? void 0 : _a.parsed) === null || _b === void 0 ? void 0 : _b.channels) || {}).forEach(([channelId, channelData]) => { | ||
const channelModel = this.createModel(channel_1.Channel, channelData, { id: channelId, pointer: `/channels/${channelId}` }); | ||
if (!channelsData.includes(channelData) && channelModel.messages().some(m => m.json() === this._json)) { | ||
channelsData.push(channelData); | ||
channels.push(channelModel); | ||
} | ||
}); | ||
return new channels_1.Channels(channels); | ||
@@ -60,0 +70,0 @@ } |
@@ -0,1 +1,2 @@ | ||
import { Channel } from './channel'; | ||
import { Channels } from './channels'; | ||
@@ -43,9 +44,11 @@ import { Operations } from './operations'; | ||
channels() { | ||
var _a, _b; | ||
const channels = []; | ||
const channelData = []; | ||
const channelsData = []; | ||
this.operations().forEach(operation => { | ||
operation.channels().forEach(channel => { | ||
const channelsData = channel.json(); | ||
if (!channelData.includes(channelsData)) { | ||
channelData.push(channelsData); | ||
const channelData = channel.json(); | ||
// Comparing with the data (JSON) because same channel could exist but it will include the ID based on where it is declared. For example, asyncapi.channels contain ID field. | ||
if (!channelsData.includes(channelData)) { | ||
channelsData.push(channelData); | ||
channels.push(channel); | ||
@@ -55,2 +58,9 @@ } | ||
}); | ||
Object.entries(((_b = (_a = this._meta.asyncapi) === null || _a === void 0 ? void 0 : _a.parsed) === null || _b === void 0 ? void 0 : _b.channels) || {}).forEach(([channelId, channelData]) => { | ||
const channelModel = this.createModel(Channel, channelData, { id: channelId, pointer: `/channels/${channelId}` }); | ||
if (!channelsData.includes(channelData) && channelModel.messages().some(m => m.json() === this._json)) { | ||
channelsData.push(channelData); | ||
channels.push(channelModel); | ||
} | ||
}); | ||
return new Channels(channels); | ||
@@ -57,0 +67,0 @@ } |
{ | ||
"name": "@asyncapi/parser", | ||
"version": "2.1.0-next-major-spec.8", | ||
"version": "2.1.0-next-major-spec.9", | ||
"description": "JavaScript AsyncAPI parser.", | ||
@@ -5,0 +5,0 @@ "bugs": { |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2612579
26073