@eventcatalog/core 3.26.13 → 3.26.15

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.
@@ -37,7 +37,7 @@ var import_axios = __toESM(require("axios"), 1);
37
37
  var import_os = __toESM(require("os"), 1);
38
38
 
39
39
  // package.json
40
- var version = "3.26.13";
40
+ var version = "3.26.15";
41
41
 
42
42
  // src/constants.ts
43
43
  var VERSION = version;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  raiseEvent
3
- } from "../chunk-4YUQLDIS.js";
4
- import "../chunk-FSFVH3VP.js";
3
+ } from "../chunk-3E57V3U3.js";
4
+ import "../chunk-76RGT53V.js";
5
5
  export {
6
6
  raiseEvent
7
7
  };
@@ -111,7 +111,7 @@ var import_axios = __toESM(require("axios"), 1);
111
111
  var import_os = __toESM(require("os"), 1);
112
112
 
113
113
  // package.json
114
- var version = "3.26.13";
114
+ var version = "3.26.15";
115
115
 
116
116
  // src/constants.ts
117
117
  var VERSION = version;
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  log_build_default
3
- } from "../chunk-HIOIWNBV.js";
4
- import "../chunk-4YUQLDIS.js";
3
+ } from "../chunk-BBW2CP5O.js";
4
+ import "../chunk-3E57V3U3.js";
5
5
  import "../chunk-4UVFXLPI.js";
6
- import "../chunk-FSFVH3VP.js";
6
+ import "../chunk-76RGT53V.js";
7
7
  import "../chunk-5T63CXKU.js";
8
8
  export {
9
9
  log_build_default as default
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  VERSION
3
- } from "./chunk-FSFVH3VP.js";
3
+ } from "./chunk-76RGT53V.js";
4
4
 
5
5
  // src/analytics/analytics.js
6
6
  import axios from "axios";
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "3.26.13";
2
+ var version = "3.26.15";
3
3
 
4
4
  // src/constants.ts
5
5
  var VERSION = version;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  raiseEvent
3
- } from "./chunk-4YUQLDIS.js";
3
+ } from "./chunk-3E57V3U3.js";
4
4
  import {
5
5
  countResources,
6
6
  serializeCounts
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  logger
3
- } from "./chunk-NN5GG4GM.js";
3
+ } from "./chunk-JIVNOOE7.js";
4
4
  import {
5
5
  cleanup,
6
6
  getEventCatalogConfigFile
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  VERSION
3
- } from "./chunk-FSFVH3VP.js";
3
+ } from "./chunk-76RGT53V.js";
4
4
 
5
5
  // src/utils/cli-logger.ts
6
6
  import pc from "picocolors";
@@ -25,7 +25,7 @@ __export(constants_exports, {
25
25
  module.exports = __toCommonJS(constants_exports);
26
26
 
27
27
  // package.json
28
- var version = "3.26.13";
28
+ var version = "3.26.15";
29
29
 
30
30
  // src/constants.ts
31
31
  var VERSION = version;
package/dist/constants.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  VERSION
3
- } from "./chunk-FSFVH3VP.js";
3
+ } from "./chunk-76RGT53V.js";
4
4
  export {
5
5
  VERSION
6
6
  };
@@ -114,7 +114,7 @@ var verifyRequiredFieldsAreInCatalogConfigFile = async (projectDirectory) => {
114
114
  var import_picocolors = __toESM(require("picocolors"), 1);
115
115
 
116
116
  // package.json
117
- var version = "3.26.13";
117
+ var version = "3.26.15";
118
118
 
119
119
  // src/constants.ts
120
120
  var VERSION = version;
@@ -1655,6 +1655,22 @@ program.command("start").description("Serves the contents of your eventcatalog b
1655
1655
  });
1656
1656
  }
1657
1657
  });
1658
+ program.command("export").description("Export your EventCatalog using the SDK dumpCatalog function").option("--include-markdown", "Include markdown content in the export", false).action(async (options) => {
1659
+ logger.welcome();
1660
+ logger.info("Exporting EventCatalog...", "export");
1661
+ if (import_fs2.default.existsSync(import_node_path9.default.join(dir, ".env"))) {
1662
+ import_dotenv.default.config({ path: import_node_path9.default.join(dir, ".env") });
1663
+ }
1664
+ const { default: initSDK } = await import("@eventcatalog/sdk");
1665
+ const sdk = initSDK(dir);
1666
+ const catalog = await sdk.dumpCatalog({ includeMarkdown: options.includeMarkdown });
1667
+ const exportsDir = import_node_path9.default.join(dir, "exports");
1668
+ ensureDir(exportsDir);
1669
+ const date = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
1670
+ const exportFile = import_node_path9.default.join(exportsDir, `catalog-${date}.json`);
1671
+ import_fs2.default.writeFileSync(exportFile, JSON.stringify(catalog, null, 2), "utf-8");
1672
+ logger.info(`Catalog exported to ${exportFile}`, "export");
1673
+ });
1658
1674
  program.command("generate [siteDir]").description("Start the generator scripts.").action(async () => {
1659
1675
  if (import_fs2.default.existsSync(import_node_path9.default.join(dir, ".env"))) {
1660
1676
  import_dotenv.default.config({ path: import_node_path9.default.join(dir, ".env") });
@@ -6,8 +6,8 @@ import {
6
6
  } from "./chunk-PLNJC7NZ.js";
7
7
  import {
8
8
  log_build_default
9
- } from "./chunk-HIOIWNBV.js";
10
- import "./chunk-4YUQLDIS.js";
9
+ } from "./chunk-BBW2CP5O.js";
10
+ import "./chunk-3E57V3U3.js";
11
11
  import "./chunk-4UVFXLPI.js";
12
12
  import {
13
13
  runMigrations
@@ -22,13 +22,13 @@ import {
22
22
  } from "./chunk-3KXCGYET.js";
23
23
  import {
24
24
  generate
25
- } from "./chunk-2IPEX677.js";
25
+ } from "./chunk-GWXHXBAD.js";
26
26
  import {
27
27
  logger
28
- } from "./chunk-NN5GG4GM.js";
28
+ } from "./chunk-JIVNOOE7.js";
29
29
  import {
30
30
  VERSION
31
- } from "./chunk-FSFVH3VP.js";
31
+ } from "./chunk-76RGT53V.js";
32
32
  import {
33
33
  getEventCatalogConfigFile,
34
34
  verifyRequiredFieldsAreInCatalogConfigFile
@@ -1002,6 +1002,22 @@ program.command("start").description("Serves the contents of your eventcatalog b
1002
1002
  });
1003
1003
  }
1004
1004
  });
1005
+ program.command("export").description("Export your EventCatalog using the SDK dumpCatalog function").option("--include-markdown", "Include markdown content in the export", false).action(async (options) => {
1006
+ logger.welcome();
1007
+ logger.info("Exporting EventCatalog...", "export");
1008
+ if (fs3.existsSync(path2.join(dir, ".env"))) {
1009
+ dotenv.config({ path: path2.join(dir, ".env") });
1010
+ }
1011
+ const { default: initSDK } = await import("@eventcatalog/sdk");
1012
+ const sdk = initSDK(dir);
1013
+ const catalog = await sdk.dumpCatalog({ includeMarkdown: options.includeMarkdown });
1014
+ const exportsDir = path2.join(dir, "exports");
1015
+ ensureDir(exportsDir);
1016
+ const date = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
1017
+ const exportFile = path2.join(exportsDir, `catalog-${date}.json`);
1018
+ fs3.writeFileSync(exportFile, JSON.stringify(catalog, null, 2), "utf-8");
1019
+ logger.info(`Catalog exported to ${exportFile}`, "export");
1020
+ });
1005
1021
  program.command("generate [siteDir]").description("Start the generator scripts.").action(async () => {
1006
1022
  if (fs3.existsSync(path2.join(dir, ".env"))) {
1007
1023
  dotenv.config({ path: path2.join(dir, ".env") });
package/dist/generate.cjs CHANGED
@@ -78,7 +78,7 @@ var getEventCatalogConfigFile = async (projectDirectory) => {
78
78
  var import_picocolors = __toESM(require("picocolors"), 1);
79
79
 
80
80
  // package.json
81
- var version = "3.26.13";
81
+ var version = "3.26.15";
82
82
 
83
83
  // src/constants.ts
84
84
  var VERSION = version;
package/dist/generate.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  generate
3
- } from "./chunk-2IPEX677.js";
4
- import "./chunk-NN5GG4GM.js";
5
- import "./chunk-FSFVH3VP.js";
3
+ } from "./chunk-GWXHXBAD.js";
4
+ import "./chunk-JIVNOOE7.js";
5
+ import "./chunk-76RGT53V.js";
6
6
  import "./chunk-5T63CXKU.js";
7
7
  export {
8
8
  generate
@@ -36,7 +36,7 @@ module.exports = __toCommonJS(cli_logger_exports);
36
36
  var import_picocolors = __toESM(require("picocolors"), 1);
37
37
 
38
38
  // package.json
39
- var version = "3.26.13";
39
+ var version = "3.26.15";
40
40
 
41
41
  // src/constants.ts
42
42
  var VERSION = version;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  logger
3
- } from "../chunk-NN5GG4GM.js";
4
- import "../chunk-FSFVH3VP.js";
3
+ } from "../chunk-JIVNOOE7.js";
4
+ import "../chunk-76RGT53V.js";
5
5
  export {
6
6
  logger
7
7
  };
@@ -85,7 +85,47 @@ if (isRemote && Object.keys(resolvedHeaders).length > 0) {
85
85
  }
86
86
 
87
87
  const parsed = await new Parser({ schemaParsers: [AvroSchemaParser()] }).parse(content, parserOptions);
88
- const stringified = parsed.document?.json();
88
+
89
+ /**
90
+ * The AsyncAPI parser resolves all $ref pointers, which can create circular
91
+ * object references (e.g. oneOf/allOf discriminator patterns where child schemas
92
+ * reference the parent). We need to break true cycles before Astro's
93
+ * `define:vars` calls JSON.stringify internally.
94
+ *
95
+ * We track ancestors (not all-ever-seen objects) so that shared but
96
+ * non-circular references are preserved intact.
97
+ * See: https://github.com/event-catalog/generators/issues/364
98
+ */
99
+ const deepCopyBreakingCycles = (value: unknown, ancestors = new WeakSet()): unknown => {
100
+ if (typeof value !== 'object' || value === null) return value;
101
+
102
+ if (ancestors.has(value)) {
103
+ const schemaId = (value as Record<string, unknown>)['x-parser-schema-id'];
104
+ if (schemaId && typeof schemaId === 'string') {
105
+ return { $ref: `#/components/schemas/${schemaId}` };
106
+ }
107
+ return { $ref: '#' };
108
+ }
109
+
110
+ ancestors.add(value);
111
+
112
+ let result: unknown;
113
+ if (Array.isArray(value)) {
114
+ result = value.map((item) => deepCopyBreakingCycles(item, ancestors));
115
+ } else {
116
+ const obj: Record<string, unknown> = {};
117
+ for (const [k, v] of Object.entries(value as Record<string, unknown>)) {
118
+ obj[k] = deepCopyBreakingCycles(v, ancestors);
119
+ }
120
+ result = obj;
121
+ }
122
+
123
+ ancestors.delete(value);
124
+ return result;
125
+ };
126
+
127
+ const rawJson = parsed.document?.json();
128
+ const stringified = rawJson ? deepCopyBreakingCycles(rawJson) : undefined;
89
129
  const config: ConfigInterface = { show: { sidebar: true, errors: true } };
90
130
 
91
131
  const component = createElement(AsyncApiComponentWP, { schema: { stringified }, config });
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  },
8
8
  "license": "SEE LICENSE IN LICENSE",
9
9
  "type": "module",
10
- "version": "3.26.13",
10
+ "version": "3.26.15",
11
11
  "publishConfig": {
12
12
  "access": "public"
13
13
  },
@@ -143,6 +143,7 @@
143
143
  "preview": "astro preview",
144
144
  "astro": "astro",
145
145
  "start:catalog": "node scripts/start-catalog-locally.js",
146
+ "export:catalog": "node scripts/export-catalog-locally.js",
146
147
  "start:catalog:server": "node scripts/start-server-locally.js",
147
148
  "preview:catalog": "node scripts/preview-catalog-locally.js",
148
149
  "generate:catalog": "node scripts/generate-catalog-locally.js",