@apiboost/omnispec 1.0.0 → 1.1.0-next.1

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 (73) hide show
  1. package/dist/cjs/asyncapi/index.js +3 -3
  2. package/dist/cjs/chunks/AsyncApiSpec-CHvM1swf.js +1880 -0
  3. package/dist/cjs/chunks/AsyncApiSpec-CHvM1swf.js.map +1 -0
  4. package/dist/cjs/chunks/{Collapsible-BHAHk_Ep.js → Collapsible-Jlb_vtdW.js} +286 -225
  5. package/dist/cjs/chunks/Collapsible-Jlb_vtdW.js.map +1 -0
  6. package/dist/cjs/chunks/{OmniSpecRenderer-CE4wxVTL.js → OmniSpecRenderer-Dj6Z6W2J.js} +3 -3
  7. package/dist/cjs/chunks/{OmniSpecRenderer-CE4wxVTL.js.map → OmniSpecRenderer-Dj6Z6W2J.js.map} +1 -1
  8. package/dist/cjs/chunks/{OpenApiSpec-D0JtmOVQ.js → OpenApiSpec-BPtXvk7C.js} +8 -8
  9. package/dist/cjs/chunks/{OpenApiSpec-D0JtmOVQ.js.map → OpenApiSpec-BPtXvk7C.js.map} +1 -1
  10. package/dist/cjs/chunks/{OpenIdConnectManual-oEnN0QJ-.js → OpenIdConnectManual-DBP0Do-3.js} +6 -67
  11. package/dist/cjs/chunks/OpenIdConnectManual-DBP0Do-3.js.map +1 -0
  12. package/dist/cjs/chunks/{ref-resolver-DWu6Q6E5.js → ref-resolver-0A8GNRI3.js} +6 -2
  13. package/dist/cjs/chunks/{ref-resolver-DWu6Q6E5.js.map → ref-resolver-0A8GNRI3.js.map} +1 -1
  14. package/dist/cjs/core/public.js +2 -2
  15. package/dist/cjs/index.js +6 -6
  16. package/dist/cjs/openapi/index.js +4 -4
  17. package/dist/cjs/wc/index.js +1 -1
  18. package/dist/esm/asyncapi/index.js +3 -3
  19. package/dist/esm/chunks/AsyncApiSpec-BPiA9b5T.js +1878 -0
  20. package/dist/esm/chunks/AsyncApiSpec-BPiA9b5T.js.map +1 -0
  21. package/dist/esm/chunks/{Collapsible-DA6-nS46.js → Collapsible-0ryLh6wX.js} +286 -227
  22. package/dist/esm/chunks/Collapsible-0ryLh6wX.js.map +1 -0
  23. package/dist/esm/chunks/{OmniSpecRenderer-MqsQFXro.js → OmniSpecRenderer-yF2Zw_B9.js} +3 -3
  24. package/dist/esm/chunks/{OmniSpecRenderer-MqsQFXro.js.map → OmniSpecRenderer-yF2Zw_B9.js.map} +1 -1
  25. package/dist/esm/chunks/{OpenApiSpec-Cy-oW6jA.js → OpenApiSpec-MGJ3oFHZ.js} +4 -4
  26. package/dist/esm/chunks/{OpenApiSpec-Cy-oW6jA.js.map → OpenApiSpec-MGJ3oFHZ.js.map} +1 -1
  27. package/dist/esm/chunks/{OpenIdConnectManual-COfITasf.js → OpenIdConnectManual-BS-n811Z.js} +5 -64
  28. package/dist/esm/chunks/OpenIdConnectManual-BS-n811Z.js.map +1 -0
  29. package/dist/esm/chunks/{ref-resolver-BIrHJOjz.js → ref-resolver-B0C36NuQ.js} +6 -3
  30. package/dist/esm/chunks/{ref-resolver-BIrHJOjz.js.map → ref-resolver-B0C36NuQ.js.map} +1 -1
  31. package/dist/esm/core/public.js +2 -2
  32. package/dist/esm/index.js +6 -6
  33. package/dist/esm/openapi/index.js +4 -4
  34. package/dist/esm/wc/index.js +1 -1
  35. package/dist/types/asyncapi/AsyncApiSpec.d.ts.map +1 -1
  36. package/dist/types/asyncapi/components/BindingsSection.d.ts +26 -0
  37. package/dist/types/asyncapi/components/BindingsSection.d.ts.map +1 -0
  38. package/dist/types/asyncapi/components/ChannelDetail.d.ts +1 -1
  39. package/dist/types/asyncapi/components/ChannelDetail.d.ts.map +1 -1
  40. package/dist/types/asyncapi/components/ComponentsSection.d.ts +1 -1
  41. package/dist/types/asyncapi/components/ComponentsSection.d.ts.map +1 -1
  42. package/dist/types/asyncapi/components/MessagePayload.d.ts +22 -0
  43. package/dist/types/asyncapi/components/MessagePayload.d.ts.map +1 -0
  44. package/dist/types/asyncapi/components/SecurityRequirementBadges.d.ts +22 -0
  45. package/dist/types/asyncapi/components/SecurityRequirementBadges.d.ts.map +1 -0
  46. package/dist/types/asyncapi/components/SecuritySchemesSection.d.ts +23 -0
  47. package/dist/types/asyncapi/components/SecuritySchemesSection.d.ts.map +1 -0
  48. package/dist/types/asyncapi/components/ServerList.d.ts +1 -1
  49. package/dist/types/asyncapi/components/ServerList.d.ts.map +1 -1
  50. package/dist/types/asyncapi/components/TagGroupHeader.d.ts +18 -0
  51. package/dist/types/asyncapi/components/TagGroupHeader.d.ts.map +1 -0
  52. package/dist/types/asyncapi/components/field-display.d.ts +20 -0
  53. package/dist/types/asyncapi/components/field-display.d.ts.map +1 -0
  54. package/dist/types/asyncapi/parser/asyncapi-parser.d.ts.map +1 -1
  55. package/dist/types/asyncapi/schema-formats.d.ts +26 -0
  56. package/dist/types/asyncapi/schema-formats.d.ts.map +1 -0
  57. package/dist/types/asyncapi/tag-grouping.d.ts +39 -0
  58. package/dist/types/asyncapi/tag-grouping.d.ts.map +1 -0
  59. package/dist/types/asyncapi/types/asyncapi.types.d.ts +35 -0
  60. package/dist/types/asyncapi/types/asyncapi.types.d.ts.map +1 -1
  61. package/dist/types/openapi/parser/ref-resolver.d.ts +8 -0
  62. package/dist/types/openapi/parser/ref-resolver.d.ts.map +1 -1
  63. package/dist/wc/standalone.js +1 -1
  64. package/dist/wc/standalone.js.map +1 -1
  65. package/package.json +2 -2
  66. package/dist/cjs/chunks/AsyncApiSpec-TBlyRxTP.js +0 -819
  67. package/dist/cjs/chunks/AsyncApiSpec-TBlyRxTP.js.map +0 -1
  68. package/dist/cjs/chunks/Collapsible-BHAHk_Ep.js.map +0 -1
  69. package/dist/cjs/chunks/OpenIdConnectManual-oEnN0QJ-.js.map +0 -1
  70. package/dist/esm/chunks/AsyncApiSpec-C3lsUpZk.js +0 -817
  71. package/dist/esm/chunks/AsyncApiSpec-C3lsUpZk.js.map +0 -1
  72. package/dist/esm/chunks/Collapsible-DA6-nS46.js.map +0 -1
  73. package/dist/esm/chunks/OpenIdConnectManual-COfITasf.js.map +0 -1
@@ -1,819 +0,0 @@
1
- 'use strict';
2
-
3
- var jsxRuntime = require('react/jsx-runtime');
4
- var React = require('react');
5
- var css = require('@emotion/css');
6
- var useSpecFetcher = require('./useSpecFetcher-BKz1jHTV.js');
7
- var Collapsible = require('./Collapsible-BHAHk_Ep.js');
8
- var ErrorBoundary = require('./ErrorBoundary-c1piU8da.js');
9
- var refResolver = require('./ref-resolver-DWu6Q6E5.js');
10
- require('@emotion/styled');
11
- require('./ssrf-guard-B6T2A7Ho.js');
12
-
13
- async function parseAsyncApiSpec(specInput) {
14
- const raw = typeof specInput === "string" ? parseSpecString(specInput) : specInput;
15
- const api = await refResolver.resolveRefs(raw);
16
- const majorVersion = parseInt(api.asyncapi.split(".")[0], 10);
17
- const isV3 = majorVersion >= 3;
18
- const servers = extractServers(api);
19
- const channels = isV3 ? extractChannelsV3(api) : extractChannelsV2(api);
20
- const components = extractComponents(api);
21
- const root = api;
22
- const tags = api.tags?.map((tag) => {
23
- const raw2 = tag;
24
- return {
25
- name: tag.name,
26
- description: tag.description,
27
- displayName: raw2["x-displayName"],
28
- externalDocs: raw2.externalDocs
29
- };
30
- })?.filter((tag) => !tag["x-internal"]);
31
- return {
32
- title: api.info.title,
33
- description: api.info.description,
34
- version: api.info.version,
35
- specVersion: api.asyncapi,
36
- servers,
37
- channels: channels.filter((ch) => !ch.xInternal),
38
- components,
39
- tags,
40
- tagGroups: root["x-tagGroups"],
41
- externalDocs: api.externalDocs,
42
- contact: api.info.contact,
43
- license: api.info.license,
44
- termsOfService: api.info.termsOfService,
45
- logo: api.info["x-logo"]
46
- };
47
- }
48
- function extractServers(api) {
49
- if (!api.servers) return [];
50
- if (Array.isArray(api.servers)) {
51
- return api.servers.map((s, idx) => ({
52
- name: s.name ?? `server-${idx}`,
53
- url: s.host ? `${s.protocol}://${s.host}${s.pathname ?? ""}` : s.url ?? "",
54
- protocol: s.protocol,
55
- protocolVersion: s.protocolVersion,
56
- description: s.description,
57
- variables: s.variables,
58
- security: s.security
59
- }));
60
- }
61
- return Object.entries(api.servers).map(([name, s]) => ({
62
- name,
63
- url: s.host ? `${s.protocol}://${s.host}${s.pathname ?? ""}` : s.url ?? "",
64
- protocol: s.protocol,
65
- protocolVersion: s.protocolVersion,
66
- description: s.description,
67
- variables: s.variables,
68
- security: s.security
69
- }));
70
- }
71
- function extractChannelsV2(api) {
72
- if (!api.channels) return [];
73
- return Object.entries(api.channels).map(([channelName, ch]) => {
74
- const operations = [];
75
- if (ch.publish) {
76
- operations.push(convertOperationV2("publish", ch.publish));
77
- }
78
- if (ch.subscribe) {
79
- operations.push(convertOperationV2("subscribe", ch.subscribe));
80
- }
81
- const raw = ch;
82
- return {
83
- name: channelName,
84
- address: channelName,
85
- description: ch.description,
86
- operations: operations.filter((op) => !op.xInternal),
87
- parameters: ch.parameters,
88
- bindings: ch.bindings,
89
- xInternal: raw["x-internal"]
90
- };
91
- });
92
- }
93
- function convertOperationV2(action, op) {
94
- let message;
95
- if (op.message) {
96
- if ("oneOf" in op.message) {
97
- message = convertMessage(op.message.oneOf[0]);
98
- } else {
99
- message = convertMessage(op.message);
100
- }
101
- }
102
- const raw = op;
103
- return {
104
- action,
105
- operationId: op.operationId,
106
- summary: op.summary,
107
- description: op.description,
108
- message,
109
- tags: op.tags,
110
- bindings: op.bindings,
111
- xBadges: raw["x-badges"],
112
- xInternal: raw["x-internal"]
113
- };
114
- }
115
- function extractChannelsV3(api) {
116
- if (!api.channels) return [];
117
- const channelMap = /* @__PURE__ */ new Map();
118
- for (const [channelName, ch] of Object.entries(api.channels)) {
119
- const raw = ch;
120
- channelMap.set(channelName, {
121
- name: channelName,
122
- address: ch.address ?? channelName,
123
- description: ch.description,
124
- operations: [],
125
- parameters: ch.parameters,
126
- bindings: ch.bindings,
127
- xInternal: raw["x-internal"]
128
- });
129
- }
130
- if (api.operations) {
131
- for (const [, op] of Object.entries(api.operations)) {
132
- const channelRef = op.channel;
133
- let channelName;
134
- if (channelRef && "$ref" in channelRef && typeof channelRef.$ref === "string") {
135
- channelName = channelRef.$ref.split("/").pop();
136
- }
137
- const messages = [];
138
- if (op.messages) {
139
- for (const msg of op.messages) {
140
- if ("$ref" in msg) continue;
141
- messages.push(convertMessage(msg));
142
- }
143
- }
144
- const raw = op;
145
- const operation = {
146
- action: op.action,
147
- summary: op.summary,
148
- description: op.description,
149
- message: messages[0],
150
- tags: op.tags,
151
- bindings: op.bindings,
152
- xBadges: raw["x-badges"],
153
- xInternal: raw["x-internal"]
154
- };
155
- if (operation.xInternal) continue;
156
- if (channelName && channelMap.has(channelName)) {
157
- channelMap.get(channelName).operations.push(operation);
158
- }
159
- }
160
- }
161
- return Array.from(channelMap.values());
162
- }
163
- function convertMessage(msg) {
164
- return {
165
- name: msg.name,
166
- title: msg.title,
167
- summary: msg.summary,
168
- description: msg.description,
169
- contentType: msg.contentType,
170
- payload: msg.payload,
171
- headers: msg.headers,
172
- correlationId: msg.correlationId,
173
- tags: msg.tags,
174
- examples: msg.examples,
175
- bindings: msg.bindings
176
- };
177
- }
178
- function extractComponents(api) {
179
- return {
180
- schemas: api.components?.schemas ?? {},
181
- messages: api.components?.messages ?? {}
182
- };
183
- }
184
- function parseSpecString(input) {
185
- const trimmed = input.trim();
186
- if (trimmed.startsWith("{")) {
187
- try {
188
- return JSON.parse(trimmed);
189
- } catch {
190
- }
191
- }
192
- return refResolver.parse(trimmed);
193
- }
194
-
195
- function useAsyncApiSpec(spec) {
196
- const parser = React.useCallback(async (raw) => {
197
- return parseAsyncApiSpec(raw);
198
- }, []);
199
- return useSpecFetcher.useSpecFetcher(spec, parser);
200
- }
201
-
202
- const containerStyle$2 = css.css({
203
- marginBottom: "32px",
204
- paddingBottom: "24px",
205
- borderBottom: "1px solid var(--omnispec-border-color)"
206
- });
207
- const titleStyle$2 = css.css({
208
- margin: "0 0 4px",
209
- fontSize: "var(--omnispec-h2-font-size)",
210
- color: "var(--omnispec-h2-color)",
211
- fontWeight: 700,
212
- display: "inline"
213
- });
214
- const versionStyle$1 = css.css({
215
- fontSize: "var(--omnispec-font-size-sm)",
216
- color: "var(--omnispec-fg-muted)",
217
- marginLeft: "12px",
218
- fontFamily: "var(--omnispec-font-mono)"
219
- });
220
- const specBadgeStyle = css.css({
221
- fontSize: "var(--omnispec-font-size-xs)",
222
- color: "var(--omnispec-color-primary)",
223
- border: "1px solid var(--omnispec-color-primary)",
224
- borderRadius: "4px",
225
- padding: "1px 6px",
226
- marginLeft: "8px",
227
- fontFamily: "var(--omnispec-font-mono)"
228
- });
229
- const metaStyle = css.css({
230
- fontSize: "var(--omnispec-font-size-sm)",
231
- color: "var(--omnispec-fg-secondary)",
232
- marginTop: "4px"
233
- });
234
- const linkStyle = css.css({
235
- color: "var(--omnispec-fg-link)",
236
- textDecoration: "none",
237
- "&:hover": {
238
- textDecoration: "underline"
239
- }
240
- });
241
- function AsyncOverview({ spec }) {
242
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: css.cx("omnispec-async-overview", containerStyle$2), children: [
243
- /* @__PURE__ */ jsxRuntime.jsx("h1", { className: titleStyle$2, children: spec.title }),
244
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: versionStyle$1, children: [
245
- "v",
246
- spec.version
247
- ] }),
248
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: specBadgeStyle, children: [
249
- "AsyncAPI ",
250
- spec.specVersion
251
- ] }),
252
- spec.description && /* @__PURE__ */ jsxRuntime.jsx(Collapsible.MarkdownRenderer, { content: spec.description }),
253
- spec.contact && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: metaStyle, children: [
254
- spec.contact.name && /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
255
- "Contact: ",
256
- spec.contact.name
257
- ] }),
258
- spec.contact.email && /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
259
- " <",
260
- /* @__PURE__ */ jsxRuntime.jsx("a", { href: `mailto:${spec.contact.email}`, className: linkStyle, children: spec.contact.email }),
261
- ">"
262
- ] }),
263
- spec.contact.url && /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
264
- " \xB7 ",
265
- /* @__PURE__ */ jsxRuntime.jsx("a", { href: spec.contact.url, target: "_blank", rel: "noopener noreferrer", className: linkStyle, children: spec.contact.url })
266
- ] })
267
- ] }),
268
- spec.license && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: metaStyle, children: [
269
- "License: ",
270
- spec.license.url ? /* @__PURE__ */ jsxRuntime.jsx("a", { href: spec.license.url, target: "_blank", rel: "noopener noreferrer", className: linkStyle, children: spec.license.name }) : spec.license.name
271
- ] }),
272
- spec.externalDocs && /* @__PURE__ */ jsxRuntime.jsx("div", { className: metaStyle, children: /* @__PURE__ */ jsxRuntime.jsx("a", { href: spec.externalDocs.url, target: "_blank", rel: "noopener noreferrer", className: linkStyle, children: spec.externalDocs.description ?? "External Documentation" }) })
273
- ] });
274
- }
275
-
276
- const protocolColors = {
277
- kafka: "#231F20",
278
- "kafka-secure": "#231F20",
279
- mqtt: "#660066",
280
- "mqtt5": "#660066",
281
- amqp: "#FF6600",
282
- "amqp1": "#FF6600",
283
- ws: "#4A90D9",
284
- wss: "#4A90D9",
285
- http: "var(--omnispec-color-get)",
286
- https: "var(--omnispec-color-get)",
287
- nats: "#27AAE1",
288
- redis: "#DC382D",
289
- sns: "#FF9900",
290
- sqs: "#FF9900",
291
- stomp: "#6DB33F",
292
- mercure: "#1D1D1D"
293
- };
294
- const badgeBase = css.css({
295
- display: "inline-block",
296
- padding: "2px 8px",
297
- borderRadius: "4px",
298
- fontSize: "10px",
299
- fontWeight: 700,
300
- fontFamily: "var(--omnispec-font-mono)",
301
- color: "#ffffff",
302
- letterSpacing: "0.5px"
303
- });
304
- const versionStyle = css.css({
305
- fontWeight: 400,
306
- opacity: 0.8
307
- });
308
- function ProtocolBadge({ protocol, version }) {
309
- const color = protocolColors[protocol.toLowerCase()] ?? "var(--omnispec-fg-muted)";
310
- return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: css.cx(badgeBase, css.css({ backgroundColor: color })), children: [
311
- protocol.toUpperCase(),
312
- version && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: versionStyle, children: [
313
- " ",
314
- version
315
- ] })
316
- ] });
317
- }
318
-
319
- const containerStyle$1 = css.css({
320
- marginBottom: "24px"
321
- });
322
- const titleStyle$1 = css.css({
323
- margin: "0 0 12px",
324
- fontSize: "var(--omnispec-h3-font-size)",
325
- color: "var(--omnispec-h3-color)",
326
- fontWeight: 600
327
- });
328
- const gridStyle = css.css({
329
- display: "flex",
330
- flexDirection: "column",
331
- gap: "8px"
332
- });
333
- const cardStyle = css.css({
334
- padding: "12px",
335
- border: "1px solid var(--omnispec-border-color)",
336
- borderRadius: "var(--omnispec-border-radius)",
337
- backgroundColor: "var(--omnispec-bg-secondary)",
338
- "&:hover": {
339
- borderColor: "var(--omnispec-color-primary)"
340
- }
341
- });
342
- const cardHeaderStyle = css.css({
343
- display: "flex",
344
- alignItems: "center",
345
- gap: "8px",
346
- marginBottom: "6px"
347
- });
348
- const serverNameStyle = css.css({
349
- fontWeight: 600,
350
- fontSize: "var(--omnispec-font-size-sm)",
351
- color: "var(--omnispec-fg-primary)"
352
- });
353
- const urlStyle = css.css({
354
- fontFamily: "var(--omnispec-font-mono)",
355
- fontSize: "var(--omnispec-font-size-sm)",
356
- color: "var(--omnispec-fg-code)",
357
- display: "block",
358
- marginBottom: "4px"
359
- });
360
- const descriptionStyle = css.css({
361
- margin: "4px 0 0",
362
- fontSize: "var(--omnispec-font-size-xs)",
363
- color: "var(--omnispec-fg-secondary)"
364
- });
365
- const variablesStyle = css.css({
366
- marginTop: "8px",
367
- fontSize: "var(--omnispec-font-size-xs)"
368
- });
369
- const varRowStyle = css.css({
370
- display: "flex",
371
- gap: "6px",
372
- marginBottom: "2px"
373
- });
374
- const varNameStyle = css.css({
375
- fontFamily: "var(--omnispec-font-mono)",
376
- color: "var(--omnispec-fg-primary)",
377
- fontWeight: 600
378
- });
379
- const varDefaultStyle = css.css({
380
- fontFamily: "var(--omnispec-font-mono)",
381
- color: "var(--omnispec-fg-muted)"
382
- });
383
- const varDescStyle = css.css({
384
- color: "var(--omnispec-fg-secondary)"
385
- });
386
- function ServerList({ servers }) {
387
- if (servers.length === 0) return null;
388
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: css.cx("omnispec-async-servers", containerStyle$1), children: [
389
- /* @__PURE__ */ jsxRuntime.jsx("h3", { className: titleStyle$1, children: "Servers" }),
390
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: gridStyle, children: servers.map((server) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cardStyle, children: [
391
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cardHeaderStyle, children: [
392
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: serverNameStyle, children: server.name }),
393
- /* @__PURE__ */ jsxRuntime.jsx(ProtocolBadge, { protocol: server.protocol, version: server.protocolVersion })
394
- ] }),
395
- /* @__PURE__ */ jsxRuntime.jsx("code", { className: urlStyle, children: server.url }),
396
- server.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: descriptionStyle, children: server.description }),
397
- server.variables && Object.entries(server.variables).length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: variablesStyle, children: Object.entries(server.variables).map(([name, variable]) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: varRowStyle, children: [
398
- /* @__PURE__ */ jsxRuntime.jsx("code", { className: varNameStyle, children: name }),
399
- variable.default && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: varDefaultStyle, children: [
400
- "= ",
401
- variable.default
402
- ] }),
403
- variable.description && /* @__PURE__ */ jsxRuntime.jsx("span", { className: varDescStyle, children: variable.description })
404
- ] }, name)) })
405
- ] }, server.name)) })
406
- ] });
407
- }
408
-
409
- const actionLabels = {
410
- publish: "PUB",
411
- subscribe: "SUB",
412
- send: "SEND",
413
- receive: "RECV"
414
- };
415
- const actionColors = {
416
- publish: "var(--omnispec-color-publish)",
417
- subscribe: "var(--omnispec-color-subscribe)",
418
- send: "var(--omnispec-color-publish)",
419
- receive: "var(--omnispec-color-subscribe)"
420
- };
421
- function ChannelDetail({ channel, id, expandAll, expandGeneration }) {
422
- const primaryAction = channel.operations[0]?.action;
423
- const primaryLabel = actionLabels[primaryAction] ?? primaryAction?.toUpperCase() ?? "";
424
- const primaryColor = actionColors[primaryAction] ?? "var(--omnispec-fg-muted)";
425
- return /* @__PURE__ */ jsxRuntime.jsxs(
426
- Collapsible.ExpandableCard,
427
- {
428
- id,
429
- title: channel.address,
430
- rightLabel: `${channel.operations.length} ${channel.operations.length === 1 ? "operation" : "operations"}`,
431
- expandAll,
432
- expandGeneration,
433
- children: [
434
- /* @__PURE__ */ jsxRuntime.jsx(Collapsible.MethodBar, { label: primaryLabel, path: channel.address, color: primaryColor }),
435
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: bodyStyle, children: [
436
- channel.description && /* @__PURE__ */ jsxRuntime.jsx("div", { className: sectionStyle, children: /* @__PURE__ */ jsxRuntime.jsx(Collapsible.MarkdownRenderer, { content: channel.description }) }),
437
- channel.parameters && Object.keys(channel.parameters).length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: sectionStyle, children: [
438
- /* @__PURE__ */ jsxRuntime.jsx("h4", { className: sectionTitleStyle, children: "Parameters" }),
439
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: paramListStyle, children: Object.entries(channel.parameters).map(([name, param]) => {
440
- const paramType = param.schema?.type;
441
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: paramRowStyle, children: [
442
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: paramHeaderStyle, children: [
443
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: paramNameStyle, children: name }),
444
- paramType && /* @__PURE__ */ jsxRuntime.jsx("pre", { className: typeBadgeStyle, children: paramType })
445
- ] }),
446
- param.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: paramDescStyle, children: param.description })
447
- ] }, name);
448
- }) })
449
- ] }),
450
- channel.operations.map((op, idx) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: operationStyle, children: [
451
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: opHeaderStyle, children: [
452
- /* @__PURE__ */ jsxRuntime.jsx(
453
- "span",
454
- {
455
- className: css.cx(actionBadgeBase, css.css({
456
- backgroundColor: actionColors[op.action] ?? "var(--omnispec-fg-muted)"
457
- })),
458
- children: actionLabels[op.action] ?? op.action.toUpperCase()
459
- }
460
- ),
461
- op.operationId && /* @__PURE__ */ jsxRuntime.jsx("span", { className: opIdStyle, children: op.operationId }),
462
- op.summary && /* @__PURE__ */ jsxRuntime.jsx("span", { className: opSummaryStyle, children: op.summary })
463
- ] }),
464
- op.description && /* @__PURE__ */ jsxRuntime.jsx("div", { className: sectionStyle, children: /* @__PURE__ */ jsxRuntime.jsx(Collapsible.MarkdownRenderer, { content: op.description }) }),
465
- op.message && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: sectionStyle, children: [
466
- /* @__PURE__ */ jsxRuntime.jsxs("h4", { className: sectionTitleStyle, children: [
467
- "Message",
468
- op.message.title && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: messageTitleStyle, children: [
469
- " \u2014 ",
470
- op.message.title
471
- ] })
472
- ] }),
473
- op.message.summary && /* @__PURE__ */ jsxRuntime.jsx("p", { className: messageSummaryStyle, children: op.message.summary }),
474
- op.message.contentType && /* @__PURE__ */ jsxRuntime.jsx("code", { className: contentTypeStyle, children: op.message.contentType }),
475
- op.message.payload && /* @__PURE__ */ jsxRuntime.jsx(
476
- Collapsible.Tabs,
477
- {
478
- tabs: [
479
- {
480
- id: `schema-${idx}`,
481
- label: "Payload Schema",
482
- content: /* @__PURE__ */ jsxRuntime.jsx(Collapsible.SchemaTree, { nodes: Collapsible.schemaToNodes(op.message.payload) })
483
- },
484
- {
485
- id: `example-${idx}`,
486
- label: "Example",
487
- content: /* @__PURE__ */ jsxRuntime.jsx(
488
- Collapsible.CodeBlock,
489
- {
490
- code: JSON.stringify(Collapsible.generateExample(op.message.payload), null, 2),
491
- language: "json"
492
- }
493
- )
494
- }
495
- ]
496
- }
497
- ),
498
- op.message.headers && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: headersWrapStyle, children: [
499
- /* @__PURE__ */ jsxRuntime.jsx("h4", { className: sectionTitleStyle, children: "Headers" }),
500
- /* @__PURE__ */ jsxRuntime.jsx(Collapsible.SchemaTree, { nodes: Collapsible.schemaToNodes(op.message.headers) })
501
- ] })
502
- ] })
503
- ] }, idx))
504
- ] })
505
- ]
506
- }
507
- );
508
- }
509
- const bodyStyle = css.css({
510
- padding: "0.75rem 1rem",
511
- [useSpecFetcher.mq.desktop]: {
512
- padding: "1rem 1.25rem"
513
- }
514
- });
515
- const sectionStyle = css.css({
516
- marginBottom: "24px"
517
- });
518
- const sectionTitleStyle = css.css({
519
- margin: "0 0 12px",
520
- fontSize: "var(--omnispec-font-size-md)",
521
- fontWeight: 700,
522
- color: "var(--omnispec-fg-primary)",
523
- letterSpacing: "0.02em"
524
- });
525
- const paramListStyle = css.css({
526
- display: "flex",
527
- flexDirection: "column"
528
- });
529
- const paramRowStyle = css.css({
530
- padding: "12px 0"
531
- });
532
- const paramHeaderStyle = css.css({
533
- display: "flex",
534
- alignItems: "center",
535
- gap: "8px",
536
- flexWrap: "wrap"
537
- });
538
- const paramNameStyle = css.css({
539
- fontSize: "var(--omnispec-font-size-sm)",
540
- fontWeight: 700,
541
- backgroundColor: "transparent",
542
- padding: 0
543
- });
544
- const typeBadgeStyle = css.css({
545
- fontSize: "var(--omnispec-font-size-xs)",
546
- fontWeight: 400
547
- });
548
- const paramDescStyle = css.css({
549
- margin: "4px 0 0",
550
- fontSize: "var(--omnispec-font-size-base)",
551
- color: "var(--omnispec-fg-secondary)",
552
- lineHeight: 1.5
553
- });
554
- const operationStyle = css.css({
555
- padding: "12px 0",
556
- borderTop: "1px solid var(--omnispec-border-color)"
557
- });
558
- const opHeaderStyle = css.css({
559
- display: "flex",
560
- alignItems: "center",
561
- gap: "8px",
562
- marginBottom: "8px"
563
- });
564
- const actionBadgeBase = css.css({
565
- display: "inline-block",
566
- padding: "2px 6px",
567
- borderRadius: "3px",
568
- fontSize: "9px",
569
- fontWeight: 700,
570
- fontFamily: "var(--omnispec-font-mono)",
571
- color: "#ffffff",
572
- letterSpacing: "0.5px"
573
- });
574
- const opIdStyle = css.css({
575
- fontSize: "var(--omnispec-font-size-sm)",
576
- fontWeight: 700,
577
- backgroundColor: "transparent",
578
- padding: 0
579
- });
580
- const opSummaryStyle = css.css({
581
- fontSize: "var(--omnispec-font-size-sm)",
582
- color: "var(--omnispec-fg-secondary)"
583
- });
584
- const messageTitleStyle = css.css({
585
- fontWeight: 400,
586
- color: "var(--omnispec-fg-primary)"
587
- });
588
- const messageSummaryStyle = css.css({
589
- margin: "0 0 8px",
590
- fontSize: "var(--omnispec-font-size-base)",
591
- color: "var(--omnispec-fg-secondary)"
592
- });
593
- const contentTypeStyle = css.css({
594
- fontFamily: "var(--omnispec-font-mono)",
595
- fontSize: "var(--omnispec-font-size-xs)",
596
- color: "var(--omnispec-fg-muted)",
597
- display: "block",
598
- marginBottom: "8px",
599
- backgroundColor: "transparent",
600
- padding: 0
601
- });
602
- const headersWrapStyle = css.css({
603
- marginTop: "16px"
604
- });
605
-
606
- function ComponentsSection({ components }) {
607
- const schemas = Object.entries(components.schemas);
608
- if (schemas.length === 0) return null;
609
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `omnispec-async-components ${containerStyle}`, id: "schemas", children: [
610
- /* @__PURE__ */ jsxRuntime.jsx("h2", { className: titleStyle, children: "Schemas" }),
611
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: schemaWrapperStyle, children: schemas.map(([name, schema]) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: schemaStyle, id: `schema-${name}`, children: /* @__PURE__ */ jsxRuntime.jsx(
612
- Collapsible.Collapsible,
613
- {
614
- title: /* @__PURE__ */ jsxRuntime.jsx("code", { className: schemaNameStyle, children: name }),
615
- defaultOpen: false,
616
- children: /* @__PURE__ */ jsxRuntime.jsx(Collapsible.SchemaTree, { nodes: Collapsible.schemaToNodes(schema) })
617
- }
618
- ) }, name)) })
619
- ] });
620
- }
621
- const containerStyle = css.css({
622
- marginTop: "2rem",
623
- paddingTop: "1.5rem",
624
- borderTop: "1px solid var(--omnispec-border-color)",
625
- [useSpecFetcher.mq.mobile]: {
626
- borderTop: "none",
627
- marginTop: "1.5rem",
628
- paddingTop: "1rem"
629
- }
630
- });
631
- const titleStyle = css.css({
632
- margin: "0 0 16px",
633
- fontSize: "var(--omnispec-h2-font-size)",
634
- color: "var(--omnispec-h2-color)",
635
- fontWeight: 700
636
- });
637
- const schemaWrapperStyle = css.css({
638
- border: "1px solid var(--omnispec-border-color)",
639
- borderRadius: "8px",
640
- padding: "1.5rem 1rem"
641
- });
642
- const schemaStyle = css.css({
643
- marginBottom: "8px"
644
- });
645
- const schemaNameStyle = css.css({
646
- fontFamily: "var(--omnispec-font-mono)",
647
- fontSize: "var(--omnispec-font-size-base)",
648
- fontWeight: 600,
649
- color: "var(--omnispec-color-primary)",
650
- backgroundColor: "transparent",
651
- padding: 0,
652
- "&:hover": {
653
- textDecoration: "underline"
654
- }
655
- });
656
-
657
- function AsyncApiSpec({
658
- spec,
659
- theme,
660
- layout = "sidebar",
661
- sidebarPosition = "left",
662
- defaultExpandOperations = false,
663
- downloadLink,
664
- sidebarNav,
665
- slots = {},
666
- schemaStyle,
667
- pro,
668
- onSpecLoaded,
669
- className
670
- }) {
671
- const resolvedSchemaStyle = useSpecFetcher.resolveSchemaStyle(schemaStyle, pro?.advancedSchemaStyles ?? false);
672
- const { data: parsedSpec, state } = useAsyncApiSpec(spec);
673
- const [searchQuery, setSearchQuery] = React.useState("");
674
- const [allExpanded, setAllExpanded] = React.useState(defaultExpandOperations);
675
- const [expandGeneration, setExpandGeneration] = React.useState(0);
676
- const handleToggleExpand = React.useCallback(() => {
677
- setAllExpanded((prev) => !prev);
678
- setExpandGeneration((prev) => prev + 1);
679
- }, []);
680
- React.useMemo(() => {
681
- if (parsedSpec && onSpecLoaded) {
682
- const major = parseInt(parsedSpec.specVersion.split(".")[0], 10);
683
- onSpecLoaded({
684
- title: parsedSpec.title,
685
- version: parsedSpec.version,
686
- type: major >= 3 ? useSpecFetcher.SpecType.ASYNCAPI_3 : useSpecFetcher.SpecType.ASYNCAPI_2
687
- });
688
- }
689
- }, [parsedSpec, onSpecLoaded]);
690
- const navItems = React.useMemo(() => {
691
- if (!parsedSpec) return [];
692
- const channelItems = parsedSpec.channels.map((ch) => {
693
- const actionLabels = ch.operations.map(
694
- (op) => op.action.toUpperCase()
695
- ).join("/");
696
- return {
697
- id: `channel-${ch.name}`,
698
- label: ch.address,
699
- badge: actionLabels || void 0,
700
- badgeColor: ch.operations[0]?.action === "subscribe" || ch.operations[0]?.action === "receive" ? "var(--omnispec-color-subscribe)" : "var(--omnispec-color-publish)"
701
- };
702
- });
703
- const items = [];
704
- if (parsedSpec.servers.length > 0) {
705
- items.push({ id: "servers", label: "Servers" });
706
- }
707
- items.push({
708
- id: "channels",
709
- label: "Channels",
710
- children: channelItems
711
- });
712
- if (Object.keys(parsedSpec.components.schemas).length > 0) {
713
- items.push({
714
- id: "schemas",
715
- label: "Schemas",
716
- children: Object.keys(parsedSpec.components.schemas).map((name) => ({
717
- id: `schema-${name}`,
718
- label: name
719
- }))
720
- });
721
- }
722
- return items;
723
- }, [parsedSpec]);
724
- const filteredChannels = React.useMemo(() => {
725
- if (!parsedSpec || !searchQuery.trim()) return parsedSpec?.channels ?? [];
726
- const q = searchQuery.toLowerCase();
727
- return parsedSpec.channels.filter(
728
- (ch) => ch.address.toLowerCase().includes(q) || ch.description?.toLowerCase().includes(q) || ch.operations.some(
729
- (op) => op.operationId?.toLowerCase().includes(q) || op.summary?.toLowerCase().includes(q)
730
- )
731
- );
732
- }, [parsedSpec, searchQuery]);
733
- const handleNavSelect = React.useCallback((id) => {
734
- const el = document.getElementById(id);
735
- el?.scrollIntoView({ behavior: "smooth", block: "start" });
736
- }, []);
737
- const navSectionIds = React.useMemo(() => Collapsible.flattenNavItemIds(navItems), [navItems]);
738
- const activeSection = Collapsible.useScrollSpy(navSectionIds);
739
- if (state.status === "loading") {
740
- return /* @__PURE__ */ jsxRuntime.jsx(useSpecFetcher.ThemeProvider, { theme, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: `omnispec-asyncapi ${className ?? ""}`, children: /* @__PURE__ */ jsxRuntime.jsx(useSpecFetcher.LoadingScreen, {}) }) });
741
- }
742
- if (state.status === "error") {
743
- return /* @__PURE__ */ jsxRuntime.jsx(
744
- useSpecFetcher.SpecStatusScreen,
745
- {
746
- theme,
747
- layout,
748
- sidebarPosition,
749
- slots,
750
- sidebarNav,
751
- premiumThemingEnabled: pro?.premiumThemingEnabled ?? false,
752
- className: `omnispec-asyncapi ${className ?? ""}`,
753
- children: /* @__PURE__ */ jsxRuntime.jsx(useSpecFetcher.ErrorMessage, { title: "Failed to load specification", message: state.error })
754
- }
755
- );
756
- }
757
- if (!parsedSpec) return null;
758
- const specNav = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
759
- /* @__PURE__ */ jsxRuntime.jsx(
760
- Collapsible.SearchBar,
761
- {
762
- placeholder: "Filter channels...",
763
- onSearch: setSearchQuery
764
- }
765
- ),
766
- /* @__PURE__ */ jsxRuntime.jsx(
767
- useSpecFetcher.NavTree,
768
- {
769
- items: navItems,
770
- activeId: activeSection,
771
- onSelect: handleNavSelect
772
- }
773
- )
774
- ] });
775
- const sidebar = useSpecFetcher.buildSidebar(sidebarNav, specNav);
776
- const resolvedDownloadLink = Collapsible.resolveDownloadLink(downloadLink, spec);
777
- return /* @__PURE__ */ jsxRuntime.jsx(useSpecFetcher.ConfigProvider, { config: { allowTryIt: false, layout, sidebarPosition, defaultExpandOperations, schemaStyle: resolvedSchemaStyle, slots, proRenderers: pro?.renderers ?? /* @__PURE__ */ new Map(), premiumThemingEnabled: pro?.premiumThemingEnabled ?? false }, children: /* @__PURE__ */ jsxRuntime.jsx(Collapsible.ExpandProvider, { expandAll: allExpanded, expandGeneration, children: /* @__PURE__ */ jsxRuntime.jsx(useSpecFetcher.ThemeProvider, { theme, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: `omnispec-asyncapi ${className ?? ""}`, children: /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundary.ErrorBoundary, { title: "Failed to render this API reference", children: /* @__PURE__ */ jsxRuntime.jsxs(
778
- useSpecFetcher.DocLayout,
779
- {
780
- layout,
781
- sidebarPosition,
782
- sidebar,
783
- sidebarHeader: slots.sidebarHeader,
784
- sidebarFooter: slots.sidebarFooter,
785
- header: slots.header,
786
- footer: slots.footer,
787
- children: [
788
- /* @__PURE__ */ jsxRuntime.jsx(
789
- Collapsible.SpecToolbar,
790
- {
791
- overview: /* @__PURE__ */ jsxRuntime.jsx(AsyncOverview, { spec: parsedSpec }),
792
- expandLabel: "channels",
793
- allExpanded,
794
- onToggleExpand: handleToggleExpand,
795
- downloadLink: resolvedDownloadLink
796
- }
797
- ),
798
- /* @__PURE__ */ jsxRuntime.jsx("div", { id: "servers", children: /* @__PURE__ */ jsxRuntime.jsx(ServerList, { servers: parsedSpec.servers }) }),
799
- /* @__PURE__ */ jsxRuntime.jsxs("div", { id: "channels", children: [
800
- /* @__PURE__ */ jsxRuntime.jsx("h2", { className: css.css({ margin: "0 0 16px", fontSize: "var(--omnispec-h2-font-size)", fontWeight: "var(--omnispec-h2-font-weight)", color: "var(--omnispec-h2-color)" }), children: "Channels" }),
801
- filteredChannels.map((channel) => /* @__PURE__ */ jsxRuntime.jsx(
802
- ChannelDetail,
803
- {
804
- id: `channel-${channel.name}`,
805
- channel,
806
- expandAll: allExpanded,
807
- expandGeneration
808
- },
809
- channel.name
810
- ))
811
- ] }),
812
- /* @__PURE__ */ jsxRuntime.jsx(ComponentsSection, { components: parsedSpec.components })
813
- ]
814
- }
815
- ) }) }) }) }) });
816
- }
817
-
818
- exports.AsyncApiSpec = AsyncApiSpec;
819
- //# sourceMappingURL=AsyncApiSpec-TBlyRxTP.js.map