@eventcatalog/generator-asyncapi 6.1.0 → 6.2.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.js +38 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -9
- package/dist/index.mjs.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.2.0",
|
|
1542
1542
|
description: "AsyncAPI generator for EventCatalog",
|
|
1543
1543
|
scripts: {
|
|
1544
1544
|
build: "tsup",
|
|
@@ -1576,10 +1576,10 @@ var package_default = {
|
|
|
1576
1576
|
dependencies: {
|
|
1577
1577
|
"@asyncapi/avro-schema-parser": "3.0.24",
|
|
1578
1578
|
"@asyncapi/parser": "3.6.0",
|
|
1579
|
-
"@eventcatalog/sdk": "2.
|
|
1579
|
+
"@eventcatalog/sdk": "2.18.2",
|
|
1580
1580
|
chalk: "4.1.2",
|
|
1581
1581
|
"fs-extra": "^11.2.0",
|
|
1582
|
-
glob: "^
|
|
1582
|
+
glob: "^12.0.0",
|
|
1583
1583
|
"gray-matter": "^4.0.3",
|
|
1584
1584
|
"js-yaml": "^4.1.0",
|
|
1585
1585
|
lodash: "^4.17.23",
|
|
@@ -4066,6 +4066,26 @@ Failed to verify license key`));
|
|
|
4066
4066
|
// src/index.ts
|
|
4067
4067
|
import { join } from "path";
|
|
4068
4068
|
var parser = new Parser();
|
|
4069
|
+
var safeStringify = (obj, indent) => {
|
|
4070
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
4071
|
+
return JSON.stringify(
|
|
4072
|
+
obj,
|
|
4073
|
+
(_key, value) => {
|
|
4074
|
+
if (typeof value === "object" && value !== null) {
|
|
4075
|
+
if (seen.has(value)) {
|
|
4076
|
+
const schemaId = value["x-parser-schema-id"];
|
|
4077
|
+
if (schemaId && typeof schemaId === "string") {
|
|
4078
|
+
return { $ref: `#/components/schemas/${schemaId}` };
|
|
4079
|
+
}
|
|
4080
|
+
return { $ref: "#" };
|
|
4081
|
+
}
|
|
4082
|
+
seen.add(value);
|
|
4083
|
+
}
|
|
4084
|
+
return value;
|
|
4085
|
+
},
|
|
4086
|
+
indent
|
|
4087
|
+
);
|
|
4088
|
+
};
|
|
4069
4089
|
parser.registerSchemaParser(AvroSchemaParser());
|
|
4070
4090
|
var cliArgs = argv(process.argv.slice(2));
|
|
4071
4091
|
var optionsSchema = z.object({
|
|
@@ -4185,6 +4205,7 @@ var index_default = async (config, options) => {
|
|
|
4185
4205
|
addSchemaToQuery,
|
|
4186
4206
|
addFileToService,
|
|
4187
4207
|
versionDomain,
|
|
4208
|
+
getResourcePath,
|
|
4188
4209
|
getSpecificationFilesForService,
|
|
4189
4210
|
writeChannel,
|
|
4190
4211
|
getChannel,
|
|
@@ -4273,10 +4294,6 @@ var index_default = async (config, options) => {
|
|
|
4273
4294
|
markdown: generatedMarkdownForService
|
|
4274
4295
|
}) : generatedMarkdownForService;
|
|
4275
4296
|
let styles2 = null;
|
|
4276
|
-
let servicePath = options.domain ? path3.join("../", "domains", options.domain.id, "services", service.id) : path3.join("../", "services", service.id);
|
|
4277
|
-
if (options.writeFilesToRoot) {
|
|
4278
|
-
servicePath = service.id;
|
|
4279
|
-
}
|
|
4280
4297
|
if (options.domain) {
|
|
4281
4298
|
const { id: domainId, name: domainName, version: domainVersion, owners: domainOwners } = options.domain;
|
|
4282
4299
|
const domain = await getDomain(options.domain.id, domainVersion || "latest");
|
|
@@ -4306,6 +4323,18 @@ Processing domain: ${domainName} (v${domainVersion})`));
|
|
|
4306
4323
|
}
|
|
4307
4324
|
await addServiceToDomain(domainId, { id: serviceId, version }, domainVersion);
|
|
4308
4325
|
}
|
|
4326
|
+
let servicePath = path3.join("../", "services", service.id);
|
|
4327
|
+
if (options.domain) {
|
|
4328
|
+
const domainResource = await getResourcePath(process.env.PROJECT_DIR, options.domain.id, options.domain.version);
|
|
4329
|
+
if (domainResource) {
|
|
4330
|
+
servicePath = path3.join("../", domainResource.directory, "services", service.id);
|
|
4331
|
+
} else {
|
|
4332
|
+
servicePath = path3.join("../", "domains", options.domain.id, "services", service.id);
|
|
4333
|
+
}
|
|
4334
|
+
}
|
|
4335
|
+
if (options.writeFilesToRoot) {
|
|
4336
|
+
servicePath = service.id;
|
|
4337
|
+
}
|
|
4309
4338
|
if (parseChannels) {
|
|
4310
4339
|
for (const channel of channels) {
|
|
4311
4340
|
const channelAsJSON = channel.json();
|
|
@@ -4435,7 +4464,7 @@ Processing domain: ${domainName} (v${domainVersion})`));
|
|
|
4435
4464
|
messageId,
|
|
4436
4465
|
{
|
|
4437
4466
|
fileName: getSchemaFileName(message2),
|
|
4438
|
-
schema:
|
|
4467
|
+
schema: safeStringify(schema, 4)
|
|
4439
4468
|
},
|
|
4440
4469
|
messageVersion,
|
|
4441
4470
|
{ path: cleanedMessagePath }
|
|
@@ -4557,7 +4586,7 @@ Finished generating event catalog for AsyncAPI ${serviceId} (v${version})`));
|
|
|
4557
4586
|
};
|
|
4558
4587
|
var getParsedSpecFile = (service, document2) => {
|
|
4559
4588
|
const isSpecFileJSON = service.path.endsWith(".json");
|
|
4560
|
-
return isSpecFileJSON ?
|
|
4589
|
+
return isSpecFileJSON ? safeStringify(document2.meta().asyncapi.parsed, 4) : yaml.dump(document2.meta().asyncapi.parsed, { noRefs: true });
|
|
4561
4590
|
};
|
|
4562
4591
|
var getRawSpecFile = async (service) => {
|
|
4563
4592
|
if (service.path.startsWith("http")) {
|