@eventcatalog/core 4.7.4 → 4.7.6
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/LICENSE +95 -0
- package/README.md +3 -2
- 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-7QTCSRAC.js → chunk-6BBLQLGL.js} +1 -1
- package/dist/chunk-DDALKGTF.js +7 -0
- package/dist/chunk-JJPB6EOZ.js +159 -0
- package/dist/chunk-MLIR3NL4.js +279 -0
- package/dist/{chunk-ZXVQXBTT.js → chunk-MNAPKH63.js} +24 -1
- package/dist/{chunk-TLWM7WRZ.js → chunk-Q534DWPZ.js} +1 -1
- package/dist/{chunk-ZIABX6SP.js → chunk-RZAJNR7O.js} +1 -1
- package/dist/chunk-WRNH5C3U.js +118 -0
- package/dist/{chunk-FDXJIZ74.js → chunk-YXANZO6Y.js} +1 -1
- package/dist/constants.cjs +1 -1
- package/dist/constants.js +1 -1
- package/dist/eventcatalog.cjs +560 -211
- package/dist/eventcatalog.config.d.cts +9 -3
- package/dist/eventcatalog.config.d.ts +9 -3
- package/dist/eventcatalog.js +40 -42
- package/dist/federation/content-cache.d.cts +5 -0
- package/dist/federation/content-cache.d.ts +5 -0
- package/dist/federation/diagnostics.cjs +187 -0
- package/dist/federation/diagnostics.d.cts +28 -0
- package/dist/federation/diagnostics.d.ts +28 -0
- package/dist/federation/diagnostics.js +14 -0
- package/dist/federation/entitlement.cjs +31 -0
- package/dist/federation/entitlement.d.cts +12 -0
- package/dist/federation/entitlement.d.ts +12 -0
- package/dist/federation/entitlement.js +6 -0
- package/dist/federation/federate.cjs +447 -118
- package/dist/federation/federate.d.cts +13 -2
- package/dist/federation/federate.d.ts +13 -2
- package/dist/federation/federate.js +9 -4
- package/dist/federation/filesystem-source-provider.d.cts +5 -0
- package/dist/federation/filesystem-source-provider.d.ts +5 -0
- package/dist/federation/github-source-provider.d.cts +5 -0
- package/dist/federation/github-source-provider.d.ts +5 -0
- package/dist/federation/output-transaction.cjs +152 -0
- package/dist/federation/output-transaction.d.cts +7 -0
- package/dist/federation/output-transaction.d.ts +7 -0
- package/dist/federation/output-transaction.js +6 -0
- package/dist/federation/public-assets.d.cts +5 -0
- package/dist/federation/public-assets.d.ts +5 -0
- package/dist/federation/source-provider.d.cts +5 -0
- package/dist/federation/source-provider.d.ts +5 -0
- package/dist/federation/source-provider.js +2 -2
- package/dist/federation/types.d.cts +5 -0
- package/dist/federation/types.d.ts +5 -0
- package/dist/generate.cjs +24 -1
- package/dist/generate.js +3 -3
- package/dist/utils/cli-logger.cjs +24 -1
- package/dist/utils/cli-logger.d.cts +6 -0
- package/dist/utils/cli-logger.d.ts +6 -0
- package/dist/utils/cli-logger.js +2 -2
- package/package.json +4 -4
- package/dist/chunk-RIUHZZRA.js +0 -204
- package/dist/{chunk-A2RZR3U4.js → chunk-6K7XZAYI.js} +3 -3
|
@@ -85,11 +85,17 @@ type FederationSourceConfig = {
|
|
|
85
85
|
path?: string;
|
|
86
86
|
/** Branch or tag to federate from a GitHub source. Not supported for filesystem sources. @default 'main' */
|
|
87
87
|
ref?: string;
|
|
88
|
-
/** Materialize source files or retain graph references only. @default 'hydrate' */
|
|
89
|
-
mode?: 'hydrate' | 'reference';
|
|
90
88
|
};
|
|
89
|
+
type FederationRuleId = 'federation/duplicate-source' | 'federation/type-collision' | 'federation/pointer-type-mismatch' | 'federation/facet-disagreement' | 'federation/asset-collision' | 'federation/missing-resource' | 'federation/unresolved-version';
|
|
90
|
+
type FederationRuleLevel = 'off' | 'warn' | 'error';
|
|
91
|
+
type FederationRulesConfig = Partial<Record<FederationRuleId, FederationRuleLevel>>;
|
|
91
92
|
type FederationConfig = {
|
|
92
93
|
sources: FederationSourceConfig[];
|
|
94
|
+
/**
|
|
95
|
+
* Override federation validation rule levels. Unconfigured rules keep their defaults.
|
|
96
|
+
* `off` hides the diagnostic, `warn` reports and continues, and `error` stops before hydration.
|
|
97
|
+
*/
|
|
98
|
+
rules?: FederationRulesConfig;
|
|
93
99
|
};
|
|
94
100
|
type DirectoryEntry = {
|
|
95
101
|
id: string;
|
|
@@ -402,4 +408,4 @@ interface Config {
|
|
|
402
408
|
federation?: FederationConfig;
|
|
403
409
|
}
|
|
404
410
|
|
|
405
|
-
export type { Config, FederationSourceConfig };
|
|
411
|
+
export type { Config, FederationRuleId, FederationRuleLevel, FederationRulesConfig, FederationSourceConfig };
|
|
@@ -85,11 +85,17 @@ type FederationSourceConfig = {
|
|
|
85
85
|
path?: string;
|
|
86
86
|
/** Branch or tag to federate from a GitHub source. Not supported for filesystem sources. @default 'main' */
|
|
87
87
|
ref?: string;
|
|
88
|
-
/** Materialize source files or retain graph references only. @default 'hydrate' */
|
|
89
|
-
mode?: 'hydrate' | 'reference';
|
|
90
88
|
};
|
|
89
|
+
type FederationRuleId = 'federation/duplicate-source' | 'federation/type-collision' | 'federation/pointer-type-mismatch' | 'federation/facet-disagreement' | 'federation/asset-collision' | 'federation/missing-resource' | 'federation/unresolved-version';
|
|
90
|
+
type FederationRuleLevel = 'off' | 'warn' | 'error';
|
|
91
|
+
type FederationRulesConfig = Partial<Record<FederationRuleId, FederationRuleLevel>>;
|
|
91
92
|
type FederationConfig = {
|
|
92
93
|
sources: FederationSourceConfig[];
|
|
94
|
+
/**
|
|
95
|
+
* Override federation validation rule levels. Unconfigured rules keep their defaults.
|
|
96
|
+
* `off` hides the diagnostic, `warn` reports and continues, and `error` stops before hydration.
|
|
97
|
+
*/
|
|
98
|
+
rules?: FederationRulesConfig;
|
|
93
99
|
};
|
|
94
100
|
type DirectoryEntry = {
|
|
95
101
|
id: string;
|
|
@@ -402,4 +408,4 @@ interface Config {
|
|
|
402
408
|
federation?: FederationConfig;
|
|
403
409
|
}
|
|
404
410
|
|
|
405
|
-
export type { Config, FederationSourceConfig };
|
|
411
|
+
export type { Config, FederationRuleId, FederationRuleLevel, FederationRulesConfig, FederationSourceConfig };
|
package/dist/eventcatalog.js
CHANGED
|
@@ -4,18 +4,25 @@ import {
|
|
|
4
4
|
import "./chunk-CA4U2JP7.js";
|
|
5
5
|
import {
|
|
6
6
|
log_build_default
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-RZAJNR7O.js";
|
|
8
|
+
import "./chunk-YXANZO6Y.js";
|
|
9
9
|
import "./chunk-K2XIENVT.js";
|
|
10
10
|
import {
|
|
11
11
|
FederationConflictError,
|
|
12
|
+
FederationDiagnosticError,
|
|
12
13
|
federateCatalog
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
14
|
+
} from "./chunk-MLIR3NL4.js";
|
|
15
|
+
import "./chunk-WRNH5C3U.js";
|
|
16
|
+
import "./chunk-5EPNFDT5.js";
|
|
17
|
+
import "./chunk-6K7XZAYI.js";
|
|
18
|
+
import "./chunk-352FGP6W.js";
|
|
15
19
|
import "./chunk-R7Z5ALYI.js";
|
|
20
|
+
import {
|
|
21
|
+
getFederationDiagnosticCounts,
|
|
22
|
+
getVisibleFederationDiagnostics
|
|
23
|
+
} from "./chunk-JJPB6EOZ.js";
|
|
24
|
+
import "./chunk-DDALKGTF.js";
|
|
16
25
|
import "./chunk-SDZQJTJW.js";
|
|
17
|
-
import "./chunk-352FGP6W.js";
|
|
18
|
-
import "./chunk-5EPNFDT5.js";
|
|
19
26
|
import {
|
|
20
27
|
getProjectOutDir,
|
|
21
28
|
isAuthEnabled,
|
|
@@ -24,10 +31,10 @@ import {
|
|
|
24
31
|
} from "./chunk-B7HCX5HM.js";
|
|
25
32
|
import {
|
|
26
33
|
generate
|
|
27
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-6BBLQLGL.js";
|
|
28
35
|
import {
|
|
29
36
|
logger
|
|
30
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-MNAPKH63.js";
|
|
31
38
|
import {
|
|
32
39
|
resolve_catalog_dependencies_default
|
|
33
40
|
} from "./chunk-LHR4G2UO.js";
|
|
@@ -47,7 +54,7 @@ import {
|
|
|
47
54
|
import "./chunk-W5JQON7Z.js";
|
|
48
55
|
import {
|
|
49
56
|
VERSION
|
|
50
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-Q534DWPZ.js";
|
|
51
58
|
import {
|
|
52
59
|
linkCoreNodeModules,
|
|
53
60
|
resolveInstalledCoreNodeModules
|
|
@@ -1128,7 +1135,7 @@ program.command("generate [siteDir]").description("Start the generator scripts."
|
|
|
1128
1135
|
}
|
|
1129
1136
|
await generate(dir);
|
|
1130
1137
|
});
|
|
1131
|
-
var reportFederationProgress = (event) => {
|
|
1138
|
+
var reportFederationProgress = (event, verbose = false) => {
|
|
1132
1139
|
switch (event.type) {
|
|
1133
1140
|
case "configured":
|
|
1134
1141
|
if (event.sources > 0)
|
|
@@ -1168,34 +1175,32 @@ var reportFederationProgress = (event) => {
|
|
|
1168
1175
|
);
|
|
1169
1176
|
return;
|
|
1170
1177
|
case "resolved":
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1178
|
+
const counts = getFederationDiagnosticCounts(event.diagnostics);
|
|
1179
|
+
const showDiagnosticDetails = verbose || counts.errors > 0;
|
|
1180
|
+
if (counts.errors === 0) {
|
|
1181
|
+
logger.success(
|
|
1182
|
+
`Graph resolved: ${event.graph.entities.length} remote resources, ${event.graph.edges.length} relationships`,
|
|
1174
1183
|
"federation"
|
|
1175
1184
|
);
|
|
1176
|
-
for (const conflict of event.graph.conflicts.slice(0, 10)) {
|
|
1177
|
-
logger.error(`${conflict.id}: ${conflict.sources.join(", ")}`, "federation");
|
|
1178
|
-
}
|
|
1179
|
-
if (event.graph.conflicts.length > 10) {
|
|
1180
|
-
logger.error(`...and ${event.graph.conflicts.length - 10} more`, "federation");
|
|
1181
|
-
}
|
|
1182
|
-
return;
|
|
1183
1185
|
}
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1186
|
+
if (counts.errors + counts.warnings === 0) return;
|
|
1187
|
+
if (showDiagnosticDetails) {
|
|
1188
|
+
const diagnostics = getVisibleFederationDiagnostics(event.diagnostics, verbose);
|
|
1189
|
+
logger.info("Federation diagnostics", "federation");
|
|
1190
|
+
logger.line();
|
|
1191
|
+
for (const diagnostic of diagnostics) {
|
|
1192
|
+
logger.diagnostic(diagnostic.severity, diagnostic.message, diagnostic.rule, diagnostic.attributes);
|
|
1193
|
+
logger.line();
|
|
1194
|
+
}
|
|
1195
|
+
logger.diagnosticSummary(counts.errors, counts.warnings);
|
|
1196
|
+
} else {
|
|
1189
1197
|
logger.warning(
|
|
1190
|
-
`${
|
|
1198
|
+
`${counts.warnings} problem${counts.warnings === 1 ? "" : "s"} (0 errors, ${counts.warnings} warning${counts.warnings === 1 ? "" : "s"})`,
|
|
1191
1199
|
"federation"
|
|
1192
1200
|
);
|
|
1193
1201
|
}
|
|
1194
|
-
if (
|
|
1195
|
-
logger.warning
|
|
1196
|
-
`${event.graph.externals.length} reference${event.graph.externals.length === 1 ? "" : "s"} remain external`,
|
|
1197
|
-
"federation"
|
|
1198
|
-
);
|
|
1202
|
+
if (!verbose && counts.warnings > 0) {
|
|
1203
|
+
logger.info("Run with --verbose to see warning details.", "federation");
|
|
1199
1204
|
}
|
|
1200
1205
|
return;
|
|
1201
1206
|
case "hydrating":
|
|
@@ -1216,22 +1221,16 @@ var reportFederationProgress = (event) => {
|
|
|
1216
1221
|
`Public assets: ${event.result.copied} copied, ${event.result.skipped} preserved from the main catalog, ${event.result.removed} stale removed`,
|
|
1217
1222
|
"federation"
|
|
1218
1223
|
);
|
|
1219
|
-
if (event.result.overwritten > 0) {
|
|
1220
|
-
logger.warning(
|
|
1221
|
-
`${event.result.overwritten} public asset conflict${event.result.overwritten === 1 ? "" : "s"} resolved using the last configured source`,
|
|
1222
|
-
"federation"
|
|
1223
|
-
);
|
|
1224
|
-
}
|
|
1225
1224
|
return;
|
|
1226
1225
|
case "complete":
|
|
1227
1226
|
logger.success(
|
|
1228
1227
|
`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)`,
|
|
1229
1228
|
"federation"
|
|
1230
1229
|
);
|
|
1231
|
-
logger.info(`
|
|
1230
|
+
logger.info(`Recorded resolved source state in ${path2.relative(dir, event.result.lockPath)}`, "federation");
|
|
1232
1231
|
}
|
|
1233
1232
|
};
|
|
1234
|
-
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) => {
|
|
1233
|
+
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) => {
|
|
1235
1234
|
logger.welcome();
|
|
1236
1235
|
if (fs3.existsSync(path2.join(dir, ".env"))) {
|
|
1237
1236
|
dotenv.config({ path: path2.join(dir, ".env") });
|
|
@@ -1240,10 +1239,9 @@ program.command("federate").description("Fetch, resolve, and hydrate the catalog
|
|
|
1240
1239
|
let cleanedPreviousOutput = false;
|
|
1241
1240
|
const result = await federateCatalog(dir, {
|
|
1242
1241
|
useCache: commandOptions.cache,
|
|
1243
|
-
isFederationEnabled: isEventCatalogScaleEnabled,
|
|
1244
1242
|
onProgress: (event) => {
|
|
1245
1243
|
if (event.type === "cleanup:complete") cleanedPreviousOutput = true;
|
|
1246
|
-
reportFederationProgress(event);
|
|
1244
|
+
reportFederationProgress(event, commandOptions.verbose);
|
|
1247
1245
|
}
|
|
1248
1246
|
});
|
|
1249
1247
|
if (!result && !cleanedPreviousOutput) logger.warning("No federation sources configured; nothing to do.", "federation");
|
|
@@ -1257,6 +1255,6 @@ program.addHelpText(
|
|
|
1257
1255
|
`
|
|
1258
1256
|
);
|
|
1259
1257
|
program.parseAsync().then(() => process.exit(0)).catch((err) => {
|
|
1260
|
-
if (!(err instanceof FederationConflictError)) console.error(err);
|
|
1258
|
+
if (!(err instanceof FederationConflictError) && !(err instanceof FederationDiagnosticError)) console.error(err);
|
|
1261
1259
|
process.exit(1);
|
|
1262
1260
|
});
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/federation/diagnostics.ts
|
|
21
|
+
var diagnostics_exports = {};
|
|
22
|
+
__export(diagnostics_exports, {
|
|
23
|
+
federationRuleDefaults: () => federationRuleDefaults,
|
|
24
|
+
getFederationDiagnosticCounts: () => getFederationDiagnosticCounts,
|
|
25
|
+
getFederationDiagnostics: () => getFederationDiagnostics,
|
|
26
|
+
getVisibleFederationDiagnostics: () => getVisibleFederationDiagnostics,
|
|
27
|
+
resolveFederationRules: () => resolveFederationRules
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(diagnostics_exports);
|
|
30
|
+
var federationRuleDefaults = {
|
|
31
|
+
"federation/duplicate-source": "error",
|
|
32
|
+
"federation/type-collision": "error",
|
|
33
|
+
"federation/pointer-type-mismatch": "error",
|
|
34
|
+
"federation/facet-disagreement": "error",
|
|
35
|
+
"federation/asset-collision": "warn",
|
|
36
|
+
"federation/missing-resource": "warn",
|
|
37
|
+
"federation/unresolved-version": "warn"
|
|
38
|
+
};
|
|
39
|
+
var resolveFederationRules = (rules = {}) => {
|
|
40
|
+
for (const [rule, level] of Object.entries(rules)) {
|
|
41
|
+
if (!Object.hasOwn(federationRuleDefaults, rule)) throw new Error(`Unknown federation rule "${rule}".`);
|
|
42
|
+
if (level !== "off" && level !== "warn" && level !== "error") {
|
|
43
|
+
throw new Error(`Invalid level "${String(level)}" for federation rule "${rule}". Expected off, warn, or error.`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return { ...federationRuleDefaults, ...rules };
|
|
47
|
+
};
|
|
48
|
+
var getExternalResource = (external) => `${external.id}${external.version === void 0 ? "" : `@${external.version}`}`;
|
|
49
|
+
var getVersionedResource = (id, version) => `${id}${version == null ? "" : `@${version}`}`;
|
|
50
|
+
var getDocumentedResourceType = (type) => {
|
|
51
|
+
const usesAn = type === "adr" || type === "agent" || type === "entity" || type === "event";
|
|
52
|
+
return `documented as ${usesAn ? "an" : "a"} ${type}`;
|
|
53
|
+
};
|
|
54
|
+
var getConflictDiagnostic = (conflict, graph) => {
|
|
55
|
+
const catalogs = { label: "catalogs", value: conflict.sources.join(", ") };
|
|
56
|
+
switch (conflict.kind) {
|
|
57
|
+
case "duplicate-source":
|
|
58
|
+
return {
|
|
59
|
+
severity: "error",
|
|
60
|
+
message: "Resource has multiple owners",
|
|
61
|
+
rule: "federation/duplicate-source",
|
|
62
|
+
attributes: [
|
|
63
|
+
{ label: "resource", value: conflict.id },
|
|
64
|
+
catalogs,
|
|
65
|
+
{ label: "resolution", value: "assign a single owning catalog" }
|
|
66
|
+
]
|
|
67
|
+
};
|
|
68
|
+
case "type-collision": {
|
|
69
|
+
const types = [
|
|
70
|
+
...new Map(
|
|
71
|
+
graph.entities.filter((entity) => entity.id === conflict.id).map(
|
|
72
|
+
(entity) => [
|
|
73
|
+
`${entity.resolvedFrom.source}:${entity.type}`,
|
|
74
|
+
{ label: entity.resolvedFrom.source, value: getDocumentedResourceType(entity.type) }
|
|
75
|
+
]
|
|
76
|
+
)
|
|
77
|
+
).values()
|
|
78
|
+
];
|
|
79
|
+
return {
|
|
80
|
+
severity: "error",
|
|
81
|
+
message: "Resource ID has conflicting types",
|
|
82
|
+
rule: "federation/type-collision",
|
|
83
|
+
attributes: [{ label: "resource", value: conflict.id }, ...types.length > 0 ? types : [catalogs]]
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
case "pointer-type-mismatch": {
|
|
87
|
+
const typeMismatch = /^Expected (.+) but found (.+)$/.exec(conflict.detail ?? "");
|
|
88
|
+
return {
|
|
89
|
+
severity: "error",
|
|
90
|
+
message: "Reference type does not match resource",
|
|
91
|
+
rule: "federation/pointer-type-mismatch",
|
|
92
|
+
attributes: [
|
|
93
|
+
{ label: "resource", value: conflict.id },
|
|
94
|
+
...typeMismatch ? [
|
|
95
|
+
{ label: "expected type", value: typeMismatch[1] },
|
|
96
|
+
{ label: "actual type", value: typeMismatch[2] }
|
|
97
|
+
] : conflict.detail ? [{ label: "detail", value: conflict.detail }] : [],
|
|
98
|
+
catalogs
|
|
99
|
+
]
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
case "facet-disagreement":
|
|
103
|
+
return {
|
|
104
|
+
severity: "error",
|
|
105
|
+
message: "Catalogs disagree about this resource",
|
|
106
|
+
rule: "federation/facet-disagreement",
|
|
107
|
+
attributes: [
|
|
108
|
+
{ label: "resource", value: conflict.id },
|
|
109
|
+
...conflict.detail ? [{ label: "detail", value: conflict.detail }] : [],
|
|
110
|
+
catalogs
|
|
111
|
+
]
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
var getFederationDiagnostics = (graph, rules = {}) => {
|
|
116
|
+
const resolvedRules = resolveFederationRules(rules);
|
|
117
|
+
const diagnostics = graph.conflicts.map((conflict) => getConflictDiagnostic(conflict, graph));
|
|
118
|
+
for (const external of graph.externals) {
|
|
119
|
+
const resource = getExternalResource(external);
|
|
120
|
+
for (const referencedBy of external.referencedBy) {
|
|
121
|
+
const referrer = graph.entities.find((entity) => entity.id === referencedBy);
|
|
122
|
+
diagnostics.push({
|
|
123
|
+
severity: "warning",
|
|
124
|
+
message: "Referenced EventCatalog resource does not exist",
|
|
125
|
+
rule: "federation/missing-resource",
|
|
126
|
+
attributes: [
|
|
127
|
+
{ label: "source catalog", value: referrer?.resolvedFrom.source ?? "unknown" },
|
|
128
|
+
{ label: "referenced by", value: referencedBy },
|
|
129
|
+
{ label: "missing resource", value: resource }
|
|
130
|
+
]
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
for (const edge of graph.edges.filter((edge2) => edge2.status === "unresolved")) {
|
|
135
|
+
const availableVersions = [
|
|
136
|
+
...new Set(graph.entities.filter((entity) => entity.id === edge.to).map((entity) => entity.version ?? "unversioned"))
|
|
137
|
+
].sort((left, right) => left.localeCompare(right, void 0, { numeric: true }));
|
|
138
|
+
diagnostics.push({
|
|
139
|
+
severity: "warning",
|
|
140
|
+
message: "Referenced EventCatalog resource version does not exist",
|
|
141
|
+
rule: "federation/unresolved-version",
|
|
142
|
+
attributes: [
|
|
143
|
+
{ label: "source catalog", value: edge.fromResolvedFrom.source },
|
|
144
|
+
{ label: "referenced by", value: getVersionedResource(edge.from, edge.fromVersion) },
|
|
145
|
+
{ label: "resource", value: edge.to },
|
|
146
|
+
{ label: "requested version", value: edge.pointer ?? "unspecified" },
|
|
147
|
+
{ label: "available versions", value: availableVersions.join(", ") }
|
|
148
|
+
]
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
for (const warning of graph.warnings) {
|
|
152
|
+
diagnostics.push({
|
|
153
|
+
severity: "warning",
|
|
154
|
+
message: "Asset collision",
|
|
155
|
+
rule: "federation/asset-collision",
|
|
156
|
+
attributes: [
|
|
157
|
+
{ label: "asset", value: warning.path },
|
|
158
|
+
{ label: "sources", value: warning.sources.join(", ") },
|
|
159
|
+
{ label: "winner", value: warning.winner },
|
|
160
|
+
{ label: "resolution", value: "last configured source wins" }
|
|
161
|
+
]
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
return diagnostics.flatMap((diagnostic) => {
|
|
165
|
+
const level = resolvedRules[diagnostic.rule];
|
|
166
|
+
if (level === "off") return [];
|
|
167
|
+
return [{ ...diagnostic, severity: level === "error" ? "error" : "warning" }];
|
|
168
|
+
}).sort(
|
|
169
|
+
(left, right) => (left.severity === right.severity ? 0 : left.severity === "error" ? -1 : 1) || left.rule.localeCompare(right.rule) || (left.attributes[0]?.value ?? "").localeCompare(right.attributes[0]?.value ?? "")
|
|
170
|
+
);
|
|
171
|
+
};
|
|
172
|
+
var getFederationDiagnosticCounts = (diagnostics) => diagnostics.reduce(
|
|
173
|
+
(counts, diagnostic) => ({
|
|
174
|
+
errors: counts.errors + (diagnostic.severity === "error" ? 1 : 0),
|
|
175
|
+
warnings: counts.warnings + (diagnostic.severity === "warning" ? 1 : 0)
|
|
176
|
+
}),
|
|
177
|
+
{ errors: 0, warnings: 0 }
|
|
178
|
+
);
|
|
179
|
+
var getVisibleFederationDiagnostics = (diagnostics, verbose) => diagnostics.filter((diagnostic) => verbose || diagnostic.severity === "error");
|
|
180
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
181
|
+
0 && (module.exports = {
|
|
182
|
+
federationRuleDefaults,
|
|
183
|
+
getFederationDiagnosticCounts,
|
|
184
|
+
getFederationDiagnostics,
|
|
185
|
+
getVisibleFederationDiagnostics,
|
|
186
|
+
resolveFederationRules
|
|
187
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ResolvedGraph } from '@eventcatalog/sdk';
|
|
2
|
+
import { FederationRuleId, FederationRuleLevel, FederationRulesConfig } from '../eventcatalog.config.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Licensed under the EventCatalog Commercial License.
|
|
6
|
+
* See /packages/core/src/federation/LICENSE
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
type FederationDiagnostic = {
|
|
10
|
+
severity: 'error' | 'warning';
|
|
11
|
+
message: string;
|
|
12
|
+
rule: FederationRuleId;
|
|
13
|
+
attributes: {
|
|
14
|
+
label: string;
|
|
15
|
+
value: string;
|
|
16
|
+
}[];
|
|
17
|
+
};
|
|
18
|
+
declare const federationRuleDefaults: Record<FederationRuleId, FederationRuleLevel>;
|
|
19
|
+
type ResolvedFederationRules = Record<FederationRuleId, FederationRuleLevel>;
|
|
20
|
+
declare const resolveFederationRules: (rules?: FederationRulesConfig) => ResolvedFederationRules;
|
|
21
|
+
declare const getFederationDiagnostics: (graph: ResolvedGraph, rules?: FederationRulesConfig) => FederationDiagnostic[];
|
|
22
|
+
declare const getFederationDiagnosticCounts: (diagnostics: FederationDiagnostic[]) => {
|
|
23
|
+
errors: number;
|
|
24
|
+
warnings: number;
|
|
25
|
+
};
|
|
26
|
+
declare const getVisibleFederationDiagnostics: (diagnostics: FederationDiagnostic[], verbose: boolean) => FederationDiagnostic[];
|
|
27
|
+
|
|
28
|
+
export { type FederationDiagnostic, type ResolvedFederationRules, federationRuleDefaults, getFederationDiagnosticCounts, getFederationDiagnostics, getVisibleFederationDiagnostics, resolveFederationRules };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ResolvedGraph } from '@eventcatalog/sdk';
|
|
2
|
+
import { FederationRuleId, FederationRuleLevel, FederationRulesConfig } from '../eventcatalog.config.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Licensed under the EventCatalog Commercial License.
|
|
6
|
+
* See /packages/core/src/federation/LICENSE
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
type FederationDiagnostic = {
|
|
10
|
+
severity: 'error' | 'warning';
|
|
11
|
+
message: string;
|
|
12
|
+
rule: FederationRuleId;
|
|
13
|
+
attributes: {
|
|
14
|
+
label: string;
|
|
15
|
+
value: string;
|
|
16
|
+
}[];
|
|
17
|
+
};
|
|
18
|
+
declare const federationRuleDefaults: Record<FederationRuleId, FederationRuleLevel>;
|
|
19
|
+
type ResolvedFederationRules = Record<FederationRuleId, FederationRuleLevel>;
|
|
20
|
+
declare const resolveFederationRules: (rules?: FederationRulesConfig) => ResolvedFederationRules;
|
|
21
|
+
declare const getFederationDiagnostics: (graph: ResolvedGraph, rules?: FederationRulesConfig) => FederationDiagnostic[];
|
|
22
|
+
declare const getFederationDiagnosticCounts: (diagnostics: FederationDiagnostic[]) => {
|
|
23
|
+
errors: number;
|
|
24
|
+
warnings: number;
|
|
25
|
+
};
|
|
26
|
+
declare const getVisibleFederationDiagnostics: (diagnostics: FederationDiagnostic[], verbose: boolean) => FederationDiagnostic[];
|
|
27
|
+
|
|
28
|
+
export { type FederationDiagnostic, type ResolvedFederationRules, federationRuleDefaults, getFederationDiagnosticCounts, getFederationDiagnostics, getVisibleFederationDiagnostics, resolveFederationRules };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
federationRuleDefaults,
|
|
3
|
+
getFederationDiagnosticCounts,
|
|
4
|
+
getFederationDiagnostics,
|
|
5
|
+
getVisibleFederationDiagnostics,
|
|
6
|
+
resolveFederationRules
|
|
7
|
+
} from "../chunk-JJPB6EOZ.js";
|
|
8
|
+
export {
|
|
9
|
+
federationRuleDefaults,
|
|
10
|
+
getFederationDiagnosticCounts,
|
|
11
|
+
getFederationDiagnostics,
|
|
12
|
+
getVisibleFederationDiagnostics,
|
|
13
|
+
resolveFederationRules
|
|
14
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/federation/entitlement.ts
|
|
21
|
+
var entitlement_exports = {};
|
|
22
|
+
__export(entitlement_exports, {
|
|
23
|
+
isFederationEnabled: () => isFederationEnabled
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(entitlement_exports);
|
|
26
|
+
var import_license = require("@eventcatalog/license");
|
|
27
|
+
var isFederationEnabled = () => (0, import_license.isEventCatalogScaleEnabled)();
|
|
28
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
29
|
+
0 && (module.exports = {
|
|
30
|
+
isFederationEnabled
|
|
31
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Licensed under the EventCatalog Commercial License.
|
|
3
|
+
* See /packages/core/src/federation/LICENSE
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Federation is currently enabled through the Scale entitlement. Keep callers
|
|
7
|
+
* plan-agnostic so this can move to the Enterprise offline entitlement without
|
|
8
|
+
* changing the federation workflow.
|
|
9
|
+
*/
|
|
10
|
+
declare const isFederationEnabled: () => Promise<boolean>;
|
|
11
|
+
|
|
12
|
+
export { isFederationEnabled };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Licensed under the EventCatalog Commercial License.
|
|
3
|
+
* See /packages/core/src/federation/LICENSE
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Federation is currently enabled through the Scale entitlement. Keep callers
|
|
7
|
+
* plan-agnostic so this can move to the Enterprise offline entitlement without
|
|
8
|
+
* changing the federation workflow.
|
|
9
|
+
*/
|
|
10
|
+
declare const isFederationEnabled: () => Promise<boolean>;
|
|
11
|
+
|
|
12
|
+
export { isFederationEnabled };
|