@eventcatalog/core 2.49.4 → 2.50.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.
@@ -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.49.4";
40
+ var version = "2.50.0";
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-6H5JZTNU.js";
4
- import "../chunk-ZIKL7B6R.js";
3
+ } from "../chunk-O4GURJKI.js";
4
+ import "../chunk-URM4QMOV.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.49.4";
109
+ var version = "2.50.0";
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-POF6LP6N.js";
4
- import "../chunk-6H5JZTNU.js";
5
- import "../chunk-ZIKL7B6R.js";
3
+ } from "../chunk-5VLU23SZ.js";
4
+ import "../chunk-O4GURJKI.js";
5
+ import "../chunk-URM4QMOV.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
  raiseEvent
3
- } from "./chunk-6H5JZTNU.js";
3
+ } from "./chunk-O4GURJKI.js";
4
4
  import {
5
5
  getEventCatalogConfigFile,
6
6
  verifyRequiredFieldsAreInCatalogConfigFile
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  VERSION
3
- } from "./chunk-ZIKL7B6R.js";
3
+ } from "./chunk-URM4QMOV.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 = "2.49.4";
2
+ var version = "2.50.0";
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.49.4";
28
+ var version = "2.50.0";
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-ZIKL7B6R.js";
3
+ } from "./chunk-URM4QMOV.js";
4
4
  export {
5
5
  VERSION
6
6
  };
@@ -157,7 +157,7 @@ var import_axios = __toESM(require("axios"), 1);
157
157
  var import_os = __toESM(require("os"), 1);
158
158
 
159
159
  // package.json
160
- var version = "2.49.4";
160
+ var version = "2.50.0";
161
161
 
162
162
  // src/constants.ts
163
163
  var VERSION = version;
@@ -6,8 +6,8 @@ import {
6
6
  } from "./chunk-XE6PFSH5.js";
7
7
  import {
8
8
  log_build_default
9
- } from "./chunk-POF6LP6N.js";
10
- import "./chunk-6H5JZTNU.js";
9
+ } from "./chunk-5VLU23SZ.js";
10
+ import "./chunk-O4GURJKI.js";
11
11
  import {
12
12
  catalogToAstro,
13
13
  checkAndConvertMdToMdx
@@ -15,7 +15,7 @@ import {
15
15
  import "./chunk-LDBRNJIL.js";
16
16
  import {
17
17
  VERSION
18
- } from "./chunk-ZIKL7B6R.js";
18
+ } from "./chunk-URM4QMOV.js";
19
19
  import {
20
20
  isAuthEnabled,
21
21
  isBackstagePluginEnabled,
@@ -2,6 +2,7 @@
2
2
  import fs from 'fs';
3
3
  import path from 'path';
4
4
  import { Code } from 'astro-expressive-code/components';
5
+ import { getAbsoluteFilePathForAstroFile } from '@utils/files';
5
6
 
6
7
  interface Props {
7
8
  file?: string;
@@ -17,9 +18,11 @@ const { file = 'schema.json', catalog, title, filePath, lang = 'json' } = Astro.
17
18
 
18
19
  let code: string | null = null;
19
20
 
20
- const exists = fs.existsSync(path.join(path.dirname(filePath), file));
21
+ const absoluteFilePath = getAbsoluteFilePathForAstroFile(filePath, file);
22
+
23
+ const exists = fs.existsSync(absoluteFilePath);
21
24
  if (exists) {
22
- code = fs.readFileSync(path.join(path.dirname(filePath), file), 'utf-8');
25
+ code = fs.readFileSync(absoluteFilePath, 'utf-8');
23
26
  }
24
27
  ---
25
28
 
@@ -7,16 +7,18 @@ import path from 'path';
7
7
  import SchemaViewerClient from './SchemaViewer.astro';
8
8
  import Admonition from '../Admonition';
9
9
  import { getMDXComponentsByName } from '@utils/markdown';
10
+ import { getAbsoluteFilePathForAstroFile } from '@utils/files';
10
11
 
11
12
  let schemas = [];
12
13
 
13
14
  try {
14
- const file = await fs.readFile(filePath, 'utf-8');
15
+ const absoluteFilePath = getAbsoluteFilePathForAstroFile(filePath);
16
+ const file = await fs.readFile(absoluteFilePath, 'utf-8');
15
17
  const schemaViewers = getMDXComponentsByName(file, 'SchemaViewer');
16
18
 
17
19
  // Loop around all the possible SchemaViewers in the file.
18
20
  const getAllComponents = schemaViewers.map(async (schemaViewerProps: any, index: number) => {
19
- const schemaPath = path.join(path.dirname(filePath), schemaViewerProps.file);
21
+ const schemaPath = getAbsoluteFilePathForAstroFile(filePath, schemaViewerProps.file);
20
22
  const exists = existsSync(schemaPath);
21
23
  let schema;
22
24
  let render = true;
@@ -12,6 +12,7 @@ import { AsyncApiComponentWP, type ConfigInterface } from '@asyncapi/react-compo
12
12
  import VerticalSideBarLayout from '@layouts/VerticalSideBarLayout.astro';
13
13
  import Config from '@utils/eventcatalog-config/catalog';
14
14
  import { Page } from './_[filename].data';
15
+ import { getAbsoluteFilePathForAstroFile } from '@utils/files';
15
16
 
16
17
  export const prerender = Page.prerender;
17
18
  export const getStaticPaths = Page.getStaticPaths;
@@ -19,10 +20,8 @@ export const getStaticPaths = Page.getStaticPaths;
19
20
  // Get data
20
21
  const { collection, data, filePath, filename } = await Page.getData(Astro);
21
22
 
22
- // @ts-ignore
23
23
  const fileName = filename || 'asyncapi.yaml';
24
- const directory = path.dirname(filePath || '');
25
- const pathToSpec = path.join(directory, fileName);
24
+ const pathToSpec = getAbsoluteFilePathForAstroFile(filePath, fileName);
26
25
  const fileExists = fs.existsSync(pathToSpec);
27
26
  let content = '';
28
27
 
@@ -1,17 +1,12 @@
1
1
  ---
2
- import type { CollectionEntry } from 'astro:content';
3
- import * as path from 'path';
4
2
  import fs from 'node:fs';
5
3
  import OpenAPISpec from './_OpenAPI.tsx';
6
4
 
7
- import type { CollectionTypes, PageTypes } from '@types';
8
5
  import { DocumentMinusIcon } from '@heroicons/react/24/outline';
9
- import { buildUrl } from '@utils/url-builder';
10
- import { pageDataLoader } from '@utils/page-loaders/page-data-loader';
11
6
  import VerticalSideBarLayout from '@layouts/VerticalSideBarLayout.astro';
12
- import { getSpecificationsForService } from '@utils/collections/services';
13
7
  import './_styles.css';
14
8
  import { Page } from './_[filename].data.ts';
9
+ import { getAbsoluteFilePathForAstroFile } from '@utils/files';
15
10
 
16
11
  export const prerender = Page.prerender;
17
12
  export const getStaticPaths = Page.getStaticPaths;
@@ -23,8 +18,7 @@ const props = await Page.getData(Astro);
23
18
  const { collection, data, catalog, filePath, filename } = props;
24
19
  const fileName = filename || 'openapi.yml';
25
20
 
26
- const directory = path.dirname(filePath || '');
27
- const pathToSpec = path.join(directory, fileName);
21
+ const pathToSpec = getAbsoluteFilePathForAstroFile(filePath, fileName);
28
22
  const fileExists = fs.existsSync(pathToSpec);
29
23
 
30
24
  let content = '';
@@ -0,0 +1,83 @@
1
+ import { getUbiquitousLanguage } from '@utils/collections/domains';
2
+ import { getDomains } from '@utils/collections/domains';
3
+ import { isSSR } from '@utils/feature';
4
+ import { HybridPage } from '@utils/page-loaders/hybrid-page';
5
+
6
+ export class Page extends HybridPage {
7
+ static async getStaticPaths() {
8
+ if (isSSR()) {
9
+ return [];
10
+ }
11
+
12
+ const domains = await getDomains({ getAllVersions: false });
13
+
14
+ const pages = await domains.reduce<Promise<any[]>>(async (acc, domain) => {
15
+ const accumulator = await acc;
16
+ const ubiquitousLanguages = await getUbiquitousLanguage(domain);
17
+
18
+ if (ubiquitousLanguages.length === 0) {
19
+ return accumulator;
20
+ }
21
+
22
+ const dictionary = ubiquitousLanguages[0].data.dictionary;
23
+
24
+ if (!dictionary) {
25
+ return accumulator;
26
+ }
27
+
28
+ return [
29
+ ...accumulator,
30
+ ...dictionary.map((item) => ({
31
+ params: {
32
+ type: domain.collection,
33
+ id: domain.data.id,
34
+ dictionaryId: item.id,
35
+ },
36
+ props: {
37
+ type: domain.collection,
38
+ domainId: domain.data.id,
39
+ domain: domain.data,
40
+ ubiquitousLanguage: item,
41
+ ...item,
42
+ },
43
+ })),
44
+ ];
45
+ }, Promise.resolve([]));
46
+
47
+ return pages;
48
+ }
49
+
50
+ protected static async fetchData(params: any) {
51
+ const { getDomains } = await import('@utils/collections/domains');
52
+ const domains = await getDomains({ getAllVersions: false });
53
+
54
+ const domain = domains.find((d) => d.data.id === params.id && d.collection === params.type);
55
+ if (!domain) return null;
56
+
57
+ const ubiquitousLanguages = await getUbiquitousLanguage(domain);
58
+ if (ubiquitousLanguages.length === 0) return null;
59
+
60
+ // Find the ubiquitous language that contains our dictionary item
61
+ const ubiquitousLanguage = ubiquitousLanguages.find((l) => l.data.dictionary?.some((d) => d.id === params.dictionaryId));
62
+ if (!ubiquitousLanguage) return null;
63
+
64
+ // Find the specific dictionary item
65
+ const item = ubiquitousLanguage.data.dictionary?.find((d) => d.id === params.dictionaryId);
66
+ if (!item) return null;
67
+
68
+ return {
69
+ type: domain.collection,
70
+ domainId: domain.data.id,
71
+ domain: domain.data,
72
+ ubiquitousLanguage: item,
73
+ ...item,
74
+ };
75
+ }
76
+
77
+ protected static createNotFoundResponse(): Response {
78
+ return new Response(null, {
79
+ status: 404,
80
+ statusText: 'Domain not found',
81
+ });
82
+ }
83
+ }
@@ -2,51 +2,17 @@
2
2
  import RectangleGroupIcon from '@heroicons/react/24/outline/RectangleGroupIcon';
3
3
  import Footer from '@layouts/Footer.astro';
4
4
  import VerticalSideBarLayout from '@layouts/VerticalSideBarLayout.astro';
5
- import { getDomains, getUbiquitousLanguage } from '@utils/collections/domains';
6
5
  import { buildUrl } from '@utils/url-builder';
7
6
  import { ClientRouter } from 'astro:transitions';
8
7
  import { marked } from 'marked';
9
8
 
10
- export async function getStaticPaths() {
11
- const domains = await getDomains({ getAllVersions: false });
9
+ import { Page } from './_index.data';
12
10
 
13
- const pages = await domains.reduce<Promise<any[]>>(async (acc, domain) => {
14
- const accumulator = await acc;
15
- const ubiquitousLanguages = await getUbiquitousLanguage(domain);
11
+ export const prerender = Page.prerender;
12
+ export const getStaticPaths = Page.getStaticPaths;
16
13
 
17
- if (ubiquitousLanguages.length === 0) {
18
- return accumulator;
19
- }
20
-
21
- const dictionary = ubiquitousLanguages[0].data.dictionary;
22
-
23
- if (!dictionary) {
24
- return accumulator;
25
- }
14
+ const props = await Page.getData(Astro);
26
15
 
27
- return [
28
- ...accumulator,
29
- ...dictionary.map((item) => ({
30
- params: {
31
- type: domain.collection,
32
- id: domain.data.id,
33
- dictionaryId: item.id,
34
- },
35
- props: {
36
- type: domain.collection,
37
- domainId: domain.data.id,
38
- domain: domain.data,
39
- ubiquitousLanguage: item,
40
- ...item,
41
- },
42
- })),
43
- ];
44
- }, Promise.resolve([]));
45
-
46
- return pages;
47
- }
48
-
49
- const props = Astro.props;
50
16
  const { ubiquitousLanguage } = props;
51
17
  const pageTitle = `${props.type} | ${ubiquitousLanguage.name}`.replace(/^\w/, (c) => c.toUpperCase());
52
18
 
@@ -89,7 +55,7 @@ const badges = [
89
55
  >
90
56
  <path stroke-linecap="round" stroke-linejoin="round" d="M10.5 19.5L3 12m0 0l7.5-7.5M3 12h18"></path>
91
57
  </svg>
92
- Back to ubiquitous language List
58
+ Back to Ubiquitous Language List
93
59
  </a>
94
60
  </li>
95
61
  </ol>
@@ -0,0 +1,17 @@
1
+ import path from 'node:path';
2
+
3
+ /**
4
+ * Using the Astro filePath, this returns the absolute path to the file
5
+ * @param filePath
6
+ * @returns
7
+ */
8
+ export const getAbsoluteFilePathForAstroFile = (filePath: string, fileName?: string) => {
9
+ const PROJECT_DIR = process.env.PROJECT_DIR || process.cwd();
10
+
11
+ if (fileName) {
12
+ const directory = path.dirname(filePath || '');
13
+ return path.join(PROJECT_DIR, '../', directory, fileName);
14
+ }
15
+
16
+ return path.join(PROJECT_DIR, '../', filePath);
17
+ };
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "url": "https://github.com/event-catalog/eventcatalog.git"
7
7
  },
8
8
  "type": "module",
9
- "version": "2.49.4",
9
+ "version": "2.50.0",
10
10
  "publishConfig": {
11
11
  "access": "public"
12
12
  },
@@ -1,6 +0,0 @@
1
- export function exampleRemarkPlugin() {
2
- // All remark and rehype plugins return a separate function
3
- return function (tree, file) {
4
- file.data.astro.frontmatter.customProperty = 'Generated property';
5
- };
6
- }