@eventcatalog/generator-asyncapi 6.3.0 → 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.0",
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));
@@ -4173,10 +4178,12 @@ var consolidateMessages = (array) => {
4173
4178
  const existing = map.get(key);
4174
4179
  if (existing) {
4175
4180
  if (item.to) {
4176
- existing.to = [...existing.to || [], ...item.to];
4181
+ const merged = [...existing.to || [], ...item.to];
4182
+ existing.to = merged.filter((ch, i, arr) => i === arr.findIndex((c) => c.id === ch.id));
4177
4183
  }
4178
4184
  if (item.from) {
4179
- existing.from = [...existing.from || [], ...item.from];
4185
+ const merged = [...existing.from || [], ...item.from];
4186
+ existing.from = merged.filter((ch, i, arr) => i === arr.findIndex((c) => c.id === ch.id));
4180
4187
  }
4181
4188
  } else {
4182
4189
  map.set(key, { ...item });
@@ -4513,6 +4520,7 @@ Processing domain: ${domainName} (v${domainVersion})`));
4513
4520
  } else {
4514
4521
  console.log(import_chalk4.default.yellow(` - Skipping external message: ${getMessageName(message2)}(v${messageVersion})`));
4515
4522
  }
4523
+ const group = options.groupMessagesBy === "x-extension" ? message2.extensions().get("x-eventcatalog-group")?.value() || void 0 : void 0;
4516
4524
  if (parseChannels) {
4517
4525
  const operationChannels = operation.channels().all();
4518
4526
  const channelPointers = operationChannels.map((channel) => {
@@ -4520,16 +4528,22 @@ Processing domain: ${domainName} (v${domainVersion})`));
4520
4528
  return { id: channel.id(), ...explicitVersion && { version: explicitVersion } };
4521
4529
  });
4522
4530
  if (isSent)
4523
- 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
+ });
4524
4537
  if (isReceived)
4525
4538
  receives.push({
4526
4539
  id: messageId,
4527
4540
  version: messageVersion,
4528
- ...channelPointers.length > 0 && { from: channelPointers }
4541
+ ...channelPointers.length > 0 && { from: channelPointers },
4542
+ ...group && { group }
4529
4543
  });
4530
4544
  } else {
4531
- if (isSent) sends.push({ id: messageId, version: messageVersion });
4532
- 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 } });
4533
4547
  }
4534
4548
  }
4535
4549
  }