@open-resource-discovery/metadata-renderer 0.0.0 → 1.0.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 (72) hide show
  1. package/LICENSE +191 -0
  2. package/README.md +94 -1
  3. package/dist/a2a/index.d.ts +9 -0
  4. package/dist/a2a.js +2 -0
  5. package/dist/asyncApi/asyncapi-browser.d.ts +3 -0
  6. package/dist/asyncApi/customAttributes/attributeLink.d.ts +3 -0
  7. package/dist/asyncApi/customAttributes/autoDiscover.d.ts +4 -0
  8. package/dist/asyncApi/customAttributes/buildExtensionsConfig.d.ts +5 -0
  9. package/dist/asyncApi/customAttributes/context.d.ts +7 -0
  10. package/dist/asyncApi/customAttributes/genericRenderer.d.ts +4 -0
  11. package/dist/asyncApi/customAttributes/sapPreset.d.ts +2 -0
  12. package/dist/asyncApi/customAttributes/stateInfo.d.ts +3 -0
  13. package/dist/asyncApi/customAttributes/styles.d.ts +2 -0
  14. package/dist/asyncApi/customAttributes/types.d.ts +32 -0
  15. package/dist/asyncApi/index.d.ts +12 -0
  16. package/dist/asyncapi.js +2 -0
  17. package/dist/chunks/a2a-B5lkgqLU.js +29 -0
  18. package/dist/chunks/asyncApi-K0uQpQwz.js +641 -0
  19. package/dist/chunks/csn-D4GBs8tC.js +548 -0
  20. package/dist/chunks/mcp-qA5sYRAN.js +29 -0
  21. package/dist/chunks/openApi-Ccp9Pa_k.js +1092 -0
  22. package/dist/chunks/utils-BC3WF3-9.js +77 -0
  23. package/dist/core/ShadowRoot.d.ts +6 -0
  24. package/dist/core/index.d.ts +11 -0
  25. package/dist/core/utils.d.ts +7 -0
  26. package/dist/core/utils.test.d.ts +1 -0
  27. package/dist/csn/customAttributes/genericRenderer.d.ts +2 -0
  28. package/dist/csn/customAttributes/postProcess.d.ts +5 -0
  29. package/dist/csn/customAttributes/sapPreset.d.ts +2 -0
  30. package/dist/csn/customAttributes/types.d.ts +28 -0
  31. package/dist/csn/index.d.ts +12 -0
  32. package/dist/csn/styles.d.ts +2 -0
  33. package/dist/csn.js +2 -0
  34. package/dist/entries/a2a.d.ts +2 -0
  35. package/dist/entries/asyncapi.d.ts +2 -0
  36. package/dist/entries/csn.d.ts +2 -0
  37. package/dist/entries/mcp.d.ts +2 -0
  38. package/dist/entries/openapi.d.ts +2 -0
  39. package/dist/favicon.ico +0 -0
  40. package/dist/favicon.svg +29 -0
  41. package/dist/index.css +210782 -0
  42. package/dist/index.d.ts +23 -0
  43. package/dist/index.js +166 -0
  44. package/dist/mcp/index.d.ts +8 -0
  45. package/dist/mcp.js +2 -0
  46. package/dist/openApi/customAttributes/attributeLink.d.ts +3 -0
  47. package/dist/openApi/customAttributes/autoDiscover.d.ts +15 -0
  48. package/dist/openApi/customAttributes/genericRenderer.d.ts +3 -0
  49. package/dist/openApi/customAttributes/sapAttributes/operation/deprecatedOperation.d.ts +10 -0
  50. package/dist/openApi/customAttributes/sapAttributes/root/extOverview.d.ts +2 -0
  51. package/dist/openApi/customAttributes/sapAttributes/root/extensible.d.ts +10 -0
  52. package/dist/openApi/customAttributes/sapAttributes/root/ordId.d.ts +6 -0
  53. package/dist/openApi/customAttributes/sapAttributes/root/stateInfo.d.ts +11 -0
  54. package/dist/openApi/customAttributes/sapAttributes/root/typeCheckXxtOverview.d.ts +10 -0
  55. package/dist/openApi/customAttributes/sapAttributes/root/typeCheckXxtOverview.spec.d.ts +1 -0
  56. package/dist/openApi/customAttributes/sapAttributes/sapPreset.d.ts +2 -0
  57. package/dist/openApi/customAttributes/sapAttributes/schema/odmEntityName.d.ts +6 -0
  58. package/dist/openApi/customAttributes/sapAttributes/schema/odmSemanticKey.d.ts +10 -0
  59. package/dist/openApi/customAttributes/types.d.ts +31 -0
  60. package/dist/openApi/index.d.ts +10 -0
  61. package/dist/openApi/styles.d.ts +2 -0
  62. package/dist/openApi/utils/context.d.ts +7 -0
  63. package/dist/openApi/utils/context.test.d.ts +1 -0
  64. package/dist/openApi/utils/plugins.d.ts +3 -0
  65. package/dist/openApi/utils/scalarTheme.d.ts +11 -0
  66. package/dist/openapi.js +2 -0
  67. package/dist/styles.d.ts +0 -0
  68. package/dist/styles.js +4 -0
  69. package/dist/theme-builder.d.ts +28 -0
  70. package/dist/types.d.ts +48 -0
  71. package/dist/vendor.d.ts +2 -0
  72. package/package.json +135 -3
@@ -0,0 +1,77 @@
1
+ import { parse } from "yaml";
2
+ //#region src/lib/core/utils.ts
3
+ function loadObject(content) {
4
+ if (!content) return;
5
+ let object;
6
+ if (content.charAt(0) === "{") try {
7
+ object = JSON.parse(content);
8
+ } catch (e) {
9
+ console.error(e);
10
+ return;
11
+ }
12
+ else try {
13
+ object = parse(content);
14
+ } catch (e) {
15
+ console.error(e);
16
+ return;
17
+ }
18
+ if (!object || typeof object !== "object") return;
19
+ return object;
20
+ }
21
+ function detectMetaType(content) {
22
+ const object = loadObject(content);
23
+ if (!object) return "unknown";
24
+ const o = object;
25
+ if (typeof o.csnInteropEffective === "string") return "csn";
26
+ if (typeof o.openapi === "string" || typeof o.swagger === "string") return "openapi";
27
+ if (typeof o.asyncapi === "string") return "asyncapi";
28
+ if (Array.isArray(o.supportedProtocolVersions)) return "mcp";
29
+ if (typeof o.capabilities === "object" && o.capabilities !== null && Array.isArray(o.skills)) return "a2a";
30
+ return "unknown";
31
+ }
32
+ function extractVersion(type, content) {
33
+ const o = loadObject(content);
34
+ if (!o) return "";
35
+ switch (type) {
36
+ case "openapi":
37
+ if (typeof o.openapi === "string") return o.openapi;
38
+ if (typeof o.swagger === "string") return "2.0";
39
+ return "";
40
+ case "asyncapi": return typeof o.asyncapi === "string" ? o.asyncapi : "";
41
+ case "a2a":
42
+ if (typeof o.protocolVersion === "string") return o.protocolVersion;
43
+ if (Array.isArray(o.supportedInterfaces) && o.supportedInterfaces.length > 0) {
44
+ const first = o.supportedInterfaces[0];
45
+ return typeof first.protocolVersion === "string" ? first.protocolVersion : "1.0.0";
46
+ }
47
+ return "0.3.0";
48
+ case "csn":
49
+ if (typeof o.$version === "string") return o.$version;
50
+ return "";
51
+ case "mcp": return Array.isArray(o.supportedProtocolVersions) && typeof o.supportedProtocolVersions[0] === "string" ? o.supportedProtocolVersions[0] : "";
52
+ default: return "";
53
+ }
54
+ }
55
+ var SHADCN_DERIVED = [
56
+ ["--ord-card", "--ord-background"],
57
+ ["--ord-card-foreground", "--ord-foreground"],
58
+ ["--ord-popover", "--ord-background"],
59
+ ["--ord-popover-foreground", "--ord-foreground"]
60
+ ];
61
+ function mapShadcnTheme(theme) {
62
+ const resolved = { ...theme };
63
+ for (const [derived, source] of SHADCN_DERIVED) if (!(derived in resolved) && source in resolved) resolved[derived] = resolved[source];
64
+ const out = {};
65
+ for (const [k, v] of Object.entries(resolved)) {
66
+ const formatted = k === "--ord-radius" ? `${v}px` : v;
67
+ out[k] = formatted;
68
+ if (k.startsWith("--ord-")) out[k.replace("--ord-", "--")] = formatted;
69
+ }
70
+ return out;
71
+ }
72
+ function buildShadcnThemeStyle(rootClass, id, theme) {
73
+ const mapped = mapShadcnTheme(theme);
74
+ return `[data-renderer-id="${id}"] .${rootClass}.ord-ui { ${Object.entries(mapped).map(([k, v]) => `${k}: ${v}`).join("; ")} }`;
75
+ }
76
+ //#endregion
77
+ export { loadObject as i, detectMetaType as n, extractVersion as r, buildShadcnThemeStyle as t };
@@ -0,0 +1,6 @@
1
+ import { ReactNode } from 'react';
2
+ export type ShadowRootProps = {
3
+ styles?: string;
4
+ children: ReactNode;
5
+ };
6
+ export declare function ShadowRoot({ styles, children }: ShadowRootProps): import("react").JSX.Element;
@@ -0,0 +1,11 @@
1
+ import { MetaType } from './utils';
2
+ import { RendererTheme, RendererMap, MetadataRendererOptions } from '../types';
3
+ export type MetadataRendererProps = {
4
+ content: string;
5
+ renderers?: RendererMap;
6
+ options?: MetadataRendererOptions;
7
+ type?: MetaType;
8
+ className?: string;
9
+ theme?: RendererTheme;
10
+ };
11
+ export declare function MetadataRenderer({ content, renderers, options, type, className, theme }: MetadataRendererProps): import("react").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { RendererTheme } from '../types';
2
+ export type MetaType = 'csn' | 'openapi' | 'asyncapi' | 'a2a' | 'mcp' | 'unknown';
3
+ export declare function loadObject(content: string): undefined | object;
4
+ export declare function detectMetaType(content: string): MetaType;
5
+ export declare function extractVersion(type: MetaType, content: string): string;
6
+ export declare function mapShadcnTheme(theme: RendererTheme): Record<string, string>;
7
+ export declare function buildShadcnThemeStyle(rootClass: string, id: string, theme: RendererTheme): string;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import { CsnAnnotationDefinition, CsnCustomAttributesConfig } from './types';
2
+ export declare function buildCsnAnnotationHtml(key: string, value: unknown, def: CsnAnnotationDefinition | undefined, config: CsnCustomAttributesConfig): string;
@@ -0,0 +1,5 @@
1
+ import { CsnCustomAttributesConfig } from './types';
2
+ type Rec = Record<string, unknown>;
3
+ export declare function discoverAnnotationKeys(doc: Rec, prefix: string): string[];
4
+ export declare function applyAnnotationRenderers(html: string, configs: CsnCustomAttributesConfig[], doc: Rec | null): string;
5
+ export {};
@@ -0,0 +1,2 @@
1
+ import { CsnCustomAttributesConfig } from './types';
2
+ export declare const sapCsnAttributesConfig: CsnCustomAttributesConfig;
@@ -0,0 +1,28 @@
1
+ export type CsnAnnotationDefinition = {
2
+ type: 'string';
3
+ label?: string;
4
+ valueLinks?: Record<string, string>;
5
+ } | {
6
+ type: 'boolean';
7
+ label?: string;
8
+ } | {
9
+ type: 'number';
10
+ label?: string;
11
+ } | {
12
+ type: 'array';
13
+ label?: string;
14
+ } | {
15
+ type: 'object';
16
+ label?: string;
17
+ } | {
18
+ type: 'link';
19
+ label?: string;
20
+ callback: (value: unknown) => string | undefined;
21
+ } | {
22
+ render: (value: unknown) => string;
23
+ };
24
+ export type CsnCustomAttributesConfig = {
25
+ prefixStartsWith?: string;
26
+ documentationUrl?: (annotationName: string) => string;
27
+ annotations?: Record<string, CsnAnnotationDefinition>;
28
+ };
@@ -0,0 +1,12 @@
1
+ import { CsnRendererConfig } from '@sap/csn-interop-renderer';
2
+ import { RendererTheme } from '../types';
3
+ import { CsnCustomAttributesConfig } from './customAttributes/types';
4
+ export type CsnRendererProps = {
5
+ content: string;
6
+ config?: CsnRendererConfig;
7
+ showCustomAttributes?: boolean;
8
+ customAttributes?: CsnCustomAttributesConfig[];
9
+ className?: string;
10
+ theme?: RendererTheme;
11
+ };
12
+ export declare function CsnRenderer({ content, config, showCustomAttributes, customAttributes, className, theme, }: CsnRendererProps): import("react").JSX.Element;
@@ -0,0 +1,2 @@
1
+ declare const _default: "\n.csn-root {\n color: var(--ord-foreground, #1a1a2e);\n background-color: var(--ord-background, #ffffff);\n container: csn / inline-size;\n /* Single font source for the whole renderer so tables, headings, paragraphs and\n custom fields stay consistent (they otherwise inherit the host page's font). */\n font-family: system-ui, -apple-system, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif;\n}\n/* Host frameworks (e.g. Docusaurus/Infima) set font-family directly on h1-h6, which\n beats inheritance from .csn-root. Re-inherit so headings match the rest of the renderer. */\n.csn-root h1,\n.csn-root h2,\n.csn-root h3,\n.csn-root h4,\n.csn-root h5,\n.csn-root h6 {\n font-family: inherit;\n}\n.csn-root table {\n border-spacing: 0;\n border-collapse: separate;\n border: solid 1px var(--ord-border, #a6a6a6);\n border-radius: calc(var(--ord-radius, 4)*1px);\n /* display: table overrides Docusaurus/Infima's global \"table { display: block }\",\n which otherwise breaks table-layout: fixed and the column widths below. */\n display: table;\n width: 100%;\n table-layout: fixed;\n overflow: hidden;\n}\n.csn-root table th {\n text-align: left;\n background-color: var(--ord-primary, #1a1a2e);\n color: var(--ord-primary-foreground, #fafafa);\n padding: 8px;\n border: 1px solid var(--ord-border, #a6a6a6);\n}\n.csn-root table td {\n text-align: start;\n padding: 8px;\n align-content: start;\n font-size: 0.875em;\n}\n.csn-root table td strong {\n font-weight: 500;\n}\n.csn-root table th:nth-child(1),\n.csn-root table td:nth-child(1) {\n width: clamp(10ch, 24cqi, 20ch);\n}\n.csn-root table th:nth-child(2),\n.csn-root table td:nth-child(2) {\n width: clamp(8ch, 19cqi, 16ch);\n}\n.csn-root table tbody td {\n color: var(--ord-foreground, #636363);\n border: 1px solid var(--ord-border, #dddfe1);\n}\n.csn-root table tbody tr {\n background-color: var(--ord-card, #f9fafb);\n}\n.csn-root table tbody tr:nth-child(odd) {\n background-color: var(--ord-background, #ffffff);\n}\n.csn-root code {\n font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, \"Liberation Mono\", monospace;\n background-color: var(--ord-code-bg, #cccccc);\n color: var(--ord-code-fg, #333333);\n}\n.csn-root a {\n color: var(--ord-accent-foreground, #375eab)\n}\n.csn-root .csn-attr-row {\n display: flex;\n gap: 0;\n margin: 6px 0;\n font-size: 0.875em;\n line-height: 1.5;\n border: 1px solid var(--ord-border, #dddfe1);\n border-radius: 4px;\n overflow: hidden;\n}\n.csn-root .csn-attr-row + br { display: none; } /* Remove br's afte attribute rows */\n.csn-root .csn-attr-label {\n width: 25%;\n min-width: 20ch;\n flex-shrink: 0;\n color: var(--ord-foreground, #1a1a2e);\n background: var(--ord-muted, #f3f4f6);\n padding: 4px 8px;\n display: inline-flex;\n align-items: center;\n gap: 4px;\n border-right: 1px solid var(--ord-border, #dddfe1);\n font-weight: 500;\n}\n.csn-root .csn-attr-value {\n color: var(--ord-muted-foreground, #6b7280);\n padding: 3px 8px;\n}\n.csn-root .csn-attr-link {\n color: var(--ord-primary, #375eab);\n text-decoration: none;\n}\n.csn-root .csn-attr-doclink {\n color: var(--ord-muted-foreground, #6b7280);\n text-decoration: none;\n font-size: 0.8em;\n margin-left: 2px;\n}\n.csn-root .csn-attr-list {\n display: flex;\n flex-direction: column;\n gap: 2px;\n}\n.csn-root .csn-attr-list-item {\n display: block;\n}\n.csn-root .csn-attr-obj {\n display: flex;\n flex-direction: column;\n gap: 2px;\n}\n.csn-root .csn-attr-kv {\n display: flex;\n gap: 4px;\n}\n.csn-root .csn-attr-kv-key {\n font-weight: 600;\n color: var(--ord-foreground, #1a1a2e);\n}\n.csn-root .csn-attr-kv-val {\n color: var(--ord-muted-foreground, #6b7280);\n}\n\n/* Width-adaptive attribute rows. Trigger is the renderer's own width (container: csn).\n Root-level annotations sit in <p> and get ~full renderer width, so they only flip to\n vertical when the renderer itself is narrow. Element-level annotations sit in a <td>\n (the Description cell) and only get the 3rd column's width, so they flip much earlier.\n (A real container on the <td> is impossible: size containment is ignored on table cells.) */\n@container csn (max-width: 420px) {\n .csn-root p .csn-attr-row {\n flex-direction: column;\n }\n .csn-root p .csn-attr-label {\n width: 100%;\n min-width: 0;\n border-right: none;\n border-bottom: 1px solid var(--ord-border, #dddfe1);\n }\n .csn-root p .csn-attr-value {\n width: 100%;\n }\n}\n@container csn (max-width: 700px) {\n .csn-root td .csn-attr-row {\n flex-direction: column;\n }\n .csn-root td .csn-attr-label {\n width: 100%;\n min-width: 0;\n border-right: none;\n border-bottom: 1px solid var(--ord-border, #dddfe1);\n }\n .csn-root td .csn-attr-value {\n width: 100%;\n }\n}\n";
2
+ export default _default;
package/dist/csn.js ADDED
@@ -0,0 +1,2 @@
1
+ import { t as CsnRenderer } from "./chunks/csn-D4GBs8tC.js";
2
+ export { CsnRenderer };
@@ -0,0 +1,2 @@
1
+ export { A2ARenderer } from '../a2a';
2
+ export type { A2ARendererProps } from '../a2a';
@@ -0,0 +1,2 @@
1
+ export { AsyncApiRenderer } from '../asyncApi';
2
+ export type { AsyncApiRendererProps } from '../asyncApi';
@@ -0,0 +1,2 @@
1
+ export { CsnRenderer } from '../csn';
2
+ export type { CsnRendererProps } from '../csn';
@@ -0,0 +1,2 @@
1
+ export { McpRenderer } from '../mcp';
2
+ export type { McpRendererProps } from '../mcp';
@@ -0,0 +1,2 @@
1
+ export { OpenApiRenderer } from '../openApi';
2
+ export type { OpenApiRendererProps } from '../openApi';
Binary file
@@ -0,0 +1,29 @@
1
+ <svg width="32" height="24" viewBox="0 0 32 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M11.0345 5.45455C11.0345 8.46701 8.56433 10.9091 5.51724 10.9091C2.47015 10.9091 0 8.46701 0 5.45455C0 2.44208 2.47015 0 5.51724 0C8.56433 0 11.0345 2.44208 11.0345 5.45455Z" fill="url(#paint0_linear_12_37)"/>
3
+ <path d="M27.5862 0H32V24H27.5862V0Z" fill="url(#paint1_linear_12_37)"/>
4
+ <path d="M18.7586 24C21.8057 24 24.2759 21.5579 24.2759 18.5455C24.2759 15.533 21.8057 13.0909 18.7586 13.0909C15.7115 13.0909 13.2414 15.533 13.2414 18.5455C13.2414 21.5579 15.7115 24 18.7586 24Z" fill="url(#paint2_linear_12_37)"/>
5
+ <path d="M11.0345 18.5455C11.0345 21.5579 8.56433 24 5.51724 24C2.47015 24 0 21.5579 0 18.5455C0 15.533 2.47015 13.0909 5.51724 13.0909C8.56433 13.0909 11.0345 15.533 11.0345 18.5455Z" fill="url(#paint3_linear_12_37)"/>
6
+ <path d="M16.3624 0.0553977L13.2414 3.14095L15.5822 5.45514L13.2414 7.76929L16.3624 10.8548L18.7032 8.5407L21.0439 10.8548L24.165 7.76929L21.8242 5.45514L24.165 3.14095L21.044 0.0553977L18.7032 2.36958L16.3624 0.0553977Z" fill="url(#paint4_linear_12_37)"/>
7
+ <defs>
8
+ <linearGradient id="paint0_linear_12_37" x1="16" y1="2.62905e-07" x2="22.9797" y2="25.3184" gradientUnits="userSpaceOnUse">
9
+ <stop stop-color="#13E5C5"/>
10
+ <stop offset="1" stop-color="#5FD2FF"/>
11
+ </linearGradient>
12
+ <linearGradient id="paint1_linear_12_37" x1="16" y1="2.62905e-07" x2="22.9797" y2="25.3184" gradientUnits="userSpaceOnUse">
13
+ <stop stop-color="#13E5C5"/>
14
+ <stop offset="1" stop-color="#5FD2FF"/>
15
+ </linearGradient>
16
+ <linearGradient id="paint2_linear_12_37" x1="16" y1="2.62905e-07" x2="22.9797" y2="25.3184" gradientUnits="userSpaceOnUse">
17
+ <stop stop-color="#13E5C5"/>
18
+ <stop offset="1" stop-color="#5FD2FF"/>
19
+ </linearGradient>
20
+ <linearGradient id="paint3_linear_12_37" x1="16" y1="2.62905e-07" x2="22.9797" y2="25.3184" gradientUnits="userSpaceOnUse">
21
+ <stop stop-color="#13E5C5"/>
22
+ <stop offset="1" stop-color="#5FD2FF"/>
23
+ </linearGradient>
24
+ <linearGradient id="paint4_linear_12_37" x1="16" y1="2.62905e-07" x2="22.9797" y2="25.3184" gradientUnits="userSpaceOnUse">
25
+ <stop stop-color="#13E5C5"/>
26
+ <stop offset="1" stop-color="#5FD2FF"/>
27
+ </linearGradient>
28
+ </defs>
29
+ </svg>