@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.
- package/LICENSE +191 -0
- package/README.md +94 -1
- package/dist/a2a/index.d.ts +9 -0
- package/dist/a2a.js +2 -0
- package/dist/asyncApi/asyncapi-browser.d.ts +3 -0
- package/dist/asyncApi/customAttributes/attributeLink.d.ts +3 -0
- package/dist/asyncApi/customAttributes/autoDiscover.d.ts +4 -0
- package/dist/asyncApi/customAttributes/buildExtensionsConfig.d.ts +5 -0
- package/dist/asyncApi/customAttributes/context.d.ts +7 -0
- package/dist/asyncApi/customAttributes/genericRenderer.d.ts +4 -0
- package/dist/asyncApi/customAttributes/sapPreset.d.ts +2 -0
- package/dist/asyncApi/customAttributes/stateInfo.d.ts +3 -0
- package/dist/asyncApi/customAttributes/styles.d.ts +2 -0
- package/dist/asyncApi/customAttributes/types.d.ts +32 -0
- package/dist/asyncApi/index.d.ts +12 -0
- package/dist/asyncapi.js +2 -0
- package/dist/chunks/a2a-B5lkgqLU.js +29 -0
- package/dist/chunks/asyncApi-K0uQpQwz.js +641 -0
- package/dist/chunks/csn-D4GBs8tC.js +548 -0
- package/dist/chunks/mcp-qA5sYRAN.js +29 -0
- package/dist/chunks/openApi-Ccp9Pa_k.js +1092 -0
- package/dist/chunks/utils-BC3WF3-9.js +77 -0
- package/dist/core/ShadowRoot.d.ts +6 -0
- package/dist/core/index.d.ts +11 -0
- package/dist/core/utils.d.ts +7 -0
- package/dist/core/utils.test.d.ts +1 -0
- package/dist/csn/customAttributes/genericRenderer.d.ts +2 -0
- package/dist/csn/customAttributes/postProcess.d.ts +5 -0
- package/dist/csn/customAttributes/sapPreset.d.ts +2 -0
- package/dist/csn/customAttributes/types.d.ts +28 -0
- package/dist/csn/index.d.ts +12 -0
- package/dist/csn/styles.d.ts +2 -0
- package/dist/csn.js +2 -0
- package/dist/entries/a2a.d.ts +2 -0
- package/dist/entries/asyncapi.d.ts +2 -0
- package/dist/entries/csn.d.ts +2 -0
- package/dist/entries/mcp.d.ts +2 -0
- package/dist/entries/openapi.d.ts +2 -0
- package/dist/favicon.ico +0 -0
- package/dist/favicon.svg +29 -0
- package/dist/index.css +210782 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +166 -0
- package/dist/mcp/index.d.ts +8 -0
- package/dist/mcp.js +2 -0
- package/dist/openApi/customAttributes/attributeLink.d.ts +3 -0
- package/dist/openApi/customAttributes/autoDiscover.d.ts +15 -0
- package/dist/openApi/customAttributes/genericRenderer.d.ts +3 -0
- package/dist/openApi/customAttributes/sapAttributes/operation/deprecatedOperation.d.ts +10 -0
- package/dist/openApi/customAttributes/sapAttributes/root/extOverview.d.ts +2 -0
- package/dist/openApi/customAttributes/sapAttributes/root/extensible.d.ts +10 -0
- package/dist/openApi/customAttributes/sapAttributes/root/ordId.d.ts +6 -0
- package/dist/openApi/customAttributes/sapAttributes/root/stateInfo.d.ts +11 -0
- package/dist/openApi/customAttributes/sapAttributes/root/typeCheckXxtOverview.d.ts +10 -0
- package/dist/openApi/customAttributes/sapAttributes/root/typeCheckXxtOverview.spec.d.ts +1 -0
- package/dist/openApi/customAttributes/sapAttributes/sapPreset.d.ts +2 -0
- package/dist/openApi/customAttributes/sapAttributes/schema/odmEntityName.d.ts +6 -0
- package/dist/openApi/customAttributes/sapAttributes/schema/odmSemanticKey.d.ts +10 -0
- package/dist/openApi/customAttributes/types.d.ts +31 -0
- package/dist/openApi/index.d.ts +10 -0
- package/dist/openApi/styles.d.ts +2 -0
- package/dist/openApi/utils/context.d.ts +7 -0
- package/dist/openApi/utils/context.test.d.ts +1 -0
- package/dist/openApi/utils/plugins.d.ts +3 -0
- package/dist/openApi/utils/scalarTheme.d.ts +11 -0
- package/dist/openapi.js +2 -0
- package/dist/styles.d.ts +0 -0
- package/dist/styles.js +4 -0
- package/dist/theme-builder.d.ts +28 -0
- package/dist/types.d.ts +48 -0
- package/dist/vendor.d.ts +2 -0
- package/package.json +135 -3
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export { MetadataRenderer } from './core';
|
|
2
|
+
export type { MetadataRendererProps } from './core';
|
|
3
|
+
export { OpenApiRenderer } from './openApi';
|
|
4
|
+
export type { OpenApiRendererProps } from './openApi';
|
|
5
|
+
export { CsnRenderer } from './csn';
|
|
6
|
+
export type { CsnRendererProps } from './csn';
|
|
7
|
+
export { AsyncApiRenderer } from './asyncApi';
|
|
8
|
+
export type { AsyncApiRendererProps } from './asyncApi';
|
|
9
|
+
export { A2ARenderer } from './a2a';
|
|
10
|
+
export type { A2ARendererProps } from './a2a';
|
|
11
|
+
export { McpRenderer } from './mcp';
|
|
12
|
+
export type { McpRendererProps } from './mcp';
|
|
13
|
+
export { detectMetaType, loadObject, extractVersion } from './core/utils';
|
|
14
|
+
export type { MetaType } from './core/utils';
|
|
15
|
+
export type { RendererTheme, RendererMap, MetadataRendererOptions, CustomAttributesOptions } from './types';
|
|
16
|
+
export { createTheme } from './theme-builder';
|
|
17
|
+
export type { ThemeTokens } from './theme-builder';
|
|
18
|
+
export type { OpenApiCustomAttributesConfig, AttributeDefinition } from './openApi/customAttributes/types';
|
|
19
|
+
export { sapOpenApiAttributesConfig } from './openApi/customAttributes/sapAttributes/sapPreset';
|
|
20
|
+
export type { AsyncApiCustomAttributesConfig, AsyncApiAttributeDefinition } from './asyncApi/customAttributes/types';
|
|
21
|
+
export { sapAsyncApiAttributesConfig } from './asyncApi/customAttributes/sapPreset';
|
|
22
|
+
export type { CsnCustomAttributesConfig, CsnAnnotationDefinition } from './csn/customAttributes/types';
|
|
23
|
+
export { sapCsnAttributesConfig } from './csn/customAttributes/sapPreset';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { i as loadObject, n as detectMetaType, r as extractVersion } from "./chunks/utils-BC3WF3-9.js";
|
|
2
|
+
import { n as sapOpenApiAttributesConfig, t as OpenApiRenderer } from "./chunks/openApi-Ccp9Pa_k.js";
|
|
3
|
+
import { n as sapCsnAttributesConfig, t as CsnRenderer } from "./chunks/csn-D4GBs8tC.js";
|
|
4
|
+
import { n as sapAsyncApiAttributesConfig, t as AsyncApiRenderer } from "./chunks/asyncApi-K0uQpQwz.js";
|
|
5
|
+
import { t as A2ARenderer } from "./chunks/a2a-B5lkgqLU.js";
|
|
6
|
+
import { t as McpRenderer } from "./chunks/mcp-qA5sYRAN.js";
|
|
7
|
+
import { useMemo } from "react";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
//#region src/lib/core/index.tsx
|
|
10
|
+
var DEFAULT_RENDERERS = {
|
|
11
|
+
openapi: OpenApiRenderer,
|
|
12
|
+
csn: CsnRenderer,
|
|
13
|
+
asyncapi: AsyncApiRenderer,
|
|
14
|
+
a2a: A2ARenderer,
|
|
15
|
+
mcp: McpRenderer
|
|
16
|
+
};
|
|
17
|
+
var PROTOCOL_LABELS = {
|
|
18
|
+
openapi: "OpenAPI",
|
|
19
|
+
csn: "CSN",
|
|
20
|
+
asyncapi: "AsyncAPI",
|
|
21
|
+
a2a: "A2A",
|
|
22
|
+
mcp: "MCP"
|
|
23
|
+
};
|
|
24
|
+
function MetadataRenderer({ content, renderers, options, type, className, theme }) {
|
|
25
|
+
const activeRenderers = renderers ?? DEFAULT_RENDERERS;
|
|
26
|
+
const autoDetect = options?.autoDetect !== false;
|
|
27
|
+
const strictTypeCheck = options?.strictTypeCheck !== false;
|
|
28
|
+
const metaType = useMemo(() => {
|
|
29
|
+
if (type) return type;
|
|
30
|
+
if (!autoDetect) return "unknown";
|
|
31
|
+
return detectMetaType(content);
|
|
32
|
+
}, [
|
|
33
|
+
type,
|
|
34
|
+
autoDetect,
|
|
35
|
+
content
|
|
36
|
+
]);
|
|
37
|
+
const detectedType = useMemo(() => {
|
|
38
|
+
if (!type || !content) return null;
|
|
39
|
+
return detectMetaType(content);
|
|
40
|
+
}, [type, content]);
|
|
41
|
+
const isMismatch = detectedType !== null && detectedType !== type && (detectedType !== "unknown" || strictTypeCheck);
|
|
42
|
+
const version = useMemo(() => extractVersion(metaType, content), [metaType, content]);
|
|
43
|
+
const label = PROTOCOL_LABELS[metaType];
|
|
44
|
+
const RendererComponent = activeRenderers[metaType];
|
|
45
|
+
let renderer;
|
|
46
|
+
if (isMismatch) {
|
|
47
|
+
const detectedLabel = detectedType === "unknown" ? "an unrecognised format" : `‘${PROTOCOL_LABELS[detectedType] ?? detectedType}’`;
|
|
48
|
+
renderer = /* @__PURE__ */ jsxs("div", {
|
|
49
|
+
style: {
|
|
50
|
+
padding: 16,
|
|
51
|
+
fontFamily: "system-ui, sans-serif"
|
|
52
|
+
},
|
|
53
|
+
children: [
|
|
54
|
+
/* @__PURE__ */ jsx("strong", { children: "Type mismatch:" }),
|
|
55
|
+
" content was detected as ",
|
|
56
|
+
detectedLabel,
|
|
57
|
+
" but ‘",
|
|
58
|
+
PROTOCOL_LABELS[type] ?? type,
|
|
59
|
+
"’ was specified."
|
|
60
|
+
]
|
|
61
|
+
});
|
|
62
|
+
} else if (RendererComponent) {
|
|
63
|
+
const extraProps = {};
|
|
64
|
+
if (metaType === "openapi") {
|
|
65
|
+
if (options?.customAttributes === false || options?.showSAPCustomFields === false) extraProps.showCustomAttributes = false;
|
|
66
|
+
else if (options?.customAttributes?.openapi) extraProps.customAttributes = options.customAttributes.openapi;
|
|
67
|
+
}
|
|
68
|
+
if (metaType === "asyncapi") {
|
|
69
|
+
if (options?.asyncapi) Object.assign(extraProps, { config: options.asyncapi });
|
|
70
|
+
if (options?.customAttributes === false) extraProps.showCustomAttributes = false;
|
|
71
|
+
else if (options?.customAttributes?.asyncapi) extraProps.customAttributes = options.customAttributes.asyncapi;
|
|
72
|
+
}
|
|
73
|
+
if (metaType === "csn") {
|
|
74
|
+
if (options?.csn) Object.assign(extraProps, { config: options.csn });
|
|
75
|
+
if (options?.customAttributes === false) extraProps.showCustomAttributes = false;
|
|
76
|
+
else if (options?.customAttributes?.csn) extraProps.customAttributes = options.customAttributes.csn;
|
|
77
|
+
}
|
|
78
|
+
if (metaType === "a2a" && options?.a2a) Object.assign(extraProps, options.a2a);
|
|
79
|
+
if (metaType === "mcp" && options?.mcp) Object.assign(extraProps, options.mcp);
|
|
80
|
+
renderer = /* @__PURE__ */ jsx(RendererComponent, {
|
|
81
|
+
content,
|
|
82
|
+
className,
|
|
83
|
+
theme,
|
|
84
|
+
...extraProps
|
|
85
|
+
});
|
|
86
|
+
} else if (options?.fallback === "raw") renderer = /* @__PURE__ */ jsx("pre", {
|
|
87
|
+
style: {
|
|
88
|
+
margin: 0,
|
|
89
|
+
padding: 16,
|
|
90
|
+
overflow: "auto",
|
|
91
|
+
height: "100%"
|
|
92
|
+
},
|
|
93
|
+
children: content
|
|
94
|
+
});
|
|
95
|
+
else renderer = /* @__PURE__ */ jsxs("div", {
|
|
96
|
+
style: {
|
|
97
|
+
padding: 16,
|
|
98
|
+
fontFamily: "system-ui, sans-serif"
|
|
99
|
+
},
|
|
100
|
+
children: [
|
|
101
|
+
/* @__PURE__ */ jsx("strong", { children: "Unsupported format:" }),
|
|
102
|
+
" No renderer registered for type ‘",
|
|
103
|
+
metaType,
|
|
104
|
+
"’."
|
|
105
|
+
]
|
|
106
|
+
});
|
|
107
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
108
|
+
style: {
|
|
109
|
+
position: "relative",
|
|
110
|
+
height: "100%",
|
|
111
|
+
...theme
|
|
112
|
+
},
|
|
113
|
+
children: [label && /* @__PURE__ */ jsxs("div", {
|
|
114
|
+
style: {
|
|
115
|
+
position: "absolute",
|
|
116
|
+
top: 8,
|
|
117
|
+
right: 8,
|
|
118
|
+
zIndex: 10,
|
|
119
|
+
padding: "2px 8px",
|
|
120
|
+
borderRadius: 4,
|
|
121
|
+
fontSize: 11,
|
|
122
|
+
fontFamily: "system-ui, sans-serif",
|
|
123
|
+
lineHeight: "16px",
|
|
124
|
+
pointerEvents: "none",
|
|
125
|
+
background: "var(--ord-muted, #e5e7eb)",
|
|
126
|
+
color: "var(--ord-muted-foreground, #6b7280)"
|
|
127
|
+
},
|
|
128
|
+
children: [label, version ? ` · ${version}` : ""]
|
|
129
|
+
}), renderer]
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region src/lib/theme-builder.ts
|
|
134
|
+
var TOKEN_MAP = {
|
|
135
|
+
background: "--ord-background",
|
|
136
|
+
foreground: "--ord-foreground",
|
|
137
|
+
primary: "--ord-primary",
|
|
138
|
+
primaryForeground: "--ord-primary-foreground",
|
|
139
|
+
secondary: "--ord-secondary",
|
|
140
|
+
secondaryForeground: "--ord-secondary-foreground",
|
|
141
|
+
muted: "--ord-muted",
|
|
142
|
+
mutedForeground: "--ord-muted-foreground",
|
|
143
|
+
accent: "--ord-accent",
|
|
144
|
+
accentForeground: "--ord-accent-foreground",
|
|
145
|
+
destructive: "--ord-destructive",
|
|
146
|
+
destructiveForeground: "--ord-destructive-foreground",
|
|
147
|
+
success: "--ord-success",
|
|
148
|
+
successForeground: "--ord-success-foreground",
|
|
149
|
+
warning: "--ord-warning",
|
|
150
|
+
warningForeground: "--ord-warning-foreground",
|
|
151
|
+
border: "--ord-border",
|
|
152
|
+
input: "--ord-input",
|
|
153
|
+
ring: "--ord-ring",
|
|
154
|
+
card: "--ord-card",
|
|
155
|
+
cardForeground: "--ord-card-foreground",
|
|
156
|
+
popover: "--ord-popover",
|
|
157
|
+
popoverForeground: "--ord-popover-foreground",
|
|
158
|
+
radius: "--ord-radius"
|
|
159
|
+
};
|
|
160
|
+
function createTheme(tokens) {
|
|
161
|
+
const result = {};
|
|
162
|
+
for (const [key, value] of Object.entries(tokens)) if (value !== void 0) result[TOKEN_MAP[key]] = value;
|
|
163
|
+
return result;
|
|
164
|
+
}
|
|
165
|
+
//#endregion
|
|
166
|
+
export { A2ARenderer, AsyncApiRenderer, CsnRenderer, McpRenderer, MetadataRenderer, OpenApiRenderer, createTheme, detectMetaType, extractVersion, loadObject, sapAsyncApiAttributesConfig, sapCsnAttributesConfig, sapOpenApiAttributesConfig };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RendererTheme } from '../types';
|
|
2
|
+
export type McpRendererProps = {
|
|
3
|
+
content: string;
|
|
4
|
+
showValidation?: boolean;
|
|
5
|
+
className?: string;
|
|
6
|
+
theme?: RendererTheme;
|
|
7
|
+
};
|
|
8
|
+
export declare function McpRenderer({ content, showValidation, className, theme }: McpRendererProps): import("react").JSX.Element;
|
package/dist/mcp.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type Rec = Record<string, unknown>;
|
|
2
|
+
export declare function discoverAttributeNames(doc: Rec, prefix: string): string[];
|
|
3
|
+
/**
|
|
4
|
+
* Synthetic property key injected into schema.properties so Scalar calls SpecificationExtension on it.
|
|
5
|
+
* The value is the full schema object; our extension component reads any x-* fields from it.
|
|
6
|
+
*/
|
|
7
|
+
export declare const SCHEMA_ATTRS_KEY = "x-sap-schema-attrs";
|
|
8
|
+
/**
|
|
9
|
+
* Clone doc and inject a synthetic property into every schema object that carries
|
|
10
|
+
* at least one key matching the given prefix. Scalar only calls SpecificationExtension
|
|
11
|
+
* on property-level schemas, so this is the only way to render schema-level x-* fields.
|
|
12
|
+
*/
|
|
13
|
+
export declare function injectSchemaExtensions(doc: Rec, prefixes: string[]): Rec;
|
|
14
|
+
export declare function extractCustomAttributeValues(doc: Rec, prefix: string): [string, unknown][];
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { JSX } from 'react';
|
|
2
|
+
import { AttributeDefinition, OpenApiCustomAttributesConfig } from './types';
|
|
3
|
+
export declare function buildGenericRenderer(fieldName: string, def: AttributeDefinition | undefined, config: OpenApiCustomAttributesConfig): (data: unknown) => JSX.Element | null;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { JSX } from 'react';
|
|
2
|
+
type Props = {
|
|
3
|
+
xSapDeprecatedOperation: {
|
|
4
|
+
deprecationDate: string;
|
|
5
|
+
successorOperationRef?: string;
|
|
6
|
+
successorOperationId?: string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export default function deprecatedOperation({ xSapDeprecatedOperation }: Props): JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { JSX } from 'react';
|
|
2
|
+
type Props = {
|
|
3
|
+
xSapExtensible: {
|
|
4
|
+
supported?: 'no' | 'manual' | 'automatic';
|
|
5
|
+
type?: 'no' | 'manual' | 'automatic';
|
|
6
|
+
description?: string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export default function extensible({ xSapExtensible }: Props): JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { JSX } from 'react';
|
|
2
|
+
type Props = {
|
|
3
|
+
xSapStateInfo: {
|
|
4
|
+
state: string;
|
|
5
|
+
deprecationDate?: string;
|
|
6
|
+
decommissionedDate?: string;
|
|
7
|
+
successorApi?: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export default function StateInfo({ xSapStateInfo }: Props): JSX.Element | null;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type ExtOverviewProps = {
|
|
2
|
+
xSapExtOverview: {
|
|
3
|
+
name: string;
|
|
4
|
+
values: string | (string | {
|
|
5
|
+
text: string;
|
|
6
|
+
format: 'plain' | 'markdown';
|
|
7
|
+
})[];
|
|
8
|
+
}[];
|
|
9
|
+
};
|
|
10
|
+
export declare function typeCheckExSapExtOverviewExSapExtOverview(obj: unknown): obj is ExtOverviewProps;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { JSX } from 'react';
|
|
2
|
+
type SemanticKeyEntry = {
|
|
3
|
+
name: string;
|
|
4
|
+
values: string[];
|
|
5
|
+
};
|
|
6
|
+
type Props = {
|
|
7
|
+
xSapOdmSemanticKey: SemanticKeyEntry[];
|
|
8
|
+
};
|
|
9
|
+
export default function odmSemanticKey({ xSapOdmSemanticKey }: Props): JSX.Element | null;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { JSX } from 'react';
|
|
2
|
+
export type AttributeDefinition = {
|
|
3
|
+
type: 'string';
|
|
4
|
+
label?: string;
|
|
5
|
+
valueLinks?: Record<string, string>;
|
|
6
|
+
} | {
|
|
7
|
+
type: 'boolean';
|
|
8
|
+
label?: string;
|
|
9
|
+
} | {
|
|
10
|
+
type: 'number';
|
|
11
|
+
label?: string;
|
|
12
|
+
} | {
|
|
13
|
+
type: 'array';
|
|
14
|
+
label?: string;
|
|
15
|
+
} | {
|
|
16
|
+
type: 'object';
|
|
17
|
+
label?: string;
|
|
18
|
+
} | {
|
|
19
|
+
type: 'link';
|
|
20
|
+
label?: string;
|
|
21
|
+
callback: (value: unknown) => string | undefined;
|
|
22
|
+
} | {
|
|
23
|
+
component: (props: unknown) => JSX.Element | null;
|
|
24
|
+
};
|
|
25
|
+
export type OpenApiCustomAttributesConfig = {
|
|
26
|
+
prefixStartsWith?: string;
|
|
27
|
+
documentationUrl?: (attributeName: string, ctx: {
|
|
28
|
+
version: string;
|
|
29
|
+
}) => string;
|
|
30
|
+
extensions?: Record<string, AttributeDefinition>;
|
|
31
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RendererTheme } from '../types';
|
|
2
|
+
import { OpenApiCustomAttributesConfig } from './customAttributes/types';
|
|
3
|
+
export type OpenApiRendererProps = {
|
|
4
|
+
content: string;
|
|
5
|
+
showCustomAttributes?: boolean;
|
|
6
|
+
customAttributes?: OpenApiCustomAttributesConfig[];
|
|
7
|
+
className?: string;
|
|
8
|
+
theme?: RendererTheme;
|
|
9
|
+
};
|
|
10
|
+
export declare function OpenApiRenderer({ content, showCustomAttributes, customAttributes, className, theme, }: OpenApiRendererProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: "\n.sap-api-container {\n display: flex;\n flex-wrap: wrap;\n container-type: inline-size;\n border: var(--scalar-border-width) solid var(--scalar-border-color);\n border-radius: var(--scalar-radius-lg);\n margin-top: 8px;\n font-size: var(--scalar-small);\n line-height: var(--scalar-line-height-3);\n overflow: hidden;\n}\n\n.sap-api-label {\n color: var(--scalar-color-1);\n width: 30%;\n min-width: 20ch;\n flex-shrink: 0;\n background: var(--scalar-background-2);\n padding: 6px 9px 6px 12px;\n border-right: var(--scalar-border-width) solid var(--scalar-border-color);\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n font-weight: 500;\n}\n\n.sap-api-label--root {\n min-width: 20ch;\n}\n\n.sap-api-value {\n color: var(--scalar-color-2);\n padding: 8px;\n flex: 1 1 0;\n min-width: 0;\n}\n\n.sap-api-value--root {\n flex: 1 1 0;\n min-width: 0;\n}\n\n.sap-api-list {\n margin: 0 2ch;\n list-style: disc;\n}\n\n.sap-api-link {\n text-decoration: none;\n color: var(--scalar-link-color);\n transition: color 0.1s ease-in-out;\n cursor: pointer;\n}\n\n.sap-api-ord-id {\n display: flex;\n align-items: flex-start;\n gap: 8px;\n}\n\n.sap-api-ord-id-text {\n flex: 1 1 auto;\n min-width: 0;\n word-break: break-all;\n}\n\n.sap-api-copy-btn {\n flex-shrink: 0;\n cursor: pointer;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n font-size: 1em;\n line-height: 1;\n padding: 4px;\n color: var(--scalar-color-2);\n background: var(--scalar-background-2);\n border: var(--scalar-border-width) solid var(--scalar-border-color);\n border-radius: var(--scalar-radius);\n transition: background 0.1s ease-in-out, color 0.1s ease-in-out;\n}\n\n.sap-api-copy-btn:hover {\n background: var(--scalar-background-3);\n color: var(--scalar-color-1);\n}\n\n.sap-api-placeholder {\n color: #999;\n}\n\n.sap-api-obj {\n margin: 0;\n padding-left: 12px;\n}\n\n.sap-api-obj-row {\n margin-bottom: 4px;\n}\n\n.sap-api-obj-key {\n font-weight: 600;\n display: inline;\n}\n\n.sap-api-obj-val {\n display: inline;\n margin: 0;\n}\n\n/* Width-adaptive rows: react to the row's own available width (container-type above).\n When the row is narrow, label and value wrap onto separate lines (label above value). */\n@container (max-width: 420px) {\n .sap-api-label,\n .sap-api-label--root {\n flex-basis: 100%;\n width: 100%;\n min-width: 0;\n border-right: none;\n border-bottom: var(--scalar-border-width) solid var(--scalar-border-color);\n }\n .sap-api-value,\n .sap-api-value--root {\n flex-basis: 100%;\n width: 100%;\n }\n}\n\na {\n text-decoration: none;\n color: var(--sapLinkColor);\n transition: color 0.1s ease-in-out;\n cursor: pointer;\n}\na:hover {\n text-decoration: underline;\n}\n\n/* Keyboard key: use Scalar background instead of Infima colors */\n.scalar-app kbd {\n background: var(--scalar-background-1);\n color: var(--scalar-color-1);\n border: 1px solid var(--scalar-border-color);\n}\n\n/* Syntax highlighting \u2014 override --scalar-color-* with ThemeEditor --ord-hljs-* tokens */\n.scalar-app .hljs-attr,\n.scalar-app .hljs-attribute { color: var(--ord-hljs-attr); }\n\n.scalar-app .hljs-string,\n.scalar-app .hljs-regexp,\n.scalar-app .hljs-subst,\n.scalar-app .hljs-doctag,\n.scalar-app .hljs-bullet,\n.scalar-app .hljs-link,\n.scalar-app .hljs-meta,\n.scalar-app .hljs-symbol { color: var(--ord-hljs-string); }\n\n.scalar-app .hljs-number,\n.scalar-app .hljs-selector-attr,\n.scalar-app .hljs-selector-pseudo,\n.scalar-app .hljs-built_in { color: var(--ord-hljs-number); }\n\n.scalar-app .hljs-title.function_ { color: var(--ord-hljs-function); }\n\n.scalar-app .hljs-addition,\n.scalar-app .hljs-literal,\n.scalar-app .hljs-selector-tag,\n.scalar-app .hljs-type { color: var(--ord-hljs-literal); }\n\n.scalar-app .hljs-keyword { color: var(--ord-hljs-keyword); }\n\n.scalar-app .hljs-comment,\n.scalar-app .hljs-quote { color: var(--ord-hljs-comment); }\n\n.scalar-app .hljs-punctuation { color: var(--ord-hljs-punctuation); }\n\n/* Hide the \"x-sap-schema-attrs\" property heading row \u2014 the row exists only to\n carry schema-level extension components; the key name should not be visible. */\n.scalar-app .property:has(.sap-schema-attrs-block) {\n padding-top: 2px;\n}\n.scalar-app .property:has(.sap-schema-attrs-block) .property-heading {\n display: none;\n}\n\n/* Override Scalar's sidebar height variable so the <aside> uses our measured container height\n instead of Scalar's default 100dvh (which breaks when embedded in Docusaurus/non-fullscreen). */\n.scalar-app {\n --refs-sidebar-height: calc(var(--scalar-container-height, 100dvh) - var(--refs-header-height, 0px));\n}\n";
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { OpenApiCustomAttributesConfig } from '../customAttributes/types';
|
|
2
|
+
export declare const openApiContext: {
|
|
3
|
+
version: string;
|
|
4
|
+
configs: OpenApiCustomAttributesConfig[];
|
|
5
|
+
getDocumentationUrl(attributeName: string): string | undefined;
|
|
6
|
+
};
|
|
7
|
+
export declare const getVersion: (content: string) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ApiReferencePlugin } from '@scalar/types/api-reference';
|
|
2
|
+
import { OpenApiCustomAttributesConfig } from '../customAttributes/types';
|
|
3
|
+
export declare function buildCustomAttributesPlugin(doc: Record<string, unknown> | undefined, configs: OpenApiCustomAttributesConfig[]): ApiReferencePlugin;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface ThemeAdapter {
|
|
2
|
+
selector: string;
|
|
3
|
+
map(canonical: Record<string, string>): Record<string, string>;
|
|
4
|
+
}
|
|
5
|
+
export declare const scalarAdapter: ThemeAdapter;
|
|
6
|
+
export declare const scalarSidebarAdapter: ThemeAdapter;
|
|
7
|
+
export declare const scalarModeAdapter: ThemeAdapter;
|
|
8
|
+
export declare const scalarHljsAdapter: ThemeAdapter;
|
|
9
|
+
export declare const scalarTeleportAdapter: ThemeAdapter;
|
|
10
|
+
export declare function buildScalarThemeStyles(id: string, theme: Record<string, string>): string;
|
|
11
|
+
export {};
|
package/dist/openapi.js
ADDED
package/dist/styles.d.ts
ADDED
|
File without changes
|
package/dist/styles.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { RendererTheme } from './types';
|
|
2
|
+
export interface ThemeTokens {
|
|
3
|
+
background?: string;
|
|
4
|
+
foreground?: string;
|
|
5
|
+
primary?: string;
|
|
6
|
+
primaryForeground?: string;
|
|
7
|
+
secondary?: string;
|
|
8
|
+
secondaryForeground?: string;
|
|
9
|
+
muted?: string;
|
|
10
|
+
mutedForeground?: string;
|
|
11
|
+
accent?: string;
|
|
12
|
+
accentForeground?: string;
|
|
13
|
+
destructive?: string;
|
|
14
|
+
destructiveForeground?: string;
|
|
15
|
+
success?: string;
|
|
16
|
+
successForeground?: string;
|
|
17
|
+
warning?: string;
|
|
18
|
+
warningForeground?: string;
|
|
19
|
+
border?: string;
|
|
20
|
+
input?: string;
|
|
21
|
+
ring?: string;
|
|
22
|
+
card?: string;
|
|
23
|
+
cardForeground?: string;
|
|
24
|
+
popover?: string;
|
|
25
|
+
popoverForeground?: string;
|
|
26
|
+
radius?: string;
|
|
27
|
+
}
|
|
28
|
+
export declare function createTheme(tokens: ThemeTokens): RendererTheme;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ComponentType } from 'react';
|
|
2
|
+
import { CsnRendererConfig } from '@sap/csn-interop-renderer';
|
|
3
|
+
import { ConfigInterface } from '@asyncapi/react-component';
|
|
4
|
+
import { MetaType } from './core/utils';
|
|
5
|
+
import { OpenApiCustomAttributesConfig } from './openApi/customAttributes/types';
|
|
6
|
+
import { AsyncApiCustomAttributesConfig } from './asyncApi/customAttributes/types';
|
|
7
|
+
import { CsnCustomAttributesConfig } from './csn/customAttributes/types';
|
|
8
|
+
export type CustomAttributesOptions = {
|
|
9
|
+
openapi?: OpenApiCustomAttributesConfig[];
|
|
10
|
+
asyncapi?: AsyncApiCustomAttributesConfig[];
|
|
11
|
+
csn?: CsnCustomAttributesConfig[];
|
|
12
|
+
};
|
|
13
|
+
export type RendererTheme = Partial<Record<`--ord-${string}`, string>>;
|
|
14
|
+
export type RendererEntry = ComponentType<{
|
|
15
|
+
content: string;
|
|
16
|
+
className?: string;
|
|
17
|
+
theme?: RendererTheme;
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
}>;
|
|
20
|
+
export type RendererMap = Partial<Record<MetaType, RendererEntry>>;
|
|
21
|
+
export type MetadataRendererOptions = {
|
|
22
|
+
/** Auto-detect format from content when `type` prop is absent. Default: true. */
|
|
23
|
+
autoDetect?: boolean;
|
|
24
|
+
/** What to show for unresolved/disabled types. Default: 'error'. */
|
|
25
|
+
fallback?: 'error' | 'raw';
|
|
26
|
+
/**
|
|
27
|
+
* When `type` is explicitly set and content is not detected as that type,
|
|
28
|
+
* show an error instead of passing content to the renderer. Default: true.
|
|
29
|
+
*/
|
|
30
|
+
strictTypeCheck?: boolean;
|
|
31
|
+
/** @deprecated Use `customAttributes.openapi` instead. */
|
|
32
|
+
showSAPCustomFields?: boolean;
|
|
33
|
+
/** Custom attribute renderers per protocol. Pass `false` to disable all. Default: SAP preset for OpenAPI. */
|
|
34
|
+
customAttributes?: CustomAttributesOptions | false;
|
|
35
|
+
/** Passed through to CsnRenderer. */
|
|
36
|
+
csn?: CsnRendererConfig;
|
|
37
|
+
/** Passed through to AsyncApiRenderer. */
|
|
38
|
+
asyncapi?: Partial<ConfigInterface>;
|
|
39
|
+
/** Passed through to A2ARenderer. */
|
|
40
|
+
a2a?: {
|
|
41
|
+
showValidation?: boolean;
|
|
42
|
+
showConnection?: boolean;
|
|
43
|
+
};
|
|
44
|
+
/** Passed through to McpRenderer. */
|
|
45
|
+
mcp?: {
|
|
46
|
+
showValidation?: boolean;
|
|
47
|
+
};
|
|
48
|
+
};
|
package/dist/vendor.d.ts
ADDED
package/package.json
CHANGED
|
@@ -1,5 +1,137 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
"name": "@open-resource-discovery/metadata-renderer",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "React components that render OpenAPI, CSN, AsyncAPI, A2A, and MCP metadata documents.",
|
|
5
|
+
"author": "SAP SE",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/open-resource-discovery/metadata-renderer"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"metadata",
|
|
13
|
+
"renderer",
|
|
14
|
+
"react",
|
|
15
|
+
"openapi",
|
|
16
|
+
"swagger",
|
|
17
|
+
"csn",
|
|
18
|
+
"asyncapi",
|
|
19
|
+
"a2a",
|
|
20
|
+
"mcp"
|
|
21
|
+
],
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=22",
|
|
24
|
+
"npm": ">=10"
|
|
25
|
+
},
|
|
26
|
+
"type": "module",
|
|
27
|
+
"scarfSettings": {
|
|
28
|
+
"enabled": false
|
|
29
|
+
},
|
|
30
|
+
"main": "./dist/index.js",
|
|
31
|
+
"module": "./dist/index.js",
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"sideEffects": [
|
|
34
|
+
"**/*.css"
|
|
35
|
+
],
|
|
36
|
+
"exports": {
|
|
37
|
+
"./package.json": "./package.json",
|
|
38
|
+
".": {
|
|
39
|
+
"types": "./dist/index.d.ts",
|
|
40
|
+
"import": "./dist/index.js",
|
|
41
|
+
"default": "./dist/index.js"
|
|
42
|
+
},
|
|
43
|
+
"./openapi": {
|
|
44
|
+
"types": "./dist/entries/openapi.d.ts",
|
|
45
|
+
"import": "./dist/openapi.js",
|
|
46
|
+
"default": "./dist/openapi.js"
|
|
47
|
+
},
|
|
48
|
+
"./csn": {
|
|
49
|
+
"types": "./dist/entries/csn.d.ts",
|
|
50
|
+
"import": "./dist/csn.js",
|
|
51
|
+
"default": "./dist/csn.js"
|
|
52
|
+
},
|
|
53
|
+
"./asyncapi": {
|
|
54
|
+
"types": "./dist/entries/asyncapi.d.ts",
|
|
55
|
+
"import": "./dist/asyncapi.js",
|
|
56
|
+
"default": "./dist/asyncapi.js"
|
|
57
|
+
},
|
|
58
|
+
"./a2a": {
|
|
59
|
+
"types": "./dist/entries/a2a.d.ts",
|
|
60
|
+
"import": "./dist/a2a.js",
|
|
61
|
+
"default": "./dist/a2a.js"
|
|
62
|
+
},
|
|
63
|
+
"./mcp": {
|
|
64
|
+
"types": "./dist/entries/mcp.d.ts",
|
|
65
|
+
"import": "./dist/mcp.js",
|
|
66
|
+
"default": "./dist/mcp.js"
|
|
67
|
+
},
|
|
68
|
+
"./styles": "./dist/index.css"
|
|
69
|
+
},
|
|
70
|
+
"files": [
|
|
71
|
+
"dist",
|
|
72
|
+
"README.md"
|
|
73
|
+
],
|
|
74
|
+
"publishConfig": {
|
|
75
|
+
"access": "public"
|
|
76
|
+
},
|
|
77
|
+
"scripts": {
|
|
78
|
+
"dev": "vite",
|
|
79
|
+
"build": "tsc -b && vite build --mode lib",
|
|
80
|
+
"build:lib:watch": "vite build --mode lib --watch",
|
|
81
|
+
"build:demo": "vite build",
|
|
82
|
+
"website:start": "npm --prefix website run start",
|
|
83
|
+
"website:build": "npm --prefix website run build",
|
|
84
|
+
"preview": "vite preview",
|
|
85
|
+
"typecheck": "tsc -b --noEmit",
|
|
86
|
+
"test": "vitest run",
|
|
87
|
+
"test:watch": "vitest",
|
|
88
|
+
"lint": "npm run eslint:ci",
|
|
89
|
+
"eslint": "eslint . --fix",
|
|
90
|
+
"eslint:ci": "eslint .",
|
|
91
|
+
"prettier": "prettier --write .",
|
|
92
|
+
"prettier:ci": "prettier --check .",
|
|
93
|
+
"format": "npm run prettier && npm run eslint",
|
|
94
|
+
"format:check": "npm run prettier:ci && npm run eslint:ci",
|
|
95
|
+
"prepack": "npm run build"
|
|
96
|
+
},
|
|
97
|
+
"peerDependencies": {
|
|
98
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
99
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
100
|
+
},
|
|
101
|
+
"dependencies": {
|
|
102
|
+
"@asyncapi/react-component": "^3.1.3",
|
|
103
|
+
"@open-resource-discovery/a2a-editor": "^0.4.2",
|
|
104
|
+
"@open-resource-discovery/mcp-server-card-ui": "0.2.1",
|
|
105
|
+
"@sap/csn-interop-renderer": "0.5.0",
|
|
106
|
+
"@scalar/api-reference-react": "^0.9.54",
|
|
107
|
+
"@scalar/react-renderer": "^0.4.1",
|
|
108
|
+
"@scalar/types": "^0.16.2",
|
|
109
|
+
"react-error-boundary": "^6.0.0",
|
|
110
|
+
"react-markdown": "^10.1.0",
|
|
111
|
+
"yaml": "^2.8.1"
|
|
112
|
+
},
|
|
113
|
+
"overrides": {
|
|
114
|
+
"dompurify": ">=3.4.12",
|
|
115
|
+
"fast-uri": ">=3.1.5",
|
|
116
|
+
"undici": ">=7.29.0 <8",
|
|
117
|
+
"postcss": ">=8.5.23",
|
|
118
|
+
"brace-expansion": ">=1.1.18"
|
|
119
|
+
},
|
|
120
|
+
"devDependencies": {
|
|
121
|
+
"@sap/eslint-config": "0.5.2",
|
|
122
|
+
"@types/node": "24.13.3",
|
|
123
|
+
"@types/react": "19.2.17",
|
|
124
|
+
"@types/react-dom": "19.2.3",
|
|
125
|
+
"@vitejs/plugin-react": "6.0.5",
|
|
126
|
+
"eslint": "10.6.0",
|
|
127
|
+
"jsdom": "29.1.1",
|
|
128
|
+
"jsonc-eslint-parser": "3.1.0",
|
|
129
|
+
"prettier": "3.9.6",
|
|
130
|
+
"react": "19.2.8",
|
|
131
|
+
"react-dom": "19.2.8",
|
|
132
|
+
"typescript": "5.9.3",
|
|
133
|
+
"vite": "8.1.5",
|
|
134
|
+
"vite-plugin-dts": "4.5.4",
|
|
135
|
+
"vitest": "3.2.7"
|
|
136
|
+
}
|
|
5
137
|
}
|