@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,641 @@
1
+ import { i as loadObject } from "./utils-BC3WF3-9.js";
2
+ /* empty css */
3
+ import { createElement, useId, useMemo } from "react";
4
+ import Markdown from "react-markdown";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ import AsyncApiComponent from "@asyncapi/react-component/browser/index.js";
7
+ import { PluginSlot } from "@asyncapi/react-component";
8
+ //#region src/lib/asyncApi/customAttributes/context.ts
9
+ var asyncApiContext = {
10
+ version: "",
11
+ configs: [],
12
+ rootFields: {},
13
+ getDocumentationUrl(fieldName) {
14
+ return (this.configs.find((c) => c.extensions?.[fieldName]) ?? this.configs.find((c) => c.prefixStartsWith && fieldName.startsWith(c.prefixStartsWith)))?.documentationUrl?.(fieldName, { version: this.version });
15
+ }
16
+ };
17
+ //#endregion
18
+ //#region src/lib/asyncApi/customAttributes/attributeLink.tsx
19
+ function AttributeLink({ attributeName }) {
20
+ const href = asyncApiContext.getDocumentationUrl(attributeName);
21
+ if (!href) return null;
22
+ return /* @__PURE__ */ jsx("a", {
23
+ href,
24
+ style: {
25
+ marginLeft: 4,
26
+ marginTop: 4
27
+ },
28
+ target: "_blank",
29
+ rel: "noreferrer",
30
+ title: "View in AsyncAPI Specification",
31
+ children: /* @__PURE__ */ jsx("svg", {
32
+ width: "16",
33
+ height: "16",
34
+ viewBox: "0 0 16 16",
35
+ fill: "currentColor",
36
+ children: /* @__PURE__ */ jsx("path", { d: "M10.604 1h4.146a.25.25 0 01.25.25v4.146a.25.25 0 01-.427.177L13.03 4.03 9.28 7.78a.75.75 0 01-1.06-1.06l3.75-3.75-1.543-1.543A.25.25 0 0110.604 1zM3.75 2A1.75 1.75 0 002 3.75v8.5c0 .966.784 1.75 1.75 1.75h8.5A1.75 1.75 0 0014 12.25v-3.5a.75.75 0 00-1.5 0v3.5a.25.25 0 01-.25.25h-8.5a.25.25 0 01-.25-.25v-8.5a.25.25 0 01.25-.25h3.5a.75.75 0 000-1.5h-3.5z" })
37
+ })
38
+ });
39
+ }
40
+ //#endregion
41
+ //#region src/lib/asyncApi/customAttributes/genericRenderer.tsx
42
+ function autoLabel(fieldName, prefix) {
43
+ let name = fieldName;
44
+ if (prefix && name.startsWith(prefix)) name = name.slice(prefix.length);
45
+ return name.replace(/([a-z])([A-Z])/g, "$1-$2").split("-").filter(Boolean).map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
46
+ }
47
+ function Label({ name, label }) {
48
+ return /* @__PURE__ */ jsxs("div", {
49
+ className: "asyncapi-attr-label",
50
+ children: [
51
+ label,
52
+ " ",
53
+ /* @__PURE__ */ jsx(AttributeLink, { attributeName: name })
54
+ ]
55
+ });
56
+ }
57
+ function renderObjectValue(val) {
58
+ if (val === null || val === void 0) return /* @__PURE__ */ jsx("span", {
59
+ className: "asyncapi-attr-placeholder",
60
+ children: "—"
61
+ });
62
+ if (typeof val === "boolean") return /* @__PURE__ */ jsx("span", { children: val ? "Yes" : "No" });
63
+ if (typeof val === "number") return /* @__PURE__ */ jsx("span", { children: val });
64
+ if (Array.isArray(val)) return /* @__PURE__ */ jsx("ul", {
65
+ className: "asyncapi-attr-list",
66
+ children: val.map((item, i) => /* @__PURE__ */ jsx("li", { children: renderObjectValue(item) }, i))
67
+ });
68
+ if (typeof val === "object") return /* @__PURE__ */ jsx("dl", {
69
+ className: "asyncapi-attr-obj",
70
+ children: Object.entries(val).map(([k, v]) => /* @__PURE__ */ jsxs("div", {
71
+ className: "asyncapi-attr-obj-row",
72
+ children: [
73
+ /* @__PURE__ */ jsxs("dt", {
74
+ className: "asyncapi-attr-obj-key",
75
+ children: [k, ":"]
76
+ }),
77
+ " ",
78
+ /* @__PURE__ */ jsx("dd", {
79
+ className: "asyncapi-attr-obj-val",
80
+ children: renderObjectValue(v)
81
+ })
82
+ ]
83
+ }, k))
84
+ });
85
+ const str = String(val);
86
+ return /[*_`[\]#]/.test(str) ? /* @__PURE__ */ jsx(Markdown, { children: str }) : /* @__PURE__ */ jsx("span", { children: str });
87
+ }
88
+ function StringRenderer(props) {
89
+ const link = props.valueLinks?.[props.value];
90
+ return /* @__PURE__ */ jsxs("div", {
91
+ className: "asyncapi-attr-row",
92
+ children: [/* @__PURE__ */ jsx(Label, {
93
+ name: props.name,
94
+ label: props.label
95
+ }), /* @__PURE__ */ jsx("p", {
96
+ className: "asyncapi-attr-value",
97
+ children: link ? /* @__PURE__ */ jsx("a", {
98
+ href: link,
99
+ rel: "noreferrer noopener",
100
+ target: "_blank",
101
+ className: "asyncapi-attr-link",
102
+ children: props.value
103
+ }) : props.value
104
+ })]
105
+ });
106
+ }
107
+ function BooleanRenderer(props) {
108
+ return /* @__PURE__ */ jsxs("div", {
109
+ className: "asyncapi-attr-row",
110
+ children: [/* @__PURE__ */ jsx(Label, {
111
+ name: props.name,
112
+ label: props.label
113
+ }), /* @__PURE__ */ jsx("p", {
114
+ className: "asyncapi-attr-value",
115
+ children: props.value ? "Yes" : "No"
116
+ })]
117
+ });
118
+ }
119
+ function NumberRenderer(props) {
120
+ return /* @__PURE__ */ jsxs("div", {
121
+ className: "asyncapi-attr-row",
122
+ children: [/* @__PURE__ */ jsx(Label, {
123
+ name: props.name,
124
+ label: props.label
125
+ }), /* @__PURE__ */ jsx("p", {
126
+ className: "asyncapi-attr-value",
127
+ children: props.value
128
+ })]
129
+ });
130
+ }
131
+ function ArrayRenderer(props) {
132
+ return /* @__PURE__ */ jsxs("div", {
133
+ className: "asyncapi-attr-row",
134
+ children: [/* @__PURE__ */ jsx(Label, {
135
+ name: props.name,
136
+ label: props.label
137
+ }), /* @__PURE__ */ jsx("div", {
138
+ className: "asyncapi-attr-value",
139
+ children: /* @__PURE__ */ jsx("ul", {
140
+ className: "asyncapi-attr-list",
141
+ children: props.value.map((item, i) => /* @__PURE__ */ jsx("li", { children: renderObjectValue(item) }, i))
142
+ })
143
+ })]
144
+ });
145
+ }
146
+ function ObjectRenderer(props) {
147
+ return /* @__PURE__ */ jsxs("div", {
148
+ className: "asyncapi-attr-row",
149
+ children: [/* @__PURE__ */ jsx(Label, {
150
+ name: props.name,
151
+ label: props.label
152
+ }), /* @__PURE__ */ jsx("div", {
153
+ className: "asyncapi-attr-value",
154
+ children: renderObjectValue(props.value)
155
+ })]
156
+ });
157
+ }
158
+ function LinkRenderer(props) {
159
+ const href = props.callback(props.value);
160
+ return /* @__PURE__ */ jsxs("div", {
161
+ className: "asyncapi-attr-row",
162
+ children: [/* @__PURE__ */ jsx(Label, {
163
+ name: props.name,
164
+ label: props.label
165
+ }), /* @__PURE__ */ jsx("p", {
166
+ className: "asyncapi-attr-value",
167
+ children: href ? /* @__PURE__ */ jsx("a", {
168
+ href,
169
+ rel: "noreferrer noopener",
170
+ target: "_blank",
171
+ className: "asyncapi-attr-link",
172
+ children: String(props.value)
173
+ }) : String(props.value)
174
+ })]
175
+ });
176
+ }
177
+ function buildAsyncApiGenericRenderer(fieldName, def, config) {
178
+ if (def && "component" in def) return def.component;
179
+ return function AsyncApiFieldRenderer({ propertyValue }) {
180
+ const value = propertyValue;
181
+ if (value === void 0 || value === null) return null;
182
+ const label = def && "label" in def && def.label ? def.label : autoLabel(fieldName, config.prefixStartsWith);
183
+ if (def?.type === "link") return /* @__PURE__ */ jsx(LinkRenderer, {
184
+ name: fieldName,
185
+ label,
186
+ value,
187
+ callback: def.callback
188
+ });
189
+ if (def?.type === "boolean" || typeof value === "boolean") return /* @__PURE__ */ jsx(BooleanRenderer, {
190
+ name: fieldName,
191
+ label,
192
+ value: Boolean(value)
193
+ });
194
+ if (def?.type === "number" || typeof value === "number") return /* @__PURE__ */ jsx(NumberRenderer, {
195
+ name: fieldName,
196
+ label,
197
+ value
198
+ });
199
+ if (def?.type === "array" || Array.isArray(value)) {
200
+ if (!Array.isArray(value)) return null;
201
+ return /* @__PURE__ */ jsx(ArrayRenderer, {
202
+ name: fieldName,
203
+ label,
204
+ value
205
+ });
206
+ }
207
+ if (def?.type === "object" || typeof value === "object") return /* @__PURE__ */ jsx(ObjectRenderer, {
208
+ name: fieldName,
209
+ label,
210
+ value
211
+ });
212
+ const valueLinks = def && "valueLinks" in def ? def.valueLinks : void 0;
213
+ return /* @__PURE__ */ jsx(StringRenderer, {
214
+ name: fieldName,
215
+ label,
216
+ value: String(value),
217
+ valueLinks
218
+ });
219
+ };
220
+ }
221
+ //#endregion
222
+ //#region src/lib/asyncApi/customAttributes/autoDiscover.ts
223
+ var ASYNCAPI_ROOT_KEYS = /* @__PURE__ */ new Set([
224
+ "asyncapi",
225
+ "info",
226
+ "channels",
227
+ "operations",
228
+ "components",
229
+ "servers",
230
+ "tags",
231
+ "id",
232
+ "defaultContentType",
233
+ "externalDocs"
234
+ ]);
235
+ function discoverAsyncApiFieldNames(doc, prefix) {
236
+ const names = /* @__PURE__ */ new Set();
237
+ const addKeys = (obj) => {
238
+ if (!obj || typeof obj !== "object") return;
239
+ for (const key of Object.keys(obj)) if (key.startsWith(prefix)) names.add(key);
240
+ };
241
+ addKeys(doc);
242
+ addKeys(doc.info);
243
+ const channels = doc.channels;
244
+ if (channels) for (const channel of Object.values(channels)) {
245
+ if (!channel || typeof channel !== "object") continue;
246
+ const ch = channel;
247
+ addKeys(ch);
248
+ for (const op of [
249
+ "subscribe",
250
+ "publish",
251
+ "send",
252
+ "receive"
253
+ ]) {
254
+ const operation = ch[op];
255
+ if (!operation || typeof operation !== "object") continue;
256
+ addKeys(operation);
257
+ addKeys(operation.message);
258
+ }
259
+ const msgs = ch.messages;
260
+ if (msgs) for (const msg of Object.values(msgs)) addKeys(msg);
261
+ }
262
+ const operations = doc.operations;
263
+ if (operations) for (const op of Object.values(operations)) addKeys(op);
264
+ const components = doc.components;
265
+ if (components) {
266
+ for (const section of ["messages", "messageTraits"]) {
267
+ const msgs = components[section];
268
+ if (msgs) for (const msg of Object.values(msgs)) addKeys(msg);
269
+ }
270
+ const schemas = components.schemas;
271
+ if (schemas) for (const schema of Object.values(schemas)) addKeys(schema);
272
+ const compChannels = components.channels;
273
+ if (compChannels) for (const ch of Object.values(compChannels)) addKeys(ch);
274
+ const compOps = components.operations;
275
+ if (compOps) for (const op of Object.values(compOps)) addKeys(op);
276
+ }
277
+ return [...names];
278
+ }
279
+ function extractRootFields(doc, prefixes) {
280
+ const result = {};
281
+ for (const [key, value] of Object.entries(doc)) {
282
+ if (ASYNCAPI_ROOT_KEYS.has(key)) continue;
283
+ if (!key.startsWith("x-")) continue;
284
+ if (prefixes.some((p) => key.startsWith(p))) result[key] = value;
285
+ }
286
+ return result;
287
+ }
288
+ //#endregion
289
+ //#region src/lib/asyncApi/customAttributes/buildExtensionsConfig.ts
290
+ function buildAsyncApiExtensionsConfig(configs, doc, version) {
291
+ asyncApiContext.version = version;
292
+ asyncApiContext.configs = configs;
293
+ if (doc) {
294
+ const prefixes = configs.map((c) => c.prefixStartsWith).filter(Boolean);
295
+ asyncApiContext.rootFields = prefixes.length ? extractRootFields(doc, prefixes) : {};
296
+ } else asyncApiContext.rootFields = {};
297
+ const result = {};
298
+ for (const config of configs) {
299
+ for (const [key, def] of Object.entries(config.extensions ?? {})) result[key] = buildAsyncApiGenericRenderer(key, def, config);
300
+ if (config.prefixStartsWith && doc) {
301
+ for (const key of discoverAsyncApiFieldNames(doc, config.prefixStartsWith)) if (!result[key]) result[key] = buildAsyncApiGenericRenderer(key, void 0, config);
302
+ }
303
+ }
304
+ return result;
305
+ }
306
+ function buildRootExtensionsPlugin(configs) {
307
+ function rootExtensionsSlot(_props) {
308
+ const entries = Object.entries(asyncApiContext.rootFields);
309
+ if (!entries.length) return null;
310
+ const nodes = entries.flatMap(([key, value]) => {
311
+ const config = asyncApiContext.configs.find((c) => c.extensions?.[key]) ?? asyncApiContext.configs.find((c) => c.prefixStartsWith && key.startsWith(c.prefixStartsWith)) ?? configs[0];
312
+ if (!config) return [];
313
+ const def = config.extensions?.[key];
314
+ return [createElement(buildAsyncApiGenericRenderer(key, def, config), {
315
+ key,
316
+ propertyName: key,
317
+ propertyValue: value,
318
+ document: void 0,
319
+ parent: void 0
320
+ })];
321
+ });
322
+ return nodes.length ? createElement("div", null, ...nodes) : null;
323
+ }
324
+ return {
325
+ name: "sap-root-extensions",
326
+ version: "1.0.0",
327
+ install(api) {
328
+ api.registerComponent(PluginSlot.INFO, rootExtensionsSlot);
329
+ }
330
+ };
331
+ }
332
+ //#endregion
333
+ //#region src/lib/asyncApi/customAttributes/stateInfo.tsx
334
+ var background = {
335
+ ACTIVE: "color-mix(in srgb, #22c55e 15%, transparent)",
336
+ BETA: "color-mix(in srgb, #3b82f6 15%, transparent)",
337
+ DEPRECATED: "color-mix(in srgb, #f97316 15%, transparent)",
338
+ DECOMMISSIONED: "color-mix(in srgb, #ef4444 15%, transparent)"
339
+ };
340
+ var color = {
341
+ ACTIVE: "#16a34a",
342
+ BETA: "#2563eb",
343
+ DEPRECATED: "#ea580c",
344
+ DECOMMISSIONED: "#dc2626"
345
+ };
346
+ function AsyncApiStateInfo({ propertyName, propertyValue }) {
347
+ if (!propertyValue || typeof propertyValue !== "object") return null;
348
+ const info = propertyValue;
349
+ const status = info.state?.toUpperCase();
350
+ const badge = /* @__PURE__ */ jsx("span", {
351
+ style: {
352
+ display: "inline-block",
353
+ borderRadius: "10px",
354
+ padding: "0 6px",
355
+ background: background[status] || "",
356
+ color: color[status] || ""
357
+ },
358
+ children: status
359
+ });
360
+ const dateFormatter = new Intl.DateTimeFormat("en-GB", { dateStyle: "long" });
361
+ const formatDate = (d) => {
362
+ const parsed = new Date(d);
363
+ return isNaN(parsed.getTime()) ? d : dateFormatter.format(parsed);
364
+ };
365
+ return /* @__PURE__ */ jsxs("div", {
366
+ className: "asyncapi-attr-row",
367
+ children: [/* @__PURE__ */ jsxs("div", {
368
+ className: "asyncapi-attr-label",
369
+ children: ["API State ", /* @__PURE__ */ jsx(AttributeLink, { attributeName: propertyName })]
370
+ }), /* @__PURE__ */ jsxs("div", {
371
+ className: "asyncapi-attr-value",
372
+ children: [
373
+ badge,
374
+ info.deprecationDate && /* @__PURE__ */ jsxs("div", { children: ["Deprecated on ", formatDate(info.deprecationDate)] }),
375
+ info.decommissionedDate && /* @__PURE__ */ jsxs("div", { children: ["Decommissioned on ", formatDate(info.decommissionedDate)] }),
376
+ info.link && /* @__PURE__ */ jsxs("div", { children: ["More info: ", /* @__PURE__ */ jsx("a", {
377
+ href: info.link,
378
+ target: "_blank",
379
+ rel: "noreferrer",
380
+ className: "asyncapi-attr-link",
381
+ children: info.link
382
+ })] })
383
+ ]
384
+ })]
385
+ });
386
+ }
387
+ //#endregion
388
+ //#region src/lib/asyncApi/customAttributes/sapPreset.ts
389
+ var sapAsyncApiAttributesConfig = {
390
+ prefixStartsWith: "x-sap-",
391
+ documentationUrl: (name) => `https://github.com/SAP/asyncapi-specification#${name}`,
392
+ extensions: {
393
+ "x-sap-catalog-spec-version": {
394
+ type: "string",
395
+ label: "SAP Catalog Spec Version"
396
+ },
397
+ "x-sap-application-namespace": {
398
+ type: "string",
399
+ label: "SAP Application Namespace"
400
+ },
401
+ "x-sap-ord-id": {
402
+ type: "string",
403
+ label: "ORD ID"
404
+ },
405
+ "x-sap-shortText": {
406
+ type: "string",
407
+ label: "SAP Short Text"
408
+ },
409
+ "x-sap-software-min-version": {
410
+ type: "string",
411
+ label: "SAP Software Version"
412
+ },
413
+ "x-sap-stateInfo": { component: AsyncApiStateInfo },
414
+ "x-sap-event-spec-version": {
415
+ type: "string",
416
+ label: "SAP Event Spec Version"
417
+ },
418
+ "x-sap-event-source": {
419
+ type: "string",
420
+ label: "SAP Event Source"
421
+ },
422
+ "x-sap-event-source-parameters": {
423
+ type: "object",
424
+ label: "SAP Event Source Parameters"
425
+ },
426
+ "x-sap-event-version": {
427
+ type: "string",
428
+ label: "SAP Event Version"
429
+ },
430
+ "x-sap-event-characteristics": {
431
+ type: "object",
432
+ label: "SAP Event Characteristics"
433
+ },
434
+ "x-sap-object-type": {
435
+ type: "string",
436
+ label: "SAP Object Type"
437
+ },
438
+ "x-sap-odm-version": {
439
+ type: "string",
440
+ label: "SAP ODM Version"
441
+ },
442
+ "x-sap-logical-odm-event-version": {
443
+ type: "string",
444
+ label: "SAP Logical ODM Event Version"
445
+ },
446
+ "x-sap-dpp-entity-semantics": {
447
+ type: "string",
448
+ label: "SAP DPP: Entity Semantics"
449
+ },
450
+ "x-sap-dpp-data-subject-role": {
451
+ type: "string",
452
+ label: "SAP DPP: Data Subject Role"
453
+ },
454
+ "x-sap-dpp-data-subject-role-description": {
455
+ type: "string",
456
+ label: "SAP DPP: Data Subject Role Description"
457
+ },
458
+ "x-sap-dpp-field-semantics": {
459
+ type: "string",
460
+ label: "SAP DPP: Field Semantics"
461
+ },
462
+ "x-sap-dpp-is-potentially-personal": {
463
+ type: "boolean",
464
+ label: "SAP DPP: Potentially Personal"
465
+ },
466
+ "x-sap-dpp-is-potentially-sensitive": {
467
+ type: "boolean",
468
+ label: "SAP DPP: Potentially Sensitive"
469
+ }
470
+ }
471
+ };
472
+ //#endregion
473
+ //#region src/lib/asyncApi/customAttributes/styles.ts
474
+ var styles_default = `
475
+ .asyncapi-attr-row {
476
+ display: flex;
477
+ border: 1px solid var(--ord-border, #e5e7eb);
478
+ border-radius: calc(var(--ord-radius, 4)*1px);
479
+ margin-top: 8px;
480
+ margin-bottom: 4px;
481
+ font-size: 0.875rem;
482
+ line-height: 1.5;
483
+ overflow: hidden;
484
+ }
485
+ .asyncapi-attr-label {
486
+ color: var(--ord-foreground, #111);
487
+ width: 20ch;
488
+ min-width: 20ch;
489
+ flex-shrink: 0;
490
+ background: var(--ord-muted, #f3f4f6);
491
+ padding: 8px 10px 8px 16px;
492
+ border-right: 1px solid var(--ord-border, #e5e7eb);
493
+ display: flex;
494
+ justify-content: space-between;
495
+ align-items: flex-start;
496
+ font-weight: 400;
497
+ }
498
+ .asyncapi-attr-value {
499
+ color: var(--ord-muted-foreground, #555);
500
+ padding: 8px;
501
+ }
502
+ .asyncapi-attr-list {
503
+ margin: 0 2ch;
504
+ list-style: disc;
505
+ }
506
+ .asyncapi-attr-link {
507
+ text-decoration: none;
508
+ color: var(--ord-primary, #0098ff);
509
+ transition: color 0.1s ease-in-out;
510
+ cursor: pointer;
511
+ }
512
+ .asyncapi-attr-placeholder {
513
+ color: #999;
514
+ }
515
+ .asyncapi-attr-obj {
516
+ margin: 0;
517
+ padding-left: 12px;
518
+ }
519
+ .asyncapi-attr-obj-row {
520
+ margin-bottom: 4px;
521
+ }
522
+ .asyncapi-attr-obj-key {
523
+ font-weight: 600;
524
+ display: inline;
525
+ }
526
+ .asyncapi-attr-obj-val {
527
+ display: inline;
528
+ margin: 0;
529
+ }
530
+
531
+ /* Width-adaptive rows: react to the renderer's own available width (container on the
532
+ wrapper above). Below the breakpoint, every row stacks label-above-value simultaneously,
533
+ and the label spans the full width. */
534
+ @container asyncapi-attrs (max-width: 520px) {
535
+ .asyncapi-attr-row {
536
+ flex-direction: column;
537
+ }
538
+ .asyncapi-attr-label {
539
+ width: 100%;
540
+ min-width: 0;
541
+ border-right: none;
542
+ border-bottom: 1px solid var(--ord-border, #e5e7eb);
543
+ }
544
+ .asyncapi-attr-value {
545
+ width: 100%;
546
+ }
547
+ }
548
+ `;
549
+ //#endregion
550
+ //#region src/lib/asyncApi/index.tsx
551
+ var DARK_DEFAULTS = {
552
+ "--ord-background": "#1e1e1e",
553
+ "--ord-foreground": "#d4d4d4",
554
+ "--ord-card": "#252526",
555
+ "--ord-primary": "#0098ff",
556
+ "--ord-primary-foreground": "#1e1e1e",
557
+ "--ord-muted": "#2d2d30",
558
+ "--ord-muted-foreground": "#969696",
559
+ "--ord-border": "#3e3e42"
560
+ };
561
+ function buildAsyncApiThemeStyle(id, theme) {
562
+ const t = theme;
563
+ const bg = t["--ord-background"];
564
+ const fg = t["--ord-foreground"];
565
+ const secondary = t["--ord-secondary"];
566
+ const secondaryFg = t["--ord-secondary-foreground"];
567
+ const muted = t["--ord-muted"];
568
+ const mutedFg = t["--ord-muted-foreground"];
569
+ const border = t["--ord-border"];
570
+ const primary = t["--ord-primary"];
571
+ const primaryFg = t["--ord-primary-foreground"];
572
+ const accent = t["--ord-accent"];
573
+ const accentFg = t["--ord-accent-foreground"];
574
+ const borderRadius = t["--ord-radius"];
575
+ const rules = [];
576
+ const scope = `[data-renderer-id="${id}"]`;
577
+ if (bg) rules.push(`${scope} .bg-white { background-color: ${bg} !important; }`);
578
+ if (fg) rules.push(`${scope} {color: ${fg}; }`);
579
+ if (accent && accentFg) rules.push(`${scope} .bg-blue-100 { color: ${accentFg}; background-color: ${accent}; }`);
580
+ if (secondary) rules.push(`${scope} .bg-gray-100 { background-color: ${secondary} !important; }`);
581
+ if (secondaryFg) rules.push(`${scope} .prose, ${scope} .text-gray-700 { color: ${secondaryFg}; }`);
582
+ if (muted) rules.push(`${scope} .bg-gray-200 { background-color: ${muted} !important; }`);
583
+ if (mutedFg) rules.push(`${scope} .text-gray-500, ${scope} .text-gray-600 { color: ${mutedFg} !important; }`);
584
+ if (primary) rules.push(`${scope} .bg-gray-800 { background-color: ${primary} !important; }`, `${scope} .bg-blue-100 .text-purple-700 { color: ${primary}; }`);
585
+ if (primaryFg) rules.push(`${scope} .text-white { color: ${primaryFg} !important; }`);
586
+ if (secondary) rules.push(`${scope} .bg-gray-400 { background-color: ${secondary} !important; }`);
587
+ if (accentFg) rules.push(`${scope} .text-gray-200, ${scope} .examples .text-gray-600 { color: ${accentFg} !important; } `);
588
+ if (fg) rules.push(`${scope} .text-gray-800, ${scope} .text-gray-900 { color: ${fg} !important; }`);
589
+ if (border) rules.push(`${scope} .border { border-color: ${border}; }`, `${scope} .border-b { border-bottom-color: ${border}; }`, `${scope} .border-gray-400 { border-color: ${border} !important; }`);
590
+ if (borderRadius) rules.push(`${scope} .rounded, ${scope} .prose pre, ${scope} .\\32 xl\\:rounded { border-radius: ${borderRadius}px; }`, `${scope} .rounded:not(.inline-block) { overflow: hidden; }`, `${scope} .rounded-tl-none { border-top-left-radius: 0px; }`, `${scope} .examples { border-radius: 0px !important; }`);
591
+ return rules.join("\n");
592
+ }
593
+ function AsyncApiRenderer({ content, config, showCustomAttributes = true, customAttributes, className, theme }) {
594
+ const id = useId();
595
+ const isDark = className?.split(/\s+/).includes("dark") ?? false;
596
+ const effectiveTheme = theme ?? (isDark ? DARK_DEFAULTS : null);
597
+ const themeStyle = effectiveTheme ? buildAsyncApiThemeStyle(id, effectiveTheme) : null;
598
+ const activeConfigs = customAttributes ?? [sapAsyncApiAttributesConfig];
599
+ const parsedDoc = useMemo(() => showCustomAttributes ? loadObject(content) : null, [content, showCustomAttributes]);
600
+ const version = useMemo(() => {
601
+ const doc = parsedDoc;
602
+ return typeof doc?.asyncapi === "string" ? doc.asyncapi : "";
603
+ }, [parsedDoc]);
604
+ const effectiveConfig = useMemo(() => {
605
+ if (!showCustomAttributes) return config ?? {};
606
+ const extensions = buildAsyncApiExtensionsConfig(activeConfigs, parsedDoc, version);
607
+ return {
608
+ ...config,
609
+ extensions: {
610
+ ...extensions,
611
+ ...config?.extensions ?? {}
612
+ }
613
+ };
614
+ }, [
615
+ config,
616
+ showCustomAttributes,
617
+ activeConfigs,
618
+ parsedDoc,
619
+ version
620
+ ]);
621
+ const rootPlugin = useMemo(() => showCustomAttributes ? buildRootExtensionsPlugin(activeConfigs) : null, [showCustomAttributes, activeConfigs]);
622
+ const scope = `[data-renderer-id="${id}"]`;
623
+ const layoutStyle = `${scope} { container: asyncapi-attrs / inline-size; height: 100%; overflow: auto; scrollbar-gutter: stable; }\n${scope} :where(h1,h2,h3,h4,p,span,strong,a,li,td,div):not(pre *) { overflow-wrap: anywhere; }`;
624
+ return /* @__PURE__ */ jsxs("div", {
625
+ "data-renderer-id": id,
626
+ className,
627
+ children: [
628
+ themeStyle && /* @__PURE__ */ jsx("style", { children: themeStyle }),
629
+ showCustomAttributes && /* @__PURE__ */ jsx("style", { children: styles_default }),
630
+ /* @__PURE__ */ jsx("style", { children: layoutStyle }),
631
+ showCustomAttributes && /* @__PURE__ */ jsx("style", { children: `[data-renderer-id="${id}"] #introduction .hidden { display: block !important; }` }),
632
+ /* @__PURE__ */ jsx(AsyncApiComponent, {
633
+ schema: content,
634
+ config: effectiveConfig,
635
+ plugins: rootPlugin ? [rootPlugin] : []
636
+ })
637
+ ]
638
+ });
639
+ }
640
+ //#endregion
641
+ export { sapAsyncApiAttributesConfig as n, AsyncApiRenderer as t };