@eventcatalog/core 4.6.2 → 4.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analytics/analytics.cjs +1 -1
- package/dist/analytics/analytics.js +2 -2
- package/dist/analytics/log-build.cjs +1 -1
- package/dist/analytics/log-build.js +3 -3
- package/dist/chunk-352FGP6W.js +123 -0
- package/dist/{chunk-AT3AQ3PK.js → chunk-4BBXOL6K.js} +1 -1
- package/dist/{chunk-MDCIQJRX.js → chunk-54KFOI6Z.js} +3 -3
- package/dist/chunk-5EPNFDT5.js +133 -0
- package/dist/{chunk-U6E25IFA.js → chunk-FZJDCQZE.js} +1 -1
- package/dist/{chunk-LQLAEEOV.js → chunk-LB5VXS6X.js} +1 -1
- package/dist/{chunk-LZDDSWXC.js → chunk-PWY4SP6L.js} +1 -1
- package/dist/chunk-R7Z5ALYI.js +44 -0
- package/dist/chunk-ZR6AH5Z2.js +204 -0
- package/dist/constants.cjs +1 -1
- package/dist/constants.js +1 -1
- package/dist/eventcatalog.cjs +651 -51
- package/dist/eventcatalog.config.d.cts +18 -1
- package/dist/eventcatalog.config.d.ts +18 -1
- package/dist/eventcatalog.js +134 -7
- package/dist/federation/content-cache.cjs +78 -0
- package/dist/federation/content-cache.d.cts +9 -0
- package/dist/federation/content-cache.d.ts +9 -0
- package/dist/federation/content-cache.js +6 -0
- package/dist/federation/federate.cjs +588 -0
- package/dist/federation/federate.d.cts +81 -0
- package/dist/federation/federate.d.ts +81 -0
- package/dist/federation/federate.js +12 -0
- package/dist/federation/github-source-provider.cjs +157 -0
- package/dist/federation/github-source-provider.d.cts +24 -0
- package/dist/federation/github-source-provider.d.ts +24 -0
- package/dist/federation/github-source-provider.js +6 -0
- package/dist/federation/public-assets.cjs +167 -0
- package/dist/federation/public-assets.d.cts +24 -0
- package/dist/federation/public-assets.d.ts +24 -0
- package/dist/federation/public-assets.js +6 -0
- package/dist/federation/types.cjs +18 -0
- package/dist/federation/types.d.cts +19 -0
- package/dist/federation/types.d.ts +19 -0
- package/dist/federation/types.js +0 -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
|
@@ -76,6 +76,21 @@ type VerticalNavigationGroupConfig = {
|
|
|
76
76
|
items?: VerticalNavigationItemConfig[];
|
|
77
77
|
};
|
|
78
78
|
type GeneratorConfig = string | Record<string, unknown> | [string, Record<string, unknown>];
|
|
79
|
+
type FederationSourceConfig = {
|
|
80
|
+
/** Stable source id used by the lockfile and federation graph. */
|
|
81
|
+
id: string;
|
|
82
|
+
/** Source locator, for example github:acme/payments. */
|
|
83
|
+
source: string;
|
|
84
|
+
/** Directory containing the source catalog. @default '.' */
|
|
85
|
+
path?: string;
|
|
86
|
+
/** Branch or tag to federate. @default 'main' */
|
|
87
|
+
ref?: string;
|
|
88
|
+
/** Materialize source files or retain graph references only. @default 'hydrate' */
|
|
89
|
+
mode?: 'hydrate' | 'reference';
|
|
90
|
+
};
|
|
91
|
+
type FederationConfig = {
|
|
92
|
+
sources: FederationSourceConfig[];
|
|
93
|
+
};
|
|
79
94
|
type DirectoryEntry = {
|
|
80
95
|
id: string;
|
|
81
96
|
markdown?: string;
|
|
@@ -383,6 +398,8 @@ interface Config {
|
|
|
383
398
|
integrations?: IntegrationsConfig;
|
|
384
399
|
scalarConfiguration?: ScalarConfiguration;
|
|
385
400
|
generators?: GeneratorConfig[];
|
|
401
|
+
/** Catalogs composed into this catalog by `eventcatalog federate`. */
|
|
402
|
+
federation?: FederationConfig;
|
|
386
403
|
}
|
|
387
404
|
|
|
388
|
-
export type { Config };
|
|
405
|
+
export type { Config, FederationSourceConfig };
|
|
@@ -76,6 +76,21 @@ type VerticalNavigationGroupConfig = {
|
|
|
76
76
|
items?: VerticalNavigationItemConfig[];
|
|
77
77
|
};
|
|
78
78
|
type GeneratorConfig = string | Record<string, unknown> | [string, Record<string, unknown>];
|
|
79
|
+
type FederationSourceConfig = {
|
|
80
|
+
/** Stable source id used by the lockfile and federation graph. */
|
|
81
|
+
id: string;
|
|
82
|
+
/** Source locator, for example github:acme/payments. */
|
|
83
|
+
source: string;
|
|
84
|
+
/** Directory containing the source catalog. @default '.' */
|
|
85
|
+
path?: string;
|
|
86
|
+
/** Branch or tag to federate. @default 'main' */
|
|
87
|
+
ref?: string;
|
|
88
|
+
/** Materialize source files or retain graph references only. @default 'hydrate' */
|
|
89
|
+
mode?: 'hydrate' | 'reference';
|
|
90
|
+
};
|
|
91
|
+
type FederationConfig = {
|
|
92
|
+
sources: FederationSourceConfig[];
|
|
93
|
+
};
|
|
79
94
|
type DirectoryEntry = {
|
|
80
95
|
id: string;
|
|
81
96
|
markdown?: string;
|
|
@@ -383,6 +398,8 @@ interface Config {
|
|
|
383
398
|
integrations?: IntegrationsConfig;
|
|
384
399
|
scalarConfiguration?: ScalarConfiguration;
|
|
385
400
|
generators?: GeneratorConfig[];
|
|
401
|
+
/** Catalogs composed into this catalog by `eventcatalog federate`. */
|
|
402
|
+
federation?: FederationConfig;
|
|
386
403
|
}
|
|
387
404
|
|
|
388
|
-
export type { Config };
|
|
405
|
+
export type { Config, FederationSourceConfig };
|
package/dist/eventcatalog.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
log_build_default
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import
|
|
3
|
+
} from "./chunk-54KFOI6Z.js";
|
|
4
|
+
import {
|
|
5
|
+
FederationConflictError,
|
|
6
|
+
federateCatalog
|
|
7
|
+
} from "./chunk-ZR6AH5Z2.js";
|
|
8
|
+
import "./chunk-R7Z5ALYI.js";
|
|
9
|
+
import "./chunk-352FGP6W.js";
|
|
10
|
+
import "./chunk-5EPNFDT5.js";
|
|
5
11
|
import {
|
|
6
12
|
runMigrations
|
|
7
13
|
} from "./chunk-XUAF2H54.js";
|
|
@@ -14,10 +20,10 @@ import {
|
|
|
14
20
|
} from "./chunk-B7HCX5HM.js";
|
|
15
21
|
import {
|
|
16
22
|
generate
|
|
17
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-4BBXOL6K.js";
|
|
18
24
|
import {
|
|
19
25
|
logger
|
|
20
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-FZJDCQZE.js";
|
|
21
27
|
import {
|
|
22
28
|
resolve_catalog_dependencies_default
|
|
23
29
|
} from "./chunk-LHR4G2UO.js";
|
|
@@ -27,7 +33,8 @@ import {
|
|
|
27
33
|
import {
|
|
28
34
|
watch
|
|
29
35
|
} from "./chunk-CAJUIMDJ.js";
|
|
30
|
-
import "./chunk-
|
|
36
|
+
import "./chunk-PWY4SP6L.js";
|
|
37
|
+
import "./chunk-K2XIENVT.js";
|
|
31
38
|
import {
|
|
32
39
|
createAstroDevLineFilter,
|
|
33
40
|
createAstroLineFilter
|
|
@@ -38,7 +45,7 @@ import {
|
|
|
38
45
|
import "./chunk-W5JQON7Z.js";
|
|
39
46
|
import {
|
|
40
47
|
VERSION
|
|
41
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-LB5VXS6X.js";
|
|
42
49
|
import {
|
|
43
50
|
linkCoreNodeModules,
|
|
44
51
|
resolveInstalledCoreNodeModules
|
|
@@ -1118,6 +1125,126 @@ program.command("generate [siteDir]").description("Start the generator scripts."
|
|
|
1118
1125
|
}
|
|
1119
1126
|
await generate(dir);
|
|
1120
1127
|
});
|
|
1128
|
+
var reportFederationProgress = (event) => {
|
|
1129
|
+
switch (event.type) {
|
|
1130
|
+
case "configured":
|
|
1131
|
+
if (event.sources > 0)
|
|
1132
|
+
logger.info(`Found ${event.sources} configured source${event.sources === 1 ? "" : "s"}`, "federation");
|
|
1133
|
+
return;
|
|
1134
|
+
case "cleanup:complete":
|
|
1135
|
+
logger.success(
|
|
1136
|
+
`No sources configured; removed previous federation output${event.publicFiles > 0 ? ` and ${event.publicFiles} managed public file${event.publicFiles === 1 ? "" : "s"}` : ""}.`,
|
|
1137
|
+
"federation"
|
|
1138
|
+
);
|
|
1139
|
+
return;
|
|
1140
|
+
case "cache:disabled":
|
|
1141
|
+
logger.info("Content cache disabled; all federated files will be downloaded.", "federation");
|
|
1142
|
+
return;
|
|
1143
|
+
case "source:start":
|
|
1144
|
+
logger.info(`[${event.current}/${event.total}] Fetching and indexing ${event.source.id}...`, "federation");
|
|
1145
|
+
return;
|
|
1146
|
+
case "source:complete":
|
|
1147
|
+
logger.success(
|
|
1148
|
+
`[${event.current}/${event.total}] ${event.source.id}: ${event.resources} resources at ${event.commit.slice(0, 7)}${event.generated ? " (index generated)" : " (published index)"}`,
|
|
1149
|
+
"federation"
|
|
1150
|
+
);
|
|
1151
|
+
return;
|
|
1152
|
+
case "local:start":
|
|
1153
|
+
logger.info("Indexing central catalog ownership...", "federation");
|
|
1154
|
+
return;
|
|
1155
|
+
case "local:complete":
|
|
1156
|
+
logger.success(
|
|
1157
|
+
`Central catalog: ${event.resources} local resource${event.resources === 1 ? "" : "s"} found (excluding federated/)`,
|
|
1158
|
+
"federation"
|
|
1159
|
+
);
|
|
1160
|
+
return;
|
|
1161
|
+
case "resolving":
|
|
1162
|
+
logger.info(
|
|
1163
|
+
`Validating ownership across ${event.localResources} local resource${event.localResources === 1 ? "" : "s"} and ${event.resources} remote resource${event.resources === 1 ? "" : "s"}...`,
|
|
1164
|
+
"federation"
|
|
1165
|
+
);
|
|
1166
|
+
return;
|
|
1167
|
+
case "resolved":
|
|
1168
|
+
if (event.graph.conflicts.length > 0) {
|
|
1169
|
+
logger.error(
|
|
1170
|
+
`${event.graph.conflicts.length} ownership conflict${event.graph.conflicts.length === 1 ? "" : "s"} found`,
|
|
1171
|
+
"federation"
|
|
1172
|
+
);
|
|
1173
|
+
for (const conflict of event.graph.conflicts.slice(0, 10)) {
|
|
1174
|
+
logger.error(`${conflict.id}: ${conflict.sources.join(", ")}`, "federation");
|
|
1175
|
+
}
|
|
1176
|
+
if (event.graph.conflicts.length > 10) {
|
|
1177
|
+
logger.error(`...and ${event.graph.conflicts.length - 10} more`, "federation");
|
|
1178
|
+
}
|
|
1179
|
+
return;
|
|
1180
|
+
}
|
|
1181
|
+
logger.success(
|
|
1182
|
+
`Graph resolved: ${event.graph.entities.length} remote resources, ${event.graph.edges.length} relationships`,
|
|
1183
|
+
"federation"
|
|
1184
|
+
);
|
|
1185
|
+
if (event.graph.warnings.length > 0) {
|
|
1186
|
+
logger.warning(
|
|
1187
|
+
`${event.graph.warnings.length} federation warning${event.graph.warnings.length === 1 ? "" : "s"}`,
|
|
1188
|
+
"federation"
|
|
1189
|
+
);
|
|
1190
|
+
}
|
|
1191
|
+
if (event.graph.externals.length > 0) {
|
|
1192
|
+
logger.warning(
|
|
1193
|
+
`${event.graph.externals.length} reference${event.graph.externals.length === 1 ? "" : "s"} remain external`,
|
|
1194
|
+
"federation"
|
|
1195
|
+
);
|
|
1196
|
+
}
|
|
1197
|
+
return;
|
|
1198
|
+
case "hydrating":
|
|
1199
|
+
logger.info(`Hydrating federated content into ${path2.relative(dir, event.outDir)}/...`, "federation");
|
|
1200
|
+
return;
|
|
1201
|
+
case "hydrate:cache":
|
|
1202
|
+
if (event.files === 1 || event.files % 25 === 0) {
|
|
1203
|
+
logger.info(`Reused ${event.files} cached file${event.files === 1 ? "" : "s"}...`, "federation");
|
|
1204
|
+
}
|
|
1205
|
+
return;
|
|
1206
|
+
case "hydrate:file":
|
|
1207
|
+
if (event.files === 1 || event.files % 25 === 0) {
|
|
1208
|
+
logger.info(`Fetched ${event.files} federated file${event.files === 1 ? "" : "s"}...`, "federation");
|
|
1209
|
+
}
|
|
1210
|
+
return;
|
|
1211
|
+
case "public:complete":
|
|
1212
|
+
logger.success(
|
|
1213
|
+
`Public assets: ${event.result.copied} copied, ${event.result.skipped} preserved from the main catalog, ${event.result.removed} stale removed`,
|
|
1214
|
+
"federation"
|
|
1215
|
+
);
|
|
1216
|
+
if (event.result.overwritten > 0) {
|
|
1217
|
+
logger.warning(
|
|
1218
|
+
`${event.result.overwritten} public asset conflict${event.result.overwritten === 1 ? "" : "s"} resolved using the last configured source`,
|
|
1219
|
+
"federation"
|
|
1220
|
+
);
|
|
1221
|
+
}
|
|
1222
|
+
return;
|
|
1223
|
+
case "complete":
|
|
1224
|
+
logger.success(
|
|
1225
|
+
`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)`,
|
|
1226
|
+
"federation"
|
|
1227
|
+
);
|
|
1228
|
+
logger.info(`Pinned source commits in ${path2.relative(dir, event.result.lockPath)}`, "federation");
|
|
1229
|
+
}
|
|
1230
|
+
};
|
|
1231
|
+
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.").action(async (commandOptions) => {
|
|
1232
|
+
logger.welcome();
|
|
1233
|
+
if (fs3.existsSync(path2.join(dir, ".env"))) {
|
|
1234
|
+
dotenv.config({ path: path2.join(dir, ".env") });
|
|
1235
|
+
}
|
|
1236
|
+
logger.info("Starting federation...", "federation");
|
|
1237
|
+
let cleanedPreviousOutput = false;
|
|
1238
|
+
const result = await federateCatalog(dir, {
|
|
1239
|
+
useCache: commandOptions.cache,
|
|
1240
|
+
isFederationEnabled: isEventCatalogScaleEnabled,
|
|
1241
|
+
onProgress: (event) => {
|
|
1242
|
+
if (event.type === "cleanup:complete") cleanedPreviousOutput = true;
|
|
1243
|
+
reportFederationProgress(event);
|
|
1244
|
+
}
|
|
1245
|
+
});
|
|
1246
|
+
if (!result && !cleanedPreviousOutput) logger.warning("No federation sources configured; nothing to do.", "federation");
|
|
1247
|
+
});
|
|
1121
1248
|
program.addHelpText(
|
|
1122
1249
|
"after",
|
|
1123
1250
|
`
|
|
@@ -1127,6 +1254,6 @@ program.addHelpText(
|
|
|
1127
1254
|
`
|
|
1128
1255
|
);
|
|
1129
1256
|
program.parseAsync().then(() => process.exit(0)).catch((err) => {
|
|
1130
|
-
console.error(err);
|
|
1257
|
+
if (!(err instanceof FederationConflictError)) console.error(err);
|
|
1131
1258
|
process.exit(1);
|
|
1132
1259
|
});
|
|
@@ -0,0 +1,78 @@
|
|
|
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/content-cache.ts
|
|
31
|
+
var content_cache_exports = {};
|
|
32
|
+
__export(content_cache_exports, {
|
|
33
|
+
createFederationContentCache: () => createFederationContentCache
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(content_cache_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 getContentHash = (content) => `sha256:${(0, import_node_crypto.createHash)("sha256").update(content).digest("hex")}`;
|
|
40
|
+
var isContentHash = (key) => /^sha256:[a-f0-9]{64}$/i.test(key);
|
|
41
|
+
var createFederationContentCache = (projectDirectory, options = {}) => {
|
|
42
|
+
const cacheDirectory = import_node_path.default.join(projectDirectory, ".eventcatalog-cache", "federation", "content");
|
|
43
|
+
const getCachePath = (key) => import_node_path.default.join(cacheDirectory, encodeURIComponent(key));
|
|
44
|
+
return {
|
|
45
|
+
async get(key) {
|
|
46
|
+
if (options.read === false || !isContentHash(key)) return void 0;
|
|
47
|
+
const cachePath = getCachePath(key);
|
|
48
|
+
try {
|
|
49
|
+
const content = await import_promises.default.readFile(cachePath);
|
|
50
|
+
if (getContentHash(content) !== key) {
|
|
51
|
+
await import_promises.default.rm(cachePath, { force: true });
|
|
52
|
+
return void 0;
|
|
53
|
+
}
|
|
54
|
+
options.onHit?.(key);
|
|
55
|
+
return content;
|
|
56
|
+
} catch (error) {
|
|
57
|
+
if (error.code === "ENOENT") return void 0;
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
async set(key, content) {
|
|
62
|
+
if (!isContentHash(key) || getContentHash(content) !== key) return;
|
|
63
|
+
await import_promises.default.mkdir(cacheDirectory, { recursive: true });
|
|
64
|
+
const cachePath = getCachePath(key);
|
|
65
|
+
const temporaryPath = `${cachePath}.tmp-${process.pid}-${(0, import_node_crypto.randomUUID)()}`;
|
|
66
|
+
try {
|
|
67
|
+
await import_promises.default.writeFile(temporaryPath, content);
|
|
68
|
+
await import_promises.default.rename(temporaryPath, cachePath);
|
|
69
|
+
} finally {
|
|
70
|
+
await import_promises.default.rm(temporaryPath, { force: true });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
76
|
+
0 && (module.exports = {
|
|
77
|
+
createFederationContentCache
|
|
78
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Cache } from '@eventcatalog/sdk';
|
|
2
|
+
|
|
3
|
+
type FederationContentCacheOptions = {
|
|
4
|
+
read?: boolean;
|
|
5
|
+
onHit?: (key: string) => void;
|
|
6
|
+
};
|
|
7
|
+
declare const createFederationContentCache: (projectDirectory: string, options?: FederationContentCacheOptions) => Cache;
|
|
8
|
+
|
|
9
|
+
export { createFederationContentCache };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Cache } from '@eventcatalog/sdk';
|
|
2
|
+
|
|
3
|
+
type FederationContentCacheOptions = {
|
|
4
|
+
read?: boolean;
|
|
5
|
+
onHit?: (key: string) => void;
|
|
6
|
+
};
|
|
7
|
+
declare const createFederationContentCache: (projectDirectory: string, options?: FederationContentCacheOptions) => Cache;
|
|
8
|
+
|
|
9
|
+
export { createFederationContentCache };
|