@eventcatalog/generator-asyncapi 6.0.0 → 6.1.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 +27 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -4
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.mts +4 -0
- package/dist/types.d.ts +4 -0
- package/dist/types.js.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1538,7 +1538,7 @@ import path3 from "path";
|
|
|
1538
1538
|
// package.json
|
|
1539
1539
|
var package_default = {
|
|
1540
1540
|
name: "@eventcatalog/generator-asyncapi",
|
|
1541
|
-
version: "6.
|
|
1541
|
+
version: "6.1.0",
|
|
1542
1542
|
description: "AsyncAPI generator for EventCatalog",
|
|
1543
1543
|
scripts: {
|
|
1544
1544
|
build: "tsup",
|
|
@@ -1575,8 +1575,8 @@ var package_default = {
|
|
|
1575
1575
|
types: "./dist/index.d.ts",
|
|
1576
1576
|
dependencies: {
|
|
1577
1577
|
"@asyncapi/avro-schema-parser": "3.0.24",
|
|
1578
|
-
"@asyncapi/parser": "3.
|
|
1579
|
-
"@eventcatalog/sdk": "2.
|
|
1578
|
+
"@asyncapi/parser": "3.6.0",
|
|
1579
|
+
"@eventcatalog/sdk": "2.17.4",
|
|
1580
1580
|
chalk: "4.1.2",
|
|
1581
1581
|
"fs-extra": "^11.2.0",
|
|
1582
1582
|
glob: "^11.0.0",
|
|
@@ -4134,6 +4134,7 @@ var optionsSchema = z.object({
|
|
|
4134
4134
|
debug: z.boolean().optional(),
|
|
4135
4135
|
parseSchemas: z.boolean().optional(),
|
|
4136
4136
|
parseChannels: z.boolean().optional(),
|
|
4137
|
+
parseExamples: z.boolean().optional(),
|
|
4137
4138
|
attachHeadersToSchema: z.boolean().optional(),
|
|
4138
4139
|
saveParsedSpecFile: z.boolean({ invalid_type_error: "The saveParsedSpecFile is not a boolean in options" }).optional()
|
|
4139
4140
|
});
|
|
@@ -4187,7 +4188,10 @@ var index_default = async (config, options) => {
|
|
|
4187
4188
|
getSpecificationFilesForService,
|
|
4188
4189
|
writeChannel,
|
|
4189
4190
|
getChannel,
|
|
4190
|
-
versionChannel
|
|
4191
|
+
versionChannel,
|
|
4192
|
+
addExampleToEvent,
|
|
4193
|
+
addExampleToCommand,
|
|
4194
|
+
addExampleToQuery
|
|
4191
4195
|
} = utils(process.env.PROJECT_DIR);
|
|
4192
4196
|
const MESSAGE_OPERATIONS = {
|
|
4193
4197
|
event: {
|
|
@@ -4195,6 +4199,7 @@ var index_default = async (config, options) => {
|
|
|
4195
4199
|
version: versionEvent,
|
|
4196
4200
|
get: getEvent,
|
|
4197
4201
|
addSchema: addSchemaToEvent,
|
|
4202
|
+
addExample: addExampleToEvent,
|
|
4198
4203
|
collection: "events"
|
|
4199
4204
|
},
|
|
4200
4205
|
command: {
|
|
@@ -4202,6 +4207,7 @@ var index_default = async (config, options) => {
|
|
|
4202
4207
|
version: versionCommand,
|
|
4203
4208
|
get: getCommand,
|
|
4204
4209
|
addSchema: addSchemaToCommand,
|
|
4210
|
+
addExample: addExampleToCommand,
|
|
4205
4211
|
collection: "commands"
|
|
4206
4212
|
},
|
|
4207
4213
|
query: {
|
|
@@ -4209,6 +4215,7 @@ var index_default = async (config, options) => {
|
|
|
4209
4215
|
version: versionQuery,
|
|
4210
4216
|
get: getQuery,
|
|
4211
4217
|
addSchema: addSchemaToQuery,
|
|
4218
|
+
addExample: addExampleToQuery,
|
|
4212
4219
|
collection: "queries"
|
|
4213
4220
|
}
|
|
4214
4221
|
};
|
|
@@ -4218,6 +4225,7 @@ var index_default = async (config, options) => {
|
|
|
4218
4225
|
saveParsedSpecFile = false,
|
|
4219
4226
|
parseSchemas = true,
|
|
4220
4227
|
parseChannels = false,
|
|
4228
|
+
parseExamples = true,
|
|
4221
4229
|
attachHeadersToSchema = false
|
|
4222
4230
|
} = options;
|
|
4223
4231
|
console.log(chalk4.green(`Processing ${services.length} AsyncAPI files...`));
|
|
@@ -4374,6 +4382,7 @@ Processing domain: ${domainName} (v${domainVersion})`));
|
|
|
4374
4382
|
version: versionMessage,
|
|
4375
4383
|
get: getMessage,
|
|
4376
4384
|
addSchema: addSchemaToMessage,
|
|
4385
|
+
addExample: addExampleToMessage,
|
|
4377
4386
|
collection: folder
|
|
4378
4387
|
} = MESSAGE_OPERATIONS[eventType];
|
|
4379
4388
|
const generatedMarkdownForMessage = defaultMarkdown(document2, message2);
|
|
@@ -4433,6 +4442,20 @@ Processing domain: ${domainName} (v${domainVersion})`));
|
|
|
4433
4442
|
);
|
|
4434
4443
|
console.log(chalk4.cyan(` - Schema added to message (v${messageVersion})`));
|
|
4435
4444
|
}
|
|
4445
|
+
if (parseExamples) {
|
|
4446
|
+
const messageExamples = message2.examples().all();
|
|
4447
|
+
for (let i = 0; i < messageExamples.length; i++) {
|
|
4448
|
+
const example = messageExamples[i];
|
|
4449
|
+
const payload = example.payload();
|
|
4450
|
+
if (payload) {
|
|
4451
|
+
const fileName2 = example.hasName() ? `${example.name()}.json` : `example-${i}.json`;
|
|
4452
|
+
await addExampleToMessage(messageId, { content: JSON.stringify(payload, null, 2), fileName: fileName2 }, messageVersion);
|
|
4453
|
+
}
|
|
4454
|
+
}
|
|
4455
|
+
if (messageExamples.length > 0) {
|
|
4456
|
+
console.log(chalk4.cyan(` - ${messageExamples.length} example(s) added to message (v${messageVersion})`));
|
|
4457
|
+
}
|
|
4458
|
+
}
|
|
4436
4459
|
} else {
|
|
4437
4460
|
console.log(chalk4.yellow(` - Skipping external message: ${getMessageName(message2)}(v${messageVersion})`));
|
|
4438
4461
|
}
|