@eventcatalog/core 4.7.2 → 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/catalog-to-astro-content-directory.cjs +65 -13
- package/dist/catalog-to-astro-content-directory.js +2 -1
- package/dist/{chunk-FTNXTYFU.js → chunk-7QTCSRAC.js} +1 -1
- package/dist/chunk-A2RZR3U4.js +29 -0
- package/dist/{chunk-CWVGSEON.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-W3SAPOZU.js → chunk-T4RVWPIQ.js} +6 -0
- package/dist/chunk-T5IUG523.js +54 -0
- package/dist/{chunk-YTT25224.js → chunk-TLWM7WRZ.js} +1 -1
- package/dist/{chunk-5QOWJT54.js → chunk-ZIABX6SP.js} +3 -3
- package/dist/{chunk-2ERJ2Z5B.js → chunk-ZXVQXBTT.js} +1 -1
- package/dist/constants.cjs +1 -1
- package/dist/constants.js +1 -1
- package/dist/custom-components.cjs +89 -0
- package/dist/custom-components.d.cts +4 -0
- package/dist/custom-components.d.ts +4 -0
- package/dist/custom-components.js +8 -0
- package/dist/eventcatalog.cjs +401 -241
- package/dist/eventcatalog.config.d.cts +3 -3
- package/dist/eventcatalog.config.d.ts +3 -3
- package/dist/eventcatalog.js +14 -11
- 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
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/federation/filesystem-source-provider.ts
|
|
31
|
+
var filesystem_source_provider_exports = {};
|
|
32
|
+
__export(filesystem_source_provider_exports, {
|
|
33
|
+
createFileSystemSourceProvider: () => createFileSystemSourceProvider
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(filesystem_source_provider_exports);
|
|
36
|
+
var import_node_crypto = require("crypto");
|
|
37
|
+
var import_promises = __toESM(require("fs/promises"), 1);
|
|
38
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
39
|
+
var import_sdk = __toESM(require("@eventcatalog/sdk"), 1);
|
|
40
|
+
var FILESYSTEM_SOURCE_PREFIX = "file:";
|
|
41
|
+
var isWithinDirectory = (directory, target) => {
|
|
42
|
+
const relativePath = import_node_path.default.relative(directory, target);
|
|
43
|
+
return relativePath === "" || !relativePath.startsWith(`..${import_node_path.default.sep}`) && relativePath !== ".." && !import_node_path.default.isAbsolute(relativePath);
|
|
44
|
+
};
|
|
45
|
+
var assertPortableRelativePath = (filePath, label, allowRoot = true) => {
|
|
46
|
+
const portablePath = filePath.replaceAll("\\", "/");
|
|
47
|
+
const normalizedPath = import_node_path.default.posix.normalize(portablePath);
|
|
48
|
+
const isUnsafe = filePath.includes("\\") || filePath.includes("\0") || import_node_path.default.posix.isAbsolute(normalizedPath) || /^[a-zA-Z]:\//.test(normalizedPath) || normalizedPath === ".." || normalizedPath.startsWith("../") || !allowRoot && (normalizedPath === "." || normalizedPath === "");
|
|
49
|
+
if (isUnsafe) throw new Error(`${label} "${filePath}" escapes its filesystem source`);
|
|
50
|
+
return normalizedPath;
|
|
51
|
+
};
|
|
52
|
+
var getSourceRoot = (projectDirectory, source) => {
|
|
53
|
+
if (!source.source.startsWith(FILESYSTEM_SOURCE_PREFIX)) {
|
|
54
|
+
throw new Error(`Unsupported federation source "${source.source}". Expected file:path/to/catalog.`);
|
|
55
|
+
}
|
|
56
|
+
const locator = source.source.slice(FILESYSTEM_SOURCE_PREFIX.length);
|
|
57
|
+
if (!locator.trim()) throw new Error(`Filesystem federation source "${source.id}" requires a path after "file:".`);
|
|
58
|
+
return import_node_path.default.resolve(projectDirectory, locator);
|
|
59
|
+
};
|
|
60
|
+
var getCatalogDirectory = async (projectDirectory, source) => {
|
|
61
|
+
if (source.ref) throw new Error(`Filesystem federation source "${source.id}" does not support "ref".`);
|
|
62
|
+
const sourceRoot = getSourceRoot(projectDirectory, source);
|
|
63
|
+
const catalogPath = assertPortableRelativePath(source.path ?? ".", "Catalog path");
|
|
64
|
+
const catalogDirectory = import_node_path.default.resolve(sourceRoot, ...catalogPath.split("/"));
|
|
65
|
+
if (!isWithinDirectory(sourceRoot, catalogDirectory)) {
|
|
66
|
+
throw new Error(`Catalog path "${source.path}" escapes source "${source.id}"`);
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
const [realSourceRoot, realCatalogDirectory] = await Promise.all([import_promises.default.realpath(sourceRoot), import_promises.default.realpath(catalogDirectory)]);
|
|
70
|
+
if (!isWithinDirectory(realSourceRoot, realCatalogDirectory)) {
|
|
71
|
+
throw new Error(`Catalog path "${source.path}" escapes source "${source.id}"`);
|
|
72
|
+
}
|
|
73
|
+
if (!(await import_promises.default.stat(realCatalogDirectory)).isDirectory()) {
|
|
74
|
+
throw new Error(`Filesystem federation source "${source.id}" is not a directory: ${catalogDirectory}`);
|
|
75
|
+
}
|
|
76
|
+
return realCatalogDirectory;
|
|
77
|
+
} catch (error) {
|
|
78
|
+
if (error.code === "ENOENT") {
|
|
79
|
+
throw new Error(`Filesystem federation source "${source.id}" does not exist: ${catalogDirectory}`, { cause: error });
|
|
80
|
+
}
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
var getArtifactPath = async (catalogDirectory, source, artifactPath) => {
|
|
85
|
+
const normalizedPath = assertPortableRelativePath(artifactPath, "Federated artifact path", false);
|
|
86
|
+
const filePath = import_node_path.default.resolve(catalogDirectory, ...normalizedPath.split("/"));
|
|
87
|
+
if (!isWithinDirectory(catalogDirectory, filePath)) {
|
|
88
|
+
throw new Error(`Federated artifact path "${artifactPath}" escapes source "${source.id}"`);
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
const realFilePath = await import_promises.default.realpath(filePath);
|
|
92
|
+
if (!isWithinDirectory(catalogDirectory, realFilePath)) {
|
|
93
|
+
throw new Error(`Federated artifact path "${artifactPath}" escapes source "${source.id}"`);
|
|
94
|
+
}
|
|
95
|
+
return realFilePath;
|
|
96
|
+
} catch (error) {
|
|
97
|
+
if (error.code === "ENOENT") {
|
|
98
|
+
throw new Error(`Federated artifact not found for "${source.id}": ${artifactPath}`, { cause: error });
|
|
99
|
+
}
|
|
100
|
+
throw error;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
var createFileSystemSourceProvider = (projectDirectory) => ({
|
|
104
|
+
async resolve(source) {
|
|
105
|
+
const catalogDirectory = await getCatalogDirectory(projectDirectory, source);
|
|
106
|
+
const localIndex = await (0, import_sdk.default)(catalogDirectory).buildIndex({
|
|
107
|
+
source: source.id,
|
|
108
|
+
commit: "local",
|
|
109
|
+
includeFederated: false
|
|
110
|
+
});
|
|
111
|
+
const snapshot = (0, import_node_crypto.createHash)("sha256").update(JSON.stringify(localIndex)).digest("hex").slice(0, 12);
|
|
112
|
+
const index = { ...localIndex, commit: `local:${snapshot}` };
|
|
113
|
+
const bytes = Buffer.from(JSON.stringify(index));
|
|
114
|
+
return { bytes, index, commit: index.commit, generated: true };
|
|
115
|
+
},
|
|
116
|
+
async fetchContent({ source, path: artifactPath }) {
|
|
117
|
+
const catalogDirectory = await getCatalogDirectory(projectDirectory, source);
|
|
118
|
+
return import_promises.default.readFile(await getArtifactPath(catalogDirectory, source, artifactPath));
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
122
|
+
0 && (module.exports = {
|
|
123
|
+
createFileSystemSourceProvider
|
|
124
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FederationSourceProvider } from './types.cjs';
|
|
2
|
+
import '@eventcatalog/sdk';
|
|
3
|
+
import '../eventcatalog.config.cjs';
|
|
4
|
+
|
|
5
|
+
declare const createFileSystemSourceProvider: (projectDirectory: string) => FederationSourceProvider;
|
|
6
|
+
|
|
7
|
+
export { createFileSystemSourceProvider };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FederationSourceProvider } from './types.js';
|
|
2
|
+
import '@eventcatalog/sdk';
|
|
3
|
+
import '../eventcatalog.config.js';
|
|
4
|
+
|
|
5
|
+
declare const createFileSystemSourceProvider: (projectDirectory: string) => FederationSourceProvider;
|
|
6
|
+
|
|
7
|
+
export { createFileSystemSourceProvider };
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/federation/source-provider.ts
|
|
31
|
+
var source_provider_exports = {};
|
|
32
|
+
__export(source_provider_exports, {
|
|
33
|
+
createFederationSourceProvider: () => createFederationSourceProvider
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(source_provider_exports);
|
|
36
|
+
|
|
37
|
+
// src/federation/filesystem-source-provider.ts
|
|
38
|
+
var import_node_crypto = require("crypto");
|
|
39
|
+
var import_promises = __toESM(require("fs/promises"), 1);
|
|
40
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
41
|
+
var import_sdk = __toESM(require("@eventcatalog/sdk"), 1);
|
|
42
|
+
var FILESYSTEM_SOURCE_PREFIX = "file:";
|
|
43
|
+
var isWithinDirectory = (directory, target) => {
|
|
44
|
+
const relativePath = import_node_path.default.relative(directory, target);
|
|
45
|
+
return relativePath === "" || !relativePath.startsWith(`..${import_node_path.default.sep}`) && relativePath !== ".." && !import_node_path.default.isAbsolute(relativePath);
|
|
46
|
+
};
|
|
47
|
+
var assertPortableRelativePath = (filePath, label, allowRoot = true) => {
|
|
48
|
+
const portablePath = filePath.replaceAll("\\", "/");
|
|
49
|
+
const normalizedPath = import_node_path.default.posix.normalize(portablePath);
|
|
50
|
+
const isUnsafe = filePath.includes("\\") || filePath.includes("\0") || import_node_path.default.posix.isAbsolute(normalizedPath) || /^[a-zA-Z]:\//.test(normalizedPath) || normalizedPath === ".." || normalizedPath.startsWith("../") || !allowRoot && (normalizedPath === "." || normalizedPath === "");
|
|
51
|
+
if (isUnsafe) throw new Error(`${label} "${filePath}" escapes its filesystem source`);
|
|
52
|
+
return normalizedPath;
|
|
53
|
+
};
|
|
54
|
+
var getSourceRoot = (projectDirectory, source) => {
|
|
55
|
+
if (!source.source.startsWith(FILESYSTEM_SOURCE_PREFIX)) {
|
|
56
|
+
throw new Error(`Unsupported federation source "${source.source}". Expected file:path/to/catalog.`);
|
|
57
|
+
}
|
|
58
|
+
const locator = source.source.slice(FILESYSTEM_SOURCE_PREFIX.length);
|
|
59
|
+
if (!locator.trim()) throw new Error(`Filesystem federation source "${source.id}" requires a path after "file:".`);
|
|
60
|
+
return import_node_path.default.resolve(projectDirectory, locator);
|
|
61
|
+
};
|
|
62
|
+
var getCatalogDirectory = async (projectDirectory, source) => {
|
|
63
|
+
if (source.ref) throw new Error(`Filesystem federation source "${source.id}" does not support "ref".`);
|
|
64
|
+
const sourceRoot = getSourceRoot(projectDirectory, source);
|
|
65
|
+
const catalogPath = assertPortableRelativePath(source.path ?? ".", "Catalog path");
|
|
66
|
+
const catalogDirectory = import_node_path.default.resolve(sourceRoot, ...catalogPath.split("/"));
|
|
67
|
+
if (!isWithinDirectory(sourceRoot, catalogDirectory)) {
|
|
68
|
+
throw new Error(`Catalog path "${source.path}" escapes source "${source.id}"`);
|
|
69
|
+
}
|
|
70
|
+
try {
|
|
71
|
+
const [realSourceRoot, realCatalogDirectory] = await Promise.all([import_promises.default.realpath(sourceRoot), import_promises.default.realpath(catalogDirectory)]);
|
|
72
|
+
if (!isWithinDirectory(realSourceRoot, realCatalogDirectory)) {
|
|
73
|
+
throw new Error(`Catalog path "${source.path}" escapes source "${source.id}"`);
|
|
74
|
+
}
|
|
75
|
+
if (!(await import_promises.default.stat(realCatalogDirectory)).isDirectory()) {
|
|
76
|
+
throw new Error(`Filesystem federation source "${source.id}" is not a directory: ${catalogDirectory}`);
|
|
77
|
+
}
|
|
78
|
+
return realCatalogDirectory;
|
|
79
|
+
} catch (error) {
|
|
80
|
+
if (error.code === "ENOENT") {
|
|
81
|
+
throw new Error(`Filesystem federation source "${source.id}" does not exist: ${catalogDirectory}`, { cause: error });
|
|
82
|
+
}
|
|
83
|
+
throw error;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
var getArtifactPath = async (catalogDirectory, source, artifactPath) => {
|
|
87
|
+
const normalizedPath = assertPortableRelativePath(artifactPath, "Federated artifact path", false);
|
|
88
|
+
const filePath = import_node_path.default.resolve(catalogDirectory, ...normalizedPath.split("/"));
|
|
89
|
+
if (!isWithinDirectory(catalogDirectory, filePath)) {
|
|
90
|
+
throw new Error(`Federated artifact path "${artifactPath}" escapes source "${source.id}"`);
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
const realFilePath = await import_promises.default.realpath(filePath);
|
|
94
|
+
if (!isWithinDirectory(catalogDirectory, realFilePath)) {
|
|
95
|
+
throw new Error(`Federated artifact path "${artifactPath}" escapes source "${source.id}"`);
|
|
96
|
+
}
|
|
97
|
+
return realFilePath;
|
|
98
|
+
} catch (error) {
|
|
99
|
+
if (error.code === "ENOENT") {
|
|
100
|
+
throw new Error(`Federated artifact not found for "${source.id}": ${artifactPath}`, { cause: error });
|
|
101
|
+
}
|
|
102
|
+
throw error;
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
var createFileSystemSourceProvider = (projectDirectory) => ({
|
|
106
|
+
async resolve(source) {
|
|
107
|
+
const catalogDirectory = await getCatalogDirectory(projectDirectory, source);
|
|
108
|
+
const localIndex = await (0, import_sdk.default)(catalogDirectory).buildIndex({
|
|
109
|
+
source: source.id,
|
|
110
|
+
commit: "local",
|
|
111
|
+
includeFederated: false
|
|
112
|
+
});
|
|
113
|
+
const snapshot = (0, import_node_crypto.createHash)("sha256").update(JSON.stringify(localIndex)).digest("hex").slice(0, 12);
|
|
114
|
+
const index = { ...localIndex, commit: `local:${snapshot}` };
|
|
115
|
+
const bytes = Buffer.from(JSON.stringify(index));
|
|
116
|
+
return { bytes, index, commit: index.commit, generated: true };
|
|
117
|
+
},
|
|
118
|
+
async fetchContent({ source, path: artifactPath }) {
|
|
119
|
+
const catalogDirectory = await getCatalogDirectory(projectDirectory, source);
|
|
120
|
+
return import_promises.default.readFile(await getArtifactPath(catalogDirectory, source, artifactPath));
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// src/federation/github-source-provider.ts
|
|
125
|
+
var import_node_child_process = require("child_process");
|
|
126
|
+
var import_promises2 = __toESM(require("fs/promises"), 1);
|
|
127
|
+
var import_node_os = __toESM(require("os"), 1);
|
|
128
|
+
var import_node_path2 = __toESM(require("path"), 1);
|
|
129
|
+
var import_node_util = require("util");
|
|
130
|
+
var import_sdk2 = __toESM(require("@eventcatalog/sdk"), 1);
|
|
131
|
+
var execFileAsync = (0, import_node_util.promisify)(import_node_child_process.execFile);
|
|
132
|
+
var parseGitHubSource = (source) => {
|
|
133
|
+
const match = /^github:([^/]+)\/(.+)$/.exec(source.source);
|
|
134
|
+
if (!match) throw new Error(`Unsupported federation source "${source.source}". Expected github:owner/repository.`);
|
|
135
|
+
return { owner: match[1], repository: match[2] };
|
|
136
|
+
};
|
|
137
|
+
var assertSafeCatalogPath = (source) => {
|
|
138
|
+
const catalogPath = source.path ?? ".";
|
|
139
|
+
const normalized = import_node_path2.default.posix.normalize(catalogPath.replaceAll("\\", "/"));
|
|
140
|
+
if (catalogPath.includes("\\") || import_node_path2.default.posix.isAbsolute(normalized) || normalized === ".." || normalized.startsWith("../")) {
|
|
141
|
+
throw new Error(`Catalog path "${catalogPath}" escapes source "${source.id}"`);
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
var encodePath = (value) => value.split("/").filter(Boolean).map(encodeURIComponent).join("/");
|
|
145
|
+
var rawUrl = (source, ref, filePath) => {
|
|
146
|
+
const { owner, repository } = parseGitHubSource(source);
|
|
147
|
+
return `https://raw.githubusercontent.com/${encodeURIComponent(owner)}/${encodeURIComponent(repository)}/${encodeURIComponent(
|
|
148
|
+
ref
|
|
149
|
+
)}/${encodePath(filePath)}`;
|
|
150
|
+
};
|
|
151
|
+
var contentsApiUrl = (source, ref, filePath) => {
|
|
152
|
+
const { owner, repository } = parseGitHubSource(source);
|
|
153
|
+
return `https://api.github.com/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repository)}/contents/${encodePath(
|
|
154
|
+
filePath
|
|
155
|
+
)}?ref=${encodeURIComponent(ref)}`;
|
|
156
|
+
};
|
|
157
|
+
var fetchBytes = async (source, ref, filePath, fetcher, token) => {
|
|
158
|
+
const url = token ? contentsApiUrl(source, ref, filePath) : rawUrl(source, ref, filePath);
|
|
159
|
+
const response = token ? await fetcher(url, {
|
|
160
|
+
headers: {
|
|
161
|
+
Accept: "application/vnd.github.raw+json",
|
|
162
|
+
Authorization: `Bearer ${token}`,
|
|
163
|
+
"X-GitHub-Api-Version": "2026-03-10"
|
|
164
|
+
}
|
|
165
|
+
}) : await fetcher(url);
|
|
166
|
+
if (response.status === 404) return void 0;
|
|
167
|
+
if (!response.ok) throw new Error(`Failed to fetch ${url}: ${response.status} ${response.statusText}`);
|
|
168
|
+
return Buffer.from(await response.arrayBuffer());
|
|
169
|
+
};
|
|
170
|
+
var getGitEnvironment = (token) => {
|
|
171
|
+
if (!token) return process.env;
|
|
172
|
+
const inheritedCount = Number.parseInt(process.env.GIT_CONFIG_COUNT ?? "0", 10);
|
|
173
|
+
const configIndex = Number.isInteger(inheritedCount) && inheritedCount >= 0 ? inheritedCount : 0;
|
|
174
|
+
return {
|
|
175
|
+
...process.env,
|
|
176
|
+
GIT_CONFIG_COUNT: String(configIndex + 1),
|
|
177
|
+
[`GIT_CONFIG_KEY_${configIndex}`]: "http.https://github.com/.extraheader",
|
|
178
|
+
[`GIT_CONFIG_VALUE_${configIndex}`]: `AUTHORIZATION: basic ${Buffer.from(`x-access-token:${token}`).toString("base64")}`
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
var createCheckout = (executeFile, token) => async (source, ref, callback) => {
|
|
182
|
+
const { owner, repository } = parseGitHubSource(source);
|
|
183
|
+
const catalogPath = import_node_path2.default.posix.normalize(source.path ?? ".");
|
|
184
|
+
const directory = await import_promises2.default.mkdtemp(import_node_path2.default.join(import_node_os.default.tmpdir(), "eventcatalog-federation-"));
|
|
185
|
+
const env = getGitEnvironment(token);
|
|
186
|
+
try {
|
|
187
|
+
const git = (args) => executeFile("git", args, { cwd: directory, env, encoding: "utf8" });
|
|
188
|
+
await git(["init", "--quiet"]);
|
|
189
|
+
await git(["remote", "add", "origin", `https://github.com/${owner}/${repository}.git`]);
|
|
190
|
+
if (catalogPath !== ".") {
|
|
191
|
+
await git(["sparse-checkout", "init", "--cone"]);
|
|
192
|
+
await git(["sparse-checkout", "set", catalogPath]);
|
|
193
|
+
}
|
|
194
|
+
await git(["fetch", "--quiet", "--depth", "1", "origin", ref]);
|
|
195
|
+
await git(["checkout", "--quiet", "--detach", "FETCH_HEAD"]);
|
|
196
|
+
return await callback(directory);
|
|
197
|
+
} finally {
|
|
198
|
+
await import_promises2.default.rm(directory, { recursive: true, force: true });
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
var generateIndex = async (source, ref, checkout, executeFile) => checkout(source, ref, async (directory) => {
|
|
202
|
+
const { stdout } = await executeFile("git", ["rev-parse", "HEAD"], { cwd: directory, encoding: "utf8" });
|
|
203
|
+
const commit = stdout.trim();
|
|
204
|
+
const catalogDirectory = import_node_path2.default.resolve(directory, source.path ?? ".");
|
|
205
|
+
const relativeCatalogDirectory = import_node_path2.default.relative(directory, catalogDirectory);
|
|
206
|
+
if (relativeCatalogDirectory.startsWith("..") || import_node_path2.default.isAbsolute(relativeCatalogDirectory)) {
|
|
207
|
+
throw new Error(`Catalog path "${source.path}" escapes source "${source.id}"`);
|
|
208
|
+
}
|
|
209
|
+
const index = await (0, import_sdk2.default)(catalogDirectory).buildIndex({ source: source.id, commit });
|
|
210
|
+
return { bytes: Buffer.from(JSON.stringify(index)), index, commit, generated: true };
|
|
211
|
+
});
|
|
212
|
+
var fetchPublishedIndex = async (source, ref, fetcher, token) => {
|
|
213
|
+
const indexPath = import_node_path2.default.posix.join(source.path ?? ".", "catalog.index.json");
|
|
214
|
+
const bytes = await fetchBytes(source, ref, indexPath, fetcher, token);
|
|
215
|
+
if (!bytes) return void 0;
|
|
216
|
+
const index = (0, import_sdk2.parseIndex)(JSON.parse(bytes.toString("utf8")));
|
|
217
|
+
if (index.source !== source.id) {
|
|
218
|
+
throw new Error(`Published index source "${index.source}" does not match configured id "${source.id}"`);
|
|
219
|
+
}
|
|
220
|
+
return { bytes, index, commit: index.commit, generated: false };
|
|
221
|
+
};
|
|
222
|
+
var createGitHubSourceProvider = (options = {}) => {
|
|
223
|
+
const fetcher = options.fetch ?? ((url, init) => fetch(url, init));
|
|
224
|
+
const executeFile = options.execFile ?? ((file, args, execOptions) => execFileAsync(file, args, execOptions));
|
|
225
|
+
const configuredToken = options.token ?? process.env.EVENTCATALOG_GITHUB_TOKEN ?? process.env.GITHUB_TOKEN;
|
|
226
|
+
const token = configuredToken?.trim() || void 0;
|
|
227
|
+
const checkout = options.checkout ?? createCheckout(executeFile, token);
|
|
228
|
+
return {
|
|
229
|
+
async resolve(source) {
|
|
230
|
+
assertSafeCatalogPath(source);
|
|
231
|
+
const ref = source.ref ?? "main";
|
|
232
|
+
return await fetchPublishedIndex(source, ref, fetcher, token) ?? generateIndex(source, ref, checkout, executeFile);
|
|
233
|
+
},
|
|
234
|
+
async fetchContent({ source, commit, path: artifactPath }) {
|
|
235
|
+
assertSafeCatalogPath(source);
|
|
236
|
+
const catalogPath = import_node_path2.default.posix.join(source.path ?? ".", artifactPath);
|
|
237
|
+
const content = await fetchBytes(source, commit, catalogPath, fetcher, token);
|
|
238
|
+
if (!content) throw new Error(`Federated artifact not found for "${source.id}": ${artifactPath}`);
|
|
239
|
+
return content;
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
// src/federation/source-provider.ts
|
|
245
|
+
var createFederationSourceProvider = (projectDirectory, providers = {}) => {
|
|
246
|
+
const github = providers.github ?? createGitHubSourceProvider();
|
|
247
|
+
const filesystem = providers.filesystem ?? createFileSystemSourceProvider(projectDirectory);
|
|
248
|
+
const getProvider = (source) => {
|
|
249
|
+
if (source.source.startsWith("github:")) return github;
|
|
250
|
+
if (source.source.startsWith("file:")) return filesystem;
|
|
251
|
+
throw new Error(`Unsupported federation source "${source.source}" for "${source.id}". Supported protocols: github:, file:.`);
|
|
252
|
+
};
|
|
253
|
+
return {
|
|
254
|
+
async resolve(source) {
|
|
255
|
+
return getProvider(source).resolve(source);
|
|
256
|
+
},
|
|
257
|
+
async fetchContent(request) {
|
|
258
|
+
return getProvider(request.source).fetchContent(request);
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
};
|
|
262
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
263
|
+
0 && (module.exports = {
|
|
264
|
+
createFederationSourceProvider
|
|
265
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FederationSourceProvider } from './types.cjs';
|
|
2
|
+
import '@eventcatalog/sdk';
|
|
3
|
+
import '../eventcatalog.config.cjs';
|
|
4
|
+
|
|
5
|
+
type FederationSourceProviders = {
|
|
6
|
+
github?: FederationSourceProvider;
|
|
7
|
+
filesystem?: FederationSourceProvider;
|
|
8
|
+
};
|
|
9
|
+
declare const createFederationSourceProvider: (projectDirectory: string, providers?: FederationSourceProviders) => FederationSourceProvider;
|
|
10
|
+
|
|
11
|
+
export { createFederationSourceProvider };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FederationSourceProvider } from './types.js';
|
|
2
|
+
import '@eventcatalog/sdk';
|
|
3
|
+
import '../eventcatalog.config.js';
|
|
4
|
+
|
|
5
|
+
type FederationSourceProviders = {
|
|
6
|
+
github?: FederationSourceProvider;
|
|
7
|
+
filesystem?: FederationSourceProvider;
|
|
8
|
+
};
|
|
9
|
+
declare const createFederationSourceProvider: (projectDirectory: string, providers?: FederationSourceProviders) => FederationSourceProvider;
|
|
10
|
+
|
|
11
|
+
export { createFederationSourceProvider };
|
package/dist/generate.cjs
CHANGED
|
@@ -108,7 +108,7 @@ var getEventCatalogConfigFile = async (projectDirectory) => {
|
|
|
108
108
|
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
109
109
|
|
|
110
110
|
// package.json
|
|
111
|
-
var version = "4.7.
|
|
111
|
+
var version = "4.7.4";
|
|
112
112
|
|
|
113
113
|
// src/constants.ts
|
|
114
114
|
var VERSION = version;
|
package/dist/generate.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
generate
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-7QTCSRAC.js";
|
|
4
|
+
import "./chunk-ZXVQXBTT.js";
|
|
5
|
+
import "./chunk-TLWM7WRZ.js";
|
|
6
6
|
import "./chunk-6QENHZZP.js";
|
|
7
7
|
export {
|
|
8
8
|
generate
|
package/dist/utils/cli-logger.js
CHANGED
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
},
|
|
8
8
|
"license": "SEE LICENSE IN LICENSE",
|
|
9
9
|
"type": "module",
|
|
10
|
-
"version": "4.7.
|
|
10
|
+
"version": "4.7.4",
|
|
11
11
|
"publishConfig": {
|
|
12
12
|
"access": "public"
|
|
13
13
|
},
|
|
@@ -119,8 +119,8 @@
|
|
|
119
119
|
"update-notifier": "^7.3.1",
|
|
120
120
|
"uuid": "^11.1.1",
|
|
121
121
|
"zod": "^4.3.6",
|
|
122
|
-
"@eventcatalog/
|
|
123
|
-
"@eventcatalog/
|
|
122
|
+
"@eventcatalog/linter": "1.1.13",
|
|
123
|
+
"@eventcatalog/sdk": "2.27.3",
|
|
124
124
|
"@eventcatalog/visualiser": "^4.1.3"
|
|
125
125
|
},
|
|
126
126
|
"devDependencies": {
|