@eventcatalog/generator-asyncapi 2.5.2 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +132 -37
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +132 -37
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.mts +0 -1
- package/dist/types.d.ts +0 -1
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -29,6 +29,7 @@ declare const optionsSchema: z.ZodObject<{
|
|
|
29
29
|
}>>;
|
|
30
30
|
debug: z.ZodOptional<z.ZodBoolean>;
|
|
31
31
|
parseSchemas: z.ZodOptional<z.ZodBoolean>;
|
|
32
|
+
parseChannels: z.ZodOptional<z.ZodBoolean>;
|
|
32
33
|
saveParsedSpecFile: z.ZodOptional<z.ZodBoolean>;
|
|
33
34
|
}, "strip", z.ZodTypeAny, {
|
|
34
35
|
services: {
|
|
@@ -43,6 +44,7 @@ declare const optionsSchema: z.ZodObject<{
|
|
|
43
44
|
} | undefined;
|
|
44
45
|
debug?: boolean | undefined;
|
|
45
46
|
parseSchemas?: boolean | undefined;
|
|
47
|
+
parseChannels?: boolean | undefined;
|
|
46
48
|
saveParsedSpecFile?: boolean | undefined;
|
|
47
49
|
}, {
|
|
48
50
|
services: {
|
|
@@ -57,6 +59,7 @@ declare const optionsSchema: z.ZodObject<{
|
|
|
57
59
|
} | undefined;
|
|
58
60
|
debug?: boolean | undefined;
|
|
59
61
|
parseSchemas?: boolean | undefined;
|
|
62
|
+
parseChannels?: boolean | undefined;
|
|
60
63
|
saveParsedSpecFile?: boolean | undefined;
|
|
61
64
|
}>;
|
|
62
65
|
type Props = z.infer<typeof optionsSchema>;
|
package/dist/index.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ declare const optionsSchema: z.ZodObject<{
|
|
|
29
29
|
}>>;
|
|
30
30
|
debug: z.ZodOptional<z.ZodBoolean>;
|
|
31
31
|
parseSchemas: z.ZodOptional<z.ZodBoolean>;
|
|
32
|
+
parseChannels: z.ZodOptional<z.ZodBoolean>;
|
|
32
33
|
saveParsedSpecFile: z.ZodOptional<z.ZodBoolean>;
|
|
33
34
|
}, "strip", z.ZodTypeAny, {
|
|
34
35
|
services: {
|
|
@@ -43,6 +44,7 @@ declare const optionsSchema: z.ZodObject<{
|
|
|
43
44
|
} | undefined;
|
|
44
45
|
debug?: boolean | undefined;
|
|
45
46
|
parseSchemas?: boolean | undefined;
|
|
47
|
+
parseChannels?: boolean | undefined;
|
|
46
48
|
saveParsedSpecFile?: boolean | undefined;
|
|
47
49
|
}, {
|
|
48
50
|
services: {
|
|
@@ -57,6 +59,7 @@ declare const optionsSchema: z.ZodObject<{
|
|
|
57
59
|
} | undefined;
|
|
58
60
|
debug?: boolean | undefined;
|
|
59
61
|
parseSchemas?: boolean | undefined;
|
|
62
|
+
parseChannels?: boolean | undefined;
|
|
60
63
|
saveParsedSpecFile?: boolean | undefined;
|
|
61
64
|
}>;
|
|
62
65
|
type Props = z.infer<typeof optionsSchema>;
|
package/dist/index.js
CHANGED
|
@@ -36,6 +36,12 @@ module.exports = __toCommonJS(src_exports);
|
|
|
36
36
|
var import_parser = require("@asyncapi/parser");
|
|
37
37
|
var import_sdk = __toESM(require("@eventcatalog/sdk"));
|
|
38
38
|
var import_promises = require("fs/promises");
|
|
39
|
+
var import_minimist = __toESM(require("minimist"));
|
|
40
|
+
var import_js_yaml = __toESM(require("js-yaml"));
|
|
41
|
+
var import_zod = require("zod");
|
|
42
|
+
var import_chalk2 = __toESM(require("chalk"));
|
|
43
|
+
var import_path = __toESM(require("path"));
|
|
44
|
+
var import_avro_schema_parser = require("@asyncapi/avro-schema-parser");
|
|
39
45
|
|
|
40
46
|
// src/utils/schemas.ts
|
|
41
47
|
var getFileExtentionFromSchemaFormat = (format = "") => {
|
|
@@ -93,6 +99,30 @@ var getSchemaFileName = (message) => {
|
|
|
93
99
|
var getMessageName = (message) => {
|
|
94
100
|
return message.hasTitle() && message.title() ? message.title() : message.id();
|
|
95
101
|
};
|
|
102
|
+
var getChannelsForMessage = (message, channels, document) => {
|
|
103
|
+
let channelsForMessage = [];
|
|
104
|
+
const globalVersion = document.info().version();
|
|
105
|
+
for (const channel of channels) {
|
|
106
|
+
for (const channelMessage of channel.messages()) {
|
|
107
|
+
if (channelMessage.id() === message.id()) {
|
|
108
|
+
channelsForMessage.push(channel);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
for (const messageChannel of message.channels()) {
|
|
113
|
+
channelsForMessage.push(messageChannel);
|
|
114
|
+
}
|
|
115
|
+
const uniqueChannels = channelsForMessage.filter(
|
|
116
|
+
(channel, index, self) => index === self.findIndex((t) => t.id() === channel.id())
|
|
117
|
+
);
|
|
118
|
+
return uniqueChannels.map((channel) => {
|
|
119
|
+
const channelVersion = channel.extensions().get("x-eventcatalog-channel-version")?.value() || globalVersion;
|
|
120
|
+
return {
|
|
121
|
+
id: channel.id(),
|
|
122
|
+
version: channelVersion
|
|
123
|
+
};
|
|
124
|
+
});
|
|
125
|
+
};
|
|
96
126
|
|
|
97
127
|
// src/utils/services.ts
|
|
98
128
|
var defaultMarkdown2 = (document) => {
|
|
@@ -124,8 +154,31 @@ var defaultMarkdown3 = (document) => {
|
|
|
124
154
|
`;
|
|
125
155
|
};
|
|
126
156
|
|
|
127
|
-
// src/
|
|
128
|
-
var
|
|
157
|
+
// src/utils/channels.ts
|
|
158
|
+
var getChannelProtocols = (channel) => {
|
|
159
|
+
const protocols = [];
|
|
160
|
+
const bindings = channel.bindings();
|
|
161
|
+
for (const binding of bindings) {
|
|
162
|
+
protocols.push(binding.protocol());
|
|
163
|
+
}
|
|
164
|
+
return protocols;
|
|
165
|
+
};
|
|
166
|
+
var defaultMarkdown4 = (_document, channel) => {
|
|
167
|
+
return `
|
|
168
|
+
${channel.hasDescription() ? `
|
|
169
|
+
## Overview
|
|
170
|
+
${channel.description()}
|
|
171
|
+
` : ""}
|
|
172
|
+
|
|
173
|
+
<ChannelInformation />
|
|
174
|
+
|
|
175
|
+
${channel.json()?.externalDocs ? `
|
|
176
|
+
## External documentation
|
|
177
|
+
- [${channel.json()?.externalDocs?.description}](${channel.json()?.externalDocs?.url})
|
|
178
|
+
` : ""}
|
|
179
|
+
|
|
180
|
+
`;
|
|
181
|
+
};
|
|
129
182
|
|
|
130
183
|
// src/checkLicense.ts
|
|
131
184
|
var import_chalk = __toESM(require("chalk"));
|
|
@@ -141,11 +194,6 @@ If using for internal, commercial or proprietary software, you can purchase a li
|
|
|
141
194
|
};
|
|
142
195
|
|
|
143
196
|
// src/index.ts
|
|
144
|
-
var import_minimist = __toESM(require("minimist"));
|
|
145
|
-
var import_js_yaml = __toESM(require("js-yaml"));
|
|
146
|
-
var import_zod = require("zod");
|
|
147
|
-
var import_avro_schema_parser = require("@asyncapi/avro-schema-parser");
|
|
148
|
-
var import_path = __toESM(require("path"));
|
|
149
197
|
var parser = new import_parser.Parser();
|
|
150
198
|
parser.registerSchemaParser((0, import_avro_schema_parser.AvroSchemaParser)());
|
|
151
199
|
var cliArgs = (0, import_minimist.default)(process.argv.slice(2));
|
|
@@ -165,6 +213,7 @@ var optionsSchema = import_zod.z.object({
|
|
|
165
213
|
}).optional(),
|
|
166
214
|
debug: import_zod.z.boolean().optional(),
|
|
167
215
|
parseSchemas: import_zod.z.boolean().optional(),
|
|
216
|
+
parseChannels: import_zod.z.boolean().optional(),
|
|
168
217
|
saveParsedSpecFile: import_zod.z.boolean({ invalid_type_error: "The saveParsedSpecFile is not a boolean in options" }).optional()
|
|
169
218
|
});
|
|
170
219
|
var validateOptions = (options) => {
|
|
@@ -185,16 +234,12 @@ var src_default = async (config, options) => {
|
|
|
185
234
|
writeQuery,
|
|
186
235
|
getService,
|
|
187
236
|
versionService,
|
|
188
|
-
rmService,
|
|
189
237
|
getDomain,
|
|
190
238
|
writeDomain,
|
|
191
239
|
addServiceToDomain,
|
|
192
240
|
getCommand,
|
|
193
241
|
getEvent,
|
|
194
242
|
getQuery,
|
|
195
|
-
rmEventById,
|
|
196
|
-
rmCommandById,
|
|
197
|
-
rmQueryById,
|
|
198
243
|
versionCommand,
|
|
199
244
|
versionEvent,
|
|
200
245
|
versionQuery,
|
|
@@ -203,33 +248,33 @@ var src_default = async (config, options) => {
|
|
|
203
248
|
addSchemaToQuery,
|
|
204
249
|
addFileToService,
|
|
205
250
|
versionDomain,
|
|
206
|
-
getSpecificationFilesForService
|
|
251
|
+
getSpecificationFilesForService,
|
|
252
|
+
writeChannel,
|
|
253
|
+
getChannel,
|
|
254
|
+
versionChannel
|
|
207
255
|
} = (0, import_sdk.default)(process.env.PROJECT_DIR);
|
|
208
256
|
const MESSAGE_OPERATIONS = {
|
|
209
257
|
event: {
|
|
210
258
|
write: writeEvent,
|
|
211
259
|
version: versionEvent,
|
|
212
260
|
get: getEvent,
|
|
213
|
-
remove: rmEventById,
|
|
214
261
|
addSchema: addSchemaToEvent
|
|
215
262
|
},
|
|
216
263
|
command: {
|
|
217
264
|
write: writeCommand,
|
|
218
265
|
version: versionCommand,
|
|
219
266
|
get: getCommand,
|
|
220
|
-
remove: rmCommandById,
|
|
221
267
|
addSchema: addSchemaToCommand
|
|
222
268
|
},
|
|
223
269
|
query: {
|
|
224
270
|
write: writeQuery,
|
|
225
271
|
version: versionQuery,
|
|
226
272
|
get: getQuery,
|
|
227
|
-
remove: rmQueryById,
|
|
228
273
|
addSchema: addSchemaToQuery
|
|
229
274
|
}
|
|
230
275
|
};
|
|
231
276
|
validateOptions(options);
|
|
232
|
-
const { services, saveParsedSpecFile = false, parseSchemas = true } = options;
|
|
277
|
+
const { services, saveParsedSpecFile = false, parseSchemas = true, parseChannels = false } = options;
|
|
233
278
|
console.log(import_chalk2.default.green(`Processing ${services.length} AsyncAPI files...`));
|
|
234
279
|
for (const service of services) {
|
|
235
280
|
console.log(import_chalk2.default.gray(`Processing ${service.path}`));
|
|
@@ -248,6 +293,7 @@ var src_default = async (config, options) => {
|
|
|
248
293
|
continue;
|
|
249
294
|
}
|
|
250
295
|
const operations = document.allOperations();
|
|
296
|
+
const channels = document.allChannels();
|
|
251
297
|
const documentTags = document.info().tags().all() || [];
|
|
252
298
|
const serviceId = service.id;
|
|
253
299
|
const serviceName = service.name || document.info().title();
|
|
@@ -282,12 +328,57 @@ Processing domain: ${domainName} (v${domainVersion})`));
|
|
|
282
328
|
}
|
|
283
329
|
await addServiceToDomain(domainId, { id: serviceId, version }, domainVersion);
|
|
284
330
|
}
|
|
331
|
+
if (parseChannels) {
|
|
332
|
+
for (const channel of channels) {
|
|
333
|
+
const channelAsJSON = channel.json();
|
|
334
|
+
const channelId = channel.id();
|
|
335
|
+
const params = channelAsJSON?.parameters || {};
|
|
336
|
+
const protocols = getChannelProtocols(channel);
|
|
337
|
+
const channelVersion = channel.extensions().get("x-eventcatalog-channel-version")?.value() || version;
|
|
338
|
+
let channelMarkdown = defaultMarkdown4(document, channel);
|
|
339
|
+
console.log(import_chalk2.default.blue(`Processing channel: ${channelId} (v${channelVersion})`));
|
|
340
|
+
const paramsForCatalog = Object.keys(params).reduce(
|
|
341
|
+
(acc, key) => {
|
|
342
|
+
const param = params[key];
|
|
343
|
+
acc[key] = {};
|
|
344
|
+
if (param.enum) acc[key].enum = param.enum;
|
|
345
|
+
if (param.default) acc[key].default = param.default;
|
|
346
|
+
if (param.examples) acc[key].examples = param.examples;
|
|
347
|
+
if (param.description) acc[key].description = param.description;
|
|
348
|
+
return acc;
|
|
349
|
+
},
|
|
350
|
+
{}
|
|
351
|
+
);
|
|
352
|
+
const catalogedChannel = await getChannel(channelId, "latest");
|
|
353
|
+
if (catalogedChannel) {
|
|
354
|
+
channelMarkdown = catalogedChannel.markdown;
|
|
355
|
+
if (catalogedChannel.version !== channelVersion) {
|
|
356
|
+
await versionChannel(channelId);
|
|
357
|
+
console.log(import_chalk2.default.cyan(` - Versioned previous channel: ${channelId} (v${channelVersion})`));
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
await writeChannel(
|
|
361
|
+
{
|
|
362
|
+
id: channelId,
|
|
363
|
+
name: channelAsJSON?.title || channel.id(),
|
|
364
|
+
markdown: channelMarkdown,
|
|
365
|
+
version: channelVersion,
|
|
366
|
+
...Object.keys(paramsForCatalog).length > 0 && { parameters: paramsForCatalog },
|
|
367
|
+
...channel.address() && { address: channel.address() },
|
|
368
|
+
...channelAsJSON?.summary && { summary: channelAsJSON.summary },
|
|
369
|
+
...protocols.length > 0 && { protocols }
|
|
370
|
+
},
|
|
371
|
+
{ override: true }
|
|
372
|
+
);
|
|
373
|
+
console.log(import_chalk2.default.cyan(` - Message ${channelId} (v${version}) created`));
|
|
374
|
+
}
|
|
375
|
+
}
|
|
285
376
|
for (const operation of operations) {
|
|
286
377
|
for (const message of operation.messages()) {
|
|
287
378
|
const eventType = message.extensions().get("x-eventcatalog-message-type")?.value() || "event";
|
|
288
379
|
const messageVersion = message.extensions().get("x-eventcatalog-message-version")?.value() || version;
|
|
289
380
|
const serviceOwnsMessageContract = isServiceMessageOwner(message);
|
|
290
|
-
const isReceived = operation.action() === "receive" || operation.action() === "
|
|
381
|
+
const isReceived = operation.action() === "receive" || operation.action() === "subscribe";
|
|
291
382
|
const isSent = operation.action() === "send" || operation.action() === "publish";
|
|
292
383
|
const messageId = message.id().toLowerCase();
|
|
293
384
|
if (eventType !== "event" && eventType !== "command" && eventType !== "query") {
|
|
@@ -297,7 +388,6 @@ Processing domain: ${domainName} (v${domainVersion})`));
|
|
|
297
388
|
write: writeMessage,
|
|
298
389
|
version: versionMessage,
|
|
299
390
|
get: getMessage,
|
|
300
|
-
remove: rmMessageById,
|
|
301
391
|
addSchema: addSchemaToMessage
|
|
302
392
|
} = MESSAGE_OPERATIONS[eventType];
|
|
303
393
|
let messageMarkdown = defaultMarkdown(document, message);
|
|
@@ -307,13 +397,12 @@ Processing domain: ${domainName} (v${domainVersion})`));
|
|
|
307
397
|
const catalogedMessage = await getMessage(message.id().toLowerCase(), "latest");
|
|
308
398
|
if (catalogedMessage) {
|
|
309
399
|
messageMarkdown = catalogedMessage.markdown;
|
|
310
|
-
if (catalogedMessage.version
|
|
311
|
-
await rmMessageById(messageId, messageVersion);
|
|
312
|
-
} else {
|
|
400
|
+
if (catalogedMessage.version !== messageVersion) {
|
|
313
401
|
await versionMessage(messageId);
|
|
314
402
|
console.log(import_chalk2.default.cyan(` - Versioned previous message: (v${catalogedMessage.version})`));
|
|
315
403
|
}
|
|
316
404
|
}
|
|
405
|
+
const channelsForMessage = parseChannels ? getChannelsForMessage(message, channels, document) : [];
|
|
317
406
|
await writeMessage(
|
|
318
407
|
{
|
|
319
408
|
id: messageId,
|
|
@@ -322,9 +411,11 @@ Processing domain: ${domainName} (v${domainVersion})`));
|
|
|
322
411
|
summary: getSummary(message),
|
|
323
412
|
markdown: messageMarkdown,
|
|
324
413
|
badges: badges.map((badge) => ({ content: badge.name(), textColor: "blue", backgroundColor: "blue" })),
|
|
325
|
-
schemaPath: messageHasSchema(message) ? getSchemaFileName(message) : void 0
|
|
414
|
+
schemaPath: messageHasSchema(message) ? getSchemaFileName(message) : void 0,
|
|
415
|
+
...channelsForMessage.length > 0 && { channels: channelsForMessage }
|
|
326
416
|
},
|
|
327
417
|
{
|
|
418
|
+
override: true,
|
|
328
419
|
path: message.id()
|
|
329
420
|
}
|
|
330
421
|
);
|
|
@@ -362,25 +453,29 @@ Processing domain: ${domainName} (v${domainVersion})`));
|
|
|
362
453
|
sends = latestServiceInCatalog.sends ? [...latestServiceInCatalog.sends, ...sends] : sends;
|
|
363
454
|
receives = latestServiceInCatalog.receives ? [...latestServiceInCatalog.receives, ...receives] : receives;
|
|
364
455
|
serviceSpecificationsFiles = await getSpecificationFilesForService(serviceId, version);
|
|
365
|
-
await rmService(serviceId);
|
|
366
456
|
}
|
|
367
457
|
}
|
|
368
458
|
const fileName = import_path.default.basename(service.path);
|
|
369
|
-
await writeService(
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
459
|
+
await writeService(
|
|
460
|
+
{
|
|
461
|
+
id: serviceId,
|
|
462
|
+
name: serviceName,
|
|
463
|
+
version,
|
|
464
|
+
summary: getSummary2(document),
|
|
465
|
+
badges: documentTags.map((tag) => ({ content: tag.name(), textColor: "blue", backgroundColor: "blue" })),
|
|
466
|
+
markdown: serviceMarkdown,
|
|
467
|
+
sends,
|
|
468
|
+
receives,
|
|
469
|
+
schemaPath: fileName || "asyncapi.yml",
|
|
470
|
+
specifications: {
|
|
471
|
+
...serviceSpecifications,
|
|
472
|
+
asyncapiPath: fileName || "asyncapi.yml"
|
|
473
|
+
}
|
|
474
|
+
},
|
|
475
|
+
{
|
|
476
|
+
override: true
|
|
382
477
|
}
|
|
383
|
-
|
|
478
|
+
);
|
|
384
479
|
const specFiles = [
|
|
385
480
|
// add any previous spec files to the list
|
|
386
481
|
...serviceSpecificationsFiles,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/utils/schemas.ts","../src/utils/messages.ts","../src/utils/services.ts","../src/utils/domains.ts","../src/checkLicense.ts"],"sourcesContent":["// import utils from '@eventcatalog/sdk';\nimport { AsyncAPIDocumentInterface, MessageInterface, Parser, fromFile, fromURL } from '@asyncapi/parser';\nimport utils from '@eventcatalog/sdk';\nimport { readFile } from 'node:fs/promises';\nimport {\n defaultMarkdown as generateMarkdownForMessage,\n getMessageName,\n getSummary as getMessageSummary,\n getSchemaFileName,\n messageHasSchema,\n} from './utils/messages';\nimport { defaultMarkdown as generateMarkdownForService, getSummary as getServiceSummary } from './utils/services';\nimport { defaultMarkdown as generateMarkdownForDomain } from './utils/domains';\nimport chalk from 'chalk';\nimport checkLicense from './checkLicense';\nimport argv from 'minimist';\nimport yaml from 'js-yaml';\nimport { z } from 'zod';\n\n// AsyncAPI Parsers\nimport { AvroSchemaParser } from '@asyncapi/avro-schema-parser';\nimport path from 'path';\nimport { EventType, MessageOperations } from './types';\n\nconst parser = new Parser();\n\n// register avro schema support\nparser.registerSchemaParser(AvroSchemaParser());\nconst cliArgs = argv(process.argv.slice(2));\n\nconst optionsSchema = z.object({\n services: z.array(\n z.object({\n id: z.string({ required_error: 'The service id is required. please provide the service id' }),\n path: z.string({ required_error: 'The service path is required. please provide the path to specification file' }),\n name: z.string().optional(),\n }),\n { message: 'Please provide correct services configuration' }\n ),\n domain: z\n .object({\n id: z.string({ required_error: 'The domain id is required. please provide a domain id' }),\n name: z.string({ required_error: 'The domain name is required. please provide a domain name' }),\n version: z.string({ required_error: 'The domain version is required. please provide a domain version' }),\n })\n .optional(),\n debug: z.boolean().optional(),\n parseSchemas: z.boolean().optional(),\n saveParsedSpecFile: z.boolean({ invalid_type_error: 'The saveParsedSpecFile is not a boolean in options' }).optional(),\n});\n\ntype Props = z.infer<typeof optionsSchema>;\ntype Domain = z.infer<typeof optionsSchema>['domain'];\ntype Service = z.infer<typeof optionsSchema>['services'][0];\n\nconst validateOptions = (options: Props) => {\n try {\n optionsSchema.parse(options);\n } catch (error: any) {\n if (error instanceof z.ZodError) throw new Error(JSON.stringify(error.issues, null, 2));\n }\n};\n\nexport default async (config: any, options: Props) => {\n if (!process.env.PROJECT_DIR) {\n throw new Error('Please provide catalog url (env variable PROJECT_DIR)');\n }\n\n const {\n writeService,\n writeEvent,\n writeCommand,\n writeQuery,\n getService,\n versionService,\n rmService,\n getDomain,\n writeDomain,\n addServiceToDomain,\n getCommand,\n getEvent,\n getQuery,\n rmEventById,\n rmCommandById,\n rmQueryById,\n versionCommand,\n versionEvent,\n versionQuery,\n addSchemaToCommand,\n addSchemaToEvent,\n addSchemaToQuery,\n addFileToService,\n versionDomain,\n getSpecificationFilesForService,\n } = utils(process.env.PROJECT_DIR);\n\n // Define the message operations mapping with proper types\n const MESSAGE_OPERATIONS: Record<EventType, MessageOperations> = {\n event: {\n write: writeEvent,\n version: versionEvent,\n get: getEvent,\n remove: rmEventById,\n addSchema: addSchemaToEvent,\n },\n command: {\n write: writeCommand,\n version: versionCommand,\n get: getCommand,\n remove: rmCommandById,\n addSchema: addSchemaToCommand,\n },\n query: {\n write: writeQuery,\n version: versionQuery,\n get: getQuery,\n remove: rmQueryById,\n addSchema: addSchemaToQuery,\n },\n };\n\n // Should the file that is written to the catalog be parsed (https://github.com/asyncapi/parser-js) or as it is?\n validateOptions(options);\n const { services, saveParsedSpecFile = false, parseSchemas = true } = options;\n // const asyncAPIFiles = Array.isArray(options.path) ? options.path : [options.path];\n console.log(chalk.green(`Processing ${services.length} AsyncAPI files...`));\n for (const service of services) {\n console.log(chalk.gray(`Processing ${service.path}`));\n\n const { document, diagnostics } = service.path.startsWith('http')\n ? await fromURL(parser, service.path).parse({\n parseSchemas,\n })\n : await fromFile(parser, service.path).parse({\n parseSchemas,\n });\n\n if (!document) {\n console.log(chalk.red('Failed to parse AsyncAPI file'));\n if (options.debug || cliArgs.debug) {\n console.log(diagnostics);\n } else {\n console.log(chalk.red('Run with debug option in the generator to see diagnostics'));\n }\n continue;\n }\n\n const operations = document.allOperations();\n const documentTags = document.info().tags().all() || [];\n\n const serviceId = service.id;\n\n const serviceName = service.name || document.info().title();\n const version = document.info().version();\n\n // What messages does this service send and receive\n let sends = [];\n let receives = [];\n\n let serviceSpecifications = {};\n let serviceSpecificationsFiles = [];\n let serviceMarkdown = generateMarkdownForService(document);\n\n // Manage domain\n if (options.domain) {\n // Try and get the domain\n const { id: domainId, name: domainName, version: domainVersion } = options.domain;\n const domain = await getDomain(options.domain.id, domainVersion || 'latest');\n const currentDomain = await getDomain(options.domain.id, 'latest');\n\n console.log(chalk.blue(`\\nProcessing domain: ${domainName} (v${domainVersion})`));\n\n // Found a domain, but the versions do not match\n if (currentDomain && currentDomain.version !== domainVersion) {\n await versionDomain(domainId);\n console.log(chalk.cyan(` - Versioned previous domain (v${currentDomain.version})`));\n }\n\n // Do we need to create a new domain?\n if (!domain || (domain && domain.version !== domainVersion)) {\n await writeDomain({\n id: domainId,\n name: domainName,\n version: domainVersion,\n markdown: generateMarkdownForDomain(document),\n // services: [{ id: serviceId, version: version }],\n });\n console.log(chalk.cyan(` - Domain (v${domainVersion}) created`));\n }\n\n if (currentDomain && currentDomain.version === domainVersion) {\n console.log(chalk.yellow(` - Domain (v${domainVersion}) already exists, skipped creation...`));\n }\n\n // Add the service to the domain\n await addServiceToDomain(domainId, { id: serviceId, version: version }, domainVersion);\n }\n\n // Find events/commands\n for (const operation of operations) {\n for (const message of operation.messages()) {\n const eventType = (message.extensions().get('x-eventcatalog-message-type')?.value() as EventType) || 'event';\n const messageVersion = message.extensions().get('x-eventcatalog-message-version')?.value() || version;\n\n // does this service own or just consume the message?\n const serviceOwnsMessageContract = isServiceMessageOwner(message);\n const isReceived = operation.action() === 'receive' || operation.action() === 'receive';\n const isSent = operation.action() === 'send' || operation.action() === 'publish';\n\n const messageId = message.id().toLowerCase();\n\n if (eventType !== 'event' && eventType !== 'command' && eventType !== 'query') {\n throw new Error('Invalid message type');\n }\n\n const {\n write: writeMessage,\n version: versionMessage,\n get: getMessage,\n remove: rmMessageById,\n addSchema: addSchemaToMessage,\n } = MESSAGE_OPERATIONS[eventType];\n\n let messageMarkdown = generateMarkdownForMessage(document, message);\n const badges = message.tags().all() || [];\n\n console.log(chalk.blue(`Processing message: ${getMessageName(message)} (v${messageVersion})`));\n\n if (serviceOwnsMessageContract) {\n // Check if the message already exists in the catalog\n const catalogedMessage = await getMessage(message.id().toLowerCase(), 'latest');\n\n if (catalogedMessage) {\n messageMarkdown = catalogedMessage.markdown;\n // if the version matches, we can override the message but keep markdown as it was\n if (catalogedMessage.version === messageVersion) {\n await rmMessageById(messageId, messageVersion);\n } else {\n // if the version does not match, we need to version the message\n await versionMessage(messageId);\n console.log(chalk.cyan(` - Versioned previous message: (v${catalogedMessage.version})`));\n }\n }\n\n // Write the message to the catalog\n await writeMessage(\n {\n id: messageId,\n version: messageVersion,\n name: getMessageName(message),\n summary: getMessageSummary(message),\n markdown: messageMarkdown,\n badges: badges.map((badge) => ({ content: badge.name(), textColor: 'blue', backgroundColor: 'blue' })),\n schemaPath: messageHasSchema(message) ? getSchemaFileName(message) : undefined,\n },\n {\n path: message.id(),\n }\n );\n\n console.log(chalk.cyan(` - Message (v${messageVersion}) created`));\n // Check if the message has a payload, if it does then document in EventCatalog\n if (messageHasSchema(message)) {\n // Get the schema from the original payload if it exists\n const schema = message.payload()?.extensions()?.get('x-parser-original-payload')?.json() || message.payload()?.json();\n\n await addSchemaToMessage(\n messageId,\n {\n fileName: getSchemaFileName(message),\n schema: JSON.stringify(schema, null, 4),\n },\n messageVersion\n );\n console.log(chalk.cyan(` - Schema added to message (v${messageVersion})`));\n }\n } else {\n // Message is not owned by this service, therefore we don't need to document it\n console.log(chalk.yellow(` - Skipping external message: ${getMessageName(message)}(v${messageVersion})`));\n }\n // Add the message to the correct array\n if (isSent) sends.push({ id: messageId, version: messageVersion });\n if (isReceived) receives.push({ id: messageId, version: messageVersion });\n }\n }\n\n // Check if service is already defined... if the versions do not match then create service.\n const latestServiceInCatalog = await getService(serviceId, 'latest');\n\n console.log(chalk.blue(`Processing service: ${serviceId} (v${version})`));\n\n if (latestServiceInCatalog) {\n serviceMarkdown = latestServiceInCatalog.markdown;\n // Found a service, and versions do not match, we need to version the one already there\n if (latestServiceInCatalog.version !== version) {\n await versionService(serviceId);\n console.log(chalk.cyan(` - Versioned previous service (v${latestServiceInCatalog.version})`));\n }\n\n // Match found, override it\n if (latestServiceInCatalog.version === version) {\n // we want to preserve the markdown any any spec files that are already there\n serviceMarkdown = latestServiceInCatalog.markdown;\n serviceSpecifications = latestServiceInCatalog.specifications ?? {};\n sends = latestServiceInCatalog.sends ? [...latestServiceInCatalog.sends, ...sends] : sends;\n receives = latestServiceInCatalog.receives ? [...latestServiceInCatalog.receives, ...receives] : receives;\n serviceSpecificationsFiles = await getSpecificationFilesForService(serviceId, version);\n await rmService(serviceId);\n }\n }\n\n const fileName = path.basename(service.path);\n\n await writeService({\n id: serviceId,\n name: serviceName,\n version: version,\n summary: getServiceSummary(document),\n badges: documentTags.map((tag) => ({ content: tag.name(), textColor: 'blue', backgroundColor: 'blue' })),\n markdown: serviceMarkdown,\n sends,\n receives,\n schemaPath: fileName || 'asyncapi.yml',\n specifications: {\n ...serviceSpecifications,\n asyncapiPath: fileName || 'asyncapi.yml',\n },\n });\n\n // What files need added to the service (speficiation files)\n const specFiles = [\n // add any previous spec files to the list\n ...serviceSpecificationsFiles,\n {\n content: saveParsedSpecFile ? getParsedSpecFile(service, document) : await getRawSpecFile(service),\n fileName: path.basename(service.path) || 'asyncapi.yml',\n },\n ];\n\n for (const specFile of specFiles) {\n await addFileToService(\n serviceId,\n {\n fileName: specFile.fileName,\n content: specFile.content,\n },\n version\n );\n }\n\n console.log(chalk.cyan(` - Service (v${version}) created`));\n\n console.log(chalk.green(`\\nFinished generating event catalog for AsyncAPI ${serviceId} (v${version})`));\n }\n\n await checkLicense();\n};\n\nconst getParsedSpecFile = (service: Service, document: AsyncAPIDocumentInterface) => {\n const isSpecFileJSON = service.path.endsWith('.json');\n return isSpecFileJSON\n ? JSON.stringify(document.meta().asyncapi.parsed, null, 4)\n : yaml.dump(document.meta().asyncapi.parsed, { noRefs: true });\n};\n\nconst getRawSpecFile = async (service: Service) => {\n if (service.path.startsWith('http')) {\n try {\n const response = await fetch(service.path);\n return response.text();\n } catch (error) {\n console.log(chalk.red(`\\nFailed to request AsyncAPI file from ${service.path}`));\n return '';\n }\n } else {\n return await readFile(service.path, 'utf8');\n }\n};\n/**\n * Is the AsyncAPI specification (service) the owner of the message?\n * This is determined by the 'x-eventcatalog-role' extension in the message\n *\n * @param message\n * @returns boolean\n *\n * default is provider (AsyncAPI file / service owns the message)\n */\nconst isServiceMessageOwner = (message: MessageInterface): boolean => {\n const value = message.extensions().get('x-eventcatalog-role')?.value() || 'provider';\n return value === 'provider';\n};\n","export const getFileExtentionFromSchemaFormat = (format: string | undefined = '') => {\n if (format.includes('avro')) return 'avsc';\n if (format.includes('yml')) return 'yml';\n if (format.includes('json')) return 'json';\n if (format.includes('openapi')) return 'openapi';\n if (format.includes('protobuf')) return 'protobuf';\n if (format.includes('yaml')) return 'yaml';\n\n return 'json';\n};\n","import { MessageInterface, AsyncAPIDocumentInterface } from '@asyncapi/parser';\nimport { getFileExtentionFromSchemaFormat } from './schemas';\n\nexport const defaultMarkdown = (_document: AsyncAPIDocumentInterface, message: MessageInterface) => {\n return `\n## Architecture\n<NodeGraph />\n\n${\n messageHasSchema(message) && messageIsJSON(message)\n ? `\n## Schema\n<SchemaViewer file=\"${getSchemaFileName(message)}\" title=\"Message Schema\" maxHeight=\"500\" />\n`\n : ''\n}\n${\n messageHasSchema(message) && !messageIsJSON(message)\n ? `\n## Schema\n<Schema file=\"${getSchemaFileName(message)}\" title=\"Message Schema\" maxHeight=\"500\" />\n`\n : ''\n}\n\n${\n message.externalDocs()\n ? `\n## External documentation\n- [${message.externalDocs()?.description()}](${message.externalDocs()?.url()})\n`\n : ''\n}\n\n`;\n};\n\nexport const getSummary = (message: MessageInterface) => {\n const messageSummary = message.hasSummary() ? message.summary() : '';\n const messageDescription = message.hasDescription() ? message.description() : '';\n\n let eventCatalogMessageSummary = messageSummary;\n\n if (!eventCatalogMessageSummary) {\n eventCatalogMessageSummary = messageDescription && messageDescription.length < 150 ? messageDescription : '';\n }\n\n return eventCatalogMessageSummary;\n};\n\nexport const messageHasSchema = (message: MessageInterface) => {\n return message.hasPayload() && message.schemaFormat();\n};\n\nexport const messageIsJSON = (message: MessageInterface) => {\n const fileName = getSchemaFileName(message);\n return fileName.endsWith('.json');\n};\n\nexport const getSchemaFileName = (message: MessageInterface) => {\n const extension = getFileExtentionFromSchemaFormat(message.schemaFormat());\n return `schema.${extension}`;\n};\n\nexport const getMessageName = (message: MessageInterface) => {\n return message.hasTitle() && message.title() ? (message.title() as string) : message.id();\n};\n","import { AsyncAPIDocumentInterface } from '@asyncapi/parser';\n\nexport const defaultMarkdown = (document: AsyncAPIDocumentInterface) => {\n return `\n\n${document.info().hasDescription() ? `${document.info().description()}` : ''} \n\n## Architecture diagram\n<NodeGraph />\n\n${\n document.info().externalDocs()\n ? `\n## External documentation\n- [${document.info().externalDocs()?.description()}](${document.info().externalDocs()?.url()})\n`\n : ''\n}\n`;\n};\n\nexport const getSummary = (document: AsyncAPIDocumentInterface) => {\n const summary = document.info().hasDescription() ? document.info().description() : '';\n return summary && summary.length < 150 ? summary : '';\n};\n","import { AsyncAPIDocumentInterface } from '@asyncapi/parser';\n\nexport const defaultMarkdown = (document: AsyncAPIDocumentInterface) => {\n return `\n\n## Architecture diagram\n<NodeGraph />\n\n`;\n};\n","import chalk from 'chalk';\n\nexport default () => {\n console.log(chalk.bgBlue(`\\nYou are using the open source license for this plugin`));\n console.log(\n chalk.blueBright(\n `This plugin is governed and published under a dual-license. \\nIf using for internal, commercial or proprietary software, 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;AACA,oBAAuF;AACvF,iBAAkB;AAClB,sBAAyB;;;ACHlB,IAAM,mCAAmC,CAAC,SAA6B,OAAO;AACnF,MAAI,OAAO,SAAS,MAAM,EAAG,QAAO;AACpC,MAAI,OAAO,SAAS,KAAK,EAAG,QAAO;AACnC,MAAI,OAAO,SAAS,MAAM,EAAG,QAAO;AACpC,MAAI,OAAO,SAAS,SAAS,EAAG,QAAO;AACvC,MAAI,OAAO,SAAS,UAAU,EAAG,QAAO;AACxC,MAAI,OAAO,SAAS,MAAM,EAAG,QAAO;AAEpC,SAAO;AACT;;;ACNO,IAAM,kBAAkB,CAAC,WAAsC,YAA8B;AAClG,SAAO;AAAA;AAAA;AAAA;AAAA,EAKP,iBAAiB,OAAO,KAAK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AAAI,QAAK,KAAK,SAAS,KAAK,EAAE,SAAS,QAAQ,EAAE,QAAQ,KAAK,CAAC;AACjE;AAEA,IAAM,iBAAiB,OAAO,YAAqB;AACjD,MAAI,QAAQ,KAAK,WAAW,MAAM,GAAG;AACnC,QAAI;AACF,YAAM,WAAW,MAAM,MAAM,QAAQ,IAAI;AACzC,aAAO,SAAS,KAAK;AAAA,IACvB,SAAS,OAAO;AACd,cAAQ,IAAI,cAAAJ,QAAM,IAAI;AAAA,uCAA0C,QAAQ,IAAI,EAAE,CAAC;AAC/E,aAAO;AAAA,IACT;AAAA,EACF,OAAO;AACL,WAAO,UAAM,0BAAS,QAAQ,MAAM,MAAM;AAAA,EAC5C;AACF;AAUA,IAAM,wBAAwB,CAAC,YAAuC;AACpE,QAAM,QAAQ,QAAQ,WAAW,EAAE,IAAI,qBAAqB,GAAG,MAAM,KAAK;AAC1E,SAAO,UAAU;AACnB;","names":["defaultMarkdown","getSummary","defaultMarkdown","import_chalk","chalk","argv","utils","chalk","defaultMarkdown","path","getSummary","yaml"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/utils/schemas.ts","../src/utils/messages.ts","../src/utils/services.ts","../src/utils/domains.ts","../src/utils/channels.ts","../src/checkLicense.ts"],"sourcesContent":["import { AsyncAPIDocumentInterface, MessageInterface, Parser, fromFile, fromURL } from '@asyncapi/parser';\nimport utils from '@eventcatalog/sdk';\nimport { readFile } from 'node:fs/promises';\nimport argv from 'minimist';\nimport yaml from 'js-yaml';\nimport { z } from 'zod';\nimport chalk from 'chalk';\nimport path from 'path';\n\n// AsyncAPI Parsers\nimport { AvroSchemaParser } from '@asyncapi/avro-schema-parser';\n\nimport {\n defaultMarkdown as generateMarkdownForMessage,\n getChannelsForMessage,\n getMessageName,\n getSummary as getMessageSummary,\n getSchemaFileName,\n messageHasSchema,\n} from './utils/messages';\nimport { defaultMarkdown as generateMarkdownForService, getSummary as getServiceSummary } from './utils/services';\nimport { defaultMarkdown as generateMarkdownForDomain } from './utils/domains';\nimport { defaultMarkdown as generateMarkdownForChannel, getChannelProtocols } from './utils/channels';\nimport checkLicense from './checkLicense';\n\nimport { EventType, MessageOperations } from './types';\n\nconst parser = new Parser();\n\n// register avro schema support\nparser.registerSchemaParser(AvroSchemaParser());\nconst cliArgs = argv(process.argv.slice(2));\n\nconst optionsSchema = z.object({\n services: z.array(\n z.object({\n id: z.string({ required_error: 'The service id is required. please provide the service id' }),\n path: z.string({ required_error: 'The service path is required. please provide the path to specification file' }),\n name: z.string().optional(),\n }),\n { message: 'Please provide correct services configuration' }\n ),\n domain: z\n .object({\n id: z.string({ required_error: 'The domain id is required. please provide a domain id' }),\n name: z.string({ required_error: 'The domain name is required. please provide a domain name' }),\n version: z.string({ required_error: 'The domain version is required. please provide a domain version' }),\n })\n .optional(),\n debug: z.boolean().optional(),\n parseSchemas: z.boolean().optional(),\n parseChannels: z.boolean().optional(),\n saveParsedSpecFile: z.boolean({ invalid_type_error: 'The saveParsedSpecFile is not a boolean in options' }).optional(),\n});\n\ntype Props = z.infer<typeof optionsSchema>;\ntype Domain = z.infer<typeof optionsSchema>['domain'];\ntype Service = z.infer<typeof optionsSchema>['services'][0];\n\nconst validateOptions = (options: Props) => {\n try {\n optionsSchema.parse(options);\n } catch (error: any) {\n if (error instanceof z.ZodError) throw new Error(JSON.stringify(error.issues, null, 2));\n }\n};\n\nexport default async (config: any, options: Props) => {\n if (!process.env.PROJECT_DIR) {\n throw new Error('Please provide catalog url (env variable PROJECT_DIR)');\n }\n\n const {\n writeService,\n writeEvent,\n writeCommand,\n writeQuery,\n getService,\n versionService,\n getDomain,\n writeDomain,\n addServiceToDomain,\n getCommand,\n getEvent,\n getQuery,\n versionCommand,\n versionEvent,\n versionQuery,\n addSchemaToCommand,\n addSchemaToEvent,\n addSchemaToQuery,\n addFileToService,\n versionDomain,\n getSpecificationFilesForService,\n writeChannel,\n getChannel,\n versionChannel,\n } = utils(process.env.PROJECT_DIR);\n\n // Define the message operations mapping with proper types\n const MESSAGE_OPERATIONS: Record<EventType, MessageOperations> = {\n event: {\n write: writeEvent,\n version: versionEvent,\n get: getEvent,\n addSchema: addSchemaToEvent,\n },\n command: {\n write: writeCommand,\n version: versionCommand,\n get: getCommand,\n addSchema: addSchemaToCommand,\n },\n query: {\n write: writeQuery,\n version: versionQuery,\n get: getQuery,\n addSchema: addSchemaToQuery,\n },\n };\n\n // Should the file that is written to the catalog be parsed (https://github.com/asyncapi/parser-js) or as it is?\n validateOptions(options);\n\n const { services, saveParsedSpecFile = false, parseSchemas = true, parseChannels = false } = options;\n // const asyncAPIFiles = Array.isArray(options.path) ? options.path : [options.path];\n console.log(chalk.green(`Processing ${services.length} AsyncAPI files...`));\n for (const service of services) {\n console.log(chalk.gray(`Processing ${service.path}`));\n\n const { document, diagnostics } = service.path.startsWith('http')\n ? await fromURL(parser, service.path).parse({\n parseSchemas,\n })\n : await fromFile(parser, service.path).parse({\n parseSchemas,\n });\n\n if (!document) {\n console.log(chalk.red('Failed to parse AsyncAPI file'));\n if (options.debug || cliArgs.debug) {\n console.log(diagnostics);\n } else {\n console.log(chalk.red('Run with debug option in the generator to see diagnostics'));\n }\n continue;\n }\n\n const operations = document.allOperations();\n const channels = document.allChannels();\n const documentTags = document.info().tags().all() || [];\n\n const serviceId = service.id;\n\n const serviceName = service.name || document.info().title();\n const version = document.info().version();\n\n // What messages does this service send and receive\n let sends = [];\n let receives = [];\n\n let serviceSpecifications = {};\n let serviceSpecificationsFiles = [];\n let serviceMarkdown = generateMarkdownForService(document);\n\n // Manage domain\n if (options.domain) {\n // Try and get the domain\n const { id: domainId, name: domainName, version: domainVersion } = options.domain;\n const domain = await getDomain(options.domain.id, domainVersion || 'latest');\n const currentDomain = await getDomain(options.domain.id, 'latest');\n\n console.log(chalk.blue(`\\nProcessing domain: ${domainName} (v${domainVersion})`));\n\n // Found a domain, but the versions do not match\n if (currentDomain && currentDomain.version !== domainVersion) {\n await versionDomain(domainId);\n console.log(chalk.cyan(` - Versioned previous domain (v${currentDomain.version})`));\n }\n\n // Do we need to create a new domain?\n if (!domain || (domain && domain.version !== domainVersion)) {\n await writeDomain({\n id: domainId,\n name: domainName,\n version: domainVersion,\n markdown: generateMarkdownForDomain(document),\n // services: [{ id: serviceId, version: version }],\n });\n console.log(chalk.cyan(` - Domain (v${domainVersion}) created`));\n }\n\n if (currentDomain && currentDomain.version === domainVersion) {\n console.log(chalk.yellow(` - Domain (v${domainVersion}) already exists, skipped creation...`));\n }\n\n // Add the service to the domain\n await addServiceToDomain(domainId, { id: serviceId, version: version }, domainVersion);\n }\n\n // Parse channels\n if (parseChannels) {\n for (const channel of channels) {\n const channelAsJSON = channel.json();\n const channelId = channel.id();\n const params = channelAsJSON?.parameters || {};\n const protocols = getChannelProtocols(channel);\n const channelVersion = channel.extensions().get('x-eventcatalog-channel-version')?.value() || version;\n let channelMarkdown = generateMarkdownForChannel(document, channel);\n\n console.log(chalk.blue(`Processing channel: ${channelId} (v${channelVersion})`));\n\n const paramsForCatalog = Object.keys(params).reduce(\n (acc, key) => {\n const param = params[key];\n acc[key] = {};\n if (param.enum) acc[key].enum = param.enum;\n if (param.default) acc[key].default = param.default;\n if (param.examples) acc[key].examples = param.examples;\n if (param.description) acc[key].description = param.description;\n return acc;\n },\n {} as Record<string, { enum?: string[]; default?: string; examples?: string[]; description?: string }>\n );\n\n const catalogedChannel = await getChannel(channelId, 'latest');\n\n if (catalogedChannel) {\n channelMarkdown = catalogedChannel.markdown;\n if (catalogedChannel.version !== channelVersion) {\n await versionChannel(channelId);\n console.log(chalk.cyan(` - Versioned previous channel: ${channelId} (v${channelVersion})`));\n }\n }\n\n await writeChannel(\n {\n id: channelId,\n name: channelAsJSON?.title || channel.id(),\n markdown: channelMarkdown,\n version: channelVersion,\n ...(Object.keys(paramsForCatalog).length > 0 && { parameters: paramsForCatalog }),\n ...(channel.address() && { address: channel.address() }),\n ...(channelAsJSON?.summary && { summary: channelAsJSON.summary }),\n ...(protocols.length > 0 && { protocols }),\n },\n { override: true }\n );\n\n console.log(chalk.cyan(` - Message ${channelId} (v${version}) created`));\n }\n }\n\n // Find events/commands\n for (const operation of operations) {\n for (const message of operation.messages()) {\n const eventType = (message.extensions().get('x-eventcatalog-message-type')?.value() as EventType) || 'event';\n const messageVersion = message.extensions().get('x-eventcatalog-message-version')?.value() || version;\n\n // does this service own or just consume the message?\n const serviceOwnsMessageContract = isServiceMessageOwner(message);\n const isReceived = operation.action() === 'receive' || operation.action() === 'subscribe';\n const isSent = operation.action() === 'send' || operation.action() === 'publish';\n\n const messageId = message.id().toLowerCase();\n\n if (eventType !== 'event' && eventType !== 'command' && eventType !== 'query') {\n throw new Error('Invalid message type');\n }\n\n const {\n write: writeMessage,\n version: versionMessage,\n get: getMessage,\n addSchema: addSchemaToMessage,\n } = MESSAGE_OPERATIONS[eventType];\n\n let messageMarkdown = generateMarkdownForMessage(document, message);\n const badges = message.tags().all() || [];\n\n console.log(chalk.blue(`Processing message: ${getMessageName(message)} (v${messageVersion})`));\n\n if (serviceOwnsMessageContract) {\n // Check if the message already exists in the catalog\n const catalogedMessage = await getMessage(message.id().toLowerCase(), 'latest');\n\n if (catalogedMessage) {\n // persist markdown if it exists\n messageMarkdown = catalogedMessage.markdown;\n\n if (catalogedMessage.version !== messageVersion) {\n // if the version does not match, we need to version the message\n await versionMessage(messageId);\n console.log(chalk.cyan(` - Versioned previous message: (v${catalogedMessage.version})`));\n }\n }\n\n const channelsForMessage = parseChannels ? getChannelsForMessage(message, channels, document) : [];\n\n // Write the message to the catalog\n await writeMessage(\n {\n id: messageId,\n version: messageVersion,\n name: getMessageName(message),\n summary: getMessageSummary(message),\n markdown: messageMarkdown,\n badges: badges.map((badge) => ({ content: badge.name(), textColor: 'blue', backgroundColor: 'blue' })),\n schemaPath: messageHasSchema(message) ? getSchemaFileName(message) : undefined,\n ...(channelsForMessage.length > 0 && { channels: channelsForMessage }),\n },\n {\n override: true,\n path: message.id(),\n }\n );\n\n console.log(chalk.cyan(` - Message (v${messageVersion}) created`));\n // Check if the message has a payload, if it does then document in EventCatalog\n if (messageHasSchema(message)) {\n // Get the schema from the original payload if it exists\n const schema = message.payload()?.extensions()?.get('x-parser-original-payload')?.json() || message.payload()?.json();\n\n await addSchemaToMessage(\n messageId,\n {\n fileName: getSchemaFileName(message),\n schema: JSON.stringify(schema, null, 4),\n },\n messageVersion\n );\n console.log(chalk.cyan(` - Schema added to message (v${messageVersion})`));\n }\n } else {\n // Message is not owned by this service, therefore we don't need to document it\n console.log(chalk.yellow(` - Skipping external message: ${getMessageName(message)}(v${messageVersion})`));\n }\n // Add the message to the correct array\n if (isSent) sends.push({ id: messageId, version: messageVersion });\n if (isReceived) receives.push({ id: messageId, version: messageVersion });\n }\n }\n\n // Check if service is already defined... if the versions do not match then create service.\n const latestServiceInCatalog = await getService(serviceId, 'latest');\n\n console.log(chalk.blue(`Processing service: ${serviceId} (v${version})`));\n\n if (latestServiceInCatalog) {\n serviceMarkdown = latestServiceInCatalog.markdown;\n // Found a service, and versions do not match, we need to version the one already there\n if (latestServiceInCatalog.version !== version) {\n await versionService(serviceId);\n console.log(chalk.cyan(` - Versioned previous service (v${latestServiceInCatalog.version})`));\n }\n\n // Match found, persist data\n if (latestServiceInCatalog.version === version) {\n // we want to preserve the markdown any any spec files that are already there\n serviceMarkdown = latestServiceInCatalog.markdown;\n serviceSpecifications = latestServiceInCatalog.specifications ?? {};\n sends = latestServiceInCatalog.sends ? [...latestServiceInCatalog.sends, ...sends] : sends;\n receives = latestServiceInCatalog.receives ? [...latestServiceInCatalog.receives, ...receives] : receives;\n serviceSpecificationsFiles = await getSpecificationFilesForService(serviceId, version);\n }\n }\n\n const fileName = path.basename(service.path);\n\n await writeService(\n {\n id: serviceId,\n name: serviceName,\n version: version,\n summary: getServiceSummary(document),\n badges: documentTags.map((tag) => ({ content: tag.name(), textColor: 'blue', backgroundColor: 'blue' })),\n markdown: serviceMarkdown,\n sends,\n receives,\n schemaPath: fileName || 'asyncapi.yml',\n specifications: {\n ...serviceSpecifications,\n asyncapiPath: fileName || 'asyncapi.yml',\n },\n },\n {\n override: true,\n }\n );\n\n // What files need added to the service (speficiation files)\n const specFiles = [\n // add any previous spec files to the list\n ...serviceSpecificationsFiles,\n {\n content: saveParsedSpecFile ? getParsedSpecFile(service, document) : await getRawSpecFile(service),\n fileName: path.basename(service.path) || 'asyncapi.yml',\n },\n ];\n\n for (const specFile of specFiles) {\n await addFileToService(\n serviceId,\n {\n fileName: specFile.fileName,\n content: specFile.content,\n },\n version\n );\n }\n\n console.log(chalk.cyan(` - Service (v${version}) created`));\n\n console.log(chalk.green(`\\nFinished generating event catalog for AsyncAPI ${serviceId} (v${version})`));\n }\n\n await checkLicense();\n};\n\nconst getParsedSpecFile = (service: Service, document: AsyncAPIDocumentInterface) => {\n const isSpecFileJSON = service.path.endsWith('.json');\n return isSpecFileJSON\n ? JSON.stringify(document.meta().asyncapi.parsed, null, 4)\n : yaml.dump(document.meta().asyncapi.parsed, { noRefs: true });\n};\n\nconst getRawSpecFile = async (service: Service) => {\n if (service.path.startsWith('http')) {\n try {\n const response = await fetch(service.path);\n return response.text();\n } catch (error) {\n console.log(chalk.red(`\\nFailed to request AsyncAPI file from ${service.path}`));\n return '';\n }\n } else {\n return await readFile(service.path, 'utf8');\n }\n};\n/**\n * Is the AsyncAPI specification (service) the owner of the message?\n * This is determined by the 'x-eventcatalog-role' extension in the message\n *\n * @param message\n * @returns boolean\n *\n * default is provider (AsyncAPI file / service owns the message)\n */\nconst isServiceMessageOwner = (message: MessageInterface): boolean => {\n const value = message.extensions().get('x-eventcatalog-role')?.value() || 'provider';\n return value === 'provider';\n};\n","export const getFileExtentionFromSchemaFormat = (format: string | undefined = '') => {\n if (format.includes('avro')) return 'avsc';\n if (format.includes('yml')) return 'yml';\n if (format.includes('json')) return 'json';\n if (format.includes('openapi')) return 'openapi';\n if (format.includes('protobuf')) return 'protobuf';\n if (format.includes('yaml')) return 'yaml';\n\n return 'json';\n};\n","import {\n MessageInterface,\n AsyncAPIDocumentInterface,\n ChannelInterface,\n ChannelsInterface,\n MessagesInterface,\n} from '@asyncapi/parser';\nimport { getFileExtentionFromSchemaFormat } from './schemas';\n\nexport const defaultMarkdown = (_document: AsyncAPIDocumentInterface, message: MessageInterface) => {\n return `\n## Architecture\n<NodeGraph />\n\n${\n messageHasSchema(message) && messageIsJSON(message)\n ? `\n## Schema\n<SchemaViewer file=\"${getSchemaFileName(message)}\" title=\"Message Schema\" maxHeight=\"500\" />\n`\n : ''\n}\n${\n messageHasSchema(message) && !messageIsJSON(message)\n ? `\n## Schema\n<Schema file=\"${getSchemaFileName(message)}\" title=\"Message Schema\" maxHeight=\"500\" />\n`\n : ''\n}\n\n${\n message.externalDocs()\n ? `\n## External documentation\n- [${message.externalDocs()?.description()}](${message.externalDocs()?.url()})\n`\n : ''\n}\n\n`;\n};\n\nexport const getSummary = (message: MessageInterface) => {\n const messageSummary = message.hasSummary() ? message.summary() : '';\n const messageDescription = message.hasDescription() ? message.description() : '';\n\n let eventCatalogMessageSummary = messageSummary;\n\n if (!eventCatalogMessageSummary) {\n eventCatalogMessageSummary = messageDescription && messageDescription.length < 150 ? messageDescription : '';\n }\n\n return eventCatalogMessageSummary;\n};\n\nexport const messageHasSchema = (message: MessageInterface) => {\n return message.hasPayload() && message.schemaFormat();\n};\n\nexport const messageIsJSON = (message: MessageInterface) => {\n const fileName = getSchemaFileName(message);\n return fileName.endsWith('.json');\n};\n\nexport const getSchemaFileName = (message: MessageInterface) => {\n const extension = getFileExtentionFromSchemaFormat(message.schemaFormat());\n return `schema.${extension}`;\n};\n\nexport const getMessageName = (message: MessageInterface) => {\n return message.hasTitle() && message.title() ? (message.title() as string) : message.id();\n};\n\nexport const getChannelsForMessage = (\n message: MessageInterface,\n channels: ChannelsInterface,\n document: AsyncAPIDocumentInterface\n): { id: string; version: string }[] => {\n let channelsForMessage: ChannelInterface[] = [];\n const globalVersion = document.info().version();\n\n // Go through all channels and link messages they document\n for (const channel of channels) {\n for (const channelMessage of channel.messages() as MessagesInterface) {\n if (channelMessage.id() === message.id()) {\n channelsForMessage.push(channel);\n }\n }\n }\n\n // You can also document a message directly to a channel, add them too\n for (const messageChannel of message.channels()) {\n channelsForMessage.push(messageChannel);\n }\n\n // Make them unique, as there may be overlapping channels\n const uniqueChannels = channelsForMessage.filter(\n (channel, index, self) => index === self.findIndex((t) => t.id() === channel.id())\n );\n\n return uniqueChannels.map((channel) => {\n const channelVersion = channel.extensions().get('x-eventcatalog-channel-version')?.value() || globalVersion;\n return {\n id: channel.id(),\n version: channelVersion,\n };\n });\n};\n","import { AsyncAPIDocumentInterface } from '@asyncapi/parser';\n\nexport const defaultMarkdown = (document: AsyncAPIDocumentInterface) => {\n return `\n\n${document.info().hasDescription() ? `${document.info().description()}` : ''} \n\n## Architecture diagram\n<NodeGraph />\n\n${\n document.info().externalDocs()\n ? `\n## External documentation\n- [${document.info().externalDocs()?.description()}](${document.info().externalDocs()?.url()})\n`\n : ''\n}\n`;\n};\n\nexport const getSummary = (document: AsyncAPIDocumentInterface) => {\n const summary = document.info().hasDescription() ? document.info().description() : '';\n return summary && summary.length < 150 ? summary : '';\n};\n","import { AsyncAPIDocumentInterface } from '@asyncapi/parser';\n\nexport const defaultMarkdown = (document: AsyncAPIDocumentInterface) => {\n return `\n\n## Architecture diagram\n<NodeGraph />\n\n`;\n};\n","import { AsyncAPIDocumentInterface, ChannelInterface } from '@asyncapi/parser';\n\nexport const getChannelProtocols = (channel: ChannelInterface): string[] => {\n const protocols = [];\n\n const bindings = channel.bindings();\n for (const binding of bindings) {\n protocols.push(binding.protocol());\n }\n\n return protocols;\n};\n\nexport const defaultMarkdown = (_document: AsyncAPIDocumentInterface, channel: ChannelInterface) => {\n return `\n ${\n channel.hasDescription()\n ? `\n ## Overview\n ${channel.description()}\n `\n : ''\n }\n\n <ChannelInformation />\n\n ${\n channel.json()?.externalDocs\n ? `\n ## External documentation\n - [${channel.json()?.externalDocs?.description}](${channel.json()?.externalDocs?.url})\n `\n : ''\n }\n \n `;\n};\n","import chalk from 'chalk';\n\nexport default () => {\n console.log(chalk.bgBlue(`\\nYou are using the open source license for this plugin`));\n console.log(\n chalk.blueBright(\n `This plugin is governed and published under a dual-license. \\nIf using for internal, commercial or proprietary software, 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,oBAAuF;AACvF,iBAAkB;AAClB,sBAAyB;AACzB,sBAAiB;AACjB,qBAAiB;AACjB,iBAAkB;AAClB,IAAAA,gBAAkB;AAClB,kBAAiB;AAGjB,gCAAiC;;;ACV1B,IAAM,mCAAmC,CAAC,SAA6B,OAAO;AACnF,MAAI,OAAO,SAAS,MAAM,EAAG,QAAO;AACpC,MAAI,OAAO,SAAS,KAAK,EAAG,QAAO;AACnC,MAAI,OAAO,SAAS,MAAM,EAAG,QAAO;AACpC,MAAI,OAAO,SAAS,SAAS,EAAG,QAAO;AACvC,MAAI,OAAO,SAAS,UAAU,EAAG,QAAO;AACxC,MAAI,OAAO,SAAS,MAAM,EAAG,QAAO;AAEpC,SAAO;AACT;;;ACAO,IAAM,kBAAkB,CAAC,WAAsC,YAA8B;AAClG,SAAO;AAAA;AAAA;AAAA;AAAA,EAKP,iBAAiB,OAAO,KAAK,cAAc,OAAO,IAC9C;AAAA;AAAA,sBAEgB,kBAAkB,OAAO,CAAC;AAAA,IAE1C,EACN;AAAA,EAEE,iBAAiB,OAAO,KAAK,CAAC,cAAc,OAAO,IAC/C;AAAA;AAAA,gBAEU,kBAAkB,OAAO,CAAC;AAAA,IAEpC,EACN;AAAA;AAAA,EAGE,QAAQ,aAAa,IACjB;AAAA;AAAA,KAED,QAAQ,aAAa,GAAG,YAAY,CAAC,KAAK,QAAQ,aAAa,GAAG,IAAI,CAAC;AAAA,IAEtE,EACN;AAAA;AAAA;AAGA;AAEO,IAAM,aAAa,CAAC,YAA8B;AACvD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K,EAAE,SAAS,QAAQ,EAAE,QAAQ,KAAK,CAAC;AACjE;AAEA,IAAM,iBAAiB,OAAO,YAAqB;AACjD,MAAI,QAAQ,KAAK,WAAW,MAAM,GAAG;AACnC,QAAI;AACF,YAAM,WAAW,MAAM,MAAM,QAAQ,IAAI;AACzC,aAAO,SAAS,KAAK;AAAA,IACvB,SAAS,OAAO;AACd,cAAQ,IAAI,cAAAJ,QAAM,IAAI;AAAA,uCAA0C,QAAQ,IAAI,EAAE,CAAC;AAC/E,aAAO;AAAA,IACT;AAAA,EACF,OAAO;AACL,WAAO,UAAM,0BAAS,QAAQ,MAAM,MAAM;AAAA,EAC5C;AACF;AAUA,IAAM,wBAAwB,CAAC,YAAuC;AACpE,QAAM,QAAQ,QAAQ,WAAW,EAAE,IAAI,qBAAqB,GAAG,MAAM,KAAK;AAC1E,SAAO,UAAU;AACnB;","names":["import_chalk","defaultMarkdown","getSummary","defaultMarkdown","defaultMarkdown","chalk","argv","utils","chalk","defaultMarkdown","path","getSummary","yaml"]}
|
package/dist/index.mjs
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
import { Parser, fromFile, fromURL } from "@asyncapi/parser";
|
|
3
3
|
import utils from "@eventcatalog/sdk";
|
|
4
4
|
import { readFile } from "node:fs/promises";
|
|
5
|
+
import argv from "minimist";
|
|
6
|
+
import yaml from "js-yaml";
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
import chalk2 from "chalk";
|
|
9
|
+
import path from "path";
|
|
10
|
+
import { AvroSchemaParser } from "@asyncapi/avro-schema-parser";
|
|
5
11
|
|
|
6
12
|
// src/utils/schemas.ts
|
|
7
13
|
var getFileExtentionFromSchemaFormat = (format = "") => {
|
|
@@ -59,6 +65,30 @@ var getSchemaFileName = (message) => {
|
|
|
59
65
|
var getMessageName = (message) => {
|
|
60
66
|
return message.hasTitle() && message.title() ? message.title() : message.id();
|
|
61
67
|
};
|
|
68
|
+
var getChannelsForMessage = (message, channels, document) => {
|
|
69
|
+
let channelsForMessage = [];
|
|
70
|
+
const globalVersion = document.info().version();
|
|
71
|
+
for (const channel of channels) {
|
|
72
|
+
for (const channelMessage of channel.messages()) {
|
|
73
|
+
if (channelMessage.id() === message.id()) {
|
|
74
|
+
channelsForMessage.push(channel);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
for (const messageChannel of message.channels()) {
|
|
79
|
+
channelsForMessage.push(messageChannel);
|
|
80
|
+
}
|
|
81
|
+
const uniqueChannels = channelsForMessage.filter(
|
|
82
|
+
(channel, index, self) => index === self.findIndex((t) => t.id() === channel.id())
|
|
83
|
+
);
|
|
84
|
+
return uniqueChannels.map((channel) => {
|
|
85
|
+
const channelVersion = channel.extensions().get("x-eventcatalog-channel-version")?.value() || globalVersion;
|
|
86
|
+
return {
|
|
87
|
+
id: channel.id(),
|
|
88
|
+
version: channelVersion
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
};
|
|
62
92
|
|
|
63
93
|
// src/utils/services.ts
|
|
64
94
|
var defaultMarkdown2 = (document) => {
|
|
@@ -90,8 +120,31 @@ var defaultMarkdown3 = (document) => {
|
|
|
90
120
|
`;
|
|
91
121
|
};
|
|
92
122
|
|
|
93
|
-
// src/
|
|
94
|
-
|
|
123
|
+
// src/utils/channels.ts
|
|
124
|
+
var getChannelProtocols = (channel) => {
|
|
125
|
+
const protocols = [];
|
|
126
|
+
const bindings = channel.bindings();
|
|
127
|
+
for (const binding of bindings) {
|
|
128
|
+
protocols.push(binding.protocol());
|
|
129
|
+
}
|
|
130
|
+
return protocols;
|
|
131
|
+
};
|
|
132
|
+
var defaultMarkdown4 = (_document, channel) => {
|
|
133
|
+
return `
|
|
134
|
+
${channel.hasDescription() ? `
|
|
135
|
+
## Overview
|
|
136
|
+
${channel.description()}
|
|
137
|
+
` : ""}
|
|
138
|
+
|
|
139
|
+
<ChannelInformation />
|
|
140
|
+
|
|
141
|
+
${channel.json()?.externalDocs ? `
|
|
142
|
+
## External documentation
|
|
143
|
+
- [${channel.json()?.externalDocs?.description}](${channel.json()?.externalDocs?.url})
|
|
144
|
+
` : ""}
|
|
145
|
+
|
|
146
|
+
`;
|
|
147
|
+
};
|
|
95
148
|
|
|
96
149
|
// src/checkLicense.ts
|
|
97
150
|
import chalk from "chalk";
|
|
@@ -107,11 +160,6 @@ If using for internal, commercial or proprietary software, you can purchase a li
|
|
|
107
160
|
};
|
|
108
161
|
|
|
109
162
|
// src/index.ts
|
|
110
|
-
import argv from "minimist";
|
|
111
|
-
import yaml from "js-yaml";
|
|
112
|
-
import { z } from "zod";
|
|
113
|
-
import { AvroSchemaParser } from "@asyncapi/avro-schema-parser";
|
|
114
|
-
import path from "path";
|
|
115
163
|
var parser = new Parser();
|
|
116
164
|
parser.registerSchemaParser(AvroSchemaParser());
|
|
117
165
|
var cliArgs = argv(process.argv.slice(2));
|
|
@@ -131,6 +179,7 @@ var optionsSchema = z.object({
|
|
|
131
179
|
}).optional(),
|
|
132
180
|
debug: z.boolean().optional(),
|
|
133
181
|
parseSchemas: z.boolean().optional(),
|
|
182
|
+
parseChannels: z.boolean().optional(),
|
|
134
183
|
saveParsedSpecFile: z.boolean({ invalid_type_error: "The saveParsedSpecFile is not a boolean in options" }).optional()
|
|
135
184
|
});
|
|
136
185
|
var validateOptions = (options) => {
|
|
@@ -151,16 +200,12 @@ var src_default = async (config, options) => {
|
|
|
151
200
|
writeQuery,
|
|
152
201
|
getService,
|
|
153
202
|
versionService,
|
|
154
|
-
rmService,
|
|
155
203
|
getDomain,
|
|
156
204
|
writeDomain,
|
|
157
205
|
addServiceToDomain,
|
|
158
206
|
getCommand,
|
|
159
207
|
getEvent,
|
|
160
208
|
getQuery,
|
|
161
|
-
rmEventById,
|
|
162
|
-
rmCommandById,
|
|
163
|
-
rmQueryById,
|
|
164
209
|
versionCommand,
|
|
165
210
|
versionEvent,
|
|
166
211
|
versionQuery,
|
|
@@ -169,33 +214,33 @@ var src_default = async (config, options) => {
|
|
|
169
214
|
addSchemaToQuery,
|
|
170
215
|
addFileToService,
|
|
171
216
|
versionDomain,
|
|
172
|
-
getSpecificationFilesForService
|
|
217
|
+
getSpecificationFilesForService,
|
|
218
|
+
writeChannel,
|
|
219
|
+
getChannel,
|
|
220
|
+
versionChannel
|
|
173
221
|
} = utils(process.env.PROJECT_DIR);
|
|
174
222
|
const MESSAGE_OPERATIONS = {
|
|
175
223
|
event: {
|
|
176
224
|
write: writeEvent,
|
|
177
225
|
version: versionEvent,
|
|
178
226
|
get: getEvent,
|
|
179
|
-
remove: rmEventById,
|
|
180
227
|
addSchema: addSchemaToEvent
|
|
181
228
|
},
|
|
182
229
|
command: {
|
|
183
230
|
write: writeCommand,
|
|
184
231
|
version: versionCommand,
|
|
185
232
|
get: getCommand,
|
|
186
|
-
remove: rmCommandById,
|
|
187
233
|
addSchema: addSchemaToCommand
|
|
188
234
|
},
|
|
189
235
|
query: {
|
|
190
236
|
write: writeQuery,
|
|
191
237
|
version: versionQuery,
|
|
192
238
|
get: getQuery,
|
|
193
|
-
remove: rmQueryById,
|
|
194
239
|
addSchema: addSchemaToQuery
|
|
195
240
|
}
|
|
196
241
|
};
|
|
197
242
|
validateOptions(options);
|
|
198
|
-
const { services, saveParsedSpecFile = false, parseSchemas = true } = options;
|
|
243
|
+
const { services, saveParsedSpecFile = false, parseSchemas = true, parseChannels = false } = options;
|
|
199
244
|
console.log(chalk2.green(`Processing ${services.length} AsyncAPI files...`));
|
|
200
245
|
for (const service of services) {
|
|
201
246
|
console.log(chalk2.gray(`Processing ${service.path}`));
|
|
@@ -214,6 +259,7 @@ var src_default = async (config, options) => {
|
|
|
214
259
|
continue;
|
|
215
260
|
}
|
|
216
261
|
const operations = document.allOperations();
|
|
262
|
+
const channels = document.allChannels();
|
|
217
263
|
const documentTags = document.info().tags().all() || [];
|
|
218
264
|
const serviceId = service.id;
|
|
219
265
|
const serviceName = service.name || document.info().title();
|
|
@@ -248,12 +294,57 @@ Processing domain: ${domainName} (v${domainVersion})`));
|
|
|
248
294
|
}
|
|
249
295
|
await addServiceToDomain(domainId, { id: serviceId, version }, domainVersion);
|
|
250
296
|
}
|
|
297
|
+
if (parseChannels) {
|
|
298
|
+
for (const channel of channels) {
|
|
299
|
+
const channelAsJSON = channel.json();
|
|
300
|
+
const channelId = channel.id();
|
|
301
|
+
const params = channelAsJSON?.parameters || {};
|
|
302
|
+
const protocols = getChannelProtocols(channel);
|
|
303
|
+
const channelVersion = channel.extensions().get("x-eventcatalog-channel-version")?.value() || version;
|
|
304
|
+
let channelMarkdown = defaultMarkdown4(document, channel);
|
|
305
|
+
console.log(chalk2.blue(`Processing channel: ${channelId} (v${channelVersion})`));
|
|
306
|
+
const paramsForCatalog = Object.keys(params).reduce(
|
|
307
|
+
(acc, key) => {
|
|
308
|
+
const param = params[key];
|
|
309
|
+
acc[key] = {};
|
|
310
|
+
if (param.enum) acc[key].enum = param.enum;
|
|
311
|
+
if (param.default) acc[key].default = param.default;
|
|
312
|
+
if (param.examples) acc[key].examples = param.examples;
|
|
313
|
+
if (param.description) acc[key].description = param.description;
|
|
314
|
+
return acc;
|
|
315
|
+
},
|
|
316
|
+
{}
|
|
317
|
+
);
|
|
318
|
+
const catalogedChannel = await getChannel(channelId, "latest");
|
|
319
|
+
if (catalogedChannel) {
|
|
320
|
+
channelMarkdown = catalogedChannel.markdown;
|
|
321
|
+
if (catalogedChannel.version !== channelVersion) {
|
|
322
|
+
await versionChannel(channelId);
|
|
323
|
+
console.log(chalk2.cyan(` - Versioned previous channel: ${channelId} (v${channelVersion})`));
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
await writeChannel(
|
|
327
|
+
{
|
|
328
|
+
id: channelId,
|
|
329
|
+
name: channelAsJSON?.title || channel.id(),
|
|
330
|
+
markdown: channelMarkdown,
|
|
331
|
+
version: channelVersion,
|
|
332
|
+
...Object.keys(paramsForCatalog).length > 0 && { parameters: paramsForCatalog },
|
|
333
|
+
...channel.address() && { address: channel.address() },
|
|
334
|
+
...channelAsJSON?.summary && { summary: channelAsJSON.summary },
|
|
335
|
+
...protocols.length > 0 && { protocols }
|
|
336
|
+
},
|
|
337
|
+
{ override: true }
|
|
338
|
+
);
|
|
339
|
+
console.log(chalk2.cyan(` - Message ${channelId} (v${version}) created`));
|
|
340
|
+
}
|
|
341
|
+
}
|
|
251
342
|
for (const operation of operations) {
|
|
252
343
|
for (const message of operation.messages()) {
|
|
253
344
|
const eventType = message.extensions().get("x-eventcatalog-message-type")?.value() || "event";
|
|
254
345
|
const messageVersion = message.extensions().get("x-eventcatalog-message-version")?.value() || version;
|
|
255
346
|
const serviceOwnsMessageContract = isServiceMessageOwner(message);
|
|
256
|
-
const isReceived = operation.action() === "receive" || operation.action() === "
|
|
347
|
+
const isReceived = operation.action() === "receive" || operation.action() === "subscribe";
|
|
257
348
|
const isSent = operation.action() === "send" || operation.action() === "publish";
|
|
258
349
|
const messageId = message.id().toLowerCase();
|
|
259
350
|
if (eventType !== "event" && eventType !== "command" && eventType !== "query") {
|
|
@@ -263,7 +354,6 @@ Processing domain: ${domainName} (v${domainVersion})`));
|
|
|
263
354
|
write: writeMessage,
|
|
264
355
|
version: versionMessage,
|
|
265
356
|
get: getMessage,
|
|
266
|
-
remove: rmMessageById,
|
|
267
357
|
addSchema: addSchemaToMessage
|
|
268
358
|
} = MESSAGE_OPERATIONS[eventType];
|
|
269
359
|
let messageMarkdown = defaultMarkdown(document, message);
|
|
@@ -273,13 +363,12 @@ Processing domain: ${domainName} (v${domainVersion})`));
|
|
|
273
363
|
const catalogedMessage = await getMessage(message.id().toLowerCase(), "latest");
|
|
274
364
|
if (catalogedMessage) {
|
|
275
365
|
messageMarkdown = catalogedMessage.markdown;
|
|
276
|
-
if (catalogedMessage.version
|
|
277
|
-
await rmMessageById(messageId, messageVersion);
|
|
278
|
-
} else {
|
|
366
|
+
if (catalogedMessage.version !== messageVersion) {
|
|
279
367
|
await versionMessage(messageId);
|
|
280
368
|
console.log(chalk2.cyan(` - Versioned previous message: (v${catalogedMessage.version})`));
|
|
281
369
|
}
|
|
282
370
|
}
|
|
371
|
+
const channelsForMessage = parseChannels ? getChannelsForMessage(message, channels, document) : [];
|
|
283
372
|
await writeMessage(
|
|
284
373
|
{
|
|
285
374
|
id: messageId,
|
|
@@ -288,9 +377,11 @@ Processing domain: ${domainName} (v${domainVersion})`));
|
|
|
288
377
|
summary: getSummary(message),
|
|
289
378
|
markdown: messageMarkdown,
|
|
290
379
|
badges: badges.map((badge) => ({ content: badge.name(), textColor: "blue", backgroundColor: "blue" })),
|
|
291
|
-
schemaPath: messageHasSchema(message) ? getSchemaFileName(message) : void 0
|
|
380
|
+
schemaPath: messageHasSchema(message) ? getSchemaFileName(message) : void 0,
|
|
381
|
+
...channelsForMessage.length > 0 && { channels: channelsForMessage }
|
|
292
382
|
},
|
|
293
383
|
{
|
|
384
|
+
override: true,
|
|
294
385
|
path: message.id()
|
|
295
386
|
}
|
|
296
387
|
);
|
|
@@ -328,25 +419,29 @@ Processing domain: ${domainName} (v${domainVersion})`));
|
|
|
328
419
|
sends = latestServiceInCatalog.sends ? [...latestServiceInCatalog.sends, ...sends] : sends;
|
|
329
420
|
receives = latestServiceInCatalog.receives ? [...latestServiceInCatalog.receives, ...receives] : receives;
|
|
330
421
|
serviceSpecificationsFiles = await getSpecificationFilesForService(serviceId, version);
|
|
331
|
-
await rmService(serviceId);
|
|
332
422
|
}
|
|
333
423
|
}
|
|
334
424
|
const fileName = path.basename(service.path);
|
|
335
|
-
await writeService(
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
425
|
+
await writeService(
|
|
426
|
+
{
|
|
427
|
+
id: serviceId,
|
|
428
|
+
name: serviceName,
|
|
429
|
+
version,
|
|
430
|
+
summary: getSummary2(document),
|
|
431
|
+
badges: documentTags.map((tag) => ({ content: tag.name(), textColor: "blue", backgroundColor: "blue" })),
|
|
432
|
+
markdown: serviceMarkdown,
|
|
433
|
+
sends,
|
|
434
|
+
receives,
|
|
435
|
+
schemaPath: fileName || "asyncapi.yml",
|
|
436
|
+
specifications: {
|
|
437
|
+
...serviceSpecifications,
|
|
438
|
+
asyncapiPath: fileName || "asyncapi.yml"
|
|
439
|
+
}
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
override: true
|
|
348
443
|
}
|
|
349
|
-
|
|
444
|
+
);
|
|
350
445
|
const specFiles = [
|
|
351
446
|
// add any previous spec files to the list
|
|
352
447
|
...serviceSpecificationsFiles,
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/utils/schemas.ts","../src/utils/messages.ts","../src/utils/services.ts","../src/utils/domains.ts","../src/checkLicense.ts"],"sourcesContent":["// import utils from '@eventcatalog/sdk';\nimport { AsyncAPIDocumentInterface, MessageInterface, Parser, fromFile, fromURL } from '@asyncapi/parser';\nimport utils from '@eventcatalog/sdk';\nimport { readFile } from 'node:fs/promises';\nimport {\n defaultMarkdown as generateMarkdownForMessage,\n getMessageName,\n getSummary as getMessageSummary,\n getSchemaFileName,\n messageHasSchema,\n} from './utils/messages';\nimport { defaultMarkdown as generateMarkdownForService, getSummary as getServiceSummary } from './utils/services';\nimport { defaultMarkdown as generateMarkdownForDomain } from './utils/domains';\nimport chalk from 'chalk';\nimport checkLicense from './checkLicense';\nimport argv from 'minimist';\nimport yaml from 'js-yaml';\nimport { z } from 'zod';\n\n// AsyncAPI Parsers\nimport { AvroSchemaParser } from '@asyncapi/avro-schema-parser';\nimport path from 'path';\nimport { EventType, MessageOperations } from './types';\n\nconst parser = new Parser();\n\n// register avro schema support\nparser.registerSchemaParser(AvroSchemaParser());\nconst cliArgs = argv(process.argv.slice(2));\n\nconst optionsSchema = z.object({\n services: z.array(\n z.object({\n id: z.string({ required_error: 'The service id is required. please provide the service id' }),\n path: z.string({ required_error: 'The service path is required. please provide the path to specification file' }),\n name: z.string().optional(),\n }),\n { message: 'Please provide correct services configuration' }\n ),\n domain: z\n .object({\n id: z.string({ required_error: 'The domain id is required. please provide a domain id' }),\n name: z.string({ required_error: 'The domain name is required. please provide a domain name' }),\n version: z.string({ required_error: 'The domain version is required. please provide a domain version' }),\n })\n .optional(),\n debug: z.boolean().optional(),\n parseSchemas: z.boolean().optional(),\n saveParsedSpecFile: z.boolean({ invalid_type_error: 'The saveParsedSpecFile is not a boolean in options' }).optional(),\n});\n\ntype Props = z.infer<typeof optionsSchema>;\ntype Domain = z.infer<typeof optionsSchema>['domain'];\ntype Service = z.infer<typeof optionsSchema>['services'][0];\n\nconst validateOptions = (options: Props) => {\n try {\n optionsSchema.parse(options);\n } catch (error: any) {\n if (error instanceof z.ZodError) throw new Error(JSON.stringify(error.issues, null, 2));\n }\n};\n\nexport default async (config: any, options: Props) => {\n if (!process.env.PROJECT_DIR) {\n throw new Error('Please provide catalog url (env variable PROJECT_DIR)');\n }\n\n const {\n writeService,\n writeEvent,\n writeCommand,\n writeQuery,\n getService,\n versionService,\n rmService,\n getDomain,\n writeDomain,\n addServiceToDomain,\n getCommand,\n getEvent,\n getQuery,\n rmEventById,\n rmCommandById,\n rmQueryById,\n versionCommand,\n versionEvent,\n versionQuery,\n addSchemaToCommand,\n addSchemaToEvent,\n addSchemaToQuery,\n addFileToService,\n versionDomain,\n getSpecificationFilesForService,\n } = utils(process.env.PROJECT_DIR);\n\n // Define the message operations mapping with proper types\n const MESSAGE_OPERATIONS: Record<EventType, MessageOperations> = {\n event: {\n write: writeEvent,\n version: versionEvent,\n get: getEvent,\n remove: rmEventById,\n addSchema: addSchemaToEvent,\n },\n command: {\n write: writeCommand,\n version: versionCommand,\n get: getCommand,\n remove: rmCommandById,\n addSchema: addSchemaToCommand,\n },\n query: {\n write: writeQuery,\n version: versionQuery,\n get: getQuery,\n remove: rmQueryById,\n addSchema: addSchemaToQuery,\n },\n };\n\n // Should the file that is written to the catalog be parsed (https://github.com/asyncapi/parser-js) or as it is?\n validateOptions(options);\n const { services, saveParsedSpecFile = false, parseSchemas = true } = options;\n // const asyncAPIFiles = Array.isArray(options.path) ? options.path : [options.path];\n console.log(chalk.green(`Processing ${services.length} AsyncAPI files...`));\n for (const service of services) {\n console.log(chalk.gray(`Processing ${service.path}`));\n\n const { document, diagnostics } = service.path.startsWith('http')\n ? await fromURL(parser, service.path).parse({\n parseSchemas,\n })\n : await fromFile(parser, service.path).parse({\n parseSchemas,\n });\n\n if (!document) {\n console.log(chalk.red('Failed to parse AsyncAPI file'));\n if (options.debug || cliArgs.debug) {\n console.log(diagnostics);\n } else {\n console.log(chalk.red('Run with debug option in the generator to see diagnostics'));\n }\n continue;\n }\n\n const operations = document.allOperations();\n const documentTags = document.info().tags().all() || [];\n\n const serviceId = service.id;\n\n const serviceName = service.name || document.info().title();\n const version = document.info().version();\n\n // What messages does this service send and receive\n let sends = [];\n let receives = [];\n\n let serviceSpecifications = {};\n let serviceSpecificationsFiles = [];\n let serviceMarkdown = generateMarkdownForService(document);\n\n // Manage domain\n if (options.domain) {\n // Try and get the domain\n const { id: domainId, name: domainName, version: domainVersion } = options.domain;\n const domain = await getDomain(options.domain.id, domainVersion || 'latest');\n const currentDomain = await getDomain(options.domain.id, 'latest');\n\n console.log(chalk.blue(`\\nProcessing domain: ${domainName} (v${domainVersion})`));\n\n // Found a domain, but the versions do not match\n if (currentDomain && currentDomain.version !== domainVersion) {\n await versionDomain(domainId);\n console.log(chalk.cyan(` - Versioned previous domain (v${currentDomain.version})`));\n }\n\n // Do we need to create a new domain?\n if (!domain || (domain && domain.version !== domainVersion)) {\n await writeDomain({\n id: domainId,\n name: domainName,\n version: domainVersion,\n markdown: generateMarkdownForDomain(document),\n // services: [{ id: serviceId, version: version }],\n });\n console.log(chalk.cyan(` - Domain (v${domainVersion}) created`));\n }\n\n if (currentDomain && currentDomain.version === domainVersion) {\n console.log(chalk.yellow(` - Domain (v${domainVersion}) already exists, skipped creation...`));\n }\n\n // Add the service to the domain\n await addServiceToDomain(domainId, { id: serviceId, version: version }, domainVersion);\n }\n\n // Find events/commands\n for (const operation of operations) {\n for (const message of operation.messages()) {\n const eventType = (message.extensions().get('x-eventcatalog-message-type')?.value() as EventType) || 'event';\n const messageVersion = message.extensions().get('x-eventcatalog-message-version')?.value() || version;\n\n // does this service own or just consume the message?\n const serviceOwnsMessageContract = isServiceMessageOwner(message);\n const isReceived = operation.action() === 'receive' || operation.action() === 'receive';\n const isSent = operation.action() === 'send' || operation.action() === 'publish';\n\n const messageId = message.id().toLowerCase();\n\n if (eventType !== 'event' && eventType !== 'command' && eventType !== 'query') {\n throw new Error('Invalid message type');\n }\n\n const {\n write: writeMessage,\n version: versionMessage,\n get: getMessage,\n remove: rmMessageById,\n addSchema: addSchemaToMessage,\n } = MESSAGE_OPERATIONS[eventType];\n\n let messageMarkdown = generateMarkdownForMessage(document, message);\n const badges = message.tags().all() || [];\n\n console.log(chalk.blue(`Processing message: ${getMessageName(message)} (v${messageVersion})`));\n\n if (serviceOwnsMessageContract) {\n // Check if the message already exists in the catalog\n const catalogedMessage = await getMessage(message.id().toLowerCase(), 'latest');\n\n if (catalogedMessage) {\n messageMarkdown = catalogedMessage.markdown;\n // if the version matches, we can override the message but keep markdown as it was\n if (catalogedMessage.version === messageVersion) {\n await rmMessageById(messageId, messageVersion);\n } else {\n // if the version does not match, we need to version the message\n await versionMessage(messageId);\n console.log(chalk.cyan(` - Versioned previous message: (v${catalogedMessage.version})`));\n }\n }\n\n // Write the message to the catalog\n await writeMessage(\n {\n id: messageId,\n version: messageVersion,\n name: getMessageName(message),\n summary: getMessageSummary(message),\n markdown: messageMarkdown,\n badges: badges.map((badge) => ({ content: badge.name(), textColor: 'blue', backgroundColor: 'blue' })),\n schemaPath: messageHasSchema(message) ? getSchemaFileName(message) : undefined,\n },\n {\n path: message.id(),\n }\n );\n\n console.log(chalk.cyan(` - Message (v${messageVersion}) created`));\n // Check if the message has a payload, if it does then document in EventCatalog\n if (messageHasSchema(message)) {\n // Get the schema from the original payload if it exists\n const schema = message.payload()?.extensions()?.get('x-parser-original-payload')?.json() || message.payload()?.json();\n\n await addSchemaToMessage(\n messageId,\n {\n fileName: getSchemaFileName(message),\n schema: JSON.stringify(schema, null, 4),\n },\n messageVersion\n );\n console.log(chalk.cyan(` - Schema added to message (v${messageVersion})`));\n }\n } else {\n // Message is not owned by this service, therefore we don't need to document it\n console.log(chalk.yellow(` - Skipping external message: ${getMessageName(message)}(v${messageVersion})`));\n }\n // Add the message to the correct array\n if (isSent) sends.push({ id: messageId, version: messageVersion });\n if (isReceived) receives.push({ id: messageId, version: messageVersion });\n }\n }\n\n // Check if service is already defined... if the versions do not match then create service.\n const latestServiceInCatalog = await getService(serviceId, 'latest');\n\n console.log(chalk.blue(`Processing service: ${serviceId} (v${version})`));\n\n if (latestServiceInCatalog) {\n serviceMarkdown = latestServiceInCatalog.markdown;\n // Found a service, and versions do not match, we need to version the one already there\n if (latestServiceInCatalog.version !== version) {\n await versionService(serviceId);\n console.log(chalk.cyan(` - Versioned previous service (v${latestServiceInCatalog.version})`));\n }\n\n // Match found, override it\n if (latestServiceInCatalog.version === version) {\n // we want to preserve the markdown any any spec files that are already there\n serviceMarkdown = latestServiceInCatalog.markdown;\n serviceSpecifications = latestServiceInCatalog.specifications ?? {};\n sends = latestServiceInCatalog.sends ? [...latestServiceInCatalog.sends, ...sends] : sends;\n receives = latestServiceInCatalog.receives ? [...latestServiceInCatalog.receives, ...receives] : receives;\n serviceSpecificationsFiles = await getSpecificationFilesForService(serviceId, version);\n await rmService(serviceId);\n }\n }\n\n const fileName = path.basename(service.path);\n\n await writeService({\n id: serviceId,\n name: serviceName,\n version: version,\n summary: getServiceSummary(document),\n badges: documentTags.map((tag) => ({ content: tag.name(), textColor: 'blue', backgroundColor: 'blue' })),\n markdown: serviceMarkdown,\n sends,\n receives,\n schemaPath: fileName || 'asyncapi.yml',\n specifications: {\n ...serviceSpecifications,\n asyncapiPath: fileName || 'asyncapi.yml',\n },\n });\n\n // What files need added to the service (speficiation files)\n const specFiles = [\n // add any previous spec files to the list\n ...serviceSpecificationsFiles,\n {\n content: saveParsedSpecFile ? getParsedSpecFile(service, document) : await getRawSpecFile(service),\n fileName: path.basename(service.path) || 'asyncapi.yml',\n },\n ];\n\n for (const specFile of specFiles) {\n await addFileToService(\n serviceId,\n {\n fileName: specFile.fileName,\n content: specFile.content,\n },\n version\n );\n }\n\n console.log(chalk.cyan(` - Service (v${version}) created`));\n\n console.log(chalk.green(`\\nFinished generating event catalog for AsyncAPI ${serviceId} (v${version})`));\n }\n\n await checkLicense();\n};\n\nconst getParsedSpecFile = (service: Service, document: AsyncAPIDocumentInterface) => {\n const isSpecFileJSON = service.path.endsWith('.json');\n return isSpecFileJSON\n ? JSON.stringify(document.meta().asyncapi.parsed, null, 4)\n : yaml.dump(document.meta().asyncapi.parsed, { noRefs: true });\n};\n\nconst getRawSpecFile = async (service: Service) => {\n if (service.path.startsWith('http')) {\n try {\n const response = await fetch(service.path);\n return response.text();\n } catch (error) {\n console.log(chalk.red(`\\nFailed to request AsyncAPI file from ${service.path}`));\n return '';\n }\n } else {\n return await readFile(service.path, 'utf8');\n }\n};\n/**\n * Is the AsyncAPI specification (service) the owner of the message?\n * This is determined by the 'x-eventcatalog-role' extension in the message\n *\n * @param message\n * @returns boolean\n *\n * default is provider (AsyncAPI file / service owns the message)\n */\nconst isServiceMessageOwner = (message: MessageInterface): boolean => {\n const value = message.extensions().get('x-eventcatalog-role')?.value() || 'provider';\n return value === 'provider';\n};\n","export const getFileExtentionFromSchemaFormat = (format: string | undefined = '') => {\n if (format.includes('avro')) return 'avsc';\n if (format.includes('yml')) return 'yml';\n if (format.includes('json')) return 'json';\n if (format.includes('openapi')) return 'openapi';\n if (format.includes('protobuf')) return 'protobuf';\n if (format.includes('yaml')) return 'yaml';\n\n return 'json';\n};\n","import { MessageInterface, AsyncAPIDocumentInterface } from '@asyncapi/parser';\nimport { getFileExtentionFromSchemaFormat } from './schemas';\n\nexport const defaultMarkdown = (_document: AsyncAPIDocumentInterface, message: MessageInterface) => {\n return `\n## Architecture\n<NodeGraph />\n\n${\n messageHasSchema(message) && messageIsJSON(message)\n ? `\n## Schema\n<SchemaViewer file=\"${getSchemaFileName(message)}\" title=\"Message Schema\" maxHeight=\"500\" />\n`\n : ''\n}\n${\n messageHasSchema(message) && !messageIsJSON(message)\n ? `\n## Schema\n<Schema file=\"${getSchemaFileName(message)}\" title=\"Message Schema\" maxHeight=\"500\" />\n`\n : ''\n}\n\n${\n message.externalDocs()\n ? `\n## External documentation\n- [${message.externalDocs()?.description()}](${message.externalDocs()?.url()})\n`\n : ''\n}\n\n`;\n};\n\nexport const getSummary = (message: MessageInterface) => {\n const messageSummary = message.hasSummary() ? message.summary() : '';\n const messageDescription = message.hasDescription() ? message.description() : '';\n\n let eventCatalogMessageSummary = messageSummary;\n\n if (!eventCatalogMessageSummary) {\n eventCatalogMessageSummary = messageDescription && messageDescription.length < 150 ? messageDescription : '';\n }\n\n return eventCatalogMessageSummary;\n};\n\nexport const messageHasSchema = (message: MessageInterface) => {\n return message.hasPayload() && message.schemaFormat();\n};\n\nexport const messageIsJSON = (message: MessageInterface) => {\n const fileName = getSchemaFileName(message);\n return fileName.endsWith('.json');\n};\n\nexport const getSchemaFileName = (message: MessageInterface) => {\n const extension = getFileExtentionFromSchemaFormat(message.schemaFormat());\n return `schema.${extension}`;\n};\n\nexport const getMessageName = (message: MessageInterface) => {\n return message.hasTitle() && message.title() ? (message.title() as string) : message.id();\n};\n","import { AsyncAPIDocumentInterface } from '@asyncapi/parser';\n\nexport const defaultMarkdown = (document: AsyncAPIDocumentInterface) => {\n return `\n\n${document.info().hasDescription() ? `${document.info().description()}` : ''} \n\n## Architecture diagram\n<NodeGraph />\n\n${\n document.info().externalDocs()\n ? `\n## External documentation\n- [${document.info().externalDocs()?.description()}](${document.info().externalDocs()?.url()})\n`\n : ''\n}\n`;\n};\n\nexport const getSummary = (document: AsyncAPIDocumentInterface) => {\n const summary = document.info().hasDescription() ? document.info().description() : '';\n return summary && summary.length < 150 ? summary : '';\n};\n","import { AsyncAPIDocumentInterface } from '@asyncapi/parser';\n\nexport const defaultMarkdown = (document: AsyncAPIDocumentInterface) => {\n return `\n\n## Architecture diagram\n<NodeGraph />\n\n`;\n};\n","import chalk from 'chalk';\n\nexport default () => {\n console.log(chalk.bgBlue(`\\nYou are using the open source license for this plugin`));\n console.log(\n chalk.blueBright(\n `This plugin is governed and published under a dual-license. \\nIf using for internal, commercial or proprietary software, you can purchase a license at https://dashboard.eventcatalog.dev/ or contact us hello@eventcatalog.dev.`\n )\n );\n};\n"],"mappings":";AACA,SAAsD,QAAQ,UAAU,eAAe;AACvF,OAAO,WAAW;AAClB,SAAS,gBAAgB;;;ACHlB,IAAM,mCAAmC,CAAC,SAA6B,OAAO;AACnF,MAAI,OAAO,SAAS,MAAM,EAAG,QAAO;AACpC,MAAI,OAAO,SAAS,KAAK,EAAG,QAAO;AACnC,MAAI,OAAO,SAAS,MAAM,EAAG,QAAO;AACpC,MAAI,OAAO,SAAS,SAAS,EAAG,QAAO;AACvC,MAAI,OAAO,SAAS,UAAU,EAAG,QAAO;AACxC,MAAI,OAAO,SAAS,MAAM,EAAG,QAAO;AAEpC,SAAO;AACT;;;ACNO,IAAM,kBAAkB,CAAC,WAAsC,YAA8B;AAClG,SAAO;AAAA;AAAA;AAAA;AAAA,EAKP,iBAAiB,OAAO,KAAK,cAAc,OAAO,IAC9C;AAAA;AAAA,sBAEgB,kBAAkB,OAAO,CAAC;AAAA,IAE1C,EACN;AAAA,EAEE,iBAAiB,OAAO,KAAK,CAAC,cAAc,OAAO,IAC/C;AAAA;AAAA,gBAEU,kBAAkB,OAAO,CAAC;AAAA,IAEpC,EACN;AAAA;AAAA,EAGE,QAAQ,aAAa,IACjB;AAAA;AAAA,KAED,QAAQ,aAAa,GAAG,YAAY,CAAC,KAAK,QAAQ,aAAa,GAAG,IAAI,CAAC;AAAA,IAEtE,EACN;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AM,QAAQ,QAAQ,WAAW,EAAE,IAAI,qBAAqB,GAAG,MAAM,KAAK;AAC1E,SAAO,UAAU;AACnB;","names":["defaultMarkdown","getSummary","defaultMarkdown","chalk","chalk","defaultMarkdown","getSummary"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/utils/schemas.ts","../src/utils/messages.ts","../src/utils/services.ts","../src/utils/domains.ts","../src/utils/channels.ts","../src/checkLicense.ts"],"sourcesContent":["import { AsyncAPIDocumentInterface, MessageInterface, Parser, fromFile, fromURL } from '@asyncapi/parser';\nimport utils from '@eventcatalog/sdk';\nimport { readFile } from 'node:fs/promises';\nimport argv from 'minimist';\nimport yaml from 'js-yaml';\nimport { z } from 'zod';\nimport chalk from 'chalk';\nimport path from 'path';\n\n// AsyncAPI Parsers\nimport { AvroSchemaParser } from '@asyncapi/avro-schema-parser';\n\nimport {\n defaultMarkdown as generateMarkdownForMessage,\n getChannelsForMessage,\n getMessageName,\n getSummary as getMessageSummary,\n getSchemaFileName,\n messageHasSchema,\n} from './utils/messages';\nimport { defaultMarkdown as generateMarkdownForService, getSummary as getServiceSummary } from './utils/services';\nimport { defaultMarkdown as generateMarkdownForDomain } from './utils/domains';\nimport { defaultMarkdown as generateMarkdownForChannel, getChannelProtocols } from './utils/channels';\nimport checkLicense from './checkLicense';\n\nimport { EventType, MessageOperations } from './types';\n\nconst parser = new Parser();\n\n// register avro schema support\nparser.registerSchemaParser(AvroSchemaParser());\nconst cliArgs = argv(process.argv.slice(2));\n\nconst optionsSchema = z.object({\n services: z.array(\n z.object({\n id: z.string({ required_error: 'The service id is required. please provide the service id' }),\n path: z.string({ required_error: 'The service path is required. please provide the path to specification file' }),\n name: z.string().optional(),\n }),\n { message: 'Please provide correct services configuration' }\n ),\n domain: z\n .object({\n id: z.string({ required_error: 'The domain id is required. please provide a domain id' }),\n name: z.string({ required_error: 'The domain name is required. please provide a domain name' }),\n version: z.string({ required_error: 'The domain version is required. please provide a domain version' }),\n })\n .optional(),\n debug: z.boolean().optional(),\n parseSchemas: z.boolean().optional(),\n parseChannels: z.boolean().optional(),\n saveParsedSpecFile: z.boolean({ invalid_type_error: 'The saveParsedSpecFile is not a boolean in options' }).optional(),\n});\n\ntype Props = z.infer<typeof optionsSchema>;\ntype Domain = z.infer<typeof optionsSchema>['domain'];\ntype Service = z.infer<typeof optionsSchema>['services'][0];\n\nconst validateOptions = (options: Props) => {\n try {\n optionsSchema.parse(options);\n } catch (error: any) {\n if (error instanceof z.ZodError) throw new Error(JSON.stringify(error.issues, null, 2));\n }\n};\n\nexport default async (config: any, options: Props) => {\n if (!process.env.PROJECT_DIR) {\n throw new Error('Please provide catalog url (env variable PROJECT_DIR)');\n }\n\n const {\n writeService,\n writeEvent,\n writeCommand,\n writeQuery,\n getService,\n versionService,\n getDomain,\n writeDomain,\n addServiceToDomain,\n getCommand,\n getEvent,\n getQuery,\n versionCommand,\n versionEvent,\n versionQuery,\n addSchemaToCommand,\n addSchemaToEvent,\n addSchemaToQuery,\n addFileToService,\n versionDomain,\n getSpecificationFilesForService,\n writeChannel,\n getChannel,\n versionChannel,\n } = utils(process.env.PROJECT_DIR);\n\n // Define the message operations mapping with proper types\n const MESSAGE_OPERATIONS: Record<EventType, MessageOperations> = {\n event: {\n write: writeEvent,\n version: versionEvent,\n get: getEvent,\n addSchema: addSchemaToEvent,\n },\n command: {\n write: writeCommand,\n version: versionCommand,\n get: getCommand,\n addSchema: addSchemaToCommand,\n },\n query: {\n write: writeQuery,\n version: versionQuery,\n get: getQuery,\n addSchema: addSchemaToQuery,\n },\n };\n\n // Should the file that is written to the catalog be parsed (https://github.com/asyncapi/parser-js) or as it is?\n validateOptions(options);\n\n const { services, saveParsedSpecFile = false, parseSchemas = true, parseChannels = false } = options;\n // const asyncAPIFiles = Array.isArray(options.path) ? options.path : [options.path];\n console.log(chalk.green(`Processing ${services.length} AsyncAPI files...`));\n for (const service of services) {\n console.log(chalk.gray(`Processing ${service.path}`));\n\n const { document, diagnostics } = service.path.startsWith('http')\n ? await fromURL(parser, service.path).parse({\n parseSchemas,\n })\n : await fromFile(parser, service.path).parse({\n parseSchemas,\n });\n\n if (!document) {\n console.log(chalk.red('Failed to parse AsyncAPI file'));\n if (options.debug || cliArgs.debug) {\n console.log(diagnostics);\n } else {\n console.log(chalk.red('Run with debug option in the generator to see diagnostics'));\n }\n continue;\n }\n\n const operations = document.allOperations();\n const channels = document.allChannels();\n const documentTags = document.info().tags().all() || [];\n\n const serviceId = service.id;\n\n const serviceName = service.name || document.info().title();\n const version = document.info().version();\n\n // What messages does this service send and receive\n let sends = [];\n let receives = [];\n\n let serviceSpecifications = {};\n let serviceSpecificationsFiles = [];\n let serviceMarkdown = generateMarkdownForService(document);\n\n // Manage domain\n if (options.domain) {\n // Try and get the domain\n const { id: domainId, name: domainName, version: domainVersion } = options.domain;\n const domain = await getDomain(options.domain.id, domainVersion || 'latest');\n const currentDomain = await getDomain(options.domain.id, 'latest');\n\n console.log(chalk.blue(`\\nProcessing domain: ${domainName} (v${domainVersion})`));\n\n // Found a domain, but the versions do not match\n if (currentDomain && currentDomain.version !== domainVersion) {\n await versionDomain(domainId);\n console.log(chalk.cyan(` - Versioned previous domain (v${currentDomain.version})`));\n }\n\n // Do we need to create a new domain?\n if (!domain || (domain && domain.version !== domainVersion)) {\n await writeDomain({\n id: domainId,\n name: domainName,\n version: domainVersion,\n markdown: generateMarkdownForDomain(document),\n // services: [{ id: serviceId, version: version }],\n });\n console.log(chalk.cyan(` - Domain (v${domainVersion}) created`));\n }\n\n if (currentDomain && currentDomain.version === domainVersion) {\n console.log(chalk.yellow(` - Domain (v${domainVersion}) already exists, skipped creation...`));\n }\n\n // Add the service to the domain\n await addServiceToDomain(domainId, { id: serviceId, version: version }, domainVersion);\n }\n\n // Parse channels\n if (parseChannels) {\n for (const channel of channels) {\n const channelAsJSON = channel.json();\n const channelId = channel.id();\n const params = channelAsJSON?.parameters || {};\n const protocols = getChannelProtocols(channel);\n const channelVersion = channel.extensions().get('x-eventcatalog-channel-version')?.value() || version;\n let channelMarkdown = generateMarkdownForChannel(document, channel);\n\n console.log(chalk.blue(`Processing channel: ${channelId} (v${channelVersion})`));\n\n const paramsForCatalog = Object.keys(params).reduce(\n (acc, key) => {\n const param = params[key];\n acc[key] = {};\n if (param.enum) acc[key].enum = param.enum;\n if (param.default) acc[key].default = param.default;\n if (param.examples) acc[key].examples = param.examples;\n if (param.description) acc[key].description = param.description;\n return acc;\n },\n {} as Record<string, { enum?: string[]; default?: string; examples?: string[]; description?: string }>\n );\n\n const catalogedChannel = await getChannel(channelId, 'latest');\n\n if (catalogedChannel) {\n channelMarkdown = catalogedChannel.markdown;\n if (catalogedChannel.version !== channelVersion) {\n await versionChannel(channelId);\n console.log(chalk.cyan(` - Versioned previous channel: ${channelId} (v${channelVersion})`));\n }\n }\n\n await writeChannel(\n {\n id: channelId,\n name: channelAsJSON?.title || channel.id(),\n markdown: channelMarkdown,\n version: channelVersion,\n ...(Object.keys(paramsForCatalog).length > 0 && { parameters: paramsForCatalog }),\n ...(channel.address() && { address: channel.address() }),\n ...(channelAsJSON?.summary && { summary: channelAsJSON.summary }),\n ...(protocols.length > 0 && { protocols }),\n },\n { override: true }\n );\n\n console.log(chalk.cyan(` - Message ${channelId} (v${version}) created`));\n }\n }\n\n // Find events/commands\n for (const operation of operations) {\n for (const message of operation.messages()) {\n const eventType = (message.extensions().get('x-eventcatalog-message-type')?.value() as EventType) || 'event';\n const messageVersion = message.extensions().get('x-eventcatalog-message-version')?.value() || version;\n\n // does this service own or just consume the message?\n const serviceOwnsMessageContract = isServiceMessageOwner(message);\n const isReceived = operation.action() === 'receive' || operation.action() === 'subscribe';\n const isSent = operation.action() === 'send' || operation.action() === 'publish';\n\n const messageId = message.id().toLowerCase();\n\n if (eventType !== 'event' && eventType !== 'command' && eventType !== 'query') {\n throw new Error('Invalid message type');\n }\n\n const {\n write: writeMessage,\n version: versionMessage,\n get: getMessage,\n addSchema: addSchemaToMessage,\n } = MESSAGE_OPERATIONS[eventType];\n\n let messageMarkdown = generateMarkdownForMessage(document, message);\n const badges = message.tags().all() || [];\n\n console.log(chalk.blue(`Processing message: ${getMessageName(message)} (v${messageVersion})`));\n\n if (serviceOwnsMessageContract) {\n // Check if the message already exists in the catalog\n const catalogedMessage = await getMessage(message.id().toLowerCase(), 'latest');\n\n if (catalogedMessage) {\n // persist markdown if it exists\n messageMarkdown = catalogedMessage.markdown;\n\n if (catalogedMessage.version !== messageVersion) {\n // if the version does not match, we need to version the message\n await versionMessage(messageId);\n console.log(chalk.cyan(` - Versioned previous message: (v${catalogedMessage.version})`));\n }\n }\n\n const channelsForMessage = parseChannels ? getChannelsForMessage(message, channels, document) : [];\n\n // Write the message to the catalog\n await writeMessage(\n {\n id: messageId,\n version: messageVersion,\n name: getMessageName(message),\n summary: getMessageSummary(message),\n markdown: messageMarkdown,\n badges: badges.map((badge) => ({ content: badge.name(), textColor: 'blue', backgroundColor: 'blue' })),\n schemaPath: messageHasSchema(message) ? getSchemaFileName(message) : undefined,\n ...(channelsForMessage.length > 0 && { channels: channelsForMessage }),\n },\n {\n override: true,\n path: message.id(),\n }\n );\n\n console.log(chalk.cyan(` - Message (v${messageVersion}) created`));\n // Check if the message has a payload, if it does then document in EventCatalog\n if (messageHasSchema(message)) {\n // Get the schema from the original payload if it exists\n const schema = message.payload()?.extensions()?.get('x-parser-original-payload')?.json() || message.payload()?.json();\n\n await addSchemaToMessage(\n messageId,\n {\n fileName: getSchemaFileName(message),\n schema: JSON.stringify(schema, null, 4),\n },\n messageVersion\n );\n console.log(chalk.cyan(` - Schema added to message (v${messageVersion})`));\n }\n } else {\n // Message is not owned by this service, therefore we don't need to document it\n console.log(chalk.yellow(` - Skipping external message: ${getMessageName(message)}(v${messageVersion})`));\n }\n // Add the message to the correct array\n if (isSent) sends.push({ id: messageId, version: messageVersion });\n if (isReceived) receives.push({ id: messageId, version: messageVersion });\n }\n }\n\n // Check if service is already defined... if the versions do not match then create service.\n const latestServiceInCatalog = await getService(serviceId, 'latest');\n\n console.log(chalk.blue(`Processing service: ${serviceId} (v${version})`));\n\n if (latestServiceInCatalog) {\n serviceMarkdown = latestServiceInCatalog.markdown;\n // Found a service, and versions do not match, we need to version the one already there\n if (latestServiceInCatalog.version !== version) {\n await versionService(serviceId);\n console.log(chalk.cyan(` - Versioned previous service (v${latestServiceInCatalog.version})`));\n }\n\n // Match found, persist data\n if (latestServiceInCatalog.version === version) {\n // we want to preserve the markdown any any spec files that are already there\n serviceMarkdown = latestServiceInCatalog.markdown;\n serviceSpecifications = latestServiceInCatalog.specifications ?? {};\n sends = latestServiceInCatalog.sends ? [...latestServiceInCatalog.sends, ...sends] : sends;\n receives = latestServiceInCatalog.receives ? [...latestServiceInCatalog.receives, ...receives] : receives;\n serviceSpecificationsFiles = await getSpecificationFilesForService(serviceId, version);\n }\n }\n\n const fileName = path.basename(service.path);\n\n await writeService(\n {\n id: serviceId,\n name: serviceName,\n version: version,\n summary: getServiceSummary(document),\n badges: documentTags.map((tag) => ({ content: tag.name(), textColor: 'blue', backgroundColor: 'blue' })),\n markdown: serviceMarkdown,\n sends,\n receives,\n schemaPath: fileName || 'asyncapi.yml',\n specifications: {\n ...serviceSpecifications,\n asyncapiPath: fileName || 'asyncapi.yml',\n },\n },\n {\n override: true,\n }\n );\n\n // What files need added to the service (speficiation files)\n const specFiles = [\n // add any previous spec files to the list\n ...serviceSpecificationsFiles,\n {\n content: saveParsedSpecFile ? getParsedSpecFile(service, document) : await getRawSpecFile(service),\n fileName: path.basename(service.path) || 'asyncapi.yml',\n },\n ];\n\n for (const specFile of specFiles) {\n await addFileToService(\n serviceId,\n {\n fileName: specFile.fileName,\n content: specFile.content,\n },\n version\n );\n }\n\n console.log(chalk.cyan(` - Service (v${version}) created`));\n\n console.log(chalk.green(`\\nFinished generating event catalog for AsyncAPI ${serviceId} (v${version})`));\n }\n\n await checkLicense();\n};\n\nconst getParsedSpecFile = (service: Service, document: AsyncAPIDocumentInterface) => {\n const isSpecFileJSON = service.path.endsWith('.json');\n return isSpecFileJSON\n ? JSON.stringify(document.meta().asyncapi.parsed, null, 4)\n : yaml.dump(document.meta().asyncapi.parsed, { noRefs: true });\n};\n\nconst getRawSpecFile = async (service: Service) => {\n if (service.path.startsWith('http')) {\n try {\n const response = await fetch(service.path);\n return response.text();\n } catch (error) {\n console.log(chalk.red(`\\nFailed to request AsyncAPI file from ${service.path}`));\n return '';\n }\n } else {\n return await readFile(service.path, 'utf8');\n }\n};\n/**\n * Is the AsyncAPI specification (service) the owner of the message?\n * This is determined by the 'x-eventcatalog-role' extension in the message\n *\n * @param message\n * @returns boolean\n *\n * default is provider (AsyncAPI file / service owns the message)\n */\nconst isServiceMessageOwner = (message: MessageInterface): boolean => {\n const value = message.extensions().get('x-eventcatalog-role')?.value() || 'provider';\n return value === 'provider';\n};\n","export const getFileExtentionFromSchemaFormat = (format: string | undefined = '') => {\n if (format.includes('avro')) return 'avsc';\n if (format.includes('yml')) return 'yml';\n if (format.includes('json')) return 'json';\n if (format.includes('openapi')) return 'openapi';\n if (format.includes('protobuf')) return 'protobuf';\n if (format.includes('yaml')) return 'yaml';\n\n return 'json';\n};\n","import {\n MessageInterface,\n AsyncAPIDocumentInterface,\n ChannelInterface,\n ChannelsInterface,\n MessagesInterface,\n} from '@asyncapi/parser';\nimport { getFileExtentionFromSchemaFormat } from './schemas';\n\nexport const defaultMarkdown = (_document: AsyncAPIDocumentInterface, message: MessageInterface) => {\n return `\n## Architecture\n<NodeGraph />\n\n${\n messageHasSchema(message) && messageIsJSON(message)\n ? `\n## Schema\n<SchemaViewer file=\"${getSchemaFileName(message)}\" title=\"Message Schema\" maxHeight=\"500\" />\n`\n : ''\n}\n${\n messageHasSchema(message) && !messageIsJSON(message)\n ? `\n## Schema\n<Schema file=\"${getSchemaFileName(message)}\" title=\"Message Schema\" maxHeight=\"500\" />\n`\n : ''\n}\n\n${\n message.externalDocs()\n ? `\n## External documentation\n- [${message.externalDocs()?.description()}](${message.externalDocs()?.url()})\n`\n : ''\n}\n\n`;\n};\n\nexport const getSummary = (message: MessageInterface) => {\n const messageSummary = message.hasSummary() ? message.summary() : '';\n const messageDescription = message.hasDescription() ? message.description() : '';\n\n let eventCatalogMessageSummary = messageSummary;\n\n if (!eventCatalogMessageSummary) {\n eventCatalogMessageSummary = messageDescription && messageDescription.length < 150 ? messageDescription : '';\n }\n\n return eventCatalogMessageSummary;\n};\n\nexport const messageHasSchema = (message: MessageInterface) => {\n return message.hasPayload() && message.schemaFormat();\n};\n\nexport const messageIsJSON = (message: MessageInterface) => {\n const fileName = getSchemaFileName(message);\n return fileName.endsWith('.json');\n};\n\nexport const getSchemaFileName = (message: MessageInterface) => {\n const extension = getFileExtentionFromSchemaFormat(message.schemaFormat());\n return `schema.${extension}`;\n};\n\nexport const getMessageName = (message: MessageInterface) => {\n return message.hasTitle() && message.title() ? (message.title() as string) : message.id();\n};\n\nexport const getChannelsForMessage = (\n message: MessageInterface,\n channels: ChannelsInterface,\n document: AsyncAPIDocumentInterface\n): { id: string; version: string }[] => {\n let channelsForMessage: ChannelInterface[] = [];\n const globalVersion = document.info().version();\n\n // Go through all channels and link messages they document\n for (const channel of channels) {\n for (const channelMessage of channel.messages() as MessagesInterface) {\n if (channelMessage.id() === message.id()) {\n channelsForMessage.push(channel);\n }\n }\n }\n\n // You can also document a message directly to a channel, add them too\n for (const messageChannel of message.channels()) {\n channelsForMessage.push(messageChannel);\n }\n\n // Make them unique, as there may be overlapping channels\n const uniqueChannels = channelsForMessage.filter(\n (channel, index, self) => index === self.findIndex((t) => t.id() === channel.id())\n );\n\n return uniqueChannels.map((channel) => {\n const channelVersion = channel.extensions().get('x-eventcatalog-channel-version')?.value() || globalVersion;\n return {\n id: channel.id(),\n version: channelVersion,\n };\n });\n};\n","import { AsyncAPIDocumentInterface } from '@asyncapi/parser';\n\nexport const defaultMarkdown = (document: AsyncAPIDocumentInterface) => {\n return `\n\n${document.info().hasDescription() ? `${document.info().description()}` : ''} \n\n## Architecture diagram\n<NodeGraph />\n\n${\n document.info().externalDocs()\n ? `\n## External documentation\n- [${document.info().externalDocs()?.description()}](${document.info().externalDocs()?.url()})\n`\n : ''\n}\n`;\n};\n\nexport const getSummary = (document: AsyncAPIDocumentInterface) => {\n const summary = document.info().hasDescription() ? document.info().description() : '';\n return summary && summary.length < 150 ? summary : '';\n};\n","import { AsyncAPIDocumentInterface } from '@asyncapi/parser';\n\nexport const defaultMarkdown = (document: AsyncAPIDocumentInterface) => {\n return `\n\n## Architecture diagram\n<NodeGraph />\n\n`;\n};\n","import { AsyncAPIDocumentInterface, ChannelInterface } from '@asyncapi/parser';\n\nexport const getChannelProtocols = (channel: ChannelInterface): string[] => {\n const protocols = [];\n\n const bindings = channel.bindings();\n for (const binding of bindings) {\n protocols.push(binding.protocol());\n }\n\n return protocols;\n};\n\nexport const defaultMarkdown = (_document: AsyncAPIDocumentInterface, channel: ChannelInterface) => {\n return `\n ${\n channel.hasDescription()\n ? `\n ## Overview\n ${channel.description()}\n `\n : ''\n }\n\n <ChannelInformation />\n\n ${\n channel.json()?.externalDocs\n ? `\n ## External documentation\n - [${channel.json()?.externalDocs?.description}](${channel.json()?.externalDocs?.url})\n `\n : ''\n }\n \n `;\n};\n","import chalk from 'chalk';\n\nexport default () => {\n console.log(chalk.bgBlue(`\\nYou are using the open source license for this plugin`));\n console.log(\n chalk.blueBright(\n `This plugin is governed and published under a dual-license. \\nIf using for internal, commercial or proprietary software, you can purchase a license at https://dashboard.eventcatalog.dev/ or contact us hello@eventcatalog.dev.`\n )\n );\n};\n"],"mappings":";AAAA,SAAsD,QAAQ,UAAU,eAAe;AACvF,OAAO,WAAW;AAClB,SAAS,gBAAgB;AACzB,OAAO,UAAU;AACjB,OAAO,UAAU;AACjB,SAAS,SAAS;AAClB,OAAOA,YAAW;AAClB,OAAO,UAAU;AAGjB,SAAS,wBAAwB;;;ACV1B,IAAM,mCAAmC,CAAC,SAA6B,OAAO;AACnF,MAAI,OAAO,SAAS,MAAM,EAAG,QAAO;AACpC,MAAI,OA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A,MAC3C;AAAA,IACF;AAEA,eAAW,YAAY,WAAW;AAChC,YAAM;AAAA,QACJ;AAAA,QACA;AAAA,UACE,UAAU,SAAS;AAAA,UACnB,SAAS,SAAS;AAAA,QACpB;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,YAAQ,IAAIF,OAAM,KAAK,gBAAgB,OAAO,WAAW,CAAC;AAE1D,YAAQ,IAAIA,OAAM,MAAM;AAAA,iDAAoD,SAAS,MAAM,OAAO,GAAG,CAAC;AAAA,EACxG;AAEA,QAAM,qBAAa;AACrB;AAEA,IAAM,oBAAoB,CAAC,SAAkB,aAAwC;AACnF,QAAM,iBAAiB,QAAQ,KAAK,SAAS,OAAO;AACpD,SAAO,iBACH,KAAK,UAAU,SAAS,KAAK,EAAE,SAAS,QAAQ,MAAM,CAAC,IACvD,KAAK,KAAK,SAAS,KAAK,EAAE,SAAS,QAAQ,EAAE,QAAQ,KAAK,CAAC;AACjE;AAEA,IAAM,iBAAiB,OAAO,YAAqB;AACjD,MAAI,QAAQ,KAAK,WAAW,MAAM,GAAG;AACnC,QAAI;AACF,YAAM,WAAW,MAAM,MAAM,QAAQ,IAAI;AACzC,aAAO,SAAS,KAAK;AAAA,IACvB,SAAS,OAAO;AACd,cAAQ,IAAIA,OAAM,IAAI;AAAA,uCAA0C,QAAQ,IAAI,EAAE,CAAC;AAC/E,aAAO;AAAA,IACT;AAAA,EACF,OAAO;AACL,WAAO,MAAM,SAAS,QAAQ,MAAM,MAAM;AAAA,EAC5C;AACF;AAUA,IAAM,wBAAwB,CAAC,YAAuC;AACpE,QAAM,QAAQ,QAAQ,WAAW,EAAE,IAAI,qBAAqB,GAAG,MAAM,KAAK;AAC1E,SAAO,UAAU;AACnB;","names":["chalk","defaultMarkdown","getSummary","defaultMarkdown","defaultMarkdown","chalk","defaultMarkdown","getSummary"]}
|
package/dist/types.d.mts
CHANGED
|
@@ -2,7 +2,6 @@ interface MessageOperations {
|
|
|
2
2
|
write: (payload: any, options: any) => Promise<void>;
|
|
3
3
|
version: (id: string) => Promise<any>;
|
|
4
4
|
get: (id: string, version: string) => Promise<any>;
|
|
5
|
-
remove: (id: string, version: string) => Promise<void>;
|
|
6
5
|
addSchema: (id: string, schema: any, version: any) => Promise<void>;
|
|
7
6
|
}
|
|
8
7
|
type EventType = 'event' | 'command' | 'query';
|
package/dist/types.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ interface MessageOperations {
|
|
|
2
2
|
write: (payload: any, options: any) => Promise<void>;
|
|
3
3
|
version: (id: string) => Promise<any>;
|
|
4
4
|
get: (id: string, version: string) => Promise<any>;
|
|
5
|
-
remove: (id: string, version: string) => Promise<void>;
|
|
6
5
|
addSchema: (id: string, schema: any, version: any) => Promise<void>;
|
|
7
6
|
}
|
|
8
7
|
type EventType = 'event' | 'command' | 'query';
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["// Define the types of operations available for each message type\nexport interface MessageOperations {\n write: (payload: any, options: any) => Promise<void>;\n version: (id: string) => Promise<any>;\n get: (id: string, version: string) => Promise<any>;\n
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["// Define the types of operations available for each message type\nexport interface MessageOperations {\n write: (payload: any, options: any) => Promise<void>;\n version: (id: string) => Promise<any>;\n get: (id: string, version: string) => Promise<any>;\n addSchema: (id: string, schema: any, version: any) => Promise<void>;\n}\n\n// Define valid event types\nexport type EventType = 'event' | 'command' | 'query';\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eventcatalog/generator-asyncapi",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"description": "AsyncAPI generator for EventCatalog",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@asyncapi/avro-schema-parser": "^3.0.24",
|
|
32
32
|
"@asyncapi/parser": "^3.3.0",
|
|
33
|
-
"@eventcatalog/sdk": "^1.1
|
|
33
|
+
"@eventcatalog/sdk": "^1.4.1",
|
|
34
34
|
"chalk": "^4",
|
|
35
35
|
"fs-extra": "^11.2.0",
|
|
36
36
|
"glob": "^11.0.0",
|