@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.d.mts CHANGED
@@ -244,6 +244,11 @@ declare const optionsSchema: z.ZodObject<{
244
244
  parseExamples: z.ZodOptional<z.ZodBoolean>;
245
245
  attachHeadersToSchema: z.ZodOptional<z.ZodBoolean>;
246
246
  saveParsedSpecFile: z.ZodOptional<z.ZodBoolean>;
247
+ /**
248
+ * Group messages in the visualiser using the `x-eventcatalog-group` extension
249
+ * on each message in the AsyncAPI spec.
250
+ */
251
+ groupMessagesBy: z.ZodOptional<z.ZodEnum<["x-extension"]>>;
247
252
  }, "strip", z.ZodTypeAny, {
248
253
  services: {
249
254
  path: string;
@@ -308,6 +313,7 @@ declare const optionsSchema: z.ZodObject<{
308
313
  parseExamples?: boolean | undefined;
309
314
  attachHeadersToSchema?: boolean | undefined;
310
315
  saveParsedSpecFile?: boolean | undefined;
316
+ groupMessagesBy?: "x-extension" | undefined;
311
317
  }, {
312
318
  services: {
313
319
  path: string;
@@ -372,6 +378,7 @@ declare const optionsSchema: z.ZodObject<{
372
378
  parseExamples?: boolean | undefined;
373
379
  attachHeadersToSchema?: boolean | undefined;
374
380
  saveParsedSpecFile?: boolean | undefined;
381
+ groupMessagesBy?: "x-extension" | undefined;
375
382
  }>;
376
383
  type Props = z.infer<typeof optionsSchema>;
377
384
  declare const _default: (config: any, options: Props) => Promise<void>;
package/dist/index.d.ts CHANGED
@@ -244,6 +244,11 @@ declare const optionsSchema: z.ZodObject<{
244
244
  parseExamples: z.ZodOptional<z.ZodBoolean>;
245
245
  attachHeadersToSchema: z.ZodOptional<z.ZodBoolean>;
246
246
  saveParsedSpecFile: z.ZodOptional<z.ZodBoolean>;
247
+ /**
248
+ * Group messages in the visualiser using the `x-eventcatalog-group` extension
249
+ * on each message in the AsyncAPI spec.
250
+ */
251
+ groupMessagesBy: z.ZodOptional<z.ZodEnum<["x-extension"]>>;
247
252
  }, "strip", z.ZodTypeAny, {
248
253
  services: {
249
254
  path: string;
@@ -308,6 +313,7 @@ declare const optionsSchema: z.ZodObject<{
308
313
  parseExamples?: boolean | undefined;
309
314
  attachHeadersToSchema?: boolean | undefined;
310
315
  saveParsedSpecFile?: boolean | undefined;
316
+ groupMessagesBy?: "x-extension" | undefined;
311
317
  }, {
312
318
  services: {
313
319
  path: string;
@@ -372,6 +378,7 @@ declare const optionsSchema: z.ZodObject<{
372
378
  parseExamples?: boolean | undefined;
373
379
  attachHeadersToSchema?: boolean | undefined;
374
380
  saveParsedSpecFile?: boolean | undefined;
381
+ groupMessagesBy?: "x-extension" | undefined;
375
382
  }>;
376
383
  type Props = z.infer<typeof optionsSchema>;
377
384
  declare const _default: (config: any, options: Props) => Promise<void>;
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.3.1",
1546
+ version: "6.4.1",
1547
1547
  description: "AsyncAPI generator for EventCatalog",
1548
1548
  scripts: {
1549
1549
  build: "tsup",
@@ -4161,7 +4161,12 @@ var optionsSchema = import_zod.z.object({
4161
4161
  parseChannels: import_zod.z.boolean().optional(),
4162
4162
  parseExamples: import_zod.z.boolean().optional(),
4163
4163
  attachHeadersToSchema: import_zod.z.boolean().optional(),
4164
- saveParsedSpecFile: import_zod.z.boolean({ invalid_type_error: "The saveParsedSpecFile is not a boolean in options" }).optional()
4164
+ saveParsedSpecFile: import_zod.z.boolean({ invalid_type_error: "The saveParsedSpecFile is not a boolean in options" }).optional(),
4165
+ /**
4166
+ * Group messages in the visualiser using the `x-eventcatalog-group` extension
4167
+ * on each message in the AsyncAPI spec.
4168
+ */
4169
+ groupMessagesBy: import_zod.z.enum(["x-extension"]).optional()
4165
4170
  });
4166
4171
  var toUniqueArray = (array) => {
4167
4172
  return array.filter((item, index, self) => index === self.findIndex((t) => t.id === item.id && t.version === item.version));
@@ -4358,6 +4363,18 @@ Processing domain: ${domainName} (v${domainVersion})`));
4358
4363
  } else {
4359
4364
  servicePath = import_path3.default.join("../", "domains", options.domain.id, "services", service.id);
4360
4365
  }
4366
+ } else {
4367
+ const existingService = await getService(serviceId, "latest");
4368
+ if (existingService) {
4369
+ const existingServiceResource = await getResourcePath(
4370
+ process.env.PROJECT_DIR,
4371
+ serviceId,
4372
+ existingService.version
4373
+ );
4374
+ if (existingServiceResource) {
4375
+ servicePath = import_path3.default.join("../", existingServiceResource.directory);
4376
+ }
4377
+ }
4361
4378
  }
4362
4379
  if (options.writeFilesToRoot) {
4363
4380
  servicePath = service.id;
@@ -4515,6 +4532,7 @@ Processing domain: ${domainName} (v${domainVersion})`));
4515
4532
  } else {
4516
4533
  console.log(import_chalk4.default.yellow(` - Skipping external message: ${getMessageName(message2)}(v${messageVersion})`));
4517
4534
  }
4535
+ const group = options.groupMessagesBy === "x-extension" ? message2.extensions().get("x-eventcatalog-group")?.value() || void 0 : void 0;
4518
4536
  if (parseChannels) {
4519
4537
  const operationChannels = operation.channels().all();
4520
4538
  const channelPointers = operationChannels.map((channel) => {
@@ -4522,16 +4540,22 @@ Processing domain: ${domainName} (v${domainVersion})`));
4522
4540
  return { id: channel.id(), ...explicitVersion && { version: explicitVersion } };
4523
4541
  });
4524
4542
  if (isSent)
4525
- sends.push({ id: messageId, version: messageVersion, ...channelPointers.length > 0 && { to: channelPointers } });
4543
+ sends.push({
4544
+ id: messageId,
4545
+ version: messageVersion,
4546
+ ...channelPointers.length > 0 && { to: channelPointers },
4547
+ ...group && { group }
4548
+ });
4526
4549
  if (isReceived)
4527
4550
  receives.push({
4528
4551
  id: messageId,
4529
4552
  version: messageVersion,
4530
- ...channelPointers.length > 0 && { from: channelPointers }
4553
+ ...channelPointers.length > 0 && { from: channelPointers },
4554
+ ...group && { group }
4531
4555
  });
4532
4556
  } else {
4533
- if (isSent) sends.push({ id: messageId, version: messageVersion });
4534
- if (isReceived) receives.push({ id: messageId, version: messageVersion });
4557
+ if (isSent) sends.push({ id: messageId, version: messageVersion, ...group && { group } });
4558
+ if (isReceived) receives.push({ id: messageId, version: messageVersion, ...group && { group } });
4535
4559
  }
4536
4560
  }
4537
4561
  }