@eventcatalog/core 4.7.3 → 4.7.4
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-XXJX3WWF.js → chunk-7QTCSRAC.js} +1 -1
- package/dist/chunk-A2RZR3U4.js +29 -0
- package/dist/{chunk-SMDTRRED.js → chunk-FDXJIZ74.js} +1 -1
- package/dist/{chunk-ZR6AH5Z2.js → chunk-RIUHZZRA.js} +4 -4
- package/dist/chunk-SDZQJTJW.js +90 -0
- package/dist/{chunk-V4FAVGI7.js → chunk-TLWM7WRZ.js} +1 -1
- package/dist/{chunk-GINIJSFI.js → chunk-ZIABX6SP.js} +1 -1
- package/dist/{chunk-IALEXWSE.js → chunk-ZXVQXBTT.js} +1 -1
- package/dist/constants.cjs +1 -1
- package/dist/constants.js +1 -1
- package/dist/eventcatalog.cjs +315 -209
- package/dist/eventcatalog.config.d.cts +3 -3
- package/dist/eventcatalog.config.d.ts +3 -3
- package/dist/eventcatalog.js +11 -9
- package/dist/federation/federate.cjs +269 -163
- package/dist/federation/federate.js +3 -1
- package/dist/federation/filesystem-source-provider.cjs +124 -0
- package/dist/federation/filesystem-source-provider.d.cts +7 -0
- package/dist/federation/filesystem-source-provider.d.ts +7 -0
- package/dist/federation/filesystem-source-provider.js +6 -0
- package/dist/federation/source-provider.cjs +265 -0
- package/dist/federation/source-provider.d.cts +11 -0
- package/dist/federation/source-provider.d.ts +11 -0
- package/dist/federation/source-provider.js +8 -0
- package/dist/generate.cjs +1 -1
- package/dist/generate.js +3 -3
- package/dist/utils/cli-logger.cjs +1 -1
- package/dist/utils/cli-logger.js +2 -2
- package/package.json +3 -3
|
@@ -140,7 +140,7 @@ var verifyRequiredFieldsAreInCatalogConfigFile = async (projectDirectory) => {
|
|
|
140
140
|
var import_os = __toESM(require("os"), 1);
|
|
141
141
|
|
|
142
142
|
// package.json
|
|
143
|
-
var version = "4.7.
|
|
143
|
+
var version = "4.7.4";
|
|
144
144
|
|
|
145
145
|
// src/constants.ts
|
|
146
146
|
var VERSION = version;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
log_build_default
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-ZIABX6SP.js";
|
|
4
|
+
import "../chunk-FDXJIZ74.js";
|
|
5
5
|
import "../chunk-K2XIENVT.js";
|
|
6
|
-
import "../chunk-
|
|
6
|
+
import "../chunk-TLWM7WRZ.js";
|
|
7
7
|
import "../chunk-6QENHZZP.js";
|
|
8
8
|
export {
|
|
9
9
|
log_build_default as default
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createFileSystemSourceProvider
|
|
3
|
+
} from "./chunk-SDZQJTJW.js";
|
|
4
|
+
import {
|
|
5
|
+
createGitHubSourceProvider
|
|
6
|
+
} from "./chunk-352FGP6W.js";
|
|
7
|
+
|
|
8
|
+
// src/federation/source-provider.ts
|
|
9
|
+
var createFederationSourceProvider = (projectDirectory, providers = {}) => {
|
|
10
|
+
const github = providers.github ?? createGitHubSourceProvider();
|
|
11
|
+
const filesystem = providers.filesystem ?? createFileSystemSourceProvider(projectDirectory);
|
|
12
|
+
const getProvider = (source) => {
|
|
13
|
+
if (source.source.startsWith("github:")) return github;
|
|
14
|
+
if (source.source.startsWith("file:")) return filesystem;
|
|
15
|
+
throw new Error(`Unsupported federation source "${source.source}" for "${source.id}". Supported protocols: github:, file:.`);
|
|
16
|
+
};
|
|
17
|
+
return {
|
|
18
|
+
async resolve(source) {
|
|
19
|
+
return getProvider(source).resolve(source);
|
|
20
|
+
},
|
|
21
|
+
async fetchContent(request) {
|
|
22
|
+
return getProvider(request.source).fetchContent(request);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export {
|
|
28
|
+
createFederationSourceProvider
|
|
29
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createFederationSourceProvider
|
|
3
|
+
} from "./chunk-A2RZR3U4.js";
|
|
1
4
|
import {
|
|
2
5
|
createFederationContentCache
|
|
3
6
|
} from "./chunk-R7Z5ALYI.js";
|
|
4
|
-
import {
|
|
5
|
-
createGitHubSourceProvider
|
|
6
|
-
} from "./chunk-352FGP6W.js";
|
|
7
7
|
import {
|
|
8
8
|
composePublicAssets
|
|
9
9
|
} from "./chunk-5EPNFDT5.js";
|
|
@@ -98,7 +98,7 @@ var federateCatalog = async (projectDirectory, options = {}) => {
|
|
|
98
98
|
}
|
|
99
99
|
validateSources(sources);
|
|
100
100
|
if (options.useCache === false) options.onProgress?.({ type: "cache:disabled" });
|
|
101
|
-
const provider = options.provider ??
|
|
101
|
+
const provider = options.provider ?? createFederationSourceProvider(projectDirectory);
|
|
102
102
|
const resolvedSources = [];
|
|
103
103
|
for (const [index, source] of sources.entries()) {
|
|
104
104
|
const current = index + 1;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// src/federation/filesystem-source-provider.ts
|
|
2
|
+
import { createHash } from "crypto";
|
|
3
|
+
import fs from "fs/promises";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import createSDK from "@eventcatalog/sdk";
|
|
6
|
+
var FILESYSTEM_SOURCE_PREFIX = "file:";
|
|
7
|
+
var isWithinDirectory = (directory, target) => {
|
|
8
|
+
const relativePath = path.relative(directory, target);
|
|
9
|
+
return relativePath === "" || !relativePath.startsWith(`..${path.sep}`) && relativePath !== ".." && !path.isAbsolute(relativePath);
|
|
10
|
+
};
|
|
11
|
+
var assertPortableRelativePath = (filePath, label, allowRoot = true) => {
|
|
12
|
+
const portablePath = filePath.replaceAll("\\", "/");
|
|
13
|
+
const normalizedPath = path.posix.normalize(portablePath);
|
|
14
|
+
const isUnsafe = filePath.includes("\\") || filePath.includes("\0") || path.posix.isAbsolute(normalizedPath) || /^[a-zA-Z]:\//.test(normalizedPath) || normalizedPath === ".." || normalizedPath.startsWith("../") || !allowRoot && (normalizedPath === "." || normalizedPath === "");
|
|
15
|
+
if (isUnsafe) throw new Error(`${label} "${filePath}" escapes its filesystem source`);
|
|
16
|
+
return normalizedPath;
|
|
17
|
+
};
|
|
18
|
+
var getSourceRoot = (projectDirectory, source) => {
|
|
19
|
+
if (!source.source.startsWith(FILESYSTEM_SOURCE_PREFIX)) {
|
|
20
|
+
throw new Error(`Unsupported federation source "${source.source}". Expected file:path/to/catalog.`);
|
|
21
|
+
}
|
|
22
|
+
const locator = source.source.slice(FILESYSTEM_SOURCE_PREFIX.length);
|
|
23
|
+
if (!locator.trim()) throw new Error(`Filesystem federation source "${source.id}" requires a path after "file:".`);
|
|
24
|
+
return path.resolve(projectDirectory, locator);
|
|
25
|
+
};
|
|
26
|
+
var getCatalogDirectory = async (projectDirectory, source) => {
|
|
27
|
+
if (source.ref) throw new Error(`Filesystem federation source "${source.id}" does not support "ref".`);
|
|
28
|
+
const sourceRoot = getSourceRoot(projectDirectory, source);
|
|
29
|
+
const catalogPath = assertPortableRelativePath(source.path ?? ".", "Catalog path");
|
|
30
|
+
const catalogDirectory = path.resolve(sourceRoot, ...catalogPath.split("/"));
|
|
31
|
+
if (!isWithinDirectory(sourceRoot, catalogDirectory)) {
|
|
32
|
+
throw new Error(`Catalog path "${source.path}" escapes source "${source.id}"`);
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
const [realSourceRoot, realCatalogDirectory] = await Promise.all([fs.realpath(sourceRoot), fs.realpath(catalogDirectory)]);
|
|
36
|
+
if (!isWithinDirectory(realSourceRoot, realCatalogDirectory)) {
|
|
37
|
+
throw new Error(`Catalog path "${source.path}" escapes source "${source.id}"`);
|
|
38
|
+
}
|
|
39
|
+
if (!(await fs.stat(realCatalogDirectory)).isDirectory()) {
|
|
40
|
+
throw new Error(`Filesystem federation source "${source.id}" is not a directory: ${catalogDirectory}`);
|
|
41
|
+
}
|
|
42
|
+
return realCatalogDirectory;
|
|
43
|
+
} catch (error) {
|
|
44
|
+
if (error.code === "ENOENT") {
|
|
45
|
+
throw new Error(`Filesystem federation source "${source.id}" does not exist: ${catalogDirectory}`, { cause: error });
|
|
46
|
+
}
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
var getArtifactPath = async (catalogDirectory, source, artifactPath) => {
|
|
51
|
+
const normalizedPath = assertPortableRelativePath(artifactPath, "Federated artifact path", false);
|
|
52
|
+
const filePath = path.resolve(catalogDirectory, ...normalizedPath.split("/"));
|
|
53
|
+
if (!isWithinDirectory(catalogDirectory, filePath)) {
|
|
54
|
+
throw new Error(`Federated artifact path "${artifactPath}" escapes source "${source.id}"`);
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
const realFilePath = await fs.realpath(filePath);
|
|
58
|
+
if (!isWithinDirectory(catalogDirectory, realFilePath)) {
|
|
59
|
+
throw new Error(`Federated artifact path "${artifactPath}" escapes source "${source.id}"`);
|
|
60
|
+
}
|
|
61
|
+
return realFilePath;
|
|
62
|
+
} catch (error) {
|
|
63
|
+
if (error.code === "ENOENT") {
|
|
64
|
+
throw new Error(`Federated artifact not found for "${source.id}": ${artifactPath}`, { cause: error });
|
|
65
|
+
}
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
var createFileSystemSourceProvider = (projectDirectory) => ({
|
|
70
|
+
async resolve(source) {
|
|
71
|
+
const catalogDirectory = await getCatalogDirectory(projectDirectory, source);
|
|
72
|
+
const localIndex = await createSDK(catalogDirectory).buildIndex({
|
|
73
|
+
source: source.id,
|
|
74
|
+
commit: "local",
|
|
75
|
+
includeFederated: false
|
|
76
|
+
});
|
|
77
|
+
const snapshot = createHash("sha256").update(JSON.stringify(localIndex)).digest("hex").slice(0, 12);
|
|
78
|
+
const index = { ...localIndex, commit: `local:${snapshot}` };
|
|
79
|
+
const bytes = Buffer.from(JSON.stringify(index));
|
|
80
|
+
return { bytes, index, commit: index.commit, generated: true };
|
|
81
|
+
},
|
|
82
|
+
async fetchContent({ source, path: artifactPath }) {
|
|
83
|
+
const catalogDirectory = await getCatalogDirectory(projectDirectory, source);
|
|
84
|
+
return fs.readFile(await getArtifactPath(catalogDirectory, source, artifactPath));
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
export {
|
|
89
|
+
createFileSystemSourceProvider
|
|
90
|
+
};
|
package/dist/constants.cjs
CHANGED