@eventcatalog/core 5.1.0 → 5.2.0

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.
Files changed (34) hide show
  1. package/dist/analytics/analytics.cjs +1 -1
  2. package/dist/analytics/analytics.js +2 -2
  3. package/dist/analytics/log-build.cjs +1 -1
  4. package/dist/analytics/log-build.js +3 -3
  5. package/dist/architecture-export.cjs +34 -2
  6. package/dist/architecture-export.d.cts +25 -1
  7. package/dist/architecture-export.d.ts +25 -1
  8. package/dist/architecture-export.js +11 -3
  9. package/dist/{chunk-FHZXZWCY.js → chunk-66OL4B7U.js} +1 -1
  10. package/dist/chunk-IR5MKGKS.js +60 -0
  11. package/dist/{chunk-OT57IOWN.js → chunk-N2LLD5TR.js} +1 -1
  12. package/dist/{chunk-TBXLUIJD.js → chunk-NBYKF4Z4.js} +1 -1
  13. package/dist/{chunk-G3CHTDAE.js → chunk-RNYFUWJI.js} +1 -1
  14. package/dist/{chunk-WBUSFEBH.js → chunk-XI5HQWM2.js} +1 -1
  15. package/dist/constants.cjs +1 -1
  16. package/dist/constants.js +1 -1
  17. package/dist/docs/api/02-config.md +51 -0
  18. package/dist/docs/development/bring-your-own-documentation/_category_.json +1 -1
  19. package/dist/docs/development/customization/08-custom-properties.md +48 -1
  20. package/dist/docs/development/export/01-introduction.md +90 -0
  21. package/dist/docs/development/export/02-architecture-reference.md +74 -0
  22. package/dist/docs/development/export/03-custom-exports.md +257 -0
  23. package/dist/docs/development/export/04-reference.md +383 -0
  24. package/dist/docs/development/export/_category_.json +12 -0
  25. package/dist/eventcatalog.cjs +64 -1
  26. package/dist/eventcatalog.config.d.cts +28 -0
  27. package/dist/eventcatalog.config.d.ts +28 -0
  28. package/dist/eventcatalog.js +47 -7
  29. package/dist/generate.cjs +1 -1
  30. package/dist/generate.js +3 -3
  31. package/dist/utils/cli-logger.cjs +1 -1
  32. package/dist/utils/cli-logger.js +2 -2
  33. package/package.json +4 -4
  34. package/dist/chunk-E6WTCJUL.js +0 -32
@@ -174,7 +174,7 @@ var verifyRequiredFieldsAreInCatalogConfigFile = async (projectDirectory) => {
174
174
  var import_picocolors = __toESM(require("picocolors"), 1);
175
175
 
176
176
  // package.json
177
- var version = "5.1.0";
177
+ var version = "5.2.0";
178
178
 
179
179
  // src/constants.ts
180
180
  var VERSION = version;
@@ -1938,6 +1938,9 @@ ${errors.join("\n")}`);
1938
1938
  };
1939
1939
  };
1940
1940
 
1941
+ // src/eventcatalog.ts
1942
+ var import_exporters2 = require("@eventcatalog/exporters");
1943
+
1941
1944
  // src/architecture-export.ts
1942
1945
  var import_node_fs9 = __toESM(require("fs"), 1);
1943
1946
  var import_node_path13 = __toESM(require("path"), 1);
@@ -1963,6 +1966,30 @@ var writeArchitectureExport = ({
1963
1966
  outputPath: getArchitectureExportPath({ outDir, isServer }),
1964
1967
  regenerateCommand: "npx eventcatalog build"
1965
1968
  });
1969
+ var resolveCustomExports = (config, { authEnabled }) => {
1970
+ const enabled = config?.exports?.custom?.enabled;
1971
+ if (enabled === false) return { enabled: false, reason: "disabled" };
1972
+ if (authEnabled && enabled !== true) return { enabled: false, reason: "auth" };
1973
+ return { enabled: true };
1974
+ };
1975
+ var hasCustomExports = ({
1976
+ projectDir,
1977
+ config
1978
+ }) => {
1979
+ const folder = import_node_path13.default.join(projectDir, config?.exports?.custom?.dir || import_exporters.DEFAULT_CUSTOM_EXPORTS_DIR);
1980
+ return import_node_fs9.default.existsSync(folder) && import_node_fs9.default.readdirSync(folder).some((name) => /\.mdx?$/i.test(name));
1981
+ };
1982
+ var getCustomExportsDir = ({ outDir, isServer }) => import_node_path13.default.join(outDir, isServer ? "client" : "", "exports");
1983
+ var writeCustomExportsToBuild = ({
1984
+ projectDir,
1985
+ outDir,
1986
+ isServer,
1987
+ config
1988
+ }) => (0, import_exporters.writeCustomExports)({
1989
+ dir: projectDir,
1990
+ outputDir: getCustomExportsDir({ outDir, isServer }),
1991
+ config: config?.exports?.custom ?? {}
1992
+ });
1966
1993
 
1967
1994
  // src/catalog-runtime.ts
1968
1995
  var import_node_fs10 = __toESM(require("fs"), 1);
@@ -3469,6 +3496,42 @@ program.command("build").description("Run build of EventCatalog").action(async (
3469
3496
  "export"
3470
3497
  );
3471
3498
  }
3499
+ if (hasCustomExports({ projectDir: dir, config })) {
3500
+ const folder = `${config?.exports?.custom?.dir || "exports"}/`;
3501
+ const customExports = resolveCustomExports(config, {
3502
+ authEnabled: isCatalogAuthEnabled({ config, projectDir: dir, isServer })
3503
+ });
3504
+ if (customExports.enabled) {
3505
+ try {
3506
+ const { written, failed } = await writeCustomExportsToBuild({
3507
+ projectDir: dir,
3508
+ outDir: import_node_path23.default.resolve(dir, await getProjectOutDir()),
3509
+ isServer,
3510
+ config
3511
+ });
3512
+ for (const exported of written) {
3513
+ logger.info(
3514
+ `Wrote the custom export "${exported.spec.title}" to ${import_node_path23.default.relative(dir, exported.path)} (${(0, import_exporters2.summariseCustomExportReport)(exported.report)})`,
3515
+ "export"
3516
+ );
3517
+ if (exported.report.unmatched.length)
3518
+ logger.warning(
3519
+ `${exported.spec.file}: nothing in the catalog matches ${exported.report.unmatched.map((u) => `${u.field} ${u.selector} (${u.reason})`).join(", ")}`,
3520
+ "export"
3521
+ );
3522
+ }
3523
+ for (const failure of failed)
3524
+ logger.warning(`Skipped the custom export ${failure.file ?? `"${failure.id}"`}: ${failure.error.message}`, "export");
3525
+ } catch (err) {
3526
+ logger.warning(`Skipped the custom exports in ${folder}: ${err.message}`, "export");
3527
+ }
3528
+ } else if (customExports.reason === "auth") {
3529
+ logger.info(
3530
+ `Skipped the custom exports in ${folder} because auth is enabled and build output is served without it. Set exports.custom.enabled to true to publish them anyway.`,
3531
+ "export"
3532
+ );
3533
+ }
3534
+ }
3472
3535
  });
3473
3536
  var previewCatalog = async ({ command }) => {
3474
3537
  await runCommandWithFilteredOutput({
@@ -346,6 +346,34 @@ interface Config {
346
346
  html?: {
347
347
  enabled?: boolean;
348
348
  };
349
+ /**
350
+ * Custom exports: parts of the catalog chosen for people outside the team (partners, the public, a regulator). Each
351
+ * is a file in `exports/` (e.g. `exports/partner-payments.mdx`) whose frontmatter says what it includes and whose
352
+ * body is its introduction, written to `exports/<id>.html` in the build output. Catalogs with auth must set
353
+ * `enabled: true`, because build output is served without auth.
354
+ */
355
+ custom?: {
356
+ /** Write the custom exports on build. @default true */
357
+ enabled?: boolean;
358
+ /** The folder that holds the custom export files. @default 'exports' */
359
+ dir?: string;
360
+ /** Build only these custom exports (by id). */
361
+ only?: string[];
362
+ /** What every custom export starts from; its own frontmatter overrides it. */
363
+ defaults?: {
364
+ /** Fields left out of every resource. @default ['owners', 'repository', 'contacts', 'docs'] */
365
+ hide?: ('owners' | 'repository' | 'specifications' | 'examples' | 'docs' | 'contacts')[];
366
+ /** Pointers at resources outside a custom export: dropped, shown as names, or pulled in (one level). @default 'omit' */
367
+ references?: 'omit' | 'name-only' | 'include';
368
+ };
369
+ /**
370
+ * Resources no custom export may show, whatever it includes: by id, e.g. [{ service: 'FraudAPI' }], or by custom
371
+ * property, e.g. [{ 'x-internal': true }] or [{ 'x-data-classification': ['confidential', 'restricted'] }].
372
+ */
373
+ neverExport?: {
374
+ [key: string]: string | number | boolean | (string | number | boolean)[] | undefined;
375
+ }[];
376
+ };
349
377
  };
350
378
  logo?: {
351
379
  alt: string;
@@ -346,6 +346,34 @@ interface Config {
346
346
  html?: {
347
347
  enabled?: boolean;
348
348
  };
349
+ /**
350
+ * Custom exports: parts of the catalog chosen for people outside the team (partners, the public, a regulator). Each
351
+ * is a file in `exports/` (e.g. `exports/partner-payments.mdx`) whose frontmatter says what it includes and whose
352
+ * body is its introduction, written to `exports/<id>.html` in the build output. Catalogs with auth must set
353
+ * `enabled: true`, because build output is served without auth.
354
+ */
355
+ custom?: {
356
+ /** Write the custom exports on build. @default true */
357
+ enabled?: boolean;
358
+ /** The folder that holds the custom export files. @default 'exports' */
359
+ dir?: string;
360
+ /** Build only these custom exports (by id). */
361
+ only?: string[];
362
+ /** What every custom export starts from; its own frontmatter overrides it. */
363
+ defaults?: {
364
+ /** Fields left out of every resource. @default ['owners', 'repository', 'contacts', 'docs'] */
365
+ hide?: ('owners' | 'repository' | 'specifications' | 'examples' | 'docs' | 'contacts')[];
366
+ /** Pointers at resources outside a custom export: dropped, shown as names, or pulled in (one level). @default 'omit' */
367
+ references?: 'omit' | 'name-only' | 'include';
368
+ };
369
+ /**
370
+ * Resources no custom export may show, whatever it includes: by id, e.g. [{ service: 'FraudAPI' }], or by custom
371
+ * property, e.g. [{ 'x-internal': true }] or [{ 'x-data-classification': ['confidential', 'restricted'] }].
372
+ */
373
+ neverExport?: {
374
+ [key: string]: string | number | boolean | (string | number | boolean)[] | undefined;
375
+ }[];
376
+ };
349
377
  };
350
378
  logo?: {
351
379
  alt: string;
@@ -7,12 +7,12 @@ import {
7
7
  import "./chunk-CA4U2JP7.js";
8
8
  import {
9
9
  log_build_default
10
- } from "./chunk-G3CHTDAE.js";
10
+ } from "./chunk-RNYFUWJI.js";
11
11
  import {
12
12
  getLicenseStatus,
13
13
  printLicenseStatus
14
14
  } from "./chunk-AD7CL772.js";
15
- import "./chunk-FHZXZWCY.js";
15
+ import "./chunk-66OL4B7U.js";
16
16
  import "./chunk-ZAZHAVKB.js";
17
17
  import "./chunk-CA6WCQ2T.js";
18
18
  import "./chunk-CPW6G62V.js";
@@ -39,10 +39,10 @@ import {
39
39
  } from "./chunk-NKNOXQ62.js";
40
40
  import {
41
41
  generate
42
- } from "./chunk-TBXLUIJD.js";
42
+ } from "./chunk-NBYKF4Z4.js";
43
43
  import {
44
44
  logger
45
- } from "./chunk-WBUSFEBH.js";
45
+ } from "./chunk-XI5HQWM2.js";
46
46
  import {
47
47
  resolve_catalog_dependencies_default
48
48
  } from "./chunk-PD7KTSYN.js";
@@ -57,10 +57,13 @@ import {
57
57
  watch
58
58
  } from "./chunk-U63GDPPY.js";
59
59
  import {
60
+ hasCustomExports,
60
61
  isCatalogAuthEnabled,
61
62
  resolveArchitectureExport,
62
- writeArchitectureExport
63
- } from "./chunk-E6WTCJUL.js";
63
+ resolveCustomExports,
64
+ writeArchitectureExport,
65
+ writeCustomExportsToBuild
66
+ } from "./chunk-IR5MKGKS.js";
64
67
  import {
65
68
  getAstroConfigPath
66
69
  } from "./chunk-VIJJ7JKH.js";
@@ -76,7 +79,7 @@ import {
76
79
  } from "./chunk-LFQJXLHG.js";
77
80
  import {
78
81
  VERSION
79
- } from "./chunk-OT57IOWN.js";
82
+ } from "./chunk-N2LLD5TR.js";
80
83
  import {
81
84
  getEventCatalogConfigFile,
82
85
  verifyRequiredFieldsAreInCatalogConfigFile
@@ -645,6 +648,7 @@ async function buildFieldsIndex(catalogDir, outputDir) {
645
648
  }
646
649
 
647
650
  // src/eventcatalog.ts
651
+ import { summariseCustomExportReport } from "@eventcatalog/exporters";
648
652
  var currentDir = path2.dirname(fileURLToPath(import.meta.url));
649
653
  var astroCli = path2.join(path2.dirname(createRequire(import.meta.url).resolve("astro/package.json")), "bin/astro.mjs");
650
654
  var ASTRO_IN_FOREGROUND = { ASTRO_DEV_BACKGROUND: "1", ASTRO_PREVIEW_BACKGROUND: "1" };
@@ -1061,6 +1065,42 @@ program.command("build").description("Run build of EventCatalog").action(async (
1061
1065
  "export"
1062
1066
  );
1063
1067
  }
1068
+ if (hasCustomExports({ projectDir: dir, config })) {
1069
+ const folder = `${config?.exports?.custom?.dir || "exports"}/`;
1070
+ const customExports = resolveCustomExports(config, {
1071
+ authEnabled: isCatalogAuthEnabled({ config, projectDir: dir, isServer })
1072
+ });
1073
+ if (customExports.enabled) {
1074
+ try {
1075
+ const { written, failed } = await writeCustomExportsToBuild({
1076
+ projectDir: dir,
1077
+ outDir: path2.resolve(dir, await getProjectOutDir()),
1078
+ isServer,
1079
+ config
1080
+ });
1081
+ for (const exported of written) {
1082
+ logger.info(
1083
+ `Wrote the custom export "${exported.spec.title}" to ${path2.relative(dir, exported.path)} (${summariseCustomExportReport(exported.report)})`,
1084
+ "export"
1085
+ );
1086
+ if (exported.report.unmatched.length)
1087
+ logger.warning(
1088
+ `${exported.spec.file}: nothing in the catalog matches ${exported.report.unmatched.map((u) => `${u.field} ${u.selector} (${u.reason})`).join(", ")}`,
1089
+ "export"
1090
+ );
1091
+ }
1092
+ for (const failure of failed)
1093
+ logger.warning(`Skipped the custom export ${failure.file ?? `"${failure.id}"`}: ${failure.error.message}`, "export");
1094
+ } catch (err) {
1095
+ logger.warning(`Skipped the custom exports in ${folder}: ${err.message}`, "export");
1096
+ }
1097
+ } else if (customExports.reason === "auth") {
1098
+ logger.info(
1099
+ `Skipped the custom exports in ${folder} because auth is enabled and build output is served without it. Set exports.custom.enabled to true to publish them anyway.`,
1100
+ "export"
1101
+ );
1102
+ }
1103
+ }
1064
1104
  });
1065
1105
  var previewCatalog = async ({ command }) => {
1066
1106
  await runCommandWithFilteredOutput({
package/dist/generate.cjs CHANGED
@@ -105,7 +105,7 @@ var getEventCatalogConfigFile = async (projectDirectory) => {
105
105
  var import_picocolors = __toESM(require("picocolors"), 1);
106
106
 
107
107
  // package.json
108
- var version = "5.1.0";
108
+ var version = "5.2.0";
109
109
 
110
110
  // src/constants.ts
111
111
  var VERSION = version;
package/dist/generate.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  generate
3
- } from "./chunk-TBXLUIJD.js";
4
- import "./chunk-WBUSFEBH.js";
5
- import "./chunk-OT57IOWN.js";
3
+ } from "./chunk-NBYKF4Z4.js";
4
+ import "./chunk-XI5HQWM2.js";
5
+ import "./chunk-N2LLD5TR.js";
6
6
  import "./chunk-4G7FSRPN.js";
7
7
  export {
8
8
  generate
@@ -36,7 +36,7 @@ module.exports = __toCommonJS(cli_logger_exports);
36
36
  var import_picocolors = __toESM(require("picocolors"), 1);
37
37
 
38
38
  // package.json
39
- var version = "5.1.0";
39
+ var version = "5.2.0";
40
40
 
41
41
  // src/constants.ts
42
42
  var VERSION = version;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  logger
3
- } from "../chunk-WBUSFEBH.js";
4
- import "../chunk-OT57IOWN.js";
3
+ } from "../chunk-XI5HQWM2.js";
4
+ import "../chunk-N2LLD5TR.js";
5
5
  export {
6
6
  logger
7
7
  };
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  },
8
8
  "license": "BUSL-1.1",
9
9
  "type": "module",
10
- "version": "5.1.0",
10
+ "version": "5.2.0",
11
11
  "publishConfig": {
12
12
  "access": "public"
13
13
  },
@@ -140,9 +140,9 @@
140
140
  "y-protocols": "^1.0.7",
141
141
  "yjs": "^13.6.33",
142
142
  "zod": "^4.6.6",
143
- "@eventcatalog/exporters": "0.0.2",
144
- "@eventcatalog/linter": "1.2.1",
145
- "@eventcatalog/sdk": "2.30.0",
143
+ "@eventcatalog/exporters": "0.1.0",
144
+ "@eventcatalog/linter": "1.2.2",
145
+ "@eventcatalog/sdk": "2.31.0",
146
146
  "@eventcatalog/visualiser": "^5.0.0"
147
147
  },
148
148
  "devDependencies": {
@@ -1,32 +0,0 @@
1
- // src/architecture-export.ts
2
- import fs from "fs";
3
- import path from "path";
4
- import { writeHtml } from "@eventcatalog/exporters";
5
- var isCatalogAuthEnabled = ({
6
- config,
7
- projectDir,
8
- isServer
9
- }) => Boolean(config?.auth?.enabled) && isServer && fs.existsSync(path.join(projectDir, "eventcatalog.auth.js"));
10
- var resolveArchitectureExport = (config, { authEnabled }) => {
11
- const enabled = config?.exports?.html?.enabled;
12
- if (enabled === false) return { enabled: false, reason: "disabled" };
13
- if (authEnabled && enabled !== true) return { enabled: false, reason: "auth" };
14
- return { enabled: true };
15
- };
16
- var getArchitectureExportPath = ({ outDir, isServer }) => path.join(outDir, isServer ? "client" : "", "architecture.html");
17
- var writeArchitectureExport = ({
18
- projectDir,
19
- outDir,
20
- isServer
21
- }) => writeHtml({
22
- dir: projectDir,
23
- outputPath: getArchitectureExportPath({ outDir, isServer }),
24
- regenerateCommand: "npx eventcatalog build"
25
- });
26
-
27
- export {
28
- isCatalogAuthEnabled,
29
- resolveArchitectureExport,
30
- getArchitectureExportPath,
31
- writeArchitectureExport
32
- };