@eventcatalog/core 2.49.5 → 2.50.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.
- package/dist/analytics/analytics.cjs +1 -1
- package/dist/analytics/analytics.js +2 -2
- package/dist/analytics/log-build.cjs +1 -1
- package/dist/analytics/log-build.js +3 -3
- package/dist/{chunk-SRWBNIXA.js → chunk-BTQCPTER.js} +1 -1
- package/dist/{chunk-XHCERMFT.js → chunk-SDBKZ3UM.js} +1 -1
- package/dist/{chunk-BUPT4PSW.js → chunk-UG5JRBOA.js} +1 -1
- package/dist/constants.cjs +1 -1
- package/dist/constants.js +1 -1
- package/dist/eventcatalog.cjs +1 -1
- package/dist/eventcatalog.js +3 -3
- package/eventcatalog/src/components/MDX/Schema.astro +5 -2
- package/eventcatalog/src/components/MDX/SchemaViewer/SchemaViewerRoot.astro +4 -2
- package/eventcatalog/src/pages/docs/[type]/[id]/[version]/asyncapi/[filename].astro +2 -3
- package/eventcatalog/src/pages/docs/[type]/[id]/[version]/spec/[filename].astro +2 -8
- package/eventcatalog/src/utils/files.ts +43 -0
- package/package.json +1 -1
- package/eventcatalog/src/utils/example-remark-plugin.mjs +0 -6
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
log_build_default
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-UG5JRBOA.js";
|
|
4
|
+
import "../chunk-BTQCPTER.js";
|
|
5
|
+
import "../chunk-SDBKZ3UM.js";
|
|
6
6
|
import "../chunk-E7TXTI7G.js";
|
|
7
7
|
export {
|
|
8
8
|
log_build_default as default
|
package/dist/constants.cjs
CHANGED
package/dist/constants.js
CHANGED
package/dist/eventcatalog.cjs
CHANGED
package/dist/eventcatalog.js
CHANGED
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
} from "./chunk-XE6PFSH5.js";
|
|
7
7
|
import {
|
|
8
8
|
log_build_default
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-UG5JRBOA.js";
|
|
10
|
+
import "./chunk-BTQCPTER.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-
|
|
18
|
+
} from "./chunk-SDBKZ3UM.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
|
|
21
|
+
const absoluteFilePath = getAbsoluteFilePathForAstroFile(filePath, file);
|
|
22
|
+
|
|
23
|
+
const exists = fs.existsSync(absoluteFilePath);
|
|
21
24
|
if (exists) {
|
|
22
|
-
code = fs.readFileSync(
|
|
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
|
|
15
|
+
const absoluteFilePath = getAbsoluteFilePathForAstroFile(filePath, filePath.split(path.sep).pop());
|
|
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 =
|
|
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
|
|
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
|
|
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,43 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Using the Astro filePath, this returns the absolute path to the file
|
|
5
|
+
*
|
|
6
|
+
* The astro file path does not return the absolute path to the file, it returns the relative path to the file.
|
|
7
|
+
*
|
|
8
|
+
* This function will return the absolute path to the file, and it will also remove any overlapping path segments, issues seen with local development and also docker
|
|
9
|
+
*
|
|
10
|
+
* @param filePath
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
export const getAbsoluteFilePathForAstroFile = (filePath: string, fileName?: string) => {
|
|
14
|
+
const PROJECT_DIR = process.env.PROJECT_DIR || process.cwd();
|
|
15
|
+
|
|
16
|
+
if (fileName) {
|
|
17
|
+
const safeRelativePath = path.posix.relative('/', path.resolve('/', filePath));
|
|
18
|
+
|
|
19
|
+
// Check for overlapping path segments
|
|
20
|
+
const projectDirSegments = PROJECT_DIR.split(path.sep);
|
|
21
|
+
const relativePathSegments = safeRelativePath.split(path.posix.sep);
|
|
22
|
+
|
|
23
|
+
// Find the longest matching suffix of PROJECT_DIR with prefix of relative path
|
|
24
|
+
let overlapLength = 0;
|
|
25
|
+
for (let i = 1; i <= Math.min(projectDirSegments.length, relativePathSegments.length); i++) {
|
|
26
|
+
const projectSuffix = projectDirSegments.slice(-i);
|
|
27
|
+
const relativPrefix = relativePathSegments.slice(0, i);
|
|
28
|
+
|
|
29
|
+
if (projectSuffix.join(path.sep) === relativPrefix.join(path.posix.sep)) {
|
|
30
|
+
overlapLength = i;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Remove overlapping segments from the relative path
|
|
35
|
+
const cleanedRelativePath = relativePathSegments.slice(overlapLength).join(path.posix.sep);
|
|
36
|
+
const absoluteFilePath = path.join(PROJECT_DIR, cleanedRelativePath);
|
|
37
|
+
|
|
38
|
+
const directory = path.dirname(absoluteFilePath || '');
|
|
39
|
+
return path.join(directory, fileName);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return path.join(PROJECT_DIR, filePath);
|
|
43
|
+
};
|
package/package.json
CHANGED