@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.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.
|
|
1546
|
+
version: "6.2.0",
|
|
1547
1547
|
description: "AsyncAPI generator for EventCatalog",
|
|
1548
1548
|
scripts: {
|
|
1549
1549
|
build: "tsup",
|
|
@@ -1581,10 +1581,10 @@ 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.18.2",
|
|
1585
1585
|
chalk: "4.1.2",
|
|
1586
1586
|
"fs-extra": "^11.2.0",
|
|
1587
|
-
glob: "^
|
|
1587
|
+
glob: "^12.0.0",
|
|
1588
1588
|
"gray-matter": "^4.0.3",
|
|
1589
1589
|
"js-yaml": "^4.1.0",
|
|
1590
1590
|
lodash: "^4.17.23",
|
|
@@ -4071,6 +4071,26 @@ Failed to verify license key`));
|
|
|
4071
4071
|
// src/index.ts
|
|
4072
4072
|
var import_node_path = require("path");
|
|
4073
4073
|
var parser = new import_parser.Parser();
|
|
4074
|
+
var safeStringify = (obj, indent) => {
|
|
4075
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
4076
|
+
return JSON.stringify(
|
|
4077
|
+
obj,
|
|
4078
|
+
(_key, value) => {
|
|
4079
|
+
if (typeof value === "object" && value !== null) {
|
|
4080
|
+
if (seen.has(value)) {
|
|
4081
|
+
const schemaId = value["x-parser-schema-id"];
|
|
4082
|
+
if (schemaId && typeof schemaId === "string") {
|
|
4083
|
+
return { $ref: `#/components/schemas/${schemaId}` };
|
|
4084
|
+
}
|
|
4085
|
+
return { $ref: "#" };
|
|
4086
|
+
}
|
|
4087
|
+
seen.add(value);
|
|
4088
|
+
}
|
|
4089
|
+
return value;
|
|
4090
|
+
},
|
|
4091
|
+
indent
|
|
4092
|
+
);
|
|
4093
|
+
};
|
|
4074
4094
|
parser.registerSchemaParser((0, import_avro_schema_parser.AvroSchemaParser)());
|
|
4075
4095
|
var cliArgs = (0, import_minimist.default)(process.argv.slice(2));
|
|
4076
4096
|
var optionsSchema = import_zod.z.object({
|
|
@@ -4190,6 +4210,7 @@ var index_default = async (config, options) => {
|
|
|
4190
4210
|
addSchemaToQuery,
|
|
4191
4211
|
addFileToService,
|
|
4192
4212
|
versionDomain,
|
|
4213
|
+
getResourcePath,
|
|
4193
4214
|
getSpecificationFilesForService,
|
|
4194
4215
|
writeChannel,
|
|
4195
4216
|
getChannel,
|
|
@@ -4278,10 +4299,6 @@ var index_default = async (config, options) => {
|
|
|
4278
4299
|
markdown: generatedMarkdownForService
|
|
4279
4300
|
}) : generatedMarkdownForService;
|
|
4280
4301
|
let styles2 = null;
|
|
4281
|
-
let servicePath = options.domain ? import_path3.default.join("../", "domains", options.domain.id, "services", service.id) : import_path3.default.join("../", "services", service.id);
|
|
4282
|
-
if (options.writeFilesToRoot) {
|
|
4283
|
-
servicePath = service.id;
|
|
4284
|
-
}
|
|
4285
4302
|
if (options.domain) {
|
|
4286
4303
|
const { id: domainId, name: domainName, version: domainVersion, owners: domainOwners } = options.domain;
|
|
4287
4304
|
const domain = await getDomain(options.domain.id, domainVersion || "latest");
|
|
@@ -4311,6 +4328,18 @@ Processing domain: ${domainName} (v${domainVersion})`));
|
|
|
4311
4328
|
}
|
|
4312
4329
|
await addServiceToDomain(domainId, { id: serviceId, version }, domainVersion);
|
|
4313
4330
|
}
|
|
4331
|
+
let servicePath = import_path3.default.join("../", "services", service.id);
|
|
4332
|
+
if (options.domain) {
|
|
4333
|
+
const domainResource = await getResourcePath(process.env.PROJECT_DIR, options.domain.id, options.domain.version);
|
|
4334
|
+
if (domainResource) {
|
|
4335
|
+
servicePath = import_path3.default.join("../", domainResource.directory, "services", service.id);
|
|
4336
|
+
} else {
|
|
4337
|
+
servicePath = import_path3.default.join("../", "domains", options.domain.id, "services", service.id);
|
|
4338
|
+
}
|
|
4339
|
+
}
|
|
4340
|
+
if (options.writeFilesToRoot) {
|
|
4341
|
+
servicePath = service.id;
|
|
4342
|
+
}
|
|
4314
4343
|
if (parseChannels) {
|
|
4315
4344
|
for (const channel of channels) {
|
|
4316
4345
|
const channelAsJSON = channel.json();
|
|
@@ -4440,7 +4469,7 @@ Processing domain: ${domainName} (v${domainVersion})`));
|
|
|
4440
4469
|
messageId,
|
|
4441
4470
|
{
|
|
4442
4471
|
fileName: getSchemaFileName(message2),
|
|
4443
|
-
schema:
|
|
4472
|
+
schema: safeStringify(schema, 4)
|
|
4444
4473
|
},
|
|
4445
4474
|
messageVersion,
|
|
4446
4475
|
{ path: cleanedMessagePath }
|
|
@@ -4562,7 +4591,7 @@ Finished generating event catalog for AsyncAPI ${serviceId} (v${version})`));
|
|
|
4562
4591
|
};
|
|
4563
4592
|
var getParsedSpecFile = (service, document2) => {
|
|
4564
4593
|
const isSpecFileJSON = service.path.endsWith(".json");
|
|
4565
|
-
return isSpecFileJSON ?
|
|
4594
|
+
return isSpecFileJSON ? safeStringify(document2.meta().asyncapi.parsed, 4) : import_js_yaml.default.dump(document2.meta().asyncapi.parsed, { noRefs: true });
|
|
4566
4595
|
};
|
|
4567
4596
|
var getRawSpecFile = async (service) => {
|
|
4568
4597
|
if (service.path.startsWith("http")) {
|