@eventcatalog/generator-asyncapi 1.0.5 → 2.0.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/README.md CHANGED
@@ -42,8 +42,8 @@ generators: [
42
42
  '@eventcatalog/generator-asyncapi',
43
43
  {
44
44
  services: [
45
- { path: path.join(__dirname, 'asyncapi-files', 'orders-service.asyncapi.yml')},
46
- { path: path.join(__dirname, 'asyncapi-files', 'accounts-service.asyncapi.yml', folderName: 'Account', id: 'account-service')}
45
+ { path: path.join(__dirname, 'asyncapi-files', 'orders-service.asyncapi.yml'), id: 'Orders Service'},
46
+ { path: path.join(__dirname, 'asyncapi-files', 'accounts-service.asyncapi.yml', id: 'Accounts Service', name: 'Awesome Accounts Service')}
47
47
  ],
48
48
  domain: { id: 'orders', name: 'Orders', version: '0.0.1' },
49
49
  },
package/dist/index.d.mts CHANGED
@@ -4,14 +4,15 @@ type Domain = {
4
4
  version: string;
5
5
  };
6
6
  type Service = {
7
- id?: string;
7
+ id: string;
8
8
  path: string;
9
- folderName?: string;
9
+ name?: string;
10
10
  };
11
11
  type Props = {
12
12
  services: Service[];
13
13
  domain?: Domain;
14
14
  debug?: boolean;
15
+ saveParsedSpecFile?: boolean;
15
16
  };
16
17
  declare const _default: (config: any, options: Props) => Promise<void>;
17
18
 
package/dist/index.d.ts CHANGED
@@ -4,14 +4,15 @@ type Domain = {
4
4
  version: string;
5
5
  };
6
6
  type Service = {
7
- id?: string;
7
+ id: string;
8
8
  path: string;
9
- folderName?: string;
9
+ name?: string;
10
10
  };
11
11
  type Props = {
12
12
  services: Service[];
13
13
  domain?: Domain;
14
14
  debug?: boolean;
15
+ saveParsedSpecFile?: boolean;
15
16
  };
16
17
  declare const _default: (config: any, options: Props) => Promise<void>;
17
18
 
package/dist/index.js CHANGED
@@ -35,7 +35,7 @@ __export(src_exports, {
35
35
  module.exports = __toCommonJS(src_exports);
36
36
  var import_parser = require("@asyncapi/parser");
37
37
  var import_sdk = __toESM(require("@eventcatalog/sdk"));
38
- var import_slugify = __toESM(require("slugify"));
38
+ var import_promises = require("fs/promises");
39
39
 
40
40
  // src/utils/schemas.ts
41
41
  var getFileExtentionFromSchemaFormat = (format = "") => {
@@ -170,9 +170,10 @@ var src_default = async (config, options) => {
170
170
  addSchemaToCommand,
171
171
  addSchemaToEvent,
172
172
  addFileToService,
173
- versionDomain
173
+ versionDomain,
174
+ getSpecificationFilesForService
174
175
  } = (0, import_sdk.default)(process.env.PROJECT_DIR);
175
- const services = options.services;
176
+ const { services, saveParsedSpecFile = false } = options;
176
177
  console.log(import_chalk2.default.green(`Processing ${services.length} AsyncAPI files...`));
177
178
  for (const service of services) {
178
179
  console.log(import_chalk2.default.gray(`Processing ${service.path}`));
@@ -188,11 +189,13 @@ var src_default = async (config, options) => {
188
189
  }
189
190
  const operations = document.allOperations();
190
191
  const documentTags = document.info().tags().all() || [];
191
- const serviceId = service.id || (0, import_slugify.default)(document.info().title(), { lower: true, strict: true });
192
+ const serviceId = service.id;
193
+ const serviceName = service.name || document.info().title();
192
194
  const version = document.info().version();
193
- const sends = [];
194
- const receives = [];
195
- let specifications = {};
195
+ let sends = [];
196
+ let receives = [];
197
+ let serviceSpecifications = {};
198
+ let serviceSpecificationsFiles = [];
196
199
  let serviceMarkdown = defaultMarkdown2(document);
197
200
  if (options.domain) {
198
201
  const { id: domainId, name: domainName, version: domainVersion } = options.domain;
@@ -276,7 +279,7 @@ Processing domain: ${domainName} (v${domainVersion})`));
276
279
  }
277
280
  }
278
281
  const latestServiceInCatalog = await getService(serviceId, "latest");
279
- console.log(import_chalk2.default.blue(`Processing service: ${document.info().title()} (v${version})`));
282
+ console.log(import_chalk2.default.blue(`Processing service: ${serviceId} (v${version})`));
280
283
  if (latestServiceInCatalog) {
281
284
  serviceMarkdown = latestServiceInCatalog.markdown;
282
285
  if (latestServiceInCatalog.version !== version) {
@@ -285,40 +288,55 @@ Processing domain: ${domainName} (v${domainVersion})`));
285
288
  }
286
289
  if (latestServiceInCatalog.version === version) {
287
290
  serviceMarkdown = latestServiceInCatalog.markdown;
288
- specifications = latestServiceInCatalog.specifications ?? {};
289
- await rmService(service.folderName || document.info().title());
291
+ serviceSpecifications = latestServiceInCatalog.specifications ?? {};
292
+ sends = latestServiceInCatalog.sends ? [...latestServiceInCatalog.sends, ...sends] : sends;
293
+ receives = latestServiceInCatalog.receives ? [...latestServiceInCatalog.receives, ...receives] : receives;
294
+ serviceSpecificationsFiles = await getSpecificationFilesForService(serviceId, version);
295
+ await rmService(serviceId);
290
296
  }
291
297
  }
292
- await writeService(
293
- {
294
- id: serviceId,
295
- name: document.info().title(),
296
- version,
297
- summary: getSummary2(document),
298
- badges: documentTags.map((tag) => ({ content: tag.name(), textColor: "blue", backgroundColor: "blue" })),
299
- markdown: serviceMarkdown,
300
- sends,
301
- receives,
302
- schemaPath: service.path.split("/").pop() || "asyncapi.yml",
303
- specifications: {
304
- ...specifications,
305
- asyncapiPath: service.path.split("/").pop() || "asyncapi.yml"
306
- }
307
- },
308
- { path: service.folderName || document.info().title() }
309
- );
310
- await addFileToService(
311
- serviceId,
298
+ await writeService({
299
+ id: serviceId,
300
+ name: serviceName,
301
+ version,
302
+ summary: getSummary2(document),
303
+ badges: documentTags.map((tag) => ({ content: tag.name(), textColor: "blue", backgroundColor: "blue" })),
304
+ markdown: serviceMarkdown,
305
+ sends,
306
+ receives,
307
+ schemaPath: service.path.split("/").pop() || "asyncapi.yml",
308
+ specifications: {
309
+ ...serviceSpecifications,
310
+ asyncapiPath: service.path.split("/").pop() || "asyncapi.yml"
311
+ }
312
+ });
313
+ const specFiles = [
314
+ // add any previous spec files to the list
315
+ ...serviceSpecificationsFiles,
312
316
  {
313
- fileName: service.path.split("/").pop() || "asyncapi.yml",
314
- content: service.path.endsWith(".json") ? JSON.stringify(document.meta().asyncapi.parsed, null, 4) : import_js_yaml.default.dump(document.meta().asyncapi.parsed, { noRefs: true })
315
- },
316
- version
317
- );
317
+ content: saveParsedSpecFile ? getParsedSpecFile(service, document) : await getRawSpecFile(service),
318
+ fileName: service.path.split("/").pop() || "asyncapi.yml"
319
+ }
320
+ ];
321
+ for (const specFile of specFiles) {
322
+ await addFileToService(
323
+ serviceId,
324
+ {
325
+ fileName: specFile.fileName,
326
+ content: specFile.content
327
+ },
328
+ version
329
+ );
330
+ }
318
331
  console.log(import_chalk2.default.cyan(` - Service (v${version}) created`));
319
332
  console.log(import_chalk2.default.green(`
320
- Finished generating event catalog for AsyncAPI ${document.info().title()} (v${version})`));
333
+ Finished generating event catalog for AsyncAPI ${serviceId} (v${version})`));
321
334
  }
322
335
  await checkLicense_default();
323
336
  };
337
+ var getParsedSpecFile = (service, document) => {
338
+ const isSpecFileJSON = service.path.endsWith(".json");
339
+ return isSpecFileJSON ? JSON.stringify(document.meta().asyncapi.parsed, null, 4) : import_js_yaml.default.dump(document.meta().asyncapi.parsed, { noRefs: true });
340
+ };
341
+ var getRawSpecFile = async (service) => await (0, import_promises.readFile)(service.path, "utf8");
324
342
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/utils/schemas.ts","../src/utils/messages.ts","../src/utils/services.ts","../src/utils/domains.ts","../src/checkLicense.ts"],"sourcesContent":["// import utils from '@eventcatalog/sdk';\nimport { Parser, fromFile } from '@asyncapi/parser';\nimport utils from '@eventcatalog/sdk';\nimport slugify from 'slugify';\nimport {\n defaultMarkdown as generateMarkdownForMessage,\n getMessageName,\n getSummary as getMessageSummary,\n getSchemaFileName,\n messageHasSchema,\n} from './utils/messages';\nimport { defaultMarkdown as generateMarkdownForService, getSummary as getServiceSummary } from './utils/services';\nimport { defaultMarkdown as generateMarkdownForDomain } from './utils/domains';\nimport chalk from 'chalk';\nimport checkLicense from './checkLicense';\nimport argv from 'minimist';\nimport yaml from 'js-yaml';\n\n// AsyncAPI Parsers\nimport { AvroSchemaParser } from '@asyncapi/avro-schema-parser';\n\nconst parser = new Parser();\n\n// register avro schema support\nparser.registerSchemaParser(AvroSchemaParser());\n\nconst cliArgs = argv(process.argv.slice(2));\n\ntype Domain = {\n id: string;\n name: string;\n version: string;\n};\n\ntype Service = {\n id?: string;\n path: string;\n folderName?: string;\n};\n\ntype Props = {\n services: Service[];\n domain?: Domain;\n debug?: boolean;\n};\n\nexport default async (config: any, options: Props) => {\n if (!process.env.PROJECT_DIR) {\n throw new Error('Please provide catalog url (env variable PROJECT_DIR)');\n }\n\n const {\n writeService,\n writeEvent,\n writeCommand,\n getService,\n versionService,\n rmService,\n getDomain,\n writeDomain,\n addServiceToDomain,\n getCommand,\n getEvent,\n rmEventById,\n rmCommandById,\n versionCommand,\n versionEvent,\n addSchemaToCommand,\n addSchemaToEvent,\n addFileToService,\n versionDomain,\n } = utils(process.env.PROJECT_DIR);\n\n const services = options.services;\n // const asyncAPIFiles = Array.isArray(options.path) ? options.path : [options.path];\n\n console.log(chalk.green(`Processing ${services.length} AsyncAPI files...`));\n\n for (const service of services) {\n console.log(chalk.gray(`Processing ${service.path}`));\n\n const { document, diagnostics } = await fromFile(parser, service.path).parse();\n\n if (!document) {\n console.log(chalk.red('Failed to parse AsyncAPI file'));\n if (options.debug || cliArgs.debug) {\n console.log(diagnostics);\n } else {\n console.log(chalk.red('Run with debug option in the generator to see diagnostics'));\n }\n continue;\n }\n\n const operations = document.allOperations();\n const documentTags = document.info().tags().all() || [];\n\n const serviceId = service.id || slugify(document.info().title(), { lower: true, strict: true });\n const version = document.info().version();\n\n // What messages does this service send and receive\n const sends = [];\n const receives = [];\n let specifications = {};\n\n let serviceMarkdown = generateMarkdownForService(document);\n\n // Manage domain\n if (options.domain) {\n // Try and get the domain\n const { id: domainId, name: domainName, version: domainVersion } = options.domain;\n const domain = await getDomain(options.domain.id, domainVersion || 'latest');\n const currentDomain = await getDomain(options.domain.id, 'latest');\n\n console.log(chalk.blue(`\\nProcessing domain: ${domainName} (v${domainVersion})`));\n\n // Found a domain, but the versions do not match\n if (currentDomain && currentDomain.version !== domainVersion) {\n await versionDomain(domainId);\n console.log(chalk.cyan(` - Versioned previous domain (v${currentDomain.version})`));\n }\n\n // Do we need to create a new domain?\n if (!domain || (domain && domain.version !== domainVersion)) {\n await writeDomain({\n id: domainId,\n name: domainName,\n version: domainVersion,\n markdown: generateMarkdownForDomain(document),\n // services: [{ id: serviceId, version: version }],\n });\n console.log(chalk.cyan(` - Domain (v${domainVersion}) created`));\n }\n\n if (currentDomain && currentDomain.version === domainVersion) {\n console.log(chalk.yellow(` - Domain (v${domainVersion}) already exists, skipped creation...`));\n }\n\n // Add the service to the domain\n await addServiceToDomain(domainId, { id: serviceId, version: version }, domainVersion);\n }\n\n // Find events/commands\n for (const operation of operations) {\n for (const message of operation.messages()) {\n const eventType = message.extensions().get('x-eventcatalog-message-type')?.value() || 'event';\n\n const messageId = message.id().toLowerCase();\n\n let messageMarkdown = generateMarkdownForMessage(document, message);\n const writeMessage = eventType === 'event' ? writeEvent : writeCommand;\n const versionMessage = eventType === 'event' ? versionEvent : versionCommand;\n const getMessage = eventType === 'event' ? getEvent : getCommand;\n const rmMessageById = eventType === 'event' ? rmEventById : rmCommandById;\n const addSchemaToMessage = eventType === 'event' ? addSchemaToEvent : addSchemaToCommand;\n const badges = message.tags().all() || [];\n\n // Check if the message already exists in the catalog\n const catalogedMessage = await getMessage(message.id().toLowerCase(), 'latest');\n\n console.log(chalk.blue(`Processing message: ${getMessageName(message)} (v${version})`));\n\n if (catalogedMessage) {\n messageMarkdown = catalogedMessage.markdown;\n // if the version matches, we can override the message but keep markdown as it was\n if (catalogedMessage.version === version) {\n await rmMessageById(messageId, version);\n } else {\n // if the version does not match, we need to version the message\n await versionMessage(messageId);\n console.log(chalk.cyan(` - Versioned previous message: (v${catalogedMessage.version})`));\n }\n }\n\n // Write the message to the catalog\n await writeMessage(\n {\n id: messageId,\n version: version,\n name: getMessageName(message),\n summary: getMessageSummary(message),\n markdown: messageMarkdown,\n badges: badges.map((badge) => ({ content: badge.name(), textColor: 'blue', backgroundColor: 'blue' })),\n schemaPath: messageHasSchema(message) ? getSchemaFileName(message) : undefined,\n },\n {\n path: message.id(),\n }\n );\n\n console.log(chalk.cyan(` - Message (v${version}) created`));\n\n // Check if the message has a payload, if it does then document in EventCatalog\n if (messageHasSchema(message)) {\n addSchemaToMessage(\n messageId,\n {\n fileName: getSchemaFileName(message),\n schema: JSON.stringify(message.payload()?.json(), null, 4),\n },\n version\n );\n console.log(chalk.cyan(` - Schema added to message (v${version})`));\n }\n\n // Add the message to the correct array\n if (operation.action() === 'send' || operation.action() === 'publish') {\n sends.push({ id: messageId, version: version });\n }\n if (operation.action() === 'receive' || operation.action() === 'subscribe') {\n receives.push({ id: messageId, version: version });\n }\n }\n }\n\n // Check if service is already defined... if the versions do not match then create service.\n const latestServiceInCatalog = await getService(serviceId, 'latest');\n\n console.log(chalk.blue(`Processing service: ${document.info().title()} (v${version})`));\n\n if (latestServiceInCatalog) {\n serviceMarkdown = latestServiceInCatalog.markdown;\n // Found a service, and versions do not match, we need to version the one already there\n if (latestServiceInCatalog.version !== version) {\n await versionService(serviceId);\n console.log(chalk.cyan(` - Versioned previous service (v${latestServiceInCatalog.version})`));\n }\n\n // Match found, override it\n if (latestServiceInCatalog.version === version) {\n serviceMarkdown = latestServiceInCatalog.markdown;\n specifications = latestServiceInCatalog.specifications ?? {};\n await rmService(service.folderName || document.info().title());\n }\n }\n\n await writeService(\n {\n id: serviceId,\n name: document.info().title(),\n version: version,\n summary: getServiceSummary(document),\n badges: documentTags.map((tag) => ({ content: tag.name(), textColor: 'blue', backgroundColor: 'blue' })),\n markdown: serviceMarkdown,\n sends,\n receives,\n schemaPath: service.path.split('/').pop() || 'asyncapi.yml',\n specifications: {\n ...specifications,\n asyncapiPath: service.path.split('/').pop() || 'asyncapi.yml',\n },\n },\n { path: service.folderName || document.info().title() }\n );\n\n await addFileToService(\n serviceId,\n {\n fileName: service.path.split('/').pop() || 'asyncapi.yml',\n content: service.path.endsWith('.json')\n ? JSON.stringify(document.meta().asyncapi.parsed, null, 4)\n : yaml.dump(document.meta().asyncapi.parsed, { noRefs: true }),\n },\n version\n );\n\n console.log(chalk.cyan(` - Service (v${version}) created`));\n\n console.log(chalk.green(`\\nFinished generating event catalog for AsyncAPI ${document.info().title()} (v${version})`));\n }\n\n await checkLicense();\n};\n","export const getFileExtentionFromSchemaFormat = (format: string | undefined = '') => {\n if (format.includes('avro')) return 'avsc';\n if (format.includes('yml')) return 'yml';\n if (format.includes('json')) return 'json';\n if (format.includes('openapi')) return 'openapi';\n if (format.includes('protobuf')) return 'protobuf';\n if (format.includes('yaml')) return 'yaml';\n\n return 'json';\n};\n","import { MessageInterface, AsyncAPIDocumentInterface } from '@asyncapi/parser';\nimport { getFileExtentionFromSchemaFormat } from './schemas';\n\nexport const defaultMarkdown = (_document: AsyncAPIDocumentInterface, message: MessageInterface) => {\n return `\n## Architecture\n<NodeGraph />\n\n${\n messageHasSchema(message) && messageIsJSON(message)\n ? `\n## Schema\n<SchemaViewer file=\"${getSchemaFileName(message)}\" title=\"Message Schema\" maxHeight=\"500\" />\n`\n : ''\n}\n${\n messageHasSchema(message) && !messageIsJSON(message)\n ? `\n## Schema\n<Schema file=\"${getSchemaFileName(message)}\" title=\"Message Schema\" maxHeight=\"500\" />\n`\n : ''\n}\n\n${\n message.externalDocs()\n ? `\n## External documentation\n- [${message.externalDocs()?.description()}](${message.externalDocs()?.url()})\n`\n : ''\n}\n\n`;\n};\n\nexport const getSummary = (message: MessageInterface) => {\n const messageSummary = message.hasSummary() ? message.summary() : '';\n const messageDescription = message.hasDescription() ? message.description() : '';\n\n let eventCatalogMessageSummary = messageSummary;\n\n if (!eventCatalogMessageSummary) {\n eventCatalogMessageSummary = messageDescription && messageDescription.length < 150 ? messageDescription : '';\n }\n\n return eventCatalogMessageSummary;\n};\n\nexport const messageHasSchema = (message: MessageInterface) => {\n return message.hasPayload() && message.schemaFormat();\n};\n\nexport const messageIsJSON = (message: MessageInterface) => {\n const fileName = getSchemaFileName(message);\n return fileName.endsWith('.json');\n};\n\nexport const getSchemaFileName = (message: MessageInterface) => {\n const extension = getFileExtentionFromSchemaFormat(message.schemaFormat());\n return `schema.${extension}`;\n};\n\nexport const getMessageName = (message: MessageInterface) => {\n return message.hasTitle() && message.title() ? (message.title() as string) : message.id();\n};\n","import { AsyncAPIDocumentInterface } from '@asyncapi/parser';\n\nexport const defaultMarkdown = (document: AsyncAPIDocumentInterface) => {\n return `\n\n${document.info().hasDescription() ? `${document.info().description()}` : ''} \n\n## Architecture diagram\n<NodeGraph />\n\n${\n document.info().externalDocs()\n ? `\n## External documentation\n- [${document.info().externalDocs()?.description()}](${document.info().externalDocs()?.url()})\n`\n : ''\n}\n`;\n};\n\nexport const getSummary = (document: AsyncAPIDocumentInterface) => {\n const summary = document.info().hasDescription() ? document.info().description() : '';\n return summary && summary.length < 150 ? summary : '';\n};\n","import { AsyncAPIDocumentInterface } from '@asyncapi/parser';\n\nexport const defaultMarkdown = (document: AsyncAPIDocumentInterface) => {\n return `\n\n## Architecture diagram\n<NodeGraph />\n\n`;\n};\n","import chalk from 'chalk';\n\nexport default () => {\n console.log(chalk.bgBlue(`\\nYou are using the open source license for this plugin`));\n console.log(\n chalk.blueBright(\n `This plugin is governed and published under a dual-license. \\nIf using for internal, commercial or proprietary software, please contact hello@eventcatalog.dev for a license to support the project.`\n )\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAAiC;AACjC,iBAAkB;AAClB,qBAAoB;;;ACHb,IAAM,mCAAmC,CAAC,SAA6B,OAAO;AACnF,MAAI,OAAO,SAAS,MAAM,EAAG,QAAO;AACpC,MAAI,OAAO,SAAS,KAAK,EAAG,QAAO;AACnC,MAAI,OAAO,SAAS,MAAM,EAAG,QAAO;AACpC,MAAI,OAAO,SAAS,SAAS,EAAG,QAAO;AACvC,MAAI,OAAO,SAAS,UAAU,EAAG,QAAO;AACxC,MAAI,OAAO,SA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IAAI,KAAK;AAAA,QAC3C,SAAS,QAAQ,KAAK,SAAS,OAAO,IAClC,KAAK,UAAU,SAAS,KAAK,EAAE,SAAS,QAAQ,MAAM,CAAC,IACvD,eAAAC,QAAK,KAAK,SAAS,KAAK,EAAE,SAAS,QAAQ,EAAE,QAAQ,KAAK,CAAC;AAAA,MACjE;AAAA,MACA;AAAA,IACF;AAEA,YAAQ,IAAI,cAAAJ,QAAM,KAAK,gBAAgB,OAAO,WAAW,CAAC;AAE1D,YAAQ,IAAI,cAAAA,QAAM,MAAM;AAAA,iDAAoD,SAAS,KAAK,EAAE,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC;AAAA,EACtH;AAEA,QAAM,qBAAa;AACrB;","names":["defaultMarkdown","getSummary","defaultMarkdown","import_chalk","chalk","argv","utils","chalk","slugify","defaultMarkdown","getSummary","yaml"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/utils/schemas.ts","../src/utils/messages.ts","../src/utils/services.ts","../src/utils/domains.ts","../src/checkLicense.ts"],"sourcesContent":["// import utils from '@eventcatalog/sdk';\nimport { AsyncAPIDocumentInterface, Parser, fromFile } from '@asyncapi/parser';\nimport utils from '@eventcatalog/sdk';\nimport slugify from 'slugify';\nimport { readFile } from 'node:fs/promises';\nimport {\n defaultMarkdown as generateMarkdownForMessage,\n getMessageName,\n getSummary as getMessageSummary,\n getSchemaFileName,\n messageHasSchema,\n} from './utils/messages';\nimport { defaultMarkdown as generateMarkdownForService, getSummary as getServiceSummary } from './utils/services';\nimport { defaultMarkdown as generateMarkdownForDomain } from './utils/domains';\nimport chalk from 'chalk';\nimport checkLicense from './checkLicense';\nimport argv from 'minimist';\nimport yaml from 'js-yaml';\n\n// AsyncAPI Parsers\nimport { AvroSchemaParser } from '@asyncapi/avro-schema-parser';\n\nconst parser = new Parser();\n\n// register avro schema support\nparser.registerSchemaParser(AvroSchemaParser());\n\nconst cliArgs = argv(process.argv.slice(2));\n\ntype Domain = {\n id: string;\n name: string;\n version: string;\n};\n\ntype Service = {\n id: string;\n path: string;\n name?: string;\n};\n\ntype Props = {\n services: Service[];\n domain?: Domain;\n debug?: boolean;\n saveParsedSpecFile?: boolean;\n};\n\nexport default async (config: any, options: Props) => {\n if (!process.env.PROJECT_DIR) {\n throw new Error('Please provide catalog url (env variable PROJECT_DIR)');\n }\n\n const {\n writeService,\n writeEvent,\n writeCommand,\n getService,\n versionService,\n rmService,\n getDomain,\n writeDomain,\n addServiceToDomain,\n getCommand,\n getEvent,\n rmEventById,\n rmCommandById,\n versionCommand,\n versionEvent,\n addSchemaToCommand,\n addSchemaToEvent,\n addFileToService,\n versionDomain,\n getSpecificationFilesForService,\n } = utils(process.env.PROJECT_DIR);\n\n // Should the file that is written to the catalog be parsed (https://github.com/asyncapi/parser-js) or as it is?\n const { services, saveParsedSpecFile = false } = options;\n // const asyncAPIFiles = Array.isArray(options.path) ? options.path : [options.path];\n console.log(chalk.green(`Processing ${services.length} AsyncAPI files...`));\n\n for (const service of services) {\n console.log(chalk.gray(`Processing ${service.path}`));\n\n const { document, diagnostics } = await fromFile(parser, service.path).parse();\n\n if (!document) {\n console.log(chalk.red('Failed to parse AsyncAPI file'));\n if (options.debug || cliArgs.debug) {\n console.log(diagnostics);\n } else {\n console.log(chalk.red('Run with debug option in the generator to see diagnostics'));\n }\n continue;\n }\n\n const operations = document.allOperations();\n const documentTags = document.info().tags().all() || [];\n\n const serviceId = service.id;\n const serviceName = service.name || document.info().title();\n const version = document.info().version();\n\n // What messages does this service send and receive\n let sends = [];\n let receives = [];\n\n let serviceSpecifications = {};\n let serviceSpecificationsFiles = [];\n let serviceMarkdown = generateMarkdownForService(document);\n\n // Manage domain\n if (options.domain) {\n // Try and get the domain\n const { id: domainId, name: domainName, version: domainVersion } = options.domain;\n const domain = await getDomain(options.domain.id, domainVersion || 'latest');\n const currentDomain = await getDomain(options.domain.id, 'latest');\n\n console.log(chalk.blue(`\\nProcessing domain: ${domainName} (v${domainVersion})`));\n\n // Found a domain, but the versions do not match\n if (currentDomain && currentDomain.version !== domainVersion) {\n await versionDomain(domainId);\n console.log(chalk.cyan(` - Versioned previous domain (v${currentDomain.version})`));\n }\n\n // Do we need to create a new domain?\n if (!domain || (domain && domain.version !== domainVersion)) {\n await writeDomain({\n id: domainId,\n name: domainName,\n version: domainVersion,\n markdown: generateMarkdownForDomain(document),\n // services: [{ id: serviceId, version: version }],\n });\n console.log(chalk.cyan(` - Domain (v${domainVersion}) created`));\n }\n\n if (currentDomain && currentDomain.version === domainVersion) {\n console.log(chalk.yellow(` - Domain (v${domainVersion}) already exists, skipped creation...`));\n }\n\n // Add the service to the domain\n await addServiceToDomain(domainId, { id: serviceId, version: version }, domainVersion);\n }\n\n // Find events/commands\n for (const operation of operations) {\n for (const message of operation.messages()) {\n const eventType = message.extensions().get('x-eventcatalog-message-type')?.value() || 'event';\n\n const messageId = message.id().toLowerCase();\n\n let messageMarkdown = generateMarkdownForMessage(document, message);\n const writeMessage = eventType === 'event' ? writeEvent : writeCommand;\n const versionMessage = eventType === 'event' ? versionEvent : versionCommand;\n const getMessage = eventType === 'event' ? getEvent : getCommand;\n const rmMessageById = eventType === 'event' ? rmEventById : rmCommandById;\n const addSchemaToMessage = eventType === 'event' ? addSchemaToEvent : addSchemaToCommand;\n const badges = message.tags().all() || [];\n\n // Check if the message already exists in the catalog\n const catalogedMessage = await getMessage(message.id().toLowerCase(), 'latest');\n\n console.log(chalk.blue(`Processing message: ${getMessageName(message)} (v${version})`));\n\n if (catalogedMessage) {\n messageMarkdown = catalogedMessage.markdown;\n // if the version matches, we can override the message but keep markdown as it was\n if (catalogedMessage.version === version) {\n await rmMessageById(messageId, version);\n } else {\n // if the version does not match, we need to version the message\n await versionMessage(messageId);\n console.log(chalk.cyan(` - Versioned previous message: (v${catalogedMessage.version})`));\n }\n }\n\n // Write the message to the catalog\n await writeMessage(\n {\n id: messageId,\n version: version,\n name: getMessageName(message),\n summary: getMessageSummary(message),\n markdown: messageMarkdown,\n badges: badges.map((badge) => ({ content: badge.name(), textColor: 'blue', backgroundColor: 'blue' })),\n schemaPath: messageHasSchema(message) ? getSchemaFileName(message) : undefined,\n },\n {\n path: message.id(),\n }\n );\n\n console.log(chalk.cyan(` - Message (v${version}) created`));\n\n // Check if the message has a payload, if it does then document in EventCatalog\n if (messageHasSchema(message)) {\n addSchemaToMessage(\n messageId,\n {\n fileName: getSchemaFileName(message),\n schema: JSON.stringify(message.payload()?.json(), null, 4),\n },\n version\n );\n console.log(chalk.cyan(` - Schema added to message (v${version})`));\n }\n\n // Add the message to the correct array\n if (operation.action() === 'send' || operation.action() === 'publish') {\n sends.push({ id: messageId, version: version });\n }\n if (operation.action() === 'receive' || operation.action() === 'subscribe') {\n receives.push({ id: messageId, version: version });\n }\n }\n }\n\n // Check if service is already defined... if the versions do not match then create service.\n const latestServiceInCatalog = await getService(serviceId, 'latest');\n\n console.log(chalk.blue(`Processing service: ${serviceId} (v${version})`));\n\n if (latestServiceInCatalog) {\n serviceMarkdown = latestServiceInCatalog.markdown;\n // Found a service, and versions do not match, we need to version the one already there\n if (latestServiceInCatalog.version !== version) {\n await versionService(serviceId);\n console.log(chalk.cyan(` - Versioned previous service (v${latestServiceInCatalog.version})`));\n }\n\n // Match found, override it\n if (latestServiceInCatalog.version === version) {\n // we want to preserve the markdown any any spec files that are already there\n serviceMarkdown = latestServiceInCatalog.markdown;\n serviceSpecifications = latestServiceInCatalog.specifications ?? {};\n sends = latestServiceInCatalog.sends ? [...latestServiceInCatalog.sends, ...sends] : sends;\n receives = latestServiceInCatalog.receives ? [...latestServiceInCatalog.receives, ...receives] : receives;\n serviceSpecificationsFiles = await getSpecificationFilesForService(serviceId, version);\n await rmService(serviceId);\n }\n }\n\n await writeService({\n id: serviceId,\n name: serviceName,\n version: version,\n summary: getServiceSummary(document),\n badges: documentTags.map((tag) => ({ content: tag.name(), textColor: 'blue', backgroundColor: 'blue' })),\n markdown: serviceMarkdown,\n sends,\n receives,\n schemaPath: service.path.split('/').pop() || 'asyncapi.yml',\n specifications: {\n ...serviceSpecifications,\n asyncapiPath: service.path.split('/').pop() || 'asyncapi.yml',\n },\n });\n\n // What files need added to the service (speficiation files)\n const specFiles = [\n // add any previous spec files to the list\n ...serviceSpecificationsFiles,\n {\n content: saveParsedSpecFile ? getParsedSpecFile(service, document) : await getRawSpecFile(service),\n fileName: service.path.split('/').pop() || 'asyncapi.yml',\n },\n ];\n\n for (const specFile of specFiles) {\n await addFileToService(\n serviceId,\n {\n fileName: specFile.fileName,\n content: specFile.content,\n },\n version\n );\n }\n\n console.log(chalk.cyan(` - Service (v${version}) created`));\n\n console.log(chalk.green(`\\nFinished generating event catalog for AsyncAPI ${serviceId} (v${version})`));\n }\n\n await checkLicense();\n};\n\nconst getParsedSpecFile = (service: Service, document: AsyncAPIDocumentInterface) => {\n const isSpecFileJSON = service.path.endsWith('.json');\n return isSpecFileJSON\n ? JSON.stringify(document.meta().asyncapi.parsed, null, 4)\n : yaml.dump(document.meta().asyncapi.parsed, { noRefs: true });\n};\n\nconst getRawSpecFile = async (service: Service) => await readFile(service.path, 'utf8');\n","export const getFileExtentionFromSchemaFormat = (format: string | undefined = '') => {\n if (format.includes('avro')) return 'avsc';\n if (format.includes('yml')) return 'yml';\n if (format.includes('json')) return 'json';\n if (format.includes('openapi')) return 'openapi';\n if (format.includes('protobuf')) return 'protobuf';\n if (format.includes('yaml')) return 'yaml';\n\n return 'json';\n};\n","import { MessageInterface, AsyncAPIDocumentInterface } from '@asyncapi/parser';\nimport { getFileExtentionFromSchemaFormat } from './schemas';\n\nexport const defaultMarkdown = (_document: AsyncAPIDocumentInterface, message: MessageInterface) => {\n return `\n## Architecture\n<NodeGraph />\n\n${\n messageHasSchema(message) && messageIsJSON(message)\n ? `\n## Schema\n<SchemaViewer file=\"${getSchemaFileName(message)}\" title=\"Message Schema\" maxHeight=\"500\" />\n`\n : ''\n}\n${\n messageHasSchema(message) && !messageIsJSON(message)\n ? `\n## Schema\n<Schema file=\"${getSchemaFileName(message)}\" title=\"Message Schema\" maxHeight=\"500\" />\n`\n : ''\n}\n\n${\n message.externalDocs()\n ? `\n## External documentation\n- [${message.externalDocs()?.description()}](${message.externalDocs()?.url()})\n`\n : ''\n}\n\n`;\n};\n\nexport const getSummary = (message: MessageInterface) => {\n const messageSummary = message.hasSummary() ? message.summary() : '';\n const messageDescription = message.hasDescription() ? message.description() : '';\n\n let eventCatalogMessageSummary = messageSummary;\n\n if (!eventCatalogMessageSummary) {\n eventCatalogMessageSummary = messageDescription && messageDescription.length < 150 ? messageDescription : '';\n }\n\n return eventCatalogMessageSummary;\n};\n\nexport const messageHasSchema = (message: MessageInterface) => {\n return message.hasPayload() && message.schemaFormat();\n};\n\nexport const messageIsJSON = (message: MessageInterface) => {\n const fileName = getSchemaFileName(message);\n return fileName.endsWith('.json');\n};\n\nexport const getSchemaFileName = (message: MessageInterface) => {\n const extension = getFileExtentionFromSchemaFormat(message.schemaFormat());\n return `schema.${extension}`;\n};\n\nexport const getMessageName = (message: MessageInterface) => {\n return message.hasTitle() && message.title() ? (message.title() as string) : message.id();\n};\n","import { AsyncAPIDocumentInterface } from '@asyncapi/parser';\n\nexport const defaultMarkdown = (document: AsyncAPIDocumentInterface) => {\n return `\n\n${document.info().hasDescription() ? `${document.info().description()}` : ''} \n\n## Architecture diagram\n<NodeGraph />\n\n${\n document.info().externalDocs()\n ? `\n## External documentation\n- [${document.info().externalDocs()?.description()}](${document.info().externalDocs()?.url()})\n`\n : ''\n}\n`;\n};\n\nexport const getSummary = (document: AsyncAPIDocumentInterface) => {\n const summary = document.info().hasDescription() ? document.info().description() : '';\n return summary && summary.length < 150 ? summary : '';\n};\n","import { AsyncAPIDocumentInterface } from '@asyncapi/parser';\n\nexport const defaultMarkdown = (document: AsyncAPIDocumentInterface) => {\n return `\n\n## Architecture diagram\n<NodeGraph />\n\n`;\n};\n","import chalk from 'chalk';\n\nexport default () => {\n console.log(chalk.bgBlue(`\\nYou are using the open source license for this plugin`));\n console.log(\n chalk.blueBright(\n `This plugin is governed and published under a dual-license. \\nIf using for internal, commercial or proprietary software, please contact hello@eventcatalog.dev for a license to support the project.`\n )\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA4D;AAC5D,iBAAkB;AAElB,sBAAyB;;;ACJlB,IAAM,mCAAmC,CAAC,SAA6B,OAAO;AACnF,MAAI,OAAO,SAAS,MAAM,EAAG,QAAO;AACpC,MAAI,OAAO,SAAS,KAAK,EAAG,QAAO;AACnC,MAAI,OAAO,SAAS,MAAM,EAAG,QAAO;AACpC,MAAI,OAAO,SAAS,SAAS,EAAG,QAAO;AACvC,MAAI,OAAO,SAAS,UAAU,EAAG,QAAO;AACxC,MAAI,OAAO,SAAS,MAAM,EAAG,QAAO;AAEpC,SAAO;AACT;;;ACNO,IAAM,kBAAkB,CAAC,WAAsC,YAA8B;AAClG,SAAO;AAAA;AAAA;AAAA;AAAA,EAKP,iBAAiB,OAAO,KAAK,cAAc,OAAO,IAC9C;AAAA;AAAA,sBAEgB,kBAAkB,OAAO,CAAC;AAAA,IAE1C,EACN;AAAA,EAEE,iBAAiB,OAAO,KAAK,CAAC,cAAc,OAAO,IAC/C;AAAA;AAAA,gBAEU,kBAAkB,OAAO,CAAC;AAAA,IAEpC,EACN;AAAA;AAAA,EAGE,QAAQ,aAAa,IACjB;AAAA;AAAA,KAED,QAAQ,aAAa,GAAG,YAAY,CAAC,KAAK,QAAQ,aAAa,GAAG,IAAI,CAAC;AAAA,IAEtE,EACN;AAAA;AAAA;AAGA;AAEO,IAAM,aAAa,CAAC,YAA8B;AACvD,QAAM,iBAAiB,QAAQ,WAAW,IAAI,QAAQ,QAAQ,IAAI;AAClE,QAAM,qBAAqB,QAAQ,eAAe,IAAI,QAAQ,YAAY,IAAI;AAE9E,MAAI,6BAA6B;AAEjC,MAAI,CAAC,4BAA4B;AAC/B,iCAA6B,sBAAsB,mBAAmB,SAAS,MAAM,qBAAqB;AAAA,EAC5G;A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EA,IAAM,iBAAiB,OAAO,YAAqB,UAAM,0BAAS,QAAQ,MAAM,MAAM;","names":["defaultMarkdown","getSummary","defaultMarkdown","import_chalk","chalk","argv","utils","chalk","defaultMarkdown","getSummary","yaml"]}
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  // src/index.ts
2
2
  import { Parser, fromFile } from "@asyncapi/parser";
3
3
  import utils from "@eventcatalog/sdk";
4
- import slugify from "slugify";
4
+ import { readFile } from "node:fs/promises";
5
5
 
6
6
  // src/utils/schemas.ts
7
7
  var getFileExtentionFromSchemaFormat = (format = "") => {
@@ -136,9 +136,10 @@ var src_default = async (config, options) => {
136
136
  addSchemaToCommand,
137
137
  addSchemaToEvent,
138
138
  addFileToService,
139
- versionDomain
139
+ versionDomain,
140
+ getSpecificationFilesForService
140
141
  } = utils(process.env.PROJECT_DIR);
141
- const services = options.services;
142
+ const { services, saveParsedSpecFile = false } = options;
142
143
  console.log(chalk2.green(`Processing ${services.length} AsyncAPI files...`));
143
144
  for (const service of services) {
144
145
  console.log(chalk2.gray(`Processing ${service.path}`));
@@ -154,11 +155,13 @@ var src_default = async (config, options) => {
154
155
  }
155
156
  const operations = document.allOperations();
156
157
  const documentTags = document.info().tags().all() || [];
157
- const serviceId = service.id || slugify(document.info().title(), { lower: true, strict: true });
158
+ const serviceId = service.id;
159
+ const serviceName = service.name || document.info().title();
158
160
  const version = document.info().version();
159
- const sends = [];
160
- const receives = [];
161
- let specifications = {};
161
+ let sends = [];
162
+ let receives = [];
163
+ let serviceSpecifications = {};
164
+ let serviceSpecificationsFiles = [];
162
165
  let serviceMarkdown = defaultMarkdown2(document);
163
166
  if (options.domain) {
164
167
  const { id: domainId, name: domainName, version: domainVersion } = options.domain;
@@ -242,7 +245,7 @@ Processing domain: ${domainName} (v${domainVersion})`));
242
245
  }
243
246
  }
244
247
  const latestServiceInCatalog = await getService(serviceId, "latest");
245
- console.log(chalk2.blue(`Processing service: ${document.info().title()} (v${version})`));
248
+ console.log(chalk2.blue(`Processing service: ${serviceId} (v${version})`));
246
249
  if (latestServiceInCatalog) {
247
250
  serviceMarkdown = latestServiceInCatalog.markdown;
248
251
  if (latestServiceInCatalog.version !== version) {
@@ -251,42 +254,57 @@ Processing domain: ${domainName} (v${domainVersion})`));
251
254
  }
252
255
  if (latestServiceInCatalog.version === version) {
253
256
  serviceMarkdown = latestServiceInCatalog.markdown;
254
- specifications = latestServiceInCatalog.specifications ?? {};
255
- await rmService(service.folderName || document.info().title());
257
+ serviceSpecifications = latestServiceInCatalog.specifications ?? {};
258
+ sends = latestServiceInCatalog.sends ? [...latestServiceInCatalog.sends, ...sends] : sends;
259
+ receives = latestServiceInCatalog.receives ? [...latestServiceInCatalog.receives, ...receives] : receives;
260
+ serviceSpecificationsFiles = await getSpecificationFilesForService(serviceId, version);
261
+ await rmService(serviceId);
256
262
  }
257
263
  }
258
- await writeService(
259
- {
260
- id: serviceId,
261
- name: document.info().title(),
262
- version,
263
- summary: getSummary2(document),
264
- badges: documentTags.map((tag) => ({ content: tag.name(), textColor: "blue", backgroundColor: "blue" })),
265
- markdown: serviceMarkdown,
266
- sends,
267
- receives,
268
- schemaPath: service.path.split("/").pop() || "asyncapi.yml",
269
- specifications: {
270
- ...specifications,
271
- asyncapiPath: service.path.split("/").pop() || "asyncapi.yml"
272
- }
273
- },
274
- { path: service.folderName || document.info().title() }
275
- );
276
- await addFileToService(
277
- serviceId,
264
+ await writeService({
265
+ id: serviceId,
266
+ name: serviceName,
267
+ version,
268
+ summary: getSummary2(document),
269
+ badges: documentTags.map((tag) => ({ content: tag.name(), textColor: "blue", backgroundColor: "blue" })),
270
+ markdown: serviceMarkdown,
271
+ sends,
272
+ receives,
273
+ schemaPath: service.path.split("/").pop() || "asyncapi.yml",
274
+ specifications: {
275
+ ...serviceSpecifications,
276
+ asyncapiPath: service.path.split("/").pop() || "asyncapi.yml"
277
+ }
278
+ });
279
+ const specFiles = [
280
+ // add any previous spec files to the list
281
+ ...serviceSpecificationsFiles,
278
282
  {
279
- fileName: service.path.split("/").pop() || "asyncapi.yml",
280
- content: service.path.endsWith(".json") ? JSON.stringify(document.meta().asyncapi.parsed, null, 4) : yaml.dump(document.meta().asyncapi.parsed, { noRefs: true })
281
- },
282
- version
283
- );
283
+ content: saveParsedSpecFile ? getParsedSpecFile(service, document) : await getRawSpecFile(service),
284
+ fileName: service.path.split("/").pop() || "asyncapi.yml"
285
+ }
286
+ ];
287
+ for (const specFile of specFiles) {
288
+ await addFileToService(
289
+ serviceId,
290
+ {
291
+ fileName: specFile.fileName,
292
+ content: specFile.content
293
+ },
294
+ version
295
+ );
296
+ }
284
297
  console.log(chalk2.cyan(` - Service (v${version}) created`));
285
298
  console.log(chalk2.green(`
286
- Finished generating event catalog for AsyncAPI ${document.info().title()} (v${version})`));
299
+ Finished generating event catalog for AsyncAPI ${serviceId} (v${version})`));
287
300
  }
288
301
  await checkLicense_default();
289
302
  };
303
+ var getParsedSpecFile = (service, document) => {
304
+ const isSpecFileJSON = service.path.endsWith(".json");
305
+ return isSpecFileJSON ? JSON.stringify(document.meta().asyncapi.parsed, null, 4) : yaml.dump(document.meta().asyncapi.parsed, { noRefs: true });
306
+ };
307
+ var getRawSpecFile = async (service) => await readFile(service.path, "utf8");
290
308
  export {
291
309
  src_default as default
292
310
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/utils/schemas.ts","../src/utils/messages.ts","../src/utils/services.ts","../src/utils/domains.ts","../src/checkLicense.ts"],"sourcesContent":["// import utils from '@eventcatalog/sdk';\nimport { Parser, fromFile } from '@asyncapi/parser';\nimport utils from '@eventcatalog/sdk';\nimport slugify from 'slugify';\nimport {\n defaultMarkdown as generateMarkdownForMessage,\n getMessageName,\n getSummary as getMessageSummary,\n getSchemaFileName,\n messageHasSchema,\n} from './utils/messages';\nimport { defaultMarkdown as generateMarkdownForService, getSummary as getServiceSummary } from './utils/services';\nimport { defaultMarkdown as generateMarkdownForDomain } from './utils/domains';\nimport chalk from 'chalk';\nimport checkLicense from './checkLicense';\nimport argv from 'minimist';\nimport yaml from 'js-yaml';\n\n// AsyncAPI Parsers\nimport { AvroSchemaParser } from '@asyncapi/avro-schema-parser';\n\nconst parser = new Parser();\n\n// register avro schema support\nparser.registerSchemaParser(AvroSchemaParser());\n\nconst cliArgs = argv(process.argv.slice(2));\n\ntype Domain = {\n id: string;\n name: string;\n version: string;\n};\n\ntype Service = {\n id?: string;\n path: string;\n folderName?: string;\n};\n\ntype Props = {\n services: Service[];\n domain?: Domain;\n debug?: boolean;\n};\n\nexport default async (config: any, options: Props) => {\n if (!process.env.PROJECT_DIR) {\n throw new Error('Please provide catalog url (env variable PROJECT_DIR)');\n }\n\n const {\n writeService,\n writeEvent,\n writeCommand,\n getService,\n versionService,\n rmService,\n getDomain,\n writeDomain,\n addServiceToDomain,\n getCommand,\n getEvent,\n rmEventById,\n rmCommandById,\n versionCommand,\n versionEvent,\n addSchemaToCommand,\n addSchemaToEvent,\n addFileToService,\n versionDomain,\n } = utils(process.env.PROJECT_DIR);\n\n const services = options.services;\n // const asyncAPIFiles = Array.isArray(options.path) ? options.path : [options.path];\n\n console.log(chalk.green(`Processing ${services.length} AsyncAPI files...`));\n\n for (const service of services) {\n console.log(chalk.gray(`Processing ${service.path}`));\n\n const { document, diagnostics } = await fromFile(parser, service.path).parse();\n\n if (!document) {\n console.log(chalk.red('Failed to parse AsyncAPI file'));\n if (options.debug || cliArgs.debug) {\n console.log(diagnostics);\n } else {\n console.log(chalk.red('Run with debug option in the generator to see diagnostics'));\n }\n continue;\n }\n\n const operations = document.allOperations();\n const documentTags = document.info().tags().all() || [];\n\n const serviceId = service.id || slugify(document.info().title(), { lower: true, strict: true });\n const version = document.info().version();\n\n // What messages does this service send and receive\n const sends = [];\n const receives = [];\n let specifications = {};\n\n let serviceMarkdown = generateMarkdownForService(document);\n\n // Manage domain\n if (options.domain) {\n // Try and get the domain\n const { id: domainId, name: domainName, version: domainVersion } = options.domain;\n const domain = await getDomain(options.domain.id, domainVersion || 'latest');\n const currentDomain = await getDomain(options.domain.id, 'latest');\n\n console.log(chalk.blue(`\\nProcessing domain: ${domainName} (v${domainVersion})`));\n\n // Found a domain, but the versions do not match\n if (currentDomain && currentDomain.version !== domainVersion) {\n await versionDomain(domainId);\n console.log(chalk.cyan(` - Versioned previous domain (v${currentDomain.version})`));\n }\n\n // Do we need to create a new domain?\n if (!domain || (domain && domain.version !== domainVersion)) {\n await writeDomain({\n id: domainId,\n name: domainName,\n version: domainVersion,\n markdown: generateMarkdownForDomain(document),\n // services: [{ id: serviceId, version: version }],\n });\n console.log(chalk.cyan(` - Domain (v${domainVersion}) created`));\n }\n\n if (currentDomain && currentDomain.version === domainVersion) {\n console.log(chalk.yellow(` - Domain (v${domainVersion}) already exists, skipped creation...`));\n }\n\n // Add the service to the domain\n await addServiceToDomain(domainId, { id: serviceId, version: version }, domainVersion);\n }\n\n // Find events/commands\n for (const operation of operations) {\n for (const message of operation.messages()) {\n const eventType = message.extensions().get('x-eventcatalog-message-type')?.value() || 'event';\n\n const messageId = message.id().toLowerCase();\n\n let messageMarkdown = generateMarkdownForMessage(document, message);\n const writeMessage = eventType === 'event' ? writeEvent : writeCommand;\n const versionMessage = eventType === 'event' ? versionEvent : versionCommand;\n const getMessage = eventType === 'event' ? getEvent : getCommand;\n const rmMessageById = eventType === 'event' ? rmEventById : rmCommandById;\n const addSchemaToMessage = eventType === 'event' ? addSchemaToEvent : addSchemaToCommand;\n const badges = message.tags().all() || [];\n\n // Check if the message already exists in the catalog\n const catalogedMessage = await getMessage(message.id().toLowerCase(), 'latest');\n\n console.log(chalk.blue(`Processing message: ${getMessageName(message)} (v${version})`));\n\n if (catalogedMessage) {\n messageMarkdown = catalogedMessage.markdown;\n // if the version matches, we can override the message but keep markdown as it was\n if (catalogedMessage.version === version) {\n await rmMessageById(messageId, version);\n } else {\n // if the version does not match, we need to version the message\n await versionMessage(messageId);\n console.log(chalk.cyan(` - Versioned previous message: (v${catalogedMessage.version})`));\n }\n }\n\n // Write the message to the catalog\n await writeMessage(\n {\n id: messageId,\n version: version,\n name: getMessageName(message),\n summary: getMessageSummary(message),\n markdown: messageMarkdown,\n badges: badges.map((badge) => ({ content: badge.name(), textColor: 'blue', backgroundColor: 'blue' })),\n schemaPath: messageHasSchema(message) ? getSchemaFileName(message) : undefined,\n },\n {\n path: message.id(),\n }\n );\n\n console.log(chalk.cyan(` - Message (v${version}) created`));\n\n // Check if the message has a payload, if it does then document in EventCatalog\n if (messageHasSchema(message)) {\n addSchemaToMessage(\n messageId,\n {\n fileName: getSchemaFileName(message),\n schema: JSON.stringify(message.payload()?.json(), null, 4),\n },\n version\n );\n console.log(chalk.cyan(` - Schema added to message (v${version})`));\n }\n\n // Add the message to the correct array\n if (operation.action() === 'send' || operation.action() === 'publish') {\n sends.push({ id: messageId, version: version });\n }\n if (operation.action() === 'receive' || operation.action() === 'subscribe') {\n receives.push({ id: messageId, version: version });\n }\n }\n }\n\n // Check if service is already defined... if the versions do not match then create service.\n const latestServiceInCatalog = await getService(serviceId, 'latest');\n\n console.log(chalk.blue(`Processing service: ${document.info().title()} (v${version})`));\n\n if (latestServiceInCatalog) {\n serviceMarkdown = latestServiceInCatalog.markdown;\n // Found a service, and versions do not match, we need to version the one already there\n if (latestServiceInCatalog.version !== version) {\n await versionService(serviceId);\n console.log(chalk.cyan(` - Versioned previous service (v${latestServiceInCatalog.version})`));\n }\n\n // Match found, override it\n if (latestServiceInCatalog.version === version) {\n serviceMarkdown = latestServiceInCatalog.markdown;\n specifications = latestServiceInCatalog.specifications ?? {};\n await rmService(service.folderName || document.info().title());\n }\n }\n\n await writeService(\n {\n id: serviceId,\n name: document.info().title(),\n version: version,\n summary: getServiceSummary(document),\n badges: documentTags.map((tag) => ({ content: tag.name(), textColor: 'blue', backgroundColor: 'blue' })),\n markdown: serviceMarkdown,\n sends,\n receives,\n schemaPath: service.path.split('/').pop() || 'asyncapi.yml',\n specifications: {\n ...specifications,\n asyncapiPath: service.path.split('/').pop() || 'asyncapi.yml',\n },\n },\n { path: service.folderName || document.info().title() }\n );\n\n await addFileToService(\n serviceId,\n {\n fileName: service.path.split('/').pop() || 'asyncapi.yml',\n content: service.path.endsWith('.json')\n ? JSON.stringify(document.meta().asyncapi.parsed, null, 4)\n : yaml.dump(document.meta().asyncapi.parsed, { noRefs: true }),\n },\n version\n );\n\n console.log(chalk.cyan(` - Service (v${version}) created`));\n\n console.log(chalk.green(`\\nFinished generating event catalog for AsyncAPI ${document.info().title()} (v${version})`));\n }\n\n await checkLicense();\n};\n","export const getFileExtentionFromSchemaFormat = (format: string | undefined = '') => {\n if (format.includes('avro')) return 'avsc';\n if (format.includes('yml')) return 'yml';\n if (format.includes('json')) return 'json';\n if (format.includes('openapi')) return 'openapi';\n if (format.includes('protobuf')) return 'protobuf';\n if (format.includes('yaml')) return 'yaml';\n\n return 'json';\n};\n","import { MessageInterface, AsyncAPIDocumentInterface } from '@asyncapi/parser';\nimport { getFileExtentionFromSchemaFormat } from './schemas';\n\nexport const defaultMarkdown = (_document: AsyncAPIDocumentInterface, message: MessageInterface) => {\n return `\n## Architecture\n<NodeGraph />\n\n${\n messageHasSchema(message) && messageIsJSON(message)\n ? `\n## Schema\n<SchemaViewer file=\"${getSchemaFileName(message)}\" title=\"Message Schema\" maxHeight=\"500\" />\n`\n : ''\n}\n${\n messageHasSchema(message) && !messageIsJSON(message)\n ? `\n## Schema\n<Schema file=\"${getSchemaFileName(message)}\" title=\"Message Schema\" maxHeight=\"500\" />\n`\n : ''\n}\n\n${\n message.externalDocs()\n ? `\n## External documentation\n- [${message.externalDocs()?.description()}](${message.externalDocs()?.url()})\n`\n : ''\n}\n\n`;\n};\n\nexport const getSummary = (message: MessageInterface) => {\n const messageSummary = message.hasSummary() ? message.summary() : '';\n const messageDescription = message.hasDescription() ? message.description() : '';\n\n let eventCatalogMessageSummary = messageSummary;\n\n if (!eventCatalogMessageSummary) {\n eventCatalogMessageSummary = messageDescription && messageDescription.length < 150 ? messageDescription : '';\n }\n\n return eventCatalogMessageSummary;\n};\n\nexport const messageHasSchema = (message: MessageInterface) => {\n return message.hasPayload() && message.schemaFormat();\n};\n\nexport const messageIsJSON = (message: MessageInterface) => {\n const fileName = getSchemaFileName(message);\n return fileName.endsWith('.json');\n};\n\nexport const getSchemaFileName = (message: MessageInterface) => {\n const extension = getFileExtentionFromSchemaFormat(message.schemaFormat());\n return `schema.${extension}`;\n};\n\nexport const getMessageName = (message: MessageInterface) => {\n return message.hasTitle() && message.title() ? (message.title() as string) : message.id();\n};\n","import { AsyncAPIDocumentInterface } from '@asyncapi/parser';\n\nexport const defaultMarkdown = (document: AsyncAPIDocumentInterface) => {\n return `\n\n${document.info().hasDescription() ? `${document.info().description()}` : ''} \n\n## Architecture diagram\n<NodeGraph />\n\n${\n document.info().externalDocs()\n ? `\n## External documentation\n- [${document.info().externalDocs()?.description()}](${document.info().externalDocs()?.url()})\n`\n : ''\n}\n`;\n};\n\nexport const getSummary = (document: AsyncAPIDocumentInterface) => {\n const summary = document.info().hasDescription() ? document.info().description() : '';\n return summary && summary.length < 150 ? summary : '';\n};\n","import { AsyncAPIDocumentInterface } from '@asyncapi/parser';\n\nexport const defaultMarkdown = (document: AsyncAPIDocumentInterface) => {\n return `\n\n## Architecture diagram\n<NodeGraph />\n\n`;\n};\n","import chalk from 'chalk';\n\nexport default () => {\n console.log(chalk.bgBlue(`\\nYou are using the open source license for this plugin`));\n console.log(\n chalk.blueBright(\n `This plugin is governed and published under a dual-license. \\nIf using for internal, commercial or proprietary software, please contact hello@eventcatalog.dev for a license to support the project.`\n )\n );\n};\n"],"mappings":";AACA,SAAS,QAAQ,gBAAgB;AACjC,OAAO,WAAW;AAClB,OAAO,aAAa;;;ACHb,IAAM,mCAAmC,CAAC,SAA6B,OAAO;AACnF,MAAI,OAAO,SAAS,MAAM,EAAG,QAAO;AACpC,MAAI,OAAO,SAAS,KAAK,EAAG,QAAO;AACnC,MAAI,OAAO,SAAS,MAAM,EAAG,QAAO;AACpC,MAAI,OAAO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,SAAS,QAAQ,KAAK,SAAS,OAAO,IAClC,KAAK,UAAU,SAAS,KAAK,EAAE,SAAS,QAAQ,MAAM,CAAC,IACvD,KAAK,KAAK,SAAS,KAAK,EAAE,SAAS,QAAQ,EAAE,QAAQ,KAAK,CAAC;AAAA,MACjE;AAAA,MACA;AAAA,IACF;AAEA,YAAQ,IAAIF,OAAM,KAAK,gBAAgB,OAAO,WAAW,CAAC;AAE1D,YAAQ,IAAIA,OAAM,MAAM;AAAA,iDAAoD,SAAS,KAAK,EAAE,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC;AAAA,EACtH;AAEA,QAAM,qBAAa;AACrB;","names":["defaultMarkdown","getSummary","defaultMarkdown","chalk","chalk","defaultMarkdown","getSummary"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/utils/schemas.ts","../src/utils/messages.ts","../src/utils/services.ts","../src/utils/domains.ts","../src/checkLicense.ts"],"sourcesContent":["// import utils from '@eventcatalog/sdk';\nimport { AsyncAPIDocumentInterface, Parser, fromFile } from '@asyncapi/parser';\nimport utils from '@eventcatalog/sdk';\nimport slugify from 'slugify';\nimport { readFile } from 'node:fs/promises';\nimport {\n defaultMarkdown as generateMarkdownForMessage,\n getMessageName,\n getSummary as getMessageSummary,\n getSchemaFileName,\n messageHasSchema,\n} from './utils/messages';\nimport { defaultMarkdown as generateMarkdownForService, getSummary as getServiceSummary } from './utils/services';\nimport { defaultMarkdown as generateMarkdownForDomain } from './utils/domains';\nimport chalk from 'chalk';\nimport checkLicense from './checkLicense';\nimport argv from 'minimist';\nimport yaml from 'js-yaml';\n\n// AsyncAPI Parsers\nimport { AvroSchemaParser } from '@asyncapi/avro-schema-parser';\n\nconst parser = new Parser();\n\n// register avro schema support\nparser.registerSchemaParser(AvroSchemaParser());\n\nconst cliArgs = argv(process.argv.slice(2));\n\ntype Domain = {\n id: string;\n name: string;\n version: string;\n};\n\ntype Service = {\n id: string;\n path: string;\n name?: string;\n};\n\ntype Props = {\n services: Service[];\n domain?: Domain;\n debug?: boolean;\n saveParsedSpecFile?: boolean;\n};\n\nexport default async (config: any, options: Props) => {\n if (!process.env.PROJECT_DIR) {\n throw new Error('Please provide catalog url (env variable PROJECT_DIR)');\n }\n\n const {\n writeService,\n writeEvent,\n writeCommand,\n getService,\n versionService,\n rmService,\n getDomain,\n writeDomain,\n addServiceToDomain,\n getCommand,\n getEvent,\n rmEventById,\n rmCommandById,\n versionCommand,\n versionEvent,\n addSchemaToCommand,\n addSchemaToEvent,\n addFileToService,\n versionDomain,\n getSpecificationFilesForService,\n } = utils(process.env.PROJECT_DIR);\n\n // Should the file that is written to the catalog be parsed (https://github.com/asyncapi/parser-js) or as it is?\n const { services, saveParsedSpecFile = false } = options;\n // const asyncAPIFiles = Array.isArray(options.path) ? options.path : [options.path];\n console.log(chalk.green(`Processing ${services.length} AsyncAPI files...`));\n\n for (const service of services) {\n console.log(chalk.gray(`Processing ${service.path}`));\n\n const { document, diagnostics } = await fromFile(parser, service.path).parse();\n\n if (!document) {\n console.log(chalk.red('Failed to parse AsyncAPI file'));\n if (options.debug || cliArgs.debug) {\n console.log(diagnostics);\n } else {\n console.log(chalk.red('Run with debug option in the generator to see diagnostics'));\n }\n continue;\n }\n\n const operations = document.allOperations();\n const documentTags = document.info().tags().all() || [];\n\n const serviceId = service.id;\n const serviceName = service.name || document.info().title();\n const version = document.info().version();\n\n // What messages does this service send and receive\n let sends = [];\n let receives = [];\n\n let serviceSpecifications = {};\n let serviceSpecificationsFiles = [];\n let serviceMarkdown = generateMarkdownForService(document);\n\n // Manage domain\n if (options.domain) {\n // Try and get the domain\n const { id: domainId, name: domainName, version: domainVersion } = options.domain;\n const domain = await getDomain(options.domain.id, domainVersion || 'latest');\n const currentDomain = await getDomain(options.domain.id, 'latest');\n\n console.log(chalk.blue(`\\nProcessing domain: ${domainName} (v${domainVersion})`));\n\n // Found a domain, but the versions do not match\n if (currentDomain && currentDomain.version !== domainVersion) {\n await versionDomain(domainId);\n console.log(chalk.cyan(` - Versioned previous domain (v${currentDomain.version})`));\n }\n\n // Do we need to create a new domain?\n if (!domain || (domain && domain.version !== domainVersion)) {\n await writeDomain({\n id: domainId,\n name: domainName,\n version: domainVersion,\n markdown: generateMarkdownForDomain(document),\n // services: [{ id: serviceId, version: version }],\n });\n console.log(chalk.cyan(` - Domain (v${domainVersion}) created`));\n }\n\n if (currentDomain && currentDomain.version === domainVersion) {\n console.log(chalk.yellow(` - Domain (v${domainVersion}) already exists, skipped creation...`));\n }\n\n // Add the service to the domain\n await addServiceToDomain(domainId, { id: serviceId, version: version }, domainVersion);\n }\n\n // Find events/commands\n for (const operation of operations) {\n for (const message of operation.messages()) {\n const eventType = message.extensions().get('x-eventcatalog-message-type')?.value() || 'event';\n\n const messageId = message.id().toLowerCase();\n\n let messageMarkdown = generateMarkdownForMessage(document, message);\n const writeMessage = eventType === 'event' ? writeEvent : writeCommand;\n const versionMessage = eventType === 'event' ? versionEvent : versionCommand;\n const getMessage = eventType === 'event' ? getEvent : getCommand;\n const rmMessageById = eventType === 'event' ? rmEventById : rmCommandById;\n const addSchemaToMessage = eventType === 'event' ? addSchemaToEvent : addSchemaToCommand;\n const badges = message.tags().all() || [];\n\n // Check if the message already exists in the catalog\n const catalogedMessage = await getMessage(message.id().toLowerCase(), 'latest');\n\n console.log(chalk.blue(`Processing message: ${getMessageName(message)} (v${version})`));\n\n if (catalogedMessage) {\n messageMarkdown = catalogedMessage.markdown;\n // if the version matches, we can override the message but keep markdown as it was\n if (catalogedMessage.version === version) {\n await rmMessageById(messageId, version);\n } else {\n // if the version does not match, we need to version the message\n await versionMessage(messageId);\n console.log(chalk.cyan(` - Versioned previous message: (v${catalogedMessage.version})`));\n }\n }\n\n // Write the message to the catalog\n await writeMessage(\n {\n id: messageId,\n version: version,\n name: getMessageName(message),\n summary: getMessageSummary(message),\n markdown: messageMarkdown,\n badges: badges.map((badge) => ({ content: badge.name(), textColor: 'blue', backgroundColor: 'blue' })),\n schemaPath: messageHasSchema(message) ? getSchemaFileName(message) : undefined,\n },\n {\n path: message.id(),\n }\n );\n\n console.log(chalk.cyan(` - Message (v${version}) created`));\n\n // Check if the message has a payload, if it does then document in EventCatalog\n if (messageHasSchema(message)) {\n addSchemaToMessage(\n messageId,\n {\n fileName: getSchemaFileName(message),\n schema: JSON.stringify(message.payload()?.json(), null, 4),\n },\n version\n );\n console.log(chalk.cyan(` - Schema added to message (v${version})`));\n }\n\n // Add the message to the correct array\n if (operation.action() === 'send' || operation.action() === 'publish') {\n sends.push({ id: messageId, version: version });\n }\n if (operation.action() === 'receive' || operation.action() === 'subscribe') {\n receives.push({ id: messageId, version: version });\n }\n }\n }\n\n // Check if service is already defined... if the versions do not match then create service.\n const latestServiceInCatalog = await getService(serviceId, 'latest');\n\n console.log(chalk.blue(`Processing service: ${serviceId} (v${version})`));\n\n if (latestServiceInCatalog) {\n serviceMarkdown = latestServiceInCatalog.markdown;\n // Found a service, and versions do not match, we need to version the one already there\n if (latestServiceInCatalog.version !== version) {\n await versionService(serviceId);\n console.log(chalk.cyan(` - Versioned previous service (v${latestServiceInCatalog.version})`));\n }\n\n // Match found, override it\n if (latestServiceInCatalog.version === version) {\n // we want to preserve the markdown any any spec files that are already there\n serviceMarkdown = latestServiceInCatalog.markdown;\n serviceSpecifications = latestServiceInCatalog.specifications ?? {};\n sends = latestServiceInCatalog.sends ? [...latestServiceInCatalog.sends, ...sends] : sends;\n receives = latestServiceInCatalog.receives ? [...latestServiceInCatalog.receives, ...receives] : receives;\n serviceSpecificationsFiles = await getSpecificationFilesForService(serviceId, version);\n await rmService(serviceId);\n }\n }\n\n await writeService({\n id: serviceId,\n name: serviceName,\n version: version,\n summary: getServiceSummary(document),\n badges: documentTags.map((tag) => ({ content: tag.name(), textColor: 'blue', backgroundColor: 'blue' })),\n markdown: serviceMarkdown,\n sends,\n receives,\n schemaPath: service.path.split('/').pop() || 'asyncapi.yml',\n specifications: {\n ...serviceSpecifications,\n asyncapiPath: service.path.split('/').pop() || 'asyncapi.yml',\n },\n });\n\n // What files need added to the service (speficiation files)\n const specFiles = [\n // add any previous spec files to the list\n ...serviceSpecificationsFiles,\n {\n content: saveParsedSpecFile ? getParsedSpecFile(service, document) : await getRawSpecFile(service),\n fileName: service.path.split('/').pop() || 'asyncapi.yml',\n },\n ];\n\n for (const specFile of specFiles) {\n await addFileToService(\n serviceId,\n {\n fileName: specFile.fileName,\n content: specFile.content,\n },\n version\n );\n }\n\n console.log(chalk.cyan(` - Service (v${version}) created`));\n\n console.log(chalk.green(`\\nFinished generating event catalog for AsyncAPI ${serviceId} (v${version})`));\n }\n\n await checkLicense();\n};\n\nconst getParsedSpecFile = (service: Service, document: AsyncAPIDocumentInterface) => {\n const isSpecFileJSON = service.path.endsWith('.json');\n return isSpecFileJSON\n ? JSON.stringify(document.meta().asyncapi.parsed, null, 4)\n : yaml.dump(document.meta().asyncapi.parsed, { noRefs: true });\n};\n\nconst getRawSpecFile = async (service: Service) => await readFile(service.path, 'utf8');\n","export const getFileExtentionFromSchemaFormat = (format: string | undefined = '') => {\n if (format.includes('avro')) return 'avsc';\n if (format.includes('yml')) return 'yml';\n if (format.includes('json')) return 'json';\n if (format.includes('openapi')) return 'openapi';\n if (format.includes('protobuf')) return 'protobuf';\n if (format.includes('yaml')) return 'yaml';\n\n return 'json';\n};\n","import { MessageInterface, AsyncAPIDocumentInterface } from '@asyncapi/parser';\nimport { getFileExtentionFromSchemaFormat } from './schemas';\n\nexport const defaultMarkdown = (_document: AsyncAPIDocumentInterface, message: MessageInterface) => {\n return `\n## Architecture\n<NodeGraph />\n\n${\n messageHasSchema(message) && messageIsJSON(message)\n ? `\n## Schema\n<SchemaViewer file=\"${getSchemaFileName(message)}\" title=\"Message Schema\" maxHeight=\"500\" />\n`\n : ''\n}\n${\n messageHasSchema(message) && !messageIsJSON(message)\n ? `\n## Schema\n<Schema file=\"${getSchemaFileName(message)}\" title=\"Message Schema\" maxHeight=\"500\" />\n`\n : ''\n}\n\n${\n message.externalDocs()\n ? `\n## External documentation\n- [${message.externalDocs()?.description()}](${message.externalDocs()?.url()})\n`\n : ''\n}\n\n`;\n};\n\nexport const getSummary = (message: MessageInterface) => {\n const messageSummary = message.hasSummary() ? message.summary() : '';\n const messageDescription = message.hasDescription() ? message.description() : '';\n\n let eventCatalogMessageSummary = messageSummary;\n\n if (!eventCatalogMessageSummary) {\n eventCatalogMessageSummary = messageDescription && messageDescription.length < 150 ? messageDescription : '';\n }\n\n return eventCatalogMessageSummary;\n};\n\nexport const messageHasSchema = (message: MessageInterface) => {\n return message.hasPayload() && message.schemaFormat();\n};\n\nexport const messageIsJSON = (message: MessageInterface) => {\n const fileName = getSchemaFileName(message);\n return fileName.endsWith('.json');\n};\n\nexport const getSchemaFileName = (message: MessageInterface) => {\n const extension = getFileExtentionFromSchemaFormat(message.schemaFormat());\n return `schema.${extension}`;\n};\n\nexport const getMessageName = (message: MessageInterface) => {\n return message.hasTitle() && message.title() ? (message.title() as string) : message.id();\n};\n","import { AsyncAPIDocumentInterface } from '@asyncapi/parser';\n\nexport const defaultMarkdown = (document: AsyncAPIDocumentInterface) => {\n return `\n\n${document.info().hasDescription() ? `${document.info().description()}` : ''} \n\n## Architecture diagram\n<NodeGraph />\n\n${\n document.info().externalDocs()\n ? `\n## External documentation\n- [${document.info().externalDocs()?.description()}](${document.info().externalDocs()?.url()})\n`\n : ''\n}\n`;\n};\n\nexport const getSummary = (document: AsyncAPIDocumentInterface) => {\n const summary = document.info().hasDescription() ? document.info().description() : '';\n return summary && summary.length < 150 ? summary : '';\n};\n","import { AsyncAPIDocumentInterface } from '@asyncapi/parser';\n\nexport const defaultMarkdown = (document: AsyncAPIDocumentInterface) => {\n return `\n\n## Architecture diagram\n<NodeGraph />\n\n`;\n};\n","import chalk from 'chalk';\n\nexport default () => {\n console.log(chalk.bgBlue(`\\nYou are using the open source license for this plugin`));\n console.log(\n chalk.blueBright(\n `This plugin is governed and published under a dual-license. \\nIf using for internal, commercial or proprietary software, please contact hello@eventcatalog.dev for a license to support the project.`\n )\n );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ACvG,UAAU;AAAA,MACV;AAAA,MACA;AAAA,MACA,YAAY,QAAQ,KAAK,MAAM,GAAG,EAAE,IAAI,KAAK;AAAA,MAC7C,gBAAgB;AAAA,QACd,GAAG;AAAA,QACH,cAAc,QAAQ,KAAK,MAAM,GAAG,EAAE,IAAI,KAAK;AAAA,MACjD;AAAA,IACF,CAAC;AAGD,UAAM,YAAY;AAAA;AAAA,MAEhB,GAAG;AAAA,MACH;AAAA,QACE,SAAS,qBAAqB,kBAAkB,SAAS,QAAQ,IAAI,MAAM,eAAe,OAAO;AAAA,QACjG,UAAU,QAAQ,KAAK,MAAM,GAAG,EAAE,IAAI,KAAK;AAAA,MAC7C;AAAA,IACF;AAEA,eAAW,YAAY,WAAW;AAChC,YAAM;AAAA,QACJ;AAAA,QACA;AAAA,UACE,UAAU,SAAS;AAAA,UACnB,SAAS,SAAS;AAAA,QACpB;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,YAAQ,IAAIF,OAAM,KAAK,gBAAgB,OAAO,WAAW,CAAC;AAE1D,YAAQ,IAAIA,OAAM,MAAM;AAAA,iDAAoD,SAAS,MAAM,OAAO,GAAG,CAAC;AAAA,EACxG;AAEA,QAAM,qBAAa;AACrB;AAEA,IAAM,oBAAoB,CAAC,SAAkB,aAAwC;AACnF,QAAM,iBAAiB,QAAQ,KAAK,SAAS,OAAO;AACpD,SAAO,iBACH,KAAK,UAAU,SAAS,KAAK,EAAE,SAAS,QAAQ,MAAM,CAAC,IACvD,KAAK,KAAK,SAAS,KAAK,EAAE,SAAS,QAAQ,EAAE,QAAQ,KAAK,CAAC;AACjE;AAEA,IAAM,iBAAiB,OAAO,YAAqB,MAAM,SAAS,QAAQ,MAAM,MAAM;","names":["defaultMarkdown","getSummary","defaultMarkdown","chalk","chalk","defaultMarkdown","getSummary"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eventcatalog/generator-asyncapi",
3
- "version": "1.0.5",
3
+ "version": "2.0.1",
4
4
  "description": "AsyncAPI generator for EventCatalog",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -30,7 +30,7 @@
30
30
  "@asyncapi/avro-schema-parser": "^3.0.24",
31
31
  "@asyncapi/parser": "^3.2.2",
32
32
  "@changesets/cli": "^2.27.7",
33
- "@eventcatalog/sdk": "^0.1.1",
33
+ "@eventcatalog/sdk": "^0.1.3",
34
34
  "chalk": "^4",
35
35
  "fs-extra": "^11.2.0",
36
36
  "glob": "^11.0.0",