@eventcatalog/generator-openapi 0.0.1 → 0.0.2

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
@@ -35,7 +35,7 @@ __export(src_exports, {
35
35
  module.exports = __toCommonJS(src_exports);
36
36
  var import_sdk2 = __toESM(require("@eventcatalog/sdk"));
37
37
  var import_promises = require("fs/promises");
38
- var import_chalk = __toESM(require("chalk"));
38
+ var import_chalk2 = __toESM(require("chalk"));
39
39
  var import_swagger_parser2 = __toESM(require("@apidevtools/swagger-parser"));
40
40
 
41
41
  // src/utils/domains.ts
@@ -157,6 +157,7 @@ async function getOperationsByType(openApiPath) {
157
157
  }
158
158
 
159
159
  // src/utils/messages.ts
160
+ var import_slugify2 = __toESM(require("slugify"));
160
161
  var markdownForParameters = (parameters) => {
161
162
  let markdown = "### Parameters\n";
162
163
  for (const parameter of parameters) {
@@ -230,10 +231,16 @@ var buildMessage = async (pathToFile, document, operation) => {
230
231
  backgroundColor: "blue"
231
232
  }));
232
233
  const badges = [{ content: operation.method.toUpperCase(), textColor: "blue", backgroundColor: "blue" }, ...operationTags];
234
+ const apiName = (0, import_slugify2.default)(document.info.title, { lower: true });
235
+ const path = operation.path.replace(/\//, "").replace(/\//g, "_");
236
+ let uniqueIdentifier = operation.operationId || `${apiName}_${operation.method}`;
237
+ if (!operation.operationId && path) {
238
+ uniqueIdentifier = uniqueIdentifier.concat(`_${path}`);
239
+ }
233
240
  return {
234
- id: operation.operationId,
241
+ id: uniqueIdentifier,
235
242
  version: document.info.version,
236
- name: operation.operationId,
243
+ name: uniqueIdentifier,
237
244
  summary: getSummary2(operation),
238
245
  markdown: defaultMarkdown3(operation, requestBodiesAndResponses),
239
246
  schemaPath: requestBodiesAndResponses?.requestBody ? "request-body.json" : "",
@@ -275,6 +282,19 @@ var getMessageTypeUtils = (projectDirectory, messageType) => {
275
282
  };
276
283
  };
277
284
 
285
+ // src/utils/checkLicense.ts
286
+ var import_chalk = __toESM(require("chalk"));
287
+ var checkLicense_default = () => {
288
+ console.log(import_chalk.default.bgBlue(`
289
+ You are using a free version of this plugin`));
290
+ console.log(
291
+ import_chalk.default.blueBright(
292
+ `This plugin is governed and published under the AGPL-3.0 copy-left license.
293
+ If using for commercial purposes or proprietary software, please contact hello@eventcatalog.dev for a license to support the project.`
294
+ )
295
+ );
296
+ };
297
+
278
298
  // src/index.ts
279
299
  var src_default = async (_, options) => {
280
300
  if (!process.env.PROJECT_DIR) {
@@ -293,12 +313,12 @@ var src_default = async (_, options) => {
293
313
  } = (0, import_sdk2.default)(process.env.PROJECT_DIR);
294
314
  const openAPIFiles = Array.isArray(options.path) ? options.path : [options.path];
295
315
  for (const path of openAPIFiles) {
296
- console.log(import_chalk.default.green(`Processing ${path}`));
316
+ console.log(import_chalk2.default.green(`Processing ${path}`));
297
317
  try {
298
318
  await import_swagger_parser2.default.validate(path);
299
319
  } catch (error) {
300
- console.error(import_chalk.default.red(`Failed to parse OpenAPI file: ${path}`));
301
- console.error(import_chalk.default.red(error));
320
+ console.error(import_chalk2.default.red(`Failed to parse OpenAPI file: ${path}`));
321
+ console.error(import_chalk2.default.red(error));
302
322
  continue;
303
323
  }
304
324
  const openAPIFile = await (0, import_promises.readFile)(path, "utf-8");
@@ -310,11 +330,11 @@ var src_default = async (_, options) => {
310
330
  const { id: domainId, name: domainName, version: domainVersion } = options.domain;
311
331
  const domain = await getDomain(options.domain.id, domainVersion || "latest");
312
332
  const currentDomain = await getDomain(options.domain.id, "latest");
313
- console.log(import_chalk.default.blue(`
333
+ console.log(import_chalk2.default.blue(`
314
334
  Processing domain: ${domainName} (v${domainVersion})`));
315
335
  if (currentDomain && currentDomain.version !== domainVersion) {
316
336
  await versionDomain(domainId);
317
- console.log(import_chalk.default.cyan(` - Versioned previous domain (v${currentDomain.version})`));
337
+ console.log(import_chalk2.default.cyan(` - Versioned previous domain (v${currentDomain.version})`));
318
338
  }
319
339
  if (!domain || domain && domain.version !== domainVersion) {
320
340
  await writeDomain({
@@ -323,22 +343,22 @@ Processing domain: ${domainName} (v${domainVersion})`));
323
343
  version: domainVersion,
324
344
  markdown: defaultMarkdown()
325
345
  });
326
- console.log(import_chalk.default.cyan(` - Domain (v${domainVersion}) created`));
346
+ console.log(import_chalk2.default.cyan(` - Domain (v${domainVersion}) created`));
327
347
  }
328
348
  if (currentDomain && currentDomain.version === domainVersion) {
329
- console.log(import_chalk.default.yellow(` - Domain (v${domainVersion}) already exists, skipped creation...`));
349
+ console.log(import_chalk2.default.yellow(` - Domain (v${domainVersion}) already exists, skipped creation...`));
330
350
  }
331
351
  await addServiceToDomain(domainId, { id: service.id, version: service.version }, domainVersion);
332
352
  }
333
353
  let { sends, receives } = await processMessagesForOpenAPISpec(path, document);
334
354
  const latestServiceInCatalog = await getService(service.id, "latest");
335
- console.log(import_chalk.default.blue(`Processing service: ${document.info.title} (v${version})`));
355
+ console.log(import_chalk2.default.blue(`Processing service: ${document.info.title} (v${version})`));
336
356
  if (latestServiceInCatalog) {
337
357
  serviceMarkdown = latestServiceInCatalog.markdown;
338
358
  sends = latestServiceInCatalog.sends || [];
339
359
  if (latestServiceInCatalog.version !== version) {
340
360
  await versionService(service.id);
341
- console.log(import_chalk.default.cyan(` - Versioned previous service (v${latestServiceInCatalog.version})`));
361
+ console.log(import_chalk2.default.cyan(` - Versioned previous service (v${latestServiceInCatalog.version})`));
342
362
  }
343
363
  if (latestServiceInCatalog.version === version) {
344
364
  await rmService(service.name);
@@ -361,14 +381,9 @@ Processing domain: ${domainName} (v${domainVersion})`));
361
381
  },
362
382
  version
363
383
  );
364
- console.log(import_chalk.default.cyan(` - Service (v${version}) created`));
365
- console.log(import_chalk.default.green(`
366
- Finished generating event catalog for OpenAPI ${service.name} (v${version})`));
367
- console.log(import_chalk.default.bgBlue(`
368
- You are using a free version of this plugin`));
369
- console.log(import_chalk.default.blueBright(`This plugin is governed and published under the AGPL-3.0 copy-left license.
370
- If using for commercial purposes or proprietary software, please contact hello@eventcatalog.dev for a license to support the project.`));
384
+ console.log(import_chalk2.default.cyan(` - Service (v${version}) created`));
371
385
  }
386
+ await checkLicense_default();
372
387
  };
373
388
  var processMessagesForOpenAPISpec = async (pathToSpec, document) => {
374
389
  const operations = await getOperationsByType(pathToSpec);
@@ -378,7 +393,7 @@ var processMessagesForOpenAPISpec = async (pathToSpec, document) => {
378
393
  const { requestBodiesAndResponses, ...message } = await buildMessage(pathToSpec, document, operation);
379
394
  let messageMarkdown = message.markdown;
380
395
  const messageType = operation.type;
381
- console.log(import_chalk.default.blue(`Processing message: ${message.name} (v${version})`));
396
+ console.log(import_chalk2.default.blue(`Processing message: ${message.name} (v${version})`));
382
397
  const { addFileToMessage, writeMessage, rmMessageById, getMessage, versionMessage } = getMessageTypeUtils(
383
398
  process.env.PROJECT_DIR,
384
399
  messageType
@@ -390,12 +405,12 @@ var processMessagesForOpenAPISpec = async (pathToSpec, document) => {
390
405
  await rmMessageById(message.id, version);
391
406
  } else {
392
407
  await versionMessage(message.id);
393
- console.log(import_chalk.default.cyan(` - Versioned previous message: (v${catalogedMessage.version})`));
408
+ console.log(import_chalk2.default.cyan(` - Versioned previous message: (v${catalogedMessage.version})`));
394
409
  }
395
410
  }
396
411
  await writeMessage({ ...message, markdown: messageMarkdown }, { path: message.name });
397
412
  receives.push({
398
- id: operation.operationId,
413
+ id: message.id,
399
414
  version: message.version
400
415
  });
401
416
  if (requestBodiesAndResponses?.requestBody) {
@@ -420,7 +435,11 @@ var processMessagesForOpenAPISpec = async (pathToSpec, document) => {
420
435
  );
421
436
  }
422
437
  }
423
- console.log(import_chalk.default.cyan(` - Message (v${version}) created`));
438
+ console.log(import_chalk2.default.cyan(` - Message (v${version}) created`));
439
+ if (!operation.operationId) {
440
+ console.log(import_chalk2.default.yellow(` - OperationId not found for ${operation.method} ${operation.path}, creating one...`));
441
+ console.log(import_chalk2.default.yellow(` - Use operationIds to give better unique names for EventCatalog`));
442
+ }
424
443
  }
425
444
  return { receives, sends: [] };
426
445
  };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/utils/domains.ts","../src/utils/services.ts","../src/utils/openapi.ts","../src/utils/messages.ts","../src/utils/catalog-shorthand.ts"],"sourcesContent":["import utils from '@eventcatalog/sdk';\nimport { readFile } from 'node:fs/promises';\nimport chalk from 'chalk';\nimport SwaggerParser from '@apidevtools/swagger-parser';\n\nimport { defaultMarkdown as generateMarkdownForDomain } from './utils/domains';\nimport { buildService } from './utils/services';\nimport { buildMessage } from './utils/messages';\nimport { getOperationsByType } from './utils/openapi';\nimport { Domain } from './types';\nimport { getMessageTypeUtils } from './utils/catalog-shorthand';\nimport { OpenAPI } from 'openapi-types';\n\ntype Props = {\n path: string | string[];\n domain?: Domain;\n debug?: boolean;\n};\n\nexport default async (_: 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 getDomain,\n versionDomain,\n writeDomain,\n addServiceToDomain,\n getService,\n versionService,\n rmService,\n writeService,\n addFileToService,\n } = utils(process.env.PROJECT_DIR);\n\n const openAPIFiles = Array.isArray(options.path) ? options.path : [options.path];\n\n for (const path of openAPIFiles) {\n console.log(chalk.green(`Processing ${path}`));\n\n try {\n await SwaggerParser.validate(path);\n } catch (error) {\n console.error(chalk.red(`Failed to parse OpenAPI file: ${path}`));\n console.error(chalk.red(error));\n continue;\n }\n\n const openAPIFile = await readFile(path, 'utf-8');\n const document = await SwaggerParser.parse(path);\n const version = document.info.version;\n\n const service = buildService(path, document);\n let serviceMarkdown = service.markdown;\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(),\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: service.id, version: service.version }, domainVersion);\n }\n\n // Process all messages for the OpenAPI spec\n let { sends, receives } = await processMessagesForOpenAPISpec(path, document);\n\n // Check if service is already defined... if the versions do not match then create service.\n const latestServiceInCatalog = await getService(service.id, 'latest');\n console.log(chalk.blue(`Processing service: ${document.info.title} (v${version})`));\n\n if (latestServiceInCatalog) {\n serviceMarkdown = latestServiceInCatalog.markdown;\n sends = latestServiceInCatalog.sends || ([] as any);\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(service.id);\n console.log(chalk.cyan(` - Versioned previous service (v${latestServiceInCatalog.version})`));\n }\n\n // Match found, override it\n if (latestServiceInCatalog.version === version) {\n await rmService(service.name);\n }\n }\n\n await writeService(\n {\n ...service,\n markdown: serviceMarkdown,\n sends,\n receives,\n },\n { path: service.name }\n );\n\n await addFileToService(\n service.id,\n {\n fileName: service.schemaPath,\n content: openAPIFile,\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 OpenAPI ${service.name} (v${version})`));\n\n console.log(chalk.bgBlue(`\\nYou are using a free version of this plugin`));\n console.log(chalk.blueBright(`This plugin is governed and published under the AGPL-3.0 copy-left license. \\nIf using for commercial purposes or proprietary software, please contact hello@eventcatalog.dev for a license to support the project.`));\n }\n};\n\nconst processMessagesForOpenAPISpec = async (pathToSpec: string, document: OpenAPI.Document) => {\n const operations = await getOperationsByType(pathToSpec);\n const version = document.info.version;\n let receives = [];\n\n // Go through all messages\n for (const operation of operations) {\n\n const { requestBodiesAndResponses, ...message } = await buildMessage(pathToSpec, document, operation);\n let messageMarkdown = message.markdown;\n const messageType = operation.type;\n\n console.log(chalk.blue(`Processing message: ${message.name} (v${version})`));\n\n const { addFileToMessage, writeMessage, rmMessageById, getMessage, versionMessage } = getMessageTypeUtils(\n process.env.PROJECT_DIR as string,\n messageType\n );\n\n // Check if the message already exists in the catalog\n const catalogedMessage = await getMessage(message.id, '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(message.id, version);\n } else {\n // if the version does not match, we need to version the message\n await versionMessage(message.id);\n console.log(chalk.cyan(` - Versioned previous message: (v${catalogedMessage.version})`));\n }\n }\n\n // Write the message to the catalog\n await writeMessage({...message, markdown: messageMarkdown}, { path: message.name });\n\n // messages will always be messages the service receives\n receives.push({\n id: operation.operationId,\n version: message.version,\n });\n\n // Does the message have a request body or responses?\n if (requestBodiesAndResponses?.requestBody) {\n await addFileToMessage(\n message.id,\n {\n fileName: 'request-body.json',\n content: JSON.stringify(requestBodiesAndResponses.requestBody, null, 2),\n },\n message.version\n );\n }\n\n if (requestBodiesAndResponses?.responses) {\n for (const [statusCode, schema] of Object.entries(requestBodiesAndResponses.responses)) {\n await addFileToMessage(\n message.id,\n {\n fileName: `response-${statusCode}.json`,\n content: JSON.stringify(schema, null, 2),\n },\n message.version\n );\n }\n }\n\n console.log(chalk.cyan(` - Message (v${version}) created`));\n }\n return { receives, sends: [] };\n};\n","export const defaultMarkdown = () => {\n return `\n\n## Architecture diagram\n<NodeGraph />\n\n`;\n};\n","import { OpenAPI } from 'openapi-types';\nimport slugify from 'slugify';\n\nexport const defaultMarkdown = (document: OpenAPI.Document, fileName: string) => {\n return `\n\n${document.info.description ? `${document.info.description}` : ''} \n\n## Architecture diagram\n<NodeGraph />\n\n## OpenAPI Specification\n<OpenAPI file=\"${fileName}\"/>\n\n${\n document.externalDocs\n ? `\n## External documentation\n- [${document.externalDocs.description}](${document.externalDocs.url})\n`\n : ''\n}\n\n`;\n};\n\nexport const getSummary = (document: OpenAPI.Document) => {\n const summary = document.info.description ? document.info.description : '';\n return summary && summary.length < 150 ? summary : '';\n};\n\n\nexport const buildService = (pathToFile:string, document: OpenAPI.Document) => {\n const schemaPath = pathToFile.split('/').pop() || 'openapi.yml';\n const documentTags = document.tags || [];\n return {\n id: slugify(document.info.title, { lower: true, strict: true }),\n version: document.info.version,\n name: document.info.title,\n summary: getSummary(document),\n schemaPath,\n markdown: defaultMarkdown(document, schemaPath),\n badges: documentTags.map((tag) => ({ content: tag.name, textColor: 'blue', backgroundColor: 'blue' }))\n }\n};","import SwaggerParser from '@apidevtools/swagger-parser';\nimport { OpenAPIDocument, OpenAPIOperation, OpenAPIParameter, Operation } from '../types';\nimport { OpenAPIV3_1 } from \"openapi-types\";\n\nconst DEFAULT_MESSAGE_TYPE = 'query';\n\nexport async function getSchemasByOperationId(filePath: string, operationId: string): Promise<OpenAPIOperation | undefined> {\n try {\n // Parse and resolve all references in the OpenAPI document\n const api = (await SwaggerParser.dereference(filePath)) as OpenAPIDocument;\n const schemas: {\n parameters: OpenAPIParameter[];\n requestBody: any;\n responses: { [statusCode: string]: any };\n } = {\n parameters: [],\n requestBody: null,\n responses: {},\n };\n\n // Iterate through paths and operations\n for (const [path, pathItem] of Object.entries(api.paths)) {\n for (const [method, operation] of Object.entries(pathItem)) {\n // Cast operation to OpenAPIOperation type\n const typedOperation = operation as OpenAPIOperation;\n\n if (typedOperation.operationId === operationId) {\n // Extract query parameters\n if (typedOperation.parameters) {\n schemas.parameters = typedOperation.parameters;\n }\n\n // Extract request body schema\n if (typedOperation.requestBody && typedOperation.requestBody.content) {\n const contentType = Object.keys(typedOperation.requestBody.content)[0];\n schemas.requestBody = typedOperation.requestBody.content[contentType].schema;\n }\n\n // Extract response schemas\n if (typedOperation.responses) {\n for (const [statusCode, response] of Object.entries(typedOperation.responses)) {\n if (response.content) {\n const contentType = Object.keys(response.content)[0];\n schemas.responses[statusCode] = response.content[contentType].schema || response.content[contentType];\n schemas.responses[statusCode].isSchema = !!response.content[contentType].schema;\n }\n }\n }\n\n return schemas;\n }\n }\n }\n\n throw new Error(`Operation with ID \"${operationId}\" not found.`);\n } catch (error) {\n console.error('Error parsing OpenAPI file or finding operation:', error);\n return;\n }\n}\n\nexport async function getOperationsByType(openApiPath: string) {\n try {\n // Parse the OpenAPI document\n const api = await SwaggerParser.validate(openApiPath);\n\n const operations = [];\n\n // Iterate through paths\n for (const path in api.paths) {\n const pathItem = api.paths[path];\n\n // Iterate through each HTTP method in the path\n for (const method in pathItem) {\n // @ts-ignore\n const openAPIOperation = pathItem[method];\n\n // Check if the x-eventcatalog-message-type field is set\n const messageType = openAPIOperation['x-eventcatalog-message-type'] || DEFAULT_MESSAGE_TYPE;\n\n const operation = {\n path: path,\n method: method.toUpperCase(),\n operationId: openAPIOperation.operationId,\n externalDocs: openAPIOperation.externalDocs,\n type: messageType,\n description: openAPIOperation.description,\n summary: openAPIOperation.summary,\n tags: openAPIOperation.tags || [],\n } as Operation;\n\n operations.push(operation);\n }\n }\n\n return operations;\n } catch (err) {\n console.error('Error parsing OpenAPI document:', err);\n return [];\n }\n}\n","import { OpenAPI } from 'openapi-types';\nimport { getSchemasByOperationId } from './openapi';\nimport { OpenAPIOperation, OpenAPIParameter, Operation } from '../types';\n\nconst markdownForParameters = (parameters: OpenAPIParameter[]) => {\n let markdown = '### Parameters\\n';\n\n for (const parameter of parameters) {\n markdown += `- **${parameter.name}** (${parameter.in})`;\n if (parameter.required) {\n markdown += ' (required)';\n }\n if (parameter.description) {\n markdown += `: ${parameter.description}`;\n }\n markdown += '\\n';\n }\n\n return markdown;\n};\n\nexport const markdownForResponses = (openAPIOperation: OpenAPIOperation) => {\n let markdown = '### Responses\\n';\n\n for (const [statusCode, content] of Object.entries(openAPIOperation.responses as any)) {\n if (content.isSchema) {\n markdown += `**${statusCode} Response**\n<SchemaViewer file=\"response-${statusCode}.json\" maxHeight=\"500\" id=\"response-${statusCode}\" />\n `;\n } else {\n markdown += `**${statusCode} Response**\n \\`\\`\\`json\n${JSON.stringify(content, null, 2)}\n\\`\\`\\`\n `;\n }\n }\n\n return markdown;\n};\n\nexport const defaultMarkdown = (message: Operation, openAPIOperation: OpenAPIOperation = {}) => {\n return `\n\n\n## Architecture\n<NodeGraph />\n\n${\n message.externalDocs\n ? `\n## External documentation\n- [${message.externalDocs.description}](${message.externalDocs.url})\n`\n : ''\n}\n\n## ${message.method.toUpperCase()} \\`(${message.path})\\`\n\n${openAPIOperation.parameters && openAPIOperation.parameters.length > 0 ? markdownForParameters(openAPIOperation.parameters) : ''}\n\n${\n openAPIOperation.requestBody\n ? `\n### Request Body\n<SchemaViewer file=\"request-body.json\" maxHeight=\"500\" id=\"request-body\" />\n`\n : ''\n}\n\n${markdownForResponses(openAPIOperation)}\n\n`;\n};\n\nexport const getSummary = (message: Operation) => {\n const messageSummary = message.summary ? message.summary : '';\n const messageDescription = message.description ? 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 buildMessage = async (pathToFile: string, document: OpenAPI.Document, operation: Operation) => {\n\n const requestBodiesAndResponses = await getSchemasByOperationId(pathToFile, operation.operationId);\n\n const operationTags = operation.tags.map((badge) => ({\n content: `tag:${badge}`,\n textColor: 'blue',\n backgroundColor: 'blue',\n }));\n\n const badges = [{ content: operation.method.toUpperCase(), textColor: 'blue', backgroundColor: 'blue' }, ...operationTags];\n\n return {\n id: operation.operationId,\n version: document.info.version,\n name: operation.operationId,\n summary: getSummary(operation),\n markdown: defaultMarkdown(operation, requestBodiesAndResponses),\n schemaPath: requestBodiesAndResponses?.requestBody ? 'request-body.json' : '',\n badges,\n requestBodiesAndResponses\n };\n};","/**\n * TODO: Move this into the SDK\n */\n\nimport utils from '@eventcatalog/sdk';\n\nexport const getMessageTypeUtils = (projectDirectory: string, messageType: string) => {\n const {\n writeEvent,\n versionCommand,\n getEvent,\n getCommand,\n rmCommandById,\n rmEventById,\n writeCommand,\n addFileToCommand,\n addFileToEvent,\n versionEvent,\n } = utils(projectDirectory);\n\n if (messageType === 'event') {\n return {\n versionMessage: versionEvent,\n getMessage: getEvent,\n rmMessageById: rmEventById,\n writeMessage: writeEvent,\n addFileToMessage: addFileToEvent,\n };\n }\n\n // default command\n return {\n versionMessage: versionCommand,\n getMessage: getCommand,\n rmMessageById: rmCommandById,\n writeMessage: writeCommand,\n addFileToMessage: addFileToCommand,\n };\n \n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,cAAkB;AAClB,sBAAyB;AACzB,mBAAkB;AAClB,IAAAC,yBAA0B;;;ACHnB,IAAM,kBAAkB,MAAM;AACnC,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAMT;;;ACNA,qBAAoB;AAEb,IAAMC,mBAAkB,CAAC,UAA4B,aAAqB;AAC/E,SAAO;AAAA;AAAA,EAEP,SAAS,KAAK,cAAc,GAAG,SAAS,KAAK,WAAW,KAAK,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAMhD,QAAQ;AAAA;AAAA,EAGvB,SAAS,eACL;AAAA;AAAA,KAED,SAAS,aAAa,WAAW,KAAK,SAAS,aAAa,GAAG;AAAA,IAE9D,EACN;AAAA;AAAA;AAGA;AAEO,IAAM,aAAa,CAAC,aAA+B;AACxD,QAAM,UAAU,SAAS,KAAK,cAAc,SAAS,KAAK,cAAc;AACxE,SAAO,WAAW,QAAQ,SAAS,MAAM,UAAU;AACrD;AAGO,IAAM,eAAe,CAAC,YAAmB,aAA+B;AAC7E,QA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I,2BAA2B,aAAa;AAC1C,YAAM;AAAA,QACJ,QAAQ;AAAA,QACR;AAAA,UACE,UAAU;AAAA,UACV,SAAS,KAAK,UAAU,0BAA0B,aAAa,MAAM,CAAC;AAAA,QACxE;AAAA,QACA,QAAQ;AAAA,MACV;AAAA,IACF;AAEA,QAAI,2BAA2B,WAAW;AACxC,iBAAW,CAAC,YAAY,MAAM,KAAK,OAAO,QAAQ,0BAA0B,SAAS,GAAG;AACtF,cAAM;AAAA,UACJ,QAAQ;AAAA,UACR;AAAA,YACE,UAAU,YAAY,UAAU;AAAA,YAChC,SAAS,KAAK,UAAU,QAAQ,MAAM,CAAC;AAAA,UACzC;AAAA,UACA,QAAQ;AAAA,QACV;AAAA,MACF;AAAA,IACF;AAEA,YAAQ,IAAI,aAAAA,QAAM,KAAK,gBAAgB,OAAO,WAAW,CAAC;AAAA,EAC5D;AACA,SAAO,EAAE,UAAU,OAAO,CAAC,EAAE;AAC/B;","names":["import_sdk","import_swagger_parser","defaultMarkdown","slugify","SwaggerParser","defaultMarkdown","getSummary","utils","utils","chalk","SwaggerParser"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/utils/domains.ts","../src/utils/services.ts","../src/utils/openapi.ts","../src/utils/messages.ts","../src/utils/catalog-shorthand.ts","../src/utils/checkLicense.ts"],"sourcesContent":["import utils from '@eventcatalog/sdk';\nimport { readFile } from 'node:fs/promises';\nimport chalk from 'chalk';\nimport SwaggerParser from '@apidevtools/swagger-parser';\n\nimport { defaultMarkdown as generateMarkdownForDomain } from './utils/domains';\nimport { buildService } from './utils/services';\nimport { buildMessage } from './utils/messages';\nimport { getOperationsByType } from './utils/openapi';\nimport { Domain } from './types';\nimport { getMessageTypeUtils } from './utils/catalog-shorthand';\nimport { OpenAPI } from 'openapi-types';\nimport checkLicense from './utils/checkLicense';\n\ntype Props = {\n path: string | string[];\n domain?: Domain;\n debug?: boolean;\n};\n\nexport default async (_: 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 getDomain,\n versionDomain,\n writeDomain,\n addServiceToDomain,\n getService,\n versionService,\n rmService,\n writeService,\n addFileToService,\n } = utils(process.env.PROJECT_DIR);\n\n const openAPIFiles = Array.isArray(options.path) ? options.path : [options.path];\n\n for (const path of openAPIFiles) {\n console.log(chalk.green(`Processing ${path}`));\n\n try {\n await SwaggerParser.validate(path);\n } catch (error) {\n console.error(chalk.red(`Failed to parse OpenAPI file: ${path}`));\n console.error(chalk.red(error));\n continue;\n }\n\n const openAPIFile = await readFile(path, 'utf-8');\n const document = await SwaggerParser.parse(path);\n const version = document.info.version;\n\n const service = buildService(path, document);\n let serviceMarkdown = service.markdown;\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(),\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: service.id, version: service.version }, domainVersion);\n }\n\n // Process all messages for the OpenAPI spec\n let { sends, receives } = await processMessagesForOpenAPISpec(path, document);\n\n // Check if service is already defined... if the versions do not match then create service.\n const latestServiceInCatalog = await getService(service.id, 'latest');\n console.log(chalk.blue(`Processing service: ${document.info.title} (v${version})`));\n\n if (latestServiceInCatalog) {\n serviceMarkdown = latestServiceInCatalog.markdown;\n sends = latestServiceInCatalog.sends || ([] as any);\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(service.id);\n console.log(chalk.cyan(` - Versioned previous service (v${latestServiceInCatalog.version})`));\n }\n\n // Match found, override it\n if (latestServiceInCatalog.version === version) {\n await rmService(service.name);\n }\n }\n\n await writeService(\n {\n ...service,\n markdown: serviceMarkdown,\n sends,\n receives,\n },\n { path: service.name }\n );\n\n await addFileToService(\n service.id,\n {\n fileName: service.schemaPath,\n content: openAPIFile,\n },\n version\n );\n\n console.log(chalk.cyan(` - Service (v${version}) created`));\n }\n\n await checkLicense();\n};\n\nconst processMessagesForOpenAPISpec = async (pathToSpec: string, document: OpenAPI.Document) => {\n const operations = await getOperationsByType(pathToSpec);\n const version = document.info.version;\n let receives = [];\n\n // Go through all messages\n for (const operation of operations) {\n const { requestBodiesAndResponses, ...message } = await buildMessage(pathToSpec, document, operation);\n let messageMarkdown = message.markdown;\n const messageType = operation.type;\n\n console.log(chalk.blue(`Processing message: ${message.name} (v${version})`));\n\n const { addFileToMessage, writeMessage, rmMessageById, getMessage, versionMessage } = getMessageTypeUtils(\n process.env.PROJECT_DIR as string,\n messageType\n );\n\n // Check if the message already exists in the catalog\n const catalogedMessage = await getMessage(message.id, '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(message.id, version);\n } else {\n // if the version does not match, we need to version the message\n await versionMessage(message.id);\n console.log(chalk.cyan(` - Versioned previous message: (v${catalogedMessage.version})`));\n }\n }\n\n // Write the message to the catalog\n await writeMessage({ ...message, markdown: messageMarkdown }, { path: message.name });\n\n // messages will always be messages the service receives\n receives.push({\n id: message.id,\n version: message.version,\n });\n\n // Does the message have a request body or responses?\n if (requestBodiesAndResponses?.requestBody) {\n await addFileToMessage(\n message.id,\n {\n fileName: 'request-body.json',\n content: JSON.stringify(requestBodiesAndResponses.requestBody, null, 2),\n },\n message.version\n );\n }\n\n if (requestBodiesAndResponses?.responses) {\n for (const [statusCode, schema] of Object.entries(requestBodiesAndResponses.responses)) {\n await addFileToMessage(\n message.id,\n {\n fileName: `response-${statusCode}.json`,\n content: JSON.stringify(schema, null, 2),\n },\n message.version\n );\n }\n }\n\n console.log(chalk.cyan(` - Message (v${version}) created`));\n if (!operation.operationId) {\n console.log(chalk.yellow(` - OperationId not found for ${operation.method} ${operation.path}, creating one...`));\n console.log(chalk.yellow(` - Use operationIds to give better unique names for EventCatalog`));\n }\n }\n return { receives, sends: [] };\n};\n","export const defaultMarkdown = () => {\n return `\n\n## Architecture diagram\n<NodeGraph />\n\n`;\n};\n","import { OpenAPI } from 'openapi-types';\nimport slugify from 'slugify';\n\nexport const defaultMarkdown = (document: OpenAPI.Document, fileName: string) => {\n return `\n\n${document.info.description ? `${document.info.description}` : ''} \n\n## Architecture diagram\n<NodeGraph />\n\n## OpenAPI Specification\n<OpenAPI file=\"${fileName}\"/>\n\n${\n document.externalDocs\n ? `\n## External documentation\n- [${document.externalDocs.description}](${document.externalDocs.url})\n`\n : ''\n}\n\n`;\n};\n\nexport const getSummary = (document: OpenAPI.Document) => {\n const summary = document.info.description ? document.info.description : '';\n return summary && summary.length < 150 ? summary : '';\n};\n\nexport const buildService = (pathToFile: string, document: OpenAPI.Document) => {\n const schemaPath = pathToFile.split('/').pop() || 'openapi.yml';\n const documentTags = document.tags || [];\n return {\n id: slugify(document.info.title, { lower: true, strict: true }),\n version: document.info.version,\n name: document.info.title,\n summary: getSummary(document),\n schemaPath,\n markdown: defaultMarkdown(document, schemaPath),\n badges: documentTags.map((tag) => ({ content: tag.name, textColor: 'blue', backgroundColor: 'blue' })),\n };\n};\n","import SwaggerParser from '@apidevtools/swagger-parser';\nimport { OpenAPIDocument, OpenAPIOperation, OpenAPIParameter, Operation } from '../types';\n\nconst DEFAULT_MESSAGE_TYPE = 'query';\n\nexport async function getSchemasByOperationId(filePath: string, operationId: string): Promise<OpenAPIOperation | undefined> {\n try {\n // Parse and resolve all references in the OpenAPI document\n const api = (await SwaggerParser.dereference(filePath)) as OpenAPIDocument;\n const schemas: {\n parameters: OpenAPIParameter[];\n requestBody: any;\n responses: { [statusCode: string]: any };\n } = {\n parameters: [],\n requestBody: null,\n responses: {},\n };\n\n // Iterate through paths and operations\n for (const [path, pathItem] of Object.entries(api.paths)) {\n for (const [method, operation] of Object.entries(pathItem)) {\n // Cast operation to OpenAPIOperation type\n const typedOperation = operation as OpenAPIOperation;\n\n if (typedOperation.operationId === operationId) {\n // Extract query parameters\n if (typedOperation.parameters) {\n schemas.parameters = typedOperation.parameters;\n }\n\n // Extract request body schema\n if (typedOperation.requestBody && typedOperation.requestBody.content) {\n const contentType = Object.keys(typedOperation.requestBody.content)[0];\n schemas.requestBody = typedOperation.requestBody.content[contentType].schema;\n }\n\n // Extract response schemas\n if (typedOperation.responses) {\n for (const [statusCode, response] of Object.entries(typedOperation.responses)) {\n if (response.content) {\n const contentType = Object.keys(response.content)[0];\n schemas.responses[statusCode] = response.content[contentType].schema || response.content[contentType];\n schemas.responses[statusCode].isSchema = !!response.content[contentType].schema;\n }\n }\n }\n\n return schemas;\n }\n }\n }\n\n throw new Error(`Operation with ID \"${operationId}\" not found.`);\n } catch (error) {\n console.error('Error parsing OpenAPI file or finding operation:', error);\n return;\n }\n}\n\nexport async function getOperationsByType(openApiPath: string) {\n try {\n // Parse the OpenAPI document\n const api = await SwaggerParser.validate(openApiPath);\n\n const operations = [];\n\n // Iterate through paths\n for (const path in api.paths) {\n const pathItem = api.paths[path];\n\n // Iterate through each HTTP method in the path\n for (const method in pathItem) {\n // @ts-ignore\n const openAPIOperation = pathItem[method];\n\n // Check if the x-eventcatalog-message-type field is set\n const messageType = openAPIOperation['x-eventcatalog-message-type'] || DEFAULT_MESSAGE_TYPE;\n\n const operation = {\n path: path,\n method: method.toUpperCase(),\n operationId: openAPIOperation.operationId,\n externalDocs: openAPIOperation.externalDocs,\n type: messageType,\n description: openAPIOperation.description,\n summary: openAPIOperation.summary,\n tags: openAPIOperation.tags || [],\n } as Operation;\n\n operations.push(operation);\n }\n }\n\n return operations;\n } catch (err) {\n console.error('Error parsing OpenAPI document:', err);\n return [];\n }\n}\n","import { OpenAPI } from 'openapi-types';\nimport { getSchemasByOperationId } from './openapi';\nimport { OpenAPIOperation, OpenAPIParameter, Operation } from '../types';\nimport slugify from 'slugify';\n\nconst markdownForParameters = (parameters: OpenAPIParameter[]) => {\n let markdown = '### Parameters\\n';\n\n for (const parameter of parameters) {\n markdown += `- **${parameter.name}** (${parameter.in})`;\n if (parameter.required) {\n markdown += ' (required)';\n }\n if (parameter.description) {\n markdown += `: ${parameter.description}`;\n }\n markdown += '\\n';\n }\n\n return markdown;\n};\n\nexport const markdownForResponses = (openAPIOperation: OpenAPIOperation) => {\n let markdown = '### Responses\\n';\n\n for (const [statusCode, content] of Object.entries(openAPIOperation.responses as any)) {\n if (content.isSchema) {\n markdown += `**${statusCode} Response**\n<SchemaViewer file=\"response-${statusCode}.json\" maxHeight=\"500\" id=\"response-${statusCode}\" />\n `;\n } else {\n markdown += `**${statusCode} Response**\n \\`\\`\\`json\n${JSON.stringify(content, null, 2)}\n\\`\\`\\`\n `;\n }\n }\n\n return markdown;\n};\n\nexport const defaultMarkdown = (message: Operation, openAPIOperation: OpenAPIOperation = {}) => {\n return `\n\n\n## Architecture\n<NodeGraph />\n\n${\n message.externalDocs\n ? `\n## External documentation\n- [${message.externalDocs.description}](${message.externalDocs.url})\n`\n : ''\n}\n\n## ${message.method.toUpperCase()} \\`(${message.path})\\`\n\n${openAPIOperation.parameters && openAPIOperation.parameters.length > 0 ? markdownForParameters(openAPIOperation.parameters) : ''}\n\n${\n openAPIOperation.requestBody\n ? `\n### Request Body\n<SchemaViewer file=\"request-body.json\" maxHeight=\"500\" id=\"request-body\" />\n`\n : ''\n}\n\n${markdownForResponses(openAPIOperation)}\n\n`;\n};\n\nexport const getSummary = (message: Operation) => {\n const messageSummary = message.summary ? message.summary : '';\n const messageDescription = message.description ? 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 buildMessage = async (pathToFile: string, document: OpenAPI.Document, operation: Operation) => {\n const requestBodiesAndResponses = await getSchemasByOperationId(pathToFile, operation.operationId);\n\n const operationTags = operation.tags.map((badge) => ({\n content: `tag:${badge}`,\n textColor: 'blue',\n backgroundColor: 'blue',\n }));\n\n const badges = [{ content: operation.method.toUpperCase(), textColor: 'blue', backgroundColor: 'blue' }, ...operationTags];\n\n const apiName = slugify(document.info.title, { lower: true });\n const path = operation.path.replace(/\\//, '').replace(/\\//g, '_');\n let uniqueIdentifier = operation.operationId || `${apiName}_${operation.method}`;\n\n if (!operation.operationId && path) {\n uniqueIdentifier = uniqueIdentifier.concat(`_${path}`);\n }\n\n return {\n id: uniqueIdentifier,\n version: document.info.version,\n name: uniqueIdentifier,\n summary: getSummary(operation),\n markdown: defaultMarkdown(operation, requestBodiesAndResponses),\n schemaPath: requestBodiesAndResponses?.requestBody ? 'request-body.json' : '',\n badges,\n requestBodiesAndResponses,\n };\n};\n","/**\n * TODO: Move this into the SDK\n */\n\nimport utils from '@eventcatalog/sdk';\n\nexport const getMessageTypeUtils = (projectDirectory: string, messageType: string) => {\n const {\n writeEvent,\n versionCommand,\n getEvent,\n getCommand,\n rmCommandById,\n rmEventById,\n writeCommand,\n addFileToCommand,\n addFileToEvent,\n versionEvent,\n } = utils(projectDirectory);\n\n if (messageType === 'event') {\n return {\n versionMessage: versionEvent,\n getMessage: getEvent,\n rmMessageById: rmEventById,\n writeMessage: writeEvent,\n addFileToMessage: addFileToEvent,\n };\n }\n\n // default command\n return {\n versionMessage: versionCommand,\n getMessage: getCommand,\n rmMessageById: rmCommandById,\n writeMessage: writeCommand,\n addFileToMessage: addFileToCommand,\n };\n};\n","import chalk from 'chalk';\n\nexport default () => {\n console.log(chalk.bgBlue(`\\nYou are using a free version of this plugin`));\n console.log(\n chalk.blueBright(\n `This plugin is governed and published under the AGPL-3.0 copy-left license. \\nIf using for commercial purposes 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;AAAA,IAAAA,cAAkB;AAClB,sBAAyB;AACzB,IAAAC,gBAAkB;AAClB,IAAAC,yBAA0B;;;ACHnB,IAAM,kBAAkB,MAAM;AACnC,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAMT;;;ACNA,qBAAoB;AAEb,IAAMC,mBAAkB,CAAC,UAA4B,aAAqB;AAC/E,SAAO;AAAA;AAAA,EAEP,SAAS,KAAK,cAAc,GAAG,SAAS,KAAK,WAAW,KAAK,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAMhD,QAAQ;AAAA;AAAA,EAGvB,SAAS,eACL;AAAA;AAAA,KAED,SAAS,aAAa,WAAW,KAAK,SAAS,aAAa,GAAG;AAAA,IAE9D,EACN;AAAA;AAAA;AAGA;AAEO,IAAM,aAAa,CAAC,aAA+B;AACxD,QAAM,UAAU,SAAS,KAAK,cAAc,SAAS,KAAK,cAAc;AACxE,SAAO,WAAW,QAAQ,SAAS,MAAM,UAAU;AACrD;AAEO,IAAM,eAAe,CAAC,YAAoB,aAA+B;AAC9E,QAAM,aAAa,WAAW,MAAM,GAAG,EAAE,IAAI,KAAK;AAClD,QAAM,eAAe,SAAS,QAAQ,CAAC;AACvC,SAAO;AAAA,IACL,QAAI,eAAAC,SAAQ,SAAS,KAAK,OAAO,EAAE,OAAO,MAAM,QAAQ,KAAK,CAAC;AAAA,IAC9D,SAAS,SAAS,KAAK;AAAA,IACvB,MAAM,SAAS,KAAK;AAAA,IACpB,SAAS,WAAW,QAA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,MACZ,SAAS,QAAQ;AAAA,IACnB,CAAC;AAGD,QAAI,2BAA2B,aAAa;AAC1C,YAAM;AAAA,QACJ,QAAQ;AAAA,QACR;AAAA,UACE,UAAU;AAAA,UACV,SAAS,KAAK,UAAU,0BAA0B,aAAa,MAAM,CAAC;AAAA,QACxE;AAAA,QACA,QAAQ;AAAA,MACV;AAAA,IACF;AAEA,QAAI,2BAA2B,WAAW;AACxC,iBAAW,CAAC,YAAY,MAAM,KAAK,OAAO,QAAQ,0BAA0B,SAAS,GAAG;AACtF,cAAM;AAAA,UACJ,QAAQ;AAAA,UACR;AAAA,YACE,UAAU,YAAY,UAAU;AAAA,YAChC,SAAS,KAAK,UAAU,QAAQ,MAAM,CAAC;AAAA,UACzC;AAAA,UACA,QAAQ;AAAA,QACV;AAAA,MACF;AAAA,IACF;AAEA,YAAQ,IAAI,cAAAA,QAAM,KAAK,gBAAgB,OAAO,WAAW,CAAC;AAC1D,QAAI,CAAC,UAAU,aAAa;AAC1B,cAAQ,IAAI,cAAAA,QAAM,OAAO,iCAAiC,UAAU,MAAM,IAAI,UAAU,IAAI,mBAAmB,CAAC;AAChH,cAAQ,IAAI,cAAAA,QAAM,OAAO,mEAAmE,CAAC;AAAA,IAC/F;AAAA,EACF;AACA,SAAO,EAAE,UAAU,OAAO,CAAC,EAAE;AAC/B;","names":["import_sdk","import_chalk","import_swagger_parser","defaultMarkdown","slugify","SwaggerParser","import_slugify","defaultMarkdown","getSummary","slugify","utils","chalk","utils","chalk","SwaggerParser"]}
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  // src/index.ts
2
2
  import utils2 from "@eventcatalog/sdk";
3
3
  import { readFile } from "node:fs/promises";
4
- import chalk from "chalk";
4
+ import chalk2 from "chalk";
5
5
  import SwaggerParser2 from "@apidevtools/swagger-parser";
6
6
 
7
7
  // src/utils/domains.ts
@@ -123,6 +123,7 @@ async function getOperationsByType(openApiPath) {
123
123
  }
124
124
 
125
125
  // src/utils/messages.ts
126
+ import slugify2 from "slugify";
126
127
  var markdownForParameters = (parameters) => {
127
128
  let markdown = "### Parameters\n";
128
129
  for (const parameter of parameters) {
@@ -196,10 +197,16 @@ var buildMessage = async (pathToFile, document, operation) => {
196
197
  backgroundColor: "blue"
197
198
  }));
198
199
  const badges = [{ content: operation.method.toUpperCase(), textColor: "blue", backgroundColor: "blue" }, ...operationTags];
200
+ const apiName = slugify2(document.info.title, { lower: true });
201
+ const path = operation.path.replace(/\//, "").replace(/\//g, "_");
202
+ let uniqueIdentifier = operation.operationId || `${apiName}_${operation.method}`;
203
+ if (!operation.operationId && path) {
204
+ uniqueIdentifier = uniqueIdentifier.concat(`_${path}`);
205
+ }
199
206
  return {
200
- id: operation.operationId,
207
+ id: uniqueIdentifier,
201
208
  version: document.info.version,
202
- name: operation.operationId,
209
+ name: uniqueIdentifier,
203
210
  summary: getSummary2(operation),
204
211
  markdown: defaultMarkdown3(operation, requestBodiesAndResponses),
205
212
  schemaPath: requestBodiesAndResponses?.requestBody ? "request-body.json" : "",
@@ -241,6 +248,19 @@ var getMessageTypeUtils = (projectDirectory, messageType) => {
241
248
  };
242
249
  };
243
250
 
251
+ // src/utils/checkLicense.ts
252
+ import chalk from "chalk";
253
+ var checkLicense_default = () => {
254
+ console.log(chalk.bgBlue(`
255
+ You are using a free version of this plugin`));
256
+ console.log(
257
+ chalk.blueBright(
258
+ `This plugin is governed and published under the AGPL-3.0 copy-left license.
259
+ If using for commercial purposes or proprietary software, please contact hello@eventcatalog.dev for a license to support the project.`
260
+ )
261
+ );
262
+ };
263
+
244
264
  // src/index.ts
245
265
  var src_default = async (_, options) => {
246
266
  if (!process.env.PROJECT_DIR) {
@@ -259,12 +279,12 @@ var src_default = async (_, options) => {
259
279
  } = utils2(process.env.PROJECT_DIR);
260
280
  const openAPIFiles = Array.isArray(options.path) ? options.path : [options.path];
261
281
  for (const path of openAPIFiles) {
262
- console.log(chalk.green(`Processing ${path}`));
282
+ console.log(chalk2.green(`Processing ${path}`));
263
283
  try {
264
284
  await SwaggerParser2.validate(path);
265
285
  } catch (error) {
266
- console.error(chalk.red(`Failed to parse OpenAPI file: ${path}`));
267
- console.error(chalk.red(error));
286
+ console.error(chalk2.red(`Failed to parse OpenAPI file: ${path}`));
287
+ console.error(chalk2.red(error));
268
288
  continue;
269
289
  }
270
290
  const openAPIFile = await readFile(path, "utf-8");
@@ -276,11 +296,11 @@ var src_default = async (_, options) => {
276
296
  const { id: domainId, name: domainName, version: domainVersion } = options.domain;
277
297
  const domain = await getDomain(options.domain.id, domainVersion || "latest");
278
298
  const currentDomain = await getDomain(options.domain.id, "latest");
279
- console.log(chalk.blue(`
299
+ console.log(chalk2.blue(`
280
300
  Processing domain: ${domainName} (v${domainVersion})`));
281
301
  if (currentDomain && currentDomain.version !== domainVersion) {
282
302
  await versionDomain(domainId);
283
- console.log(chalk.cyan(` - Versioned previous domain (v${currentDomain.version})`));
303
+ console.log(chalk2.cyan(` - Versioned previous domain (v${currentDomain.version})`));
284
304
  }
285
305
  if (!domain || domain && domain.version !== domainVersion) {
286
306
  await writeDomain({
@@ -289,22 +309,22 @@ Processing domain: ${domainName} (v${domainVersion})`));
289
309
  version: domainVersion,
290
310
  markdown: defaultMarkdown()
291
311
  });
292
- console.log(chalk.cyan(` - Domain (v${domainVersion}) created`));
312
+ console.log(chalk2.cyan(` - Domain (v${domainVersion}) created`));
293
313
  }
294
314
  if (currentDomain && currentDomain.version === domainVersion) {
295
- console.log(chalk.yellow(` - Domain (v${domainVersion}) already exists, skipped creation...`));
315
+ console.log(chalk2.yellow(` - Domain (v${domainVersion}) already exists, skipped creation...`));
296
316
  }
297
317
  await addServiceToDomain(domainId, { id: service.id, version: service.version }, domainVersion);
298
318
  }
299
319
  let { sends, receives } = await processMessagesForOpenAPISpec(path, document);
300
320
  const latestServiceInCatalog = await getService(service.id, "latest");
301
- console.log(chalk.blue(`Processing service: ${document.info.title} (v${version})`));
321
+ console.log(chalk2.blue(`Processing service: ${document.info.title} (v${version})`));
302
322
  if (latestServiceInCatalog) {
303
323
  serviceMarkdown = latestServiceInCatalog.markdown;
304
324
  sends = latestServiceInCatalog.sends || [];
305
325
  if (latestServiceInCatalog.version !== version) {
306
326
  await versionService(service.id);
307
- console.log(chalk.cyan(` - Versioned previous service (v${latestServiceInCatalog.version})`));
327
+ console.log(chalk2.cyan(` - Versioned previous service (v${latestServiceInCatalog.version})`));
308
328
  }
309
329
  if (latestServiceInCatalog.version === version) {
310
330
  await rmService(service.name);
@@ -327,14 +347,9 @@ Processing domain: ${domainName} (v${domainVersion})`));
327
347
  },
328
348
  version
329
349
  );
330
- console.log(chalk.cyan(` - Service (v${version}) created`));
331
- console.log(chalk.green(`
332
- Finished generating event catalog for OpenAPI ${service.name} (v${version})`));
333
- console.log(chalk.bgBlue(`
334
- You are using a free version of this plugin`));
335
- console.log(chalk.blueBright(`This plugin is governed and published under the AGPL-3.0 copy-left license.
336
- If using for commercial purposes or proprietary software, please contact hello@eventcatalog.dev for a license to support the project.`));
350
+ console.log(chalk2.cyan(` - Service (v${version}) created`));
337
351
  }
352
+ await checkLicense_default();
338
353
  };
339
354
  var processMessagesForOpenAPISpec = async (pathToSpec, document) => {
340
355
  const operations = await getOperationsByType(pathToSpec);
@@ -344,7 +359,7 @@ var processMessagesForOpenAPISpec = async (pathToSpec, document) => {
344
359
  const { requestBodiesAndResponses, ...message } = await buildMessage(pathToSpec, document, operation);
345
360
  let messageMarkdown = message.markdown;
346
361
  const messageType = operation.type;
347
- console.log(chalk.blue(`Processing message: ${message.name} (v${version})`));
362
+ console.log(chalk2.blue(`Processing message: ${message.name} (v${version})`));
348
363
  const { addFileToMessage, writeMessage, rmMessageById, getMessage, versionMessage } = getMessageTypeUtils(
349
364
  process.env.PROJECT_DIR,
350
365
  messageType
@@ -356,12 +371,12 @@ var processMessagesForOpenAPISpec = async (pathToSpec, document) => {
356
371
  await rmMessageById(message.id, version);
357
372
  } else {
358
373
  await versionMessage(message.id);
359
- console.log(chalk.cyan(` - Versioned previous message: (v${catalogedMessage.version})`));
374
+ console.log(chalk2.cyan(` - Versioned previous message: (v${catalogedMessage.version})`));
360
375
  }
361
376
  }
362
377
  await writeMessage({ ...message, markdown: messageMarkdown }, { path: message.name });
363
378
  receives.push({
364
- id: operation.operationId,
379
+ id: message.id,
365
380
  version: message.version
366
381
  });
367
382
  if (requestBodiesAndResponses?.requestBody) {
@@ -386,7 +401,11 @@ var processMessagesForOpenAPISpec = async (pathToSpec, document) => {
386
401
  );
387
402
  }
388
403
  }
389
- console.log(chalk.cyan(` - Message (v${version}) created`));
404
+ console.log(chalk2.cyan(` - Message (v${version}) created`));
405
+ if (!operation.operationId) {
406
+ console.log(chalk2.yellow(` - OperationId not found for ${operation.method} ${operation.path}, creating one...`));
407
+ console.log(chalk2.yellow(` - Use operationIds to give better unique names for EventCatalog`));
408
+ }
390
409
  }
391
410
  return { receives, sends: [] };
392
411
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/utils/domains.ts","../src/utils/services.ts","../src/utils/openapi.ts","../src/utils/messages.ts","../src/utils/catalog-shorthand.ts"],"sourcesContent":["import utils from '@eventcatalog/sdk';\nimport { readFile } from 'node:fs/promises';\nimport chalk from 'chalk';\nimport SwaggerParser from '@apidevtools/swagger-parser';\n\nimport { defaultMarkdown as generateMarkdownForDomain } from './utils/domains';\nimport { buildService } from './utils/services';\nimport { buildMessage } from './utils/messages';\nimport { getOperationsByType } from './utils/openapi';\nimport { Domain } from './types';\nimport { getMessageTypeUtils } from './utils/catalog-shorthand';\nimport { OpenAPI } from 'openapi-types';\n\ntype Props = {\n path: string | string[];\n domain?: Domain;\n debug?: boolean;\n};\n\nexport default async (_: 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 getDomain,\n versionDomain,\n writeDomain,\n addServiceToDomain,\n getService,\n versionService,\n rmService,\n writeService,\n addFileToService,\n } = utils(process.env.PROJECT_DIR);\n\n const openAPIFiles = Array.isArray(options.path) ? options.path : [options.path];\n\n for (const path of openAPIFiles) {\n console.log(chalk.green(`Processing ${path}`));\n\n try {\n await SwaggerParser.validate(path);\n } catch (error) {\n console.error(chalk.red(`Failed to parse OpenAPI file: ${path}`));\n console.error(chalk.red(error));\n continue;\n }\n\n const openAPIFile = await readFile(path, 'utf-8');\n const document = await SwaggerParser.parse(path);\n const version = document.info.version;\n\n const service = buildService(path, document);\n let serviceMarkdown = service.markdown;\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(),\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: service.id, version: service.version }, domainVersion);\n }\n\n // Process all messages for the OpenAPI spec\n let { sends, receives } = await processMessagesForOpenAPISpec(path, document);\n\n // Check if service is already defined... if the versions do not match then create service.\n const latestServiceInCatalog = await getService(service.id, 'latest');\n console.log(chalk.blue(`Processing service: ${document.info.title} (v${version})`));\n\n if (latestServiceInCatalog) {\n serviceMarkdown = latestServiceInCatalog.markdown;\n sends = latestServiceInCatalog.sends || ([] as any);\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(service.id);\n console.log(chalk.cyan(` - Versioned previous service (v${latestServiceInCatalog.version})`));\n }\n\n // Match found, override it\n if (latestServiceInCatalog.version === version) {\n await rmService(service.name);\n }\n }\n\n await writeService(\n {\n ...service,\n markdown: serviceMarkdown,\n sends,\n receives,\n },\n { path: service.name }\n );\n\n await addFileToService(\n service.id,\n {\n fileName: service.schemaPath,\n content: openAPIFile,\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 OpenAPI ${service.name} (v${version})`));\n\n console.log(chalk.bgBlue(`\\nYou are using a free version of this plugin`));\n console.log(chalk.blueBright(`This plugin is governed and published under the AGPL-3.0 copy-left license. \\nIf using for commercial purposes or proprietary software, please contact hello@eventcatalog.dev for a license to support the project.`));\n }\n};\n\nconst processMessagesForOpenAPISpec = async (pathToSpec: string, document: OpenAPI.Document) => {\n const operations = await getOperationsByType(pathToSpec);\n const version = document.info.version;\n let receives = [];\n\n // Go through all messages\n for (const operation of operations) {\n\n const { requestBodiesAndResponses, ...message } = await buildMessage(pathToSpec, document, operation);\n let messageMarkdown = message.markdown;\n const messageType = operation.type;\n\n console.log(chalk.blue(`Processing message: ${message.name} (v${version})`));\n\n const { addFileToMessage, writeMessage, rmMessageById, getMessage, versionMessage } = getMessageTypeUtils(\n process.env.PROJECT_DIR as string,\n messageType\n );\n\n // Check if the message already exists in the catalog\n const catalogedMessage = await getMessage(message.id, '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(message.id, version);\n } else {\n // if the version does not match, we need to version the message\n await versionMessage(message.id);\n console.log(chalk.cyan(` - Versioned previous message: (v${catalogedMessage.version})`));\n }\n }\n\n // Write the message to the catalog\n await writeMessage({...message, markdown: messageMarkdown}, { path: message.name });\n\n // messages will always be messages the service receives\n receives.push({\n id: operation.operationId,\n version: message.version,\n });\n\n // Does the message have a request body or responses?\n if (requestBodiesAndResponses?.requestBody) {\n await addFileToMessage(\n message.id,\n {\n fileName: 'request-body.json',\n content: JSON.stringify(requestBodiesAndResponses.requestBody, null, 2),\n },\n message.version\n );\n }\n\n if (requestBodiesAndResponses?.responses) {\n for (const [statusCode, schema] of Object.entries(requestBodiesAndResponses.responses)) {\n await addFileToMessage(\n message.id,\n {\n fileName: `response-${statusCode}.json`,\n content: JSON.stringify(schema, null, 2),\n },\n message.version\n );\n }\n }\n\n console.log(chalk.cyan(` - Message (v${version}) created`));\n }\n return { receives, sends: [] };\n};\n","export const defaultMarkdown = () => {\n return `\n\n## Architecture diagram\n<NodeGraph />\n\n`;\n};\n","import { OpenAPI } from 'openapi-types';\nimport slugify from 'slugify';\n\nexport const defaultMarkdown = (document: OpenAPI.Document, fileName: string) => {\n return `\n\n${document.info.description ? `${document.info.description}` : ''} \n\n## Architecture diagram\n<NodeGraph />\n\n## OpenAPI Specification\n<OpenAPI file=\"${fileName}\"/>\n\n${\n document.externalDocs\n ? `\n## External documentation\n- [${document.externalDocs.description}](${document.externalDocs.url})\n`\n : ''\n}\n\n`;\n};\n\nexport const getSummary = (document: OpenAPI.Document) => {\n const summary = document.info.description ? document.info.description : '';\n return summary && summary.length < 150 ? summary : '';\n};\n\n\nexport const buildService = (pathToFile:string, document: OpenAPI.Document) => {\n const schemaPath = pathToFile.split('/').pop() || 'openapi.yml';\n const documentTags = document.tags || [];\n return {\n id: slugify(document.info.title, { lower: true, strict: true }),\n version: document.info.version,\n name: document.info.title,\n summary: getSummary(document),\n schemaPath,\n markdown: defaultMarkdown(document, schemaPath),\n badges: documentTags.map((tag) => ({ content: tag.name, textColor: 'blue', backgroundColor: 'blue' }))\n }\n};","import SwaggerParser from '@apidevtools/swagger-parser';\nimport { OpenAPIDocument, OpenAPIOperation, OpenAPIParameter, Operation } from '../types';\nimport { OpenAPIV3_1 } from \"openapi-types\";\n\nconst DEFAULT_MESSAGE_TYPE = 'query';\n\nexport async function getSchemasByOperationId(filePath: string, operationId: string): Promise<OpenAPIOperation | undefined> {\n try {\n // Parse and resolve all references in the OpenAPI document\n const api = (await SwaggerParser.dereference(filePath)) as OpenAPIDocument;\n const schemas: {\n parameters: OpenAPIParameter[];\n requestBody: any;\n responses: { [statusCode: string]: any };\n } = {\n parameters: [],\n requestBody: null,\n responses: {},\n };\n\n // Iterate through paths and operations\n for (const [path, pathItem] of Object.entries(api.paths)) {\n for (const [method, operation] of Object.entries(pathItem)) {\n // Cast operation to OpenAPIOperation type\n const typedOperation = operation as OpenAPIOperation;\n\n if (typedOperation.operationId === operationId) {\n // Extract query parameters\n if (typedOperation.parameters) {\n schemas.parameters = typedOperation.parameters;\n }\n\n // Extract request body schema\n if (typedOperation.requestBody && typedOperation.requestBody.content) {\n const contentType = Object.keys(typedOperation.requestBody.content)[0];\n schemas.requestBody = typedOperation.requestBody.content[contentType].schema;\n }\n\n // Extract response schemas\n if (typedOperation.responses) {\n for (const [statusCode, response] of Object.entries(typedOperation.responses)) {\n if (response.content) {\n const contentType = Object.keys(response.content)[0];\n schemas.responses[statusCode] = response.content[contentType].schema || response.content[contentType];\n schemas.responses[statusCode].isSchema = !!response.content[contentType].schema;\n }\n }\n }\n\n return schemas;\n }\n }\n }\n\n throw new Error(`Operation with ID \"${operationId}\" not found.`);\n } catch (error) {\n console.error('Error parsing OpenAPI file or finding operation:', error);\n return;\n }\n}\n\nexport async function getOperationsByType(openApiPath: string) {\n try {\n // Parse the OpenAPI document\n const api = await SwaggerParser.validate(openApiPath);\n\n const operations = [];\n\n // Iterate through paths\n for (const path in api.paths) {\n const pathItem = api.paths[path];\n\n // Iterate through each HTTP method in the path\n for (const method in pathItem) {\n // @ts-ignore\n const openAPIOperation = pathItem[method];\n\n // Check if the x-eventcatalog-message-type field is set\n const messageType = openAPIOperation['x-eventcatalog-message-type'] || DEFAULT_MESSAGE_TYPE;\n\n const operation = {\n path: path,\n method: method.toUpperCase(),\n operationId: openAPIOperation.operationId,\n externalDocs: openAPIOperation.externalDocs,\n type: messageType,\n description: openAPIOperation.description,\n summary: openAPIOperation.summary,\n tags: openAPIOperation.tags || [],\n } as Operation;\n\n operations.push(operation);\n }\n }\n\n return operations;\n } catch (err) {\n console.error('Error parsing OpenAPI document:', err);\n return [];\n }\n}\n","import { OpenAPI } from 'openapi-types';\nimport { getSchemasByOperationId } from './openapi';\nimport { OpenAPIOperation, OpenAPIParameter, Operation } from '../types';\n\nconst markdownForParameters = (parameters: OpenAPIParameter[]) => {\n let markdown = '### Parameters\\n';\n\n for (const parameter of parameters) {\n markdown += `- **${parameter.name}** (${parameter.in})`;\n if (parameter.required) {\n markdown += ' (required)';\n }\n if (parameter.description) {\n markdown += `: ${parameter.description}`;\n }\n markdown += '\\n';\n }\n\n return markdown;\n};\n\nexport const markdownForResponses = (openAPIOperation: OpenAPIOperation) => {\n let markdown = '### Responses\\n';\n\n for (const [statusCode, content] of Object.entries(openAPIOperation.responses as any)) {\n if (content.isSchema) {\n markdown += `**${statusCode} Response**\n<SchemaViewer file=\"response-${statusCode}.json\" maxHeight=\"500\" id=\"response-${statusCode}\" />\n `;\n } else {\n markdown += `**${statusCode} Response**\n \\`\\`\\`json\n${JSON.stringify(content, null, 2)}\n\\`\\`\\`\n `;\n }\n }\n\n return markdown;\n};\n\nexport const defaultMarkdown = (message: Operation, openAPIOperation: OpenAPIOperation = {}) => {\n return `\n\n\n## Architecture\n<NodeGraph />\n\n${\n message.externalDocs\n ? `\n## External documentation\n- [${message.externalDocs.description}](${message.externalDocs.url})\n`\n : ''\n}\n\n## ${message.method.toUpperCase()} \\`(${message.path})\\`\n\n${openAPIOperation.parameters && openAPIOperation.parameters.length > 0 ? markdownForParameters(openAPIOperation.parameters) : ''}\n\n${\n openAPIOperation.requestBody\n ? `\n### Request Body\n<SchemaViewer file=\"request-body.json\" maxHeight=\"500\" id=\"request-body\" />\n`\n : ''\n}\n\n${markdownForResponses(openAPIOperation)}\n\n`;\n};\n\nexport const getSummary = (message: Operation) => {\n const messageSummary = message.summary ? message.summary : '';\n const messageDescription = message.description ? 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 buildMessage = async (pathToFile: string, document: OpenAPI.Document, operation: Operation) => {\n\n const requestBodiesAndResponses = await getSchemasByOperationId(pathToFile, operation.operationId);\n\n const operationTags = operation.tags.map((badge) => ({\n content: `tag:${badge}`,\n textColor: 'blue',\n backgroundColor: 'blue',\n }));\n\n const badges = [{ content: operation.method.toUpperCase(), textColor: 'blue', backgroundColor: 'blue' }, ...operationTags];\n\n return {\n id: operation.operationId,\n version: document.info.version,\n name: operation.operationId,\n summary: getSummary(operation),\n markdown: defaultMarkdown(operation, requestBodiesAndResponses),\n schemaPath: requestBodiesAndResponses?.requestBody ? 'request-body.json' : '',\n badges,\n requestBodiesAndResponses\n };\n};","/**\n * TODO: Move this into the SDK\n */\n\nimport utils from '@eventcatalog/sdk';\n\nexport const getMessageTypeUtils = (projectDirectory: string, messageType: string) => {\n const {\n writeEvent,\n versionCommand,\n getEvent,\n getCommand,\n rmCommandById,\n rmEventById,\n writeCommand,\n addFileToCommand,\n addFileToEvent,\n versionEvent,\n } = utils(projectDirectory);\n\n if (messageType === 'event') {\n return {\n versionMessage: versionEvent,\n getMessage: getEvent,\n rmMessageById: rmEventById,\n writeMessage: writeEvent,\n addFileToMessage: addFileToEvent,\n };\n }\n\n // default command\n return {\n versionMessage: versionCommand,\n getMessage: getCommand,\n rmMessageById: rmCommandById,\n writeMessage: writeCommand,\n addFileToMessage: addFileToCommand,\n };\n \n};\n"],"mappings":";AAAA,OAAOA,YAAW;AAClB,SAAS,gBAAgB;AACzB,OAAO,WAAW;AAClB,OAAOC,oBAAmB;;;ACHnB,IAAM,kBAAkB,MAAM;AACnC,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAMT;;;ACNA,OAAO,aAAa;AAEb,IAAMC,mB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AA,MACzC,OAAO;AAEL,cAAM,eAAe,QAAQ,EAAE;AAC/B,gBAAQ,IAAI,MAAM,KAAK,oCAAoC,iBAAiB,OAAO,GAAG,CAAC;AAAA,MACzF;AAAA,IACF;AAGA,UAAM,aAAa,EAAC,GAAG,SAAS,UAAU,gBAAe,GAAG,EAAE,MAAM,QAAQ,KAAK,CAAC;AAGlF,aAAS,KAAK;AAAA,MACZ,IAAI,UAAU;AAAA,MACd,SAAS,QAAQ;AAAA,IACnB,CAAC;AAGD,QAAI,2BAA2B,aAAa;AAC1C,YAAM;AAAA,QACJ,QAAQ;AAAA,QACR;AAAA,UACE,UAAU;AAAA,UACV,SAAS,KAAK,UAAU,0BAA0B,aAAa,MAAM,CAAC;AAAA,QACxE;AAAA,QACA,QAAQ;AAAA,MACV;AAAA,IACF;AAEA,QAAI,2BAA2B,WAAW;AACxC,iBAAW,CAAC,YAAY,MAAM,KAAK,OAAO,QAAQ,0BAA0B,SAAS,GAAG;AACtF,cAAM;AAAA,UACJ,QAAQ;AAAA,UACR;AAAA,YACE,UAAU,YAAY,UAAU;AAAA,YAChC,SAAS,KAAK,UAAU,QAAQ,MAAM,CAAC;AAAA,UACzC;AAAA,UACA,QAAQ;AAAA,QACV;AAAA,MACF;AAAA,IACF;AAEA,YAAQ,IAAI,MAAM,KAAK,gBAAgB,OAAO,WAAW,CAAC;AAAA,EAC5D;AACA,SAAO,EAAE,UAAU,OAAO,CAAC,EAAE;AAC/B;","names":["utils","SwaggerParser","defaultMarkdown","defaultMarkdown","getSummary","utils","SwaggerParser"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/utils/domains.ts","../src/utils/services.ts","../src/utils/openapi.ts","../src/utils/messages.ts","../src/utils/catalog-shorthand.ts","../src/utils/checkLicense.ts"],"sourcesContent":["import utils from '@eventcatalog/sdk';\nimport { readFile } from 'node:fs/promises';\nimport chalk from 'chalk';\nimport SwaggerParser from '@apidevtools/swagger-parser';\n\nimport { defaultMarkdown as generateMarkdownForDomain } from './utils/domains';\nimport { buildService } from './utils/services';\nimport { buildMessage } from './utils/messages';\nimport { getOperationsByType } from './utils/openapi';\nimport { Domain } from './types';\nimport { getMessageTypeUtils } from './utils/catalog-shorthand';\nimport { OpenAPI } from 'openapi-types';\nimport checkLicense from './utils/checkLicense';\n\ntype Props = {\n path: string | string[];\n domain?: Domain;\n debug?: boolean;\n};\n\nexport default async (_: 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 getDomain,\n versionDomain,\n writeDomain,\n addServiceToDomain,\n getService,\n versionService,\n rmService,\n writeService,\n addFileToService,\n } = utils(process.env.PROJECT_DIR);\n\n const openAPIFiles = Array.isArray(options.path) ? options.path : [options.path];\n\n for (const path of openAPIFiles) {\n console.log(chalk.green(`Processing ${path}`));\n\n try {\n await SwaggerParser.validate(path);\n } catch (error) {\n console.error(chalk.red(`Failed to parse OpenAPI file: ${path}`));\n console.error(chalk.red(error));\n continue;\n }\n\n const openAPIFile = await readFile(path, 'utf-8');\n const document = await SwaggerParser.parse(path);\n const version = document.info.version;\n\n const service = buildService(path, document);\n let serviceMarkdown = service.markdown;\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(),\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: service.id, version: service.version }, domainVersion);\n }\n\n // Process all messages for the OpenAPI spec\n let { sends, receives } = await processMessagesForOpenAPISpec(path, document);\n\n // Check if service is already defined... if the versions do not match then create service.\n const latestServiceInCatalog = await getService(service.id, 'latest');\n console.log(chalk.blue(`Processing service: ${document.info.title} (v${version})`));\n\n if (latestServiceInCatalog) {\n serviceMarkdown = latestServiceInCatalog.markdown;\n sends = latestServiceInCatalog.sends || ([] as any);\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(service.id);\n console.log(chalk.cyan(` - Versioned previous service (v${latestServiceInCatalog.version})`));\n }\n\n // Match found, override it\n if (latestServiceInCatalog.version === version) {\n await rmService(service.name);\n }\n }\n\n await writeService(\n {\n ...service,\n markdown: serviceMarkdown,\n sends,\n receives,\n },\n { path: service.name }\n );\n\n await addFileToService(\n service.id,\n {\n fileName: service.schemaPath,\n content: openAPIFile,\n },\n version\n );\n\n console.log(chalk.cyan(` - Service (v${version}) created`));\n }\n\n await checkLicense();\n};\n\nconst processMessagesForOpenAPISpec = async (pathToSpec: string, document: OpenAPI.Document) => {\n const operations = await getOperationsByType(pathToSpec);\n const version = document.info.version;\n let receives = [];\n\n // Go through all messages\n for (const operation of operations) {\n const { requestBodiesAndResponses, ...message } = await buildMessage(pathToSpec, document, operation);\n let messageMarkdown = message.markdown;\n const messageType = operation.type;\n\n console.log(chalk.blue(`Processing message: ${message.name} (v${version})`));\n\n const { addFileToMessage, writeMessage, rmMessageById, getMessage, versionMessage } = getMessageTypeUtils(\n process.env.PROJECT_DIR as string,\n messageType\n );\n\n // Check if the message already exists in the catalog\n const catalogedMessage = await getMessage(message.id, '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(message.id, version);\n } else {\n // if the version does not match, we need to version the message\n await versionMessage(message.id);\n console.log(chalk.cyan(` - Versioned previous message: (v${catalogedMessage.version})`));\n }\n }\n\n // Write the message to the catalog\n await writeMessage({ ...message, markdown: messageMarkdown }, { path: message.name });\n\n // messages will always be messages the service receives\n receives.push({\n id: message.id,\n version: message.version,\n });\n\n // Does the message have a request body or responses?\n if (requestBodiesAndResponses?.requestBody) {\n await addFileToMessage(\n message.id,\n {\n fileName: 'request-body.json',\n content: JSON.stringify(requestBodiesAndResponses.requestBody, null, 2),\n },\n message.version\n );\n }\n\n if (requestBodiesAndResponses?.responses) {\n for (const [statusCode, schema] of Object.entries(requestBodiesAndResponses.responses)) {\n await addFileToMessage(\n message.id,\n {\n fileName: `response-${statusCode}.json`,\n content: JSON.stringify(schema, null, 2),\n },\n message.version\n );\n }\n }\n\n console.log(chalk.cyan(` - Message (v${version}) created`));\n if (!operation.operationId) {\n console.log(chalk.yellow(` - OperationId not found for ${operation.method} ${operation.path}, creating one...`));\n console.log(chalk.yellow(` - Use operationIds to give better unique names for EventCatalog`));\n }\n }\n return { receives, sends: [] };\n};\n","export const defaultMarkdown = () => {\n return `\n\n## Architecture diagram\n<NodeGraph />\n\n`;\n};\n","import { OpenAPI } from 'openapi-types';\nimport slugify from 'slugify';\n\nexport const defaultMarkdown = (document: OpenAPI.Document, fileName: string) => {\n return `\n\n${document.info.description ? `${document.info.description}` : ''} \n\n## Architecture diagram\n<NodeGraph />\n\n## OpenAPI Specification\n<OpenAPI file=\"${fileName}\"/>\n\n${\n document.externalDocs\n ? `\n## External documentation\n- [${document.externalDocs.description}](${document.externalDocs.url})\n`\n : ''\n}\n\n`;\n};\n\nexport const getSummary = (document: OpenAPI.Document) => {\n const summary = document.info.description ? document.info.description : '';\n return summary && summary.length < 150 ? summary : '';\n};\n\nexport const buildService = (pathToFile: string, document: OpenAPI.Document) => {\n const schemaPath = pathToFile.split('/').pop() || 'openapi.yml';\n const documentTags = document.tags || [];\n return {\n id: slugify(document.info.title, { lower: true, strict: true }),\n version: document.info.version,\n name: document.info.title,\n summary: getSummary(document),\n schemaPath,\n markdown: defaultMarkdown(document, schemaPath),\n badges: documentTags.map((tag) => ({ content: tag.name, textColor: 'blue', backgroundColor: 'blue' })),\n };\n};\n","import SwaggerParser from '@apidevtools/swagger-parser';\nimport { OpenAPIDocument, OpenAPIOperation, OpenAPIParameter, Operation } from '../types';\n\nconst DEFAULT_MESSAGE_TYPE = 'query';\n\nexport async function getSchemasByOperationId(filePath: string, operationId: string): Promise<OpenAPIOperation | undefined> {\n try {\n // Parse and resolve all references in the OpenAPI document\n const api = (await SwaggerParser.dereference(filePath)) as OpenAPIDocument;\n const schemas: {\n parameters: OpenAPIParameter[];\n requestBody: any;\n responses: { [statusCode: string]: any };\n } = {\n parameters: [],\n requestBody: null,\n responses: {},\n };\n\n // Iterate through paths and operations\n for (const [path, pathItem] of Object.entries(api.paths)) {\n for (const [method, operation] of Object.entries(pathItem)) {\n // Cast operation to OpenAPIOperation type\n const typedOperation = operation as OpenAPIOperation;\n\n if (typedOperation.operationId === operationId) {\n // Extract query parameters\n if (typedOperation.parameters) {\n schemas.parameters = typedOperation.parameters;\n }\n\n // Extract request body schema\n if (typedOperation.requestBody && typedOperation.requestBody.content) {\n const contentType = Object.keys(typedOperation.requestBody.content)[0];\n schemas.requestBody = typedOperation.requestBody.content[contentType].schema;\n }\n\n // Extract response schemas\n if (typedOperation.responses) {\n for (const [statusCode, response] of Object.entries(typedOperation.responses)) {\n if (response.content) {\n const contentType = Object.keys(response.content)[0];\n schemas.responses[statusCode] = response.content[contentType].schema || response.content[contentType];\n schemas.responses[statusCode].isSchema = !!response.content[contentType].schema;\n }\n }\n }\n\n return schemas;\n }\n }\n }\n\n throw new Error(`Operation with ID \"${operationId}\" not found.`);\n } catch (error) {\n console.error('Error parsing OpenAPI file or finding operation:', error);\n return;\n }\n}\n\nexport async function getOperationsByType(openApiPath: string) {\n try {\n // Parse the OpenAPI document\n const api = await SwaggerParser.validate(openApiPath);\n\n const operations = [];\n\n // Iterate through paths\n for (const path in api.paths) {\n const pathItem = api.paths[path];\n\n // Iterate through each HTTP method in the path\n for (const method in pathItem) {\n // @ts-ignore\n const openAPIOperation = pathItem[method];\n\n // Check if the x-eventcatalog-message-type field is set\n const messageType = openAPIOperation['x-eventcatalog-message-type'] || DEFAULT_MESSAGE_TYPE;\n\n const operation = {\n path: path,\n method: method.toUpperCase(),\n operationId: openAPIOperation.operationId,\n externalDocs: openAPIOperation.externalDocs,\n type: messageType,\n description: openAPIOperation.description,\n summary: openAPIOperation.summary,\n tags: openAPIOperation.tags || [],\n } as Operation;\n\n operations.push(operation);\n }\n }\n\n return operations;\n } catch (err) {\n console.error('Error parsing OpenAPI document:', err);\n return [];\n }\n}\n","import { OpenAPI } from 'openapi-types';\nimport { getSchemasByOperationId } from './openapi';\nimport { OpenAPIOperation, OpenAPIParameter, Operation } from '../types';\nimport slugify from 'slugify';\n\nconst markdownForParameters = (parameters: OpenAPIParameter[]) => {\n let markdown = '### Parameters\\n';\n\n for (const parameter of parameters) {\n markdown += `- **${parameter.name}** (${parameter.in})`;\n if (parameter.required) {\n markdown += ' (required)';\n }\n if (parameter.description) {\n markdown += `: ${parameter.description}`;\n }\n markdown += '\\n';\n }\n\n return markdown;\n};\n\nexport const markdownForResponses = (openAPIOperation: OpenAPIOperation) => {\n let markdown = '### Responses\\n';\n\n for (const [statusCode, content] of Object.entries(openAPIOperation.responses as any)) {\n if (content.isSchema) {\n markdown += `**${statusCode} Response**\n<SchemaViewer file=\"response-${statusCode}.json\" maxHeight=\"500\" id=\"response-${statusCode}\" />\n `;\n } else {\n markdown += `**${statusCode} Response**\n \\`\\`\\`json\n${JSON.stringify(content, null, 2)}\n\\`\\`\\`\n `;\n }\n }\n\n return markdown;\n};\n\nexport const defaultMarkdown = (message: Operation, openAPIOperation: OpenAPIOperation = {}) => {\n return `\n\n\n## Architecture\n<NodeGraph />\n\n${\n message.externalDocs\n ? `\n## External documentation\n- [${message.externalDocs.description}](${message.externalDocs.url})\n`\n : ''\n}\n\n## ${message.method.toUpperCase()} \\`(${message.path})\\`\n\n${openAPIOperation.parameters && openAPIOperation.parameters.length > 0 ? markdownForParameters(openAPIOperation.parameters) : ''}\n\n${\n openAPIOperation.requestBody\n ? `\n### Request Body\n<SchemaViewer file=\"request-body.json\" maxHeight=\"500\" id=\"request-body\" />\n`\n : ''\n}\n\n${markdownForResponses(openAPIOperation)}\n\n`;\n};\n\nexport const getSummary = (message: Operation) => {\n const messageSummary = message.summary ? message.summary : '';\n const messageDescription = message.description ? 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 buildMessage = async (pathToFile: string, document: OpenAPI.Document, operation: Operation) => {\n const requestBodiesAndResponses = await getSchemasByOperationId(pathToFile, operation.operationId);\n\n const operationTags = operation.tags.map((badge) => ({\n content: `tag:${badge}`,\n textColor: 'blue',\n backgroundColor: 'blue',\n }));\n\n const badges = [{ content: operation.method.toUpperCase(), textColor: 'blue', backgroundColor: 'blue' }, ...operationTags];\n\n const apiName = slugify(document.info.title, { lower: true });\n const path = operation.path.replace(/\\//, '').replace(/\\//g, '_');\n let uniqueIdentifier = operation.operationId || `${apiName}_${operation.method}`;\n\n if (!operation.operationId && path) {\n uniqueIdentifier = uniqueIdentifier.concat(`_${path}`);\n }\n\n return {\n id: uniqueIdentifier,\n version: document.info.version,\n name: uniqueIdentifier,\n summary: getSummary(operation),\n markdown: defaultMarkdown(operation, requestBodiesAndResponses),\n schemaPath: requestBodiesAndResponses?.requestBody ? 'request-body.json' : '',\n badges,\n requestBodiesAndResponses,\n };\n};\n","/**\n * TODO: Move this into the SDK\n */\n\nimport utils from '@eventcatalog/sdk';\n\nexport const getMessageTypeUtils = (projectDirectory: string, messageType: string) => {\n const {\n writeEvent,\n versionCommand,\n getEvent,\n getCommand,\n rmCommandById,\n rmEventById,\n writeCommand,\n addFileToCommand,\n addFileToEvent,\n versionEvent,\n } = utils(projectDirectory);\n\n if (messageType === 'event') {\n return {\n versionMessage: versionEvent,\n getMessage: getEvent,\n rmMessageById: rmEventById,\n writeMessage: writeEvent,\n addFileToMessage: addFileToEvent,\n };\n }\n\n // default command\n return {\n versionMessage: versionCommand,\n getMessage: getCommand,\n rmMessageById: rmCommandById,\n writeMessage: writeCommand,\n addFileToMessage: addFileToCommand,\n };\n};\n","import chalk from 'chalk';\n\nexport default () => {\n console.log(chalk.bgBlue(`\\nYou are using a free version of this plugin`));\n console.log(\n chalk.blueBright(\n `This plugin is governed and published under the AGPL-3.0 copy-left license. \\nIf using for commercial purposes or proprietary software, please contact hello@eventcatalog.dev for a license to support the project.`\n )\n );\n};\n"],"mappings":";AAAA,OAAOA,YAAW;AAClB,SAAS,gBAAgB;AACzB,OAAOC,YAAW;AAClB,OAAOC,oBAAmB;;;ACHnB,IAAM,kBAAkB,MAAM;AACnC,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAMT;;;ACNA,OAAO,aAAa;AAEb,IAAMC,mBAAkB,CAAC,UAA4B,aAAqB;AAC/E,SAAO;AAAA;AAAA,EAEP,SAAS,KAAK,cAAc,GAAG,SAAS,KAAK,WAAW,KAAK,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAMhD,QAAQ;AAAA;AAAA,EAGvB,SAAS,eACL;AAAA;AAAA,KAED,SAAS,aAAa,WAAW,KAAK,SAAS,aAAa,GAAG;AAAA,IAE9D,EACN;AAAA;AAAA;AAGA;AAEO,IAAM,aAAa,CAAC,aAA+B;AACxD,QAAM,UAAU,SAAS,KAAK,cAAc,SAAS,KAAK,cAAc;AACxE,SAAO,WAAW,QAAQ,SAAS,MAAM,UAAU;AACrD;AAEO,IAAM,eAAe,CAAC,YAAoB,aAA+B;AAC9E,QAAM,aAAa,WAAW,MAAM,GAAG,EAAE,IAAI,KAAK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B,GAAG,EAAE,MAAM,QAAQ,KAAK,CAAC;AAGpF,aAAS,KAAK;AAAA,MACZ,IAAI,QAAQ;AAAA,MACZ,SAAS,QAAQ;AAAA,IACnB,CAAC;AAGD,QAAI,2BAA2B,aAAa;AAC1C,YAAM;AAAA,QACJ,QAAQ;AAAA,QACR;AAAA,UACE,UAAU;AAAA,UACV,SAAS,KAAK,UAAU,0BAA0B,aAAa,MAAM,CAAC;AAAA,QACxE;AAAA,QACA,QAAQ;AAAA,MACV;AAAA,IACF;AAEA,QAAI,2BAA2B,WAAW;AACxC,iBAAW,CAAC,YAAY,MAAM,KAAK,OAAO,QAAQ,0BAA0B,SAAS,GAAG;AACtF,cAAM;AAAA,UACJ,QAAQ;AAAA,UACR;AAAA,YACE,UAAU,YAAY,UAAU;AAAA,YAChC,SAAS,KAAK,UAAU,QAAQ,MAAM,CAAC;AAAA,UACzC;AAAA,UACA,QAAQ;AAAA,QACV;AAAA,MACF;AAAA,IACF;AAEA,YAAQ,IAAIA,OAAM,KAAK,gBAAgB,OAAO,WAAW,CAAC;AAC1D,QAAI,CAAC,UAAU,aAAa;AAC1B,cAAQ,IAAIA,OAAM,OAAO,iCAAiC,UAAU,MAAM,IAAI,UAAU,IAAI,mBAAmB,CAAC;AAChH,cAAQ,IAAIA,OAAM,OAAO,mEAAmE,CAAC;AAAA,IAC/F;AAAA,EACF;AACA,SAAO,EAAE,UAAU,OAAO,CAAC,EAAE;AAC/B;","names":["utils","chalk","SwaggerParser","defaultMarkdown","slugify","defaultMarkdown","getSummary","utils","chalk","SwaggerParser"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eventcatalog/generator-openapi",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "OpenAPI generator for EventCatalog",
5
5
  "publishConfig": {
6
6
  "access": "public"