@eventcatalog/generator-asyncapi 6.2.1 → 6.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1543,7 +1543,7 @@ var import_path3 = __toESM(require("path"));
1543
1543
  // package.json
1544
1544
  var package_default = {
1545
1545
  name: "@eventcatalog/generator-asyncapi",
1546
- version: "6.2.1",
1546
+ version: "6.3.0",
1547
1547
  description: "AsyncAPI generator for EventCatalog",
1548
1548
  scripts: {
1549
1549
  build: "tsup",
@@ -4166,6 +4166,24 @@ var optionsSchema = import_zod.z.object({
4166
4166
  var toUniqueArray = (array) => {
4167
4167
  return array.filter((item, index, self) => index === self.findIndex((t) => t.id === item.id && t.version === item.version));
4168
4168
  };
4169
+ var consolidateMessages = (array) => {
4170
+ const map = /* @__PURE__ */ new Map();
4171
+ for (const item of array) {
4172
+ const key = `${item.id}::${item.version}`;
4173
+ const existing = map.get(key);
4174
+ if (existing) {
4175
+ if (item.to) {
4176
+ existing.to = [...existing.to || [], ...item.to];
4177
+ }
4178
+ if (item.from) {
4179
+ existing.from = [...existing.from || [], ...item.from];
4180
+ }
4181
+ } else {
4182
+ map.set(key, { ...item });
4183
+ }
4184
+ }
4185
+ return Array.from(map.values());
4186
+ };
4169
4187
  var mergeAsyncApiIntoSpecifications = (existingSpecs, asyncapiFileName) => {
4170
4188
  if (Array.isArray(existingSpecs)) {
4171
4189
  return [...existingSpecs.filter((spec) => spec.type !== "asyncapi"), { type: "asyncapi", path: asyncapiFileName }];
@@ -4544,6 +4562,8 @@ Processing domain: ${domainName} (v${domainVersion})`));
4544
4562
  }
4545
4563
  }
4546
4564
  const fileName = import_path3.default.basename(service.path);
4565
+ sends = consolidateMessages(sends);
4566
+ receives = consolidateMessages(receives);
4547
4567
  await writeService(
4548
4568
  {
4549
4569
  id: serviceId,