@eventcatalog/core 2.22.0 → 2.23.1

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 = "2.22.0";
40
+ var version = "2.23.1";
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-6HZQETSS.js";
4
- import "../chunk-NQSIMY3C.js";
3
+ } from "../chunk-GGTLXJHB.js";
4
+ import "../chunk-MUBFMCSR.js";
5
5
  export {
6
6
  raiseEvent
7
7
  };
@@ -106,7 +106,7 @@ var import_axios = __toESM(require("axios"), 1);
106
106
  var import_os = __toESM(require("os"), 1);
107
107
 
108
108
  // package.json
109
- var version = "2.22.0";
109
+ var version = "2.23.1";
110
110
 
111
111
  // src/constants.ts
112
112
  var VERSION = version;
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  log_build_default
3
- } from "../chunk-O3MRQUYC.js";
4
- import "../chunk-6HZQETSS.js";
5
- import "../chunk-NQSIMY3C.js";
3
+ } from "../chunk-I76AB6JV.js";
4
+ import "../chunk-GGTLXJHB.js";
5
+ import "../chunk-MUBFMCSR.js";
6
6
  import "../chunk-E7TXTI7G.js";
7
7
  export {
8
8
  log_build_default as default
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  VERSION
3
- } from "./chunk-NQSIMY3C.js";
3
+ } from "./chunk-MUBFMCSR.js";
4
4
 
5
5
  // src/analytics/analytics.js
6
6
  import axios from "axios";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  raiseEvent
3
- } from "./chunk-6HZQETSS.js";
3
+ } from "./chunk-GGTLXJHB.js";
4
4
  import {
5
5
  getEventCatalogConfigFile,
6
6
  verifyRequiredFieldsAreInCatalogConfigFile
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "2.22.0";
2
+ var version = "2.23.1";
3
3
 
4
4
  // src/constants.ts
5
5
  var VERSION = version;
@@ -25,7 +25,7 @@ __export(constants_exports, {
25
25
  module.exports = __toCommonJS(constants_exports);
26
26
 
27
27
  // package.json
28
- var version = "2.22.0";
28
+ var version = "2.23.1";
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-NQSIMY3C.js";
3
+ } from "./chunk-MUBFMCSR.js";
4
4
  export {
5
5
  VERSION
6
6
  };
@@ -161,7 +161,7 @@ var import_axios = __toESM(require("axios"), 1);
161
161
  var import_os = __toESM(require("os"), 1);
162
162
 
163
163
  // package.json
164
- var version = "2.22.0";
164
+ var version = "2.23.1";
165
165
 
166
166
  // src/constants.ts
167
167
  var VERSION = version;
@@ -513,7 +513,6 @@ var resolve_catalog_dependencies_default = async (catalogDir, core2) => {
513
513
  };
514
514
 
515
515
  // src/eventcatalog.ts
516
- var import_semver = __toESM(require("semver"), 1);
517
516
  var import_boxen2 = __toESM(require("boxen"), 1);
518
517
 
519
518
  // src/features.ts
@@ -562,27 +561,21 @@ var isBackstagePluginEnabled = async (licenseKey) => {
562
561
  };
563
562
 
564
563
  // src/eventcatalog.ts
565
- var boxenOptions = {
566
- padding: 1,
567
- margin: 1,
568
- align: "center",
569
- borderColor: "yellow",
570
- borderStyle: {
571
- topLeft: " ",
572
- topRight: " ",
573
- bottomLeft: " ",
574
- bottomRight: " ",
575
- right: " ",
576
- top: "-",
577
- bottom: "-",
578
- left: " "
579
- }
580
- };
564
+ var import_update_notifier = __toESM(require("update-notifier"), 1);
581
565
  var currentDir = import_node_path7.default.dirname((0, import_node_url.fileURLToPath)(importMetaUrl));
582
566
  var program = new import_commander.Command().version(VERSION);
583
567
  var dir = import_node_path7.default.resolve(process.env.PROJECT_DIR || process.cwd());
584
568
  var core = import_node_path7.default.resolve(process.env.CATALOG_DIR || (0, import_node_path6.join)(dir, ".eventcatalog-core"));
585
569
  var eventCatalogDir = import_node_path7.default.resolve((0, import_node_path6.join)(currentDir, "../eventcatalog/"));
570
+ var getInstalledEventCatalogVersion = () => {
571
+ try {
572
+ const pkg = import_fs2.default.readFileSync((0, import_node_path6.join)(dir, "package.json"), "utf8");
573
+ const json = JSON.parse(pkg);
574
+ return json.dependencies["@eventcatalog/core"];
575
+ } catch (error) {
576
+ return null;
577
+ }
578
+ };
586
579
  program.name("eventcatalog").description("Documentation tool for event-driven architectures");
587
580
  var ensureDir = (dir2) => {
588
581
  if (!import_fs2.default.existsSync(dir2)) {
@@ -605,29 +598,35 @@ var clearCore = () => {
605
598
  if (import_fs2.default.existsSync(core)) import_fs2.default.rmSync(core, { recursive: true });
606
599
  };
607
600
  var checkForUpdate = () => {
608
- try {
609
- const packageJson = JSON.parse(import_fs2.default.readFileSync(import_node_path7.default.join(dir, "package.json"), "utf-8"));
610
- const userEventCatalogVersion = packageJson.dependencies["@eventcatalog/core"];
611
- const corePackageJson = JSON.parse(import_fs2.default.readFileSync(import_node_path7.default.join(core, "package.json"), "utf-8"));
612
- const coreVersion = corePackageJson.version;
613
- const userVersion = userEventCatalogVersion.replace(/[\^~]/, "");
614
- if (import_semver.default.lt(userVersion, coreVersion)) {
615
- const docusaurusUpdateMessage = (0, import_boxen2.default)(
616
- `Update available for EventCatalog
617
- @eventcatalog/core ${userVersion} \u2192 ${coreVersion}
618
-
619
- Run \`npm i @eventcatalog/core@${coreVersion}\` to update your EventCatalog
620
- `,
621
- boxenOptions
622
- );
623
- console.log(docusaurusUpdateMessage);
624
- }
625
- } catch (error) {
601
+ const installedVersion = getInstalledEventCatalogVersion();
602
+ if (!installedVersion) return;
603
+ const pkg = { name: "@eventcatalog/core", version: installedVersion };
604
+ const notifier = (0, import_update_notifier.default)({ pkg, updateCheckInterval: 0 });
605
+ if (notifier.update) {
606
+ const message = `EventCatalog update available ${notifier.update.current} \u2192 ${notifier.update.latest}
607
+ Run npm i @eventcatalog/core to update`;
608
+ console.log(
609
+ (0, import_boxen2.default)(message, {
610
+ padding: 1,
611
+ margin: 1,
612
+ align: "center",
613
+ borderColor: "yellow",
614
+ borderStyle: {
615
+ topLeft: " ",
616
+ topRight: " ",
617
+ bottomLeft: " ",
618
+ bottomRight: " ",
619
+ right: " ",
620
+ top: "-",
621
+ bottom: "-",
622
+ left: " "
623
+ }
624
+ })
625
+ );
626
626
  }
627
627
  };
628
628
  program.command("dev").description("Run development server of EventCatalog").option("-d, --debug", "Output EventCatalog application information into your terminal").option("--force-recreate", "Recreate the eventcatalog-core directory", false).action(async (options, command) => {
629
629
  console.log("Setting up EventCatalog....");
630
- checkForUpdate();
631
630
  if (options.debug) {
632
631
  console.log("Debug mode enabled");
633
632
  console.log("PROJECT_DIR", dir);
@@ -635,10 +634,10 @@ program.command("dev").description("Run development server of EventCatalog").opt
635
634
  }
636
635
  if (options.forceRecreate) clearCore();
637
636
  copyCore();
638
- console.log("EventCatalog is starting at http://localhost:3000/docs");
639
637
  await resolve_catalog_dependencies_default(dir, core);
640
638
  await catalogToAstro(dir, core);
641
639
  const canEmbedPages = await isBackstagePluginEnabled();
640
+ checkForUpdate();
642
641
  let watchUnsub;
643
642
  try {
644
643
  watchUnsub = await watch(dir, core);
@@ -663,12 +662,12 @@ program.command("dev").description("Run development server of EventCatalog").opt
663
662
  });
664
663
  program.command("build").description("Run build of EventCatalog").action(async (options, command) => {
665
664
  console.log("Building EventCatalog...");
666
- checkForUpdate();
667
665
  copyCore();
668
666
  await log_build_default(dir);
669
667
  await resolve_catalog_dependencies_default(dir, core);
670
668
  await catalogToAstro(dir, core);
671
669
  const canEmbedPages = await isBackstagePluginEnabled();
670
+ checkForUpdate();
672
671
  (0, import_node_child_process.execSync)(
673
672
  `cross-env PROJECT_DIR='${dir}' CATALOG_DIR='${core}' ENABLE_EMBED=${canEmbedPages} npx astro build ${command.args.join(" ").trim()}`,
674
673
  {
@@ -33,6 +33,10 @@ interface Config {
33
33
  mdxOptimize?: boolean;
34
34
  docs: {
35
35
  sidebar: {
36
+ /**
37
+ * @default 'FLAT_VIEW'
38
+ */
39
+ type?: 'FLAT_VIEW' | 'TREE_VIEW';
36
40
  showPageHeadings: true;
37
41
  services?: SideBarConfig;
38
42
  messages?: SideBarConfig;
@@ -33,6 +33,10 @@ interface Config {
33
33
  mdxOptimize?: boolean;
34
34
  docs: {
35
35
  sidebar: {
36
+ /**
37
+ * @default 'FLAT_VIEW'
38
+ */
39
+ type?: 'FLAT_VIEW' | 'TREE_VIEW';
36
40
  showPageHeadings: true;
37
41
  services?: SideBarConfig;
38
42
  messages?: SideBarConfig;
@@ -6,14 +6,14 @@ import {
6
6
  } from "./chunk-OW2FQPYP.js";
7
7
  import {
8
8
  log_build_default
9
- } from "./chunk-O3MRQUYC.js";
10
- import "./chunk-6HZQETSS.js";
9
+ } from "./chunk-I76AB6JV.js";
10
+ import "./chunk-GGTLXJHB.js";
11
11
  import {
12
12
  catalogToAstro
13
13
  } from "./chunk-CXKIF3EI.js";
14
14
  import {
15
15
  VERSION
16
- } from "./chunk-NQSIMY3C.js";
16
+ } from "./chunk-MUBFMCSR.js";
17
17
  import {
18
18
  isBackstagePluginEnabled
19
19
  } from "./chunk-XMDPVKIJ.js";
@@ -31,29 +31,22 @@ import fs from "fs";
31
31
  import path from "node:path";
32
32
  import { fileURLToPath } from "node:url";
33
33
  import concurrently from "concurrently";
34
- import semver from "semver";
35
34
  import boxen from "boxen";
36
- var boxenOptions = {
37
- padding: 1,
38
- margin: 1,
39
- align: "center",
40
- borderColor: "yellow",
41
- borderStyle: {
42
- topLeft: " ",
43
- topRight: " ",
44
- bottomLeft: " ",
45
- bottomRight: " ",
46
- right: " ",
47
- top: "-",
48
- bottom: "-",
49
- left: " "
50
- }
51
- };
35
+ import updateNotifier from "update-notifier";
52
36
  var currentDir = path.dirname(fileURLToPath(import.meta.url));
53
37
  var program = new Command().version(VERSION);
54
38
  var dir = path.resolve(process.env.PROJECT_DIR || process.cwd());
55
39
  var core = path.resolve(process.env.CATALOG_DIR || join(dir, ".eventcatalog-core"));
56
40
  var eventCatalogDir = path.resolve(join(currentDir, "../eventcatalog/"));
41
+ var getInstalledEventCatalogVersion = () => {
42
+ try {
43
+ const pkg = fs.readFileSync(join(dir, "package.json"), "utf8");
44
+ const json = JSON.parse(pkg);
45
+ return json.dependencies["@eventcatalog/core"];
46
+ } catch (error) {
47
+ return null;
48
+ }
49
+ };
57
50
  program.name("eventcatalog").description("Documentation tool for event-driven architectures");
58
51
  var ensureDir = (dir2) => {
59
52
  if (!fs.existsSync(dir2)) {
@@ -76,29 +69,35 @@ var clearCore = () => {
76
69
  if (fs.existsSync(core)) fs.rmSync(core, { recursive: true });
77
70
  };
78
71
  var checkForUpdate = () => {
79
- try {
80
- const packageJson = JSON.parse(fs.readFileSync(path.join(dir, "package.json"), "utf-8"));
81
- const userEventCatalogVersion = packageJson.dependencies["@eventcatalog/core"];
82
- const corePackageJson = JSON.parse(fs.readFileSync(path.join(core, "package.json"), "utf-8"));
83
- const coreVersion = corePackageJson.version;
84
- const userVersion = userEventCatalogVersion.replace(/[\^~]/, "");
85
- if (semver.lt(userVersion, coreVersion)) {
86
- const docusaurusUpdateMessage = boxen(
87
- `Update available for EventCatalog
88
- @eventcatalog/core ${userVersion} \u2192 ${coreVersion}
89
-
90
- Run \`npm i @eventcatalog/core@${coreVersion}\` to update your EventCatalog
91
- `,
92
- boxenOptions
93
- );
94
- console.log(docusaurusUpdateMessage);
95
- }
96
- } catch (error) {
72
+ const installedVersion = getInstalledEventCatalogVersion();
73
+ if (!installedVersion) return;
74
+ const pkg = { name: "@eventcatalog/core", version: installedVersion };
75
+ const notifier = updateNotifier({ pkg, updateCheckInterval: 0 });
76
+ if (notifier.update) {
77
+ const message = `EventCatalog update available ${notifier.update.current} \u2192 ${notifier.update.latest}
78
+ Run npm i @eventcatalog/core to update`;
79
+ console.log(
80
+ boxen(message, {
81
+ padding: 1,
82
+ margin: 1,
83
+ align: "center",
84
+ borderColor: "yellow",
85
+ borderStyle: {
86
+ topLeft: " ",
87
+ topRight: " ",
88
+ bottomLeft: " ",
89
+ bottomRight: " ",
90
+ right: " ",
91
+ top: "-",
92
+ bottom: "-",
93
+ left: " "
94
+ }
95
+ })
96
+ );
97
97
  }
98
98
  };
99
99
  program.command("dev").description("Run development server of EventCatalog").option("-d, --debug", "Output EventCatalog application information into your terminal").option("--force-recreate", "Recreate the eventcatalog-core directory", false).action(async (options, command) => {
100
100
  console.log("Setting up EventCatalog....");
101
- checkForUpdate();
102
101
  if (options.debug) {
103
102
  console.log("Debug mode enabled");
104
103
  console.log("PROJECT_DIR", dir);
@@ -106,10 +105,10 @@ program.command("dev").description("Run development server of EventCatalog").opt
106
105
  }
107
106
  if (options.forceRecreate) clearCore();
108
107
  copyCore();
109
- console.log("EventCatalog is starting at http://localhost:3000/docs");
110
108
  await resolve_catalog_dependencies_default(dir, core);
111
109
  await catalogToAstro(dir, core);
112
110
  const canEmbedPages = await isBackstagePluginEnabled();
111
+ checkForUpdate();
113
112
  let watchUnsub;
114
113
  try {
115
114
  watchUnsub = await watch(dir, core);
@@ -134,12 +133,12 @@ program.command("dev").description("Run development server of EventCatalog").opt
134
133
  });
135
134
  program.command("build").description("Run build of EventCatalog").action(async (options, command) => {
136
135
  console.log("Building EventCatalog...");
137
- checkForUpdate();
138
136
  copyCore();
139
137
  await log_build_default(dir);
140
138
  await resolve_catalog_dependencies_default(dir, core);
141
139
  await catalogToAstro(dir, core);
142
140
  const canEmbedPages = await isBackstagePluginEnabled();
141
+ checkForUpdate();
143
142
  execSync(
144
143
  `cross-env PROJECT_DIR='${dir}' CATALOG_DIR='${core}' ENABLE_EMBED=${canEmbedPages} npx astro build ${command.args.join(" ").trim()}`,
145
144
  {
@@ -0,0 +1,65 @@
1
+ import { isCollectionVisibleInCatalog } from '@eventcatalog';
2
+ import { buildUrl } from '@utils/url-builder';
3
+ import { getChannels } from '@utils/channels';
4
+ import { getDomains } from '@utils/collections/domains';
5
+ import { getFlows } from '@utils/collections/flows';
6
+ import { getServices } from '@utils/collections/services';
7
+ import { getCommands } from '@utils/commands';
8
+ import { getEvents } from '@utils/events';
9
+ import { getQueries } from '@utils/queries';
10
+ import { getTeams } from '@utils/teams';
11
+ import { getUsers } from '@utils/users';
12
+
13
+ export async function getCatalogResources({ currentPath }: { currentPath: string }) {
14
+ const events = await getEvents({ getAllVersions: false });
15
+ const commands = await getCommands({ getAllVersions: false });
16
+ const queries = await getQueries({ getAllVersions: false });
17
+ const services = await getServices({ getAllVersions: false });
18
+ const domains = await getDomains({ getAllVersions: false });
19
+ const channels = await getChannels({ getAllVersions: false });
20
+ const flows = await getFlows({ getAllVersions: false });
21
+
22
+ const messages = [...events, ...commands, ...queries];
23
+
24
+ // @ts-ignore for large catalogs https://github.com/event-catalog/eventcatalog/issues/552
25
+ const allData = [...domains, ...services, ...messages, ...channels, ...flows];
26
+
27
+ const allDataAsSideNav = allData.reduce((acc, item) => {
28
+ const title = item.collection;
29
+ const group = acc[title] || [];
30
+ const route = currentPath.includes('visualiser') ? 'visualiser' : 'docs';
31
+
32
+ const navigationItem = {
33
+ label: item.data.name,
34
+ version: item.data.version,
35
+ // items: item.collection === 'users' ? [] : item.headings,
36
+ visible: isCollectionVisibleInCatalog(item.collection),
37
+ // @ts-ignore
38
+ href: item.data.version
39
+ ? // @ts-ignore
40
+ buildUrl(`/${route}/${item.collection}/${item.data.id}/${item.data.version}`)
41
+ : buildUrl(`/${route}/${item.collection}/${item.data.id}`),
42
+ collection: item.collection,
43
+ };
44
+
45
+ group.push(navigationItem);
46
+
47
+ return {
48
+ ...acc,
49
+ [title]: group,
50
+ };
51
+ }, {} as any);
52
+
53
+ const sideNav = {
54
+ ...(currentPath.includes('visualiser')
55
+ ? {
56
+ 'bounded context map': [
57
+ { label: 'Domain map', href: buildUrl('/visualiser/context-map'), collection: 'bounded-context-map' },
58
+ ],
59
+ }
60
+ : {}),
61
+ ...allDataAsSideNav,
62
+ };
63
+
64
+ return sideNav;
65
+ }
@@ -75,7 +75,7 @@ const CatalogResourcesSideBar: React.FC<CatalogResourcesSideBarProps> = ({ resou
75
75
  if (!isInitialized) return null;
76
76
 
77
77
  return (
78
- <nav className="space-y-6 text-black ">
78
+ <nav className="space-y-6 text-black px-5 py-4 ">
79
79
  <div className="space-y-2">
80
80
  <div className="mb-4 px-1">
81
81
  <input
@@ -0,0 +1,31 @@
1
+ ---
2
+ import type { HTMLAttributes } from 'astro/types';
3
+ import config from '@config';
4
+
5
+ // FlatView
6
+ import CatalogResourcesSideBar from './CatalogResourcesSideBar';
7
+ import { getCatalogResources } from './CatalogResourcesSideBar/getCatalogResources';
8
+
9
+ // TreeView
10
+ import { SideNavTreeView } from './TreeView';
11
+ import { getTreeView } from './TreeView/getTreeView';
12
+
13
+ interface Props extends Omit<HTMLAttributes<'div'>, 'children'> {}
14
+
15
+ const currentPath = Astro.url.pathname;
16
+
17
+ let props;
18
+
19
+ const SIDENAV_TYPE = config?.docs?.sidebar?.type ?? 'FLAT_VIEW';
20
+
21
+ if (SIDENAV_TYPE === 'FLAT_VIEW') {
22
+ props = await getCatalogResources({ currentPath });
23
+ } else if (SIDENAV_TYPE === 'TREE_VIEW') {
24
+ props = getTreeView({ projectDir: process.env.PROJECT_DIR!, currentPath });
25
+ }
26
+ ---
27
+
28
+ <div {...Astro.props}>
29
+ {SIDENAV_TYPE === 'FLAT_VIEW' && <CatalogResourcesSideBar resources={props} currentPath={currentPath} client:load />}
30
+ {SIDENAV_TYPE === 'TREE_VIEW' && <SideNavTreeView client:only transition:persist tree={props} />}
31
+ </div>