@eventcatalog/generator-asyncapi 2.3.1 → 2.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.js CHANGED
@@ -280,6 +280,9 @@ Processing domain: ${domainName} (v${domainVersion})`));
280
280
  for (const operation of operations) {
281
281
  for (const message of operation.messages()) {
282
282
  const eventType = message.extensions().get("x-eventcatalog-message-type")?.value() || "event";
283
+ const serviceOwnsMessageContract = isServiceMessageOwner(message);
284
+ const isReceived = operation.action() === "receive" || operation.action() === "receive";
285
+ const isSent = operation.action() === "send" || operation.action() === "publish";
283
286
  const messageId = message.id().toLowerCase();
284
287
  if (eventType !== "event" && eventType !== "command" && eventType !== "query") {
285
288
  throw new Error("Invalid message type");
@@ -293,49 +296,49 @@ Processing domain: ${domainName} (v${domainVersion})`));
293
296
  } = MESSAGE_OPERATIONS[eventType];
294
297
  let messageMarkdown = defaultMarkdown(document, message);
295
298
  const badges = message.tags().all() || [];
296
- const catalogedMessage = await getMessage(message.id().toLowerCase(), "latest");
297
299
  console.log(import_chalk2.default.blue(`Processing message: ${getMessageName(message)} (v${version})`));
298
- if (catalogedMessage) {
299
- messageMarkdown = catalogedMessage.markdown;
300
- if (catalogedMessage.version === version) {
301
- await rmMessageById(messageId, version);
302
- } else {
303
- await versionMessage(messageId);
304
- console.log(import_chalk2.default.cyan(` - Versioned previous message: (v${catalogedMessage.version})`));
300
+ if (serviceOwnsMessageContract) {
301
+ const catalogedMessage = await getMessage(message.id().toLowerCase(), "latest");
302
+ if (catalogedMessage) {
303
+ messageMarkdown = catalogedMessage.markdown;
304
+ if (catalogedMessage.version === version) {
305
+ await rmMessageById(messageId, version);
306
+ } else {
307
+ await versionMessage(messageId);
308
+ console.log(import_chalk2.default.cyan(` - Versioned previous message: (v${catalogedMessage.version})`));
309
+ }
305
310
  }
306
- }
307
- await writeMessage(
308
- {
309
- id: messageId,
310
- version,
311
- name: getMessageName(message),
312
- summary: getSummary(message),
313
- markdown: messageMarkdown,
314
- badges: badges.map((badge) => ({ content: badge.name(), textColor: "blue", backgroundColor: "blue" })),
315
- schemaPath: messageHasSchema(message) ? getSchemaFileName(message) : void 0
316
- },
317
- {
318
- path: message.id()
319
- }
320
- );
321
- console.log(import_chalk2.default.cyan(` - Message (v${version}) created`));
322
- if (messageHasSchema(message)) {
323
- addSchemaToMessage(
324
- messageId,
311
+ await writeMessage(
325
312
  {
326
- fileName: getSchemaFileName(message),
327
- schema: JSON.stringify(message.payload()?.json(), null, 4)
313
+ id: messageId,
314
+ version,
315
+ name: getMessageName(message),
316
+ summary: getSummary(message),
317
+ markdown: messageMarkdown,
318
+ badges: badges.map((badge) => ({ content: badge.name(), textColor: "blue", backgroundColor: "blue" })),
319
+ schemaPath: messageHasSchema(message) ? getSchemaFileName(message) : void 0
328
320
  },
329
- version
321
+ {
322
+ path: message.id()
323
+ }
330
324
  );
331
- console.log(import_chalk2.default.cyan(` - Schema added to message (v${version})`));
332
- }
333
- if (operation.action() === "send" || operation.action() === "publish") {
334
- sends.push({ id: messageId, version });
335
- }
336
- if (operation.action() === "receive" || operation.action() === "subscribe") {
337
- receives.push({ id: messageId, version });
325
+ console.log(import_chalk2.default.cyan(` - Message (v${version}) created`));
326
+ if (messageHasSchema(message)) {
327
+ addSchemaToMessage(
328
+ messageId,
329
+ {
330
+ fileName: getSchemaFileName(message),
331
+ schema: JSON.stringify(message.payload()?.json(), null, 4)
332
+ },
333
+ version
334
+ );
335
+ console.log(import_chalk2.default.cyan(` - Schema added to message (v${version})`));
336
+ }
337
+ } else {
338
+ console.log(import_chalk2.default.yellow(` - Skipping external message: ${getMessageName(message)}(v${version})`));
338
339
  }
340
+ if (isSent) sends.push({ id: messageId, version });
341
+ if (isReceived) receives.push({ id: messageId, version });
339
342
  }
340
343
  }
341
344
  const latestServiceInCatalog = await getService(serviceId, "latest");
@@ -413,4 +416,8 @@ Failed to request AsyncAPI file from ${service.path}`));
413
416
  return await (0, import_promises.readFile)(service.path, "utf8");
414
417
  }
415
418
  };
419
+ var isServiceMessageOwner = (message) => {
420
+ const value = message.extensions().get("x-eventcatalog-role")?.value() || "provider";
421
+ return value === "provider";
422
+ };
416
423
  //# 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 { AsyncAPIDocumentInterface, Parser, fromFile, fromURL } from '@asyncapi/parser';\nimport utils from '@eventcatalog/sdk';\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';\nimport { z } from 'zod';\n\n// AsyncAPI Parsers\nimport { AvroSchemaParser } from '@asyncapi/avro-schema-parser';\nimport path from 'path';\nimport { EventType, MessageOperations } from './types';\n\nconst parser = new Parser();\n\n// register avro schema support\nparser.registerSchemaParser(AvroSchemaParser());\nconst cliArgs = argv(process.argv.slice(2));\n\nconst optionsSchema = z.object({\n services: z.array(\n z.object({\n id: z.string({ required_error: 'The service id is required. please provide the service id' }),\n path: z.string({ required_error: 'The service path is required. please provide the path to specification file' }),\n name: z.string().optional(),\n }),\n { message: 'Please provide correct services configuration' }\n ),\n domain: z\n .object({\n id: z.string({ required_error: 'The domain id is required. please provide a domain id' }),\n name: z.string({ required_error: 'The domain name is required. please provide a domain name' }),\n version: z.string({ required_error: 'The domain version is required. please provide a domain version' }),\n })\n .optional(),\n debug: z.boolean().optional(),\n saveParsedSpecFile: z.boolean({ invalid_type_error: 'The saveParsedSpecFile is not a boolean in options' }).optional(),\n});\n\ntype Props = z.infer<typeof optionsSchema>;\ntype Domain = z.infer<typeof optionsSchema>['domain'];\ntype Service = z.infer<typeof optionsSchema>['services'][0];\n\nconst validateOptions = (options: Props) => {\n try {\n optionsSchema.parse(options);\n } catch (error: any) {\n if (error instanceof z.ZodError) throw new Error(JSON.stringify(error.issues, null, 2));\n }\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 writeQuery,\n getService,\n versionService,\n rmService,\n getDomain,\n writeDomain,\n addServiceToDomain,\n getCommand,\n getEvent,\n getQuery,\n rmEventById,\n rmCommandById,\n rmQueryById,\n versionCommand,\n versionEvent,\n versionQuery,\n addSchemaToCommand,\n addSchemaToEvent,\n addSchemaToQuery,\n addFileToService,\n versionDomain,\n getSpecificationFilesForService,\n } = utils(process.env.PROJECT_DIR);\n\n // Define the message operations mapping with proper types\n const MESSAGE_OPERATIONS: Record<EventType, MessageOperations> = {\n event: {\n write: writeEvent,\n version: versionEvent,\n get: getEvent,\n remove: rmEventById,\n addSchema: addSchemaToEvent,\n },\n command: {\n write: writeCommand,\n version: versionCommand,\n get: getCommand,\n remove: rmCommandById,\n addSchema: addSchemaToCommand,\n },\n query: {\n write: writeQuery,\n version: versionQuery,\n get: getQuery,\n remove: rmQueryById,\n addSchema: addSchemaToQuery,\n },\n };\n\n // Should the file that is written to the catalog be parsed (https://github.com/asyncapi/parser-js) or as it is?\n validateOptions(options);\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 for (const service of services) {\n console.log(chalk.gray(`Processing ${service.path}`));\n\n const { document, diagnostics } = service.path.startsWith('http')\n ? await fromURL(parser, service.path).parse()\n : 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\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() as EventType) || 'event';\n\n const messageId = message.id().toLowerCase();\n\n if (eventType !== 'event' && eventType !== 'command' && eventType !== 'query') {\n throw new Error('Invalid message type');\n }\n\n const {\n write: writeMessage,\n version: versionMessage,\n get: getMessage,\n remove: rmMessageById,\n addSchema: addSchemaToMessage,\n } = MESSAGE_OPERATIONS[eventType];\n\n let messageMarkdown = generateMarkdownForMessage(document, message);\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 const fileName = path.basename(service.path);\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: fileName || 'asyncapi.yml',\n specifications: {\n ...serviceSpecifications,\n asyncapiPath: fileName || '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: path.basename(service.path) || '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) => {\n if (service.path.startsWith('http')) {\n try {\n const response = await fetch(service.path);\n return response.text();\n } catch (error) {\n console.log(chalk.red(`\\nFailed to request AsyncAPI file from ${service.path}`));\n return '';\n }\n } else {\n return await readFile(service.path, 'utf8');\n }\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,oBAAqE;AACrE,iBAAkB;AAClB,sBAAyB;;;ACHlB,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;A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ultMarkdown","getSummary","defaultMarkdown","import_chalk","chalk","argv","utils","chalk","defaultMarkdown","path","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, MessageInterface, Parser, fromFile, fromURL } from '@asyncapi/parser';\nimport utils from '@eventcatalog/sdk';\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';\nimport { z } from 'zod';\n\n// AsyncAPI Parsers\nimport { AvroSchemaParser } from '@asyncapi/avro-schema-parser';\nimport path from 'path';\nimport { EventType, MessageOperations } from './types';\n\nconst parser = new Parser();\n\n// register avro schema support\nparser.registerSchemaParser(AvroSchemaParser());\nconst cliArgs = argv(process.argv.slice(2));\n\nconst optionsSchema = z.object({\n services: z.array(\n z.object({\n id: z.string({ required_error: 'The service id is required. please provide the service id' }),\n path: z.string({ required_error: 'The service path is required. please provide the path to specification file' }),\n name: z.string().optional(),\n }),\n { message: 'Please provide correct services configuration' }\n ),\n domain: z\n .object({\n id: z.string({ required_error: 'The domain id is required. please provide a domain id' }),\n name: z.string({ required_error: 'The domain name is required. please provide a domain name' }),\n version: z.string({ required_error: 'The domain version is required. please provide a domain version' }),\n })\n .optional(),\n debug: z.boolean().optional(),\n saveParsedSpecFile: z.boolean({ invalid_type_error: 'The saveParsedSpecFile is not a boolean in options' }).optional(),\n});\n\ntype Props = z.infer<typeof optionsSchema>;\ntype Domain = z.infer<typeof optionsSchema>['domain'];\ntype Service = z.infer<typeof optionsSchema>['services'][0];\n\nconst validateOptions = (options: Props) => {\n try {\n optionsSchema.parse(options);\n } catch (error: any) {\n if (error instanceof z.ZodError) throw new Error(JSON.stringify(error.issues, null, 2));\n }\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 writeQuery,\n getService,\n versionService,\n rmService,\n getDomain,\n writeDomain,\n addServiceToDomain,\n getCommand,\n getEvent,\n getQuery,\n rmEventById,\n rmCommandById,\n rmQueryById,\n versionCommand,\n versionEvent,\n versionQuery,\n addSchemaToCommand,\n addSchemaToEvent,\n addSchemaToQuery,\n addFileToService,\n versionDomain,\n getSpecificationFilesForService,\n } = utils(process.env.PROJECT_DIR);\n\n // Define the message operations mapping with proper types\n const MESSAGE_OPERATIONS: Record<EventType, MessageOperations> = {\n event: {\n write: writeEvent,\n version: versionEvent,\n get: getEvent,\n remove: rmEventById,\n addSchema: addSchemaToEvent,\n },\n command: {\n write: writeCommand,\n version: versionCommand,\n get: getCommand,\n remove: rmCommandById,\n addSchema: addSchemaToCommand,\n },\n query: {\n write: writeQuery,\n version: versionQuery,\n get: getQuery,\n remove: rmQueryById,\n addSchema: addSchemaToQuery,\n },\n };\n\n // Should the file that is written to the catalog be parsed (https://github.com/asyncapi/parser-js) or as it is?\n validateOptions(options);\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 for (const service of services) {\n console.log(chalk.gray(`Processing ${service.path}`));\n\n const { document, diagnostics } = service.path.startsWith('http')\n ? await fromURL(parser, service.path).parse()\n : 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\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() as EventType) || 'event';\n\n // does this service own or just consume the message?\n const serviceOwnsMessageContract = isServiceMessageOwner(message);\n const isReceived = operation.action() === 'receive' || operation.action() === 'receive';\n const isSent = operation.action() === 'send' || operation.action() === 'publish';\n\n const messageId = message.id().toLowerCase();\n\n if (eventType !== 'event' && eventType !== 'command' && eventType !== 'query') {\n throw new Error('Invalid message type');\n }\n\n const {\n write: writeMessage,\n version: versionMessage,\n get: getMessage,\n remove: rmMessageById,\n addSchema: addSchemaToMessage,\n } = MESSAGE_OPERATIONS[eventType];\n\n let messageMarkdown = generateMarkdownForMessage(document, message);\n const badges = message.tags().all() || [];\n\n console.log(chalk.blue(`Processing message: ${getMessageName(message)} (v${version})`));\n\n if (serviceOwnsMessageContract) {\n // Check if the message already exists in the catalog\n const catalogedMessage = await getMessage(message.id().toLowerCase(), 'latest');\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 // 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 } else {\n // Message is not owned by this service, therefore we don't need to document it\n console.log(chalk.yellow(` - Skipping external message: ${getMessageName(message)}(v${version})`));\n }\n // Add the message to the correct array\n if (isSent) sends.push({ id: messageId, version: version });\n if (isReceived) receives.push({ id: messageId, version: version });\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 const fileName = path.basename(service.path);\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: fileName || 'asyncapi.yml',\n specifications: {\n ...serviceSpecifications,\n asyncapiPath: fileName || '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: path.basename(service.path) || '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) => {\n if (service.path.startsWith('http')) {\n try {\n const response = await fetch(service.path);\n return response.text();\n } catch (error) {\n console.log(chalk.red(`\\nFailed to request AsyncAPI file from ${service.path}`));\n return '';\n }\n } else {\n return await readFile(service.path, 'utf8');\n }\n};\n/**\n * Is the AsyncAPI specification (service) the owner of the message?\n * This is determined by the 'x-eventcatalog-role' extension in the message\n *\n * @param message\n * @returns boolean\n *\n * default is provider (AsyncAPI file / service owns the message)\n */\nconst isServiceMessageOwner = (message: MessageInterface): boolean => {\n const value = message.extensions().get('x-eventcatalog-role')?.value() || 'provider';\n return value === 'provider';\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,oBAAuF;AACvF,iBAAkB;AAClB,sBAAyB;;;ACHlB,IAAM,mCAAmC,CAAC,SAA6B,OAAO;AACnF,MAAI,OAAO,SAAS,MAAM,EAAG,QAAO;AAC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SAAS,QAAQ,MAAM,CAAC,IACvD,eAAAI,QAAK,KAAK,SAAS,KAAK,EAAE,SAAS,QAAQ,EAAE,QAAQ,KAAK,CAAC;AACjE;AAEA,IAAM,iBAAiB,OAAO,YAAqB;AACjD,MAAI,QAAQ,KAAK,WAAW,MAAM,GAAG;AACnC,QAAI;AACF,YAAM,WAAW,MAAM,MAAM,QAAQ,IAAI;AACzC,aAAO,SAAS,KAAK;AAAA,IACvB,SAAS,OAAO;AACd,cAAQ,IAAI,cAAAJ,QAAM,IAAI;AAAA,uCAA0C,QAAQ,IAAI,EAAE,CAAC;AAC/E,aAAO;AAAA,IACT;AAAA,EACF,OAAO;AACL,WAAO,UAAM,0BAAS,QAAQ,MAAM,MAAM;AAAA,EAC5C;AACF;AAUA,IAAM,wBAAwB,CAAC,YAAuC;AACpE,QAAM,QAAQ,QAAQ,WAAW,EAAE,IAAI,qBAAqB,GAAG,MAAM,KAAK;AAC1E,SAAO,UAAU;AACnB;","names":["defaultMarkdown","getSummary","defaultMarkdown","import_chalk","chalk","argv","utils","chalk","defaultMarkdown","path","getSummary","yaml"]}
package/dist/index.mjs CHANGED
@@ -246,6 +246,9 @@ Processing domain: ${domainName} (v${domainVersion})`));
246
246
  for (const operation of operations) {
247
247
  for (const message of operation.messages()) {
248
248
  const eventType = message.extensions().get("x-eventcatalog-message-type")?.value() || "event";
249
+ const serviceOwnsMessageContract = isServiceMessageOwner(message);
250
+ const isReceived = operation.action() === "receive" || operation.action() === "receive";
251
+ const isSent = operation.action() === "send" || operation.action() === "publish";
249
252
  const messageId = message.id().toLowerCase();
250
253
  if (eventType !== "event" && eventType !== "command" && eventType !== "query") {
251
254
  throw new Error("Invalid message type");
@@ -259,49 +262,49 @@ Processing domain: ${domainName} (v${domainVersion})`));
259
262
  } = MESSAGE_OPERATIONS[eventType];
260
263
  let messageMarkdown = defaultMarkdown(document, message);
261
264
  const badges = message.tags().all() || [];
262
- const catalogedMessage = await getMessage(message.id().toLowerCase(), "latest");
263
265
  console.log(chalk2.blue(`Processing message: ${getMessageName(message)} (v${version})`));
264
- if (catalogedMessage) {
265
- messageMarkdown = catalogedMessage.markdown;
266
- if (catalogedMessage.version === version) {
267
- await rmMessageById(messageId, version);
268
- } else {
269
- await versionMessage(messageId);
270
- console.log(chalk2.cyan(` - Versioned previous message: (v${catalogedMessage.version})`));
266
+ if (serviceOwnsMessageContract) {
267
+ const catalogedMessage = await getMessage(message.id().toLowerCase(), "latest");
268
+ if (catalogedMessage) {
269
+ messageMarkdown = catalogedMessage.markdown;
270
+ if (catalogedMessage.version === version) {
271
+ await rmMessageById(messageId, version);
272
+ } else {
273
+ await versionMessage(messageId);
274
+ console.log(chalk2.cyan(` - Versioned previous message: (v${catalogedMessage.version})`));
275
+ }
271
276
  }
272
- }
273
- await writeMessage(
274
- {
275
- id: messageId,
276
- version,
277
- name: getMessageName(message),
278
- summary: getSummary(message),
279
- markdown: messageMarkdown,
280
- badges: badges.map((badge) => ({ content: badge.name(), textColor: "blue", backgroundColor: "blue" })),
281
- schemaPath: messageHasSchema(message) ? getSchemaFileName(message) : void 0
282
- },
283
- {
284
- path: message.id()
285
- }
286
- );
287
- console.log(chalk2.cyan(` - Message (v${version}) created`));
288
- if (messageHasSchema(message)) {
289
- addSchemaToMessage(
290
- messageId,
277
+ await writeMessage(
291
278
  {
292
- fileName: getSchemaFileName(message),
293
- schema: JSON.stringify(message.payload()?.json(), null, 4)
279
+ id: messageId,
280
+ version,
281
+ name: getMessageName(message),
282
+ summary: getSummary(message),
283
+ markdown: messageMarkdown,
284
+ badges: badges.map((badge) => ({ content: badge.name(), textColor: "blue", backgroundColor: "blue" })),
285
+ schemaPath: messageHasSchema(message) ? getSchemaFileName(message) : void 0
294
286
  },
295
- version
287
+ {
288
+ path: message.id()
289
+ }
296
290
  );
297
- console.log(chalk2.cyan(` - Schema added to message (v${version})`));
298
- }
299
- if (operation.action() === "send" || operation.action() === "publish") {
300
- sends.push({ id: messageId, version });
301
- }
302
- if (operation.action() === "receive" || operation.action() === "subscribe") {
303
- receives.push({ id: messageId, version });
291
+ console.log(chalk2.cyan(` - Message (v${version}) created`));
292
+ if (messageHasSchema(message)) {
293
+ addSchemaToMessage(
294
+ messageId,
295
+ {
296
+ fileName: getSchemaFileName(message),
297
+ schema: JSON.stringify(message.payload()?.json(), null, 4)
298
+ },
299
+ version
300
+ );
301
+ console.log(chalk2.cyan(` - Schema added to message (v${version})`));
302
+ }
303
+ } else {
304
+ console.log(chalk2.yellow(` - Skipping external message: ${getMessageName(message)}(v${version})`));
304
305
  }
306
+ if (isSent) sends.push({ id: messageId, version });
307
+ if (isReceived) receives.push({ id: messageId, version });
305
308
  }
306
309
  }
307
310
  const latestServiceInCatalog = await getService(serviceId, "latest");
@@ -379,6 +382,10 @@ Failed to request AsyncAPI file from ${service.path}`));
379
382
  return await readFile(service.path, "utf8");
380
383
  }
381
384
  };
385
+ var isServiceMessageOwner = (message) => {
386
+ const value = message.extensions().get("x-eventcatalog-role")?.value() || "provider";
387
+ return value === "provider";
388
+ };
382
389
  export {
383
390
  src_default as default
384
391
  };
@@ -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 { AsyncAPIDocumentInterface, Parser, fromFile, fromURL } from '@asyncapi/parser';\nimport utils from '@eventcatalog/sdk';\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';\nimport { z } from 'zod';\n\n// AsyncAPI Parsers\nimport { AvroSchemaParser } from '@asyncapi/avro-schema-parser';\nimport path from 'path';\nimport { EventType, MessageOperations } from './types';\n\nconst parser = new Parser();\n\n// register avro schema support\nparser.registerSchemaParser(AvroSchemaParser());\nconst cliArgs = argv(process.argv.slice(2));\n\nconst optionsSchema = z.object({\n services: z.array(\n z.object({\n id: z.string({ required_error: 'The service id is required. please provide the service id' }),\n path: z.string({ required_error: 'The service path is required. please provide the path to specification file' }),\n name: z.string().optional(),\n }),\n { message: 'Please provide correct services configuration' }\n ),\n domain: z\n .object({\n id: z.string({ required_error: 'The domain id is required. please provide a domain id' }),\n name: z.string({ required_error: 'The domain name is required. please provide a domain name' }),\n version: z.string({ required_error: 'The domain version is required. please provide a domain version' }),\n })\n .optional(),\n debug: z.boolean().optional(),\n saveParsedSpecFile: z.boolean({ invalid_type_error: 'The saveParsedSpecFile is not a boolean in options' }).optional(),\n});\n\ntype Props = z.infer<typeof optionsSchema>;\ntype Domain = z.infer<typeof optionsSchema>['domain'];\ntype Service = z.infer<typeof optionsSchema>['services'][0];\n\nconst validateOptions = (options: Props) => {\n try {\n optionsSchema.parse(options);\n } catch (error: any) {\n if (error instanceof z.ZodError) throw new Error(JSON.stringify(error.issues, null, 2));\n }\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 writeQuery,\n getService,\n versionService,\n rmService,\n getDomain,\n writeDomain,\n addServiceToDomain,\n getCommand,\n getEvent,\n getQuery,\n rmEventById,\n rmCommandById,\n rmQueryById,\n versionCommand,\n versionEvent,\n versionQuery,\n addSchemaToCommand,\n addSchemaToEvent,\n addSchemaToQuery,\n addFileToService,\n versionDomain,\n getSpecificationFilesForService,\n } = utils(process.env.PROJECT_DIR);\n\n // Define the message operations mapping with proper types\n const MESSAGE_OPERATIONS: Record<EventType, MessageOperations> = {\n event: {\n write: writeEvent,\n version: versionEvent,\n get: getEvent,\n remove: rmEventById,\n addSchema: addSchemaToEvent,\n },\n command: {\n write: writeCommand,\n version: versionCommand,\n get: getCommand,\n remove: rmCommandById,\n addSchema: addSchemaToCommand,\n },\n query: {\n write: writeQuery,\n version: versionQuery,\n get: getQuery,\n remove: rmQueryById,\n addSchema: addSchemaToQuery,\n },\n };\n\n // Should the file that is written to the catalog be parsed (https://github.com/asyncapi/parser-js) or as it is?\n validateOptions(options);\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 for (const service of services) {\n console.log(chalk.gray(`Processing ${service.path}`));\n\n const { document, diagnostics } = service.path.startsWith('http')\n ? await fromURL(parser, service.path).parse()\n : 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\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() as EventType) || 'event';\n\n const messageId = message.id().toLowerCase();\n\n if (eventType !== 'event' && eventType !== 'command' && eventType !== 'query') {\n throw new Error('Invalid message type');\n }\n\n const {\n write: writeMessage,\n version: versionMessage,\n get: getMessage,\n remove: rmMessageById,\n addSchema: addSchemaToMessage,\n } = MESSAGE_OPERATIONS[eventType];\n\n let messageMarkdown = generateMarkdownForMessage(document, message);\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 const fileName = path.basename(service.path);\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: fileName || 'asyncapi.yml',\n specifications: {\n ...serviceSpecifications,\n asyncapiPath: fileName || '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: path.basename(service.path) || '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) => {\n if (service.path.startsWith('http')) {\n try {\n const response = await fetch(service.path);\n return response.text();\n } catch (error) {\n console.log(chalk.red(`\\nFailed to request AsyncAPI file from ${service.path}`));\n return '';\n }\n } else {\n return await readFile(service.path, 'utf8');\n }\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 );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B;AACjD,MAAI,QAAQ,KAAK,WAAW,MAAM,GAAG;AACnC,QAAI;AACF,YAAM,WAAW,MAAM,MAAM,QAAQ,IAAI;AACzC,aAAO,SAAS,KAAK;AAAA,IACvB,SAAS,OAAO;AACd,cAAQ,IAAIA,OAAM,IAAI;AAAA,uCAA0C,QAAQ,IAAI,EAAE,CAAC;AAC/E,aAAO;AAAA,IACT;AAAA,EACF,OAAO;AACL,WAAO,MAAM,SAAS,QAAQ,MAAM,MAAM;AAAA,EAC5C;AACF;","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, MessageInterface, Parser, fromFile, fromURL } from '@asyncapi/parser';\nimport utils from '@eventcatalog/sdk';\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';\nimport { z } from 'zod';\n\n// AsyncAPI Parsers\nimport { AvroSchemaParser } from '@asyncapi/avro-schema-parser';\nimport path from 'path';\nimport { EventType, MessageOperations } from './types';\n\nconst parser = new Parser();\n\n// register avro schema support\nparser.registerSchemaParser(AvroSchemaParser());\nconst cliArgs = argv(process.argv.slice(2));\n\nconst optionsSchema = z.object({\n services: z.array(\n z.object({\n id: z.string({ required_error: 'The service id is required. please provide the service id' }),\n path: z.string({ required_error: 'The service path is required. please provide the path to specification file' }),\n name: z.string().optional(),\n }),\n { message: 'Please provide correct services configuration' }\n ),\n domain: z\n .object({\n id: z.string({ required_error: 'The domain id is required. please provide a domain id' }),\n name: z.string({ required_error: 'The domain name is required. please provide a domain name' }),\n version: z.string({ required_error: 'The domain version is required. please provide a domain version' }),\n })\n .optional(),\n debug: z.boolean().optional(),\n saveParsedSpecFile: z.boolean({ invalid_type_error: 'The saveParsedSpecFile is not a boolean in options' }).optional(),\n});\n\ntype Props = z.infer<typeof optionsSchema>;\ntype Domain = z.infer<typeof optionsSchema>['domain'];\ntype Service = z.infer<typeof optionsSchema>['services'][0];\n\nconst validateOptions = (options: Props) => {\n try {\n optionsSchema.parse(options);\n } catch (error: any) {\n if (error instanceof z.ZodError) throw new Error(JSON.stringify(error.issues, null, 2));\n }\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 writeQuery,\n getService,\n versionService,\n rmService,\n getDomain,\n writeDomain,\n addServiceToDomain,\n getCommand,\n getEvent,\n getQuery,\n rmEventById,\n rmCommandById,\n rmQueryById,\n versionCommand,\n versionEvent,\n versionQuery,\n addSchemaToCommand,\n addSchemaToEvent,\n addSchemaToQuery,\n addFileToService,\n versionDomain,\n getSpecificationFilesForService,\n } = utils(process.env.PROJECT_DIR);\n\n // Define the message operations mapping with proper types\n const MESSAGE_OPERATIONS: Record<EventType, MessageOperations> = {\n event: {\n write: writeEvent,\n version: versionEvent,\n get: getEvent,\n remove: rmEventById,\n addSchema: addSchemaToEvent,\n },\n command: {\n write: writeCommand,\n version: versionCommand,\n get: getCommand,\n remove: rmCommandById,\n addSchema: addSchemaToCommand,\n },\n query: {\n write: writeQuery,\n version: versionQuery,\n get: getQuery,\n remove: rmQueryById,\n addSchema: addSchemaToQuery,\n },\n };\n\n // Should the file that is written to the catalog be parsed (https://github.com/asyncapi/parser-js) or as it is?\n validateOptions(options);\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 for (const service of services) {\n console.log(chalk.gray(`Processing ${service.path}`));\n\n const { document, diagnostics } = service.path.startsWith('http')\n ? await fromURL(parser, service.path).parse()\n : 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\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() as EventType) || 'event';\n\n // does this service own or just consume the message?\n const serviceOwnsMessageContract = isServiceMessageOwner(message);\n const isReceived = operation.action() === 'receive' || operation.action() === 'receive';\n const isSent = operation.action() === 'send' || operation.action() === 'publish';\n\n const messageId = message.id().toLowerCase();\n\n if (eventType !== 'event' && eventType !== 'command' && eventType !== 'query') {\n throw new Error('Invalid message type');\n }\n\n const {\n write: writeMessage,\n version: versionMessage,\n get: getMessage,\n remove: rmMessageById,\n addSchema: addSchemaToMessage,\n } = MESSAGE_OPERATIONS[eventType];\n\n let messageMarkdown = generateMarkdownForMessage(document, message);\n const badges = message.tags().all() || [];\n\n console.log(chalk.blue(`Processing message: ${getMessageName(message)} (v${version})`));\n\n if (serviceOwnsMessageContract) {\n // Check if the message already exists in the catalog\n const catalogedMessage = await getMessage(message.id().toLowerCase(), 'latest');\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 // 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 } else {\n // Message is not owned by this service, therefore we don't need to document it\n console.log(chalk.yellow(` - Skipping external message: ${getMessageName(message)}(v${version})`));\n }\n // Add the message to the correct array\n if (isSent) sends.push({ id: messageId, version: version });\n if (isReceived) receives.push({ id: messageId, version: version });\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 const fileName = path.basename(service.path);\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: fileName || 'asyncapi.yml',\n specifications: {\n ...serviceSpecifications,\n asyncapiPath: fileName || '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: path.basename(service.path) || '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) => {\n if (service.path.startsWith('http')) {\n try {\n const response = await fetch(service.path);\n return response.text();\n } catch (error) {\n console.log(chalk.red(`\\nFailed to request AsyncAPI file from ${service.path}`));\n return '';\n }\n } else {\n return await readFile(service.path, 'utf8');\n }\n};\n/**\n * Is the AsyncAPI specification (service) the owner of the message?\n * This is determined by the 'x-eventcatalog-role' extension in the message\n *\n * @param message\n * @returns boolean\n *\n * default is provider (AsyncAPI file / service owns the message)\n */\nconst isServiceMessageOwner = (message: MessageInterface): boolean => {\n const value = message.extensions().get('x-eventcatalog-role')?.value() || 'provider';\n return value === 'provider';\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,SAAsD,QAAQ,UAAU,eAAe;AACvF,OAAO,WAAW;AAClB,SAAS,gBAAgB;;;ACHlB,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;AAEA,SAAO;A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B;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;AACjD,MAAI,QAAQ,KAAK,WAAW,MAAM,GAAG;AACnC,QAAI;AACF,YAAM,WAAW,MAAM,MAAM,QAAQ,IAAI;AACzC,aAAO,SAAS,KAAK;AAAA,IACvB,SAAS,OAAO;AACd,cAAQ,IAAIA,OAAM,IAAI;AAAA,uCAA0C,QAAQ,IAAI,EAAE,CAAC;AAC/E,aAAO;AAAA,IACT;AAAA,EACF,OAAO;AACL,WAAO,MAAM,SAAS,QAAQ,MAAM,MAAM;AAAA,EAC5C;AACF;AAUA,IAAM,wBAAwB,CAAC,YAAuC;AACpE,QAAM,QAAQ,QAAQ,WAAW,EAAE,IAAI,qBAAqB,GAAG,MAAM,KAAK;AAC1E,SAAO,UAAU;AACnB;","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": "2.3.1",
3
+ "version": "2.4.0",
4
4
  "description": "AsyncAPI generator for EventCatalog",
5
5
  "publishConfig": {
6
6
  "access": "public"