@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.mjs CHANGED
@@ -1538,7 +1538,7 @@ import path3 from "path";
1538
1538
  // package.json
1539
1539
  var package_default = {
1540
1540
  name: "@eventcatalog/generator-asyncapi",
1541
- version: "6.2.1",
1541
+ version: "6.3.0",
1542
1542
  description: "AsyncAPI generator for EventCatalog",
1543
1543
  scripts: {
1544
1544
  build: "tsup",
@@ -4161,6 +4161,24 @@ var optionsSchema = z.object({
4161
4161
  var toUniqueArray = (array) => {
4162
4162
  return array.filter((item, index, self) => index === self.findIndex((t) => t.id === item.id && t.version === item.version));
4163
4163
  };
4164
+ var consolidateMessages = (array) => {
4165
+ const map = /* @__PURE__ */ new Map();
4166
+ for (const item of array) {
4167
+ const key = `${item.id}::${item.version}`;
4168
+ const existing = map.get(key);
4169
+ if (existing) {
4170
+ if (item.to) {
4171
+ existing.to = [...existing.to || [], ...item.to];
4172
+ }
4173
+ if (item.from) {
4174
+ existing.from = [...existing.from || [], ...item.from];
4175
+ }
4176
+ } else {
4177
+ map.set(key, { ...item });
4178
+ }
4179
+ }
4180
+ return Array.from(map.values());
4181
+ };
4164
4182
  var mergeAsyncApiIntoSpecifications = (existingSpecs, asyncapiFileName) => {
4165
4183
  if (Array.isArray(existingSpecs)) {
4166
4184
  return [...existingSpecs.filter((spec) => spec.type !== "asyncapi"), { type: "asyncapi", path: asyncapiFileName }];
@@ -4539,6 +4557,8 @@ Processing domain: ${domainName} (v${domainVersion})`));
4539
4557
  }
4540
4558
  }
4541
4559
  const fileName = path3.basename(service.path);
4560
+ sends = consolidateMessages(sends);
4561
+ receives = consolidateMessages(receives);
4542
4562
  await writeService(
4543
4563
  {
4544
4564
  id: serviceId,