@eventcatalog/generator-asyncapi 6.3.1 → 6.4.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.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.3.1",
1541
+ version: "6.4.1",
1542
1542
  description: "AsyncAPI generator for EventCatalog",
1543
1543
  scripts: {
1544
1544
  build: "tsup",
@@ -4156,7 +4156,12 @@ var optionsSchema = z.object({
4156
4156
  parseChannels: z.boolean().optional(),
4157
4157
  parseExamples: z.boolean().optional(),
4158
4158
  attachHeadersToSchema: z.boolean().optional(),
4159
- saveParsedSpecFile: z.boolean({ invalid_type_error: "The saveParsedSpecFile is not a boolean in options" }).optional()
4159
+ saveParsedSpecFile: z.boolean({ invalid_type_error: "The saveParsedSpecFile is not a boolean in options" }).optional(),
4160
+ /**
4161
+ * Group messages in the visualiser using the `x-eventcatalog-group` extension
4162
+ * on each message in the AsyncAPI spec.
4163
+ */
4164
+ groupMessagesBy: z.enum(["x-extension"]).optional()
4160
4165
  });
4161
4166
  var toUniqueArray = (array) => {
4162
4167
  return array.filter((item, index, self) => index === self.findIndex((t) => t.id === item.id && t.version === item.version));
@@ -4353,6 +4358,18 @@ Processing domain: ${domainName} (v${domainVersion})`));
4353
4358
  } else {
4354
4359
  servicePath = path3.join("../", "domains", options.domain.id, "services", service.id);
4355
4360
  }
4361
+ } else {
4362
+ const existingService = await getService(serviceId, "latest");
4363
+ if (existingService) {
4364
+ const existingServiceResource = await getResourcePath(
4365
+ process.env.PROJECT_DIR,
4366
+ serviceId,
4367
+ existingService.version
4368
+ );
4369
+ if (existingServiceResource) {
4370
+ servicePath = path3.join("../", existingServiceResource.directory);
4371
+ }
4372
+ }
4356
4373
  }
4357
4374
  if (options.writeFilesToRoot) {
4358
4375
  servicePath = service.id;
@@ -4510,6 +4527,7 @@ Processing domain: ${domainName} (v${domainVersion})`));
4510
4527
  } else {
4511
4528
  console.log(chalk4.yellow(` - Skipping external message: ${getMessageName(message2)}(v${messageVersion})`));
4512
4529
  }
4530
+ const group = options.groupMessagesBy === "x-extension" ? message2.extensions().get("x-eventcatalog-group")?.value() || void 0 : void 0;
4513
4531
  if (parseChannels) {
4514
4532
  const operationChannels = operation.channels().all();
4515
4533
  const channelPointers = operationChannels.map((channel) => {
@@ -4517,16 +4535,22 @@ Processing domain: ${domainName} (v${domainVersion})`));
4517
4535
  return { id: channel.id(), ...explicitVersion && { version: explicitVersion } };
4518
4536
  });
4519
4537
  if (isSent)
4520
- sends.push({ id: messageId, version: messageVersion, ...channelPointers.length > 0 && { to: channelPointers } });
4538
+ sends.push({
4539
+ id: messageId,
4540
+ version: messageVersion,
4541
+ ...channelPointers.length > 0 && { to: channelPointers },
4542
+ ...group && { group }
4543
+ });
4521
4544
  if (isReceived)
4522
4545
  receives.push({
4523
4546
  id: messageId,
4524
4547
  version: messageVersion,
4525
- ...channelPointers.length > 0 && { from: channelPointers }
4548
+ ...channelPointers.length > 0 && { from: channelPointers },
4549
+ ...group && { group }
4526
4550
  });
4527
4551
  } else {
4528
- if (isSent) sends.push({ id: messageId, version: messageVersion });
4529
- if (isReceived) receives.push({ id: messageId, version: messageVersion });
4552
+ if (isSent) sends.push({ id: messageId, version: messageVersion, ...group && { group } });
4553
+ if (isReceived) receives.push({ id: messageId, version: messageVersion, ...group && { group } });
4530
4554
  }
4531
4555
  }
4532
4556
  }