@eventcatalog/generator-openapi 2.3.0 → 3.0.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/README.md +9 -1
- package/dist/index.js +45 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -23
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.mts +3 -0
- package/dist/types.d.ts +3 -0
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -108,6 +108,14 @@ Thank you to our project sponsors.
|
|
|
108
108
|
|
|
109
109
|
<hr />
|
|
110
110
|
|
|
111
|
+
<div align="center">
|
|
112
|
+
<img alt="oso" src="./images/sponsors/oso-logo-green.png" width="40%" />
|
|
113
|
+
<p style="margin: 0; padding: 0;">Delivering Apache Kafka professional services to your business</p>
|
|
114
|
+
<a href="https://oso.sh/?utm_source=eventcatalog&utm_medium=web&utm_campaign=sponsorship" target="_blank" >Learn more</a>
|
|
115
|
+
</div>
|
|
116
|
+
|
|
117
|
+
<hr />
|
|
118
|
+
|
|
111
119
|
_Sponsors help make EventCatalog sustainable, want to help the project? Get in touch! Or [visit our sponsor page](https://www.eventcatalog.dev/support)._
|
|
112
120
|
|
|
113
121
|
# Enterprise support
|
|
@@ -142,4 +150,4 @@ You can find the [contributing guidelines here](https://eventcatalog.dev/docs/co
|
|
|
142
150
|
|
|
143
151
|
This project is governed by a [dual-license](./LICENSE.md). To ensure the sustainability of the project, you can freely make use of this software if your projects are Open Source. Otherwise for internal systems you must obtain a [commercial license](./LICENSE-COMMERCIAL.md).
|
|
144
152
|
|
|
145
|
-
|
|
153
|
+
If you would like to obtain a Commercial License, you can purchase a license at https://dashboard.eventcatalog.dev or email us at `hello@eventcatalog.dev`
|
package/dist/index.js
CHANGED
|
@@ -139,6 +139,12 @@ async function getOperationsByType(openApiPath) {
|
|
|
139
139
|
const openAPIOperation = pathItem[method];
|
|
140
140
|
const messageType = openAPIOperation["x-eventcatalog-message-type"] || DEFAULT_MESSAGE_TYPE;
|
|
141
141
|
const messageAction = openAPIOperation["x-eventcatalog-message-action"] === "sends" ? "sends" : "receives";
|
|
142
|
+
const extensions = Object.keys(openAPIOperation).reduce((acc, key) => {
|
|
143
|
+
if (key.startsWith("x-eventcatalog-")) {
|
|
144
|
+
acc[key] = openAPIOperation[key];
|
|
145
|
+
}
|
|
146
|
+
return acc;
|
|
147
|
+
}, {});
|
|
142
148
|
const operation = {
|
|
143
149
|
path: path2,
|
|
144
150
|
method: method.toUpperCase(),
|
|
@@ -148,7 +154,8 @@ async function getOperationsByType(openApiPath) {
|
|
|
148
154
|
action: messageAction,
|
|
149
155
|
description: openAPIOperation.description,
|
|
150
156
|
summary: openAPIOperation.summary,
|
|
151
|
-
tags: openAPIOperation.tags || []
|
|
157
|
+
tags: openAPIOperation.tags || [],
|
|
158
|
+
extensions
|
|
152
159
|
};
|
|
153
160
|
operations.push(operation);
|
|
154
161
|
}
|
|
@@ -200,6 +207,11 @@ var defaultMarkdown3 = (message, openAPIOperation = {}) => {
|
|
|
200
207
|
## Architecture
|
|
201
208
|
<NodeGraph />
|
|
202
209
|
|
|
210
|
+
${message.description ? `
|
|
211
|
+
## Overview
|
|
212
|
+
${message.description}
|
|
213
|
+
` : ""}
|
|
214
|
+
|
|
203
215
|
${message.externalDocs ? `
|
|
204
216
|
## External documentation
|
|
205
217
|
- [${message.externalDocs.description}](${message.externalDocs.url})
|
|
@@ -229,6 +241,7 @@ var getSummary2 = (message) => {
|
|
|
229
241
|
};
|
|
230
242
|
var buildMessage = async (pathToFile, document, operation) => {
|
|
231
243
|
const requestBodiesAndResponses = await getSchemasByOperationId(pathToFile, operation.operationId);
|
|
244
|
+
const extensions = operation.extensions || {};
|
|
232
245
|
const operationTags = operation.tags.map((badge) => ({
|
|
233
246
|
content: `tag:${badge}`,
|
|
234
247
|
textColor: "blue",
|
|
@@ -242,9 +255,9 @@ var buildMessage = async (pathToFile, document, operation) => {
|
|
|
242
255
|
uniqueIdentifier = uniqueIdentifier.concat(`_${path2}`);
|
|
243
256
|
}
|
|
244
257
|
return {
|
|
245
|
-
id: uniqueIdentifier,
|
|
258
|
+
id: extensions["x-eventcatalog-message-id"] || uniqueIdentifier,
|
|
246
259
|
version: document.info.version,
|
|
247
|
-
name: uniqueIdentifier,
|
|
260
|
+
name: extensions["x-eventcatalog-message-name"] || uniqueIdentifier,
|
|
248
261
|
summary: getSummary2(operation),
|
|
249
262
|
markdown: defaultMarkdown3(operation, requestBodiesAndResponses),
|
|
250
263
|
schemaPath: requestBodiesAndResponses?.requestBody ? "request-body.json" : "",
|
|
@@ -266,24 +279,37 @@ var getMessageTypeUtils = (projectDirectory, messageType) => {
|
|
|
266
279
|
writeCommand,
|
|
267
280
|
addFileToCommand,
|
|
268
281
|
addFileToEvent,
|
|
269
|
-
versionEvent
|
|
282
|
+
versionEvent,
|
|
283
|
+
versionQuery,
|
|
284
|
+
getQuery,
|
|
285
|
+
rmQueryById,
|
|
286
|
+
writeQuery,
|
|
287
|
+
addFileToQuery
|
|
270
288
|
} = (0, import_sdk.default)(projectDirectory);
|
|
271
|
-
|
|
272
|
-
|
|
289
|
+
const messageTypeMap = {
|
|
290
|
+
event: {
|
|
273
291
|
versionMessage: versionEvent,
|
|
274
292
|
getMessage: getEvent,
|
|
275
293
|
rmMessageById: rmEventById,
|
|
276
294
|
writeMessage: writeEvent,
|
|
277
295
|
addFileToMessage: addFileToEvent
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
296
|
+
},
|
|
297
|
+
command: {
|
|
298
|
+
versionMessage: versionCommand,
|
|
299
|
+
getMessage: getCommand,
|
|
300
|
+
rmMessageById: rmCommandById,
|
|
301
|
+
writeMessage: writeCommand,
|
|
302
|
+
addFileToMessage: addFileToCommand
|
|
303
|
+
},
|
|
304
|
+
query: {
|
|
305
|
+
versionMessage: versionQuery,
|
|
306
|
+
getMessage: getQuery,
|
|
307
|
+
rmMessageById: rmQueryById,
|
|
308
|
+
writeMessage: writeQuery,
|
|
309
|
+
addFileToMessage: addFileToQuery
|
|
310
|
+
}
|
|
286
311
|
};
|
|
312
|
+
return messageTypeMap[messageType] || messageTypeMap.query;
|
|
287
313
|
};
|
|
288
314
|
|
|
289
315
|
// src/utils/checkLicense.ts
|
|
@@ -294,7 +320,7 @@ You are using the open source license for this plugin`));
|
|
|
294
320
|
console.log(
|
|
295
321
|
import_chalk.default.blueBright(
|
|
296
322
|
`This plugin is governed and published under a dual-license.
|
|
297
|
-
If using for internal, commercial or proprietary software,
|
|
323
|
+
If using for internal, commercial or proprietary software, you can purchase a license at https://dashboard.eventcatalog.dev/ or contact us hello@eventcatalog.dev.`
|
|
298
324
|
)
|
|
299
325
|
);
|
|
300
326
|
};
|
|
@@ -312,7 +338,6 @@ var src_default = async (_, options) => {
|
|
|
312
338
|
addServiceToDomain,
|
|
313
339
|
getService,
|
|
314
340
|
versionService,
|
|
315
|
-
rmServiceById,
|
|
316
341
|
writeService,
|
|
317
342
|
addFileToService,
|
|
318
343
|
getSpecificationFilesForService
|
|
@@ -374,7 +399,6 @@ Processing domain: ${domainName} (v${domainVersion})`));
|
|
|
374
399
|
}
|
|
375
400
|
if (latestServiceInCatalog.version === version) {
|
|
376
401
|
receives = latestServiceInCatalog.receives ? [...latestServiceInCatalog.receives, ...receives] : receives;
|
|
377
|
-
await rmServiceById(service.id);
|
|
378
402
|
}
|
|
379
403
|
}
|
|
380
404
|
await writeService(
|
|
@@ -385,7 +409,7 @@ Processing domain: ${domainName} (v${domainVersion})`));
|
|
|
385
409
|
sends,
|
|
386
410
|
receives
|
|
387
411
|
},
|
|
388
|
-
{ path: service.id }
|
|
412
|
+
{ path: service.id, override: true }
|
|
389
413
|
);
|
|
390
414
|
const specFiles = [
|
|
391
415
|
// add any previous spec files to the list
|
|
@@ -419,21 +443,19 @@ var processMessagesForOpenAPISpec = async (pathToSpec, document) => {
|
|
|
419
443
|
const messageType = operation.type;
|
|
420
444
|
const messageAction = operation.action;
|
|
421
445
|
console.log(import_chalk2.default.blue(`Processing message: ${message.name} (v${version})`));
|
|
422
|
-
const { addFileToMessage, writeMessage,
|
|
446
|
+
const { addFileToMessage, writeMessage, getMessage, versionMessage } = getMessageTypeUtils(
|
|
423
447
|
process.env.PROJECT_DIR,
|
|
424
448
|
messageType
|
|
425
449
|
);
|
|
426
450
|
const catalogedMessage = await getMessage(message.id, "latest");
|
|
427
451
|
if (catalogedMessage) {
|
|
428
452
|
messageMarkdown = catalogedMessage.markdown;
|
|
429
|
-
if (catalogedMessage.version
|
|
430
|
-
await rmMessageById(message.id, version);
|
|
431
|
-
} else {
|
|
453
|
+
if (catalogedMessage.version !== version) {
|
|
432
454
|
await versionMessage(message.id);
|
|
433
455
|
console.log(import_chalk2.default.cyan(` - Versioned previous message: (v${catalogedMessage.version})`));
|
|
434
456
|
}
|
|
435
457
|
}
|
|
436
|
-
await writeMessage({ ...message, markdown: messageMarkdown }, { path: message.
|
|
458
|
+
await writeMessage({ ...message, markdown: messageMarkdown }, { path: message.id, override: true });
|
|
437
459
|
if (messageAction === "sends") {
|
|
438
460
|
sends.push({
|
|
439
461
|
id: message.id,
|
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","../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, Service } from './types';\nimport { getMessageTypeUtils } from './utils/catalog-shorthand';\nimport { OpenAPI } from 'openapi-types';\nimport checkLicense from './utils/checkLicense';\nimport yaml from 'js-yaml';\n\ntype Props = {\n services: Service[];\n domain?: Domain;\n debug?: boolean;\n saveParsedSpecFile?: 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 rmServiceById,\n writeService,\n addFileToService,\n getSpecificationFilesForService,\n } = utils(process.env.PROJECT_DIR);\n\n const { services = [], saveParsedSpecFile = false } = options;\n for (const serviceSpec of services) {\n console.log(chalk.green(`Processing ${serviceSpec.path}`));\n\n try {\n await SwaggerParser.validate(serviceSpec.path);\n } catch (error) {\n console.error(chalk.red(`Failed to parse OpenAPI file: ${serviceSpec.path}`));\n console.error(chalk.red(error));\n continue;\n }\n\n const document = await SwaggerParser.dereference(serviceSpec.path);\n const version = document.info.version;\n\n const service = buildService(serviceSpec, document);\n let serviceMarkdown = service.markdown;\n let serviceSpecificationsFiles = [];\n let serviceSpecifications = service.specifications;\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(serviceSpec.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 serviceSpecificationsFiles = await getSpecificationFilesForService(service.id, 'latest');\n sends = latestServiceInCatalog.sends || ([] as any);\n\n // persist any specifications that are already in the catalog\n serviceSpecifications = {\n ...serviceSpecifications,\n ...latestServiceInCatalog.specifications,\n };\n\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 receives = latestServiceInCatalog.receives ? [...latestServiceInCatalog.receives, ...receives] : receives;\n await rmServiceById(service.id);\n }\n }\n\n await writeService(\n {\n ...service,\n markdown: serviceMarkdown,\n specifications: serviceSpecifications,\n sends,\n receives,\n },\n { path: service.id }\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(serviceSpec, document) : await getRawSpecFile(serviceSpec),\n fileName: service.schemaPath,\n },\n ];\n\n for (const specFile of specFiles) {\n await addFileToService(\n service.id,\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\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 sends = [];\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 const messageAction = operation.action;\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 // If the message send or recieved by the service?\n if (messageAction === 'sends') {\n sends.push({\n id: message.id,\n version: message.version,\n });\n } else {\n receives.push({\n id: message.id,\n version: message.version,\n });\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\nconst getParsedSpecFile = (service: Service, document: OpenAPI.Document) => {\n const isSpecFileJSON = service.path.endsWith('.json');\n return isSpecFileJSON ? JSON.stringify(document, null, 2) : yaml.dump(document, { noRefs: true });\n};\n\nconst getRawSpecFile = async (service: Service) => await readFile(service.path, 'utf8');\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';\nimport { Service } from '../types';\nimport path from 'path';\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${\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 = (serviceOptions: Service, document: OpenAPI.Document) => {\n const schemaPath = path.basename(serviceOptions.path) || 'openapi.yml';\n const documentTags = document.tags || [];\n const serviceId = serviceOptions.id || slugify(document.info.title, { lower: true, strict: true });\n return {\n id: serviceId,\n version: document.info.version,\n name: document.info.title,\n summary: getSummary(document),\n schemaPath,\n specifications: {\n openapiPath: schemaPath,\n },\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 const messageAction = openAPIOperation['x-eventcatalog-message-action'] === 'sends' ? 'sends' : 'receives';\n\n const operation = {\n path: path,\n method: method.toUpperCase(),\n operationId: openAPIOperation.operationId,\n externalDocs: openAPIOperation.externalDocs,\n type: messageType,\n action: messageAction,\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 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":";;;;;;;;;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AI,mBAAmB,CAAC;AAChH,cAAQ,IAAI,cAAAA,QAAM,OAAO,mEAAmE,CAAC;AAAA,IAC/F;AAAA,EACF;AACA,SAAO,EAAE,UAAU,MAAM;AAC3B;AAEA,IAAM,oBAAoB,CAAC,SAAkB,aAA+B;AAC1E,QAAM,iBAAiB,QAAQ,KAAK,SAAS,OAAO;AACpD,SAAO,iBAAiB,KAAK,UAAU,UAAU,MAAM,CAAC,IAAI,eAAAE,QAAK,KAAK,UAAU,EAAE,QAAQ,KAAK,CAAC;AAClG;AAEA,IAAM,iBAAiB,OAAO,YAAqB,UAAM,0BAAS,QAAQ,MAAM,MAAM;","names":["import_sdk","import_chalk","import_swagger_parser","defaultMarkdown","path","slugify","SwaggerParser","path","import_slugify","defaultMarkdown","getSummary","slugify","path","utils","chalk","utils","chalk","SwaggerParser","yaml"]}
|
|
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, Service } from './types';\nimport { getMessageTypeUtils } from './utils/catalog-shorthand';\nimport { OpenAPI } from 'openapi-types';\nimport checkLicense from './utils/checkLicense';\nimport yaml from 'js-yaml';\n\ntype Props = {\n services: Service[];\n domain?: Domain;\n debug?: boolean;\n saveParsedSpecFile?: 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 writeService,\n addFileToService,\n getSpecificationFilesForService,\n } = utils(process.env.PROJECT_DIR);\n\n const { services = [], saveParsedSpecFile = false } = options;\n for (const serviceSpec of services) {\n console.log(chalk.green(`Processing ${serviceSpec.path}`));\n\n try {\n await SwaggerParser.validate(serviceSpec.path);\n } catch (error) {\n console.error(chalk.red(`Failed to parse OpenAPI file: ${serviceSpec.path}`));\n console.error(chalk.red(error));\n continue;\n }\n\n const document = await SwaggerParser.dereference(serviceSpec.path);\n const version = document.info.version;\n\n const service = buildService(serviceSpec, document);\n let serviceMarkdown = service.markdown;\n let serviceSpecificationsFiles = [];\n let serviceSpecifications = service.specifications;\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(serviceSpec.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 serviceSpecificationsFiles = await getSpecificationFilesForService(service.id, 'latest');\n sends = latestServiceInCatalog.sends || ([] as any);\n\n // persist any specifications that are already in the catalog\n serviceSpecifications = {\n ...serviceSpecifications,\n ...latestServiceInCatalog.specifications,\n };\n\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 receives = latestServiceInCatalog.receives ? [...latestServiceInCatalog.receives, ...receives] : receives;\n }\n }\n\n await writeService(\n {\n ...service,\n markdown: serviceMarkdown,\n specifications: serviceSpecifications,\n sends,\n receives,\n },\n { path: service.id, override: true }\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(serviceSpec, document) : await getRawSpecFile(serviceSpec),\n fileName: service.schemaPath,\n },\n ];\n\n for (const specFile of specFiles) {\n await addFileToService(\n service.id,\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\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 sends = [];\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 const messageAction = operation.action;\n\n console.log(chalk.blue(`Processing message: ${message.name} (v${version})`));\n\n const { addFileToMessage, writeMessage, 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 // 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.id, override: true });\n\n // If the message send or recieved by the service?\n if (messageAction === 'sends') {\n sends.push({\n id: message.id,\n version: message.version,\n });\n } else {\n receives.push({\n id: message.id,\n version: message.version,\n });\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\nconst getParsedSpecFile = (service: Service, document: OpenAPI.Document) => {\n const isSpecFileJSON = service.path.endsWith('.json');\n return isSpecFileJSON ? JSON.stringify(document, null, 2) : yaml.dump(document, { noRefs: true });\n};\n\nconst getRawSpecFile = async (service: Service) => await readFile(service.path, 'utf8');\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';\nimport { Service } from '../types';\nimport path from 'path';\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${\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 = (serviceOptions: Service, document: OpenAPI.Document) => {\n const schemaPath = path.basename(serviceOptions.path) || 'openapi.yml';\n const documentTags = document.tags || [];\n const serviceId = serviceOptions.id || slugify(document.info.title, { lower: true, strict: true });\n return {\n id: serviceId,\n version: document.info.version,\n name: document.info.title,\n summary: getSummary(document),\n schemaPath,\n specifications: {\n openapiPath: schemaPath,\n },\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 const messageAction = openAPIOperation['x-eventcatalog-message-action'] === 'sends' ? 'sends' : 'receives';\n const extensions = Object.keys(openAPIOperation).reduce((acc: { [key: string]: any }, key) => {\n if (key.startsWith('x-eventcatalog-')) {\n acc[key] = openAPIOperation[key];\n }\n return acc;\n }, {});\n\n const operation = {\n path: path,\n method: method.toUpperCase(),\n operationId: openAPIOperation.operationId,\n externalDocs: openAPIOperation.externalDocs,\n type: messageType,\n action: messageAction,\n description: openAPIOperation.description,\n summary: openAPIOperation.summary,\n tags: openAPIOperation.tags || [],\n extensions,\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.description\n ? `\n## Overview\n${message.description}\n`\n : ''\n}\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 const extensions = operation.extensions || {};\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: extensions['x-eventcatalog-message-id'] || uniqueIdentifier,\n version: document.info.version,\n name: extensions['x-eventcatalog-message-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 versionQuery,\n getQuery,\n rmQueryById,\n writeQuery,\n addFileToQuery,\n } = utils(projectDirectory);\n\n const messageTypeMap: { [key: string]: any } = {\n event: {\n versionMessage: versionEvent,\n getMessage: getEvent,\n rmMessageById: rmEventById,\n writeMessage: writeEvent,\n addFileToMessage: addFileToEvent,\n },\n command: {\n versionMessage: versionCommand,\n getMessage: getCommand,\n rmMessageById: rmCommandById,\n writeMessage: writeCommand,\n addFileToMessage: addFileToCommand,\n },\n query: {\n versionMessage: versionQuery,\n getMessage: getQuery,\n rmMessageById: rmQueryById,\n writeMessage: writeQuery,\n addFileToMessage: addFileToQuery,\n },\n };\n\n return messageTypeMap[messageType] || messageTypeMap.query;\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, you can purchase a license at https://dashboard.eventcatalog.dev/ or contact us hello@eventcatalog.dev.`\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;AAEpB,kBAAiB;AAEV,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,EAM/D,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,gBAAyB,aAA+B;AACnF,QAAM,aAAa,YAAAC,QAAK,SAAS,eAAe,IAAI,KAAK;AACzD,QAAM,eAAe,SAAS,QAAQ,CAAC;AACvC,QAAM,YAAY,eAAe,UAAM,eAAAC,SAAQ,SAAS,KAAK,OAAO,EAAE,OAAO,MAAM,QAAQ,KAAK,CAAC;AACjG,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,SAAS,SAAS,KAAK;AAAA,IACvB,MAAM,SAAS,KAAK;AAAA,IACpB,SAAS,WAAW,QAAQ;AAAA,IAC5B;AAAA,IACA,gBAAgB;AAAA,MACd,aAAa;AAAA,IACf;AAAA,IACA,UAAUF,iBAAgB,UAAU,UAAU;AAAA,IAC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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,MAAM;AAC3B;AAEA,IAAM,oBAAoB,CAAC,SAAkB,aAA+B;AAC1E,QAAM,iBAAiB,QAAQ,KAAK,SAAS,OAAO;AACpD,SAAO,iBAAiB,KAAK,UAAU,UAAU,MAAM,CAAC,IAAI,eAAAE,QAAK,KAAK,UAAU,EAAE,QAAQ,KAAK,CAAC;AAClG;AAEA,IAAM,iBAAiB,OAAO,YAAqB,UAAM,0BAAS,QAAQ,MAAM,MAAM;","names":["import_sdk","import_chalk","import_swagger_parser","defaultMarkdown","path","slugify","SwaggerParser","path","import_slugify","defaultMarkdown","getSummary","slugify","path","utils","chalk","utils","chalk","SwaggerParser","yaml"]}
|
package/dist/index.mjs
CHANGED
|
@@ -105,6 +105,12 @@ async function getOperationsByType(openApiPath) {
|
|
|
105
105
|
const openAPIOperation = pathItem[method];
|
|
106
106
|
const messageType = openAPIOperation["x-eventcatalog-message-type"] || DEFAULT_MESSAGE_TYPE;
|
|
107
107
|
const messageAction = openAPIOperation["x-eventcatalog-message-action"] === "sends" ? "sends" : "receives";
|
|
108
|
+
const extensions = Object.keys(openAPIOperation).reduce((acc, key) => {
|
|
109
|
+
if (key.startsWith("x-eventcatalog-")) {
|
|
110
|
+
acc[key] = openAPIOperation[key];
|
|
111
|
+
}
|
|
112
|
+
return acc;
|
|
113
|
+
}, {});
|
|
108
114
|
const operation = {
|
|
109
115
|
path: path2,
|
|
110
116
|
method: method.toUpperCase(),
|
|
@@ -114,7 +120,8 @@ async function getOperationsByType(openApiPath) {
|
|
|
114
120
|
action: messageAction,
|
|
115
121
|
description: openAPIOperation.description,
|
|
116
122
|
summary: openAPIOperation.summary,
|
|
117
|
-
tags: openAPIOperation.tags || []
|
|
123
|
+
tags: openAPIOperation.tags || [],
|
|
124
|
+
extensions
|
|
118
125
|
};
|
|
119
126
|
operations.push(operation);
|
|
120
127
|
}
|
|
@@ -166,6 +173,11 @@ var defaultMarkdown3 = (message, openAPIOperation = {}) => {
|
|
|
166
173
|
## Architecture
|
|
167
174
|
<NodeGraph />
|
|
168
175
|
|
|
176
|
+
${message.description ? `
|
|
177
|
+
## Overview
|
|
178
|
+
${message.description}
|
|
179
|
+
` : ""}
|
|
180
|
+
|
|
169
181
|
${message.externalDocs ? `
|
|
170
182
|
## External documentation
|
|
171
183
|
- [${message.externalDocs.description}](${message.externalDocs.url})
|
|
@@ -195,6 +207,7 @@ var getSummary2 = (message) => {
|
|
|
195
207
|
};
|
|
196
208
|
var buildMessage = async (pathToFile, document, operation) => {
|
|
197
209
|
const requestBodiesAndResponses = await getSchemasByOperationId(pathToFile, operation.operationId);
|
|
210
|
+
const extensions = operation.extensions || {};
|
|
198
211
|
const operationTags = operation.tags.map((badge) => ({
|
|
199
212
|
content: `tag:${badge}`,
|
|
200
213
|
textColor: "blue",
|
|
@@ -208,9 +221,9 @@ var buildMessage = async (pathToFile, document, operation) => {
|
|
|
208
221
|
uniqueIdentifier = uniqueIdentifier.concat(`_${path2}`);
|
|
209
222
|
}
|
|
210
223
|
return {
|
|
211
|
-
id: uniqueIdentifier,
|
|
224
|
+
id: extensions["x-eventcatalog-message-id"] || uniqueIdentifier,
|
|
212
225
|
version: document.info.version,
|
|
213
|
-
name: uniqueIdentifier,
|
|
226
|
+
name: extensions["x-eventcatalog-message-name"] || uniqueIdentifier,
|
|
214
227
|
summary: getSummary2(operation),
|
|
215
228
|
markdown: defaultMarkdown3(operation, requestBodiesAndResponses),
|
|
216
229
|
schemaPath: requestBodiesAndResponses?.requestBody ? "request-body.json" : "",
|
|
@@ -232,24 +245,37 @@ var getMessageTypeUtils = (projectDirectory, messageType) => {
|
|
|
232
245
|
writeCommand,
|
|
233
246
|
addFileToCommand,
|
|
234
247
|
addFileToEvent,
|
|
235
|
-
versionEvent
|
|
248
|
+
versionEvent,
|
|
249
|
+
versionQuery,
|
|
250
|
+
getQuery,
|
|
251
|
+
rmQueryById,
|
|
252
|
+
writeQuery,
|
|
253
|
+
addFileToQuery
|
|
236
254
|
} = utils(projectDirectory);
|
|
237
|
-
|
|
238
|
-
|
|
255
|
+
const messageTypeMap = {
|
|
256
|
+
event: {
|
|
239
257
|
versionMessage: versionEvent,
|
|
240
258
|
getMessage: getEvent,
|
|
241
259
|
rmMessageById: rmEventById,
|
|
242
260
|
writeMessage: writeEvent,
|
|
243
261
|
addFileToMessage: addFileToEvent
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
262
|
+
},
|
|
263
|
+
command: {
|
|
264
|
+
versionMessage: versionCommand,
|
|
265
|
+
getMessage: getCommand,
|
|
266
|
+
rmMessageById: rmCommandById,
|
|
267
|
+
writeMessage: writeCommand,
|
|
268
|
+
addFileToMessage: addFileToCommand
|
|
269
|
+
},
|
|
270
|
+
query: {
|
|
271
|
+
versionMessage: versionQuery,
|
|
272
|
+
getMessage: getQuery,
|
|
273
|
+
rmMessageById: rmQueryById,
|
|
274
|
+
writeMessage: writeQuery,
|
|
275
|
+
addFileToMessage: addFileToQuery
|
|
276
|
+
}
|
|
252
277
|
};
|
|
278
|
+
return messageTypeMap[messageType] || messageTypeMap.query;
|
|
253
279
|
};
|
|
254
280
|
|
|
255
281
|
// src/utils/checkLicense.ts
|
|
@@ -260,7 +286,7 @@ You are using the open source license for this plugin`));
|
|
|
260
286
|
console.log(
|
|
261
287
|
chalk.blueBright(
|
|
262
288
|
`This plugin is governed and published under a dual-license.
|
|
263
|
-
If using for internal, commercial or proprietary software,
|
|
289
|
+
If using for internal, commercial or proprietary software, you can purchase a license at https://dashboard.eventcatalog.dev/ or contact us hello@eventcatalog.dev.`
|
|
264
290
|
)
|
|
265
291
|
);
|
|
266
292
|
};
|
|
@@ -278,7 +304,6 @@ var src_default = async (_, options) => {
|
|
|
278
304
|
addServiceToDomain,
|
|
279
305
|
getService,
|
|
280
306
|
versionService,
|
|
281
|
-
rmServiceById,
|
|
282
307
|
writeService,
|
|
283
308
|
addFileToService,
|
|
284
309
|
getSpecificationFilesForService
|
|
@@ -340,7 +365,6 @@ Processing domain: ${domainName} (v${domainVersion})`));
|
|
|
340
365
|
}
|
|
341
366
|
if (latestServiceInCatalog.version === version) {
|
|
342
367
|
receives = latestServiceInCatalog.receives ? [...latestServiceInCatalog.receives, ...receives] : receives;
|
|
343
|
-
await rmServiceById(service.id);
|
|
344
368
|
}
|
|
345
369
|
}
|
|
346
370
|
await writeService(
|
|
@@ -351,7 +375,7 @@ Processing domain: ${domainName} (v${domainVersion})`));
|
|
|
351
375
|
sends,
|
|
352
376
|
receives
|
|
353
377
|
},
|
|
354
|
-
{ path: service.id }
|
|
378
|
+
{ path: service.id, override: true }
|
|
355
379
|
);
|
|
356
380
|
const specFiles = [
|
|
357
381
|
// add any previous spec files to the list
|
|
@@ -385,21 +409,19 @@ var processMessagesForOpenAPISpec = async (pathToSpec, document) => {
|
|
|
385
409
|
const messageType = operation.type;
|
|
386
410
|
const messageAction = operation.action;
|
|
387
411
|
console.log(chalk2.blue(`Processing message: ${message.name} (v${version})`));
|
|
388
|
-
const { addFileToMessage, writeMessage,
|
|
412
|
+
const { addFileToMessage, writeMessage, getMessage, versionMessage } = getMessageTypeUtils(
|
|
389
413
|
process.env.PROJECT_DIR,
|
|
390
414
|
messageType
|
|
391
415
|
);
|
|
392
416
|
const catalogedMessage = await getMessage(message.id, "latest");
|
|
393
417
|
if (catalogedMessage) {
|
|
394
418
|
messageMarkdown = catalogedMessage.markdown;
|
|
395
|
-
if (catalogedMessage.version
|
|
396
|
-
await rmMessageById(message.id, version);
|
|
397
|
-
} else {
|
|
419
|
+
if (catalogedMessage.version !== version) {
|
|
398
420
|
await versionMessage(message.id);
|
|
399
421
|
console.log(chalk2.cyan(` - Versioned previous message: (v${catalogedMessage.version})`));
|
|
400
422
|
}
|
|
401
423
|
}
|
|
402
|
-
await writeMessage({ ...message, markdown: messageMarkdown }, { path: message.
|
|
424
|
+
await writeMessage({ ...message, markdown: messageMarkdown }, { path: message.id, override: true });
|
|
403
425
|
if (messageAction === "sends") {
|
|
404
426
|
sends.push({
|
|
405
427
|
id: message.id,
|
package/dist/index.mjs.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","../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, Service } from './types';\nimport { getMessageTypeUtils } from './utils/catalog-shorthand';\nimport { OpenAPI } from 'openapi-types';\nimport checkLicense from './utils/checkLicense';\nimport yaml from 'js-yaml';\n\ntype Props = {\n services: Service[];\n domain?: Domain;\n debug?: boolean;\n saveParsedSpecFile?: 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 rmServiceById,\n writeService,\n addFileToService,\n getSpecificationFilesForService,\n } = utils(process.env.PROJECT_DIR);\n\n const { services = [], saveParsedSpecFile = false } = options;\n for (const serviceSpec of services) {\n console.log(chalk.green(`Processing ${serviceSpec.path}`));\n\n try {\n await SwaggerParser.validate(serviceSpec.path);\n } catch (error) {\n console.error(chalk.red(`Failed to parse OpenAPI file: ${serviceSpec.path}`));\n console.error(chalk.red(error));\n continue;\n }\n\n const document = await SwaggerParser.dereference(serviceSpec.path);\n const version = document.info.version;\n\n const service = buildService(serviceSpec, document);\n let serviceMarkdown = service.markdown;\n let serviceSpecificationsFiles = [];\n let serviceSpecifications = service.specifications;\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(serviceSpec.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 serviceSpecificationsFiles = await getSpecificationFilesForService(service.id, 'latest');\n sends = latestServiceInCatalog.sends || ([] as any);\n\n // persist any specifications that are already in the catalog\n serviceSpecifications = {\n ...serviceSpecifications,\n ...latestServiceInCatalog.specifications,\n };\n\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 receives = latestServiceInCatalog.receives ? [...latestServiceInCatalog.receives, ...receives] : receives;\n await rmServiceById(service.id);\n }\n }\n\n await writeService(\n {\n ...service,\n markdown: serviceMarkdown,\n specifications: serviceSpecifications,\n sends,\n receives,\n },\n { path: service.id }\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(serviceSpec, document) : await getRawSpecFile(serviceSpec),\n fileName: service.schemaPath,\n },\n ];\n\n for (const specFile of specFiles) {\n await addFileToService(\n service.id,\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\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 sends = [];\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 const messageAction = operation.action;\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 // If the message send or recieved by the service?\n if (messageAction === 'sends') {\n sends.push({\n id: message.id,\n version: message.version,\n });\n } else {\n receives.push({\n id: message.id,\n version: message.version,\n });\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\nconst getParsedSpecFile = (service: Service, document: OpenAPI.Document) => {\n const isSpecFileJSON = service.path.endsWith('.json');\n return isSpecFileJSON ? JSON.stringify(document, null, 2) : yaml.dump(document, { noRefs: true });\n};\n\nconst getRawSpecFile = async (service: Service) => await readFile(service.path, 'utf8');\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';\nimport { Service } from '../types';\nimport path from 'path';\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${\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 = (serviceOptions: Service, document: OpenAPI.Document) => {\n const schemaPath = path.basename(serviceOptions.path) || 'openapi.yml';\n const documentTags = document.tags || [];\n const serviceId = serviceOptions.id || slugify(document.info.title, { lower: true, strict: true });\n return {\n id: serviceId,\n version: document.info.version,\n name: document.info.title,\n summary: getSummary(document),\n schemaPath,\n specifications: {\n openapiPath: schemaPath,\n },\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 const messageAction = openAPIOperation['x-eventcatalog-message-action'] === 'sends' ? 'sends' : 'receives';\n\n const operation = {\n path: path,\n method: method.toUpperCase(),\n operationId: openAPIOperation.operationId,\n externalDocs: openAPIOperation.externalDocs,\n type: messageType,\n action: messageAction,\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 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.d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+B;AAC1E,QAAM,iBAAiB,QAAQ,KAAK,SAAS,OAAO;AACpD,SAAO,iBAAiB,KAAK,UAAU,UAAU,MAAM,CAAC,IAAI,KAAK,KAAK,UAAU,EAAE,QAAQ,KAAK,CAAC;AAClG;AAEA,IAAM,iBAAiB,OAAO,YAAqB,MAAM,SAAS,QAAQ,MAAM,MAAM;","names":["utils","chalk","SwaggerParser","defaultMarkdown","path","slugify","defaultMarkdown","getSummary","path","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, Service } from './types';\nimport { getMessageTypeUtils } from './utils/catalog-shorthand';\nimport { OpenAPI } from 'openapi-types';\nimport checkLicense from './utils/checkLicense';\nimport yaml from 'js-yaml';\n\ntype Props = {\n services: Service[];\n domain?: Domain;\n debug?: boolean;\n saveParsedSpecFile?: 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 writeService,\n addFileToService,\n getSpecificationFilesForService,\n } = utils(process.env.PROJECT_DIR);\n\n const { services = [], saveParsedSpecFile = false } = options;\n for (const serviceSpec of services) {\n console.log(chalk.green(`Processing ${serviceSpec.path}`));\n\n try {\n await SwaggerParser.validate(serviceSpec.path);\n } catch (error) {\n console.error(chalk.red(`Failed to parse OpenAPI file: ${serviceSpec.path}`));\n console.error(chalk.red(error));\n continue;\n }\n\n const document = await SwaggerParser.dereference(serviceSpec.path);\n const version = document.info.version;\n\n const service = buildService(serviceSpec, document);\n let serviceMarkdown = service.markdown;\n let serviceSpecificationsFiles = [];\n let serviceSpecifications = service.specifications;\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(serviceSpec.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 serviceSpecificationsFiles = await getSpecificationFilesForService(service.id, 'latest');\n sends = latestServiceInCatalog.sends || ([] as any);\n\n // persist any specifications that are already in the catalog\n serviceSpecifications = {\n ...serviceSpecifications,\n ...latestServiceInCatalog.specifications,\n };\n\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 receives = latestServiceInCatalog.receives ? [...latestServiceInCatalog.receives, ...receives] : receives;\n }\n }\n\n await writeService(\n {\n ...service,\n markdown: serviceMarkdown,\n specifications: serviceSpecifications,\n sends,\n receives,\n },\n { path: service.id, override: true }\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(serviceSpec, document) : await getRawSpecFile(serviceSpec),\n fileName: service.schemaPath,\n },\n ];\n\n for (const specFile of specFiles) {\n await addFileToService(\n service.id,\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\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 sends = [];\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 const messageAction = operation.action;\n\n console.log(chalk.blue(`Processing message: ${message.name} (v${version})`));\n\n const { addFileToMessage, writeMessage, 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 // 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.id, override: true });\n\n // If the message send or recieved by the service?\n if (messageAction === 'sends') {\n sends.push({\n id: message.id,\n version: message.version,\n });\n } else {\n receives.push({\n id: message.id,\n version: message.version,\n });\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\nconst getParsedSpecFile = (service: Service, document: OpenAPI.Document) => {\n const isSpecFileJSON = service.path.endsWith('.json');\n return isSpecFileJSON ? JSON.stringify(document, null, 2) : yaml.dump(document, { noRefs: true });\n};\n\nconst getRawSpecFile = async (service: Service) => await readFile(service.path, 'utf8');\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';\nimport { Service } from '../types';\nimport path from 'path';\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${\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 = (serviceOptions: Service, document: OpenAPI.Document) => {\n const schemaPath = path.basename(serviceOptions.path) || 'openapi.yml';\n const documentTags = document.tags || [];\n const serviceId = serviceOptions.id || slugify(document.info.title, { lower: true, strict: true });\n return {\n id: serviceId,\n version: document.info.version,\n name: document.info.title,\n summary: getSummary(document),\n schemaPath,\n specifications: {\n openapiPath: schemaPath,\n },\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 const messageAction = openAPIOperation['x-eventcatalog-message-action'] === 'sends' ? 'sends' : 'receives';\n const extensions = Object.keys(openAPIOperation).reduce((acc: { [key: string]: any }, key) => {\n if (key.startsWith('x-eventcatalog-')) {\n acc[key] = openAPIOperation[key];\n }\n return acc;\n }, {});\n\n const operation = {\n path: path,\n method: method.toUpperCase(),\n operationId: openAPIOperation.operationId,\n externalDocs: openAPIOperation.externalDocs,\n type: messageType,\n action: messageAction,\n description: openAPIOperation.description,\n summary: openAPIOperation.summary,\n tags: openAPIOperation.tags || [],\n extensions,\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.description\n ? `\n## Overview\n${message.description}\n`\n : ''\n}\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 const extensions = operation.extensions || {};\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: extensions['x-eventcatalog-message-id'] || uniqueIdentifier,\n version: document.info.version,\n name: extensions['x-eventcatalog-message-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 versionQuery,\n getQuery,\n rmQueryById,\n writeQuery,\n addFileToQuery,\n } = utils(projectDirectory);\n\n const messageTypeMap: { [key: string]: any } = {\n event: {\n versionMessage: versionEvent,\n getMessage: getEvent,\n rmMessageById: rmEventById,\n writeMessage: writeEvent,\n addFileToMessage: addFileToEvent,\n },\n command: {\n versionMessage: versionCommand,\n getMessage: getCommand,\n rmMessageById: rmCommandById,\n writeMessage: writeCommand,\n addFileToMessage: addFileToCommand,\n },\n query: {\n versionMessage: versionQuery,\n getMessage: getQuery,\n rmMessageById: rmQueryById,\n writeMessage: writeQuery,\n addFileToMessage: addFileToQuery,\n },\n };\n\n return messageTypeMap[messageType] || messageTypeMap.query;\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, you can purchase a license at https://dashboard.eventcatalog.dev/ or contact us hello@eventcatalog.dev.`\n )\n );\n};\n"],"mappings":";AAAA,OAAOA,YAAW;AAClB,SAAS,gBAAgB;AACzB,OAAOC,YAAW;AAClB,OAAOC,oBAAmB;;;ACHnB,IAAM,kBAAkB,MAAM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,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,MAAM;AAC3B;AAEA,IAAM,oBAAoB,CAAC,SAAkB,aAA+B;AAC1E,QAAM,iBAAiB,QAAQ,KAAK,SAAS,OAAO;AACpD,SAAO,iBAAiB,KAAK,UAAU,UAAU,MAAM,CAAC,IAAI,KAAK,KAAK,UAAU,EAAE,QAAQ,KAAK,CAAC;AAClG;AAEA,IAAM,iBAAiB,OAAO,YAAqB,MAAM,SAAS,QAAQ,MAAM,MAAM;","names":["utils","chalk","SwaggerParser","defaultMarkdown","path","slugify","defaultMarkdown","getSummary","path","utils","chalk","SwaggerParser"]}
|
package/dist/types.d.mts
CHANGED
package/dist/types.d.ts
CHANGED
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import { OpenAPIV3_1 } from 'openapi-types';\n\nexport type Domain = {\n id: string;\n name: string;\n version: string;\n};\n\nexport type Service = {\n id: string;\n path: string;\n};\n\nexport type Operation = {\n path: string;\n method: string;\n operationId: string;\n summary?: string;\n description?: string;\n type: string;\n action: string;\n externalDocs?: OpenAPIV3_1.ExternalDocumentationObject;\n tags: string[];\n};\n\nexport interface OpenAPIParameter {\n name: string;\n in: string;\n required?: boolean;\n schema?: any;\n description?: string;\n}\n\nexport interface OpenAPIOperation {\n operationId?: string;\n parameters?: OpenAPIParameter[];\n requestBody?: {\n content?: {\n [contentType: string]: {\n schema: any;\n };\n };\n };\n responses?: {\n [statusCode: string]: {\n isSchema?: boolean;\n content?: {\n [contentType: string]: {\n schema: any;\n };\n };\n };\n };\n}\n\nexport interface OpenAPIPathItem {\n [method: string]: OpenAPIOperation;\n}\n\nexport interface OpenAPIPaths {\n [path: string]: OpenAPIPathItem;\n}\n\nexport interface OpenAPIDocument {\n paths: OpenAPIPaths;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import { OpenAPIV3_1 } from 'openapi-types';\n\nexport type Domain = {\n id: string;\n name: string;\n version: string;\n};\n\nexport type Service = {\n id: string;\n path: string;\n};\n\nexport type Operation = {\n path: string;\n method: string;\n operationId: string;\n summary?: string;\n description?: string;\n type: string;\n action: string;\n externalDocs?: OpenAPIV3_1.ExternalDocumentationObject;\n tags: string[];\n extensions?: {\n [key: string]: any;\n };\n};\n\nexport interface OpenAPIParameter {\n name: string;\n in: string;\n required?: boolean;\n schema?: any;\n description?: string;\n}\n\nexport interface OpenAPIOperation {\n operationId?: string;\n parameters?: OpenAPIParameter[];\n requestBody?: {\n content?: {\n [contentType: string]: {\n schema: any;\n };\n };\n };\n responses?: {\n [statusCode: string]: {\n isSchema?: boolean;\n content?: {\n [contentType: string]: {\n schema: any;\n };\n };\n };\n };\n}\n\nexport interface OpenAPIPathItem {\n [method: string]: OpenAPIOperation;\n}\n\nexport interface OpenAPIPaths {\n [path: string]: OpenAPIPathItem;\n}\n\nexport interface OpenAPIDocument {\n paths: OpenAPIPaths;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eventcatalog/generator-openapi",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "OpenAPI generator for EventCatalog",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@apidevtools/swagger-parser": "^10.1.0",
|
|
30
30
|
"@changesets/cli": "^2.27.7",
|
|
31
|
-
"@eventcatalog/sdk": "^1.1
|
|
31
|
+
"@eventcatalog/sdk": "^1.4.1",
|
|
32
32
|
"chalk": "^4",
|
|
33
33
|
"js-yaml": "^4.1.0",
|
|
34
34
|
"openapi-types": "^12.1.3",
|