@eventcatalog/generator-asyncapi 6.0.1 → 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 +26 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -3
- 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 +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -241,6 +241,7 @@ declare const optionsSchema: z.ZodObject<{
|
|
|
241
241
|
debug: z.ZodOptional<z.ZodBoolean>;
|
|
242
242
|
parseSchemas: z.ZodOptional<z.ZodBoolean>;
|
|
243
243
|
parseChannels: z.ZodOptional<z.ZodBoolean>;
|
|
244
|
+
parseExamples: z.ZodOptional<z.ZodBoolean>;
|
|
244
245
|
attachHeadersToSchema: z.ZodOptional<z.ZodBoolean>;
|
|
245
246
|
saveParsedSpecFile: z.ZodOptional<z.ZodBoolean>;
|
|
246
247
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -304,6 +305,7 @@ declare const optionsSchema: z.ZodObject<{
|
|
|
304
305
|
debug?: boolean | undefined;
|
|
305
306
|
parseSchemas?: boolean | undefined;
|
|
306
307
|
parseChannels?: boolean | undefined;
|
|
308
|
+
parseExamples?: boolean | undefined;
|
|
307
309
|
attachHeadersToSchema?: boolean | undefined;
|
|
308
310
|
saveParsedSpecFile?: boolean | undefined;
|
|
309
311
|
}, {
|
|
@@ -367,6 +369,7 @@ declare const optionsSchema: z.ZodObject<{
|
|
|
367
369
|
debug?: boolean | undefined;
|
|
368
370
|
parseSchemas?: boolean | undefined;
|
|
369
371
|
parseChannels?: boolean | undefined;
|
|
372
|
+
parseExamples?: boolean | undefined;
|
|
370
373
|
attachHeadersToSchema?: boolean | undefined;
|
|
371
374
|
saveParsedSpecFile?: boolean | undefined;
|
|
372
375
|
}>;
|
package/dist/index.d.ts
CHANGED
|
@@ -241,6 +241,7 @@ declare const optionsSchema: z.ZodObject<{
|
|
|
241
241
|
debug: z.ZodOptional<z.ZodBoolean>;
|
|
242
242
|
parseSchemas: z.ZodOptional<z.ZodBoolean>;
|
|
243
243
|
parseChannels: z.ZodOptional<z.ZodBoolean>;
|
|
244
|
+
parseExamples: z.ZodOptional<z.ZodBoolean>;
|
|
244
245
|
attachHeadersToSchema: z.ZodOptional<z.ZodBoolean>;
|
|
245
246
|
saveParsedSpecFile: z.ZodOptional<z.ZodBoolean>;
|
|
246
247
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -304,6 +305,7 @@ declare const optionsSchema: z.ZodObject<{
|
|
|
304
305
|
debug?: boolean | undefined;
|
|
305
306
|
parseSchemas?: boolean | undefined;
|
|
306
307
|
parseChannels?: boolean | undefined;
|
|
308
|
+
parseExamples?: boolean | undefined;
|
|
307
309
|
attachHeadersToSchema?: boolean | undefined;
|
|
308
310
|
saveParsedSpecFile?: boolean | undefined;
|
|
309
311
|
}, {
|
|
@@ -367,6 +369,7 @@ declare const optionsSchema: z.ZodObject<{
|
|
|
367
369
|
debug?: boolean | undefined;
|
|
368
370
|
parseSchemas?: boolean | undefined;
|
|
369
371
|
parseChannels?: boolean | undefined;
|
|
372
|
+
parseExamples?: boolean | undefined;
|
|
370
373
|
attachHeadersToSchema?: boolean | undefined;
|
|
371
374
|
saveParsedSpecFile?: boolean | undefined;
|
|
372
375
|
}>;
|
package/dist/index.js
CHANGED
|
@@ -1543,7 +1543,7 @@ var import_path3 = __toESM(require("path"));
|
|
|
1543
1543
|
// package.json
|
|
1544
1544
|
var package_default = {
|
|
1545
1545
|
name: "@eventcatalog/generator-asyncapi",
|
|
1546
|
-
version: "6.0
|
|
1546
|
+
version: "6.1.0",
|
|
1547
1547
|
description: "AsyncAPI generator for EventCatalog",
|
|
1548
1548
|
scripts: {
|
|
1549
1549
|
build: "tsup",
|
|
@@ -1581,7 +1581,7 @@ var package_default = {
|
|
|
1581
1581
|
dependencies: {
|
|
1582
1582
|
"@asyncapi/avro-schema-parser": "3.0.24",
|
|
1583
1583
|
"@asyncapi/parser": "3.6.0",
|
|
1584
|
-
"@eventcatalog/sdk": "2.
|
|
1584
|
+
"@eventcatalog/sdk": "2.17.4",
|
|
1585
1585
|
chalk: "4.1.2",
|
|
1586
1586
|
"fs-extra": "^11.2.0",
|
|
1587
1587
|
glob: "^11.0.0",
|
|
@@ -4139,6 +4139,7 @@ var optionsSchema = import_zod.z.object({
|
|
|
4139
4139
|
debug: import_zod.z.boolean().optional(),
|
|
4140
4140
|
parseSchemas: import_zod.z.boolean().optional(),
|
|
4141
4141
|
parseChannels: import_zod.z.boolean().optional(),
|
|
4142
|
+
parseExamples: import_zod.z.boolean().optional(),
|
|
4142
4143
|
attachHeadersToSchema: import_zod.z.boolean().optional(),
|
|
4143
4144
|
saveParsedSpecFile: import_zod.z.boolean({ invalid_type_error: "The saveParsedSpecFile is not a boolean in options" }).optional()
|
|
4144
4145
|
});
|
|
@@ -4192,7 +4193,10 @@ var index_default = async (config, options) => {
|
|
|
4192
4193
|
getSpecificationFilesForService,
|
|
4193
4194
|
writeChannel,
|
|
4194
4195
|
getChannel,
|
|
4195
|
-
versionChannel
|
|
4196
|
+
versionChannel,
|
|
4197
|
+
addExampleToEvent,
|
|
4198
|
+
addExampleToCommand,
|
|
4199
|
+
addExampleToQuery
|
|
4196
4200
|
} = (0, import_sdk.default)(process.env.PROJECT_DIR);
|
|
4197
4201
|
const MESSAGE_OPERATIONS = {
|
|
4198
4202
|
event: {
|
|
@@ -4200,6 +4204,7 @@ var index_default = async (config, options) => {
|
|
|
4200
4204
|
version: versionEvent,
|
|
4201
4205
|
get: getEvent,
|
|
4202
4206
|
addSchema: addSchemaToEvent,
|
|
4207
|
+
addExample: addExampleToEvent,
|
|
4203
4208
|
collection: "events"
|
|
4204
4209
|
},
|
|
4205
4210
|
command: {
|
|
@@ -4207,6 +4212,7 @@ var index_default = async (config, options) => {
|
|
|
4207
4212
|
version: versionCommand,
|
|
4208
4213
|
get: getCommand,
|
|
4209
4214
|
addSchema: addSchemaToCommand,
|
|
4215
|
+
addExample: addExampleToCommand,
|
|
4210
4216
|
collection: "commands"
|
|
4211
4217
|
},
|
|
4212
4218
|
query: {
|
|
@@ -4214,6 +4220,7 @@ var index_default = async (config, options) => {
|
|
|
4214
4220
|
version: versionQuery,
|
|
4215
4221
|
get: getQuery,
|
|
4216
4222
|
addSchema: addSchemaToQuery,
|
|
4223
|
+
addExample: addExampleToQuery,
|
|
4217
4224
|
collection: "queries"
|
|
4218
4225
|
}
|
|
4219
4226
|
};
|
|
@@ -4223,6 +4230,7 @@ var index_default = async (config, options) => {
|
|
|
4223
4230
|
saveParsedSpecFile = false,
|
|
4224
4231
|
parseSchemas = true,
|
|
4225
4232
|
parseChannels = false,
|
|
4233
|
+
parseExamples = true,
|
|
4226
4234
|
attachHeadersToSchema = false
|
|
4227
4235
|
} = options;
|
|
4228
4236
|
console.log(import_chalk4.default.green(`Processing ${services.length} AsyncAPI files...`));
|
|
@@ -4379,6 +4387,7 @@ Processing domain: ${domainName} (v${domainVersion})`));
|
|
|
4379
4387
|
version: versionMessage,
|
|
4380
4388
|
get: getMessage,
|
|
4381
4389
|
addSchema: addSchemaToMessage,
|
|
4390
|
+
addExample: addExampleToMessage,
|
|
4382
4391
|
collection: folder
|
|
4383
4392
|
} = MESSAGE_OPERATIONS[eventType];
|
|
4384
4393
|
const generatedMarkdownForMessage = defaultMarkdown(document2, message2);
|
|
@@ -4438,6 +4447,20 @@ Processing domain: ${domainName} (v${domainVersion})`));
|
|
|
4438
4447
|
);
|
|
4439
4448
|
console.log(import_chalk4.default.cyan(` - Schema added to message (v${messageVersion})`));
|
|
4440
4449
|
}
|
|
4450
|
+
if (parseExamples) {
|
|
4451
|
+
const messageExamples = message2.examples().all();
|
|
4452
|
+
for (let i = 0; i < messageExamples.length; i++) {
|
|
4453
|
+
const example = messageExamples[i];
|
|
4454
|
+
const payload = example.payload();
|
|
4455
|
+
if (payload) {
|
|
4456
|
+
const fileName2 = example.hasName() ? `${example.name()}.json` : `example-${i}.json`;
|
|
4457
|
+
await addExampleToMessage(messageId, { content: JSON.stringify(payload, null, 2), fileName: fileName2 }, messageVersion);
|
|
4458
|
+
}
|
|
4459
|
+
}
|
|
4460
|
+
if (messageExamples.length > 0) {
|
|
4461
|
+
console.log(import_chalk4.default.cyan(` - ${messageExamples.length} example(s) added to message (v${messageVersion})`));
|
|
4462
|
+
}
|
|
4463
|
+
}
|
|
4441
4464
|
} else {
|
|
4442
4465
|
console.log(import_chalk4.default.yellow(` - Skipping external message: ${getMessageName(message2)}(v${messageVersion})`));
|
|
4443
4466
|
}
|