@redocly/api-docs 0.2.0-next.5 → 0.2.0-next.7

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 (173) hide show
  1. package/lib/RedocStandalone.d.ts +38 -0
  2. package/lib/RedocStandalone.js +1 -0
  3. package/lib/RedoclyApiDocs.js +1 -1
  4. package/lib/RedoclyApiDocsStandalone.d.ts +2 -0
  5. package/lib/RedoclyApiDocsStandalone.js +3 -3
  6. package/lib/adapters/asyncapi/items/overview/content.js +1 -1
  7. package/lib/adapters/graphql/group/utils.js +1 -1
  8. package/lib/adapters/graphql/utils/createApiItem.js +1 -1
  9. package/lib/adapters/openapi/build-code-sample-source.d.ts +1 -1
  10. package/lib/adapters/openapi/build-code-sample-source.js +1 -1
  11. package/lib/adapters/openapi/configure/merge-utils.d.ts +1 -1
  12. package/lib/adapters/openapi/configure/resolve-request-values.js +1 -1
  13. package/lib/adapters/openapi/index.js +1 -1
  14. package/lib/adapters/openapi/items/operation/content.js +1 -1
  15. package/lib/adapters/openapi/items/operation/item.js +1 -1
  16. package/lib/adapters/openapi/items/overview/content.js +1 -1
  17. package/lib/adapters/openapi/utils/merge-mock-server.d.ts +2 -2
  18. package/lib/adapters/utils/markdoc.d.ts +4 -1
  19. package/lib/adapters/utils/markdoc.js +1 -1
  20. package/lib/components/ErrorBoundary.d.ts +4 -2
  21. package/lib/components/ErrorBoundary.js +1 -1
  22. package/lib/components/Header/HeaderItem.js +5 -5
  23. package/lib/components/Header/HeaderPageActions.d.ts +4 -0
  24. package/lib/components/Header/HeaderPageActions.js +1 -0
  25. package/lib/components/Header/PageActions.d.ts +4 -0
  26. package/lib/components/Header/PageActions.js +11 -0
  27. package/lib/components/ItemContent/sections/MessagesSection.js +1 -1
  28. package/lib/components/Mcp/McpPrompt.js +1 -1
  29. package/lib/components/Mcp/McpTool.js +1 -1
  30. package/lib/components/Mcp/utils.d.ts +1 -1
  31. package/lib/components/Mcp/utils.js +1 -1
  32. package/lib/components/Schema/styled.js +4 -4
  33. package/lib/components/Schema/views/ArrayRenderer.js +1 -1
  34. package/lib/components/Schema/views/DiscriminatorPropertyRow.js +1 -1
  35. package/lib/components/Schema/views/Examples.js +1 -1
  36. package/lib/components/Search/index.d.ts +15 -0
  37. package/lib/components/Search/index.js +1 -0
  38. package/lib/components/Security/SecurityFlowDetail.js +1 -1
  39. package/lib/components/Security/styled.js +7 -7
  40. package/lib/components/StickySidebar/FloatingButton.d.ts +1 -0
  41. package/lib/components/StickySidebar/FloatingButton.js +32 -0
  42. package/lib/components/StickySidebar/RedoclyAttributionLogo.d.ts +5 -0
  43. package/lib/components/StickySidebar/RedoclyAttributionLogo.js +1 -0
  44. package/lib/components/StickySidebar/StickySidebar.js +33 -9
  45. package/lib/components/common/Breadcrumbs.js +2 -2
  46. package/lib/components/common/ResponseCodeTabs.js +1 -1
  47. package/lib/components/common/Tag.js +1 -1
  48. package/lib/components/common/ViewNested.js +2 -2
  49. package/lib/components/graphql/GraphQLFieldView.js +1 -1
  50. package/lib/components/graphql/RequiresScopesModal.js +3 -3
  51. package/lib/components/graphql/sections/GraphQLArgsSection.js +1 -1
  52. package/lib/components/markdoc/SchemaDefinition.js +1 -1
  53. package/lib/components/panels/ExampleItem/CodeSampleItem.js +1 -1
  54. package/lib/components/panels/ExampleItem/ResponseExampleItem.js +1 -1
  55. package/lib/components/panels/ExampleItem/SecuritySchemeSelector.d.ts +9 -0
  56. package/lib/components/panels/ExampleItem/SecuritySchemeSelector.js +1 -0
  57. package/lib/components/panels/ExampleItem/ServerDropdown.js +1 -1
  58. package/lib/components/panels/ExampleItem/generate-request-sample.d.ts +28 -0
  59. package/lib/components/panels/ExampleItem/generate-request-sample.js +1 -0
  60. package/lib/components/panels/ExampleItem/styled.d.ts +1 -49
  61. package/lib/components/panels/ExampleItem/useActiveServer.d.ts +17 -0
  62. package/lib/components/panels/ExampleItem/useActiveServer.js +1 -0
  63. package/lib/components/panels/ExampleItem/useCodeSampleLanguages.d.ts +23 -0
  64. package/lib/components/panels/ExampleItem/useCodeSampleLanguages.js +1 -0
  65. package/lib/components/panels/ExampleItem/useReplayRequestState.d.ts +18 -0
  66. package/lib/components/panels/ExampleItem/useReplayRequestState.js +1 -0
  67. package/lib/components/panels/ExampleItem/useTryItFooter.d.ts +3 -0
  68. package/lib/components/panels/ExampleItem/useTryItFooter.js +7 -0
  69. package/lib/components/panels/GroupPanelItem.js +1 -1
  70. package/lib/components/panels/LanguageItem/LanguagePanelItem.js +5 -1
  71. package/lib/components/panels/LanguageItem/styled.js +17 -14
  72. package/lib/components/panels/McpExamplePanelItem.js +2 -2
  73. package/lib/components/panels/McpPanelItem.js +2 -2
  74. package/lib/components/panels/ServerItem/ServerItem.js +1 -1
  75. package/lib/components/panels/asyncapi/BrokerItem/BrokerModal.js +1 -1
  76. package/lib/components/panels/asyncapi/BrokerItem/BrokerPanelItem.js +1 -1
  77. package/lib/components/panels/shared-panel-styles.js +1 -1
  78. package/lib/components/panels/styled.js +1 -1
  79. package/lib/components/pluggable/RedocResponseSamples.js +1 -1
  80. package/lib/hoc/withLicenseGate.d.ts +5 -0
  81. package/lib/hoc/withLicenseGate.js +1 -0
  82. package/lib/hoc/withStoreProvider.d.ts +2 -0
  83. package/lib/hoc/withStoreProvider.js +1 -1
  84. package/lib/hooks/useCopySpecSlice.d.ts +9 -0
  85. package/lib/hooks/useCopySpecSlice.js +1 -0
  86. package/lib/hooks/useInitialTelemetry.d.ts +2 -0
  87. package/lib/hooks/useInitialTelemetry.js +1 -0
  88. package/lib/hooks/useLicense.js +1 -1
  89. package/lib/hooks/useLicenseGate.d.ts +6 -0
  90. package/lib/hooks/useLicenseGate.js +1 -0
  91. package/lib/hooks/useScrollSpyUrlSync.js +1 -1
  92. package/lib/index.d.ts +6 -1
  93. package/lib/index.js +1 -1
  94. package/lib/jotai/app.d.ts +6 -0
  95. package/lib/jotai/app.js +1 -1
  96. package/lib/jotai/examples.js +1 -1
  97. package/lib/jotai/store.d.ts +4 -0
  98. package/lib/jotai/store.js +1 -1
  99. package/lib/options/editionOverrides.d.ts +3 -0
  100. package/lib/options/editionOverrides.js +1 -0
  101. package/lib/options/helpers.d.ts +1 -2
  102. package/lib/options/helpers.js +1 -1
  103. package/lib/options/normalizeOptions.d.ts +1 -1
  104. package/lib/options/normalizeOptions.js +1 -1
  105. package/lib/options/standaloneLayoutVars.d.ts +3 -0
  106. package/lib/options/standaloneLayoutVars.js +1 -0
  107. package/lib/pages/ItemPage.js +4 -2
  108. package/lib/services/code-samples/apply-env-variables.d.ts +8 -0
  109. package/lib/services/code-samples/apply-env-variables.js +1 -0
  110. package/lib/services/code-samples/builder.js +1 -1
  111. package/lib/services/code-samples/language-availability.d.ts +4 -0
  112. package/lib/services/code-samples/language-availability.js +1 -0
  113. package/lib/services/code-samples/{replay/normalize-servers.d.ts → normalize-servers.d.ts} +1 -1
  114. package/lib/services/code-samples/normalize-servers.js +1 -0
  115. package/lib/services/code-samples/replay/from-openapi-document.d.ts +8 -1
  116. package/lib/services/code-samples/replay/from-openapi-document.js +1 -1
  117. package/lib/services/code-samples/replay/index.d.ts +1 -1
  118. package/lib/services/code-samples/replay/index.js +1 -1
  119. package/lib/services/code-samples/replay/replay-predefined-env.d.ts +1 -2
  120. package/lib/services/code-samples/replay/replay-predefined-env.js +1 -1
  121. package/lib/services/code-samples/server-env.d.ts +3 -0
  122. package/lib/services/code-samples/server-env.js +1 -0
  123. package/lib/services/code-samples/source.d.ts +3 -3
  124. package/lib/services/license/check.d.ts +1 -0
  125. package/lib/services/license/check.js +1 -1
  126. package/lib/services/operation-samples/index.js +1 -1
  127. package/lib/services/search/indexer.d.ts +9 -0
  128. package/lib/services/search/indexer.js +1 -0
  129. package/lib/services/search/types.d.ts +27 -0
  130. package/lib/services/search/types.js +0 -0
  131. package/lib/services/spec-slice/assistant-links.d.ts +9 -0
  132. package/lib/services/spec-slice/assistant-links.js +5 -0
  133. package/lib/services/spec-slice/asyncapi-slice.d.ts +5 -0
  134. package/lib/services/spec-slice/asyncapi-slice.js +1 -0
  135. package/lib/services/spec-slice/clone-strip.d.ts +1 -0
  136. package/lib/services/spec-slice/clone-strip.js +1 -0
  137. package/lib/services/spec-slice/component-closure.d.ts +6 -0
  138. package/lib/services/spec-slice/component-closure.js +1 -0
  139. package/lib/services/spec-slice/graphql-slice.d.ts +2 -0
  140. package/lib/services/spec-slice/graphql-slice.js +1 -0
  141. package/lib/services/spec-slice/index.d.ts +6 -0
  142. package/lib/services/spec-slice/index.js +1 -0
  143. package/lib/services/spec-slice/openapi-slice.d.ts +6 -0
  144. package/lib/services/spec-slice/openapi-slice.js +1 -0
  145. package/lib/services/spec-slice/resolve-scope.d.ts +4 -0
  146. package/lib/services/spec-slice/resolve-scope.js +1 -0
  147. package/lib/services/spec-slice/types.d.ts +37 -0
  148. package/lib/services/spec-slice/types.js +0 -0
  149. package/lib/standalone.d.ts +19 -0
  150. package/lib/standalone.js +2 -0
  151. package/lib/standaloneThemeConfig.d.ts +3 -0
  152. package/lib/standaloneThemeConfig.js +1 -0
  153. package/lib/telemetry/RedocTelemetry.d.ts +3 -0
  154. package/lib/telemetry/RedocTelemetry.js +1 -1
  155. package/lib/telemetry/defaults.d.ts +2 -0
  156. package/lib/telemetry/defaults.js +1 -0
  157. package/lib/types/code-samples-config.d.ts +68 -0
  158. package/lib/types/code-samples-config.js +0 -0
  159. package/lib/types/common.d.ts +1 -1
  160. package/lib/types/content.d.ts +4 -3
  161. package/lib/types/edition-config.d.ts +4 -0
  162. package/lib/types/edition-config.js +0 -0
  163. package/lib/types/events.d.ts +2 -2
  164. package/lib/types/openapi.d.ts +2 -1
  165. package/lib/types/options.d.ts +24 -88
  166. package/lib/utils/compose.d.ts +1 -0
  167. package/lib/utils/deep-link.d.ts +1 -0
  168. package/lib/utils/deep-link.js +1 -1
  169. package/lib/utils/extract-extensions.js +1 -1
  170. package/lib/utils/x-logo.d.ts +13 -0
  171. package/lib/utils/x-logo.js +1 -0
  172. package/package.json +19 -8
  173. package/lib/services/code-samples/replay/normalize-servers.js +0 -1
@@ -0,0 +1,38 @@
1
+ import type { ReactElement, ReactNode } from 'react';
2
+ import type { ApiItem, ApiStore } from './types/store.js';
3
+ import type { ApiSpecType } from './types/common.js';
4
+ import type { RawApiDocsOptions } from './types/options.js';
5
+ import type { RedocTelemetryConfig } from './telemetry/RedocTelemetry.js';
6
+ import type { MarkdownAdapter } from './contexts/markdownAdapter.js';
7
+ import type { RedoclyApiDocsStandaloneProps } from './RedoclyApiDocsStandalone.js';
8
+ type RedocStandaloneProps = {
9
+ /** Parsed definition object, or a GraphQL SDL string when `specType` is `graphql`. */
10
+ definition?: Record<string, unknown> | string;
11
+ /** URL to fetch the definition from. Ignored when `definition` is provided. */
12
+ definitionUrl?: string;
13
+ /** Detected automatically when omitted (`.graphql`/`.gql` URL or document shape). */
14
+ specType?: ApiSpecType;
15
+ options?: Partial<RawApiDocsOptions>;
16
+ basePath?: string;
17
+ logo?: RedoclyApiDocsStandaloneProps['logo'];
18
+ markdownAdapter?: MarkdownAdapter;
19
+ telemetryConfig?: Partial<RedocTelemetryConfig>;
20
+ onLoaded?: (error?: Error) => void;
21
+ /** Rendered while the definition is loading. */
22
+ children?: ReactNode;
23
+ };
24
+ type PreparedApiDocs = {
25
+ items: ApiItem[];
26
+ store: ApiStore;
27
+ options: RawApiDocsOptions;
28
+ specType: ApiSpecType;
29
+ /** Bundled definition, or the raw SDL string for GraphQL. */
30
+ document?: Record<string, unknown> | string;
31
+ };
32
+ export declare function detectSpecType({ definition, definitionUrl, specType, }: Pick<RedocStandaloneProps, 'definition' | 'definitionUrl' | 'specType'>): ApiSpecType | undefined;
33
+ declare function prepareApiDocs({ definition, definitionUrl, specType, options, basePath, }: Pick<RedocStandaloneProps, 'definition' | 'definitionUrl' | 'specType' | 'options' | 'basePath'>): Promise<PreparedApiDocs>;
34
+ /** Loads and bundles the definition, builds the item model, and renders `RedoclyApiDocsStandalone`. */
35
+ declare const RedocStandalone: ({ definition, definitionUrl, specType, options, basePath, logo, markdownAdapter, telemetryConfig, onLoaded, children, }: RedocStandaloneProps) => ReactElement | null;
36
+ export { RedocStandalone, prepareApiDocs };
37
+ export type { RedocStandaloneProps };
38
+ export default RedocStandalone;
@@ -0,0 +1 @@
1
+ import{Fragment as b,jsx as d,jsxs as x}from"react/jsx-runtime";import{useEffect as E,useMemo as L,useState as P}from"react";import{Loading as S}from"@redocly/theme/components/Loaders/Loading";import{RedoclyApiDocsStandalone as T}from"./RedoclyApiDocsStandalone.js";import{buildItems as k}from"./adapters/build.js";import{markdocParser as D}from"./components/markdoc/markdocParser.js";import{argValueToBoolean as w}from"./options/helpers.js";import{loadAndBundleDefinition as I}from"./utils/loadAndBundleSpec.js";import{logoFromDefinition as v}from"./utils/x-logo.js";import{apiSpecType as s}from"./types/common.js";const B=/\.(graphql|gql)([?#]|$)/i;function F({definition:e,definitionUrl:r,specType:o}){if(o)return o;if(typeof e=="string"||B.test(r??""))return s.GRAPHQL;if(e&&typeof e=="object")return"asyncapi"in e?s.ASYNCAPI:s.OPENAPI}function G(e){if(typeof e!="object"||e===null)throw new Error('"definition" must be an object when "skipBundle" is enabled');return e}async function H({definition:e,definitionUrl:r,specType:o,skipBundle:a}){if(e===void 0&&r===void 0)throw new Error('Either "definition" or "definitionUrl" must be provided');const n=F({definition:e,definitionUrl:r,specType:o});if(n===s.GRAPHQL){const p=typeof e=="string"?e:await(await fetch(r)).text(),{parse:i}=await import("graphql");return{document:i(p),type:s.GRAPHQL,sdl:p}}const t=a?G(e):await I(e??r),c=n??(t&&typeof t=="object"&&"asyncapi"in t?s.ASYNCAPI:s.OPENAPI);return{document:t,type:c}}async function h({definition:e,definitionUrl:r,specType:o,options:a={},basePath:n="/"}){const t=await H({definition:e,definitionUrl:r,specType:o,skipBundle:w(a.skipBundle,!1)}),c={specType:t.type,metadata:{type:t.type},...a},{items:p,store:i}=await k({type:t.type,document:t.document,options:c,basePath:n,markdownParser:D});return{items:p,store:i,options:c,specType:t.type,document:t.type===s.GRAPHQL?t.sdl:t.document}}const j=({definition:e,definitionUrl:r,specType:o,options:a,basePath:n="/",logo:t,markdownAdapter:c,telemetryConfig:p,onLoaded:i,children:f})=>{const[u,y]=P(null),[g,A]=P(null),R=L(()=>({typeOfUsage:"react",...p}),[p]);return E(()=>{let m=!1;return y(null),A(null),h({definition:e,definitionUrl:r,specType:o,options:a,basePath:n}).then(l=>{m||(y(l),i?.())}).catch(l=>{m||(A(l),i?.(l))}),()=>{m=!0}},[e,r,o,n]),g?x("div",{role:"alert",style:{padding:"1em",fontFamily:"monospace",color:"#e53e3e"},children:["Failed to load API definition: ",g.message]}):u?d(T,{items:u.items,store:u.store,basePath:n,options:u.options,logo:t??v(u.document),markdownAdapter:c,telemetryConfig:R,definition:u.document,definitionUrl:r}):f!==void 0?d(b,{children:f}):w(a?.hideLoading,!1)?null:d(S,{color:"--loading-spinner-color"})};var z=j;export{j as RedocStandalone,z as default,F as detectSpecType,h as prepareApiDocs};
@@ -1 +1 @@
1
- import{jsx as t,jsxs as f}from"react/jsx-runtime";import{memo as g,useCallback as S,useMemo as b}from"react";import{useAtomValue as v}from"jotai";import{GlobalStyle as T}from"@redocly/theme/core/openapi";import{RedocTelemetry as w}from"./telemetry/RedocTelemetry.js";import{TelemetryContext as x}from"./contexts/telemetry.js";import{MarkdownAdapterProvider as R}from"./contexts/markdownAdapter.js";import{specTypeAtom as P}from"./jotai/store.js";import{useApiDocsRoutes as A}from"./hooks/useApiDocsRoutes.js";import{useTelemetry as C}from"./hooks/useTelemetry.js";import{useVisitedChannelsTracker as k}from"./hooks/useVisitedChannelsTracker.js";import{useRouterHashBridge as j}from"./hooks/useRouterHashBridge.js";import{useScrollSpyUrlSync as D}from"./hooks/useScrollSpyUrlSync.js";import{useTelemetryPageMetrics as E}from"./hooks/useTelemetryPageMetrics.js";import{EntryPage as V}from"./pages/EntryPage.js";import{ErrorBoundary as B}from"./components/ErrorBoundary.js";import{compose as M}from"./utils/compose.js";import{withRouter as U}from"./hoc/withRouter.js";import{withStoreProvider as I}from"./hoc/withStoreProvider.js";import{withReplayPrefetch as N}from"./hoc/withReplayPrefetch.js";const u=r=>{const{items:s=[],basePath:o,markdownAdapter:m,telemetryConfig:e}=r,{routeIndex:c}=A(s,o),i=v(P),n=e?.specType,l=e?.collectorUrl,p=e?.serviceName,a=e?.serviceVersion,d=e?.disabled,h=b(()=>new w({specType:n??i,collectorUrl:l,serviceName:p??"realm-ui",serviceVersion:a,disabled:d}),[i,n,l,p,a,d]);return t(R,{value:m,children:f(x.Provider,{value:h,children:[t(H,{}),t(_,{routeIndex:c,basePath:o})]})})};function H(){return k(),j(),D(),null}const _=({routeIndex:r,basePath:s})=>{const o=C();E();const m=S((e,c)=>{o.sendErrorMessage([{id:"errorBoundaryCatch",object:"error",uri:typeof window<"u"?window.location.href:"",details:{message:e.message,stack:c.componentStack??void 0}}])},[o]);return f(B,{onError:m,children:[t(T,{}),t(V,{routeIndex:r,basePath:s})]})},y=M(I,U,g,r=>N(r,{respectHideReplay:!0}))(u);var ce=y;export{y as RedoclyApiDocs,u as RedoclyApiDocsComponent,ce as default};
1
+ import{jsx as o,jsxs as f}from"react/jsx-runtime";import{memo as T,useMemo as v}from"react";import{useAtomValue as S}from"jotai";import{GlobalStyle as x}from"@redocly/theme/core/openapi";import{RedocTelemetry as R}from"./telemetry/RedocTelemetry.js";import{TelemetryContext as b}from"./contexts/telemetry.js";import{MarkdownAdapterProvider as P}from"./contexts/markdownAdapter.js";import{specTypeAtom as A}from"./jotai/store.js";import{useApiDocsRoutes as w}from"./hooks/useApiDocsRoutes.js";import{useVisitedChannelsTracker as U}from"./hooks/useVisitedChannelsTracker.js";import{useRouterHashBridge as C}from"./hooks/useRouterHashBridge.js";import{useScrollSpyUrlSync as D}from"./hooks/useScrollSpyUrlSync.js";import{useTelemetryPageMetrics as V}from"./hooks/useTelemetryPageMetrics.js";import{useInitialTelemetry as j}from"./hooks/useInitialTelemetry.js";import{EntryPage as I}from"./pages/EntryPage.js";import{ErrorBoundary as k}from"./components/ErrorBoundary.js";import{compose as B}from"./utils/compose.js";import{withRouter as M}from"./hoc/withRouter.js";import{withStoreProvider as N}from"./hoc/withStoreProvider.js";import{withLicenseGate as O}from"./hoc/withLicenseGate.js";import{withReplayPrefetch as E}from"./hoc/withReplayPrefetch.js";const d=e=>{const{items:t=[],basePath:s,markdownAdapter:y,telemetryConfig:r}=e,{routeIndex:h}=w(t,s),m=S(A),i=r?.specType,c=r?.collectorUrl,p=r?.serviceName,n=r?.serviceVersion,l=r?.disabled,a=r?.typeOfUsage,g=v(()=>new R({specType:i??m,collectorUrl:c,serviceName:p,serviceVersion:n,disabled:l,typeOfUsage:a}),[m,i,c,p,n,l,a]);return o(P,{value:y,children:f(b.Provider,{value:g,children:[o(G,{}),o(H,{routeIndex:h,basePath:s})]})})};function G(){return U(),C(),D(),null}const H=({routeIndex:e,basePath:t})=>(V(),j(),f(k,{children:[o(x,{}),o(I,{routeIndex:e,basePath:t})]})),u=B(N,M,T,e=>O(e),e=>E(e,{respectHideReplay:!0}))(d);var pe=u;export{u as RedoclyApiDocs,d as RedoclyApiDocsComponent,pe as default};
@@ -11,6 +11,8 @@ type RedoclyApiDocsStandaloneProps = {
11
11
  logo?: RawLogo;
12
12
  telemetryConfig?: Partial<RedocTelemetryConfig>;
13
13
  markdownAdapter?: MarkdownAdapter;
14
+ definition?: Record<string, unknown> | string;
15
+ definitionUrl?: string;
14
16
  };
15
17
  declare const RedoclyApiDocsStandalone: import("react").FC<any>;
16
18
  export { RedoclyApiDocsStandalone };
@@ -1,4 +1,4 @@
1
- import{Fragment as j,jsx as o,jsxs as f}from"react/jsx-runtime";import{memo as D,useMemo as a}from"react";import{createMarkdocAdapter as O}from"./components/markdoc/markdocAdapter.js";import{styled as h}from"styled-components";import{useAtomValue as e}from"jotai";import{SidebarLogo as z}from"@redocly/theme/components/SidebarLogo/SidebarLogo";import{ThemeDataContext as I}from"@redocly/theme/core/openapi";import{RedoclyApiDocsComponent as M}from"./RedoclyApiDocs.js";import{SideMenu as P}from"./components/SideMenu/SideMenu.js";import{StickySidebar as T}from"./components/StickySidebar/StickySidebar.js";import{isGraphqlDocsSidebarHidden as H}from"./options/helpers.js";import{toSidebarLogo as R}from"./utils/logo.js";import{globalOptionsAtom as V,licenseKeyAtom as _,storeAtom as F}from"./jotai/store.js";import{collapsedSidebarAtom as K}from"./jotai/app.js";import{useLicense as q}from"./hooks/useLicense.js";import{LicenseOverlay as G}from"./components/LicenseOverlay.js";import{compose as N}from"./utils/compose.js";import{withRouter as Y}from"./hoc/withRouter.js";import{withStoreProvider as $}from"./hoc/withStoreProvider.js";import{useCodeHighlight as B}from"./hooks/useCodeHighlight.js";const E=({children:t})=>{const r=a(()=>({hooks:{useCodeHighlight:()=>({highlight:B})}}),[]);return o(I.Provider,{value:r,children:t})},p=N($,Y,D)(({items:t,basePath:r,logo:g,telemetryConfig:b,markdownAdapter:n})=>{const i=e(V),u=e(F),v=e(_),{isValid:s,licenseInfo:y,isPending:S}=q(v),m=s?t:[],{hideSidebar:x,scrollYOffset:l,markdocOptions:d}=i,A=a(()=>n??O(d),[n,d]),k=e(K),w=!x&&!H(i),L=R(g)??i.apiLogo??u.logo,C=a(()=>{const c=l?.()??0;return c>0?{"--navbar-height":`${c}px`}:void 0},[l]);return o(E,{children:f(J,{style:C,children:[!S&&!s&&o(G,{licenseInfo:y}),w&&o(j,{children:f(T,{className:"menu-content",collapsedSidebar:k,children:[o(z,{dataTestId:"logo",...L}),o(P,{items:m})]})}),o(Q,{children:o(M,{items:m,basePath:r,markdownAdapter:A,telemetryConfig:b})})]})})}),J=h.div`
1
+ import{jsx as o,jsxs as l}from"react/jsx-runtime";import{memo as S,useMemo as i}from"react";import{createMarkdocAdapter as x}from"./components/markdoc/markdocAdapter.js";import{styled as d}from"styled-components";import{useAtomValue as a}from"jotai";import{SidebarLogo as k}from"@redocly/theme/components/SidebarLogo/SidebarLogo";import{ThemeDataContext as A}from"@redocly/theme/core/openapi";import{RedoclyApiDocsComponent as w}from"./RedoclyApiDocs.js";import{SideMenu as L}from"./components/SideMenu/SideMenu.js";import{StickySidebar as C}from"./components/StickySidebar/StickySidebar.js";import{getStandaloneLayoutStyle as j}from"./options/standaloneLayoutVars.js";import{toSidebarLogo as z}from"./utils/logo.js";import{globalOptionsAtom as D,storeAtom as M}from"./jotai/store.js";import{collapsedSidebarAtom as T}from"./jotai/app.js";import{useLicenseGate as O}from"./hooks/useLicenseGate.js";import{compose as P}from"./utils/compose.js";import{withRouter as R}from"./hoc/withRouter.js";import{withStoreProvider as H}from"./hoc/withStoreProvider.js";import{useCodeHighlight as I}from"./hooks/useCodeHighlight.js";const _=({children:e})=>{const r=i(()=>({hooks:{useCodeHighlight:()=>({highlight:I})}}),[]);return o(A.Provider,{value:r,children:e})},c=P(H,R,S)(({items:e,basePath:r,logo:p,telemetryConfig:h,markdownAdapter:n})=>{const t=a(D),f=a(M),{gatedItems:m,overlay:g}=O(e),{markdocOptions:s}=t,b=i(()=>n??x(s),[n,s]),u=a(T),v=z(p)??t.apiLogo??f.logo,y=i(()=>j(t),[t]);return o(_,{children:l(G,{style:y,children:[g,l(C,{className:"menu-content",collapsedSidebar:u,children:[o(k,{dataTestId:"logo",...v}),o(L,{items:m})]}),o(N,{children:o(w,{items:m,basePath:r,markdownAdapter:b,telemetryConfig:h})})]})})}),G=d.div`
2
2
  display: flex;
3
3
  position: relative;
4
4
  min-height: 100vh;
@@ -20,7 +20,7 @@ import{Fragment as j,jsx as o,jsxs as f}from"react/jsx-runtime";import{memo as D
20
20
  * {
21
21
  box-sizing: border-box;
22
22
  }
23
- `,Q=h.div`
23
+ `,N=d.div`
24
24
  flex: 1;
25
25
  min-width: 0;
26
- `;var uo=p;export{p as RedoclyApiDocsStandalone,uo as default};
26
+ `;var ao=c;export{c as RedoclyApiDocsStandalone,ao as default};
@@ -1 +1 @@
1
- import{extractContentUntilFirstHeading as u}from"../../../utils/markdoc.js";import{parseMarkdown as T}from"../../../utils/parseMarkdown.js";import{contentType as h,nodeTypes as n}from"../../../../types/common.js";import{buildDownloadPanelContent as C}from"../../panels/download.js";import{buildOverviewPanelContent as R}from"../../panels/overview.js";import{buildBrokersPanelContent as v}from"../../panels/brokers.js";import{buildInfoMetadataContentNode as I}from"../../../utils/infoMetadata.js";function V({document:t,options:o,protocol:a,sectionChildren:p,basePath:s}){const e=t.info,c=u(e?.description,o),f=[C(o.downloadUrls??[]),R(e),...t.servers?[v(t.servers,a,o)]:[]],r={nodeType:n.OVERVIEW_SECTION_WRAPPER,children:[{nodeType:n.HEADER,showPageActions:!0,level:1,label:`${e?.title??""} ${e?.version??""}`.trim()}],sectionId:s};c?.length&&r.children.push({nodeType:n.OVERVIEW_SECTION_WRAPPER,children:[{nodeType:n.MARKDOC,content:c}],sectionId:s});const i=e?.externalDocs;if(i?.url){const m=T(i.description,o)??[];r.children.push({nodeType:n.EXTERNAL_DOCS,url:i.url,description:m})}const l=I(e,o.hideInfoMetadata),d=[r];l&&d.push(l),d.push(...p);const E={nodeType:n.CONTAINER,panels:f,children:d};return{contentType:h.OVERVIEW,children:[E]}}export{V as buildOverviewContent};
1
+ import{extractContentUntilFirstHeading as u}from"../../../utils/markdoc.js";import{parseMarkdown as T}from"../../../utils/parseMarkdown.js";import{contentType as h,nodeTypes as n}from"../../../../types/common.js";import{buildDownloadPanelContent as C}from"../../panels/download.js";import{buildOverviewPanelContent as R}from"../../panels/overview.js";import{buildBrokersPanelContent as v}from"../../panels/brokers.js";import{buildInfoMetadataContentNode as I}from"../../../utils/infoMetadata.js";function V({document:t,options:o,protocol:a,sectionChildren:p,basePath:s}){const e=t.info,c=u(e?.description,o),f=[C(o.downloadUrls??[]),R(e),...t.servers?[v(t.servers,a,o)]:[]],r={nodeType:n.OVERVIEW_SECTION_WRAPPER,children:[{nodeType:n.HEADER,showPageActions:!0,level:1,label:`${e?.title??""} ${e?.version??""}`.trim()}],sectionId:s};c?.length&&r.children.push({nodeType:n.OVERVIEW_SECTION_WRAPPER,children:[{nodeType:n.MARKDOC,content:c}],sectionId:s});const i=e?.externalDocs;if(i?.url){const m=T(i.description,o)??[];r.children.push({nodeType:n.EXTERNAL_DOCS,url:i.url,description:m})}const d=[r],l=I(e,o.hideInfoMetadata);l&&d.push(l),d.push(...p);const E={nodeType:n.CONTAINER,panels:f,children:d};return{contentType:h.OVERVIEW,children:[E]}}export{V as buildOverviewContent};
@@ -1 +1 @@
1
- import{contentType as s,nodeTypes as a}from"../../../types/common.js";import{safeSlugify as c}from"../../../utils/string.js";import{joinWithSeparator as m}from"../../../utils/url.js";import{DEFAULT_GROUP_LABELS as u}from"../utils/constants.js";import{buildGroupItemsPanelContent as f}from"../panels/group-items.js";import{graphqlContext as g}from"../buildContext.js";function y({typeGroup:e,items:n,label:r,parentPath:p}){const t=g.get(),o=r??(e?u[e]:"Overview"),l=r?void 0:e?o.toLowerCase():"info.title",i=m(p??t.basePath,c(o?.toLowerCase()));return{type:"group",label:o,labelTranslationKey:l,link:i,routeSlug:i,items:n,content:t.processContent?{contentType:s.GROUP,children:[{nodeType:a.CONTAINER,children:[{nodeType:a.HEADER,level:2,label:o,labelTranslationKey:l,showPageActions:!0}],panels:[f(n,t,e)]}]}:null}}export{y as createGroup};
1
+ import{contentType as m,nodeTypes as l}from"../../../types/common.js";import{safeSlugify as p}from"../../../utils/string.js";import{joinWithSeparator as u}from"../../../utils/url.js";import{itemVariant as e}from"../../../types/common.js";import{DEFAULT_GROUP_LABELS as T}from"../utils/constants.js";import{buildGroupItemsPanelContent as E}from"../panels/group-items.js";import{graphqlContext as f}from"../buildContext.js";const A={[e.QUERY]:"queries",[e.MUTATION]:"mutations",[e.SUBSCRIPTION]:"subscriptions",[e.DIRECTIVE]:"directives",[e.OBJECT]:"objects",[e.INTERFACE]:"interfaces",[e.INPUT]:"inputs",[e.UNION]:"unions",[e.ENUM]:"enums",[e.SCALAR]:"scalars"};function d({typeGroup:t,items:r,label:i,parentPath:c}){const o=f.get(),n=i??(t?T[t]:"Overview"),s=i?void 0:t?A[t]:"info.title",a=u(c??o.basePath,p(n?.toLowerCase()));return{type:"group",label:n,labelTranslationKey:s,link:a,routeSlug:a,items:r,content:o.processContent?{contentType:m.GROUP,children:[{nodeType:l.CONTAINER,children:[{nodeType:l.HEADER,level:2,label:n,labelTranslationKey:s,showPageActions:!0}],panels:[E(r,o,t)]}]}:null}}export{d as createGroup};
@@ -1 +1 @@
1
- import{itemVariant as n}from"../../../types/common.js";import{safeSlugify as d}from"../../../utils/string.js";import{joinWithSeparator as f,normalizePath as m,toRelativePath as C}from"../../../utils/url.js";import{shouldIncludeItem as a}from"../utils/shouldIncludeItem.js";import{appendGraphqlItemFeedback as s}from"./appendGraphqlItemFeedback.js";import{buildDirectiveContent as I}from"../items/directive/content.js";import{buildQueryContent as T}from"../items/query/content.js";import{buildMutationContent as b}from"../items/mutation/content.js";import{buildSubscriptionContent as N}from"../items/subscription/content.js";import{buildUnionContent as E}from"../items/union/content.js";import{buildEnumContent as p}from"../items/enum/content.js";import{buildScalarContent as h}from"../items/scalar/content.js";import{buildInputContent as P}from"../items/input/content.js";import{buildObjectContent as S}from"../items/object/content.js";import{buildInterfaceContent as U}from"../items/interface/content.js";import{graphqlContext as A}from"../buildContext.js";const R={[n.QUERY]:"queries",[n.MUTATION]:"mutations",[n.SUBSCRIPTION]:"subscriptions",[n.DIRECTIVE]:"directives",[n.OBJECT]:"objects",[n.INTERFACE]:"interfaces",[n.UNION]:"unions",[n.ENUM]:"enums",[n.INPUT]:"inputs",[n.SCALAR]:"scalars"};function $(e){const t=A.get(),i=`${e.variant}:${e.name}`;if(e.processedItems?.has(i)||(e.filter||e.menuCommonFilter)&&!a(e.name,e.filter,e.menuCommonFilter))return null;const o=e.parentPath?e.parentPath:f(t.basePath,R[e.variant]),u=f(o,d(e.name.toLowerCase())),l=e.label??e.name;if(e.processedItems?.add(i),!t.processContent)return{type:"link",label:l,link:u,routeSlug:u,...e.deprecated&&{deprecated:!0},content:null};let r=g({variant:e.variant,source:e.source,name:e.name,markdownOptions:t.options});t.options.feedback?.hide!==!0&&r&&(r=s(r,m(C(u,t.basePath))));const c=v(e.source);return c&&r?.meta&&(r.meta.position=c),{type:"link",label:l,link:u,routeSlug:u,...e.deprecated&&{deprecated:!0},content:r}}function g({variant:e,source:t,name:i,markdownOptions:o}){switch(e){case n.DIRECTIVE:return I(t,o);case n.QUERY:return T(t,i,o);case n.MUTATION:return b(t,i,o);case n.SUBSCRIPTION:return N(t,i,o);case n.UNION:return E(t,o);case n.ENUM:return p(t,o);case n.SCALAR:return h(t,o);case n.INPUT:return P(t,o);case n.OBJECT:return S(t,o);case n.INTERFACE:return U(t,o);default:return}}function v(e){const t=e?.astNode?.loc;if(t?.startToken)return{start:{lineNumber:t.startToken.line,column:t.startToken.column},end:t.endToken?{lineNumber:t.endToken.line,column:t.endToken.column}:void 0}}export{$ as createApiItem};
1
+ import{itemVariant as n}from"../../../types/common.js";import{safeSlugify as d}from"../../../utils/string.js";import{joinWithSeparator as f}from"../../../utils/url.js";import{normalizePath as m,toRelativePath as C}from"../../../utils/url.js";import{shouldIncludeItem as a}from"../utils/shouldIncludeItem.js";import{appendGraphqlItemFeedback as s}from"./appendGraphqlItemFeedback.js";import{buildDirectiveContent as I}from"../items/directive/content.js";import{buildQueryContent as T}from"../items/query/content.js";import{buildMutationContent as b}from"../items/mutation/content.js";import{buildSubscriptionContent as N}from"../items/subscription/content.js";import{buildUnionContent as E}from"../items/union/content.js";import{buildEnumContent as p}from"../items/enum/content.js";import{buildScalarContent as h}from"../items/scalar/content.js";import{buildInputContent as P}from"../items/input/content.js";import{buildObjectContent as S}from"../items/object/content.js";import{buildInterfaceContent as U}from"../items/interface/content.js";import{graphqlContext as A}from"../buildContext.js";const R={[n.QUERY]:"queries",[n.MUTATION]:"mutations",[n.SUBSCRIPTION]:"subscriptions",[n.DIRECTIVE]:"directives",[n.OBJECT]:"objects",[n.INTERFACE]:"interfaces",[n.UNION]:"unions",[n.ENUM]:"enums",[n.INPUT]:"inputs",[n.SCALAR]:"scalars"};function z(t){const e=A.get(),r=`${t.variant}:${t.name}`;if(t.processedItems?.has(r)||(t.filter||t.menuCommonFilter)&&!a(t.name,t.filter,t.menuCommonFilter))return null;const o=t.parentPath?t.parentPath:f(e.basePath,R[t.variant]),u=f(o,d(t.name.toLowerCase())),l=t.label??t.name;if(t.processedItems?.add(r),!e.processContent)return{type:"link",label:l,link:u,routeSlug:u,...t.deprecated&&{deprecated:!0},content:null};let i=g({variant:t.variant,source:t.source,name:t.name,markdownOptions:e.options});e.options.feedback?.hide!==!0&&i&&(i=s(i,m(C(u,e.basePath))));const c=v(t.source);return c&&i?.meta&&(i.meta.position=c),{type:"link",label:l,link:u,routeSlug:u,...t.deprecated&&{deprecated:!0},content:i}}function g({variant:t,source:e,name:r,markdownOptions:o}){switch(t){case n.DIRECTIVE:return I(e,o);case n.QUERY:return T(e,r,o);case n.MUTATION:return b(e,r,o);case n.SUBSCRIPTION:return N(e,r,o);case n.UNION:return E(e,o);case n.ENUM:return p(e,o);case n.SCALAR:return h(e,o);case n.INPUT:return P(e,o);case n.OBJECT:return S(e,o);case n.INTERFACE:return U(e,o);default:return}}function v(t){const e=t?.astNode?.loc;if(e?.startToken)return{start:{lineNumber:e.startToken.line,column:e.startToken.column},end:e.endToken?{lineNumber:e.endToken.line,column:e.endToken.column}:void 0}}export{z as createApiItem};
@@ -2,4 +2,4 @@ import type { OperationInfo } from '../../types/openapi.js';
2
2
  import type { StoreContext } from '../../types/store.js';
3
3
  import type { ApiDocsOptions } from '../../types/options.js';
4
4
  import type { CodeSampleSource } from '../../services/code-samples/index.js';
5
- export declare function buildCodeSampleSource(operationInfo: OperationInfo, storeCtx: StoreContext, options: ApiDocsOptions, ignoreNamedSchemas?: Set<string>, isWebhook?: boolean, href?: string): CodeSampleSource;
5
+ export declare function buildCodeSampleSource(operationInfo: OperationInfo, storeCtx: StoreContext, ignoreNamedSchemas?: Set<string>, isWebhook?: boolean, href?: string, options?: ApiDocsOptions): CodeSampleSource;
@@ -1 +1 @@
1
- import{REDOCLY_TEAMS_RBAC as w}from"@redocly/config";import{registerExample as O,pickRenderableDescription as M,registerSchema as R,resolveContent as A,resolveRef as S,readRbacScope as q,rbacProp as P}from"../helpers.js";import{panelKind as T,schemaKind as j}from"../../types/common.js";import{isStatusCode as C}from"../../utils/status-code.js";import{encodeJsonPointerSegment as B}from"../../utils/refPointer.js";import{applyIgnoreNamedSchemasDeep as U}from"./utils/applyIgnoreNamedSchemasDeep.js";import{mergeInMockServer as L,pickOperationServers as _}from"./utils/merge-mock-server.js";import{mergeSecurityIntoScheme as E}from"./configure/merge-utils.js";import{hasOpenApiExampleValue as $,resolveOpenApiExampleValue as g}from"./resolve-openapi-example-value.js";function D(r,n,t){const a=S(n,r,t)??r;return U(a,t)}function re(r,n,t,a,o,i){const u=n?.document??{},l=F(r,u,t),s=K(r,u,n,a),e=N(r,n),c=G(r,u,n,a),y=J(r),d=r.responses,p=d?Object.keys(d).filter(C):void 0,f=r.security;return{kind:T.CODE_SAMPLE,operationType:o?"webhook":"http",method:r.httpVerb?.toUpperCase()??"GET",path:r.pathName??"/",servers:l,parameters:s,security:e,requestBody:c,responseCodes:p,requestValues:y,pointer:r.pathName,...i&&{href:i},...r.operationId&&{openApiOperationId:r.operationId},...r.summary&&{summary:r.summary},...f&&f.length>1&&{securityGroups:f}}}function F(r,n,t){const a=n.servers,o=_(r.servers,a),u=L(o.filter(l=>typeof l?.url=="string"),t.mockServer).map(l=>({url:l.url??"",name:l.name,description:typeof l.description=="string"?l.description:void 0,...l.isMockServer&&{isMockServer:!0},variables:l.variables&&Object.keys(l.variables).length>0?Object.fromEntries(Object.entries(l.variables).map(([s,e])=>[s,{default:e.default,enum:e.enum}])):void 0}));return u.length>0?u:[{url:"/"}]}function K(r,n,t,a){const i=(r.parameters??[]).map(s=>D(s,n,a)),u={path:[],query:[],querystring:[],header:[],cookie:[]},l=r.requestValues?.serverRequestValues;for(const s of i){const e=s.in;if(!e||!u[e])continue;const c=s.content,y=c?Object.keys(c)[0]:void 0,d=y&&c?c[y]?.schema:s.schema,p=d&&typeof d=="object"?S(n,d,a)??d:d;let f;p&&t&&(f=R(t.schemaStore,t.hashIndex,{kind:j.JSON_SCHEMA,data:p}));const V=p&&typeof p=="object"&&"example"in p?p.example:void 0;let v;if(s.examples&&typeof s.examples=="object")for(const m of Object.values(s.examples)){if(!m||typeof m!="object")continue;const x=S(n,m,a)??m;if($(x)){v=g(x);break}}const b={};if(l&&s.name)for(const[m,x]of Object.entries(l)){const k=x?.[e==="querystring"?"queryString":e==="header"?"headers":e==="cookie"?"cookies":e]?.[s.name];k!=null&&(b[m]={example:k})}u[e].push({name:s.name??"",in:e,required:s.required,example:s.example??v??V,schemaId:f,serializationMime:y,style:s.style,explode:s.explode,...Object.keys(b).length>0&&{serverValues:b}})}return u}function N(r,n){const t=r.requestValues?.security,a=r.requestValues?.serverRequestValues,o=r.security,i=[];if(!o||!n)return i;for(const u of o){const l=Object.keys(u),s=l.map(e=>n.securitySchemeStore[e]).filter(Boolean).map(e=>{let c={id:e.id,type:e.type,name:e.paramName,in:e.in,scheme:e.scheme,bearerFormat:e.bearerFormat,openIdConnectUrl:e.openIdConnectUrl,flows:e.flows,"x-defaultClientId":e["x-defaultClientId"],"x-defaultAccessToken":e["x-defaultAccessToken"],"x-defaultTokenType":e["x-defaultTokenType"],"x-defaultClientSecret":e["x-defaultClientSecret"],"x-defaultUsername":e["x-defaultUsername"],"x-defaultPassword":e["x-defaultPassword"],serverValues:e.serverValues?{...e.serverValues}:void 0};if(t&&(c=E(c,t)),a)for(const[y,d]of Object.entries(a))d?.security&&(c=E(c,d.security,y));return c});if(s.length>0){const e=l.flatMap(c=>u[c]??[]);i.push({schemes:s,scopes:e})}}return i}function G(r,n,t,a){const o=r.requestBody,i=o?S(n,o,a)??o:void 0,u=A(n,i,a);if(!u||!t)return;const l={};for(const[s,e]of Object.entries(u)){let c;const y=e.itemSchema,d=e.schema??y;if(d){const V=S(n,d,a)??d;c=R(t.schemaStore,t.hashIndex,{kind:j.JSON_SCHEMA,data:V})}const p=r.pointer?`${r.pointer}/requestBody/content/${B(s)}`.replace(/^\//,""):void 0,f=[];if(e.example!==void 0&&f.push(O(t.exampleStore,{value:e.example,...p&&{id:`${p}/example`}})),e.examples){const V=q(e.examples);for(const[v,b]of Object.entries(e.examples)){if(v===w)continue;const m=S(n,b,a);if(m){const x=q(b)??q(m)??V,h=O(t.exampleStore,{value:g(m),key:v,summary:typeof m.summary=="string"?m.summary:v,description:M(m.description),externalValue:typeof m.externalValue=="string"?m.externalValue:void 0,...P(x),...p&&{id:`${p}/examples/${B(v)}`}});f.push(h)}}}l[s]={schemaId:c,...f.length>0&&{exampleIds:f}}}return l}function J(r){const n=r.requestValues?.serverRequestValues,t=r.requestValues?.envVariables;let a,o;if(t&&typeof t=="object")if("values"in t){const s=t;a=s.values,o=s.serverValues}else a=t;const i=r.requestValues?.body;let u;if(n)for(const[s,e]of Object.entries(n))e?.body!==void 0&&(u=u??{},u[s]=e.body),e?.envVariables&&(o=o??{},o[s]={...o[s],...e.envVariables});return a||o||r.requestValues?.security||i!==void 0||u?{...r.requestValues?.security&&{security:r.requestValues.security},...a&&{envVariables:a},...o&&{serverEnvVariables:o},...i!==void 0&&{body:i},...u&&{serverBody:u}}:void 0}export{re as buildCodeSampleSource};
1
+ import{REDOCLY_TEAMS_RBAC as w}from"@redocly/config";import{registerExample as O,pickRenderableDescription as M,registerSchema as R,resolveContent as A,resolveRef as S,readRbacScope as q,rbacProp as P}from"../helpers.js";import{panelKind as T,schemaKind as j}from"../../types/common.js";import{isStatusCode as C}from"../../utils/status-code.js";import{encodeJsonPointerSegment as B}from"../../utils/refPointer.js";import{applyIgnoreNamedSchemasDeep as U}from"./utils/applyIgnoreNamedSchemasDeep.js";import{pickOperationServers as L}from"./utils/merge-mock-server.js";import{mergeInMockServer as _}from"./utils/merge-mock-server.js";import{mergeSecurityIntoScheme as E}from"./configure/merge-utils.js";import{hasOpenApiExampleValue as $,resolveOpenApiExampleValue as g}from"./resolve-openapi-example-value.js";function D(r,n,a){const u=S(n,r,a)??r;return U(u,a)}function te(r,n,a,u,l,i){const s=n?.document??{},m=F(r,s,i),t=K(r,s,n,a),e=N(r,n),o=G(r,s,n,a),y=J(r),c=r.responses,p=c?Object.keys(c).filter(C):void 0,f=r.security;return{kind:T.CODE_SAMPLE,operationType:u?"webhook":"http",method:r.httpVerb?.toUpperCase()??"GET",path:r.pathName??"/",servers:m,parameters:t,security:e,requestBody:o,responseCodes:p,requestValues:y,pointer:r.pathName,...l&&{href:l},...r.operationId&&{openApiOperationId:r.operationId},...r.summary&&{summary:r.summary},...f&&f.length>1&&{securityGroups:f}}}function F(r,n,a){const u=n.servers;let l=L(r.servers,u);l=_(l.filter(s=>typeof s?.url=="string"),a?.mockServer);const i=l.map(s=>({url:s.url??"",name:s.name,description:typeof s.description=="string"?s.description:void 0,...s.isMockServer&&{isMockServer:!0},variables:s.variables&&Object.keys(s.variables).length>0?Object.fromEntries(Object.entries(s.variables).map(([m,t])=>[m,{default:t.default,enum:t.enum}])):void 0}));return i.length>0?i:[{url:"/"}]}function K(r,n,a,u){const i=(r.parameters??[]).map(t=>D(t,n,u)),s={path:[],query:[],querystring:[],header:[],cookie:[]},m=r.requestValues?.serverRequestValues;for(const t of i){const e=t.in;if(!e||!s[e])continue;const o=t.content,y=o?Object.keys(o)[0]:void 0,c=y&&o?o[y]?.schema:t.schema,p=c&&typeof c=="object"?S(n,c,u)??c:c;let f;p&&a&&(f=R(a.schemaStore,a.hashIndex,{kind:j.JSON_SCHEMA,data:p}));const V=p&&typeof p=="object"&&"example"in p?p.example:void 0;let v;if(t.examples&&typeof t.examples=="object")for(const d of Object.values(t.examples)){if(!d||typeof d!="object")continue;const x=S(n,d,u)??d;if($(x)){v=g(x);break}}const b={};if(m&&t.name)for(const[d,x]of Object.entries(m)){const k=x?.[e==="querystring"?"queryString":e==="header"?"headers":e==="cookie"?"cookies":e]?.[t.name];k!=null&&(b[d]={example:k})}s[e].push({name:t.name??"",in:e,required:t.required,example:t.example??v??V,schemaId:f,serializationMime:y,style:t.style,explode:t.explode,...Object.keys(b).length>0&&{serverValues:b}})}return s}function N(r,n){const a=r.requestValues?.security,u=r.requestValues?.serverRequestValues,l=r.security,i=[];if(!l||!n)return i;for(const s of l){const m=Object.keys(s),t=m.map(e=>n.securitySchemeStore[e]).filter(Boolean).map(e=>{let o={id:e.id,type:e.type,name:e.paramName,in:e.in,scheme:e.scheme,bearerFormat:e.bearerFormat,openIdConnectUrl:e.openIdConnectUrl,flows:e.flows,"x-defaultClientId":e["x-defaultClientId"],"x-defaultAccessToken":e["x-defaultAccessToken"],"x-defaultTokenType":e["x-defaultTokenType"],"x-defaultClientSecret":e["x-defaultClientSecret"],"x-defaultUsername":e["x-defaultUsername"],"x-defaultPassword":e["x-defaultPassword"],serverValues:e.serverValues?{...e.serverValues}:void 0};if(a&&(o=E(o,a)),u)for(const[y,c]of Object.entries(u))c?.security&&(o=E(o,c.security,y));return o});if(t.length>0){const e=m.flatMap(o=>s[o]??[]);i.push({schemes:t,scopes:e})}}return i}function G(r,n,a,u){const l=r.requestBody,i=l?S(n,l,u)??l:void 0,s=A(n,i,u);if(!s||!a)return;const m={};for(const[t,e]of Object.entries(s)){let o;const y=e.itemSchema,c=e.schema??y;if(c){const V=S(n,c,u)??c;o=R(a.schemaStore,a.hashIndex,{kind:j.JSON_SCHEMA,data:V})}const p=r.pointer?`${r.pointer}/requestBody/content/${B(t)}`.replace(/^\//,""):void 0,f=[];if(e.example!==void 0&&f.push(O(a.exampleStore,{value:e.example,...p&&{id:`${p}/example`}})),e.examples){const V=q(e.examples);for(const[v,b]of Object.entries(e.examples)){if(v===w)continue;const d=S(n,b,u);if(d){const x=q(b)??q(d)??V,h=O(a.exampleStore,{value:g(d),key:v,summary:typeof d.summary=="string"?d.summary:v,description:M(d.description),externalValue:typeof d.externalValue=="string"?d.externalValue:void 0,...P(x),...p&&{id:`${p}/examples/${B(v)}`}});f.push(h)}}}m[t]={schemaId:o,...f.length>0&&{exampleIds:f}}}return m}function J(r){const n=r.requestValues?.serverRequestValues,a=r.requestValues?.envVariables;let u,l;if(a&&typeof a=="object")if("values"in a){const t=a;u=t.values,l=t.serverValues}else u=a;const i=r.requestValues?.body;let s;if(n)for(const[t,e]of Object.entries(n))e?.body!==void 0&&(s=s??{},s[t]=e.body),e?.envVariables&&(l=l??{},l[t]={...l[t],...e.envVariables});return u||l||r.requestValues?.security||i!==void 0||s?{...r.requestValues?.security&&{security:r.requestValues.security},...u&&{envVariables:u},...l&&{serverEnvVariables:l},...i!==void 0&&{body:i},...s&&{serverBody:s}}:void 0}export{te as buildCodeSampleSource};
@@ -21,7 +21,7 @@ export declare function mergeSecurityIntoScheme<S extends SchemeForCredentials>(
21
21
  serverValues: Record<string, SecuritySchemeCredentials>;
22
22
  };
23
23
  export declare function applyServerVariableDefaults(servers: OpenAPIServer[] | undefined, serverVariables: Record<string, string> | undefined, targetServerUrl?: string): void;
24
- /** Immutable variant of {@link applyServerVariableDefaults} for the Replay runtime path. */
24
+ /** Immutable variant of {@link applyServerVariableDefaults} for runtime callers that must not mutate. */
25
25
  export declare function withServerVariableDefaults<T extends {
26
26
  url: string;
27
27
  variables?: Record<string, {
@@ -1 +1 @@
1
- import{configure as c}from"@redocly/theme/ext/configure";import{getOperationData as m}from"../utils/operation.js";function d(n){const{operationInfo:e,info:r,servers:a,basePath:s,userClaims:i,dynamicRequestValues:t}=n;if(t!=null&&Object.keys(t).length>0)return t;const{slug:u}=m(e,s),l=e.summary||e.operationId||e.pathName||"Unknown Operation",p={userClaims:i,info:r,operation:{name:l,path:e.pathName??"",operationId:e.operationId,href:u,method:e.httpVerb??""},servers:a},o=(c(p)??{}).requestValues;return o!=null&&Object.keys(o).length>0?o:{}}export{d as resolveRequestValues};
1
+ import{configure as p}from"@redocly/theme/ext/configure";import{getOperationData as f}from"../utils/operation.js";function d(n){const{operationInfo:e,info:r,servers:s,basePath:a,dynamicRequestValues:t}=n,{userClaims:i}=n;if(t!=null&&Object.keys(t).length>0)return t;const{slug:u}=f(e,a),c=e.summary||e.operationId||e.pathName||"Unknown Operation",l={userClaims:i,info:r,operation:{name:c,path:e.pathName??"",operationId:e.operationId,href:u,method:e.httpVerb??""},servers:s},o=(p(l)??{}).requestValues;return o!=null&&Object.keys(o).length>0?o:{}}export{d as resolveRequestValues};
@@ -1 +1 @@
1
- import{createStoreContext as s,toRecord as l}from"../helpers.js";import{populateOpenApiStore as p}from"./store.js";import{createBuildContext as u}from"./build/context.js";import{buildOverviewItems as f}from"./items/overview/item.js";import{addTagItems as S}from"./group/item.js";import{openApiContext as m}from"./buildContext.js";import{mergeInMockServer as g}from"./utils/merge-mock-server.js";import{toSidebarLogo as v}from"../../utils/logo.js";function d(){return new Promise(r=>setTimeout(r,0))}function x(r,t){const o=r.servers??[];return g(o.filter(e=>typeof e?.url=="string"),t.mockServer).map(e=>({url:e.url,...e.name&&{name:e.name},...e.isMockServer&&{isMockServer:!0},...typeof e.description=="string"&&e.description&&{description:e.description},...e.variables&&Object.keys(e.variables).length>0&&{variables:e.variables}}))}async function M({document:r,basePath:t="/",options:o,processContent:i=!0}){const e=s(l(r));i&&(p(r,e,o),await d());const a=u({document:r,options:o,basePath:t,storeCtx:e,processContent:i}),n=x(r,o),c=v(r.info?.["x-logo"],r.info?.contact?.url);return m.run(a,()=>({items:b(),store:{schemaStore:e.schemaStore,exampleStore:e.exampleStore,securitySchemeStore:e.securitySchemeStore,mcp:e.document["x-mcp"],schemaCatalogLink:r["x-schema-catalog-link"],...n.length>0&&{servers:n},...c&&{logo:c}}}))}function b(){const r=m.get(),t=[...f(r.document)];return S(r.document,t),t}export{b as buildOpenApiItems,M as processOpenApiDocument};
1
+ import{createStoreContext as s,toRecord as l}from"../helpers.js";import{populateOpenApiStore as p}from"./store.js";import{createBuildContext as u}from"./build/context.js";import{buildOverviewItems as S}from"./items/overview/item.js";import{addTagItems as f}from"./group/item.js";import{openApiContext as c}from"./buildContext.js";import{mergeInMockServer as v}from"./utils/merge-mock-server.js";import{toSidebarLogo as g}from"../../utils/logo.js";function x(){return new Promise(r=>setTimeout(r,0))}function d(r,t){let o=(r.servers??[]).filter(e=>typeof e?.url=="string");return o=v(o,t.mockServer),o.map(e=>({url:e.url,...e.name&&{name:e.name},...e.isMockServer&&{isMockServer:!0},...typeof e.description=="string"&&e.description&&{description:e.description},...e.variables&&Object.keys(e.variables).length>0&&{variables:e.variables}}))}async function M({document:r,basePath:t="/",options:i,processContent:o=!0}){const e=s(l(r));o&&(p(r,e,i),await x());const m=u({document:r,options:i,basePath:t,storeCtx:e,processContent:o}),n=d(r,i),a=g(r.info?.["x-logo"],r.info?.contact?.url);return c.run(m,()=>({items:b(),store:{schemaStore:e.schemaStore,exampleStore:e.exampleStore,securitySchemeStore:e.securitySchemeStore,mcp:e.document["x-mcp"],schemaCatalogLink:r["x-schema-catalog-link"],...n.length>0&&{servers:n},...a&&{logo:a}}}))}function b(){const r=c.get(),t=[...S(r.document)];return f(r.document,t),t}export{b as buildOpenApiItems,M as processOpenApiDocument};
@@ -1 +1 @@
1
- import{REDOCLY_TEAMS_RBAC as U}from"@redocly/config";import{contentType as le,itemVariant as me,nodeTypes as f,panelKind as Y,schemaKind as B}from"../../../../types/common.js";import{readRbacScope as E,rbacProp as A,registerExample as J,pickRenderableDescription as ee,registerSchema as H,resolveContent as z,resolveRef as P}from"../../../helpers.js";import{applyIgnoreNamedSchemasDeep as te}from"../../utils/applyIgnoreNamedSchemasDeep.js";import{isStatusCode as ue}from"../../../../utils/status-code.js";import{parseMarkdown as K}from"../../../utils/parseMarkdown.js";import{extractDescriptionSegments as ye,resolveMarkdocHeadingIds as W}from"../../../utils/markdoc.js";import{getExtensionsForDisplay as G}from"../../../../utils/extract-extensions.js";import{openApiContext as $}from"../../buildContext.js";import{buildCodeSampleSource as he}from"../../build-code-sample-source.js";import{mergeInMockServer as fe,pickOperationServers as be}from"../../utils/merge-mock-server.js";import{normalizePath as xe,toRelativePath as se}from"../../../../utils/url.js";import{encodeJsonPointerSegment as N}from"../../../../utils/refPointer.js";import{hasOpenApiExampleValue as ne,resolveOpenApiExampleValue as Z}from"../../resolve-openapi-example-value.js";const Q="request",re="responses",oe="callbacks";function Se(){const e=new Map;return(r,s)=>{const o=`${r}/${s}`,n=e.get(o)??0;return e.set(o,n+1),n===0?o:`${o}~${n}`}}function Le(e,r){const{options:s,storeCtx:o,basePath:n}=$.get(),t=e.summary||e.operationId||e.pathName||"Unknown Operation",c=[],{feedback:l}=s,i=e.isWebhook||!1,p=[{nodeType:f.HEADER,level:2,label:t,badges:e["x-badges"],isWebhook:i,deprecated:e.deprecated,showPageActions:!0}],a=G(e,s.showExtensions);Object.keys(a).length>0&&p.push({nodeType:f.EXTENSIONS,extensions:a}),c.push({nodeType:f.CONTAINER,children:p,panels:[]});const u=s.ignoreNamedSchemas,h=e["x-codeSamples"]?.map(({lang:m,label:v,source:D})=>({lang:m,label:v,source:D})),b=be(e.servers,o?.document?.servers),x=fe(b.filter(m=>typeof m?.url=="string"),s.mockServer).map(m=>{const v=E(m);return{url:m.url??"",name:m.name,description:typeof m.description=="string"?m.description:void 0,...m.isMockServer&&{isMockServer:!0},variables:m.variables&&Object.keys(m.variables).length>0?Object.fromEntries(Object.entries(m.variables).map(([D,L])=>[D,{default:L.default}])):void 0,...A(v)}}),y=ce(e,u),S=se(r,n);let d=[];e.description&&(W(e.description,S,Q),d=ye(e.description,s));const g=d.some(m=>m.kind==="schemaDefinition"),T=y.find(m=>m.nodeType===f.ITEM&&m.variant==="body"),C=ve(e,u,i,S||void 0),q=T?.schemaId,R=T?.mediaTypes,k=T?.mediaTypeSchemas,M=E(T),O=[{children:[{kind:Y.CODE_SAMPLE,source:C,definitionSamples:h?.length?h:void 0,isWebhook:i,hideReplay:e["x-hideReplay"]===!0,servers:x?.length?x:void 0,schemaId:q,exampleIds:T?.exampleIds,mediaTypes:R,mediaTypeSchemas:k,examples:T?.exampleIds?.map(()=>({}))??[]}],...A(M)}];if(y.length>0||d.length>0)if(g){c.push({nodeType:f.CONTAINER,children:[{nodeType:f.HEADER,level:4,label:"Request",labelTranslationKey:"request",deepLinkSuffix:Q}],panels:[]});for(const m of d)m.kind==="schemaDefinition"?c.push(m.node):c.push({nodeType:f.CONTAINER,children:[m.node],panels:[]});c.push({nodeType:f.CONTAINER,children:[...y],panels:O})}else c.push({nodeType:f.CONTAINER,children:[{nodeType:f.HEADER,level:4,label:"Request",labelTranslationKey:"request",deepLinkSuffix:Q},...d.map(m=>m.node),...y],panels:O});else c.push({nodeType:f.CONTAINER,children:[{nodeType:f.HEADER,level:4,label:"Request",labelTranslationKey:"request",deepLinkSuffix:Q},{nodeType:f.EMPTY_MESSAGE,label:"No request data",labelTranslationKey:"noRequestData"}],panels:O});if(e.responses){const m=ae(e,s,S,u);if(m){const v=m.responses?.some(j=>j.schemaId||(j.exampleIds?.length??0)>0),D=m?.responses?.map(j=>{const pe=j[U];return{code:j.code,schemaId:j.schemaId,exampleIds:j.exampleIds,mediaTypes:j.mediaTypes,mediaTypeContent:j.mediaTypeContent,...A(pe)}}),L=[];v&&L.push({children:[{kind:Y.RESPONSE,headerTitle:"Response",responseCodes:D,examples:[]}]});const de=E(e.responses);c.push({nodeType:f.CONTAINER,children:[{nodeType:f.HEADER,level:4,label:"Responses",labelTranslationKey:"responses",deepLinkSuffix:"responses"},m],panels:L.length>0?L:[],...A(de)})}}Array.isArray(e.callbacks)&&e.callbacks.length>0&&c.push(...Te(e,S,u)),l?.hide!==!0&&c.push({nodeType:f.CONTAINER,children:[{nodeType:f.FEEDBACK,pageSlug:xe(se(r,n))}],panels:[]});const _=y.some(m=>{const v=m;return v.variant==="body"&&((v.exampleIds?.length??0)>0||!!v.schemaId)})||(h?.length??0)>0;return{contentType:le.ITEM,itemVariant:me.HTTP_ITEM,seo:e["x-seo"],meta:{sourceId:e.operationId,name:t,deprecated:e.deprecated,isWebhook:e.isWebhook||!1,pointer:e.pointer,hasSamples:_},children:c}}function Te(e,r,s){const o=[{nodeType:f.CONTAINER,children:[{nodeType:f.HEADER,level:4,label:"Callbacks",labelTranslationKey:"callbacks",deepLinkSuffix:oe}],panels:[]}],n=Se();for(const t of e.callbacks??[])if(t.operations)for(const c of t.operations){const l=c.httpVerb??"post",i=n(t.name,l);o.push(Ee(e,t,c,i,r,s))}return o}function Ee(e,r,s,o,n,t){const{options:c}=$.get(),l=s.httpVerb??"post",i={pointer:e.pointer+"/callbacks/"+r.name+"/"+l,pathName:s.pathName??r.url??"",httpVerb:l,summary:s.summary,deprecated:s.deprecated,isWebhook:!1,isAdditionalOperation:!1,tags:[],parameters:s.parameters,requestBody:s.requestBody,responses:s.responses,servers:s.servers,security:s.security},p=ce(i,t),a=ae(i,c,`${n}/callbacks/${o}`,t),u=[...p];a&&u.push(a);const h=s.externalDocs,b=G(s,c.showExtensions);let x;s.description&&(x=K(s.description,c),W(x??[],n,`${oe}/${o}`));const y={httpVerb:l,pathName:i.pathName,summary:i.summary,operationId:typeof s.operationId=="string"?s.operationId:void 0,description:x,deprecated:i.deprecated,callbackName:r.name,callbackId:o,externalDocs:h?{url:h.url,description:h.description}:void 0,extensions:Object.keys(b).length>0?b:void 0,contentChildren:u.length>0?u:void 0},S=Ce(s,i,o,t),d=E(r);return{nodeType:f.CONTAINER,children:[{nodeType:f.ITEM,variant:"callback",callback:y,pointer:e.pointer+"/callbacks"}],panels:S,...A(d)}}function Ce(e,r,s,o){const{storeCtx:n}=$.get(),t=[];if(!e.requestBody||!("content"in e.requestBody))return t;const c=n?.document??{},l=P(c,e.requestBody,o)??e.requestBody,i=z(c,l,o);if(!i)return t;const p=Object.keys(i);let a=!1;const u={};for(const[y,S]of Object.entries(i)){let d;if(S.schema){const C=S.schema;d=H(n.schemaStore,n.hashIndex,{kind:B.JSON_SCHEMA,data:C})}const g=`${r.pointer}/requestBody/content/${N(y)}`.replace(/^\//,""),T=[];if(S.example!==void 0){const C=J(n.exampleStore,{value:S.example,id:`${g}/example`});T.push(C),a=!0}if(S.examples)for(const[C,q]of Object.entries(S.examples)){const R=P(c,q,o);if(R&&ne(R)){const k=J(n.exampleStore,{value:Z(R),summary:R.summary??C,description:ee(R.description),id:`${g}/examples/${N(C)}`});T.push(k),a=!0}}u[y]={schemaId:d,exampleIds:T.length>0?T:void 0},d&&(a=!0)}const h=e["x-codeSamples"];if(!(a||(h?.length??0)>0))return t;const x=e.servers?.filter(y=>y.url).map(({url:y,name:S,description:d,variables:g})=>({url:y,name:S,description:d,variables:g}));return t.push({children:[{kind:Y.CALLBACK_PAYLOAD,callbackName:s,path:r.pathName,httpVerb:r.httpVerb,servers:x?.length?x:void 0,definitionSamples:h,mediaTypes:p.length>0?p:void 0,mediaTypeSchemas:Object.keys(u).length>0?u:void 0,examples:[]}]}),t}function ge(e,r,s){const o=P(r,e,s)??e,{$ref:n,...t}=e,c=typeof n=="string"?{...o,...t}:o;return te(c,s)}function V(e,r,s){if(!e||typeof e!="object")return;const o=e,n=P(r,o,s)??o;return te(n,s)}function Re(e,r,s){if(!e||typeof e!="object")return;const o=E(e),n={},t=[];for(const[c,l]of Object.entries(e)){if(c===U)continue;const i=P(r,l,s)??l,p=i.content,a=p?p[Object.keys(p)[0]]:void 0,u=i.schema??a?.schema??a?.itemSchema,h=V(u,r,s);if(!h)continue;const b=ie(i.examples,r,s),x=E(l)??E(i)??o;n[c]={...h,...i.description!==void 0&&{description:i.description},...i.example!==void 0&&{example:i.example},...b&&{examples:b},...A(x)},i.required&&t.push(c)}if(Object.keys(n).length!==0)return{type:"object",properties:n,...t.length>0?{required:t}:{}}}function Oe(e){if(typeof e=="string"||e&&typeof e=="object"&&"$$mdtype"in e||Array.isArray(e)&&e.length>0&&e.every(r=>!!r&&typeof r=="object"&&"$$mdtype"in r))return e}function F(e,r){const{storeCtx:s,options:o}=$.get(),n=s.document;return e.map(t=>{const c=t.schema;let l={};if(c&&typeof c=="object")l=c;else if(t.content&&typeof t.content=="object"){const b=t.content,x=Object.keys(b)[0],y=x?b[x]?.schema:void 0;y&&typeof y=="object"&&(l=y)}const i=H(s.schemaStore,s.hashIndex,{kind:B.JSON_SCHEMA,data:l}),p=t["x-badges"],a=l["x-badges"],u=Array.isArray(p)?p:Array.isArray(a)?a:void 0,h=G(t,o.showExtensions);return{name:String(t.name??""),in:typeof t.in=="string"?t.in:void 0,schemaId:i,description:Oe(t.description),required:t.required===!0?!0:void 0,deprecated:t.deprecated===!0?!0:void 0,example:t.example,examples:ie(t.examples,n,r),...u?.length?{badges:u}:{},...Object.keys(h).length?{extensions:h}:{},...A(E(t))}})}function ie(e,r,s){if(!e||typeof e!="object")return;const o={};for(const[n,t]of Object.entries(e)){if(!t||typeof t!="object")continue;const c=P(r,t,s)??t;if(!ne(c))continue;const l=Z(c);o[n]={...typeof c.summary=="string"&&{summary:c.summary},...typeof c.description=="string"&&{description:c.description},...l!==void 0&&{value:typeof l=="string"?l:JSON.stringify(l)}}}return Object.keys(o).length>0?o:void 0}function ce(e,r){const{storeCtx:s,options:o}=$.get(),n=[],t=s.document,c=Ae(e);if(c&&n.push(c),e.parameters&&Array.isArray(e.parameters)){const i=e.parameters.map(d=>ge(d,t,r)),p=i.filter(d=>d.in==="header"),a=i.filter(d=>d.in==="query"),u=i.filter(d=>d.in==="path"),h=i.filter(d=>d.in==="cookie"),b=i.filter(d=>d.in==="querystring"),x=b.filter(d=>!d.content||typeof d.content!="object"),y=b.filter(d=>d.content&&typeof d.content=="object"),S=b.length>0;u.length>0&&n.push({nodeType:f.ITEM,variant:"path",label:"Path",labelTranslationKey:"path",parameters:F(u,r),pointer:e.pointer+"/parameters"}),a.length>0&&!S&&n.push({nodeType:f.ITEM,variant:"query",label:"Query",labelTranslationKey:"query",parameters:F(a,r),pointer:e.pointer+"/parameters"}),x.length>0&&n.push({nodeType:f.ITEM,variant:"querystring",label:"Query String",labelTranslationKey:"querystring",parameters:F(x,r),pointer:e.pointer+"/parameters"});for(const d of y){const g=d.content,T=Object.keys(g),C={};for(const M of T){const O=g[M];if(!O)continue;let I;const w=O.itemSchema,_=O.schema??w,m=V(_,t,r);m&&(I=H(s.schemaStore,s.hashIndex,{kind:B.JSON_SCHEMA,data:m}));const v=X(O,r);C[M]={schemaId:I,exampleIds:v,...A(E(_))}}const q=T[0],R=q?C[q]:void 0,k=K(d.description,o);n.push({nodeType:f.ITEM,variant:"querystring-body",label:String(d.name??""),required:d.required===!0?!0:void 0,mediaTypes:T.length>0?T:void 0,mediaTypeSchemas:Object.keys(C).length>0?C:void 0,schemaId:R?.schemaId,exampleIds:R?.exampleIds,pointer:e.pointer+"/parameters",...k!==void 0?{description:k}:{},...A(E(d))})}h.length>0&&n.push({nodeType:f.ITEM,variant:"cookies",label:"Cookies",labelTranslationKey:"cookie",parameters:F(h,r),pointer:e.pointer+"/parameters"}),p.length>0&&n.push({nodeType:f.ITEM,variant:"headers",label:"Headers",labelTranslationKey:"header",parameters:F(p,r),pointer:e.pointer+"/parameters"})}if(e.requestBody){const l=P(t,e.requestBody,r)??e.requestBody,i=z(t,l,r),p=i?Object.keys(i):void 0;let a,u,h;if(i&&p){h={};for(const d of p){const g=i[d];if(!g)continue;let T;const C=g.itemSchema,q=g.schema??C,R=V(q,t,r);R&&(T=H(s.schemaStore,s.hashIndex,{kind:B.JSON_SCHEMA,data:R}));const k=X(g,r,`${e.pointer}/requestBody/content/${N(d)}`);h[d]={schemaId:T,exampleIds:k,...A(E(q))}}const y=p[0],S=y?h[y]:void 0;a=S?.schemaId,u=S?.exampleIds}const b=K(l.description,o),x=E(e.requestBody)??E(l);n.push({nodeType:f.ITEM,variant:"body",label:"Request Body",labelTranslationKey:"body",required:l.required,mediaTypes:p,mediaTypeSchemas:h,schemaId:a,exampleIds:u,pointer:e.pointer+"/requestBody",...b!==void 0?{description:b}:{},...A(x)})}return n}function ae(e,r,s,o){if(!e.responses)return;const{storeCtx:n}=$.get(),t=n?.document??{},c=e.responses,i=Object.entries(c).filter(([p])=>ue(p)).map(([p,a])=>{const u=P(t,a,o)??a;let h=E(a)??E(u);const b=z(t,u,o),x=b?Object.keys(b):[],y=x[0],S=y&&b?b[y]:void 0;let d,g,T,C;if(b&&x.length>0){C={};for(const O of x){const I=b[O];if(!I)continue;let w;const _=I.itemSchema,m=I.schema??_,v=V(m,t,o);v&&(w=H(n.schemaStore,n.hashIndex,{kind:B.JSON_SCHEMA,data:v}));const D=X(I,o,`${e.pointer}/responses/${N(p)}/content/${N(O)}`);C[O]={schemaId:w,exampleIds:D,...A(E(m))}}const M=y?C[y]:void 0;d=M?.schemaId,g=M?.exampleIds}else if(S){const M=S.itemSchema,O=S.schema??M,I=V(O,t,o);I&&(h=h??E(O),d=H(n.schemaStore,n.hashIndex,{kind:B.JSON_SCHEMA,data:I})),g=X(S,o,y?`${e.pointer}/responses/${N(p)}/content/${N(y)}`:void 0)}const q=Re(u.headers,t,o);q&&(T=H(n.schemaStore,n.hashIndex,{kind:B.JSON_SCHEMA,data:q}));let R;u.description&&(R=K(u.description,r),W(R??[],s,`${re}/${p}`));const k=u["x-summary"]?K(u["x-summary"],r):void 0;return k&&W(k,s,`${re}/${p}/summary`),{code:p,summary:k,description:R,mediaType:y,mediaTypes:x.length>0?x:void 0,mediaTypeContent:C,schemaId:d,exampleIds:g,headers:u.headers,headerSchemaId:T,...A(h)}});return{nodeType:f.ITEM,variant:"responses",responses:i,pointer:e.pointer+"/responses"}}function X(e,r,s){const{storeCtx:o}=$.get(),n=[],t=o.document,c=s?.replace(/^\//,"");if(e.example!==void 0){const l=J(o.exampleStore,{value:e.example,...c&&{id:`${c}/example`}});n.push(l)}if(e.examples&&typeof e.examples=="object"){const l=E(e.examples);for(const[i,p]of Object.entries(e.examples)){if(i===U||!p||typeof p!="object")continue;const a=P(t,p,r)??p,u=E(p)??E(a)??l,h=J(o.exampleStore,{value:Z(a),key:i,summary:typeof a.summary=="string"?a.summary:i,description:ee(a.description),externalValue:typeof a.externalValue=="string"?a.externalValue:void 0,...A(u),...c&&{id:`${c}/examples/${N(i)}`}});n.push(h)}}return n.length>0?n:void 0}function Ae(e){const{storeCtx:r,options:s}=$.get();if(!e.security||!Array.isArray(e.security)||e.security.length===0)return;const o=e.security.map(n=>{const t=Object.entries(n);if(t.length===0)return null;const c=r?.document?.components?.securitySchemes,l=t.map(([i,p])=>{const a=r?.securitySchemeStore[i],u=E(c?.[i])??a?.[U];return{name:i,scopes:Array.isArray(p)?p:void 0,type:a?.type,scheme:a?.scheme,bearerFormat:a?.bearerFormat,in:a?.in,paramName:a?.paramName,description:a?.description?K(a.description,s):a?.description,openIdConnectUrl:a?.openIdConnectUrl,oauth2MetadataUrl:a?.oauth2MetadataUrl,deprecated:a?.deprecated,flows:a?.flows,...A(u)}}).filter(i=>i.name);return l.length>0?{schemes:l}:null}).filter(n=>n!==null);if(o.length!==0)return{nodeType:f.SECURITY,requirements:o}}function ve(e,r,s,o){const{storeCtx:n,options:t}=$.get();if(!n)throw new Error("OpenAPI store context is not initialized");return he(e,n,t,r,s,o)}export{Le as buildItemContent,Se as createCallbackIdFactory};
1
+ import{REDOCLY_TEAMS_RBAC as J}from"@redocly/config";import{contentType as me,itemVariant as ue,nodeTypes as h,panelKind as z,schemaKind as B}from"../../../../types/common.js";import{readRbacScope as C,rbacProp as R,registerExample as W,pickRenderableDescription as te,registerSchema as H,resolveContent as G,resolveRef as $}from"../../../helpers.js";import{applyIgnoreNamedSchemasDeep as se}from"../../utils/applyIgnoreNamedSchemasDeep.js";import{isStatusCode as ye}from"../../../../utils/status-code.js";import{parseMarkdown as _}from"../../../utils/parseMarkdown.js";import{extractDescriptionSegments as he,resolveMarkdocHeadingIds as Q}from"../../../utils/markdoc.js";import{getExtensionsForDisplay as Z}from"../../../../utils/extract-extensions.js";import{openApiContext as M}from"../../buildContext.js";import{buildCodeSampleSource as fe}from"../../build-code-sample-source.js";import{pickOperationServers as be}from"../../utils/merge-mock-server.js";import{mergeInMockServer as xe}from"../../utils/merge-mock-server.js";import{normalizePath as Se}from"../../../../utils/url.js";import{toRelativePath as ne}from"../../../../utils/url.js";import{encodeJsonPointerSegment as N}from"../../../../utils/refPointer.js";import{hasOpenApiExampleValue as re,resolveOpenApiExampleValue as ee}from"../../resolve-openapi-example-value.js";const X="request",oe="responses",ie="callbacks";function Te(){const e=new Map;return(r,s)=>{const o=`${r}/${s}`,n=e.get(o)??0;return e.set(o,n+1),n===0?o:`${o}~${n}`}}function Ue(e,r){const{options:s,storeCtx:o,basePath:n}=M.get(),t=e.summary||e.operationId||e.pathName||"Unknown Operation",c=[],{feedback:l}=s,i=e.isWebhook||!1,p=[{nodeType:h.HEADER,level:2,label:t,badges:e["x-badges"],isWebhook:i,deprecated:e.deprecated,showPageActions:!0}],a=Z(e,s.showExtensions);Object.keys(a).length>0&&p.push({nodeType:h.EXTENSIONS,extensions:a}),c.push({nodeType:h.CONTAINER,children:p,panels:[]});const m=s.ignoreNamedSchemas,y=e["x-codeSamples"]?.map(({lang:u,label:I,source:L})=>({lang:u,label:I,source:L}));let b=be(e.servers,o?.document?.servers).filter(u=>typeof u?.url=="string");b=xe(b,s.mockServer);const f=b.map(u=>{const I=C(u);return{url:u.url??"",name:u.name,description:typeof u.description=="string"?u.description:void 0,...u.isMockServer&&{isMockServer:!0},variables:u.variables&&Object.keys(u.variables).length>0?Object.fromEntries(Object.entries(u.variables).map(([L,V])=>[L,{default:V.default}])):void 0,...R(I)}}),x=ae(e,m),d=ne(r,n);let E=[];e.description&&(Q(e.description,d,X),E=he(e.description,s));const g=E.some(u=>u.kind==="schemaDefinition"),S=x.find(u=>u.nodeType===h.ITEM&&u.variant==="body"),q=qe(e,m,i,d||void 0),O=S?.schemaId,k=S?.mediaTypes,j=S?.mediaTypeSchemas,v=C(S),A=[{children:[{kind:z.CODE_SAMPLE,source:q,definitionSamples:y?.length?y:void 0,isWebhook:i,hideReplay:e["x-hideReplay"]===!0,servers:f?.length?f:void 0,schemaId:O,exampleIds:S?.exampleIds,mediaTypes:k,mediaTypeSchemas:j,examples:S?.exampleIds?.map(()=>({}))??[]}],...R(v)}];if(x.length>0||E.length>0)if(g){c.push({nodeType:h.CONTAINER,children:[{nodeType:h.HEADER,level:4,label:"Request",labelTranslationKey:"request",deepLinkSuffix:X}],panels:[]});for(const u of E)u.kind==="schemaDefinition"?c.push(u.node):c.push({nodeType:h.CONTAINER,children:[u.node],panels:[]});c.push({nodeType:h.CONTAINER,children:[...x],panels:A})}else c.push({nodeType:h.CONTAINER,children:[{nodeType:h.HEADER,level:4,label:"Request",labelTranslationKey:"request",deepLinkSuffix:X},...E.map(u=>u.node),...x],panels:A});else c.push({nodeType:h.CONTAINER,children:[{nodeType:h.HEADER,level:4,label:"Request",labelTranslationKey:"request",deepLinkSuffix:X},{nodeType:h.EMPTY_MESSAGE,label:"No request data",labelTranslationKey:"noRequestData"}],panels:A});if(e.responses){const u=de(e,s,d,m);if(u){const I=u.responses?.some(P=>P.schemaId||(P.exampleIds?.length??0)>0),L=u?.responses?.map(P=>{const le=P[J];return{code:P.code,schemaId:P.schemaId,exampleIds:P.exampleIds,mediaTypes:P.mediaTypes,mediaTypeContent:P.mediaTypeContent,...R(le)}}),V=[];I&&V.push({children:[{kind:z.RESPONSE,responseCodes:L,examples:[]}]});const pe=C(e.responses);c.push({nodeType:h.CONTAINER,children:[{nodeType:h.HEADER,level:4,label:"Responses",labelTranslationKey:"responses",deepLinkSuffix:"responses"},u],panels:V.length>0?V:[],...R(pe)})}}Array.isArray(e.callbacks)&&e.callbacks.length>0&&c.push(...Ee(e,d,m)),l?.hide!==!0&&c.push({nodeType:h.CONTAINER,children:[{nodeType:h.FEEDBACK,pageSlug:Se(ne(r,n))}],panels:[]});const D=x.some(u=>{const I=u;return I.variant==="body"&&((I.exampleIds?.length??0)>0||!!I.schemaId)})||(y?.length??0)>0;return{contentType:me.ITEM,itemVariant:ue.HTTP_ITEM,seo:e["x-seo"],meta:{sourceId:e.operationId,name:t,deprecated:e.deprecated,isWebhook:e.isWebhook||!1,pointer:e.pointer,hasSamples:D},children:c}}function Ee(e,r,s){const o=[{nodeType:h.CONTAINER,children:[{nodeType:h.HEADER,level:4,label:"Callbacks",labelTranslationKey:"callbacks",deepLinkSuffix:ie}],panels:[]}],n=Te();for(const t of e.callbacks??[])if(t.operations)for(const c of t.operations){const l=c.httpVerb??"post",i=n(t.name,l);o.push(Ce(e,t,c,i,r,s))}return o}function Ce(e,r,s,o,n,t){const{options:c}=M.get(),l=s.httpVerb??"post",i={pointer:e.pointer+"/callbacks/"+r.name+"/"+l,pathName:s.pathName??r.url??"",httpVerb:l,summary:s.summary,deprecated:s.deprecated,isWebhook:!1,isAdditionalOperation:!1,tags:[],parameters:s.parameters,requestBody:s.requestBody,responses:s.responses,servers:s.servers,security:s.security},p=ae(i,t),a=de(i,c,`${n}/callbacks/${o}`,t),m=[...p];a&&m.push(a);const y=s.externalDocs,T=Z(s,c.showExtensions);let b;s.description&&(b=_(s.description,c),Q(b??[],n,`${ie}/${o}`));const f={httpVerb:l,pathName:i.pathName,summary:i.summary,operationId:typeof s.operationId=="string"?s.operationId:void 0,description:b,deprecated:i.deprecated,callbackName:r.name,callbackId:o,externalDocs:y?{url:y.url,description:y.description}:void 0,extensions:Object.keys(T).length>0?T:void 0,contentChildren:m.length>0?m:void 0},x=ge(s,i,o,t),d=C(r);return{nodeType:h.CONTAINER,children:[{nodeType:h.ITEM,variant:"callback",callback:f,pointer:e.pointer+"/callbacks"}],panels:x,...R(d)}}function ge(e,r,s,o){const{storeCtx:n}=M.get(),t=[];if(!e.requestBody||!("content"in e.requestBody))return t;const c=n?.document??{},l=$(c,e.requestBody,o)??e.requestBody,i=G(c,l,o);if(!i)return t;const p=Object.keys(i);let a=!1;const m={};for(const[f,x]of Object.entries(i)){let d;if(x.schema){const S=x.schema;d=H(n.schemaStore,n.hashIndex,{kind:B.JSON_SCHEMA,data:S})}const E=`${r.pointer}/requestBody/content/${N(f)}`.replace(/^\//,""),g=[];if(x.example!==void 0){const S=W(n.exampleStore,{value:x.example,id:`${E}/example`});g.push(S),a=!0}if(x.examples)for(const[S,q]of Object.entries(x.examples)){const O=$(c,q,o);if(O&&re(O)){const k=W(n.exampleStore,{value:ee(O),summary:O.summary??S,description:te(O.description),id:`${E}/examples/${N(S)}`});g.push(k),a=!0}}m[f]={schemaId:d,exampleIds:g.length>0?g:void 0},d&&(a=!0)}const y=e["x-codeSamples"];if(!(a||(y?.length??0)>0))return t;const b=e.servers?.filter(f=>f.url).map(({url:f,name:x,description:d,variables:E})=>({url:f,name:x,description:d,variables:E}));return t.push({children:[{kind:z.CALLBACK_PAYLOAD,callbackName:s,path:r.pathName,httpVerb:r.httpVerb,servers:b?.length?b:void 0,definitionSamples:y,mediaTypes:p.length>0?p:void 0,mediaTypeSchemas:Object.keys(m).length>0?m:void 0,examples:[]}]}),t}function Oe(e,r,s){const o=$(r,e,s)??e,{$ref:n,...t}=e,c=typeof n=="string"?{...o,...t}:o;return se(c,s)}function F(e,r,s){if(!e||typeof e!="object")return;const o=e,n=$(r,o,s)??o;return se(n,s)}function Re(e,r,s){if(!e||typeof e!="object")return;const o=C(e),n={},t=[];for(const[c,l]of Object.entries(e)){if(c===J)continue;const i=$(r,l,s)??l,p=i.content,a=p?p[Object.keys(p)[0]]:void 0,m=i.schema??a?.schema??a?.itemSchema,y=F(m,r,s);if(!y)continue;const T=ce(i.examples,r,s),b=C(l)??C(i)??o;n[c]={...y,...i.description!==void 0&&{description:i.description},...i.example!==void 0&&{example:i.example},...T&&{examples:T},...R(b)},i.required&&t.push(c)}if(Object.keys(n).length!==0)return{type:"object",properties:n,...t.length>0?{required:t}:{}}}function Ae(e){if(typeof e=="string"||e&&typeof e=="object"&&"$$mdtype"in e||Array.isArray(e)&&e.length>0&&e.every(r=>!!r&&typeof r=="object"&&"$$mdtype"in r))return e}function U(e,r){const{storeCtx:s,options:o}=M.get(),n=s.document;return e.map(t=>{const c=t.schema;let l={};if(c&&typeof c=="object")l=c;else if(t.content&&typeof t.content=="object"){const T=t.content,b=Object.keys(T)[0],f=b?T[b]?.schema:void 0;f&&typeof f=="object"&&(l=f)}const i=H(s.schemaStore,s.hashIndex,{kind:B.JSON_SCHEMA,data:l}),p=t["x-badges"],a=l["x-badges"],m=Array.isArray(p)?p:Array.isArray(a)?a:void 0,y=Z(t,o.showExtensions);return{name:String(t.name??""),in:typeof t.in=="string"?t.in:void 0,schemaId:i,description:Ae(t.description),required:t.required===!0?!0:void 0,deprecated:t.deprecated===!0?!0:void 0,example:t.example,examples:ce(t.examples,n,r),...m?.length?{badges:m}:{},...Object.keys(y).length?{extensions:y}:{},...R(C(t))}})}function ce(e,r,s){if(!e||typeof e!="object")return;const o={};for(const[n,t]of Object.entries(e)){if(!t||typeof t!="object")continue;const c=$(r,t,s)??t;if(!re(c))continue;const l=ee(c);o[n]={...typeof c.summary=="string"&&{summary:c.summary},...typeof c.description=="string"&&{description:c.description},...l!==void 0&&{value:typeof l=="string"?l:JSON.stringify(l)}}}return Object.keys(o).length>0?o:void 0}function ae(e,r){const{storeCtx:s,options:o}=M.get(),n=[],t=s.document,c=ve(e);if(c&&n.push(c),e.parameters&&Array.isArray(e.parameters)){const i=e.parameters.map(d=>Oe(d,t,r)),p=i.filter(d=>d.in==="header"),a=i.filter(d=>d.in==="query"),m=i.filter(d=>d.in==="path"),y=i.filter(d=>d.in==="cookie"),T=i.filter(d=>d.in==="querystring"),b=T.filter(d=>!d.content||typeof d.content!="object"),f=T.filter(d=>d.content&&typeof d.content=="object"),x=T.length>0;m.length>0&&n.push({nodeType:h.ITEM,variant:"path",label:"Path",labelTranslationKey:"path",parameters:U(m,r),pointer:e.pointer+"/parameters"}),a.length>0&&!x&&n.push({nodeType:h.ITEM,variant:"query",label:"Query",labelTranslationKey:"query",parameters:U(a,r),pointer:e.pointer+"/parameters"}),b.length>0&&n.push({nodeType:h.ITEM,variant:"querystring",label:"Query String",labelTranslationKey:"querystring",parameters:U(b,r),pointer:e.pointer+"/parameters"});for(const d of f){const E=d.content,g=Object.keys(E),S={};for(const j of g){const v=E[j];if(!v)continue;let A;const K=v.itemSchema,w=v.schema??K,D=F(w,t,r);D&&(A=H(s.schemaStore,s.hashIndex,{kind:B.JSON_SCHEMA,data:D}));const u=Y(v,r);S[j]={schemaId:A,exampleIds:u,...R(C(w))}}const q=g[0],O=q?S[q]:void 0,k=_(d.description,o);n.push({nodeType:h.ITEM,variant:"querystring-body",label:String(d.name??""),required:d.required===!0?!0:void 0,mediaTypes:g.length>0?g:void 0,mediaTypeSchemas:Object.keys(S).length>0?S:void 0,schemaId:O?.schemaId,exampleIds:O?.exampleIds,pointer:e.pointer+"/parameters",...k!==void 0?{description:k}:{},...R(C(d))})}y.length>0&&n.push({nodeType:h.ITEM,variant:"cookies",label:"Cookies",labelTranslationKey:"cookie",parameters:U(y,r),pointer:e.pointer+"/parameters"}),p.length>0&&n.push({nodeType:h.ITEM,variant:"headers",label:"Headers",labelTranslationKey:"header",parameters:U(p,r),pointer:e.pointer+"/parameters"})}if(e.requestBody){const l=$(t,e.requestBody,r)??e.requestBody,i=G(t,l,r),p=i?Object.keys(i):void 0;let a,m,y;if(i&&p){y={};for(const d of p){const E=i[d];if(!E)continue;let g;const S=E.itemSchema,q=E.schema??S,O=F(q,t,r);O&&(g=H(s.schemaStore,s.hashIndex,{kind:B.JSON_SCHEMA,data:O}));const k=Y(E,r,`${e.pointer}/requestBody/content/${N(d)}`);y[d]={schemaId:g,exampleIds:k,...R(C(q))}}const f=p[0],x=f?y[f]:void 0;a=x?.schemaId,m=x?.exampleIds}const T=_(l.description,o),b=C(e.requestBody)??C(l);n.push({nodeType:h.ITEM,variant:"body",label:"Request Body",labelTranslationKey:"body",required:l.required,mediaTypes:p,mediaTypeSchemas:y,schemaId:a,exampleIds:m,pointer:e.pointer+"/requestBody",...T!==void 0?{description:T}:{},...R(b)})}return n}function de(e,r,s,o){if(!e.responses)return;const{storeCtx:n}=M.get(),t=n?.document??{},c=e.responses,i=Object.entries(c).filter(([p])=>ye(p)).map(([p,a])=>{const m=$(t,a,o)??a;let y=C(a)??C(m);const T=G(t,m,o),b=T?Object.keys(T):[],f=b[0],x=f&&T?T[f]:void 0;let d,E,g,S;if(T&&b.length>0){S={};for(const v of b){const A=T[v];if(!A)continue;let K;const w=A.itemSchema,D=A.schema??w,u=F(D,t,o);u&&(K=H(n.schemaStore,n.hashIndex,{kind:B.JSON_SCHEMA,data:u}));const I=Y(A,o,`${e.pointer}/responses/${N(p)}/content/${N(v)}`);S[v]={schemaId:K,exampleIds:I,...R(C(D))}}const j=f?S[f]:void 0;d=j?.schemaId,E=j?.exampleIds}else if(x){const j=x.itemSchema,v=x.schema??j,A=F(v,t,o);A&&(y=y??C(v),d=H(n.schemaStore,n.hashIndex,{kind:B.JSON_SCHEMA,data:A})),E=Y(x,o,f?`${e.pointer}/responses/${N(p)}/content/${N(f)}`:void 0)}const q=Re(m.headers,t,o);q&&(g=H(n.schemaStore,n.hashIndex,{kind:B.JSON_SCHEMA,data:q}));let O;m.description&&(O=_(m.description,r),Q(O??[],s,`${oe}/${p}`));const k=m["x-summary"]?_(m["x-summary"],r):void 0;return k&&Q(k,s,`${oe}/${p}/summary`),{code:p,summary:k,description:O,mediaType:f,mediaTypes:b.length>0?b:void 0,mediaTypeContent:S,schemaId:d,exampleIds:E,headers:m.headers,headerSchemaId:g,...R(y)}});return{nodeType:h.ITEM,variant:"responses",responses:i,pointer:e.pointer+"/responses"}}function Y(e,r,s){const{storeCtx:o}=M.get(),n=[],t=o.document,c=s?.replace(/^\//,"");if(e.example!==void 0){const l=W(o.exampleStore,{value:e.example,...c&&{id:`${c}/example`}});n.push(l)}if(e.examples&&typeof e.examples=="object"){const l=C(e.examples);for(const[i,p]of Object.entries(e.examples)){if(i===J||!p||typeof p!="object")continue;const a=$(t,p,r)??p,m=C(p)??C(a)??l,y=W(o.exampleStore,{value:ee(a),key:i,summary:typeof a.summary=="string"?a.summary:i,description:te(a.description),externalValue:typeof a.externalValue=="string"?a.externalValue:void 0,...R(m),...c&&{id:`${c}/examples/${N(i)}`}});n.push(y)}}return n.length>0?n:void 0}function ve(e){const{storeCtx:r,options:s}=M.get();if(!e.security||!Array.isArray(e.security)||e.security.length===0)return;const o=e.security.map(n=>{const t=Object.entries(n);if(t.length===0)return null;const c=r?.document?.components?.securitySchemes,l=t.map(([i,p])=>{const a=r?.securitySchemeStore[i],m=C(c?.[i])??a?.[J];return{name:i,scopes:Array.isArray(p)?p:void 0,type:a?.type,scheme:a?.scheme,bearerFormat:a?.bearerFormat,in:a?.in,paramName:a?.paramName,description:a?.description?_(a.description,s):a?.description,openIdConnectUrl:a?.openIdConnectUrl,oauth2MetadataUrl:a?.oauth2MetadataUrl,deprecated:a?.deprecated,flows:a?.flows,...R(m)}}).filter(i=>i.name);return l.length>0?{schemes:l}:null}).filter(n=>n!==null);if(o.length!==0)return{nodeType:h.SECURITY,requirements:o}}function qe(e,r,s,o){const{storeCtx:n}=M.get(),{options:t}=M.get();if(!n)throw new Error("OpenAPI store context is not initialized");return fe(e,n,r,s,o,t)}export{Ue as buildItemContent,Te as createCallbackIdFactory};
@@ -1 +1 @@
1
- import{REDOCLY_TEAMS_RBAC as h}from"@redocly/config";import{WEBHOOKS_GROUP_TITLE as k}from"../../../../constants/openapi.js";import{buildItemContent as v}from"./content.js";import{getOperationData as y}from"../../utils/operation.js";import{resolveRequestValues as R,applyRequestValuesToOperationInfo as C}from"../../configure/index.js";import{openApiContext as d}from"../../buildContext.js";import{mergeInMockServer as I,pickOperationServers as S}from"../../utils/merge-mock-server.js";function j({operations:t,result:o,basePath:n,parentRbac:s}){const{basePath:r}=d.get(),e=n??r,{regular:c,regularDeprecated:u,webhooks:p,webhooksDeprecated:a}=D(t);for(const i of[...c,...u])O(i,e,o,s);const f=p.length>0||a.length>0,m=c.length>0||u.length>0;f&&m&&o.push({type:"separator",label:k,variant:"secondary",content:null});for(const i of[...p,...a])O(i,e,o,s)}function D(t){const o=[],n=[],s=[],r=[];for(const e of t)e.isWebhook?(e.deprecated?r:s).push(e):(e.deprecated?n:o).push(e);return{regular:o,regularDeprecated:n,webhooks:s,webhooksDeprecated:r}}function O(t,o,n,s){const{document:r,options:e,processContent:c}=d.get(),u=S(t.servers,r.servers),p=I(u.filter(l=>typeof l?.url=="string"),e.mockServer);if(c){const l=R({operationInfo:t,info:r.info??{},servers:p,basePath:o,userClaims:e.userClaims,dynamicRequestValues:e.dynamicRequestValues});l&&Object.keys(l).length>0&&C(t,l,p)}const{slug:a,badges:f,httpPath:m,seo:i,...b}=y(t,o),g={...b,type:"link",link:a,routeSlug:a,metadata:{...i?{seo:i}:{}},[h]:t[h]??s,content:c?v(t,a):null};f&&Object.assign(g,{badges:f}),m&&Object.assign(g,{httpPath:m}),n.push(g)}export{j as addOperationItems};
1
+ import{REDOCLY_TEAMS_RBAC as h}from"@redocly/config";import{WEBHOOKS_GROUP_TITLE as k}from"../../../../constants/openapi.js";import{buildItemContent as v}from"./content.js";import{getOperationData as y}from"../../utils/operation.js";import{resolveRequestValues as R,applyRequestValuesToOperationInfo as S}from"../../configure/index.js";import{openApiContext as d}from"../../buildContext.js";import{mergeInMockServer as C}from"../../utils/merge-mock-server.js";import{pickOperationServers as I}from"../../utils/merge-mock-server.js";function A({operations:t,result:o,basePath:a,parentRbac:r}){const{basePath:s}=d.get(),e=a??s,{regular:p,regularDeprecated:m,webhooks:n,webhooksDeprecated:i}=w(t);for(const c of[...p,...m])O(c,e,o,r);const f=n.length>0||i.length>0,u=p.length>0||m.length>0;f&&u&&o.push({type:"separator",label:k,variant:"secondary",content:null});for(const c of[...n,...i])O(c,e,o,r)}function w(t){const o=[],a=[],r=[],s=[];for(const e of t)e.isWebhook?(e.deprecated?s:r).push(e):(e.deprecated?a:o).push(e);return{regular:o,regularDeprecated:a,webhooks:r,webhooksDeprecated:s}}function O(t,o,a,r){const{document:s,options:e,processContent:p}=d.get();let n=I(t.servers,s.servers).filter(l=>typeof l?.url=="string");if(n=C(n,e.mockServer),p){const l=R({operationInfo:t,info:s.info??{},servers:n,basePath:o,userClaims:e.userClaims,dynamicRequestValues:e.dynamicRequestValues});l&&Object.keys(l).length>0&&S(t,l,n)}const{slug:i,badges:f,httpPath:u,seo:c,...b}=y(t,o),g={...b,type:"link",link:i,routeSlug:i,metadata:{...c?{seo:c}:{}},[h]:t[h]??r,content:p?v(t,i):null};f&&Object.assign(g,{badges:f}),u&&Object.assign(g,{httpPath:u}),a.push(g)}export{A as addOperationItems};
@@ -1 +1 @@
1
- import{contentType as A,nodeTypes as n}from"../../../../types/common.js";import{asString as S}from"../../../../utils/string.js";import{parseMarkdown as l}from"../../../utils/parseMarkdown.js";import{buildDownloadPanelContent as M}from"../../panels/download.js";import{buildInfoMetadataContentNode as N}from"../../../utils/infoMetadata.js";import{buildOverviewPanelContent as x}from"../../panels/overview.js";import{buildLanguagesPanelContent as V}from"../../panels/languages.js";import{buildMcpPanelContent as W}from"../../panels/mcp.js";import{buildServersPanelContent as _}from"../../panels/servers.js";import{mergeInMockServer as k}from"../../utils/merge-mock-server.js";function G({document:i,description:T,sectionChildren:g,options:o}){const{downloadUrls:p,hideDownloadButtons:y,hideInfoMetadata:D,basePath:m}=o,u=o.codeSamples?.languages??[],e=i.info,f=e?.["x-seo"],c=S(f?.title)??S(e?.title)??"API Documentation",I=e?.version?`${c} (${e.version})`:c,t=[];!y&&p&&t.push(M(p)),t.push(x(e)),u.length&&t.push(V(u));const h=W(i);h&&t.push(h);const O=k(i.servers??[],o.mockServer).map(r=>({...r,description:typeof r.description=="string"?r.description:void 0})),v=_(O);v&&t.push(v);const s={nodeType:n.OVERVIEW_SECTION_WRAPPER,children:[{nodeType:n.HEADER,level:1,label:I,showPageActions:!0}],sectionId:m},C=l(e.summary,o);C&&s.children.push({nodeType:n.MARKDOC,content:C});const E=l(T,o);E&&s.children.push({nodeType:n.OVERVIEW_SECTION_WRAPPER,children:[{nodeType:n.MARKDOC,content:E}],sectionId:m});const R=o,a=i.externalDocs||e?.externalDocs;if(a?.url){const r=l(a.description,R)??[];s.children.push({nodeType:n.EXTERNAL_DOCS,url:a.url,description:r})}const P=N(e,D),d=[s];P&&d.push(P),d.push(...g);const b={nodeType:n.CONTAINER,panels:t,children:d},w={name:c};return{contentType:A.OVERVIEW,seo:f,meta:w,children:[b]}}export{G as buildOverviewContent};
1
+ import{contentType as M,nodeTypes as o}from"../../../../types/common.js";import{asString as y}from"../../../../utils/string.js";import{parseMarkdown as p}from"../../../utils/parseMarkdown.js";import{buildDownloadPanelContent as N}from"../../panels/download.js";import{buildOverviewPanelContent as x}from"../../panels/overview.js";import{buildInfoMetadataContentNode as V}from"../../../utils/infoMetadata.js";import{buildLanguagesPanelContent as W}from"../../panels/languages.js";import{mergeInMockServer as _}from"../../utils/merge-mock-server.js";import{buildMcpPanelContent as k}from"../../panels/mcp.js";import{buildServersPanelContent as L}from"../../panels/servers.js";function G({document:i,description:S,sectionChildren:g,options:n}){const{downloadUrls:m,hideDownloadButtons:D,basePath:u}=n,{hideInfoMetadata:I}=n,f=n.codeSamples?.languages??[],e=i.info,h=e?.["x-seo"],c=y(h?.title)??y(e?.title)??"API Documentation",O=e?.version?`${c} (${e.version})`:c,t=[];!D&&m&&t.push(N(m)),t.push(x(e)),f.length&&t.push(W(f));const C=k(i);C&&t.push(C);let a=i.servers??[];a=_(a,n.mockServer);const R=a.map(r=>({...r,description:typeof r.description=="string"?r.description:void 0})),E=L(R);E&&t.push(E);const s={nodeType:o.OVERVIEW_SECTION_WRAPPER,children:[{nodeType:o.HEADER,level:1,label:O,showPageActions:!0}],sectionId:u},v=p(e.summary,n);v&&s.children.push({nodeType:o.MARKDOC,content:v});const P=p(S,n);P&&s.children.push({nodeType:o.OVERVIEW_SECTION_WRAPPER,children:[{nodeType:o.MARKDOC,content:P}],sectionId:u});const b=n,d=i.externalDocs||e?.externalDocs;if(d?.url){const r=p(d.description,b)??[];s.children.push({nodeType:o.EXTERNAL_DOCS,url:d.url,description:r})}const l=[s],T=V(e,I);T&&l.push(T),l.push(...g);const w={nodeType:o.CONTAINER,panels:t,children:l},A={name:c};return{contentType:M.OVERVIEW,seo:h,meta:A,children:[w]}}export{G as buildOverviewContent};
@@ -8,8 +8,8 @@ export declare function mergeInMockServer(servers: OpenAPIServer[], mockServerOp
8
8
  /** Operation servers win when non-empty; an empty array falls through to the
9
9
  * document servers (see the empty-array test — a `??` fallback would not). */
10
10
  export declare function pickOperationServers<T>(operationServers: T[] | undefined, documentServers: T[] | undefined): T[];
11
- /** Strips servers injected by {@link mergeInMockServer}. Returns the same
12
- * reference when nothing is flagged. */
11
+ /** Strips servers flagged as mock servers. Returns the same reference when
12
+ * nothing is flagged. */
13
13
  export declare function excludeMockServers<T extends {
14
14
  isMockServer?: boolean;
15
15
  }>(servers: T[]): T[];
@@ -5,7 +5,10 @@ import type { ApiDocsOptions } from '../../types/options.js';
5
5
  import type { MarkdownHeading } from '../../types/openapi.js';
6
6
  import type { ParseMarkdownOptions } from './parseMarkdown.js';
7
7
  export type { MarkdownHeading };
8
- export type MarkdownSanitizeOptions = Partial<Pick<ApiDocsOptions, 'sanitize' | 'unstable_hooks'>>;
8
+ export type MarkdownSanitizeOptions = {
9
+ sanitize?: ApiDocsOptions['sanitize'];
10
+ unstable_hooks?: ApiDocsOptions['unstable_hooks'];
11
+ };
9
12
  export type DescriptionSegment = {
10
13
  kind: 'markdoc';
11
14
  node: ContentNode;
@@ -1 +1 @@
1
- import{contentType as v,itemVariant as N,nodeTypes as u}from"../../types/common.js";import{safeSlugify as x}from"../../utils/string.js";import{parseMarkdown as p}from"./parseMarkdown.js";import{isPlainText as k}from"./isPlainText.js";import{joinWithSeparator as a}from"../../utils/url.js";import{buildDeepLinkUrl as O}from"../../utils/deep-link.js";import{getDOMPurify as E}from"./dompurify.js";function L(t){return t.type==="tag"&&t.tag==="schemaDefinition"}const W=/^[ \t]{0,3}#{1,6}[ \t]/m;function M(t){const r=t.search(W);return r===-1?t:t.slice(0,r)}function X(t,r){if(typeof t=="string"){const n=M(t).trim();if(k(n))return n}const e=p(t,r);if(!e)return;if(typeof e=="string")return e;if(Array.isArray(e)){const n=e.findIndex(o=>o.type==="heading");return n===-1?e:e.slice(0,n)}if(!e.children||!Array.isArray(e.children))return;const i=e.children.findIndex(n=>n.type==="heading");return i===-1?[e]:(e.children=e.children.slice(0,i),[e])}function Y(t,r,{sliceAtFirstHeading:e=!1}={}){if(typeof t=="string"&&e){const f=M(t).trim();if(k(f))return[{kind:"markdoc",node:{nodeType:u.MARKDOC,content:f}}]}const i=p(t,r);if(!i)return[];if(typeof i=="string")return[{kind:"markdoc",node:{nodeType:u.MARKDOC,content:i}}];let n=Array.isArray(i)?i:i.children??[];if(e){const f=n.findIndex(d=>d.type==="heading");f!==-1&&(n=n.slice(0,f))}const o=[];let c=[];const l=()=>{c.length>0&&(o.push({kind:"markdoc",node:{nodeType:u.MARKDOC,content:c}}),c=[])};for(const f of n)L(f)?(l(),o.push({kind:"schemaDefinition",node:{nodeType:u.MARKDOC,content:[f]}})):c.push(f);return l(),o}function _(t,r,e){const i=t.toLowerCase(),n=i.startsWith("section/")?i.slice(8):i,o=r.toLowerCase();let c=n!==o?n:"";return e&&(c=a(e,c)),c}function S(t,...r){let e=t.toLowerCase();for(const i of r){const n=i?`${i.toLowerCase()}/`:"";n&&`${e}/`.startsWith(n)&&(e=e.slice(n.length))}return e}function J(t,r,e){if(typeof t=="string")return;const i=n=>{if(n.type==="heading"&&n.attributes?.level){const o=n.attributes.id?S(n.attributes.id,r,e):x(m(n).trim()).toLowerCase();if(o){const c=_(o,r,e);n.attributes.id=a(r,c).toLowerCase(),n.attributes.deepLinkHash=O("",r,c)}}for(const o of n.children??[])i(o)};if(Array.isArray(t))for(const n of t)i(n);else i(t)}function H(t,r,e,i){const n=p(t,r);if(!n)return[];if(typeof n=="string")return[];const o=[];let c;const l=(s,h,R=o,y,A)=>{s=z(s);const T=A!==void 0,C=T?A:e;let g;y.attributes.id?g=S(y.attributes.id,C):T||i?g=x(s):g=`section/${x(s)}`;const I=a(C,g).toLowerCase();y.attributes.id=I;const b={id:I,name:s,level:h,items:[],ast:[y]};return R.push(b),b},f=s=>{if(typeof s?.attributes?.content=="string")return s.attributes.content;if(s?.children)return f(s.children[0])},d=s=>{const h=f(s)||"";s.type==="heading"&&s.attributes?.level===1?c=l(h,s.attributes.level,void 0,s):s.attributes?.level?l(h,s.attributes.level,c?.items,s,c?.id):c?.items?.length?c.items[c.items.length-1]?.ast?.push(s):o.length&&o[o.length-1]?.ast?.push(s)};if(Array.isArray(n))for(const s of n)d(s);else if(n.children)for(const s of n.children)d(s);return o}function K({heading:t,basePath:r}){const e=t.items.length>0,i=a(r,t.id).toLowerCase(),n=e?t.items.map(o=>K({heading:o,basePath:r})):[];return{type:e?"group":"link",label:t.name,link:i,routeSlug:i,items:e?n:void 0,content:P(t)}}function Q(t,r,e){const i=[],n=[];for(const o of H(t,e,"")){const{item:c,children:l}=w(o,r);i.push(c),n.push(...l)}return{sectionItems:i,sectionChildren:n}}function w(t,r){const e=a(r,t.id),i=t.items.length>0,n=t.ast?.length?[V(t.ast,a(r,t.id))]:[],o=[];for(const l of t.items){const{item:f,children:d}=w(l,r);o.push(f);const s=a(r,l.id);n.push({nodeType:u.OVERVIEW_SECTION_WRAPPER,children:d,sectionId:s})}return{item:{type:i?"group":"link",label:t.name,link:e,routeSlug:e,items:i?o:void 0,content:null},children:n}}function Z(t){return typeof t=="string"?t.trim():Array.isArray(t)?t.map(r=>m(r)).filter(Boolean).join(" ").trim():m(t).trim()}function D(t,r=50){if(typeof t=="string"){const o=t.split(/\n[ \t]*\n/)[0].replace(/\s+/g," ").trim();return o?o.substring(0,r):void 0}const i=(Array.isArray(t)?t:t.children??[t])[0];if(!i)return;const n=m(i);return n?n.substring(0,r):void 0}function tt(t,r){if(!t)return;const e=p(t,r);if(!e)return;const i=D(e);return i?i.length===50?i+"\u2026":i:void 0}function et(t,r){if(!t)return;const e=p(t,r);if(e)return D(e,Number.POSITIVE_INFINITY)}function m(t){const r=[];function e(i){typeof i.attributes?.content=="string"&&r.push(i.attributes.content);for(const n of i.children??[])e(n)}return e(t),r.join("")}function nt(t){return typeof t=="string"?t.trim():(Array.isArray(t)?t:[t]).map(e=>m(e)).join("").trim()}function z(t){return t.replace(/&#(\d+);/g,(r,e)=>String.fromCharCode(parseInt(e,10))).replace(/&quot;/g,'"').replace(/&amp;/g,"&")}function rt(t,r){const{unstable_hooks:e,sanitize:i}=r??{};return e?.sanitize?e.sanitize(t):i?E().sanitize(t):t}function P(t){const r=[];return t.ast&&t.ast.length>0&&r.push({nodeType:u.MARKDOC,content:t.ast}),{contentType:v.ITEM,itemVariant:N.MARKDOWN,meta:{name:t.name},children:[{nodeType:u.CONTAINER,children:r,panels:[]}]}}function V(t,r){return{nodeType:u.OVERVIEW_SECTION_WRAPPER,children:[{nodeType:u.MARKDOC,content:t}],sectionId:r}}export{K as buildMarkdownSectionItem,nt as collectMarkdownPlainText,Q as collectMarkdownSections,X as extractContentUntilFirstHeading,Y as extractDescriptionSegments,D as extractFirstParagraphText,Z as extractFullText,H as extractMarkdownSections,et as extractSeoDescriptionText,tt as extractSummaryText,_ as resolveMarkdocHeadingDeepSuffix,J as resolveMarkdocHeadingIds,rt as sanitizeMarkdownSource,z as unescapeHTMLChars};
1
+ import{contentType as v,itemVariant as N,nodeTypes as u}from"../../types/common.js";import{safeSlugify as x}from"../../utils/string.js";import{parseMarkdown as p}from"./parseMarkdown.js";import{isPlainText as k}from"./isPlainText.js";import{joinWithSeparator as a}from"../../utils/url.js";import{buildDeepLinkUrl as O}from"../../utils/deep-link.js";import{getDOMPurify as E}from"./dompurify.js";function L(t){return t.type==="tag"&&t.tag==="schemaDefinition"}const W=/^[ \t]{0,3}#{1,6}[ \t]/m;function M(t){const r=t.search(W);return r===-1?t:t.slice(0,r)}function X(t,r){if(typeof t=="string"){const n=M(t).trim();if(k(n))return n}const e=p(t,r);if(!e)return;if(typeof e=="string")return e;if(Array.isArray(e)){const n=e.findIndex(o=>o.type==="heading");return n===-1?e:e.slice(0,n)}if(!e.children||!Array.isArray(e.children))return;const i=e.children.findIndex(n=>n.type==="heading");return i===-1?[e]:(e.children=e.children.slice(0,i),[e])}function Y(t,r,{sliceAtFirstHeading:e=!1}={}){if(typeof t=="string"&&e){const f=M(t).trim();if(k(f))return[{kind:"markdoc",node:{nodeType:u.MARKDOC,content:f}}]}const i=p(t,r);if(!i)return[];if(typeof i=="string")return[{kind:"markdoc",node:{nodeType:u.MARKDOC,content:i}}];let n=Array.isArray(i)?i:i.children??[];if(e){const f=n.findIndex(d=>d.type==="heading");f!==-1&&(n=n.slice(0,f))}const o=[];let c=[];const l=()=>{c.length>0&&(o.push({kind:"markdoc",node:{nodeType:u.MARKDOC,content:c}}),c=[])};for(const f of n)L(f)?(l(),o.push({kind:"schemaDefinition",node:{nodeType:u.MARKDOC,content:[f]}})):c.push(f);return l(),o}function _(t,r,e){const i=t.toLowerCase(),n=i.startsWith("section/")?i.slice(8):i,o=r.toLowerCase();let c=n!==o?n:"";return e&&(c=a(e,c)),c}function S(t,...r){let e=t.toLowerCase();for(const i of r){const n=i?`${i.toLowerCase()}/`:"";n&&`${e}/`.startsWith(n)&&(e=e.slice(n.length))}return e}function J(t,r,e){if(typeof t=="string")return;const i=n=>{if(n.type==="heading"&&n.attributes?.level){const o=n.attributes.id?S(n.attributes.id,r,e):x(m(n).trim()).toLowerCase();if(o){const c=_(o,r,e);n.attributes.id=a(r,c).toLowerCase(),n.attributes.deepLinkHash=O("",r,c)}}for(const o of n.children??[])i(o)};if(Array.isArray(t))for(const n of t)i(n);else i(t)}function H(t,r,e,i){const n=p(t,r);if(!n)return[];if(typeof n=="string")return[];const o=[];let c;const l=(s,h,R=o,y,A)=>{s=z(s);const T=A!==void 0,C=T?A:e;let g;y.attributes.id?g=S(y.attributes.id,C):T||i?g=x(s):g=`section/${x(s)}`;const I=a(C,g).toLowerCase();y.attributes.id=I;const b={id:I,name:s,level:h,items:[],ast:[y]};return R.push(b),b},f=s=>{if(typeof s?.attributes?.content=="string")return s.attributes.content;if(s?.children)return f(s.children[0])},d=s=>{const h=f(s)||"";s.type==="heading"&&s.attributes?.level===1?c=l(h,s.attributes.level,void 0,s):s.attributes?.level?l(h,s.attributes.level,c?.items,s,c?.id):c?.items?.length?c.items[c.items.length-1]?.ast?.push(s):o.length&&o[o.length-1]?.ast?.push(s)};if(Array.isArray(n))for(const s of n)d(s);else if(n.children)for(const s of n.children)d(s);return o}function K({heading:t,basePath:r}){const e=t.items.length>0,i=a(r,t.id).toLowerCase(),n=e?t.items.map(o=>K({heading:o,basePath:r})):[];return{type:e?"group":"link",label:t.name,link:i,routeSlug:i,items:e?n:void 0,content:P(t)}}function Q(t,r,e){const i=[],n=[];for(const o of H(t,e,"")){const{item:c,children:l}=w(o,r);i.push(c),n.push(...l)}return{sectionItems:i,sectionChildren:n}}function w(t,r){const e=a(r,t.id),i=t.items.length>0,n=t.ast?.length?[V(t.ast,a(r,t.id))]:[],o=[];for(const l of t.items){const{item:f,children:d}=w(l,r);o.push(f);const s=a(r,l.id);n.push({nodeType:u.OVERVIEW_SECTION_WRAPPER,children:d,sectionId:s})}return{item:{type:i?"group":"link",label:t.name,link:e,routeSlug:e,items:i?o:void 0,content:null},children:n}}function Z(t){return typeof t=="string"?t.trim():Array.isArray(t)?t.map(r=>m(r)).filter(Boolean).join(" ").trim():m(t).trim()}function D(t,r=50){if(typeof t=="string"){const o=t.split(/\n[ \t]*\n/)[0].replace(/\s+/g," ").trim();return o?o.substring(0,r):void 0}const i=(Array.isArray(t)?t:t.children??[t])[0];if(!i)return;const n=m(i);return n?n.substring(0,r):void 0}function tt(t,r){if(!t)return;const e=p(t,r);if(!e)return;const i=D(e);return i?i.length===50?i+"\u2026":i:void 0}function et(t,r){if(!t)return;const e=p(t,r);if(e)return D(e,Number.POSITIVE_INFINITY)}function m(t){const r=[];function e(i){typeof i.attributes?.content=="string"&&r.push(i.attributes.content);for(const n of i.children??[])e(n)}return e(t),r.join("")}function nt(t){return typeof t=="string"?t.trim():(Array.isArray(t)?t:[t]).map(e=>m(e)).join("").trim()}function z(t){return t.replace(/&#(\d+);/g,(r,e)=>String.fromCharCode(parseInt(e,10))).replace(/&quot;/g,'"').replace(/&amp;/g,"&")}function rt(t,r){const{sanitize:e}=r??{},{unstable_hooks:i}=r??{};return i?.sanitize?i.sanitize(t):e?E().sanitize(t):t}function P(t){const r=[];return t.ast&&t.ast.length>0&&r.push({nodeType:u.MARKDOC,content:t.ast}),{contentType:v.ITEM,itemVariant:N.MARKDOWN,meta:{name:t.name},children:[{nodeType:u.CONTAINER,children:r,panels:[]}]}}function V(t,r){return{nodeType:u.OVERVIEW_SECTION_WRAPPER,children:[{nodeType:u.MARKDOC,content:t}],sectionId:r}}export{K as buildMarkdownSectionItem,nt as collectMarkdownPlainText,Q as collectMarkdownSections,X as extractContentUntilFirstHeading,Y as extractDescriptionSegments,D as extractFirstParagraphText,Z as extractFullText,H as extractMarkdownSections,et as extractSeoDescriptionText,tt as extractSummaryText,_ as resolveMarkdocHeadingDeepSuffix,J as resolveMarkdocHeadingIds,rt as sanitizeMarkdownSource,z as unescapeHTMLChars};
@@ -1,15 +1,17 @@
1
1
  import { Component } from 'react';
2
- import type { ReactNode, ErrorInfo } from 'react';
2
+ import type { ReactNode, ErrorInfo, ContextType } from 'react';
3
+ import { TelemetryContext } from '../contexts/telemetry.js';
3
4
  type ErrorBoundaryProps = {
4
5
  children: ReactNode;
5
6
  fallback?: ReactNode;
6
- onError?: (error: Error, errorInfo: ErrorInfo) => void;
7
7
  };
8
8
  type ErrorBoundaryState = {
9
9
  hasError: boolean;
10
10
  error: Error | null;
11
11
  };
12
12
  export declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
13
+ static contextType: import("react").Context<import("../index.js").RedocTelemetry>;
14
+ context: ContextType<typeof TelemetryContext>;
13
15
  constructor(props: ErrorBoundaryProps);
14
16
  static getDerivedStateFromError(error: Error): ErrorBoundaryState;
15
17
  componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
@@ -1 +1 @@
1
- import{jsx as t,jsxs as o}from"react/jsx-runtime";import{Component as n}from"react";class l extends n{constructor(r){super(r),this.state={hasError:!1,error:null}}static getDerivedStateFromError(r){return{hasError:!0,error:r}}componentDidCatch(r,e){console.error("[api-docs] Rendering error:",r,e.componentStack);try{this.props.onError?.(r,e)}catch(s){console.error("[api-docs] onError handler threw:",s)}}render(){return this.state.hasError?this.props.fallback?this.props.fallback:o("div",{role:"alert",style:{padding:"20px",color:"#c00"},children:[t("h2",{children:"Something went wrong rendering the API documentation."}),o("details",{style:{whiteSpace:"pre-wrap",marginTop:"10px"},children:[t("summary",{children:"Error details"}),this.state.error?.message]})]}):this.props.children}}export{l as ErrorBoundary};
1
+ import{jsx as o,jsxs as s}from"react/jsx-runtime";import{Component as a}from"react";import{TelemetryContext as i}from"../contexts/telemetry.js";class h extends a{static contextType=i;constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error("[api-docs] Rendering error:",e,t.componentStack);const r=this.context;try{r.sendErrorMessage([{id:"errorBoundaryCatch",object:"error",uri:typeof window<"u"?window.location.href:"",...r.typeOfUsage?{typeOfUsage:r.typeOfUsage}:{},details:{message:e.message,stack:t.componentStack??void 0}}])}catch(n){console.error("[api-docs] error telemetry failed:",n)}}render(){return this.state.hasError?this.props.fallback?this.props.fallback:s("div",{role:"alert",style:{padding:"20px",color:"#c00"},children:[o("h2",{children:"Something went wrong rendering the API documentation."}),s("details",{style:{whiteSpace:"pre-wrap",marginTop:"10px"},children:[o("summary",{children:"Error details"}),this.state.error?.message]})]}):this.props.children}}export{h as ErrorBoundary};
@@ -1,11 +1,11 @@
1
- import{Fragment as B,jsx as r,jsxs as l}from"react/jsx-runtime";import{useMemo as d,memo as Q,useContext as U}from"react";import{useAtomValue as E}from"jotai";import{styled as t,css as c}from"styled-components";import{apiSpecType as I}from"../../types/common.js";import{H1 as V}from"@redocly/theme/components/Typography/H1";import{H2 as Y}from"@redocly/theme/components/Typography/H2";import{H3 as J}from"@redocly/theme/components/Typography/H3";import{H4 as X}from"@redocly/theme/components/Typography/H4";import{PageActions as Z}from"@redocly/theme/components/PageActions/PageActions";import{breakpoints as ee}from"@redocly/theme/core/utils";import{useSpecTranslate as re}from"../../hooks/useTranslate.js";import{resolveText as te}from"../../utils/resolveText.js";import{routingBasePathAtom as oe,specTypeAtom as ae}from"../../jotai/store.js";import{GraphQLHeaderExtras as ne}from"../graphql/GraphQLHeaderExtras.js";import{StyledBadge as D,TextBadge as ie,renderPropertyBadge as W}from"../common/Badge.js";import{DeepLinkAnchor as se,deepLinkHoverReveal as le}from"../common/DeepLinkAnchor.js";import{joinWithSeparator as pe,toRelativePath as de}from"../../utils/url.js";import{encodeBackSlashes as ce}from"../../utils/string.js";import{buildDeepLinkUrl as me,getDeepLinkId as ge}from"../../utils/deep-link.js";import{useNavigationUrlNormalizer as he}from"../../hooks/useNormalizeUrl.js";import{ItemIdContext as fe}from"../../hooks/useDeepLinkSection.js";import{ArgsCollapsed as be}from"../graphql/styled.js";import{ResponsesDeepLinkAnchor as ue}from"./ResponseDeepLinkAnchor.js";import{HeaderResponseCodeTabs as xe}from"./HeaderResponseCodeTabs.js";import{ExpandAllButton as ve}from"../common/ExpandAllButton.js";import{useHeaderExpandableKeys as He,useResponseCodes as we,useHeaderHasRenderedCollapsibles as ke}from"./hooks.js";function ye({node:e,path:m,parentNode:_}){const{level:g,label:q,badges:u,deprecated:z,graphqlReturnType:j,graphqlArgs:x,graphqlDeprecated:G,graphqlOperationType:N,showPageActions:F=!1,deepLinkSuffix:a,protocolTag:w,isWebhook:y}=e,$=E(ae),v=re(),o=$===I.GRAPHQL,A=z||o&&G,i=E(oe),k=he(),h=U(fe),s=we(_,a),K=s?.[0]||"",f=te(v,e.labelTranslationKey,e.label),p=d(()=>m?de(m,i):"",[m,i]),H=d(()=>p?k(a?me(i,p,a):pe(i,ce(p.toLowerCase()))):"",[p,i,a,k]),R=a==="responses"&&!!s&&s.length>0&&!!m,T=He(a),M=ke(a),C=d(()=>u?.filter(n=>n.position==="before")??[],[u]),L=d(()=>u?.filter(n=>n.position!=="before")??[],[u]),P=d(()=>!H||g<=1?null:R?r(ue,{routingBasePath:i,relativePath:p,itemId:h??"",label:`link to ${f}`}):r(se,{to:H,label:`link to ${f}`}),[H,g,R,i,p,h,f]),S=d(()=>{const n=l(B,{children:[P,C.map(W),f,L.map(W)]});switch(g){case 1:return r(Be,{$inline:o,children:n});case 2:return l(Ee,{$inline:o,children:[n,A&&r(D,{$deprecated:!0,children:v("badges.deprecated","deprecated")}),y&&r(D,{webhook:!0,children:v("badges.webhook","Webhook")})]});case 3:return r(Ie,{$inline:o,children:n});case 4:return r(De,{$inline:o,children:n});case 5:return r(We,{$inline:o,children:n});default:return null}},[P,C,f,L,g,A,v,y,o]),O=!o&&g===4&&a==="responses";return l(B,{children:[w&&r(Pe,{color:w.color,borderless:!0,children:w.label}),l($e,{id:a?ge(H):void 0,$spacingBeforeResponses:O,$isAsyncApi:$===I.ASYNCAPI,children:[l(Te,{$badgeCount:s?.length??0,children:[o?l(Se,{children:[S,x&&x.length>0&&l(Ce,{"data-testid":"collapsed-args",$size:"lg",children:["(",x.length===1?x[0].name:"...args",")"]})]}):S,s&&s.length>0&&r(xe,{codes:s,itemId:h??"",firstCode:K}),T.length>0&&M&&h&&r(ve,{itemId:h,deepLinkKeys:T})]}),F&&r(Le,{children:r(Z,{pageSlug:m||i})})]}),o&&r(ne,{returnType:j,operationName:q,operationType:N})]})}const $e=t.div`
1
+ import{Fragment as B,jsx as r,jsxs as l}from"react/jsx-runtime";import{useMemo as d,memo as Q,useContext as U}from"react";import{useAtomValue as E}from"jotai";import{styled as t,css as c}from"styled-components";import{apiSpecType as I}from"../../types/common.js";import{H1 as V}from"@redocly/theme/components/Typography/H1";import{H2 as Y}from"@redocly/theme/components/Typography/H2";import{H3 as J}from"@redocly/theme/components/Typography/H3";import{H4 as X}from"@redocly/theme/components/Typography/H4";import{breakpoints as Z}from"@redocly/theme/core/openapi";import{useSpecTranslate as ee}from"../../hooks/useTranslate.js";import{resolveText as re}from"../../utils/resolveText.js";import{routingBasePathAtom as te,specTypeAtom as oe}from"../../jotai/store.js";import{GraphQLHeaderExtras as ae}from"../graphql/GraphQLHeaderExtras.js";import{StyledBadge as D,TextBadge as ne,renderPropertyBadge as W}from"../common/Badge.js";import{DeepLinkAnchor as ie,deepLinkHoverReveal as se}from"../common/DeepLinkAnchor.js";import{joinWithSeparator as le,toRelativePath as pe}from"../../utils/url.js";import{encodeBackSlashes as de}from"../../utils/string.js";import{buildDeepLinkUrl as ce,getDeepLinkId as me}from"../../utils/deep-link.js";import{useNavigationUrlNormalizer as ge}from"../../hooks/useNormalizeUrl.js";import{ItemIdContext as he}from"../../hooks/useDeepLinkSection.js";import{ArgsCollapsed as fe}from"../graphql/styled.js";import{ResponsesDeepLinkAnchor as be}from"./ResponseDeepLinkAnchor.js";import{HeaderResponseCodeTabs as ue}from"./HeaderResponseCodeTabs.js";import{HeaderPageActions as xe}from"./HeaderPageActions.js";import{ExpandAllButton as ve}from"../common/ExpandAllButton.js";import{useHeaderExpandableKeys as He,useResponseCodes as we,useHeaderHasRenderedCollapsibles as ke}from"./hooks.js";function ye({node:e,path:m,parentNode:_}){const{level:g,label:q,badges:u,deprecated:z,graphqlReturnType:j,graphqlArgs:x,graphqlDeprecated:G,graphqlOperationType:N,showPageActions:F=!1,deepLinkSuffix:a,protocolTag:w,isWebhook:y}=e,$=E(oe),v=ee(),o=$===I.GRAPHQL,A=z||o&&G,i=E(te),k=ge(),h=U(he),s=we(_,a),K=s?.[0]||"",f=re(v,e.labelTranslationKey,e.label),p=d(()=>m?pe(m,i):"",[m,i]),H=d(()=>p?k(a?ce(i,p,a):le(i,de(p.toLowerCase()))):"",[p,i,a,k]),R=a==="responses"&&!!s&&s.length>0&&!!m,T=He(a),M=ke(a),C=d(()=>u?.filter(n=>n.position==="before")??[],[u]),L=d(()=>u?.filter(n=>n.position!=="before")??[],[u]),P=d(()=>!H||g<=1?null:R?r(be,{routingBasePath:i,relativePath:p,itemId:h??"",label:`link to ${f}`}):r(ie,{to:H,label:`link to ${f}`}),[H,g,R,i,p,h,f]),S=d(()=>{const n=l(B,{children:[P,C.map(W),f,L.map(W)]});switch(g){case 1:return r(Be,{$inline:o,children:n});case 2:return l(Ee,{$inline:o,children:[n,A&&r(D,{$deprecated:!0,children:v("badges.deprecated","deprecated")}),y&&r(D,{webhook:!0,children:v("badges.webhook","Webhook")})]});case 3:return r(Ie,{$inline:o,children:n});case 4:return r(De,{$inline:o,children:n});case 5:return r(We,{$inline:o,children:n});default:return null}},[P,C,f,L,g,A,v,y,o]),O=!o&&g===4&&a==="responses";return l(B,{children:[w&&r(Pe,{color:w.color,borderless:!0,children:w.label}),l($e,{id:a?me(H):void 0,$spacingBeforeResponses:O,$isAsyncApi:$===I.ASYNCAPI,children:[l(Te,{$badgeCount:s?.length??0,children:[o?l(Se,{children:[S,x&&x.length>0&&l(Ce,{"data-testid":"collapsed-args",$size:"lg",children:["(",x.length===1?x[0].name:"...args",")"]})]}):S,s&&s.length>0&&r(ue,{codes:s,itemId:h??"",firstCode:K}),T.length>0&&M&&h&&r(ve,{itemId:h,deepLinkKeys:T})]}),F&&r(Le,{children:r(xe,{pageSlug:m||i})})]}),o&&r(ae,{returnType:j,operationName:q,operationType:N})]})}const $e=t.div`
2
2
  container-type: inline-size;
3
3
  container-name: api-docs-heading;
4
4
  position: relative;
5
5
  display: flex;
6
6
  align-items: flex-start;
7
7
  gap: var(--spacing-base);
8
- ${le}
8
+ ${se}
9
9
  margin-bottom: var(--spacing-base);
10
10
  flex-wrap: nowrap;
11
11
  gap: var(--spacing-xs);
@@ -29,7 +29,7 @@ import{Fragment as B,jsx as r,jsxs as l}from"react/jsx-runtime";import{useMemo a
29
29
  margin-top: var(--spacing-xl);
30
30
  `}
31
31
 
32
- @media screen and (max-width: ${ee.small}) {
32
+ @media screen and (max-width: ${Z.small}) {
33
33
  gap: 0;
34
34
  }
35
35
  `,Ae=250,Re=64,Te=t.div`
@@ -51,12 +51,12 @@ import{Fragment as B,jsx as r,jsxs as l}from"react/jsx-runtime";import{useMemo a
51
51
  }
52
52
  }
53
53
  `}
54
- `,Ce=t(be)`
54
+ `,Ce=t(fe)`
55
55
  margin-left: var(--spacing-xs);
56
56
  `,Le=t.div`
57
57
  flex-shrink: 0;
58
58
  margin-left: auto;
59
- `,Pe=t(ie)`
59
+ `,Pe=t(ne)`
60
60
  display: block;
61
61
  align-self: flex-start;
62
62
  margin-top: var(--spacing-md);
@@ -0,0 +1,4 @@
1
+ import type { JSX } from 'react';
2
+ export declare function HeaderPageActions({ pageSlug }: {
3
+ pageSlug: string;
4
+ }): JSX.Element | null;
@@ -0,0 +1 @@
1
+ import{jsx as r}from"react/jsx-runtime";import{PageActions as e}from"@redocly/theme/components/PageActions/PageActions";function i({pageSlug:o}){return r(e,{pageSlug:o})}export{i as HeaderPageActions};
@@ -0,0 +1,4 @@
1
+ import type { JSX } from 'react';
2
+ export declare function PageActions({ pageSlug }: {
3
+ pageSlug: string;
4
+ }): JSX.Element | null;
@@ -0,0 +1,11 @@
1
+ import{jsx as e}from"react/jsx-runtime";import{useEffect as S,useRef as b,useState as y}from"react";import{styled as g}from"styled-components";import{Button as x}from"@redocly/theme/components/Button/Button";import{SplitButton as I}from"@redocly/theme/components/SplitButton/SplitButton";import{DropdownMenu as L}from"@redocly/theme/components/Dropdown/DropdownMenu";import{DropdownMenuItem as A}from"@redocly/theme/components/Dropdown/DropdownMenuItem";import{PageActionsMenuItem as w}from"@redocly/theme/components/PageActions/PageActionsMenuItem";import{CopyIcon as h}from"@redocly/theme/icons/CopyIcon/CopyIcon";import{ChatGptIcon as k}from"@redocly/theme/icons/ChatGptIcon/ChatGptIcon";import{ClaudeIcon as v}from"@redocly/theme/icons/ClaudeIcon/ClaudeIcon";import{Spinner as D}from"@redocly/theme/icons/Spinner/Spinner";import{CheckmarkFilledIcon as G}from"@redocly/theme/icons/CheckmarkFilledIcon/CheckmarkFilledIcon";import{ClipboardService as M}from"@redocly/theme/core/openapi";import{useSpecTranslate as P}from"../../hooks/useTranslate.js";import{useCopySpecSlice as _}from"../../hooks/useCopySpecSlice.js";import{ASSISTANT_LINK_BASES as C,buildInlinePromptLink as B,buildFetchSpecPromptLink as O}from"../../services/spec-slice/index.js";const R=1e3;function N(i){if(i)try{return new URL(i,document.baseURI).toString()}catch{return}}function it({pageSlug:i}){const o=P(),n=_(i),[l,c]=y("idle"),a=b(void 0);if(S(()=>()=>clearTimeout(a.current),[]),!n)return null;const u=async()=>{if(l!=="processing"){c("processing");try{const t=await n.getText();M.copyCustom(t),c("done"),clearTimeout(a.current),a.current=setTimeout(()=>c("idle"),R)}catch(t){console.error(t),c("idle")}}},d=async t=>{const r=window.open("","_blank");try{const p=await n.getText(),f=N(n.specUrl),s=B(t,p,n.contentKind)??(f?O(t,f,n.scope):void 0);if(!s){r?.close();return}r?r.location.href=s:window.open(s,"_blank")}catch(p){r?.close(),console.error(p)}},m=[{buttonText:o("page.actions.copyButtonText","Copy"),title:o("page.actions.copyTitle","Copy for LLM"),description:o("page.actions.copyDescription",n.contentKind==="graphql"?"Copy page as GraphQL SDL for LLMs":"Copy page as YAML for LLMs"),iconComponent:h,onClick:u},{buttonText:o("page.actions.claudeButtonText","Open in Claude"),title:o("page.actions.claudeTitle","Open in Claude"),description:o("page.actions.claudeDescription","Get insights from Claude"),iconComponent:v,onClick:()=>d(C.claude)},{buttonText:o("page.actions.chatGptButtonText","Open in ChatGPT"),title:o("page.actions.chatGptTitle","Open in ChatGPT"),description:o("page.actions.chatGptDescription","Get insights from ChatGPT"),iconComponent:k,onClick:()=>d(C.chatgpt)}],T=m.map((t,r)=>e(A,{onAction:()=>"onClick"in t?t.onClick():void 0,children:e(w,{pageAction:t})},`${t.title}-${r}`));return e(z,{"data-testid":"page-actions",children:e(I,{portalled:!0,variant:"outlined",size:"medium",toggleAriaLabel:o("page.actions.moreActions","More actions"),button:e(x,{variant:"outlined",icon:U(l),onClick:u,children:m[0].buttonText}),children:e(E,{children:T})})})}function U(i){switch(i){case"processing":return e(D,{color:"var(--page-actions-processing-icon-color)"});case"done":return e(G,{color:"var(--page-actions-done-icon-color)"});default:return e(h,{})}}const z=g.div`
2
+ margin-left: auto;
3
+ padding-left: var(--page-actions-padding-left);
4
+ --button-color: var(--page-actions-button-text-color);
5
+
6
+ .button-group-size-medium .button.button-size-medium {
7
+ --button-icon-left-padding: var(--page-actions-button-padding);
8
+ }
9
+ `,E=g(L)`
10
+ --dropdown-menu-max-height: var(--page-actions-dropdown-max-height);
11
+ `;export{it as PageActions};
@@ -1,4 +1,4 @@
1
- import{Fragment as g,jsx as n,jsxs as l}from"react/jsx-runtime";import{styled as a}from"styled-components";import{useCallback as N,useContext as W,useEffect as K,useMemo as r,useRef as z,useState as q}from"react";import{useAtomValue as G,useSetAtom as U}from"jotai";import{Segmented as Q}from"@redocly/theme/components/Segmented/Segmented";import{breakpoints as S}from"@redocly/theme/core/utils";import{collectMarkdownPlainText as X}from"../../../adapters/utils/markdoc.js";import{SECTION_ATTR as Y}from"../../../constants/openapi.js";import{SchemaView as f}from"../../Schema/SchemaView.js";import{VariantDropdown as Z}from"../../Schema/views/VariantDropdown.js";import{Markdown as ee}from"../../common/Markdown.js";import{ExternalDocumentation as ne}from"../../common/ExternalDocumentation.js";import{DeepLinkAnchor as D,deepLinkHoverReveal as C}from"../../common/DeepLinkAnchor.js";import{buildAsyncApiSuffix as b,getDeepLinkId as w}from"../../../utils/deep-link.js";import{DeepLinkSectionContext as E,ItemIdContext as te,useDeepLinkUrl as M}from"../../../hooks/useDeepLinkSection.js";import{isRecord as $}from"../../../adapters/helpers.js";import{itemStoreAtom as oe,itemStoreFieldAtom as ae}from"../../../jotai/itemStore.js";import{useSpecTranslate as re}from"../../../hooks/useTranslate.js";import{useTelemetry as ie}from"../../../hooks/useTelemetry.js";import{useKeyFromHash as se}from"../hooks.js";const ce=3;function je({node:e}){const o=e.messages;return!o||o.length===0?n(g,{}):n(le,{messages:o})}function le({messages:e}){const o=W(te),d=U(oe(o??"")),h=G(r(()=>ae({itemId:o??"",key:"activeMessageKey"}),[o])),y=r(()=>e.map(t=>t.name),[e]),i=se(o??void 0,y,"m"),m=z(void 0),s=i!==void 0&&i!==m.current?i:h||e[0].name,c=r(()=>e.find(t=>t.name===s)??e[0],[e,s]);K(()=>{i&&d({activeMessageKey:i}),m.current=i},[i,d]);const u=ie(),v=r(()=>e.map(t=>({value:t.name,label:t.label||t.name})),[e]),I=z(null),[P,R]=q(!1);K(()=>{const t=()=>{const A=I.current;if(!A)return;const O=A.querySelectorAll('[role="tab"]'),V=Array.from(O).some(J=>{const T=J;return T.offsetWidth<T.scrollWidth});R(V)};return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[v]);const _=e.length>ce||e.length>1&&P,k=N(t=>{u.sendSwitchMessageClickedMessage([{id:"switchMessageButton",object:"button",uri:"urn:redocly:redoc:ui:button:switchMessageButton",message:t}]),d({activeMessageKey:t})},[u,d]),j=r(()=>c?.name?b({section:"messages",messageKey:c.name}):"",[c?.name]),x=M(j),L=r(()=>o?`${o}/messages`:void 0,[o]),H=L?{[Y]:L}:{};return l("div",{...H,children:[n(me,{children:e.length>1?l(g,{children:["Accepts ",n(pe,{children:"one of"})," the following messages:"]}):n(g,{children:"Accepts the following message:"})}),l(ue,{id:w(x),children:[x&&n(fe,{children:n(D,{to:x,label:"link to Message selector"})}),_?n(Z,{value:s,options:v,onChange:t=>{t.value!==void 0&&k(t.value)}}):n(Q,{ref:I,size:"small",value:s,options:v,onChange:t=>{t.value!==void 0&&k(t.value)}})]}),c&&n(de,{message:c})]})}function de({message:e}){const o=re(),d=o("header","Headers"),h=r(()=>e.name?{asyncSection:"messages",messageKey:e.name,t:"headers"}:null,[e.name]),y=r(()=>e.name?{asyncSection:"messages",messageKey:e.name,t:"payload"}:null,[e.name]),i=r(()=>e.name?b({section:"messages",messageKey:e.name,subsection:"headers"}):"",[e.name]),m=r(()=>e.name?b({section:"messages",messageKey:e.name,subsection:"payload"}):"",[e.name]),p=M(i),s=M(m),c=e.payloadLabel??o("payload","Payload"),u=e.externalDocs?.description!=null?X(e.externalDocs.description):void 0;return l(he,{children:[e.summary&&n(ye,{children:e.summary}),e.description&&n(ve,{children:n(ee,{source:e.description})}),e.externalDocs?.url&&n(xe,{children:n(ne,{externalDocs:{url:e.externalDocs.url,description:u||void 0},compact:!0})}),(e.headerSchemaId||$(e.headers))&&l(B,{id:w(p),children:[l(F,{children:[p&&n(D,{to:p,label:`link to ${d}`}),d]}),n(E.Provider,{value:h,children:e.headerSchemaId?n(f,{schemaId:e.headerSchemaId,expandByDefault:!0}):n(f,{schema:e.headers,expandByDefault:!0})})]}),(e.schemaId||$(e.payload))&&l(B,{id:w(s),children:[l(F,{children:[s&&n(D,{to:s,label:`link to ${c}`}),c,e.contentType&&n(ge,{children:e.contentType})]}),n(E.Provider,{value:y,children:e.schemaId?n(f,{schemaId:e.schemaId,expandByDefault:!0}):n(f,{schema:e.payload,expandByDefault:!0})})]})]})}const me=a.p`
1
+ import{Fragment as g,jsx as n,jsxs as l}from"react/jsx-runtime";import{styled as a}from"styled-components";import{useCallback as N,useContext as W,useEffect as K,useMemo as r,useRef as z,useState as q}from"react";import{useAtomValue as G,useSetAtom as U}from"jotai";import{Segmented as Q}from"@redocly/theme/components/Segmented/Segmented";import{breakpoints as S}from"@redocly/theme/core/openapi";import{collectMarkdownPlainText as X}from"../../../adapters/utils/markdoc.js";import{SECTION_ATTR as Y}from"../../../constants/openapi.js";import{SchemaView as f}from"../../Schema/SchemaView.js";import{VariantDropdown as Z}from"../../Schema/views/VariantDropdown.js";import{Markdown as ee}from"../../common/Markdown.js";import{ExternalDocumentation as ne}from"../../common/ExternalDocumentation.js";import{DeepLinkAnchor as D,deepLinkHoverReveal as C}from"../../common/DeepLinkAnchor.js";import{buildAsyncApiSuffix as b,getDeepLinkId as w}from"../../../utils/deep-link.js";import{DeepLinkSectionContext as E,ItemIdContext as te,useDeepLinkUrl as M}from"../../../hooks/useDeepLinkSection.js";import{isRecord as $}from"../../../adapters/helpers.js";import{itemStoreAtom as oe,itemStoreFieldAtom as ae}from"../../../jotai/itemStore.js";import{useSpecTranslate as re}from"../../../hooks/useTranslate.js";import{useTelemetry as ie}from"../../../hooks/useTelemetry.js";import{useKeyFromHash as se}from"../hooks.js";const ce=3;function je({node:e}){const o=e.messages;return!o||o.length===0?n(g,{}):n(le,{messages:o})}function le({messages:e}){const o=W(te),d=U(oe(o??"")),h=G(r(()=>ae({itemId:o??"",key:"activeMessageKey"}),[o])),y=r(()=>e.map(t=>t.name),[e]),i=se(o??void 0,y,"m"),m=z(void 0),s=i!==void 0&&i!==m.current?i:h||e[0].name,c=r(()=>e.find(t=>t.name===s)??e[0],[e,s]);K(()=>{i&&d({activeMessageKey:i}),m.current=i},[i,d]);const u=ie(),v=r(()=>e.map(t=>({value:t.name,label:t.label||t.name})),[e]),I=z(null),[P,R]=q(!1);K(()=>{const t=()=>{const A=I.current;if(!A)return;const O=A.querySelectorAll('[role="tab"]'),V=Array.from(O).some(J=>{const T=J;return T.offsetWidth<T.scrollWidth});R(V)};return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[v]);const _=e.length>ce||e.length>1&&P,k=N(t=>{u.sendSwitchMessageClickedMessage([{id:"switchMessageButton",object:"button",uri:"urn:redocly:redoc:ui:button:switchMessageButton",message:t}]),d({activeMessageKey:t})},[u,d]),j=r(()=>c?.name?b({section:"messages",messageKey:c.name}):"",[c?.name]),x=M(j),L=r(()=>o?`${o}/messages`:void 0,[o]),H=L?{[Y]:L}:{};return l("div",{...H,children:[n(me,{children:e.length>1?l(g,{children:["Accepts ",n(pe,{children:"one of"})," the following messages:"]}):n(g,{children:"Accepts the following message:"})}),l(ue,{id:w(x),children:[x&&n(fe,{children:n(D,{to:x,label:"link to Message selector"})}),_?n(Z,{value:s,options:v,onChange:t=>{t.value!==void 0&&k(t.value)}}):n(Q,{ref:I,size:"small",value:s,options:v,onChange:t=>{t.value!==void 0&&k(t.value)}})]}),c&&n(de,{message:c})]})}function de({message:e}){const o=re(),d=o("header","Headers"),h=r(()=>e.name?{asyncSection:"messages",messageKey:e.name,t:"headers"}:null,[e.name]),y=r(()=>e.name?{asyncSection:"messages",messageKey:e.name,t:"payload"}:null,[e.name]),i=r(()=>e.name?b({section:"messages",messageKey:e.name,subsection:"headers"}):"",[e.name]),m=r(()=>e.name?b({section:"messages",messageKey:e.name,subsection:"payload"}):"",[e.name]),p=M(i),s=M(m),c=e.payloadLabel??o("payload","Payload"),u=e.externalDocs?.description!=null?X(e.externalDocs.description):void 0;return l(he,{children:[e.summary&&n(ye,{children:e.summary}),e.description&&n(ve,{children:n(ee,{source:e.description})}),e.externalDocs?.url&&n(xe,{children:n(ne,{externalDocs:{url:e.externalDocs.url,description:u||void 0},compact:!0})}),(e.headerSchemaId||$(e.headers))&&l(B,{id:w(p),children:[l(F,{children:[p&&n(D,{to:p,label:`link to ${d}`}),d]}),n(E.Provider,{value:h,children:e.headerSchemaId?n(f,{schemaId:e.headerSchemaId,expandByDefault:!0}):n(f,{schema:e.headers,expandByDefault:!0})})]}),(e.schemaId||$(e.payload))&&l(B,{id:w(s),children:[l(F,{children:[s&&n(D,{to:s,label:`link to ${c}`}),c,e.contentType&&n(ge,{children:e.contentType})]}),n(E.Provider,{value:y,children:e.schemaId?n(f,{schemaId:e.schemaId,expandByDefault:!0}):n(f,{schema:e.payload,expandByDefault:!0})})]})]})}const me=a.p`
2
2
  margin: 0 0 var(--spacing-sm, 12px);
3
3
  color: var(--text-color-secondary, #666);
4
4
  font-size: var(--font-size-base, 14px);
@@ -1 +1 @@
1
- import{jsx as e,jsxs as m}from"react/jsx-runtime";import{memo as h,useMemo as n}from"react";import{useAtomValue as g}from"jotai";import{storeAtom as M}from"../../jotai/store.js";import{useSpecTranslate as x}from"../../hooks/useTranslate.js";import{SchemaView as A}from"../Schema/SchemaView.js";import{ContentWrapper as c}from"../common/ContentWrapper.js";import{DeepLinkAnchor as S}from"../common/DeepLinkAnchor.js";import{Markdown as D}from"../common/Markdown.js";import{getDeepLinkId as k}from"../../utils/deep-link.js";import{DeepLinkSectionContext as L,useDeepLinkUrl as P}from"../../hooks/useDeepLinkSection.js";import{McpSection as b,McpSubRow as a,McpTitle as j,McpTitleWrapper as w}from"./styled.js";import{buildMcpExamplePanel as C,buildPromptArgumentsSchema as T,useMcpDescriptionAst as v}from"./utils.js";function V({name:p}){const i=g(M),l=x(),r=n(()=>i.mcp?.prompts?.find(f=>f.name===p),[i.mcp,p]),s=v(r?.description),t=n(()=>r?.arguments?.length?T(r.arguments):null,[r]),u=n(()=>t?[C(t,"Arguments example")]:void 0,[t]),o=P("arguments"),d=n(()=>({t:"arguments"}),[]);return r?m(b,{children:[s?e(c,{children:e(a,{children:e(D,{source:s})})}):null,t&&e(c,{panels:u,children:m(a,{children:[e(w,{id:k(o),children:m(j,{children:[o&&e(S,{to:o,label:"link to Arguments"}),l("openapi.mcp.inputSchema","Arguments")]})}),e(L.Provider,{value:d,children:e(A,{schema:t,expandByDefault:!0})})]})})]}):null}const J=h(V);export{J as McpPrompt};
1
+ import{jsx as e,jsxs as m}from"react/jsx-runtime";import{memo as h,useMemo as n}from"react";import{useAtomValue as g}from"jotai";import{storeAtom as M}from"../../jotai/store.js";import{useSpecTranslate as S}from"../../hooks/useTranslate.js";import{SchemaView as x}from"../Schema/SchemaView.js";import{ContentWrapper as c}from"../common/ContentWrapper.js";import{DeepLinkAnchor as A}from"../common/DeepLinkAnchor.js";import{Markdown as D}from"../common/Markdown.js";import{getDeepLinkId as k}from"../../utils/deep-link.js";import{DeepLinkSectionContext as L,useDeepLinkUrl as P}from"../../hooks/useDeepLinkSection.js";import{McpSection as b,McpSubRow as a,McpTitle as j,McpTitleWrapper as w}from"./styled.js";import{buildMcpExamplePanel as C,buildPromptArgumentsSchema as T,useMcpDescriptionAst as v}from"./utils.js";function V({name:p}){const i=g(M),u=S(),r=n(()=>i.mcp?.prompts?.find(f=>f.name===p),[i.mcp,p]),s=v(r?.description),t=n(()=>r?.arguments?.length?T(r.arguments):null,[r]),l=n(()=>t?[C(t,"arguments")]:void 0,[t]),o=P("arguments"),d=n(()=>({t:"arguments"}),[]);return r?m(b,{children:[s?e(c,{children:e(a,{children:e(D,{source:s})})}):null,t&&e(c,{panels:l,children:m(a,{children:[e(w,{id:k(o),children:m(j,{children:[o&&e(A,{to:o,label:"link to Arguments"}),u("openapi.mcp.inputSchema","Arguments")]})}),e(L.Provider,{value:d,children:e(x,{schema:t,expandByDefault:!0})})]})})]}):null}const J=h(V);export{J as McpPrompt};