@eventcatalog/generator-asyncapi 4.2.0 → 4.3.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.mjs CHANGED
@@ -1051,9 +1051,9 @@ var require_src = __commonJS({
1051
1051
  }
1052
1052
  });
1053
1053
 
1054
- // ../../node_modules/.pnpm/agent-base@7.1.3/node_modules/agent-base/dist/helpers.js
1054
+ // ../../node_modules/.pnpm/agent-base@7.1.4/node_modules/agent-base/dist/helpers.js
1055
1055
  var require_helpers = __commonJS({
1056
- "../../node_modules/.pnpm/agent-base@7.1.3/node_modules/agent-base/dist/helpers.js"(exports) {
1056
+ "../../node_modules/.pnpm/agent-base@7.1.4/node_modules/agent-base/dist/helpers.js"(exports) {
1057
1057
  "use strict";
1058
1058
  var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
1059
1059
  if (k2 === void 0) k2 = k;
@@ -1121,9 +1121,9 @@ var require_helpers = __commonJS({
1121
1121
  }
1122
1122
  });
1123
1123
 
1124
- // ../../node_modules/.pnpm/agent-base@7.1.3/node_modules/agent-base/dist/index.js
1124
+ // ../../node_modules/.pnpm/agent-base@7.1.4/node_modules/agent-base/dist/index.js
1125
1125
  var require_dist = __commonJS({
1126
- "../../node_modules/.pnpm/agent-base@7.1.3/node_modules/agent-base/dist/index.js"(exports) {
1126
+ "../../node_modules/.pnpm/agent-base@7.1.4/node_modules/agent-base/dist/index.js"(exports) {
1127
1127
  "use strict";
1128
1128
  var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
1129
1129
  if (k2 === void 0) k2 = k;
@@ -1219,7 +1219,7 @@ var require_dist = __commonJS({
1219
1219
  // In order to properly update the socket pool, we need to call `getName()` on
1220
1220
  // the core `https.Agent` if it is a secureEndpoint.
1221
1221
  getName(options) {
1222
- const secureEndpoint = typeof options.secureEndpoint === "boolean" ? options.secureEndpoint : this.isSecureEndpoint(options);
1222
+ const secureEndpoint = this.isSecureEndpoint(options);
1223
1223
  if (secureEndpoint) {
1224
1224
  return https_1.Agent.prototype.getName.call(this, options);
1225
1225
  }
@@ -1536,7 +1536,7 @@ import path2 from "path";
1536
1536
  // package.json
1537
1537
  var package_default = {
1538
1538
  name: "@eventcatalog/generator-asyncapi",
1539
- version: "4.2.0",
1539
+ version: "4.3.0",
1540
1540
  description: "AsyncAPI generator for EventCatalog",
1541
1541
  scripts: {
1542
1542
  build: "tsup",
@@ -1574,7 +1574,7 @@ var package_default = {
1574
1574
  dependencies: {
1575
1575
  "@asyncapi/avro-schema-parser": "^3.0.24",
1576
1576
  "@asyncapi/parser": "^3.3.0",
1577
- "@eventcatalog/sdk": "^2.2.6",
1577
+ "@eventcatalog/sdk": "^2.5.5",
1578
1578
  chalk: "^4",
1579
1579
  "fs-extra": "^11.2.0",
1580
1580
  glob: "^11.0.0",
@@ -2657,15 +2657,47 @@ var optionsSchema = z.object({
2657
2657
  id: z.string({ required_error: "The service id is required. please provide the service id" }),
2658
2658
  path: z.string({ required_error: "The service path is required. please provide the path to specification file" }),
2659
2659
  name: z.string().optional(),
2660
- owners: z.array(z.string()).optional()
2660
+ owners: z.array(z.string()).optional(),
2661
+ generateMarkdown: z.function().args(
2662
+ z.object({
2663
+ service: z.object({
2664
+ id: z.string(),
2665
+ name: z.string(),
2666
+ version: z.string()
2667
+ }),
2668
+ // AsyncAPI Interface
2669
+ document: z.any(),
2670
+ markdown: z.string().optional()
2671
+ })
2672
+ ).returns(z.string()).optional()
2661
2673
  }),
2662
2674
  { message: "Please provide correct services configuration" }
2663
2675
  ),
2676
+ messages: z.object({
2677
+ generateMarkdown: z.function().args(
2678
+ z.object({
2679
+ message: z.any(),
2680
+ document: z.any(),
2681
+ markdown: z.string().optional()
2682
+ })
2683
+ ).returns(z.string()).optional()
2684
+ }).optional(),
2664
2685
  domain: z.object({
2665
2686
  id: z.string({ required_error: "The domain id is required. please provide a domain id" }),
2666
2687
  name: z.string({ required_error: "The domain name is required. please provide a domain name" }),
2667
2688
  owners: z.array(z.string()).optional(),
2668
- version: z.string({ required_error: "The domain version is required. please provide a domain version" })
2689
+ version: z.string({ required_error: "The domain version is required. please provide a domain version" }),
2690
+ // function that takes options (including domain) and returns a string
2691
+ generateMarkdown: z.function().args(
2692
+ z.object({
2693
+ domain: z.object({
2694
+ id: z.string(),
2695
+ name: z.string(),
2696
+ version: z.string()
2697
+ }),
2698
+ markdown: z.string().optional()
2699
+ })
2700
+ ).returns(z.string()).optional()
2669
2701
  }).optional(),
2670
2702
  debug: z.boolean().optional(),
2671
2703
  parseSchemas: z.boolean().optional(),
@@ -2769,7 +2801,12 @@ var index_default = async (config, options) => {
2769
2801
  let repository = null;
2770
2802
  let serviceSpecifications = {};
2771
2803
  let serviceSpecificationsFiles = [];
2772
- let serviceMarkdown = defaultMarkdown2(document2);
2804
+ const generatedMarkdownForService = defaultMarkdown2(document2);
2805
+ let serviceMarkdown = service.generateMarkdown ? service.generateMarkdown({
2806
+ service: { id: service.id, name: serviceName, version },
2807
+ document: document2,
2808
+ markdown: generatedMarkdownForService
2809
+ }) : generatedMarkdownForService;
2773
2810
  let styles2 = null;
2774
2811
  let servicePath = options.domain ? path2.join("../", "domains", options.domain.id, "services", service.id) : path2.join("../", "services", service.id);
2775
2812
  if (options.writeFilesToRoot) {
@@ -2786,11 +2823,12 @@ Processing domain: ${domainName} (v${domainVersion})`));
2786
2823
  console.log(chalk3.cyan(` - Versioned previous domain (v${currentDomain.version})`));
2787
2824
  }
2788
2825
  if (!domain || domain && domain.version !== domainVersion) {
2826
+ const generatedMarkdownForDomain = defaultMarkdown3(document2);
2789
2827
  await writeDomain({
2790
2828
  id: domainId,
2791
2829
  name: domainName,
2792
2830
  version: domainVersion,
2793
- markdown: defaultMarkdown3(document2),
2831
+ markdown: options.domain?.generateMarkdown ? options.domain.generateMarkdown({ domain: options.domain, markdown: generatedMarkdownForDomain }) : generatedMarkdownForDomain,
2794
2832
  ...domainOwners && { owners: domainOwners }
2795
2833
  // services: [{ id: serviceId, version: version }],
2796
2834
  });
@@ -2866,7 +2904,8 @@ Processing domain: ${domainName} (v${domainVersion})`));
2866
2904
  addSchema: addSchemaToMessage,
2867
2905
  collection: folder
2868
2906
  } = MESSAGE_OPERATIONS[eventType];
2869
- let messageMarkdown = defaultMarkdown(document2, message);
2907
+ const generatedMarkdownForMessage = defaultMarkdown(document2, message);
2908
+ let messageMarkdown = options.messages?.generateMarkdown ? options.messages.generateMarkdown({ message, document: document2, markdown: generatedMarkdownForMessage }) : generatedMarkdownForMessage;
2870
2909
  const badges = message.tags().all() || [];
2871
2910
  console.log(chalk3.blue(`Processing message: ${getMessageName(message)} (v${messageVersion})`));
2872
2911
  let messagePath = join(servicePath, folder, message.id());