@eventcatalog/core 4.2.1 → 4.2.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.
Files changed (32) 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/astro-output.cjs +43 -0
  6. package/dist/astro-output.d.cts +4 -0
  7. package/dist/astro-output.d.ts +4 -0
  8. package/dist/astro-output.js +8 -0
  9. package/dist/{chunk-PUTZR6SV.js → chunk-DGDCWOWP.js} +1 -1
  10. package/dist/{chunk-A6SWOPJ4.js → chunk-I4TTHHXI.js} +1 -1
  11. package/dist/{chunk-DTQ2MXRB.js → chunk-M2YEUPPP.js} +1 -1
  12. package/dist/{chunk-V6UMVNX4.js → chunk-QQC5UX3E.js} +3 -3
  13. package/dist/chunk-RDYYZQYU.js +18 -0
  14. package/dist/{chunk-RQ36O7QA.js → chunk-WOASLQ3F.js} +1 -1
  15. package/dist/constants.cjs +1 -1
  16. package/dist/constants.js +1 -1
  17. package/dist/eventcatalog.cjs +15 -12
  18. package/dist/eventcatalog.js +16 -23
  19. package/dist/generate.cjs +1 -1
  20. package/dist/generate.js +3 -3
  21. package/dist/utils/cli-logger.cjs +1 -1
  22. package/dist/utils/cli-logger.js +2 -2
  23. package/eventcatalog/src/components/MDX/CustomProperties/CustomProperties.astro +39 -0
  24. package/eventcatalog/src/components/MDX/CustomProperties/CustomProperty.astro +37 -0
  25. package/eventcatalog/src/components/MDX/CustomProperties/CustomPropertyRow.astro +37 -0
  26. package/eventcatalog/src/components/MDX/CustomProperties/CustomPropertyValue.astro +51 -0
  27. package/eventcatalog/src/components/MDX/CustomProperties/custom-properties.spec.ts +38 -0
  28. package/eventcatalog/src/components/MDX/CustomProperties/custom-properties.ts +39 -0
  29. package/eventcatalog/src/components/MDX/components.tsx +4 -0
  30. package/eventcatalog/src/content.config.ts +402 -373
  31. package/eventcatalog/src/utils/collections/extension-properties.ts +25 -0
  32. package/package.json +3 -3
@@ -36,7 +36,7 @@ module.exports = __toCommonJS(analytics_exports);
36
36
  var import_os = __toESM(require("os"), 1);
37
37
 
38
38
  // package.json
39
- var version = "4.2.1";
39
+ var version = "4.2.3";
40
40
 
41
41
  // src/constants.ts
42
42
  var VERSION = version;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  raiseEvent
3
- } from "../chunk-RQ36O7QA.js";
4
- import "../chunk-PUTZR6SV.js";
3
+ } from "../chunk-WOASLQ3F.js";
4
+ import "../chunk-DGDCWOWP.js";
5
5
  export {
6
6
  raiseEvent
7
7
  };
@@ -140,7 +140,7 @@ var verifyRequiredFieldsAreInCatalogConfigFile = async (projectDirectory) => {
140
140
  var import_os = __toESM(require("os"), 1);
141
141
 
142
142
  // package.json
143
- var version = "4.2.1";
143
+ var version = "4.2.3";
144
144
 
145
145
  // src/constants.ts
146
146
  var VERSION = version;
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  log_build_default
3
- } from "../chunk-V6UMVNX4.js";
4
- import "../chunk-RQ36O7QA.js";
3
+ } from "../chunk-QQC5UX3E.js";
5
4
  import "../chunk-K2XIENVT.js";
6
- import "../chunk-PUTZR6SV.js";
5
+ import "../chunk-WOASLQ3F.js";
6
+ import "../chunk-DGDCWOWP.js";
7
7
  import "../chunk-6QENHZZP.js";
8
8
  export {
9
9
  log_build_default as default
@@ -0,0 +1,43 @@
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/astro-output.ts
21
+ var astro_output_exports = {};
22
+ __export(astro_output_exports, {
23
+ createAstroDevLineFilter: () => createAstroDevLineFilter,
24
+ createAstroLineFilter: () => createAstroLineFilter
25
+ });
26
+ module.exports = __toCommonJS(astro_output_exports);
27
+ var createAstroLineFilter = () => {
28
+ return (line) => {
29
+ const isIgnoredGetStaticPathsWarning = line.includes("[router]") && line.includes("getStaticPaths() ignored in dynamic page");
30
+ return line.includes("[glob-loader]") || isIgnoredGetStaticPathsWarning || /^\s*The collection ".*" does not exist or is empty\. Please check your content config file for errors\.\s*$/.test(line);
31
+ };
32
+ };
33
+ var createAstroDevLineFilter = () => {
34
+ const shouldFilterAstroLine = createAstroLineFilter();
35
+ return (line) => {
36
+ return shouldFilterAstroLine(line) || line.includes("[router]");
37
+ };
38
+ };
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ createAstroDevLineFilter,
42
+ createAstroLineFilter
43
+ });
@@ -0,0 +1,4 @@
1
+ declare const createAstroLineFilter: () => (line: string) => boolean;
2
+ declare const createAstroDevLineFilter: () => (line: string) => boolean;
3
+
4
+ export { createAstroDevLineFilter, createAstroLineFilter };
@@ -0,0 +1,4 @@
1
+ declare const createAstroLineFilter: () => (line: string) => boolean;
2
+ declare const createAstroDevLineFilter: () => (line: string) => boolean;
3
+
4
+ export { createAstroDevLineFilter, createAstroLineFilter };
@@ -0,0 +1,8 @@
1
+ import {
2
+ createAstroDevLineFilter,
3
+ createAstroLineFilter
4
+ } from "./chunk-RDYYZQYU.js";
5
+ export {
6
+ createAstroDevLineFilter,
7
+ createAstroLineFilter
8
+ };
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "4.2.1";
2
+ var version = "4.2.3";
3
3
 
4
4
  // src/constants.ts
5
5
  var VERSION = version;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  logger
3
- } from "./chunk-DTQ2MXRB.js";
3
+ } from "./chunk-M2YEUPPP.js";
4
4
  import {
5
5
  cleanup,
6
6
  getEventCatalogConfigFile
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  VERSION
3
- } from "./chunk-PUTZR6SV.js";
3
+ } from "./chunk-DGDCWOWP.js";
4
4
 
5
5
  // src/utils/cli-logger.ts
6
6
  import pc from "picocolors";
@@ -1,10 +1,10 @@
1
- import {
2
- raiseEvent
3
- } from "./chunk-RQ36O7QA.js";
4
1
  import {
5
2
  countResources,
6
3
  serializeCounts
7
4
  } from "./chunk-K2XIENVT.js";
5
+ import {
6
+ raiseEvent
7
+ } from "./chunk-WOASLQ3F.js";
8
8
  import {
9
9
  getEventCatalogConfigFile,
10
10
  verifyRequiredFieldsAreInCatalogConfigFile
@@ -0,0 +1,18 @@
1
+ // src/astro-output.ts
2
+ var createAstroLineFilter = () => {
3
+ return (line) => {
4
+ const isIgnoredGetStaticPathsWarning = line.includes("[router]") && line.includes("getStaticPaths() ignored in dynamic page");
5
+ return line.includes("[glob-loader]") || isIgnoredGetStaticPathsWarning || /^\s*The collection ".*" does not exist or is empty\. Please check your content config file for errors\.\s*$/.test(line);
6
+ };
7
+ };
8
+ var createAstroDevLineFilter = () => {
9
+ const shouldFilterAstroLine = createAstroLineFilter();
10
+ return (line) => {
11
+ return shouldFilterAstroLine(line) || line.includes("[router]");
12
+ };
13
+ };
14
+
15
+ export {
16
+ createAstroLineFilter,
17
+ createAstroDevLineFilter
18
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  VERSION
3
- } from "./chunk-PUTZR6SV.js";
3
+ } from "./chunk-DGDCWOWP.js";
4
4
 
5
5
  // src/analytics/analytics.js
6
6
  import os from "os";
@@ -25,7 +25,7 @@ __export(constants_exports, {
25
25
  module.exports = __toCommonJS(constants_exports);
26
26
 
27
27
  // package.json
28
- var version = "4.2.1";
28
+ var version = "4.2.3";
29
29
 
30
30
  // src/constants.ts
31
31
  var VERSION = version;
package/dist/constants.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  VERSION
3
- } from "./chunk-PUTZR6SV.js";
3
+ } from "./chunk-DGDCWOWP.js";
4
4
  export {
5
5
  VERSION
6
6
  };
@@ -144,7 +144,7 @@ var verifyRequiredFieldsAreInCatalogConfigFile = async (projectDirectory) => {
144
144
  var import_picocolors = __toESM(require("picocolors"), 1);
145
145
 
146
146
  // package.json
147
- var version = "4.2.1";
147
+ var version = "4.2.3";
148
148
 
149
149
  // src/constants.ts
150
150
  var VERSION = version;
@@ -1831,6 +1831,20 @@ var linkCoreNodeModules = ({
1831
1831
  import_fs2.default.symlinkSync(installedCoreNodeModules, coreNodeModules, process.platform === "win32" ? "junction" : "dir");
1832
1832
  };
1833
1833
 
1834
+ // src/astro-output.ts
1835
+ var createAstroLineFilter = () => {
1836
+ return (line) => {
1837
+ const isIgnoredGetStaticPathsWarning = line.includes("[router]") && line.includes("getStaticPaths() ignored in dynamic page");
1838
+ return line.includes("[glob-loader]") || isIgnoredGetStaticPathsWarning || /^\s*The collection ".*" does not exist or is empty\. Please check your content config file for errors\.\s*$/.test(line);
1839
+ };
1840
+ };
1841
+ var createAstroDevLineFilter = () => {
1842
+ const shouldFilterAstroLine = createAstroLineFilter();
1843
+ return (line) => {
1844
+ return shouldFilterAstroLine(line) || line.includes("[router]");
1845
+ };
1846
+ };
1847
+
1834
1848
  // src/eventcatalog.ts
1835
1849
  var import_license = require("@eventcatalog/license");
1836
1850
  var currentDir = import_node_path11.default.dirname((0, import_node_url.fileURLToPath)(importMetaUrl));
@@ -1903,17 +1917,6 @@ var startDevPrewarm = ({
1903
1917
  };
1904
1918
  setTimeout(tick, initialDelayMs);
1905
1919
  };
1906
- var createAstroLineFilter = () => {
1907
- return (line) => {
1908
- return line.includes("[glob-loader]") || /^\s*The collection ".*" does not exist or is empty\. Please check your content config file for errors\.\s*$/.test(line);
1909
- };
1910
- };
1911
- var createAstroDevLineFilter = () => {
1912
- const shouldFilterAstroLine = createAstroLineFilter();
1913
- return (line) => {
1914
- return shouldFilterAstroLine(line) || line.includes("[router]");
1915
- };
1916
- };
1917
1920
  var buildDevSearchIndex = async ({ config }) => {
1918
1921
  const result = await buildSearchIndex({
1919
1922
  projectDir: dir,
@@ -1,16 +1,23 @@
1
1
  import {
2
2
  log_build_default
3
- } from "./chunk-V6UMVNX4.js";
3
+ } from "./chunk-QQC5UX3E.js";
4
+ import "./chunk-K2XIENVT.js";
4
5
  import {
5
6
  runMigrations
6
7
  } from "./chunk-XUAF2H54.js";
7
8
  import "./chunk-CA4U2JP7.js";
9
+ import {
10
+ getProjectOutDir,
11
+ isAuthEnabled,
12
+ isIndexedSearchEnabled,
13
+ isOutputServer
14
+ } from "./chunk-B7HCX5HM.js";
8
15
  import {
9
16
  generate
10
- } from "./chunk-A6SWOPJ4.js";
17
+ } from "./chunk-I4TTHHXI.js";
11
18
  import {
12
19
  logger
13
- } from "./chunk-DTQ2MXRB.js";
20
+ } from "./chunk-M2YEUPPP.js";
14
21
  import {
15
22
  resolve_catalog_dependencies_default
16
23
  } from "./chunk-LHR4G2UO.js";
@@ -20,25 +27,22 @@ import {
20
27
  import {
21
28
  watch
22
29
  } from "./chunk-CAJUIMDJ.js";
23
- import "./chunk-RQ36O7QA.js";
24
- import "./chunk-K2XIENVT.js";
30
+ import "./chunk-WOASLQ3F.js";
31
+ import {
32
+ createAstroDevLineFilter,
33
+ createAstroLineFilter
34
+ } from "./chunk-RDYYZQYU.js";
25
35
  import {
26
36
  catalogToAstro
27
37
  } from "./chunk-W3SAPOZU.js";
28
38
  import "./chunk-W5JQON7Z.js";
29
39
  import {
30
40
  VERSION
31
- } from "./chunk-PUTZR6SV.js";
41
+ } from "./chunk-DGDCWOWP.js";
32
42
  import {
33
43
  linkCoreNodeModules,
34
44
  resolveInstalledCoreNodeModules
35
45
  } from "./chunk-BWN544LB.js";
36
- import {
37
- getProjectOutDir,
38
- isAuthEnabled,
39
- isIndexedSearchEnabled,
40
- isOutputServer
41
- } from "./chunk-B7HCX5HM.js";
42
46
  import {
43
47
  getEventCatalogConfigFile,
44
48
  verifyRequiredFieldsAreInCatalogConfigFile
@@ -677,17 +681,6 @@ var startDevPrewarm = ({
677
681
  };
678
682
  setTimeout(tick, initialDelayMs);
679
683
  };
680
- var createAstroLineFilter = () => {
681
- return (line) => {
682
- return line.includes("[glob-loader]") || /^\s*The collection ".*" does not exist or is empty\. Please check your content config file for errors\.\s*$/.test(line);
683
- };
684
- };
685
- var createAstroDevLineFilter = () => {
686
- const shouldFilterAstroLine = createAstroLineFilter();
687
- return (line) => {
688
- return shouldFilterAstroLine(line) || line.includes("[router]");
689
- };
690
- };
691
684
  var buildDevSearchIndex = async ({ config }) => {
692
685
  const result = await buildSearchIndex({
693
686
  projectDir: dir,
package/dist/generate.cjs CHANGED
@@ -108,7 +108,7 @@ var getEventCatalogConfigFile = async (projectDirectory) => {
108
108
  var import_picocolors = __toESM(require("picocolors"), 1);
109
109
 
110
110
  // package.json
111
- var version = "4.2.1";
111
+ var version = "4.2.3";
112
112
 
113
113
  // src/constants.ts
114
114
  var VERSION = version;
package/dist/generate.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  generate
3
- } from "./chunk-A6SWOPJ4.js";
4
- import "./chunk-DTQ2MXRB.js";
5
- import "./chunk-PUTZR6SV.js";
3
+ } from "./chunk-I4TTHHXI.js";
4
+ import "./chunk-M2YEUPPP.js";
5
+ import "./chunk-DGDCWOWP.js";
6
6
  import "./chunk-6QENHZZP.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 = "4.2.1";
39
+ var version = "4.2.3";
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-DTQ2MXRB.js";
4
- import "../chunk-PUTZR6SV.js";
3
+ } from "../chunk-M2YEUPPP.js";
4
+ import "../chunk-DGDCWOWP.js";
5
5
  export {
6
6
  logger
7
7
  };
@@ -0,0 +1,39 @@
1
+ ---
2
+ import CustomPropertyRow from './CustomPropertyRow.astro';
3
+ import { getCustomProperties } from './custom-properties';
4
+
5
+ interface Props {
6
+ title?: string;
7
+ data?: Record<string, unknown>;
8
+ }
9
+
10
+ const { title = 'Custom properties', data } = Astro.props;
11
+ const properties = getCustomProperties(data);
12
+ ---
13
+
14
+ {
15
+ properties.length > 0 && (
16
+ <section class="not-prose my-8">
17
+ {title && <h3 class="mb-4 text-xl font-semibold text-[rgb(var(--ec-page-text))]">{title}</h3>}
18
+ <div class="overflow-x-auto">
19
+ <table class="w-full border-collapse text-left text-sm text-[rgb(var(--ec-page-text-muted))]">
20
+ <thead>
21
+ <tr class="border-b border-[rgb(var(--ec-page-border))] text-[rgb(var(--ec-page-text))]">
22
+ <th scope="col" class="py-3 pr-6 font-semibold">
23
+ Property
24
+ </th>
25
+ <th scope="col" class="py-3 font-semibold">
26
+ Value
27
+ </th>
28
+ </tr>
29
+ </thead>
30
+ <tbody class="divide-y divide-[rgb(var(--ec-page-border))]">
31
+ {properties.map((property) => (
32
+ <CustomPropertyRow property={property} />
33
+ ))}
34
+ </tbody>
35
+ </table>
36
+ </div>
37
+ </section>
38
+ )
39
+ }
@@ -0,0 +1,37 @@
1
+ ---
2
+ import CustomPropertyRow from './CustomPropertyRow.astro';
3
+ import { getCustomProperty } from './custom-properties';
4
+
5
+ interface Props {
6
+ name: string;
7
+ label?: string;
8
+ data?: Record<string, unknown>;
9
+ }
10
+
11
+ const { name, label, data } = Astro.props;
12
+ const property = getCustomProperty(data, name);
13
+
14
+ if (property && label) property.label = label;
15
+ ---
16
+
17
+ {
18
+ property && (
19
+ <div class="not-prose my-6 overflow-x-auto">
20
+ <table class="w-full border-collapse text-left text-sm text-[rgb(var(--ec-page-text-muted))]">
21
+ <thead>
22
+ <tr class="border-b border-[rgb(var(--ec-page-border))] text-[rgb(var(--ec-page-text))]">
23
+ <th scope="col" class="py-3 pr-6 font-semibold">
24
+ Property
25
+ </th>
26
+ <th scope="col" class="py-3 font-semibold">
27
+ Value
28
+ </th>
29
+ </tr>
30
+ </thead>
31
+ <tbody class="divide-y divide-[rgb(var(--ec-page-border))]">
32
+ <CustomPropertyRow property={property} />
33
+ </tbody>
34
+ </table>
35
+ </div>
36
+ )
37
+ }
@@ -0,0 +1,37 @@
1
+ ---
2
+ import CustomPropertyValue from './CustomPropertyValue.astro';
3
+ import type { CustomProperty } from './custom-properties';
4
+ import { InformationCircleIcon } from '@heroicons/react/24/outline';
5
+
6
+ interface Props {
7
+ property: CustomProperty;
8
+ }
9
+
10
+ const { property } = Astro.props;
11
+ ---
12
+
13
+ <tr class="hover:bg-[rgb(var(--ec-content-hover))]">
14
+ <td class="w-1/3 min-w-48 py-4 pr-6 align-top font-medium text-[rgb(var(--ec-page-text))]">
15
+ <span class="inline-flex items-center gap-1.5">
16
+ {property.label}
17
+ <span class="group relative inline-flex">
18
+ <button
19
+ type="button"
20
+ class="inline-flex cursor-help text-[rgb(var(--ec-page-text-muted))] hover:text-[rgb(var(--ec-page-text))] focus:outline-hidden focus:ring-2 focus:ring-[rgb(var(--ec-accent))] focus:ring-offset-2"
21
+ aria-label={`Frontmatter property: ${property.name}`}
22
+ >
23
+ <InformationCircleIcon className="h-4 w-4" aria-hidden="true" />
24
+ </button>
25
+ <span
26
+ role="tooltip"
27
+ class="pointer-events-none absolute left-full top-1/2 z-20 ml-2 -translate-y-1/2 whitespace-nowrap rounded-md bg-[rgb(var(--ec-page-text))] px-2.5 py-1.5 text-xs font-medium text-[rgb(var(--ec-page-bg))] opacity-0 shadow-lg transition-opacity group-hover:opacity-100 group-focus-within:opacity-100"
28
+ >
29
+ {property.name}
30
+ </span>
31
+ </span>
32
+ </span>
33
+ </td>
34
+ <td class="min-w-0 py-4 align-top text-sm">
35
+ <CustomPropertyValue value={property.value} />
36
+ </td>
37
+ </tr>
@@ -0,0 +1,51 @@
1
+ ---
2
+ import { formatCustomPropertyLabel } from './custom-properties';
3
+
4
+ interface Props {
5
+ value: unknown;
6
+ }
7
+
8
+ const { value } = Astro.props;
9
+ const isArray = Array.isArray(value);
10
+ const isDate = value instanceof Date;
11
+ const isObject = value !== null && typeof value === 'object' && !isArray && !isDate;
12
+ const entries = isObject ? Object.entries(value as Record<string, unknown>) : [];
13
+ const scalarValue = value === null || value === undefined ? '—' : isDate ? value.toISOString() : String(value);
14
+ ---
15
+
16
+ {
17
+ isArray ? (
18
+ value.length > 0 ? (
19
+ <ul class="m-0 list-disc space-y-1 pl-5 text-[rgb(var(--ec-page-text))]">
20
+ {value.map((item) => (
21
+ <li>
22
+ <Astro.self value={item} />
23
+ </li>
24
+ ))}
25
+ </ul>
26
+ ) : (
27
+ <span class="text-[rgb(var(--ec-page-text-muted))]">—</span>
28
+ )
29
+ ) : isObject ? (
30
+ entries.length > 0 ? (
31
+ <dl class="m-0 space-y-2">
32
+ {entries.map(([name, nestedValue]) => (
33
+ <div class="grid gap-1 sm:grid-cols-[minmax(0,10rem)_minmax(0,1fr)]">
34
+ <dt class="font-medium text-[rgb(var(--ec-page-text-muted))]">{formatCustomPropertyLabel(name)}</dt>
35
+ <dd class="m-0 min-w-0 text-[rgb(var(--ec-page-text))]">
36
+ <Astro.self value={nestedValue} />
37
+ </dd>
38
+ </div>
39
+ ))}
40
+ </dl>
41
+ ) : (
42
+ <span class="text-[rgb(var(--ec-page-text-muted))]">—</span>
43
+ )
44
+ ) : typeof value === 'boolean' ? (
45
+ <span class="inline-flex rounded-full bg-[rgb(var(--ec-content-hover))] px-2 py-0.5 text-xs font-medium text-[rgb(var(--ec-page-text))]">
46
+ {scalarValue}
47
+ </span>
48
+ ) : (
49
+ <span class="break-words text-[rgb(var(--ec-page-text))]">{scalarValue}</span>
50
+ )
51
+ }
@@ -0,0 +1,38 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { formatCustomPropertyLabel, getCustomProperties, getCustomProperty, isCustomPropertyName } from './custom-properties';
3
+
4
+ describe('custom properties MDX components', () => {
5
+ it('recognizes extension property names', () => {
6
+ expect(isCustomPropertyName('x-owner')).toBe(true);
7
+ expect(isCustomPropertyName('x-')).toBe(false);
8
+ expect(isCustomPropertyName('owner')).toBe(false);
9
+ });
10
+
11
+ it('creates a readable label without changing uppercase text', () => {
12
+ expect(formatCustomPropertyLabel('x-operational-tier')).toBe('Operational Tier');
13
+ expect(formatCustomPropertyLabel('x-PII_classification')).toBe('PII Classification');
14
+ });
15
+
16
+ it('extracts only custom properties and preserves their values', () => {
17
+ const properties = getCustomProperties({
18
+ id: 'payment-api',
19
+ 'x-operational-tier': 1,
20
+ 'x-on-call': { schedule: 'payments-primary' },
21
+ });
22
+
23
+ expect(properties).toEqual([
24
+ { name: 'x-operational-tier', label: 'Operational Tier', value: 1 },
25
+ { name: 'x-on-call', label: 'On Call', value: { schedule: 'payments-primary' } },
26
+ ]);
27
+ });
28
+
29
+ it('gets a named custom property', () => {
30
+ expect(getCustomProperty({ 'x-owner': 'payments' }, 'x-owner')).toEqual({
31
+ name: 'x-owner',
32
+ label: 'Owner',
33
+ value: 'payments',
34
+ });
35
+ expect(getCustomProperty({ owner: 'payments' }, 'owner')).toBeUndefined();
36
+ expect(getCustomProperty({ 'x-owner': 'payments' }, 'x-missing')).toBeUndefined();
37
+ });
38
+ });
@@ -0,0 +1,39 @@
1
+ export type CustomProperty = {
2
+ name: string;
3
+ label: string;
4
+ value: unknown;
5
+ };
6
+
7
+ export const isCustomPropertyName = (name: string) => name.startsWith('x-') && name.length > 2;
8
+
9
+ export const formatCustomPropertyLabel = (name: string) => {
10
+ const propertyName = isCustomPropertyName(name) ? name.slice(2) : name;
11
+
12
+ return propertyName
13
+ .split(/[-_.\s]+/)
14
+ .filter(Boolean)
15
+ .map((part) => `${part.charAt(0).toUpperCase()}${part.slice(1)}`)
16
+ .join(' ');
17
+ };
18
+
19
+ export const getCustomProperties = (data?: Record<string, unknown>): CustomProperty[] => {
20
+ if (!data) return [];
21
+
22
+ return Object.entries(data)
23
+ .filter(([name]) => isCustomPropertyName(name))
24
+ .map(([name, value]) => ({
25
+ name,
26
+ label: formatCustomPropertyLabel(name),
27
+ value,
28
+ }));
29
+ };
30
+
31
+ export const getCustomProperty = (data: Record<string, unknown> | undefined, name: string): CustomProperty | undefined => {
32
+ if (!data || !isCustomPropertyName(name) || !Object.prototype.hasOwnProperty.call(data, name)) return undefined;
33
+
34
+ return {
35
+ name,
36
+ label: formatCustomPropertyLabel(name),
37
+ value: data[name],
38
+ };
39
+ };
@@ -41,6 +41,8 @@ import SchemaViewerPortal from '@components/MDX/SchemaViewer/SchemaViewerPortal'
41
41
  import { jsx } from 'astro/jsx-runtime';
42
42
  import RemoteSchema from '@components/MDX/RemoteSchema.astro';
43
43
  import Visibility from '@components/MDX/Visibility';
44
+ import CustomProperties from '@components/MDX/CustomProperties/CustomProperties.astro';
45
+ import CustomProperty from '@components/MDX/CustomProperties/CustomProperty.astro';
44
46
 
45
47
  const getEntityMapCollection = (props: any, mdxProp: any) => {
46
48
  const collection = mdxProp.collection ?? props.collection;
@@ -50,6 +52,8 @@ const getEntityMapCollection = (props: any, mdxProp: any) => {
50
52
  const components = (props: any) => {
51
53
  return {
52
54
  Attachments: (mdxProp: any) => jsx(Attachments, { ...props, ...mdxProp }),
55
+ CustomProperties: (mdxProp: any) => jsx(CustomProperties, { ...props, ...mdxProp }),
56
+ CustomProperty: (mdxProp: any) => jsx(CustomProperty, { ...props, ...mdxProp }),
53
57
  Accordion,
54
58
  AccordionGroup,
55
59
  Admonition,