@eventcatalog/core 5.0.0-beta.26 → 5.0.0-beta.28
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 +89 -44
- package/dist/analytics/log-build.d.cts +2 -2
- package/dist/analytics/log-build.d.ts +2 -2
- package/dist/analytics/log-build.js +5 -4
- package/dist/analytics/studio-usage.cjs +90 -0
- package/dist/analytics/studio-usage.d.cts +5 -0
- package/dist/analytics/studio-usage.d.ts +5 -0
- package/dist/analytics/studio-usage.js +10 -0
- package/dist/{chunk-RFIXKATC.js → chunk-4G7FSRPN.js} +35 -42
- package/dist/chunk-CA6WCQ2T.js +54 -0
- package/dist/{chunk-M4TIQ4Z6.js → chunk-EUMQAONX.js} +1 -1
- package/dist/{chunk-O2ZA26FX.js → chunk-G46KUC6G.js} +4 -2
- package/dist/{chunk-MDWB5HLO.js → chunk-NKNOXQ62.js} +1 -1
- package/dist/{chunk-KHACCTW2.js → chunk-OX6TSVHY.js} +2 -2
- package/dist/{chunk-36RYTYT5.js → chunk-PD7KTSYN.js} +1 -1
- package/dist/{chunk-TMCBFXNE.js → chunk-QWFP2PDM.js} +1 -1
- package/dist/{chunk-LBHPRPYB.js → chunk-TDUUHSGF.js} +1 -1
- package/dist/{chunk-W4RMG6EP.js → chunk-VAL22T5Y.js} +12 -4
- package/dist/constants.cjs +1 -1
- package/dist/constants.js +1 -1
- package/dist/eventcatalog-config-file-utils.cjs +34 -41
- package/dist/eventcatalog-config-file-utils.d.cts +56 -58
- package/dist/eventcatalog-config-file-utils.d.ts +56 -58
- package/dist/eventcatalog-config-file-utils.js +1 -1
- package/dist/eventcatalog.cjs +281 -233
- package/dist/eventcatalog.js +15 -13
- package/dist/features.cjs +34 -41
- package/dist/features.js +2 -2
- package/dist/federation/federate.cjs +37 -44
- package/dist/federation/federate.js +4 -4
- package/dist/federation/source-provider.js +2 -2
- package/dist/generate.cjs +37 -42
- package/dist/generate.js +4 -4
- package/dist/resolve-catalog-dependencies.cjs +34 -41
- package/dist/resolve-catalog-dependencies.js +2 -2
- package/dist/utils/cli-logger.cjs +1 -1
- package/dist/utils/cli-logger.js +2 -2
- package/eventcatalog/integrations/config-loader.mjs +56 -58
- package/package.json +3 -3
- package/dist/{chunk-A2RZR3U4.js → chunk-6K7XZAYI.js} +3 -3
package/dist/eventcatalog.cjs
CHANGED
|
@@ -29,12 +29,12 @@ var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
|
29
29
|
// src/eventcatalog.ts
|
|
30
30
|
var import_commander = require("commander");
|
|
31
31
|
var import_node_child_process2 = require("child_process");
|
|
32
|
-
var
|
|
32
|
+
var import_node_path21 = require("path");
|
|
33
33
|
var import_node_http = __toESM(require("http"), 1);
|
|
34
34
|
var import_fs = __toESM(require("fs"), 1);
|
|
35
|
-
var
|
|
35
|
+
var import_node_path22 = __toESM(require("path"), 1);
|
|
36
36
|
var import_node_url2 = require("url");
|
|
37
|
-
var
|
|
37
|
+
var import_node_module3 = require("module");
|
|
38
38
|
|
|
39
39
|
// src/generate.js
|
|
40
40
|
var import_node_path3 = __toESM(require("path"), 1);
|
|
@@ -50,65 +50,58 @@ var import_promises = require("fs/promises");
|
|
|
50
50
|
var import_node_fs = require("fs");
|
|
51
51
|
var import_node_path = __toESM(require("path"), 1);
|
|
52
52
|
var import_node_url = require("url");
|
|
53
|
-
var
|
|
53
|
+
var import_node_module = require("module");
|
|
54
54
|
async function cleanup(projectDirectory) {
|
|
55
55
|
const filePath = import_node_path.default.join(projectDirectory, "eventcatalog.config.mjs");
|
|
56
56
|
if ((0, import_node_fs.existsSync)(filePath)) {
|
|
57
57
|
await (0, import_promises.rm)(filePath);
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
var
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
var linkNodeModulesIntoTempDirectory = async ({ projectDirectory, tempDir }) => {
|
|
75
|
-
const nodeModulesDirectory = findNodeModulesDirectory(projectDirectory);
|
|
76
|
-
if (!nodeModulesDirectory) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
await (0, import_promises.symlink)(nodeModulesDirectory, import_node_path.default.join(tempDir, "node_modules"), "dir");
|
|
60
|
+
var hidesConfigModuleTypeWarning = false;
|
|
61
|
+
var loads = 0;
|
|
62
|
+
var hideConfigModuleTypeWarning = () => {
|
|
63
|
+
if (hidesConfigModuleTypeWarning) return;
|
|
64
|
+
hidesConfigModuleTypeWarning = true;
|
|
65
|
+
const emitWarning = process.emitWarning;
|
|
66
|
+
process.emitWarning = function(warning, ...args) {
|
|
67
|
+
const code = typeof args[0] === "object" ? args[0]?.code : args[1];
|
|
68
|
+
const message2 = typeof warning === "string" ? warning : warning?.message;
|
|
69
|
+
if (code === "MODULE_TYPELESS_PACKAGE_JSON" && message2?.includes("eventcatalog.config.js")) return;
|
|
70
|
+
return emitWarning.call(this, warning, ...args);
|
|
71
|
+
};
|
|
80
72
|
};
|
|
81
|
-
var
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
73
|
+
var AS_MODULE_QUERY = "eventcatalog-config-as-module";
|
|
74
|
+
var loadsMarkedConfigsAsModules = false;
|
|
75
|
+
var loadMarkedConfigsAsModules = () => {
|
|
76
|
+
if (loadsMarkedConfigsAsModules) return;
|
|
77
|
+
loadsMarkedConfigsAsModules = true;
|
|
78
|
+
const hook = `export async function load(url, context, nextLoad) {
|
|
79
|
+
return nextLoad(url, url.includes('${AS_MODULE_QUERY}=') ? { ...context, format: 'module' } : context);
|
|
80
|
+
}`;
|
|
81
|
+
(0, import_node_module.register)(`data:text/javascript,${encodeURIComponent(hook)}`);
|
|
82
|
+
};
|
|
83
|
+
var isCommonJSPackage = async (projectDirectory) => {
|
|
84
|
+
try {
|
|
85
|
+
const packageJson = JSON.parse(await (0, import_promises.readFile)(import_node_path.default.join(projectDirectory, "package.json"), "utf-8"));
|
|
86
|
+
return packageJson?.type === "commonjs";
|
|
87
|
+
} catch {
|
|
88
|
+
return false;
|
|
85
89
|
}
|
|
86
|
-
const tempDir = await (0, import_promises.mkdtemp)(import_node_path.default.join((0, import_node_os.tmpdir)(), "eventcatalog-config-"));
|
|
87
|
-
await linkNodeModulesIntoTempDirectory({ projectDirectory, tempDir });
|
|
88
|
-
return tempDir;
|
|
89
90
|
};
|
|
90
91
|
var getEventCatalogConfigFile = async (projectDirectory) => {
|
|
91
|
-
let tempDir;
|
|
92
92
|
try {
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
configFilePath = import_node_path.default.join(tempDir, "eventcatalog.config.mjs");
|
|
99
|
-
await (0, import_promises.copyFile)(import_node_path.default.join(projectDirectory, "eventcatalog.config.js"), configFilePath);
|
|
100
|
-
}
|
|
101
|
-
const configFileURL = `${(0, import_node_url.pathToFileURL)(configFilePath).href}?t=${Date.now()}`;
|
|
93
|
+
hideConfigModuleTypeWarning();
|
|
94
|
+
const asModule = await isCommonJSPackage(projectDirectory);
|
|
95
|
+
if (asModule) loadMarkedConfigsAsModules();
|
|
96
|
+
const configFileURL = (0, import_node_url.pathToFileURL)(import_node_path.default.join(projectDirectory, "eventcatalog.config.js")).href;
|
|
97
|
+
const query = `${asModule ? AS_MODULE_QUERY : "loaded"}=${Date.now()}-${loads++}`;
|
|
102
98
|
const config = await import(
|
|
103
99
|
/* @vite-ignore */
|
|
104
|
-
configFileURL
|
|
100
|
+
`${configFileURL}?${query}`
|
|
105
101
|
);
|
|
106
102
|
return config.default;
|
|
107
103
|
} finally {
|
|
108
104
|
await cleanup(projectDirectory);
|
|
109
|
-
if (tempDir) {
|
|
110
|
-
await (0, import_promises.rm)(tempDir, { recursive: true, force: true });
|
|
111
|
-
}
|
|
112
105
|
}
|
|
113
106
|
};
|
|
114
107
|
|
|
@@ -181,7 +174,7 @@ var verifyRequiredFieldsAreInCatalogConfigFile = async (projectDirectory) => {
|
|
|
181
174
|
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
182
175
|
|
|
183
176
|
// package.json
|
|
184
|
-
var version = "5.0.0-beta.
|
|
177
|
+
var version = "5.0.0-beta.28";
|
|
185
178
|
|
|
186
179
|
// src/constants.ts
|
|
187
180
|
var VERSION = version;
|
|
@@ -295,10 +288,12 @@ var generate = async (PROJECT_DIRECTORY) => {
|
|
|
295
288
|
for (const { plugin } of errors) {
|
|
296
289
|
logger.error(` - ${plugin}`, "generator");
|
|
297
290
|
}
|
|
291
|
+
process.exitCode = 1;
|
|
298
292
|
}
|
|
299
293
|
} catch (error) {
|
|
300
294
|
console.error(error);
|
|
301
295
|
await cleanup(PROJECT_DIRECTORY);
|
|
296
|
+
process.exitCode = 1;
|
|
302
297
|
}
|
|
303
298
|
};
|
|
304
299
|
|
|
@@ -641,6 +636,55 @@ var printLicenseStatus = (license, tsd) => {
|
|
|
641
636
|
);
|
|
642
637
|
};
|
|
643
638
|
|
|
639
|
+
// src/analytics/studio-usage.js
|
|
640
|
+
var import_node_fs3 = __toESM(require("fs"), 1);
|
|
641
|
+
var import_node_path6 = __toESM(require("path"), 1);
|
|
642
|
+
var DAY_IN_MS3 = 24 * 60 * 60 * 1e3;
|
|
643
|
+
var DEFAULT_DATABASE_PATH = ".eventcatalog/eventcatalog.db";
|
|
644
|
+
var getStudioMode = (configFile) => {
|
|
645
|
+
const enabled = configFile.studio?.enabled;
|
|
646
|
+
if (enabled === false) return "off";
|
|
647
|
+
return configFile.output === "server" && enabled === true ? "server" : "dev";
|
|
648
|
+
};
|
|
649
|
+
var getStorageType = (configFile) => configFile.storage?.type || "memory";
|
|
650
|
+
var loadSqlite = () => {
|
|
651
|
+
const emitWarning = process.emitWarning;
|
|
652
|
+
process.emitWarning = function(warning, ...args) {
|
|
653
|
+
const type = typeof args[0] === "object" ? args[0]?.type : args[0];
|
|
654
|
+
const message2 = typeof warning === "string" ? warning : warning?.message;
|
|
655
|
+
if (type === "ExperimentalWarning" && message2?.startsWith("SQLite")) return;
|
|
656
|
+
return emitWarning.call(this, warning, ...args);
|
|
657
|
+
};
|
|
658
|
+
try {
|
|
659
|
+
return process.getBuiltinModule?.("node:sqlite");
|
|
660
|
+
} catch {
|
|
661
|
+
return void 0;
|
|
662
|
+
} finally {
|
|
663
|
+
process.emitWarning = emitWarning;
|
|
664
|
+
}
|
|
665
|
+
};
|
|
666
|
+
var UNKNOWN = "canvases:unknown";
|
|
667
|
+
var serializeStudioUsage = (projectDirectory, configFile, now = Date.now()) => {
|
|
668
|
+
if (getStudioMode(configFile) === "off" || getStorageType(configFile) !== "sqlite") return UNKNOWN;
|
|
669
|
+
const file = import_node_path6.default.resolve(projectDirectory, configFile.storage.path ?? DEFAULT_DATABASE_PATH);
|
|
670
|
+
if (!import_node_fs3.default.existsSync(file)) return "canvases:0,changed7d:0,changed30d:0,deleted:0";
|
|
671
|
+
let database;
|
|
672
|
+
try {
|
|
673
|
+
const sqlite = loadSqlite();
|
|
674
|
+
if (!sqlite?.DatabaseSync) return UNKNOWN;
|
|
675
|
+
database = new sqlite.DatabaseSync(file, { readOnly: true });
|
|
676
|
+
const canvases = database.prepare(
|
|
677
|
+
"SELECT COUNT(*) AS total, SUM(updated_at >= ?) AS changed7d, SUM(updated_at >= ?) AS changed30d FROM studio_canvases"
|
|
678
|
+
).get(now - 7 * DAY_IN_MS3, now - 30 * DAY_IN_MS3);
|
|
679
|
+
const { deleted } = database.prepare("SELECT COUNT(*) AS deleted FROM studio_deleted_canvases").get();
|
|
680
|
+
return `canvases:${canvases.total},changed7d:${canvases.changed7d ?? 0},changed30d:${canvases.changed30d ?? 0},deleted:${deleted}`;
|
|
681
|
+
} catch {
|
|
682
|
+
return UNKNOWN;
|
|
683
|
+
} finally {
|
|
684
|
+
database?.close();
|
|
685
|
+
}
|
|
686
|
+
};
|
|
687
|
+
|
|
644
688
|
// src/analytics/log-build.js
|
|
645
689
|
var isMCPEnabled = (configFile) => configFile.output === "server" && (configFile.mcp?.enabled ?? true);
|
|
646
690
|
var getFeatures = async (configFile) => {
|
|
@@ -654,7 +698,9 @@ var getFeatures = async (configFile) => {
|
|
|
654
698
|
environments: Array.isArray(configFile.environments) && configFile.environments.length > 0,
|
|
655
699
|
output: configFile.output || "static",
|
|
656
700
|
mcp,
|
|
657
|
-
mcpAuth: mcp && (configFile.mcp?.auth?.enabled ?? false)
|
|
701
|
+
mcpAuth: mcp && (configFile.mcp?.auth?.enabled ?? false),
|
|
702
|
+
studio: getStudioMode(configFile),
|
|
703
|
+
storage: getStorageType(configFile)
|
|
658
704
|
};
|
|
659
705
|
};
|
|
660
706
|
var getDirectoryProvider = (source) => {
|
|
@@ -755,7 +801,8 @@ var main = async (projectDir, { command = "build", license } = {}) => {
|
|
|
755
801
|
generators: generatorNames.toString(),
|
|
756
802
|
features: Object.keys(features).map((feature) => `${feature}:${features[feature]}`).join(","),
|
|
757
803
|
directorySources: serializeDirectorySources(configFile),
|
|
758
|
-
resources: serializeCounts(resourceCounts)
|
|
804
|
+
resources: serializeCounts(resourceCounts),
|
|
805
|
+
studio: serializeStudioUsage(projectDir, configFile)
|
|
759
806
|
},
|
|
760
807
|
configFile
|
|
761
808
|
);
|
|
@@ -776,8 +823,8 @@ async function watch(projectDirectory, catalogDirectory, callback = () => {
|
|
|
776
823
|
}
|
|
777
824
|
|
|
778
825
|
// src/resolve-catalog-dependencies.js
|
|
779
|
-
var
|
|
780
|
-
var
|
|
826
|
+
var import_node_path7 = __toESM(require("path"), 1);
|
|
827
|
+
var import_node_fs4 = __toESM(require("fs"), 1);
|
|
781
828
|
var import_gray_matter2 = __toESM(require("gray-matter"), 1);
|
|
782
829
|
var resolve_catalog_dependencies_default = async (catalogDir, core2) => {
|
|
783
830
|
const catalogConfig = await getEventCatalogConfigFile(catalogDir);
|
|
@@ -785,11 +832,11 @@ var resolve_catalog_dependencies_default = async (catalogDir, core2) => {
|
|
|
785
832
|
if (!dependencies) {
|
|
786
833
|
return;
|
|
787
834
|
}
|
|
788
|
-
const dependenciesDir =
|
|
789
|
-
if (
|
|
790
|
-
|
|
835
|
+
const dependenciesDir = import_node_path7.default.join(catalogDir, "dependencies");
|
|
836
|
+
if (import_node_fs4.default.existsSync(dependenciesDir)) {
|
|
837
|
+
import_node_fs4.default.rmSync(dependenciesDir, { recursive: true, force: true });
|
|
791
838
|
}
|
|
792
|
-
|
|
839
|
+
import_node_fs4.default.mkdirSync(dependenciesDir, { recursive: true });
|
|
793
840
|
const resourceTypes = Object.keys(dependencies);
|
|
794
841
|
for (const resourceType of resourceTypes) {
|
|
795
842
|
for (const dependency of dependencies[resourceType]) {
|
|
@@ -809,9 +856,9 @@ var resolve_catalog_dependencies_default = async (catalogDir, core2) => {
|
|
|
809
856
|
},
|
|
810
857
|
frontmatter
|
|
811
858
|
);
|
|
812
|
-
const resourceFile =
|
|
813
|
-
|
|
814
|
-
|
|
859
|
+
const resourceFile = import_node_path7.default.join(dependenciesDir, resourceType, dependency.id, `index.md`);
|
|
860
|
+
import_node_fs4.default.mkdirSync(import_node_path7.default.dirname(resourceFile), { recursive: true });
|
|
861
|
+
import_node_fs4.default.writeFileSync(resourceFile, markdown);
|
|
815
862
|
}
|
|
816
863
|
}
|
|
817
864
|
return;
|
|
@@ -821,8 +868,8 @@ var resolve_catalog_dependencies_default = async (catalogDir, core2) => {
|
|
|
821
868
|
var import_boxen2 = __toESM(require("boxen"), 1);
|
|
822
869
|
|
|
823
870
|
// src/features.ts
|
|
824
|
-
var
|
|
825
|
-
var
|
|
871
|
+
var import_node_path8 = require("path");
|
|
872
|
+
var import_node_fs5 = __toESM(require("fs"), 1);
|
|
826
873
|
var getProjectOutDir = async () => {
|
|
827
874
|
const config = await getEventCatalogConfigFile(process.env.PROJECT_DIR || "");
|
|
828
875
|
return config?.outDir || "dist";
|
|
@@ -837,7 +884,7 @@ var isIndexedSearchEnabled = async () => {
|
|
|
837
884
|
};
|
|
838
885
|
var isAuthEnabled = async () => {
|
|
839
886
|
const directory = process.env.PROJECT_DIR || process.cwd();
|
|
840
|
-
const hasAuthConfig =
|
|
887
|
+
const hasAuthConfig = import_node_fs5.default.existsSync((0, import_node_path8.join)(directory, "eventcatalog.auth.js"));
|
|
841
888
|
return hasAuthConfig;
|
|
842
889
|
};
|
|
843
890
|
|
|
@@ -846,11 +893,11 @@ var import_update_notifier = __toESM(require("update-notifier"), 1);
|
|
|
846
893
|
var import_dotenv = __toESM(require("dotenv"), 1);
|
|
847
894
|
|
|
848
895
|
// src/migrations/message-channels-to-service-channels.ts
|
|
849
|
-
var
|
|
896
|
+
var import_node_fs6 = __toESM(require("fs"), 1);
|
|
850
897
|
var import_glob2 = require("glob");
|
|
851
|
-
var
|
|
898
|
+
var import_node_os = __toESM(require("os"), 1);
|
|
852
899
|
var import_gray_matter3 = __toESM(require("gray-matter"), 1);
|
|
853
|
-
var
|
|
900
|
+
var import_node_path9 = __toESM(require("path"), 1);
|
|
854
901
|
var DISABLE_CHANNEL_MIGRATION_ENV = "EVENTCATALOG_DISABLE_CHANNEL_MIGRATION";
|
|
855
902
|
var isChannelMigrationDisabled = () => {
|
|
856
903
|
return ["true", "1", "yes"].includes((process.env[DISABLE_CHANNEL_MIGRATION_ENV] ?? "").toLowerCase());
|
|
@@ -859,7 +906,7 @@ var message_channels_to_service_channels_default = async (dir2) => {
|
|
|
859
906
|
if (isChannelMigrationDisabled()) {
|
|
860
907
|
return { status: "skipped", message: `Channel migration disabled by ${DISABLE_CHANNEL_MIGRATION_ENV}` };
|
|
861
908
|
}
|
|
862
|
-
const PROJECT_DIR =
|
|
909
|
+
const PROJECT_DIR = import_node_path9.default.join(dir2 || process.env.PROJECT_DIR);
|
|
863
910
|
const messages = await (0, import_glob2.glob)(
|
|
864
911
|
[
|
|
865
912
|
"**/events/*/index.mdx",
|
|
@@ -882,7 +929,7 @@ var message_channels_to_service_channels_default = async (dir2) => {
|
|
|
882
929
|
cwd: PROJECT_DIR,
|
|
883
930
|
absolute: true,
|
|
884
931
|
nodir: true,
|
|
885
|
-
windowsPathsNoEscape:
|
|
932
|
+
windowsPathsNoEscape: import_node_os.default.platform() == "win32",
|
|
886
933
|
ignore: ["node_modules/**", "**/dist/**", "**/teams", "**/users", "**/package.json", "**/Dockerfile"]
|
|
887
934
|
}
|
|
888
935
|
);
|
|
@@ -899,7 +946,7 @@ var message_channels_to_service_channels_default = async (dir2) => {
|
|
|
899
946
|
}
|
|
900
947
|
);
|
|
901
948
|
const messagesWithChannels = messages.reduce((acc, message2) => {
|
|
902
|
-
const file =
|
|
949
|
+
const file = import_node_fs6.default.readFileSync(message2, "utf8");
|
|
903
950
|
const { data } = (0, import_gray_matter3.default)(file);
|
|
904
951
|
if (data.channels?.length > 0) {
|
|
905
952
|
acc.push({
|
|
@@ -913,7 +960,7 @@ var message_channels_to_service_channels_default = async (dir2) => {
|
|
|
913
960
|
return { status: "success", message: "No messages with channels found in the catalog" };
|
|
914
961
|
}
|
|
915
962
|
const servicesWithChannels = services.reduce((acc, service) => {
|
|
916
|
-
const file =
|
|
963
|
+
const file = import_node_fs6.default.readFileSync(service, "utf8");
|
|
917
964
|
const { data } = (0, import_gray_matter3.default)(file);
|
|
918
965
|
const isSending = data.sends?.some((send) => messagesWithChannels.some((message2) => message2.id === send.id));
|
|
919
966
|
const isReceiving = data.receives?.some(
|
|
@@ -928,7 +975,7 @@ var message_channels_to_service_channels_default = async (dir2) => {
|
|
|
928
975
|
return acc;
|
|
929
976
|
}, []);
|
|
930
977
|
for (const service of servicesWithChannels) {
|
|
931
|
-
const file =
|
|
978
|
+
const file = import_node_fs6.default.readFileSync(service.path, "utf8");
|
|
932
979
|
const { data } = (0, import_gray_matter3.default)(file);
|
|
933
980
|
const messagesTheServiceSendsThatNeedUpdating = data.sends?.filter((send) => messagesWithChannels.some((message2) => message2.id === send.id)) ?? [];
|
|
934
981
|
const messagesTheServiceReceivesThatNeedUpdating = data.receives?.filter((receive) => messagesWithChannels.some((message2) => message2.id === receive.id)) ?? [];
|
|
@@ -948,14 +995,14 @@ var message_channels_to_service_channels_default = async (dir2) => {
|
|
|
948
995
|
...newSends.length > 0 ? { sends: newSends } : {},
|
|
949
996
|
...newReceives.length > 0 ? { receives: newReceives } : {}
|
|
950
997
|
};
|
|
951
|
-
|
|
998
|
+
import_node_fs6.default.writeFileSync(service.path, import_gray_matter3.default.stringify(file, newData));
|
|
952
999
|
}
|
|
953
1000
|
}
|
|
954
1001
|
for (const message2 of messagesWithChannels) {
|
|
955
|
-
const file =
|
|
1002
|
+
const file = import_node_fs6.default.readFileSync(message2.path, "utf8");
|
|
956
1003
|
const parsed = (0, import_gray_matter3.default)(file);
|
|
957
1004
|
const { channels, ...newData } = parsed.data;
|
|
958
|
-
|
|
1005
|
+
import_node_fs6.default.writeFileSync(message2.path, import_gray_matter3.default.stringify(parsed.content, newData));
|
|
959
1006
|
}
|
|
960
1007
|
console.log("\u2714 Channels migrated to new services API");
|
|
961
1008
|
};
|
|
@@ -966,7 +1013,7 @@ var runMigrations = async (dir2) => {
|
|
|
966
1013
|
};
|
|
967
1014
|
|
|
968
1015
|
// src/utils/child-process-signals.ts
|
|
969
|
-
var
|
|
1016
|
+
var import_node_os2 = require("os");
|
|
970
1017
|
var FORWARDED_SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
971
1018
|
var isRunning = (child) => child.exitCode === null && child.signalCode === null;
|
|
972
1019
|
var stopChildWithParent = (child, parent = process) => {
|
|
@@ -985,19 +1032,19 @@ var stopChildWithParent = (child, parent = process) => {
|
|
|
985
1032
|
for (const signal of FORWARDED_SIGNALS) parent.off(signal, onSignal);
|
|
986
1033
|
parent.off("exit", onExit);
|
|
987
1034
|
if (!received) return false;
|
|
988
|
-
parent.exit(128 +
|
|
1035
|
+
parent.exit(128 + import_node_os2.constants.signals[received]);
|
|
989
1036
|
return true;
|
|
990
1037
|
}
|
|
991
1038
|
};
|
|
992
1039
|
};
|
|
993
1040
|
|
|
994
1041
|
// eventcatalog/src/features/fields/field-indexer.ts
|
|
995
|
-
var
|
|
996
|
-
var
|
|
1042
|
+
var import_node_path11 = __toESM(require("path"), 1);
|
|
1043
|
+
var import_node_fs8 = __toESM(require("fs"), 1);
|
|
997
1044
|
|
|
998
1045
|
// eventcatalog/src/features/fields/fields-db.ts
|
|
999
1046
|
var import_sql = __toESM(require("sql.js"), 1);
|
|
1000
|
-
var
|
|
1047
|
+
var import_node_fs7 = __toESM(require("fs"), 1);
|
|
1001
1048
|
var SCHEMA_SQL = `
|
|
1002
1049
|
CREATE TABLE IF NOT EXISTS fields (
|
|
1003
1050
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
@@ -1066,13 +1113,13 @@ var FieldsDatabase = class _FieldsDatabase {
|
|
|
1066
1113
|
this.dbPath = dbPath;
|
|
1067
1114
|
}
|
|
1068
1115
|
static async create(dbPath, options) {
|
|
1069
|
-
if (options?.recreate &&
|
|
1070
|
-
|
|
1116
|
+
if (options?.recreate && import_node_fs7.default.existsSync(dbPath)) {
|
|
1117
|
+
import_node_fs7.default.unlinkSync(dbPath);
|
|
1071
1118
|
}
|
|
1072
1119
|
const SQL = await (0, import_sql.default)();
|
|
1073
1120
|
let db;
|
|
1074
|
-
if (!options?.recreate &&
|
|
1075
|
-
const buffer =
|
|
1121
|
+
if (!options?.recreate && import_node_fs7.default.existsSync(dbPath)) {
|
|
1122
|
+
const buffer = import_node_fs7.default.readFileSync(dbPath);
|
|
1076
1123
|
db = new SQL.Database(buffer);
|
|
1077
1124
|
} else {
|
|
1078
1125
|
db = new SQL.Database();
|
|
@@ -1133,7 +1180,7 @@ var FieldsDatabase = class _FieldsDatabase {
|
|
|
1133
1180
|
save() {
|
|
1134
1181
|
const data = this.db.export();
|
|
1135
1182
|
const buffer = Buffer.from(data);
|
|
1136
|
-
|
|
1183
|
+
import_node_fs7.default.writeFileSync(this.dbPath, buffer);
|
|
1137
1184
|
}
|
|
1138
1185
|
queryFields(params) {
|
|
1139
1186
|
const {
|
|
@@ -1358,22 +1405,22 @@ function getAvroTypeName(type) {
|
|
|
1358
1405
|
function walkAvroRecord(schema, prefix, fields) {
|
|
1359
1406
|
if (!schema.fields || !Array.isArray(schema.fields)) return;
|
|
1360
1407
|
for (const field of schema.fields) {
|
|
1361
|
-
const
|
|
1408
|
+
const path21 = prefix ? `${prefix}.${field.name}` : field.name;
|
|
1362
1409
|
const isOptional = Array.isArray(field.type) && field.type.includes("null");
|
|
1363
1410
|
const typeName = getAvroTypeName(field.type);
|
|
1364
1411
|
fields.push({
|
|
1365
|
-
path:
|
|
1412
|
+
path: path21,
|
|
1366
1413
|
type: typeName,
|
|
1367
1414
|
description: field.doc || "",
|
|
1368
1415
|
required: !isOptional
|
|
1369
1416
|
});
|
|
1370
1417
|
const innerType = Array.isArray(field.type) ? field.type.find((t) => typeof t === "object" && t.type === "record") : typeof field.type === "object" && field.type.type === "record" ? field.type : null;
|
|
1371
1418
|
if (innerType) {
|
|
1372
|
-
walkAvroRecord(innerType,
|
|
1419
|
+
walkAvroRecord(innerType, path21, fields);
|
|
1373
1420
|
}
|
|
1374
1421
|
const arrayType = Array.isArray(field.type) ? field.type.find((t) => typeof t === "object" && t.type === "array") : typeof field.type === "object" && field.type.type === "array" ? field.type : null;
|
|
1375
1422
|
if (arrayType && typeof arrayType.items === "object" && arrayType.items.type === "record") {
|
|
1376
|
-
walkAvroRecord(arrayType.items, `${
|
|
1423
|
+
walkAvroRecord(arrayType.items, `${path21}[]`, fields);
|
|
1377
1424
|
}
|
|
1378
1425
|
}
|
|
1379
1426
|
}
|
|
@@ -1404,32 +1451,32 @@ function walkJsonSchema(node, prefix, requiredList, rootSchema, fields) {
|
|
|
1404
1451
|
}
|
|
1405
1452
|
if (!node.properties) return;
|
|
1406
1453
|
for (const [name, prop] of Object.entries(node.properties)) {
|
|
1407
|
-
const
|
|
1454
|
+
const path21 = prefix ? `${prefix}.${name}` : name;
|
|
1408
1455
|
const isRequired = requiredList.includes(name);
|
|
1409
1456
|
if (prop.$ref) {
|
|
1410
1457
|
const resolved = resolveLocalRef(prop.$ref, rootSchema);
|
|
1411
1458
|
if (resolved) {
|
|
1412
1459
|
const rawRefType = resolved.type || "object";
|
|
1413
1460
|
const type2 = Array.isArray(rawRefType) ? [...rawRefType].sort().join(" | ") : rawRefType;
|
|
1414
|
-
fields.push({ path:
|
|
1461
|
+
fields.push({ path: path21, type: type2, description: resolved.description || "", required: isRequired });
|
|
1415
1462
|
if (resolved.properties) {
|
|
1416
|
-
walkJsonSchema(resolved,
|
|
1463
|
+
walkJsonSchema(resolved, path21, resolved.required || [], rootSchema, fields);
|
|
1417
1464
|
}
|
|
1418
1465
|
} else {
|
|
1419
|
-
fields.push({ path:
|
|
1466
|
+
fields.push({ path: path21, type: "$ref", description: "", required: isRequired });
|
|
1420
1467
|
}
|
|
1421
1468
|
continue;
|
|
1422
1469
|
}
|
|
1423
1470
|
const rawType = prop.type || (prop.enum ? "enum" : prop.$ref ? "$ref" : "object");
|
|
1424
1471
|
const typeList = Array.isArray(rawType) ? rawType : [rawType];
|
|
1425
1472
|
const type = Array.isArray(rawType) ? [...rawType].sort().join(" | ") : rawType;
|
|
1426
|
-
fields.push({ path:
|
|
1473
|
+
fields.push({ path: path21, type, description: prop.description || "", required: isRequired });
|
|
1427
1474
|
if (typeList.includes("object") && prop.properties) {
|
|
1428
|
-
walkJsonSchema(prop,
|
|
1475
|
+
walkJsonSchema(prop, path21, prop.required || [], rootSchema, fields);
|
|
1429
1476
|
}
|
|
1430
1477
|
if (typeList.includes("array") && prop.items) {
|
|
1431
1478
|
if (prop.items.type === "object" && prop.items.properties) {
|
|
1432
|
-
walkJsonSchema(prop.items, `${
|
|
1479
|
+
walkJsonSchema(prop.items, `${path21}[]`, prop.items.required || [], rootSchema, fields);
|
|
1433
1480
|
}
|
|
1434
1481
|
}
|
|
1435
1482
|
}
|
|
@@ -1446,22 +1493,22 @@ function resolveLocalRef(ref, rootSchema) {
|
|
|
1446
1493
|
}
|
|
1447
1494
|
|
|
1448
1495
|
// eventcatalog/integrations/runtime-paths.mjs
|
|
1449
|
-
var
|
|
1496
|
+
var import_node_path10 = __toESM(require("path"), 1);
|
|
1450
1497
|
function getRuntimePaths(projectDirectory, runtimeDirectory) {
|
|
1451
|
-
const project =
|
|
1452
|
-
const cacheDirectory =
|
|
1453
|
-
const runtime = runtimeDirectory ?
|
|
1498
|
+
const project = import_node_path10.default.resolve(projectDirectory);
|
|
1499
|
+
const cacheDirectory = import_node_path10.default.join(project, ".astro");
|
|
1500
|
+
const runtime = runtimeDirectory ? import_node_path10.default.resolve(runtimeDirectory) : import_node_path10.default.join(cacheDirectory, "eventcatalog");
|
|
1454
1501
|
return {
|
|
1455
1502
|
projectDirectory: project,
|
|
1456
1503
|
cacheDirectory,
|
|
1457
1504
|
runtimeDirectory: runtime,
|
|
1458
|
-
fieldsDatabasePath:
|
|
1505
|
+
fieldsDatabasePath: import_node_path10.default.join(runtime, ".eventcatalog", "fields.db")
|
|
1459
1506
|
};
|
|
1460
1507
|
}
|
|
1461
1508
|
|
|
1462
1509
|
// eventcatalog/src/features/fields/field-indexer.ts
|
|
1463
1510
|
function detectFormat(fileName) {
|
|
1464
|
-
const ext =
|
|
1511
|
+
const ext = import_node_path11.default.extname(fileName).toLowerCase();
|
|
1465
1512
|
if (ext === ".proto") return "proto";
|
|
1466
1513
|
if (ext === ".avro" || ext === ".avsc") return "avro";
|
|
1467
1514
|
return "json-schema";
|
|
@@ -1470,9 +1517,9 @@ async function buildFieldsIndex(catalogDir, outputDir) {
|
|
|
1470
1517
|
const sdkModule = await import("@eventcatalog/sdk");
|
|
1471
1518
|
const sdk = sdkModule.default(catalogDir);
|
|
1472
1519
|
const { fieldsDatabasePath: dbPath } = getRuntimePaths(catalogDir, outputDir || catalogDir);
|
|
1473
|
-
const dbDir =
|
|
1474
|
-
if (!
|
|
1475
|
-
|
|
1520
|
+
const dbDir = import_node_path11.default.dirname(dbPath);
|
|
1521
|
+
if (!import_node_fs8.default.existsSync(dbDir)) {
|
|
1522
|
+
import_node_fs8.default.mkdirSync(dbDir, { recursive: true });
|
|
1476
1523
|
}
|
|
1477
1524
|
const db = await FieldsDatabase.create(dbPath, { recreate: true });
|
|
1478
1525
|
const warnings = [];
|
|
@@ -1556,7 +1603,7 @@ async function buildFieldsIndex(catalogDir, outputDir) {
|
|
|
1556
1603
|
|
|
1557
1604
|
// src/search-indexer.ts
|
|
1558
1605
|
var import_promises4 = __toESM(require("fs/promises"), 1);
|
|
1559
|
-
var
|
|
1606
|
+
var import_node_path12 = __toESM(require("path"), 1);
|
|
1560
1607
|
var import_glob3 = require("glob");
|
|
1561
1608
|
var import_gray_matter4 = __toESM(require("gray-matter"), 1);
|
|
1562
1609
|
var RESOURCE_COLLECTIONS = {
|
|
@@ -1620,9 +1667,9 @@ var markdownToSearchText = (content) => {
|
|
|
1620
1667
|
};
|
|
1621
1668
|
var inferDocIdFromFile = (relativePath, frontmatterId) => {
|
|
1622
1669
|
if (frontmatterId) return frontmatterId;
|
|
1623
|
-
const fileName =
|
|
1670
|
+
const fileName = import_node_path12.default.posix.basename(removeExtension(relativePath));
|
|
1624
1671
|
if (fileName.toLowerCase() === "index") {
|
|
1625
|
-
return
|
|
1672
|
+
return import_node_path12.default.posix.basename(import_node_path12.default.posix.dirname(relativePath));
|
|
1626
1673
|
}
|
|
1627
1674
|
return stripNumericPrefix(fileName);
|
|
1628
1675
|
};
|
|
@@ -1640,7 +1687,7 @@ var findResourceSegment = (segments) => {
|
|
|
1640
1687
|
return match;
|
|
1641
1688
|
};
|
|
1642
1689
|
var readResourceFrontmatter = async (projectDir, resourcePath) => {
|
|
1643
|
-
const candidates = [
|
|
1690
|
+
const candidates = [import_node_path12.default.join(projectDir, resourcePath, "index.mdx"), import_node_path12.default.join(projectDir, resourcePath, "index.md")];
|
|
1644
1691
|
for (const candidate of candidates) {
|
|
1645
1692
|
try {
|
|
1646
1693
|
const file = await import_promises4.default.readFile(candidate, "utf8");
|
|
@@ -1665,7 +1712,7 @@ var deriveRecordFromPath = async ({
|
|
|
1665
1712
|
}
|
|
1666
1713
|
if (segments[0] === "docs") {
|
|
1667
1714
|
const customPath = normalizeUrlPath(removeExtension(segments.slice(1).join("/")));
|
|
1668
|
-
const title = data.title || data.label ||
|
|
1715
|
+
const title = data.title || data.label || import_node_path12.default.posix.basename(customPath) || "Custom docs";
|
|
1669
1716
|
return {
|
|
1670
1717
|
url: buildUrl(`/docs/custom/${customPath}`, config),
|
|
1671
1718
|
title,
|
|
@@ -1783,7 +1830,7 @@ var collectSearchRecords = async ({
|
|
|
1783
1830
|
files.map(async (file) => {
|
|
1784
1831
|
const raw = await import_promises4.default.readFile(file, "utf8");
|
|
1785
1832
|
const parsed = (0, import_gray_matter4.default)(raw);
|
|
1786
|
-
const relativePath = normalizePath(
|
|
1833
|
+
const relativePath = normalizePath(import_node_path12.default.relative(projectDir, file));
|
|
1787
1834
|
const baseRecord = await deriveRecordFromPath({
|
|
1788
1835
|
projectDir,
|
|
1789
1836
|
relativePath,
|
|
@@ -1831,7 +1878,7 @@ var getSearchOutputPath = ({
|
|
|
1831
1878
|
if (searchOutputPath) {
|
|
1832
1879
|
return searchOutputPath;
|
|
1833
1880
|
}
|
|
1834
|
-
return
|
|
1881
|
+
return import_node_path12.default.join(outDir, isServer ? "client" : "", "pagefind");
|
|
1835
1882
|
};
|
|
1836
1883
|
var buildSearchIndex = async ({ projectDir, outDir, config, isServer, searchOutputPath }) => {
|
|
1837
1884
|
const records = await collectSearchRecords({ projectDir, config });
|
|
@@ -1885,74 +1932,74 @@ ${errors.join("\n")}`);
|
|
|
1885
1932
|
};
|
|
1886
1933
|
|
|
1887
1934
|
// src/catalog-runtime.ts
|
|
1888
|
-
var
|
|
1889
|
-
var
|
|
1890
|
-
var
|
|
1891
|
-
var require2 = (0,
|
|
1935
|
+
var import_node_fs9 = __toESM(require("fs"), 1);
|
|
1936
|
+
var import_node_path13 = __toESM(require("path"), 1);
|
|
1937
|
+
var import_node_module2 = require("module");
|
|
1938
|
+
var require2 = (0, import_node_module2.createRequire)(importMetaUrl);
|
|
1892
1939
|
var writeIfChanged = (file, content) => {
|
|
1893
|
-
if (
|
|
1894
|
-
|
|
1895
|
-
|
|
1940
|
+
if (import_node_fs9.default.existsSync(file) && import_node_fs9.default.readFileSync(file, "utf8") === content) return;
|
|
1941
|
+
import_node_fs9.default.mkdirSync(import_node_path13.default.dirname(file), { recursive: true });
|
|
1942
|
+
import_node_fs9.default.writeFileSync(file, content);
|
|
1896
1943
|
};
|
|
1897
1944
|
var importPath = (file) => file.replace(/\\/g, "/");
|
|
1898
|
-
var hasLegacyCatalogRuntime = (projectDirectory) =>
|
|
1945
|
+
var hasLegacyCatalogRuntime = (projectDirectory) => import_node_fs9.default.existsSync(import_node_path13.default.join(projectDirectory, ".eventcatalog-core"));
|
|
1899
1946
|
var clearCatalogCache = (projectDirectory) => {
|
|
1900
1947
|
const { cacheDirectory } = getRuntimePaths(projectDirectory);
|
|
1901
|
-
|
|
1948
|
+
import_node_fs9.default.rmSync(cacheDirectory, { recursive: true, force: true });
|
|
1902
1949
|
};
|
|
1903
1950
|
var prepareCatalogRuntime = ({ projectDirectory, catalogDirectory, packageDirectory }) => {
|
|
1904
|
-
const runtime =
|
|
1905
|
-
const source =
|
|
1906
|
-
const project =
|
|
1951
|
+
const runtime = import_node_path13.default.resolve(catalogDirectory);
|
|
1952
|
+
const source = import_node_path13.default.resolve(packageDirectory);
|
|
1953
|
+
const project = import_node_path13.default.resolve(projectDirectory);
|
|
1907
1954
|
if (runtime === source || runtime === project) {
|
|
1908
1955
|
throw new Error("The catalog runtime must be separate from the project and installed application directories.");
|
|
1909
1956
|
}
|
|
1910
|
-
|
|
1957
|
+
import_node_fs9.default.mkdirSync(runtime, { recursive: true });
|
|
1911
1958
|
writeIfChanged(
|
|
1912
|
-
|
|
1913
|
-
`export { collections } from ${JSON.stringify(importPath(
|
|
1959
|
+
import_node_path13.default.join(runtime, "content.config.ts"),
|
|
1960
|
+
`export { collections } from ${JSON.stringify(importPath(import_node_path13.default.join(source, "src/content.config.ts")))};
|
|
1914
1961
|
`
|
|
1915
1962
|
);
|
|
1916
|
-
const packageTsconfig = JSON.parse(
|
|
1963
|
+
const packageTsconfig = JSON.parse(import_node_fs9.default.readFileSync(import_node_path13.default.join(source, "tsconfig.json"), "utf8"));
|
|
1917
1964
|
const paths = Object.fromEntries(
|
|
1918
1965
|
Object.entries(packageTsconfig.compilerOptions.paths).map(([alias, targets]) => [
|
|
1919
1966
|
alias,
|
|
1920
|
-
targets.map((target) => importPath(
|
|
1967
|
+
targets.map((target) => importPath(import_node_path13.default.resolve(source, target)))
|
|
1921
1968
|
])
|
|
1922
1969
|
);
|
|
1923
|
-
paths["@config"] = [importPath(
|
|
1924
|
-
paths["@catalog/styles"] = [importPath(
|
|
1970
|
+
paths["@config"] = [importPath(import_node_path13.default.join(project, "eventcatalog.config.js"))];
|
|
1971
|
+
paths["@catalog/styles"] = [importPath(import_node_path13.default.join(project, "eventcatalog.styles.css"))];
|
|
1925
1972
|
paths["@catalog/components/*"] = [
|
|
1926
|
-
importPath(
|
|
1927
|
-
importPath(
|
|
1973
|
+
importPath(import_node_path13.default.join(project, "components/*")),
|
|
1974
|
+
importPath(import_node_path13.default.join(project, "federated/components/*"))
|
|
1928
1975
|
];
|
|
1929
|
-
paths["@catalog/snippets/*"] = [importPath(
|
|
1976
|
+
paths["@catalog/snippets/*"] = [importPath(import_node_path13.default.join(project, "snippets/*"))];
|
|
1930
1977
|
for (const specifier of ["astro", "astro/zod", "astro/loaders", "astro/runtime/server/index.js"]) {
|
|
1931
1978
|
paths[specifier] = [importPath(require2.resolve(specifier).replace(/\.js$/, ".d.ts"))];
|
|
1932
1979
|
}
|
|
1933
1980
|
writeIfChanged(
|
|
1934
|
-
|
|
1981
|
+
import_node_path13.default.join(runtime, "tsconfig.json"),
|
|
1935
1982
|
JSON.stringify(
|
|
1936
1983
|
{
|
|
1937
|
-
extends: importPath(
|
|
1984
|
+
extends: importPath(import_node_path13.default.join(source, "tsconfig.json")),
|
|
1938
1985
|
compilerOptions: {
|
|
1939
1986
|
baseUrl: ".",
|
|
1940
1987
|
paths,
|
|
1941
1988
|
typeRoots: [
|
|
1942
|
-
importPath(
|
|
1943
|
-
importPath(
|
|
1944
|
-
importPath(
|
|
1945
|
-
importPath(
|
|
1989
|
+
importPath(import_node_path13.default.join(project, "node_modules/@types")),
|
|
1990
|
+
importPath(import_node_path13.default.join(source, "../node_modules/@types")),
|
|
1991
|
+
importPath(import_node_path13.default.join(source, "../node_modules")),
|
|
1992
|
+
importPath(import_node_path13.default.join(project, "node_modules"))
|
|
1946
1993
|
]
|
|
1947
1994
|
},
|
|
1948
1995
|
include: [
|
|
1949
|
-
importPath(
|
|
1996
|
+
importPath(import_node_path13.default.join(project, ".astro/types.d.ts")),
|
|
1950
1997
|
"content.config.ts",
|
|
1951
|
-
importPath(
|
|
1952
|
-
importPath(
|
|
1998
|
+
importPath(import_node_path13.default.join(project, "components/**/*")),
|
|
1999
|
+
importPath(import_node_path13.default.join(source, "src/**/*"))
|
|
1953
2000
|
],
|
|
1954
2001
|
// Keep legacy generated files out of checks on an existing checkout.
|
|
1955
|
-
exclude: (packageTsconfig.exclude ?? []).map((entry) => importPath(
|
|
2002
|
+
exclude: (packageTsconfig.exclude ?? []).map((entry) => importPath(import_node_path13.default.resolve(source, entry)))
|
|
1956
2003
|
},
|
|
1957
2004
|
null,
|
|
1958
2005
|
2
|
|
@@ -2032,8 +2079,8 @@ var createAstroDevLineFilter = () => {
|
|
|
2032
2079
|
};
|
|
2033
2080
|
|
|
2034
2081
|
// src/astro-config-path.ts
|
|
2035
|
-
var
|
|
2036
|
-
var getAstroConfigPath = (projectDirectory, configFile, paths =
|
|
2082
|
+
var import_node_path14 = __toESM(require("path"), 1);
|
|
2083
|
+
var getAstroConfigPath = (projectDirectory, configFile, paths = import_node_path14.default) => {
|
|
2037
2084
|
const relative = paths.relative(projectDirectory, configFile);
|
|
2038
2085
|
const projectRoot = paths.parse(paths.resolve(projectDirectory)).root.toLowerCase();
|
|
2039
2086
|
const configRoot = paths.parse(paths.resolve(configFile)).root.toLowerCase();
|
|
@@ -2048,18 +2095,18 @@ var getAstroConfigPath = (projectDirectory, configFile, paths = import_node_path
|
|
|
2048
2095
|
// src/federation/federate.ts
|
|
2049
2096
|
var import_node_crypto5 = require("crypto");
|
|
2050
2097
|
var import_promises10 = __toESM(require("fs/promises"), 1);
|
|
2051
|
-
var
|
|
2098
|
+
var import_node_path20 = __toESM(require("path"), 1);
|
|
2052
2099
|
var import_sdk3 = __toESM(require("@eventcatalog/sdk"), 1);
|
|
2053
2100
|
|
|
2054
2101
|
// src/federation/content-cache.ts
|
|
2055
2102
|
var import_node_crypto2 = require("crypto");
|
|
2056
2103
|
var import_promises5 = __toESM(require("fs/promises"), 1);
|
|
2057
|
-
var
|
|
2104
|
+
var import_node_path15 = __toESM(require("path"), 1);
|
|
2058
2105
|
var getContentHash = (content) => `sha256:${(0, import_node_crypto2.createHash)("sha256").update(content).digest("hex")}`;
|
|
2059
2106
|
var isContentHash = (key) => /^sha256:[a-f0-9]{64}$/i.test(key);
|
|
2060
2107
|
var createFederationContentCache = (projectDirectory, options = {}) => {
|
|
2061
|
-
const cacheDirectory =
|
|
2062
|
-
const getCachePath = (key) =>
|
|
2108
|
+
const cacheDirectory = import_node_path15.default.join(projectDirectory, ".eventcatalog-cache", "federation", "content");
|
|
2109
|
+
const getCachePath = (key) => import_node_path15.default.join(cacheDirectory, encodeURIComponent(key));
|
|
2063
2110
|
return {
|
|
2064
2111
|
async get(key) {
|
|
2065
2112
|
if (options.read === false || !isContentHash(key)) return void 0;
|
|
@@ -2246,20 +2293,20 @@ var getVisibleFederationDiagnostics = (diagnostics, verbose) => diagnostics.filt
|
|
|
2246
2293
|
|
|
2247
2294
|
// src/federation/output-transaction.ts
|
|
2248
2295
|
var import_promises6 = __toESM(require("fs/promises"), 1);
|
|
2249
|
-
var
|
|
2296
|
+
var import_node_path16 = __toESM(require("path"), 1);
|
|
2250
2297
|
var getSafePublicPath = (publicDirectory, relativePath) => {
|
|
2251
|
-
const normalizedPath =
|
|
2252
|
-
const unsafe = relativePath.length === 0 || relativePath.includes("\0") || relativePath.includes("\\") ||
|
|
2298
|
+
const normalizedPath = import_node_path16.default.posix.normalize(relativePath);
|
|
2299
|
+
const unsafe = relativePath.length === 0 || relativePath.includes("\0") || relativePath.includes("\\") || import_node_path16.default.posix.isAbsolute(relativePath) || /^[a-zA-Z]:\//.test(relativePath) || normalizedPath !== relativePath || normalizedPath === ".." || normalizedPath.startsWith("../");
|
|
2253
2300
|
if (unsafe) return void 0;
|
|
2254
|
-
const destinationPath =
|
|
2255
|
-
const relativeDestinationPath =
|
|
2256
|
-
return relativeDestinationPath !== "" && relativeDestinationPath !== ".." && !relativeDestinationPath.startsWith(`..${
|
|
2301
|
+
const destinationPath = import_node_path16.default.resolve(publicDirectory, relativePath);
|
|
2302
|
+
const relativeDestinationPath = import_node_path16.default.relative(publicDirectory, destinationPath);
|
|
2303
|
+
return relativeDestinationPath !== "" && relativeDestinationPath !== ".." && !relativeDestinationPath.startsWith(`..${import_node_path16.default.sep}`) && !import_node_path16.default.isAbsolute(relativeDestinationPath) ? destinationPath : void 0;
|
|
2257
2304
|
};
|
|
2258
2305
|
var beginFederationOutputTransaction = async (projectDirectory, outDir, relativePublicPaths) => {
|
|
2259
|
-
const transactionDirectory = await import_promises6.default.mkdtemp(
|
|
2260
|
-
const previousOutDir =
|
|
2261
|
-
const publicBackupDirectory =
|
|
2262
|
-
const publicDirectory =
|
|
2306
|
+
const transactionDirectory = await import_promises6.default.mkdtemp(import_node_path16.default.join(projectDirectory, ".eventcatalog-federation-transaction-"));
|
|
2307
|
+
const previousOutDir = import_node_path16.default.join(transactionDirectory, "federated");
|
|
2308
|
+
const publicBackupDirectory = import_node_path16.default.join(transactionDirectory, "public");
|
|
2309
|
+
const publicDirectory = import_node_path16.default.resolve(projectDirectory, "public");
|
|
2263
2310
|
const publicSnapshots = [];
|
|
2264
2311
|
const missingPublicDirectories = /* @__PURE__ */ new Set();
|
|
2265
2312
|
let hadPreviousOutDir = false;
|
|
@@ -2270,8 +2317,8 @@ var beginFederationOutputTransaction = async (projectDirectory, outDir, relative
|
|
|
2270
2317
|
try {
|
|
2271
2318
|
const stat = await import_promises6.default.lstat(destinationPath);
|
|
2272
2319
|
if (!stat.isFile()) continue;
|
|
2273
|
-
const backupPath =
|
|
2274
|
-
await import_promises6.default.mkdir(
|
|
2320
|
+
const backupPath = import_node_path16.default.join(publicBackupDirectory, `${publicSnapshots.length}`);
|
|
2321
|
+
await import_promises6.default.mkdir(import_node_path16.default.dirname(backupPath), { recursive: true });
|
|
2275
2322
|
await import_promises6.default.copyFile(destinationPath, backupPath);
|
|
2276
2323
|
publicSnapshots.push({ backupPath, destinationPath, state: "file" });
|
|
2277
2324
|
} catch (error) {
|
|
@@ -2279,7 +2326,7 @@ var beginFederationOutputTransaction = async (projectDirectory, outDir, relative
|
|
|
2279
2326
|
if (code === "ENOTDIR") continue;
|
|
2280
2327
|
if (code !== "ENOENT") throw error;
|
|
2281
2328
|
publicSnapshots.push({ destinationPath, state: "missing" });
|
|
2282
|
-
let directory =
|
|
2329
|
+
let directory = import_node_path16.default.dirname(destinationPath);
|
|
2283
2330
|
while (directory !== publicDirectory) {
|
|
2284
2331
|
try {
|
|
2285
2332
|
await import_promises6.default.lstat(directory);
|
|
@@ -2289,7 +2336,7 @@ var beginFederationOutputTransaction = async (projectDirectory, outDir, relative
|
|
|
2289
2336
|
if (directoryCode === "ENOTDIR") break;
|
|
2290
2337
|
if (directoryCode !== "ENOENT") throw directoryError;
|
|
2291
2338
|
missingPublicDirectories.add(directory);
|
|
2292
|
-
directory =
|
|
2339
|
+
directory = import_node_path16.default.dirname(directory);
|
|
2293
2340
|
}
|
|
2294
2341
|
}
|
|
2295
2342
|
}
|
|
@@ -2325,7 +2372,7 @@ var beginFederationOutputTransaction = async (projectDirectory, outDir, relative
|
|
|
2325
2372
|
continue;
|
|
2326
2373
|
}
|
|
2327
2374
|
await attempt(async () => {
|
|
2328
|
-
await import_promises6.default.mkdir(
|
|
2375
|
+
await import_promises6.default.mkdir(import_node_path16.default.dirname(snapshot.destinationPath), { recursive: true });
|
|
2329
2376
|
await import_promises6.default.copyFile(snapshot.backupPath, snapshot.destinationPath);
|
|
2330
2377
|
});
|
|
2331
2378
|
}
|
|
@@ -2362,7 +2409,7 @@ var withFederationOutputTransaction = async (projectDirectory, outDir, relativeP
|
|
|
2362
2409
|
// src/federation/public-assets.ts
|
|
2363
2410
|
var import_node_crypto3 = require("crypto");
|
|
2364
2411
|
var import_promises7 = __toESM(require("fs/promises"), 1);
|
|
2365
|
-
var
|
|
2412
|
+
var import_node_path17 = __toESM(require("path"), 1);
|
|
2366
2413
|
var getContentHash2 = (content) => `sha256:${(0, import_node_crypto3.createHash)("sha256").update(content).digest("hex")}`;
|
|
2367
2414
|
var getFileHash = async (filePath) => {
|
|
2368
2415
|
try {
|
|
@@ -2374,13 +2421,13 @@ var getFileHash = async (filePath) => {
|
|
|
2374
2421
|
}
|
|
2375
2422
|
};
|
|
2376
2423
|
var getSafePath = (directory, relativePath) => {
|
|
2377
|
-
const normalizedPath =
|
|
2378
|
-
const unsafe = relativePath.length === 0 || relativePath.includes("\0") || relativePath.includes("\\") ||
|
|
2424
|
+
const normalizedPath = import_node_path17.default.posix.normalize(relativePath);
|
|
2425
|
+
const unsafe = relativePath.length === 0 || relativePath.includes("\0") || relativePath.includes("\\") || import_node_path17.default.posix.isAbsolute(relativePath) || /^[a-zA-Z]:\//.test(relativePath) || normalizedPath !== relativePath || normalizedPath === ".." || normalizedPath.startsWith("../");
|
|
2379
2426
|
if (unsafe) return void 0;
|
|
2380
|
-
const resolvedDirectory =
|
|
2381
|
-
const resolvedPath =
|
|
2382
|
-
const relativeResolvedPath =
|
|
2383
|
-
if (relativeResolvedPath === "" || relativeResolvedPath === ".." || relativeResolvedPath.startsWith(`..${
|
|
2427
|
+
const resolvedDirectory = import_node_path17.default.resolve(directory);
|
|
2428
|
+
const resolvedPath = import_node_path17.default.resolve(resolvedDirectory, relativePath);
|
|
2429
|
+
const relativeResolvedPath = import_node_path17.default.relative(resolvedDirectory, resolvedPath);
|
|
2430
|
+
if (relativeResolvedPath === "" || relativeResolvedPath === ".." || relativeResolvedPath.startsWith(`..${import_node_path17.default.sep}`) || import_node_path17.default.isAbsolute(relativeResolvedPath)) {
|
|
2384
2431
|
return void 0;
|
|
2385
2432
|
}
|
|
2386
2433
|
return resolvedPath;
|
|
@@ -2388,16 +2435,16 @@ var getSafePath = (directory, relativePath) => {
|
|
|
2388
2435
|
var listFiles = async (directory, relativeDirectory = "") => {
|
|
2389
2436
|
let entries;
|
|
2390
2437
|
try {
|
|
2391
|
-
entries = await import_promises7.default.readdir(
|
|
2438
|
+
entries = await import_promises7.default.readdir(import_node_path17.default.join(directory, relativeDirectory), { withFileTypes: true });
|
|
2392
2439
|
} catch (error) {
|
|
2393
2440
|
if (error.code === "ENOENT") return [];
|
|
2394
2441
|
throw error;
|
|
2395
2442
|
}
|
|
2396
2443
|
const files = await Promise.all(
|
|
2397
2444
|
entries.map(async (entry) => {
|
|
2398
|
-
const relativePath =
|
|
2445
|
+
const relativePath = import_node_path17.default.join(relativeDirectory, entry.name);
|
|
2399
2446
|
if (entry.isDirectory()) return listFiles(directory, relativePath);
|
|
2400
|
-
return entry.isFile() ? [relativePath.split(
|
|
2447
|
+
return entry.isFile() ? [relativePath.split(import_node_path17.default.sep).join("/")] : [];
|
|
2401
2448
|
})
|
|
2402
2449
|
);
|
|
2403
2450
|
return files.flat().sort();
|
|
@@ -2412,19 +2459,19 @@ var pathExists = async (filePath) => {
|
|
|
2412
2459
|
}
|
|
2413
2460
|
};
|
|
2414
2461
|
var hasBlockingParent = async (publicDirectory, destinationPath) => {
|
|
2415
|
-
let currentPath =
|
|
2462
|
+
let currentPath = import_node_path17.default.dirname(destinationPath);
|
|
2416
2463
|
while (currentPath !== publicDirectory) {
|
|
2417
2464
|
try {
|
|
2418
2465
|
if (!(await import_promises7.default.lstat(currentPath)).isDirectory()) return true;
|
|
2419
2466
|
} catch (error) {
|
|
2420
2467
|
if (error.code !== "ENOENT") throw error;
|
|
2421
2468
|
}
|
|
2422
|
-
currentPath =
|
|
2469
|
+
currentPath = import_node_path17.default.dirname(currentPath);
|
|
2423
2470
|
}
|
|
2424
2471
|
return false;
|
|
2425
2472
|
};
|
|
2426
2473
|
var pruneEmptyDirectories = async (publicDirectory, filePath) => {
|
|
2427
|
-
let currentPath =
|
|
2474
|
+
let currentPath = import_node_path17.default.dirname(filePath);
|
|
2428
2475
|
while (currentPath !== publicDirectory) {
|
|
2429
2476
|
try {
|
|
2430
2477
|
await import_promises7.default.rmdir(currentPath);
|
|
@@ -2432,7 +2479,7 @@ var pruneEmptyDirectories = async (publicDirectory, filePath) => {
|
|
|
2432
2479
|
if (!["ENOENT", "ENOTEMPTY"].includes(error.code ?? "")) throw error;
|
|
2433
2480
|
if (error.code === "ENOTEMPTY") return;
|
|
2434
2481
|
}
|
|
2435
|
-
currentPath =
|
|
2482
|
+
currentPath = import_node_path17.default.dirname(currentPath);
|
|
2436
2483
|
}
|
|
2437
2484
|
};
|
|
2438
2485
|
var composePublicAssets = async ({
|
|
@@ -2442,8 +2489,8 @@ var composePublicAssets = async ({
|
|
|
2442
2489
|
previousFiles = {},
|
|
2443
2490
|
collisionPaths = /* @__PURE__ */ new Set()
|
|
2444
2491
|
}) => {
|
|
2445
|
-
const publicDirectory =
|
|
2446
|
-
const federatedPublicDirectory =
|
|
2492
|
+
const publicDirectory = import_node_path17.default.resolve(projectDirectory, "public");
|
|
2493
|
+
const federatedPublicDirectory = import_node_path17.default.resolve(federatedDirectory, "public");
|
|
2447
2494
|
const sourceFiles = await listFiles(federatedPublicDirectory);
|
|
2448
2495
|
const sourceFileSet = new Set(sourceFiles);
|
|
2449
2496
|
const managedFiles = /* @__PURE__ */ new Set();
|
|
@@ -2479,7 +2526,7 @@ var composePublicAssets = async ({
|
|
|
2479
2526
|
const asset = publicAssetsByPath.get(relativePath);
|
|
2480
2527
|
if (!asset) throw new Error(`Cannot identify the source of federated public asset "${relativePath}"`);
|
|
2481
2528
|
const content = await import_promises7.default.readFile(sourcePath);
|
|
2482
|
-
await import_promises7.default.mkdir(
|
|
2529
|
+
await import_promises7.default.mkdir(import_node_path17.default.dirname(destinationPath), { recursive: true });
|
|
2483
2530
|
await import_promises7.default.writeFile(destinationPath, content);
|
|
2484
2531
|
files[relativePath] = { source: asset.resolvedFrom.source, hash: getContentHash2(content) };
|
|
2485
2532
|
copied += 1;
|
|
@@ -2492,17 +2539,17 @@ var composePublicAssets = async ({
|
|
|
2492
2539
|
// src/federation/filesystem-source-provider.ts
|
|
2493
2540
|
var import_node_crypto4 = require("crypto");
|
|
2494
2541
|
var import_promises8 = __toESM(require("fs/promises"), 1);
|
|
2495
|
-
var
|
|
2542
|
+
var import_node_path18 = __toESM(require("path"), 1);
|
|
2496
2543
|
var import_sdk = __toESM(require("@eventcatalog/sdk"), 1);
|
|
2497
2544
|
var FILESYSTEM_SOURCE_PREFIX = "file:";
|
|
2498
2545
|
var isWithinDirectory = (directory, target) => {
|
|
2499
|
-
const relativePath =
|
|
2500
|
-
return relativePath === "" || !relativePath.startsWith(`..${
|
|
2546
|
+
const relativePath = import_node_path18.default.relative(directory, target);
|
|
2547
|
+
return relativePath === "" || !relativePath.startsWith(`..${import_node_path18.default.sep}`) && relativePath !== ".." && !import_node_path18.default.isAbsolute(relativePath);
|
|
2501
2548
|
};
|
|
2502
2549
|
var assertPortableRelativePath = (filePath, label, allowRoot = true) => {
|
|
2503
2550
|
const portablePath = filePath.replaceAll("\\", "/");
|
|
2504
|
-
const normalizedPath =
|
|
2505
|
-
const isUnsafe = filePath.includes("\\") || filePath.includes("\0") ||
|
|
2551
|
+
const normalizedPath = import_node_path18.default.posix.normalize(portablePath);
|
|
2552
|
+
const isUnsafe = filePath.includes("\\") || filePath.includes("\0") || import_node_path18.default.posix.isAbsolute(normalizedPath) || /^[a-zA-Z]:\//.test(normalizedPath) || normalizedPath === ".." || normalizedPath.startsWith("../") || !allowRoot && (normalizedPath === "." || normalizedPath === "");
|
|
2506
2553
|
if (isUnsafe) throw new Error(`${label} "${filePath}" escapes its filesystem source`);
|
|
2507
2554
|
return normalizedPath;
|
|
2508
2555
|
};
|
|
@@ -2512,13 +2559,13 @@ var getSourceRoot = (projectDirectory, source) => {
|
|
|
2512
2559
|
}
|
|
2513
2560
|
const locator = source.source.slice(FILESYSTEM_SOURCE_PREFIX.length);
|
|
2514
2561
|
if (!locator.trim()) throw new Error(`Filesystem federation source "${source.id}" requires a path after "file:".`);
|
|
2515
|
-
return
|
|
2562
|
+
return import_node_path18.default.resolve(projectDirectory, locator);
|
|
2516
2563
|
};
|
|
2517
2564
|
var getCatalogDirectory = async (projectDirectory, source) => {
|
|
2518
2565
|
if (source.ref) throw new Error(`Filesystem federation source "${source.id}" does not support "ref".`);
|
|
2519
2566
|
const sourceRoot = getSourceRoot(projectDirectory, source);
|
|
2520
2567
|
const catalogPath = assertPortableRelativePath(source.path ?? ".", "Catalog path");
|
|
2521
|
-
const catalogDirectory =
|
|
2568
|
+
const catalogDirectory = import_node_path18.default.resolve(sourceRoot, ...catalogPath.split("/"));
|
|
2522
2569
|
if (!isWithinDirectory(sourceRoot, catalogDirectory)) {
|
|
2523
2570
|
throw new Error(`Catalog path "${source.path}" escapes source "${source.id}"`);
|
|
2524
2571
|
}
|
|
@@ -2540,7 +2587,7 @@ var getCatalogDirectory = async (projectDirectory, source) => {
|
|
|
2540
2587
|
};
|
|
2541
2588
|
var getArtifactPath = async (catalogDirectory, source, artifactPath) => {
|
|
2542
2589
|
const normalizedPath = assertPortableRelativePath(artifactPath, "Federated artifact path", false);
|
|
2543
|
-
const filePath =
|
|
2590
|
+
const filePath = import_node_path18.default.resolve(catalogDirectory, ...normalizedPath.split("/"));
|
|
2544
2591
|
if (!isWithinDirectory(catalogDirectory, filePath)) {
|
|
2545
2592
|
throw new Error(`Federated artifact path "${artifactPath}" escapes source "${source.id}"`);
|
|
2546
2593
|
}
|
|
@@ -2579,8 +2626,8 @@ var createFileSystemSourceProvider = (projectDirectory) => ({
|
|
|
2579
2626
|
// src/federation/github-source-provider.ts
|
|
2580
2627
|
var import_node_child_process = require("child_process");
|
|
2581
2628
|
var import_promises9 = __toESM(require("fs/promises"), 1);
|
|
2582
|
-
var
|
|
2583
|
-
var
|
|
2629
|
+
var import_node_os3 = __toESM(require("os"), 1);
|
|
2630
|
+
var import_node_path19 = __toESM(require("path"), 1);
|
|
2584
2631
|
var import_node_util = require("util");
|
|
2585
2632
|
var import_sdk2 = __toESM(require("@eventcatalog/sdk"), 1);
|
|
2586
2633
|
var execFileAsync = (0, import_node_util.promisify)(import_node_child_process.execFile);
|
|
@@ -2591,8 +2638,8 @@ var parseGitHubSource = (source) => {
|
|
|
2591
2638
|
};
|
|
2592
2639
|
var assertSafeCatalogPath = (source) => {
|
|
2593
2640
|
const catalogPath = source.path ?? ".";
|
|
2594
|
-
const normalized =
|
|
2595
|
-
if (catalogPath.includes("\\") ||
|
|
2641
|
+
const normalized = import_node_path19.default.posix.normalize(catalogPath.replaceAll("\\", "/"));
|
|
2642
|
+
if (catalogPath.includes("\\") || import_node_path19.default.posix.isAbsolute(normalized) || normalized === ".." || normalized.startsWith("../")) {
|
|
2596
2643
|
throw new Error(`Catalog path "${catalogPath}" escapes source "${source.id}"`);
|
|
2597
2644
|
}
|
|
2598
2645
|
};
|
|
@@ -2635,8 +2682,8 @@ var getGitEnvironment = (token) => {
|
|
|
2635
2682
|
};
|
|
2636
2683
|
var createCheckout = (executeFile, token) => async (source, ref, callback) => {
|
|
2637
2684
|
const { owner, repository } = parseGitHubSource(source);
|
|
2638
|
-
const catalogPath =
|
|
2639
|
-
const directory = await import_promises9.default.mkdtemp(
|
|
2685
|
+
const catalogPath = import_node_path19.default.posix.normalize(source.path ?? ".");
|
|
2686
|
+
const directory = await import_promises9.default.mkdtemp(import_node_path19.default.join(import_node_os3.default.tmpdir(), "eventcatalog-federation-"));
|
|
2640
2687
|
const env = getGitEnvironment(token);
|
|
2641
2688
|
try {
|
|
2642
2689
|
const git = (args) => executeFile("git", args, { cwd: directory, env, encoding: "utf8" });
|
|
@@ -2656,16 +2703,16 @@ var createCheckout = (executeFile, token) => async (source, ref, callback) => {
|
|
|
2656
2703
|
var generateIndex = async (source, ref, checkout, executeFile) => checkout(source, ref, async (directory) => {
|
|
2657
2704
|
const { stdout } = await executeFile("git", ["rev-parse", "HEAD"], { cwd: directory, encoding: "utf8" });
|
|
2658
2705
|
const commit = stdout.trim();
|
|
2659
|
-
const catalogDirectory =
|
|
2660
|
-
const relativeCatalogDirectory =
|
|
2661
|
-
if (relativeCatalogDirectory.startsWith("..") ||
|
|
2706
|
+
const catalogDirectory = import_node_path19.default.resolve(directory, source.path ?? ".");
|
|
2707
|
+
const relativeCatalogDirectory = import_node_path19.default.relative(directory, catalogDirectory);
|
|
2708
|
+
if (relativeCatalogDirectory.startsWith("..") || import_node_path19.default.isAbsolute(relativeCatalogDirectory)) {
|
|
2662
2709
|
throw new Error(`Catalog path "${source.path}" escapes source "${source.id}"`);
|
|
2663
2710
|
}
|
|
2664
2711
|
const index = await (0, import_sdk2.default)(catalogDirectory).buildIndex({ source: source.id, commit });
|
|
2665
2712
|
return { bytes: Buffer.from(JSON.stringify(index)), index, commit, generated: true };
|
|
2666
2713
|
});
|
|
2667
2714
|
var fetchPublishedIndex = async (source, ref, fetcher, token) => {
|
|
2668
|
-
const indexPath =
|
|
2715
|
+
const indexPath = import_node_path19.default.posix.join(source.path ?? ".", "catalog.index.json");
|
|
2669
2716
|
const bytes = await fetchBytes(source, ref, indexPath, fetcher, token);
|
|
2670
2717
|
if (!bytes) return void 0;
|
|
2671
2718
|
const index = (0, import_sdk2.parseIndex)(JSON.parse(bytes.toString("utf8")));
|
|
@@ -2688,7 +2735,7 @@ var createGitHubSourceProvider = (options = {}) => {
|
|
|
2688
2735
|
},
|
|
2689
2736
|
async fetchContent({ source, commit, path: artifactPath }) {
|
|
2690
2737
|
assertSafeCatalogPath(source);
|
|
2691
|
-
const catalogPath =
|
|
2738
|
+
const catalogPath = import_node_path19.default.posix.join(source.path ?? ".", artifactPath);
|
|
2692
2739
|
const content = await fetchBytes(source, commit, catalogPath, fetcher, token);
|
|
2693
2740
|
if (!content) throw new Error(`Federated artifact not found for "${source.id}": ${artifactPath}`);
|
|
2694
2741
|
return content;
|
|
@@ -2799,8 +2846,8 @@ var pathExists2 = async (filePath) => {
|
|
|
2799
2846
|
}
|
|
2800
2847
|
};
|
|
2801
2848
|
var cleanupPreviousFederation = async (projectDirectory, onProgress) => {
|
|
2802
|
-
const outDir =
|
|
2803
|
-
const lockPath =
|
|
2849
|
+
const outDir = import_node_path20.default.join(projectDirectory, "federated");
|
|
2850
|
+
const lockPath = import_node_path20.default.join(projectDirectory, "eventcatalog.lock");
|
|
2804
2851
|
const previousLock = await readLock(lockPath);
|
|
2805
2852
|
const hadFederatedOutput = await pathExists2(outDir);
|
|
2806
2853
|
const hadLock = previousLock !== void 0;
|
|
@@ -2860,8 +2907,8 @@ var federateCatalog = async (projectDirectory, options = {}) => {
|
|
|
2860
2907
|
throw new Error(`Failed to federate source "${source.id}": ${message2}`, { cause: error });
|
|
2861
2908
|
}
|
|
2862
2909
|
}
|
|
2863
|
-
const outDir =
|
|
2864
|
-
const lockPath =
|
|
2910
|
+
const outDir = import_node_path20.default.join(projectDirectory, "federated");
|
|
2911
|
+
const lockPath = import_node_path20.default.join(projectDirectory, "eventcatalog.lock");
|
|
2865
2912
|
const previousLock = await readLock(lockPath);
|
|
2866
2913
|
const resources = resolvedSources.reduce((total, source) => total + source.resolved.index.resources.length, 0);
|
|
2867
2914
|
const remoteIndexes = resolvedSources.map(({ resolved }) => resolved.index);
|
|
@@ -2973,17 +3020,17 @@ Run npm i @eventcatalog/core to update`;
|
|
|
2973
3020
|
};
|
|
2974
3021
|
|
|
2975
3022
|
// src/eventcatalog.ts
|
|
2976
|
-
var currentDir =
|
|
2977
|
-
var astroCli =
|
|
3023
|
+
var currentDir = import_node_path22.default.dirname((0, import_node_url2.fileURLToPath)(importMetaUrl));
|
|
3024
|
+
var astroCli = import_node_path22.default.join(import_node_path22.default.dirname((0, import_node_module3.createRequire)(importMetaUrl).resolve("astro/package.json")), "bin/astro.mjs");
|
|
2978
3025
|
var ASTRO_IN_FOREGROUND = { ASTRO_DEV_BACKGROUND: "1", ASTRO_PREVIEW_BACKGROUND: "1" };
|
|
2979
3026
|
var program = new import_commander.Command().version(VERSION);
|
|
2980
|
-
var dir =
|
|
2981
|
-
var eventCatalogDir =
|
|
2982
|
-
var astroConfigPath = () => getAstroConfigPath(dir, (0,
|
|
3027
|
+
var dir = import_node_path22.default.resolve(process.env.PROJECT_DIR || process.cwd());
|
|
3028
|
+
var eventCatalogDir = import_node_path22.default.resolve((0, import_node_path21.join)(currentDir, "../eventcatalog/"));
|
|
3029
|
+
var astroConfigPath = () => getAstroConfigPath(dir, (0, import_node_path21.join)(eventCatalogDir, "astro.config.mjs"));
|
|
2983
3030
|
var { runtimeDirectory: core } = getRuntimePaths(dir);
|
|
2984
3031
|
var getInstalledEventCatalogVersion = () => {
|
|
2985
3032
|
try {
|
|
2986
|
-
const pkg = import_fs.default.readFileSync((0,
|
|
3033
|
+
const pkg = import_fs.default.readFileSync((0, import_node_path21.join)(dir, "package.json"), "utf8");
|
|
2987
3034
|
const json = JSON.parse(pkg);
|
|
2988
3035
|
return json.dependencies["@eventcatalog/core"];
|
|
2989
3036
|
} catch (error) {
|
|
@@ -3052,12 +3099,12 @@ var startDevPrewarm = ({
|
|
|
3052
3099
|
var buildDevSearchIndex = async ({ config }) => {
|
|
3053
3100
|
const result = await buildSearchIndex({
|
|
3054
3101
|
projectDir: dir,
|
|
3055
|
-
outDir:
|
|
3056
|
-
searchOutputPath:
|
|
3102
|
+
outDir: import_node_path22.default.join(core, "public"),
|
|
3103
|
+
searchOutputPath: import_node_path22.default.join(core, "public", "pagefind"),
|
|
3057
3104
|
config,
|
|
3058
3105
|
isServer: false
|
|
3059
3106
|
});
|
|
3060
|
-
logger.info(`Indexed ${result.records} page(s) into ${
|
|
3107
|
+
logger.info(`Indexed ${result.records} page(s) into ${import_node_path22.default.relative(core, result.outputPath)}`, "search");
|
|
3061
3108
|
};
|
|
3062
3109
|
var warnIfIndexedSearchUsesAuth = async () => {
|
|
3063
3110
|
if (!await isAuthEnabled()) {
|
|
@@ -3239,8 +3286,8 @@ program.command("dev").description("Run development server of EventCatalog").opt
|
|
|
3239
3286
|
logger.info("Setting up EventCatalog...", "eventcatalog");
|
|
3240
3287
|
const isServer = await isOutputServer();
|
|
3241
3288
|
logger.info(isServer ? "EventCatalog is running in Server Mode" : "EventCatalog is running in Static Mode", "config");
|
|
3242
|
-
if (import_fs.default.existsSync(
|
|
3243
|
-
import_dotenv.default.config({ path:
|
|
3289
|
+
if (import_fs.default.existsSync(import_node_path22.default.join(dir, ".env"))) {
|
|
3290
|
+
import_dotenv.default.config({ path: import_node_path22.default.join(dir, ".env") });
|
|
3244
3291
|
}
|
|
3245
3292
|
if (options.debug) {
|
|
3246
3293
|
logger.info("Debug mode enabled", "debug");
|
|
@@ -3318,8 +3365,8 @@ program.command("build").description("Run build of EventCatalog").action(async (
|
|
|
3318
3365
|
logger.info("Building EventCatalog...", "build");
|
|
3319
3366
|
const isServer = await isOutputServer();
|
|
3320
3367
|
logger.info(isServer ? "EventCatalog is running in Server Mode" : "EventCatalog is running in Static Mode", "config");
|
|
3321
|
-
if (import_fs.default.existsSync(
|
|
3322
|
-
import_dotenv.default.config({ path:
|
|
3368
|
+
if (import_fs.default.existsSync(import_node_path22.default.join(dir, ".env"))) {
|
|
3369
|
+
import_dotenv.default.config({ path: import_node_path22.default.join(dir, ".env") });
|
|
3323
3370
|
}
|
|
3324
3371
|
await verifyRequiredFieldsAreInCatalogConfigFile(dir);
|
|
3325
3372
|
const config = await getEventCatalogConfigFile(dir);
|
|
@@ -3356,7 +3403,7 @@ program.command("build").description("Run build of EventCatalog").action(async (
|
|
|
3356
3403
|
});
|
|
3357
3404
|
if (await isIndexedSearchEnabled()) {
|
|
3358
3405
|
await warnIfIndexedSearchUsesAuth();
|
|
3359
|
-
const outDir =
|
|
3406
|
+
const outDir = import_node_path22.default.resolve(dir, await getProjectOutDir());
|
|
3360
3407
|
logger.info("Building indexed search...", "search");
|
|
3361
3408
|
const result = await buildSearchIndex({
|
|
3362
3409
|
projectDir: dir,
|
|
@@ -3364,7 +3411,7 @@ program.command("build").description("Run build of EventCatalog").action(async (
|
|
|
3364
3411
|
config,
|
|
3365
3412
|
isServer
|
|
3366
3413
|
});
|
|
3367
|
-
logger.info(`Indexed ${result.records} page(s) into ${
|
|
3414
|
+
logger.info(`Indexed ${result.records} page(s) into ${import_node_path22.default.relative(dir, result.outputPath)}`, "search");
|
|
3368
3415
|
}
|
|
3369
3416
|
});
|
|
3370
3417
|
var previewCatalog = async ({ command }) => {
|
|
@@ -3395,7 +3442,7 @@ if (start) {
|
|
|
3395
3442
|
}
|
|
3396
3443
|
`;
|
|
3397
3444
|
var startServerCatalog = async () => {
|
|
3398
|
-
const serverEntryPath =
|
|
3445
|
+
const serverEntryPath = import_node_path22.default.join(dir, "dist", "server", "entry.mjs");
|
|
3399
3446
|
const config = await getEventCatalogConfigFile(dir);
|
|
3400
3447
|
const base = (config?.base || "/").replace(/\/$/, "");
|
|
3401
3448
|
await runCommandWithFilteredOutput({
|
|
@@ -3414,20 +3461,21 @@ var startServerCatalog = async () => {
|
|
|
3414
3461
|
program.command("preview").description("Serves the contents of your eventcatalog build directory").action(async (options, command) => {
|
|
3415
3462
|
logger.welcome();
|
|
3416
3463
|
logger.info("Starting preview of your build...", "preview");
|
|
3417
|
-
if (import_fs.default.existsSync(
|
|
3418
|
-
import_dotenv.default.config({ path:
|
|
3464
|
+
if (import_fs.default.existsSync(import_node_path22.default.join(dir, ".env"))) {
|
|
3465
|
+
import_dotenv.default.config({ path: import_node_path22.default.join(dir, ".env") });
|
|
3419
3466
|
}
|
|
3420
3467
|
await previewCatalog({ command });
|
|
3421
3468
|
});
|
|
3422
3469
|
program.command("start").description("Serves the contents of your eventcatalog build directory").action(async (options, command) => {
|
|
3423
3470
|
logger.welcome();
|
|
3424
3471
|
logger.info("Starting preview of your build...", "preview");
|
|
3425
|
-
if (import_fs.default.existsSync(
|
|
3426
|
-
import_dotenv.default.config({ path:
|
|
3472
|
+
if (import_fs.default.existsSync(import_node_path22.default.join(dir, ".env"))) {
|
|
3473
|
+
import_dotenv.default.config({ path: import_node_path22.default.join(dir, ".env") });
|
|
3427
3474
|
}
|
|
3428
3475
|
const isServerOutput = await isOutputServer();
|
|
3429
3476
|
if (isServerOutput) {
|
|
3430
|
-
await getLicenseStatus2(dir);
|
|
3477
|
+
const license = await getLicenseStatus2(dir);
|
|
3478
|
+
void log_build_default(dir, { command: "start", license });
|
|
3431
3479
|
await startServerCatalog();
|
|
3432
3480
|
} else {
|
|
3433
3481
|
await previewCatalog({ command });
|
|
@@ -3436,22 +3484,22 @@ program.command("start").description("Serves the contents of your eventcatalog b
|
|
|
3436
3484
|
program.command("export").description("Export your EventCatalog using the SDK dumpCatalog function").option("--include-markdown", "Include markdown content in the export", false).action(async (options) => {
|
|
3437
3485
|
logger.welcome();
|
|
3438
3486
|
logger.info("Exporting EventCatalog...", "export");
|
|
3439
|
-
if (import_fs.default.existsSync(
|
|
3440
|
-
import_dotenv.default.config({ path:
|
|
3487
|
+
if (import_fs.default.existsSync(import_node_path22.default.join(dir, ".env"))) {
|
|
3488
|
+
import_dotenv.default.config({ path: import_node_path22.default.join(dir, ".env") });
|
|
3441
3489
|
}
|
|
3442
3490
|
const { default: initSDK } = await import("@eventcatalog/sdk");
|
|
3443
3491
|
const sdk = initSDK(dir);
|
|
3444
3492
|
const catalog = await sdk.dumpCatalog({ includeMarkdown: options.includeMarkdown });
|
|
3445
|
-
const exportsDir =
|
|
3493
|
+
const exportsDir = import_node_path22.default.join(dir, "exports");
|
|
3446
3494
|
ensureDir(exportsDir);
|
|
3447
3495
|
const date = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
3448
|
-
const exportFile =
|
|
3496
|
+
const exportFile = import_node_path22.default.join(exportsDir, `catalog-${date}.json`);
|
|
3449
3497
|
import_fs.default.writeFileSync(exportFile, JSON.stringify(catalog, null, 2), "utf-8");
|
|
3450
3498
|
logger.info(`Catalog exported to ${exportFile}`, "export");
|
|
3451
3499
|
});
|
|
3452
3500
|
program.command("generate [siteDir]").description("Start the generator scripts.").action(async () => {
|
|
3453
|
-
if (import_fs.default.existsSync(
|
|
3454
|
-
import_dotenv.default.config({ path:
|
|
3501
|
+
if (import_fs.default.existsSync(import_node_path22.default.join(dir, ".env"))) {
|
|
3502
|
+
import_dotenv.default.config({ path: import_node_path22.default.join(dir, ".env") });
|
|
3455
3503
|
}
|
|
3456
3504
|
await generate(dir);
|
|
3457
3505
|
});
|
|
@@ -3524,7 +3572,7 @@ var reportFederationProgress = (event, verbose = false) => {
|
|
|
3524
3572
|
}
|
|
3525
3573
|
return;
|
|
3526
3574
|
case "hydrating":
|
|
3527
|
-
logger.info(`Hydrating federated content into ${
|
|
3575
|
+
logger.info(`Hydrating federated content into ${import_node_path22.default.relative(dir, event.outDir)}/...`, "federation");
|
|
3528
3576
|
return;
|
|
3529
3577
|
case "hydrate:cache":
|
|
3530
3578
|
if (event.files === 1 || event.files % 25 === 0) {
|
|
@@ -3547,13 +3595,13 @@ var reportFederationProgress = (event, verbose = false) => {
|
|
|
3547
3595
|
`Federation complete: ${event.result.sources} sources, ${event.result.resources} remote resources, ${event.result.hydrate.written} files written (${event.result.hydrate.fetched} downloaded, ${event.result.hydrate.written - event.result.hydrate.fetched} cached)`,
|
|
3548
3596
|
"federation"
|
|
3549
3597
|
);
|
|
3550
|
-
logger.info(`Recorded resolved source state in ${
|
|
3598
|
+
logger.info(`Recorded resolved source state in ${import_node_path22.default.relative(dir, event.result.lockPath)}`, "federation");
|
|
3551
3599
|
}
|
|
3552
3600
|
};
|
|
3553
3601
|
program.command("federate").description("Fetch, resolve, and hydrate the catalogs configured in federation.sources.").option("--no-cache", "Download all federation content and refresh the cache.").option("-v, --verbose", "Show detailed federation diagnostics.").action(async (commandOptions) => {
|
|
3554
3602
|
logger.welcome();
|
|
3555
|
-
if (import_fs.default.existsSync(
|
|
3556
|
-
import_dotenv.default.config({ path:
|
|
3603
|
+
if (import_fs.default.existsSync(import_node_path22.default.join(dir, ".env"))) {
|
|
3604
|
+
import_dotenv.default.config({ path: import_node_path22.default.join(dir, ".env") });
|
|
3557
3605
|
}
|
|
3558
3606
|
logger.info("Starting federation...", "federation");
|
|
3559
3607
|
let cleanedPreviousOutput = false;
|
|
@@ -3574,7 +3622,7 @@ program.addHelpText(
|
|
|
3574
3622
|
Example: npx eventcatalog dev --debug -- --env=production --port=3000
|
|
3575
3623
|
`
|
|
3576
3624
|
);
|
|
3577
|
-
program.parseAsync().then(() => process.exit(
|
|
3625
|
+
program.parseAsync().then(() => process.exit()).catch((err) => {
|
|
3578
3626
|
if (!(err instanceof FederationConflictError) && !(err instanceof FederationDiagnosticError)) console.error(err);
|
|
3579
3627
|
process.exit(1);
|
|
3580
3628
|
});
|