@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.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.
|
|
1546
|
+
version: "6.3.1",
|
|
1547
1547
|
description: "AsyncAPI generator for EventCatalog",
|
|
1548
1548
|
scripts: {
|
|
1549
1549
|
build: "tsup",
|
|
@@ -4166,6 +4166,26 @@ 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
|
+
const merged = [...existing.to || [], ...item.to];
|
|
4177
|
+
existing.to = merged.filter((ch, i, arr) => i === arr.findIndex((c) => c.id === ch.id));
|
|
4178
|
+
}
|
|
4179
|
+
if (item.from) {
|
|
4180
|
+
const merged = [...existing.from || [], ...item.from];
|
|
4181
|
+
existing.from = merged.filter((ch, i, arr) => i === arr.findIndex((c) => c.id === ch.id));
|
|
4182
|
+
}
|
|
4183
|
+
} else {
|
|
4184
|
+
map.set(key, { ...item });
|
|
4185
|
+
}
|
|
4186
|
+
}
|
|
4187
|
+
return Array.from(map.values());
|
|
4188
|
+
};
|
|
4169
4189
|
var mergeAsyncApiIntoSpecifications = (existingSpecs, asyncapiFileName) => {
|
|
4170
4190
|
if (Array.isArray(existingSpecs)) {
|
|
4171
4191
|
return [...existingSpecs.filter((spec) => spec.type !== "asyncapi"), { type: "asyncapi", path: asyncapiFileName }];
|
|
@@ -4544,6 +4564,8 @@ Processing domain: ${domainName} (v${domainVersion})`));
|
|
|
4544
4564
|
}
|
|
4545
4565
|
}
|
|
4546
4566
|
const fileName = import_path3.default.basename(service.path);
|
|
4567
|
+
sends = consolidateMessages(sends);
|
|
4568
|
+
receives = consolidateMessages(receives);
|
|
4547
4569
|
await writeService(
|
|
4548
4570
|
{
|
|
4549
4571
|
id: serviceId,
|