@eventcatalog/generator-asyncapi 6.2.1 → 6.3.1
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 +23 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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.
|
|
1541
|
+
version: "6.3.1",
|
|
1542
1542
|
description: "AsyncAPI generator for EventCatalog",
|
|
1543
1543
|
scripts: {
|
|
1544
1544
|
build: "tsup",
|
|
@@ -4161,6 +4161,26 @@ 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
|
+
const merged = [...existing.to || [], ...item.to];
|
|
4172
|
+
existing.to = merged.filter((ch, i, arr) => i === arr.findIndex((c) => c.id === ch.id));
|
|
4173
|
+
}
|
|
4174
|
+
if (item.from) {
|
|
4175
|
+
const merged = [...existing.from || [], ...item.from];
|
|
4176
|
+
existing.from = merged.filter((ch, i, arr) => i === arr.findIndex((c) => c.id === ch.id));
|
|
4177
|
+
}
|
|
4178
|
+
} else {
|
|
4179
|
+
map.set(key, { ...item });
|
|
4180
|
+
}
|
|
4181
|
+
}
|
|
4182
|
+
return Array.from(map.values());
|
|
4183
|
+
};
|
|
4164
4184
|
var mergeAsyncApiIntoSpecifications = (existingSpecs, asyncapiFileName) => {
|
|
4165
4185
|
if (Array.isArray(existingSpecs)) {
|
|
4166
4186
|
return [...existingSpecs.filter((spec) => spec.type !== "asyncapi"), { type: "asyncapi", path: asyncapiFileName }];
|
|
@@ -4539,6 +4559,8 @@ Processing domain: ${domainName} (v${domainVersion})`));
|
|
|
4539
4559
|
}
|
|
4540
4560
|
}
|
|
4541
4561
|
const fileName = path3.basename(service.path);
|
|
4562
|
+
sends = consolidateMessages(sends);
|
|
4563
|
+
receives = consolidateMessages(receives);
|
|
4542
4564
|
await writeService(
|
|
4543
4565
|
{
|
|
4544
4566
|
id: serviceId,
|