@redocly/api-docs 0.2.0-next.4 → 0.2.0-next.6

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 (136) 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/adapters/asyncapi/items/overview/content.js +1 -1
  6. package/lib/adapters/graphql/utils/createApiItem.js +1 -1
  7. package/lib/adapters/helpers.d.ts +2 -0
  8. package/lib/adapters/helpers.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/index.js +1 -1
  13. package/lib/adapters/openapi/items/operation/content.js +1 -1
  14. package/lib/adapters/openapi/items/operation/item.js +1 -1
  15. package/lib/adapters/openapi/items/overview/content.js +1 -1
  16. package/lib/adapters/openapi/store.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 +1 -1
  23. package/lib/components/ItemContent/sections/MessagesSection.js +1 -1
  24. package/lib/components/Schema/styled.js +4 -4
  25. package/lib/components/Schema/views/ArrayRenderer.js +1 -1
  26. package/lib/components/Search/index.d.ts +15 -0
  27. package/lib/components/Search/index.js +1 -0
  28. package/lib/components/Security/styled.js +7 -7
  29. package/lib/components/StickySidebar/FloatingButton.d.ts +1 -0
  30. package/lib/components/StickySidebar/FloatingButton.js +32 -0
  31. package/lib/components/StickySidebar/RedoclyAttributionLogo.d.ts +5 -0
  32. package/lib/components/StickySidebar/RedoclyAttributionLogo.js +1 -0
  33. package/lib/components/StickySidebar/StickySidebar.js +33 -9
  34. package/lib/components/common/Breadcrumbs.js +2 -2
  35. package/lib/components/common/ResponseCodeTabs.js +1 -1
  36. package/lib/components/common/Tag.js +1 -1
  37. package/lib/components/common/ViewNested.js +2 -2
  38. package/lib/components/graphql/GraphQLFieldView.js +1 -1
  39. package/lib/components/graphql/RequiresScopesModal.js +3 -3
  40. package/lib/components/graphql/sections/GraphQLArgsSection.js +1 -1
  41. package/lib/components/panels/ExampleItem/CallbackPayloadItem.js +2 -2
  42. package/lib/components/panels/ExampleItem/CodeSampleItem.js +1 -1
  43. package/lib/components/panels/ExampleItem/PayloadExampleItem.js +2 -2
  44. package/lib/components/panels/ExampleItem/ResponseExampleItem.js +1 -1
  45. package/lib/components/panels/ExampleItem/SecuritySchemeSelector.d.ts +9 -0
  46. package/lib/components/panels/ExampleItem/SecuritySchemeSelector.js +1 -0
  47. package/lib/components/panels/ExampleItem/ServerDropdown.js +1 -1
  48. package/lib/components/panels/ExampleItem/generate-request-sample.d.ts +28 -0
  49. package/lib/components/panels/ExampleItem/generate-request-sample.js +1 -0
  50. package/lib/components/panels/ExampleItem/selectors.d.ts +5 -2
  51. package/lib/components/panels/ExampleItem/selectors.js +1 -1
  52. package/lib/components/panels/ExampleItem/styled.d.ts +2 -49
  53. package/lib/components/panels/ExampleItem/styled.js +11 -5
  54. package/lib/components/panels/ExampleItem/useActiveServer.d.ts +17 -0
  55. package/lib/components/panels/ExampleItem/useActiveServer.js +1 -0
  56. package/lib/components/panels/ExampleItem/useCodeSampleLanguages.d.ts +23 -0
  57. package/lib/components/panels/ExampleItem/useCodeSampleLanguages.js +1 -0
  58. package/lib/components/panels/ExampleItem/useReplayRequestState.d.ts +18 -0
  59. package/lib/components/panels/ExampleItem/useReplayRequestState.js +1 -0
  60. package/lib/components/panels/ExampleItem/useTryItFooter.d.ts +3 -0
  61. package/lib/components/panels/ExampleItem/useTryItFooter.js +7 -0
  62. package/lib/components/panels/GroupPanelItem.js +1 -1
  63. package/lib/components/panels/McpPanelItem.js +2 -2
  64. package/lib/components/panels/ServerItem/ServerItem.js +1 -1
  65. package/lib/components/panels/asyncapi/BrokerItem/BrokerModal.js +1 -1
  66. package/lib/components/panels/asyncapi/BrokerItem/BrokerPanelItem.js +1 -1
  67. package/lib/components/panels/shared-panel-styles.js +1 -1
  68. package/lib/components/pluggable/RedocExample.js +5 -2
  69. package/lib/hoc/withStoreProvider.js +1 -1
  70. package/lib/hooks/useInitialTelemetry.d.ts +2 -0
  71. package/lib/hooks/useInitialTelemetry.js +1 -0
  72. package/lib/hooks/useScrollSpyUrlSync.js +1 -1
  73. package/lib/index.d.ts +3 -0
  74. package/lib/index.js +1 -1
  75. package/lib/jotai/app.d.ts +6 -0
  76. package/lib/jotai/app.js +1 -1
  77. package/lib/jotai/examples.js +1 -1
  78. package/lib/jotai/itemStore.d.ts +1 -0
  79. package/lib/jotai/itemStore.js +1 -1
  80. package/lib/options/editionOverrides.d.ts +3 -0
  81. package/lib/options/editionOverrides.js +1 -0
  82. package/lib/options/helpers.d.ts +1 -1
  83. package/lib/options/normalizeOptions.d.ts +1 -1
  84. package/lib/options/normalizeOptions.js +1 -1
  85. package/lib/pages/ItemPage.js +4 -2
  86. package/lib/services/code-samples/apply-env-variables.d.ts +8 -0
  87. package/lib/services/code-samples/apply-env-variables.js +1 -0
  88. package/lib/services/code-samples/builder.d.ts +3 -5
  89. package/lib/services/code-samples/builder.js +1 -1
  90. package/lib/services/code-samples/discriminator.d.ts +16 -10
  91. package/lib/services/code-samples/discriminator.js +1 -1
  92. package/lib/services/code-samples/language-availability.d.ts +4 -0
  93. package/lib/services/code-samples/language-availability.js +1 -0
  94. package/lib/services/code-samples/{replay/normalize-servers.d.ts → normalize-servers.d.ts} +1 -1
  95. package/lib/services/code-samples/normalize-servers.js +1 -0
  96. package/lib/services/code-samples/replay/from-openapi-document.js +1 -1
  97. package/lib/services/code-samples/replay/replay-predefined-env.d.ts +1 -2
  98. package/lib/services/code-samples/replay/replay-predefined-env.js +1 -1
  99. package/lib/services/code-samples/resolvers.js +1 -1
  100. package/lib/services/code-samples/server-env.d.ts +3 -0
  101. package/lib/services/code-samples/server-env.js +1 -0
  102. package/lib/services/code-samples/source.d.ts +3 -3
  103. package/lib/services/operation-samples/index.js +1 -1
  104. package/lib/services/schema/dialects/jsonSchema.d.ts +5 -1
  105. package/lib/services/schema/dialects/jsonSchema.js +1 -1
  106. package/lib/services/schema/propertyTreeBuilder.js +1 -1
  107. package/lib/services/search/indexer.d.ts +9 -0
  108. package/lib/services/search/indexer.js +1 -0
  109. package/lib/services/search/types.d.ts +27 -0
  110. package/lib/services/search/types.js +0 -0
  111. package/lib/standalone.d.ts +19 -0
  112. package/lib/standalone.js +2 -0
  113. package/lib/standaloneThemeConfig.d.ts +3 -0
  114. package/lib/standaloneThemeConfig.js +1 -0
  115. package/lib/telemetry/RedocTelemetry.d.ts +3 -0
  116. package/lib/telemetry/RedocTelemetry.js +1 -1
  117. package/lib/telemetry/defaults.d.ts +2 -0
  118. package/lib/telemetry/defaults.js +1 -0
  119. package/lib/types/code-samples-config.d.ts +68 -0
  120. package/lib/types/code-samples-config.js +0 -0
  121. package/lib/types/common.d.ts +1 -1
  122. package/lib/types/content.d.ts +2 -1
  123. package/lib/types/edition-config.d.ts +4 -0
  124. package/lib/types/edition-config.js +0 -0
  125. package/lib/types/events.d.ts +2 -2
  126. package/lib/types/openapi.d.ts +2 -1
  127. package/lib/types/options.d.ts +27 -85
  128. package/lib/types/store.d.ts +1 -1
  129. package/lib/utils/deep-link.d.ts +1 -0
  130. package/lib/utils/deep-link.js +1 -1
  131. package/lib/utils/extract-extensions.js +1 -1
  132. package/lib/utils/scroll-anchoring.d.ts +2 -1
  133. package/lib/utils/x-logo.d.ts +13 -0
  134. package/lib/utils/x-logo.js +1 -0
  135. package/package.json +28 -7
  136. 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 (OpenAPI/AsyncAPI only) — used for search deep links. */
30
+ document?: Record<string, unknown>;
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 h,jsx as A,jsxs as E}from"react/jsx-runtime";import{useEffect as S,useMemo as j,useState as P}from"react";import{RedoclyApiDocsStandalone as I}from"./RedoclyApiDocsStandalone.js";import{buildItems as T}from"./adapters/build.js";import{markdocParser as v}from"./components/markdoc/markdocParser.js";import{loadAndBundleDefinition as D}from"./utils/loadAndBundleSpec.js";import{logoFromDefinition as F}from"./utils/x-logo.js";import{apiSpecType as s}from"./types/common.js";const G=/\.(graphql|gql)([?#]|$)/i;function H({definition:e,definitionUrl:t,specType:n}){if(n)return n;if(typeof e=="string"||G.test(t??""))return s.GRAPHQL;if(e&&typeof e=="object")return"asyncapi"in e?s.ASYNCAPI:s.OPENAPI}async function L({definition:e,definitionUrl:t,specType:n}){if(e===void 0&&t===void 0)throw new Error('Either "definition" or "definitionUrl" must be provided');const a=H({definition:e,definitionUrl:t,specType:n});if(a===s.GRAPHQL){const p=typeof e=="string"?e:await(await fetch(t)).text(),{parse:c}=await import("graphql");return{document:c(p),type:s.GRAPHQL}}const o=await D(e??t),r=a??(o&&typeof o=="object"&&"asyncapi"in o?s.ASYNCAPI:s.OPENAPI);return{document:o,type:r}}async function g({definition:e,definitionUrl:t,specType:n,options:a={},basePath:o="/"}){const r=await L({definition:e,definitionUrl:t,specType:n}),p={specType:r.type,metadata:{type:r.type},...a},{items:c,store:m}=await T({type:r.type,document:r.document,options:p,basePath:o,markdownParser:v});return{items:c,store:m,options:p,specType:r.type,document:r.type===s.GRAPHQL?void 0:r.document}}const w=({definition:e,definitionUrl:t,specType:n,options:a,basePath:o="/",logo:r,markdownAdapter:p,telemetryConfig:c,onLoaded:m,children:R})=>{const[i,l]=P(null),[f,y]=P(null),x=j(()=>({typeOfUsage:"react",...c}),[c]);return S(()=>{let d=!1;return l(null),y(null),g({definition:e,definitionUrl:t,specType:n,options:a,basePath:o}).then(u=>{d||(l(u),m?.())}).catch(u=>{d||(y(u),m?.(u))}),()=>{d=!0}},[e,t,n,o]),f?E("div",{role:"alert",style:{padding:"1em",fontFamily:"monospace",color:"#e53e3e"},children:["Failed to load API definition: ",f.message]}):i?A(I,{items:i.items,store:i.store,basePath:o,options:i.options,logo:r??F(i.document),markdownAdapter:p,telemetryConfig:x,definition:i.document}):A(h,{children:R??null})};var Y=w;export{w as RedocStandalone,Y as default,H as detectSpecType,g 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 U}from"./hooks/useApiDocsRoutes.js";import{useVisitedChannelsTracker as w}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{withReplayPrefetch as O}from"./hoc/withReplayPrefetch.js";const d=r=>{const{items:t=[],basePath:s,markdownAdapter:y,telemetryConfig:e}=r,{routeIndex:g}=U(t,s),m=S(A),c=e?.specType,i=e?.collectorUrl,p=e?.serviceName,n=e?.serviceVersion,l=e?.disabled,a=e?.typeOfUsage,h=v(()=>new R({specType:c??m,collectorUrl:i,serviceName:p,serviceVersion:n,disabled:l,typeOfUsage:a}),[m,c,i,p,n,l,a]);return o(P,{value:y,children:f(b.Provider,{value:h,children:[o(E,{}),o(H,{routeIndex:g,basePath:s})]})})};function E(){return w(),C(),D(),null}const H=({routeIndex:r,basePath:t})=>(V(),j(),f(k,{children:[o(x,{}),o(I,{routeIndex:r,basePath:t})]})),u=B(N,M,T,r=>O(r,{respectHideReplay:!0}))(d);var ce=u;export{u as RedoclyApiDocs,d as RedoclyApiDocsComponent,ce as default};
@@ -11,6 +11,8 @@ type RedoclyApiDocsStandaloneProps = {
11
11
  logo?: RawLogo;
12
12
  telemetryConfig?: Partial<RedocTelemetryConfig>;
13
13
  markdownAdapter?: MarkdownAdapter;
14
+ /** Bundled definition — consumed only by the community fork (search `$ref` resolution). */
15
+ definition?: Record<string, unknown>;
14
16
  };
15
17
  declare const RedoclyApiDocsStandalone: import("react").FC<any>;
16
18
  export { RedoclyApiDocsStandalone };
@@ -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{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};
@@ -15,6 +15,8 @@ export declare function splitRbacSection<T>(map: Record<string, T> | undefined):
15
15
  sectionRbac: Record<string, string> | undefined;
16
16
  entries: [string, T][];
17
17
  };
18
+ /** Accepts a raw markdown string or a host-pre-parsed AST node; drops anything else. */
19
+ export declare function pickRenderableDescription(value: unknown): ExampleEntry['description'];
18
20
  export declare function registerExample(exampleStore: Record<string, ExampleEntry>, entry: Omit<ExampleEntry, 'id'> & {
19
21
  id?: string;
20
22
  }): string;
@@ -1 +1 @@
1
- import{REDOCLY_TEAMS_RBAC as u}from"@redocly/config";import{getDefinitionName as l}from"./openapi/utils/helpers.js";let d=0,x=0;function C(){d=0,x=0}function s(e,r){return e==null?String(e):typeof e!="object"?JSON.stringify(e):(r||(r=new Set),r.has(e)?'"[Circular]"':(r.add(e),Array.isArray(e)?"["+e.map(n=>s(n,r)).join(",")+"]":c(e)?"{"+Object.keys(e).sort().map(n=>JSON.stringify(n)+":"+s(e[n],r)).join(",")+"}":"{}"))}function O(e,r,t){const n=g(t);if(t.id&&e[t.id])return t.id;if(!t.id){const o=s(t.data),p=r[o];if(p)return p;const f=`schema_${d++}`;return e[f]={...n,id:f},r[o]=f,f}e[t.id]={...n,id:t.id};const i=s(t.data);return r[i]||(r[i]=t.id),t.id}function g(e){const r=m(e.data);return r?{...e,[u]:r}:e}function m(e){if(!c(e))return;const r=e[u];return c(r)?r:void 0}function A(e){return e?{[u]:e}:{}}function E(e){return e?{sectionRbac:m(e),entries:Object.entries(e).filter(([r])=>r!==u)}:{sectionRbac:void 0,entries:[]}}function $(e,r){const t=r.id??`example_${x++}`;return e[t]||(e[t]={...r,id:t}),t}function k(e,r){return e[r.id]||(e[r.id]=r),r.id}function y(e){return{schemaStore:{},exampleStore:{},securitySchemeStore:{},hashIndex:{},document:e}}function c(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function N(e){return c(e)?e:{}}function a(e,r,t){if(c(r)){if(typeof r.$ref=="string"){const n=r.$ref,i=l(n);return i&&t?.has(i)?{type:"object",title:i}:R(e,n)}return r}}function b(e){return c(e)&&typeof e.$ref=="string"}function _(e,r,t){const n=r?.content;if(!n)return;const i=b(n)?a(e,n,t):n;return S(i,r)}function S(e,r){if(!e)return e;const t=r["x-examples"];if(t){const i={...e};for(const o of Object.keys(t))i[o]={...i[o],examples:t[o]};return i}const n=r["x-example"];if(n){const i={...e};for(const o of Object.keys(n))i[o]={...i[o],example:n[o]};return i}return e}function R(e,r){if(!r.startsWith("#/"))return;const t=r.slice(2).split("/").map(i=>i.replace(/~1/g,"/").replace(/~0/g,"~"));let n=e;for(const i of t){if(!c(n))return;n=n[i]}return c(n)?n:void 0}export{y as createStoreContext,b as isOpenAPIRef,c as isRecord,A as rbacProp,m as readRbacScope,$ as registerExample,O as registerSchema,k as registerSecurityScheme,C as resetStoreCounters,_ as resolveContent,R as resolveJsonPointer,a as resolveRef,E as splitRbacSection,s as stableStringify,N as toRecord};
1
+ import{REDOCLY_TEAMS_RBAC as u}from"@redocly/config";import{getDefinitionName as l}from"./openapi/utils/helpers.js";let d=0,x=0;function C(){d=0,x=0}function s(e,r){return e==null?String(e):typeof e!="object"?JSON.stringify(e):(r||(r=new Set),r.has(e)?'"[Circular]"':(r.add(e),Array.isArray(e)?"["+e.map(n=>s(n,r)).join(",")+"]":c(e)?"{"+Object.keys(e).sort().map(n=>JSON.stringify(n)+":"+s(e[n],r)).join(",")+"}":"{}"))}function O(e,r,t){const n=g(t);if(t.id&&e[t.id])return t.id;if(!t.id){const o=s(t.data),p=r[o];if(p)return p;const f=`schema_${d++}`;return e[f]={...n,id:f},r[o]=f,f}e[t.id]={...n,id:t.id};const i=s(t.data);return r[i]||(r[i]=t.id),t.id}function g(e){const r=m(e.data);return r?{...e,[u]:r}:e}function m(e){if(!c(e))return;const r=e[u];return c(r)?r:void 0}function A(e){return e?{[u]:e}:{}}function E(e){return e?{sectionRbac:m(e),entries:Object.entries(e).filter(([r])=>r!==u)}:{sectionRbac:void 0,entries:[]}}function y(e){return typeof e=="string"||typeof e=="object"&&e!==null?e:void 0}function k(e,r){const t=r.id??`example_${x++}`;return e[t]||(e[t]={...r,id:t}),t}function $(e,r){return e[r.id]||(e[r.id]=r),r.id}function N(e){return{schemaStore:{},exampleStore:{},securitySchemeStore:{},hashIndex:{},document:e}}function c(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function _(e){return c(e)?e:{}}function b(e,r,t){if(c(r)){if(typeof r.$ref=="string"){const n=r.$ref,i=l(n);return i&&t?.has(i)?{type:"object",title:i}:R(e,n)}return r}}function a(e){return c(e)&&typeof e.$ref=="string"}function D(e,r,t){const n=r?.content;if(!n)return;const i=a(n)?b(e,n,t):n;return S(i,r)}function S(e,r){if(!e)return e;const t=r["x-examples"];if(t){const i={...e};for(const o of Object.keys(t))i[o]={...i[o],examples:t[o]};return i}const n=r["x-example"];if(n){const i={...e};for(const o of Object.keys(n))i[o]={...i[o],example:n[o]};return i}return e}function R(e,r){if(!r.startsWith("#/"))return;const t=r.slice(2).split("/").map(i=>i.replace(/~1/g,"/").replace(/~0/g,"~"));let n=e;for(const i of t){if(!c(n))return;n=n[i]}return c(n)?n:void 0}export{N as createStoreContext,a as isOpenAPIRef,c as isRecord,y as pickRenderableDescription,A as rbacProp,m as readRbacScope,k as registerExample,O as registerSchema,$ as registerSecurityScheme,C as resetStoreCounters,D as resolveContent,R as resolveJsonPointer,b as resolveRef,E as splitRbacSection,s as stableStringify,_ as toRecord};
@@ -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,registerSchema as R,resolveContent as M,resolveRef as S,readRbacScope as q,rbacProp as A}from"../helpers.js";import{panelKind as P,schemaKind as j}from"../../types/common.js";import{isStatusCode as T}from"../../utils/status-code.js";import{encodeJsonPointerSegment as g}from"../../utils/refPointer.js";import{applyIgnoreNamedSchemasDeep as C}from"./utils/applyIgnoreNamedSchemasDeep.js";import{mergeInMockServer as U,pickOperationServers as L}from"./utils/merge-mock-server.js";import{mergeSecurityIntoScheme as B}from"./configure/merge-utils.js";import{hasOpenApiExampleValue as _,resolveOpenApiExampleValue as E}from"./resolve-openapi-example-value.js";function $(r,n,t){const a=S(n,r,t)??r;return C(a,t)}function ee(r,n,t,a,l,d){const u=n?.document??{},o=F(r,u,t),s=K(r,u,n,a),e=N(r,n),c=D(r,u,n,a),y=G(r),m=r.responses,p=m?Object.keys(m).filter(T):void 0,f=r.security;return{kind:P.CODE_SAMPLE,operationType:l?"webhook":"http",method:r.httpVerb?.toUpperCase()??"GET",path:r.pathName??"/",servers:o,parameters:s,security:e,requestBody:c,responseCodes:p,requestValues:y,pointer:r.pathName,...d&&{href:d},...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,l=L(r.servers,a),u=U(l.filter(o=>typeof o?.url=="string"),t.mockServer).map(o=>({url:o.url??"",name:o.name,description:typeof o.description=="string"?o.description:void 0,...o.isMockServer&&{isMockServer:!0},variables:o.variables&&Object.keys(o.variables).length>0?Object.fromEntries(Object.entries(o.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 d=(r.parameters??[]).map(s=>$(s,n,a)),u={path:[],query:[],querystring:[],header:[],cookie:[]},o=r.requestValues?.serverRequestValues;for(const s of d){const e=s.in;if(!e||!u[e])continue;const c=s.content,y=c?Object.keys(c)[0]:void 0,m=y&&c?c[y]?.schema:s.schema,p=m&&typeof m=="object"?S(n,m,a)??m:m;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 i of Object.values(s.examples)){if(!i||typeof i!="object")continue;const x=S(n,i,a)??i;if(_(x)){v=E(x);break}}const b={};if(o&&s.name)for(const[i,x]of Object.entries(o)){const k=x?.[e==="querystring"?"queryString":e==="header"?"headers":e==="cookie"?"cookies":e]?.[s.name];k!=null&&(b[i]={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,l=r.security,d=[];if(!l||!n)return d;for(const u of l){const o=Object.keys(u),s=o.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=B(c,t)),a)for(const[y,m]of Object.entries(a))m?.security&&(c=B(c,m.security,y));return c});if(s.length>0){const e=o.flatMap(c=>u[c]??[]);d.push({schemes:s,scopes:e})}}return d}function D(r,n,t,a){const l=r.requestBody,d=l?S(n,l,a)??l:void 0,u=M(n,d,a);if(!u||!t)return;const o={};for(const[s,e]of Object.entries(u)){let c;const y=e.itemSchema,m=e.schema??y;if(m){const V=S(n,m,a)??m;c=R(t.schemaStore,t.hashIndex,{kind:j.JSON_SCHEMA,data:V})}const p=r.pointer?`${r.pointer}/requestBody/content/${g(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 i=S(n,b,a);if(i){const x=q(b)??q(i)??V,h=O(t.exampleStore,{value:E(i),key:v,summary:typeof i.summary=="string"?i.summary:v,description:typeof i.description=="string"?i.description:void 0,externalValue:typeof i.externalValue=="string"?i.externalValue:void 0,...A(x),...p&&{id:`${p}/examples/${g(v)}`}});f.push(h)}}}o[s]={schemaId:c,...f.length>0&&{exampleIds:f}}}return o}function G(r){const n=r.requestValues?.serverRequestValues,t=r.requestValues?.envVariables;let a,l;if(t&&typeof t=="object")if("values"in t){const s=t;a=s.values,l=s.serverValues}else a=t;const d=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&&(l=l??{},l[s]={...l[s],...e.envVariables});return a||l||r.requestValues?.security||d!==void 0||u?{...r.requestValues?.security&&{security:r.requestValues.security},...a&&{envVariables:a},...l&&{serverEnvVariables:l},...d!==void 0&&{body:d},...u&&{serverBody:u}}:void 0}export{ee 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{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 pe,itemVariant as le,nodeTypes as f,panelKind as Y,schemaKind as B}from"../../../../types/common.js";import{readRbacScope as E,rbacProp as A,registerExample as J,registerSchema as H,resolveContent as z,resolveRef as P}from"../../../helpers.js";import{applyIgnoreNamedSchemasDeep as ee}from"../../utils/applyIgnoreNamedSchemasDeep.js";import{isStatusCode as ue}from"../../../../utils/status-code.js";import{parseMarkdown as K}from"../../../utils/parseMarkdown.js";import{extractDescriptionSegments as me,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 ye}from"../../build-code-sample-source.js";import{mergeInMockServer as he,pickOperationServers as fe}from"../../utils/merge-mock-server.js";import{normalizePath as be,toRelativePath as te}from"../../../../utils/url.js";import{encodeJsonPointerSegment as N}from"../../../../utils/refPointer.js";import{hasOpenApiExampleValue as se,resolveOpenApiExampleValue as Z}from"../../resolve-openapi-example-value.js";const Q="request",ne="responses",re="callbacks";function xe(){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 we(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 m=s.ignoreNamedSchemas,h=e["x-codeSamples"]?.map(({lang:u,label:v,source:D})=>({lang:u,label:v,source:D})),b=fe(e.servers,o?.document?.servers),x=he(b.filter(u=>typeof u?.url=="string"),s.mockServer).map(u=>{const v=E(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(([D,L])=>[D,{default:L.default}])):void 0,...A(v)}}),y=ie(e,m),S=te(r,n);let d=[];e.description&&(W(e.description,S,Q),d=me(e.description,s));const g=d.some(u=>u.kind==="schemaDefinition"),T=y.find(u=>u.nodeType===f.ITEM&&u.variant==="body"),C=Ae(e,m,i,S||void 0),q=T?.schemaId,O=T?.mediaTypes,k=T?.mediaTypeSchemas,M=E(T),R=[{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:O,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 u of d)u.kind==="schemaDefinition"?c.push(u.node):c.push({nodeType:f.CONTAINER,children:[u.node],panels:[]});c.push({nodeType:f.CONTAINER,children:[...y],panels:R})}else c.push({nodeType:f.CONTAINER,children:[{nodeType:f.HEADER,level:4,label:"Request",labelTranslationKey:"request",deepLinkSuffix:Q},...d.map(u=>u.node),...y],panels:R});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:R});if(e.responses){const u=ce(e,s,S,m);if(u){const v=u.responses?.some(j=>j.schemaId||(j.exampleIds?.length??0)>0),D=u?.responses?.map(j=>{const de=j[U];return{code:j.code,schemaId:j.schemaId,exampleIds:j.exampleIds,mediaTypes:j.mediaTypes,mediaTypeContent:j.mediaTypeContent,...A(de)}}),L=[];v&&L.push({children:[{kind:Y.RESPONSE,headerTitle:"Response",responseCodes:D,examples:[]}]});const ae=E(e.responses);c.push({nodeType:f.CONTAINER,children:[{nodeType:f.HEADER,level:4,label:"Responses",labelTranslationKey:"responses",deepLinkSuffix:"responses"},u],panels:L.length>0?L:[],...A(ae)})}}Array.isArray(e.callbacks)&&e.callbacks.length>0&&c.push(...Se(e,S,m)),l?.hide!==!0&&c.push({nodeType:f.CONTAINER,children:[{nodeType:f.FEEDBACK,pageSlug:be(te(r,n))}],panels:[]});const _=y.some(u=>{const v=u;return v.variant==="body"&&((v.exampleIds?.length??0)>0||!!v.schemaId)})||(h?.length??0)>0;return{contentType:pe.ITEM,itemVariant:le.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 Se(e,r,s){const o=[{nodeType:f.CONTAINER,children:[{nodeType:f.HEADER,level:4,label:"Callbacks",labelTranslationKey:"callbacks",deepLinkSuffix:re}],panels:[]}],n=xe();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(Te(e,t,c,i,r,s))}return o}function Te(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=ie(i,t),a=ce(i,c,`${n}/callbacks/${o}`,t),m=[...p];a&&m.push(a);const h=s.externalDocs,b=G(s,c.showExtensions);let x;s.description&&(x=K(s.description,c),W(x??[],n,`${re}/${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:m.length>0?m:void 0},S=Ee(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 Ee(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 m={};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 O=P(c,q,o);if(O&&se(O)){const k=J(n.exampleStore,{value:Z(O),summary:O.summary??C,id:`${g}/examples/${N(C)}`});T.push(k),a=!0}}m[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(m).length>0?m:void 0,examples:[]}]}),t}function Ce(e,r,s){const o=P(r,e,s)??e,{$ref:n,...t}=e,c=typeof n=="string"?{...o,...t}:o;return ee(c,s)}function V(e,r,s){if(!e||typeof e!="object")return;const o=e,n=P(r,o,s)??o;return ee(n,s)}function ge(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,m=i.schema??a?.schema??a?.itemSchema,h=V(m,r,s);if(!h)continue;const b=oe(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"],m=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:oe(t.examples,n,r),...m?.length?{badges:m}:{},...Object.keys(h).length?{extensions:h}:{},...A(E(t))}})}function oe(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(!se(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 ie(e,r){const{storeCtx:s,options:o}=$.get(),n=[],t=s.document,c=Re(e);if(c&&n.push(c),e.parameters&&Array.isArray(e.parameters)){const i=e.parameters.map(d=>Ce(d,t,r)),p=i.filter(d=>d.in==="header"),a=i.filter(d=>d.in==="query"),m=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;m.length>0&&n.push({nodeType:f.ITEM,variant:"path",label:"Path",labelTranslationKey:"path",parameters:F(m,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 R=g[M];if(!R)continue;let I;const w=R.itemSchema,_=R.schema??w,u=V(_,t,r);u&&(I=H(s.schemaStore,s.hashIndex,{kind:B.JSON_SCHEMA,data:u}));const v=X(R,r);C[M]={schemaId:I,exampleIds:v,...A(E(_))}}const q=T[0],O=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:O?.schemaId,exampleIds:O?.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,m,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,O=V(q,t,r);O&&(T=H(s.schemaStore,s.hashIndex,{kind:B.JSON_SCHEMA,data:O}));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,m=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:m,pointer:e.pointer+"/requestBody",...b!==void 0?{description:b}:{},...A(x)})}return n}function ce(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 m=P(t,a,o)??a;let h=E(a)??E(m);const b=z(t,m,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 R of x){const I=b[R];if(!I)continue;let w;const _=I.itemSchema,u=I.schema??_,v=V(u,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(R)}`);C[R]={schemaId:w,exampleIds:D,...A(E(u))}}const M=y?C[y]:void 0;d=M?.schemaId,g=M?.exampleIds}else if(S){const M=S.itemSchema,R=S.schema??M,I=V(R,t,o);I&&(h=h??E(R),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=ge(m.headers,t,o);q&&(T=H(n.schemaStore,n.hashIndex,{kind:B.JSON_SCHEMA,data:q}));let O;m.description&&(O=K(m.description,r),W(O??[],s,`${ne}/${p}`));const k=m["x-summary"]?K(m["x-summary"],r):void 0;return k&&W(k,s,`${ne}/${p}/summary`),{code:p,summary:k,description:O,mediaType:y,mediaTypes:x.length>0?x:void 0,mediaTypeContent:C,schemaId:d,exampleIds:g,headers:m.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,m=E(p)??E(a)??l,h=J(o.exampleStore,{value:Z(a),key:i,summary:typeof a.summary=="string"?a.summary:i,description:typeof a.description=="string"?a.description:void 0,externalValue:typeof a.externalValue=="string"?a.externalValue:void 0,...A(m),...c&&{id:`${c}/examples/${N(i)}`}});n.push(h)}}return n.length>0?n:void 0}function Re(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],m=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(m)}}).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 Ae(e,r,s,o){const{storeCtx:n,options:t}=$.get();if(!n)throw new Error("OpenAPI store context is not initialized");return ye(e,n,t,r,s,o)}export{we as buildItemContent,xe 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 O,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,...O(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),R=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:R,exampleIds:S?.exampleIds,mediaTypes:k,mediaTypeSchemas:j,examples:S?.exampleIds?.map(()=>({}))??[]}],...O(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,...O(le)}}),V=[];I&&V.push({children:[{kind:z.RESPONSE,headerTitle:"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:[],...O(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,...O(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 R=$(c,q,o);if(R&&re(R)){const k=W(n.exampleStore,{value:ee(R),summary:R.summary??S,description:te(R.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 Re(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 Oe(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},...O(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}:{},...O(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=>Re(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,...O(C(w))}}const q=g[0],R=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:R?.schemaId,exampleIds:R?.exampleIds,pointer:e.pointer+"/parameters",...k!==void 0?{description:k}:{},...O(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,R=F(q,t,r);R&&(g=H(s.schemaStore,s.hashIndex,{kind:B.JSON_SCHEMA,data:R}));const k=Y(E,r,`${e.pointer}/requestBody/content/${N(d)}`);y[d]={schemaId:g,exampleIds:k,...O(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}:{},...O(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,...O(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=Oe(m.headers,t,o);q&&(g=H(n.schemaStore,n.hashIndex,{kind:B.JSON_SCHEMA,data:q}));let R;m.description&&(R=_(m.description,r),Q(R??[],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:R,mediaType:f,mediaTypes:b.length>0?b:void 0,mediaTypeContent:S,schemaId:d,exampleIds:E,headers:m.headers,headerSchemaId:g,...O(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,...O(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,...O(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};
@@ -1 +1 @@
1
- import{schemaKind as w}from"../../types/common.js";import{registerSchema as v,registerExample as E,registerSecurityScheme as V,resolveRef as S,isRecord as y,readRbacScope as l,rbacProp as b,splitRbacSection as g}from"../helpers.js";import{applyIgnoreNamedSchemasDeep as k}from"./utils/applyIgnoreNamedSchemasDeep.js";import{parseMarkdown as A}from"../utils/parseMarkdown.js";import{resolveOpenApiExampleValue as C}from"./resolve-openapi-example-value.js";const I=["x-defaultClientId","x-defaultAccessToken","x-defaultTokenType","x-defaultClientSecret","x-defaultUsername","x-defaultPassword"];function M(d){const c={},r=d;for(const n of I)r[n]&&(c[n]=r[n]);return r["x-serverValues"]&&(c.serverValues=r["x-serverValues"]),c}function j(d,c,r){const{schemaStore:n,exampleStore:f,securitySchemeStore:u,hashIndex:R}=c,{ignoreNamedSchemas:p}=r,x=c.document,a=d.components,h=d["x-root"];if(y(h)){const s=k(h,p),o=y(s)?s:h;v(n,R,{id:"x-root",kind:w.JSON_SCHEMA,title:typeof o.title=="string"?o.title:"Root",data:o})}if(!a)return{schemaStore:n,exampleStore:f,securitySchemeStore:u};if(a.schemas){const{sectionRbac:s,entries:o}=g(a.schemas);for(const[i,t]of o){const e=S(x,t,p)??t,m=k(e,p);y(m)&&v(n,R,{id:`components/schemas/${i}`,kind:w.JSON_SCHEMA,title:typeof m.title=="string"?m.title:i,data:m,...b(s)})}}if(a.examples){const{sectionRbac:s,entries:o}=g(a.examples);for(const[i,t]of o){const e=S(x,t,p)??t;!e||typeof e!="object"||E(f,{id:`components/examples/${i}`,value:C(e),summary:typeof e.summary=="string"?e.summary:void 0,description:typeof e.description=="string"?e.description:void 0,externalValue:e.externalValue,...b(l(t)??l(e)??s)})}}if(a.securitySchemes){const{sectionRbac:s,entries:o}=g(a.securitySchemes);for(const[i,t]of o){if(!t||typeof t!="object")continue;const e=S(x,t,p)??t;if(!e)continue;const m={id:i,type:e.type,scheme:e.scheme,bearerFormat:e.bearerFormat,description:e.description?A(e.description,r):void 0,in:e.in,paramName:e.name,openIdConnectUrl:e.openIdConnectUrl,oauth2MetadataUrl:e.oauth2MetadataUrl,deprecated:e.deprecated,flows:e.flows,...M(e),...b(l(t)??l(e)??s)};V(u,m)}}return{schemaStore:n,exampleStore:f,securitySchemeStore:u}}export{j as populateOpenApiStore};
1
+ import{schemaKind as w}from"../../types/common.js";import{encodeJsonPointerSegment as O}from"../../utils/refPointer.js";import{getImplicitDiscriminatorChildren as k}from"../../services/schema/dialects/jsonSchema.js";import{registerSchema as A,registerExample as C,pickRenderableDescription as I,registerSecurityScheme as E,resolveRef as g,isRecord as y,readRbacScope as S,rbacProp as b,splitRbacSection as R}from"../helpers.js";import{applyIgnoreNamedSchemasDeep as v}from"./utils/applyIgnoreNamedSchemasDeep.js";import{parseMarkdown as M}from"../utils/parseMarkdown.js";import{resolveOpenApiExampleValue as N}from"./resolve-openapi-example-value.js";const V=["x-defaultClientId","x-defaultAccessToken","x-defaultTokenType","x-defaultClientSecret","x-defaultUsername","x-defaultPassword"];function U(c){const o={},r=c;for(const n of V)r[n]&&(o[n]=r[n]);return r["x-serverValues"]&&(o.serverValues=r["x-serverValues"]),o}function j(c){const o=c.components?.schemas;if(!o||typeof o!="object")return;const r=k(c);for(const[n,l]of Object.entries(o)){if(!y(l))continue;const a=l,{discriminator:f}=a;if(!f?.propertyName||f.mapping||f["x-explicitMappingOnly"]||Array.isArray(a.oneOf)||Array.isArray(a.anyOf))continue;const m=r[`#/components/schemas/${O(n)}`];if(!m?.length)continue;const d={};for(const{ref:s,value:x}of m)d[x]=s;o[n]={...a,discriminator:{...f,mapping:d}}}}function K(c,o,r){const{schemaStore:n,exampleStore:l,securitySchemeStore:a,hashIndex:f}=o,{ignoreNamedSchemas:m}=r,d=o.document;j(c);const s=c.components,x=c["x-root"];if(y(x)){const p=v(x,m),i=y(p)?p:x;A(n,f,{id:"x-root",kind:w.JSON_SCHEMA,title:typeof i.title=="string"?i.title:"Root",data:i})}if(!s)return{schemaStore:n,exampleStore:l,securitySchemeStore:a};if(s.schemas){const{sectionRbac:p,entries:i}=R(s.schemas);for(const[u,t]of i){const e=g(d,t,m)??t,h=v(e,m);y(h)&&A(n,f,{id:`components/schemas/${u}`,kind:w.JSON_SCHEMA,title:typeof h.title=="string"?h.title:u,data:h,...b(p)})}}if(s.examples){const{sectionRbac:p,entries:i}=R(s.examples);for(const[u,t]of i){const e=g(d,t,m)??t;!e||typeof e!="object"||C(l,{id:`components/examples/${u}`,value:N(e),summary:typeof e.summary=="string"?e.summary:void 0,description:I(e.description),externalValue:e.externalValue,...b(S(t)??S(e)??p)})}}if(s.securitySchemes){const{sectionRbac:p,entries:i}=R(s.securitySchemes);for(const[u,t]of i){if(!t||typeof t!="object")continue;const e=g(d,t,m)??t;if(!e)continue;const h={id:u,type:e.type,scheme:e.scheme,bearerFormat:e.bearerFormat,description:e.description?M(e.description,r):void 0,in:e.in,paramName:e.name,openIdConnectUrl:e.openIdConnectUrl,oauth2MetadataUrl:e.oauth2MetadataUrl,deprecated:e.deprecated,flows:e.flows,...U(e),...b(S(t)??S(e)??p)};E(a,h)}}return{schemaStore:n,exampleStore:l,securitySchemeStore:a}}export{K as populateOpenApiStore};
@@ -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,4 +1,4 @@
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{PageActions as Z}from"@redocly/theme/components/PageActions/PageActions";import{breakpoints as ee}from"@redocly/theme/core/openapi";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`
2
2
  container-type: inline-size;
3
3
  container-name: api-docs-heading;
4
4
  position: relative;
@@ -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);
@@ -97,7 +97,7 @@ import{styled as r}from"styled-components";import{Link as i}from"react-router";i
97
97
  font-family: var(--font-family-monospaced);
98
98
  font-size: var(--font-size-sm);
99
99
  line-height: var(--line-height-sm);
100
- border-radius: var(--border-radius);
100
+ border-radius: var(--tag-border-radius);
101
101
  color: var(--text-color-secondary);
102
102
  display: inline-flex;
103
103
  word-break: var(--code-word-break);
@@ -173,7 +173,7 @@ import{styled as r}from"styled-components";import{Link as i}from"react-router";i
173
173
  flex-basis: 100%;
174
174
  min-width: 0;
175
175
  border: 1px solid var(--border-color-secondary);
176
- border-radius: var(--border-radius);
176
+ border-radius: var(--border-radius-xl);
177
177
  overflow: hidden;
178
178
  `,F=r.div`
179
179
  display: flex;
@@ -270,7 +270,7 @@ import{styled as r}from"styled-components";import{Link as i}from"react-router";i
270
270
  width: 100%;
271
271
  `,Y=r.span`
272
272
  padding: 0 var(--spacing-xs);
273
- border-radius: var(--border-radius);
273
+ border-radius: var(--tag-border-radius);
274
274
  border: 1px solid var(--border-color-secondary);
275
275
  background-color: var(--bg-color);
276
276
  font-size: var(--font-size-sm);
@@ -305,7 +305,7 @@ import{styled as r}from"styled-components";import{Link as i}from"react-router";i
305
305
  color: var(--tag-basic-content-color);
306
306
  padding: 0 var(--spacing-xs);
307
307
  border: 1px solid var(--border-color-secondary);
308
- border-radius: var(--border-radius);
308
+ border-radius: var(--tag-border-radius);
309
309
  margin: var(--spacing-xxs) 0 var(--spacing-xs);
310
310
  position: relative;
311
311
  width: fit-content;
@@ -1 +1 @@
1
- import{jsx as r,jsxs as i}from"react/jsx-runtime";import{useAtomValue as I}from"jotai";import{ArrayWrapper as A,ArrayLabel as g,ArrayClosingLabel as b,ArrayLabelValue as l,ArrayLine as c,SchemaTypeLabel as O,PropertyList as x}from"../styled.js";import{globalOptionsAtom as C}from"../../../jotai/store.js";import{isWithinExpansionLevel as F}from"../../../utils/expansion.js";import{PropertyRenderer as R}from"./PropertyRenderer.js";import{ObjectRenderer as B}from"./ObjectRenderer.js";import{PropertyFieldRow as j}from"./PropertyFieldRow.js";function D(s){return!s||s.length===0?s:[...s.slice(0,-1),s[s.length-1]+"[]"]}function _({property:s,level:o,fieldParentsName:d,skipReadOnly:p,skipWriteOnly:m,onOneOfChange:h}){const{schemasExpansionLevel:w}=I(C),n=s.items;if(!n||n.length===0)return r(O,{children:"array"});const L=F(o,w,1),y=D(d),f=o===1,u=n.some(e=>e.isTupleItem||e.isAdditionalItems),t=n[0];if(!u&&n.length===1&&t&&t.switcher){const e=r(R,{property:t,level:o+1,fieldParentsName:y,skipReadOnly:p,skipWriteOnly:m,onOneOfChange:h});return f?i(A,{children:[i(g,{children:[r(l,{children:"Array ["}),r(c,{})]}),e,i(b,{className:"array-closing-label",children:[r(c,{}),r(l,{children:"]"})]})]}):e}if(!u&&n.length===1&&t&&t.properties){const e=r(B,{property:t,level:o,fieldParentsName:y,skipReadOnly:p,skipWriteOnly:m,onOneOfChange:h});return f?i(A,{children:[i(g,{children:[r(l,{children:"Array ["}),r(c,{})]}),e,i(b,{className:"array-closing-label",children:[r(c,{}),r(l,{children:"]"})]})]}):e}return u||n.length>1?r(x,{children:n.map((e,a)=>r(j,{name:e.isAdditionalItems?`[${a}...]`:`[${a}]`,property:e,level:o,expandByDefault:L,isFirst:a===0,fieldParentsName:d,skipReadOnly:p,skipWriteOnly:m,onOneOfChange:h},a))}):t&&!t.switcher&&!t.properties&&!f?r(x,{children:r(j,{name:"[i]",property:t,level:o,expandByDefault:L,isFirst:!0,fieldParentsName:d,skipReadOnly:p,skipWriteOnly:m,onOneOfChange:h})}):i(A,{children:[i(g,{children:[r(l,{children:"Array ["}),r(c,{})]}),n.map((e,a)=>r(R,{property:e,level:o+1,fieldParentsName:y,skipReadOnly:p,skipWriteOnly:m,onOneOfChange:h},a)),i(b,{className:"array-closing-label",children:[r(c,{}),r(l,{children:"]"})]})]})}export{_ as ArrayRenderer};
1
+ import{jsx as r,jsxs as n}from"react/jsx-runtime";import{useAtomValue as I}from"jotai";import{ArrayWrapper as u,ArrayLabel as A,ArrayClosingLabel as b,ArrayLabelValue as o,ArrayLine as l,SchemaTypeLabel as N,PropertyList as L}from"../styled.js";import{globalOptionsAtom as O}from"../../../jotai/store.js";import{appendArraySuffix as P}from"../../../utils/deep-link.js";import{isWithinExpansionLevel as C}from"../../../utils/expansion.js";import{PropertyRenderer as x}from"./PropertyRenderer.js";import{ObjectRenderer as F}from"./ObjectRenderer.js";import{PropertyFieldRow as R}from"./PropertyFieldRow.js";function $({property:j,level:s,fieldParentsName:d,skipReadOnly:p,skipWriteOnly:c,onOneOfChange:m}){const{schemasExpansionLevel:w}=I(O),i=j.items;if(!i||i.length===0)return r(N,{children:"array"});const g=C(s,w,1),h=d&&P(d),y=s===1,f=i.some(e=>e.isTupleItem||e.isAdditionalItems),t=i[0];if(!f&&i.length===1&&t&&t.switcher){const e=r(x,{property:t,level:s+1,fieldParentsName:h,skipReadOnly:p,skipWriteOnly:c,onOneOfChange:m});return y?n(u,{children:[n(A,{children:[r(o,{children:"Array ["}),r(l,{})]}),e,n(b,{className:"array-closing-label",children:[r(l,{}),r(o,{children:"]"})]})]}):e}if(!f&&i.length===1&&t&&t.properties){const e=r(F,{property:t,level:s,fieldParentsName:h,skipReadOnly:p,skipWriteOnly:c,onOneOfChange:m});return y?n(u,{children:[n(A,{children:[r(o,{children:"Array ["}),r(l,{})]}),e,n(b,{className:"array-closing-label",children:[r(l,{}),r(o,{children:"]"})]})]}):e}return f||i.length>1?r(L,{children:i.map((e,a)=>r(R,{name:e.isAdditionalItems?`[${a}...]`:`[${a}]`,property:e,level:s,expandByDefault:g,isFirst:a===0,fieldParentsName:d,skipReadOnly:p,skipWriteOnly:c,onOneOfChange:m},a))}):t&&!t.switcher&&!t.properties&&!y?r(L,{children:r(R,{name:"[i]",property:t,level:s,expandByDefault:g,isFirst:!0,fieldParentsName:d,skipReadOnly:p,skipWriteOnly:c,onOneOfChange:m})}):n(u,{children:[n(A,{children:[r(o,{children:"Array ["}),r(l,{})]}),i.map((e,a)=>r(x,{property:e,level:s+1,fieldParentsName:h,skipReadOnly:p,skipWriteOnly:c,onOneOfChange:m},a)),n(b,{className:"array-closing-label",children:[r(l,{}),r(o,{children:"]"})]})]})}export{$ as ArrayRenderer};
@@ -0,0 +1,15 @@
1
+ import type { ReactElement } from 'react';
2
+ import type { ApiItem, ApiStore } from '../../types/store.js';
3
+ export type SearchProps = {
4
+ items: ApiItem[];
5
+ store: ApiStore;
6
+ basePath: string;
7
+ /** Bundled definition — enables `$ref` resolution for schema-field results. */
8
+ document?: Record<string, unknown>;
9
+ };
10
+ /**
11
+ * Search ships only in the open-source Redoc (`index.ce.ts` and the `.ce`
12
+ * files it re-exports replace this stub there); enterprise search is provided
13
+ * by the portal.
14
+ */
15
+ export declare function Search(_props: SearchProps): ReactElement | null;
@@ -0,0 +1 @@
1
+ function n(r){return null}export{n as Search};