@eventcatalog/generator-asyncapi 6.3.1 → 6.4.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.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.0",
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));
@@ -4515,6 +4520,7 @@ Processing domain: ${domainName} (v${domainVersion})`));
4515
4520
  } else {
4516
4521
  console.log(import_chalk4.default.yellow(` - Skipping external message: ${getMessageName(message2)}(v${messageVersion})`));
4517
4522
  }
4523
+ const group = options.groupMessagesBy === "x-extension" ? message2.extensions().get("x-eventcatalog-group")?.value() || void 0 : void 0;
4518
4524
  if (parseChannels) {
4519
4525
  const operationChannels = operation.channels().all();
4520
4526
  const channelPointers = operationChannels.map((channel) => {
@@ -4522,16 +4528,22 @@ Processing domain: ${domainName} (v${domainVersion})`));
4522
4528
  return { id: channel.id(), ...explicitVersion && { version: explicitVersion } };
4523
4529
  });
4524
4530
  if (isSent)
4525
- sends.push({ id: messageId, version: messageVersion, ...channelPointers.length > 0 && { to: channelPointers } });
4531
+ sends.push({
4532
+ id: messageId,
4533
+ version: messageVersion,
4534
+ ...channelPointers.length > 0 && { to: channelPointers },
4535
+ ...group && { group }
4536
+ });
4526
4537
  if (isReceived)
4527
4538
  receives.push({
4528
4539
  id: messageId,
4529
4540
  version: messageVersion,
4530
- ...channelPointers.length > 0 && { from: channelPointers }
4541
+ ...channelPointers.length > 0 && { from: channelPointers },
4542
+ ...group && { group }
4531
4543
  });
4532
4544
  } else {
4533
- if (isSent) sends.push({ id: messageId, version: messageVersion });
4534
- if (isReceived) receives.push({ id: messageId, version: messageVersion });
4545
+ if (isSent) sends.push({ id: messageId, version: messageVersion, ...group && { group } });
4546
+ if (isReceived) receives.push({ id: messageId, version: messageVersion, ...group && { group } });
4535
4547
  }
4536
4548
  }
4537
4549
  }