@redocly/api-docs 0.1.0 → 0.2.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{jsx as e,jsxs as m}from"react/jsx-runtime";import{memo as f,useMemo as n}from"react";import{useAtomValue as h}from"jotai";import{storeAtom as g}from"../../jotai/store.js";import{useSpecTranslate as x}from"../../hooks/useTranslate.js";import{SchemaView as S}from"../Schema/SchemaView.js";import{ContentWrapper as s}from"../common/ContentWrapper.js";import{DeepLinkAnchor as D}from"../common/DeepLinkAnchor.js";import{renderDescription as M}from"../graphql/renderDescription.js";import{getDeepLinkId as A}from"../../utils/deep-link.js";import{DeepLinkSectionContext as k,useDeepLinkUrl as L}from"../../hooks/useDeepLinkSection.js";import{McpSection as P,McpSubRow as c,McpTitle as b,McpTitleWrapper as j}from"./styled.js";import{buildMcpExamplePanel as C,buildPromptArgumentsSchema as T}from"./utils.js";function v({name:p}){const i=h(g),a=x(),r=n(()=>i.mcp?.prompts?.find(d=>d.name===p),[i.mcp,p]),t=n(()=>r?.arguments?.length?T(r.arguments):null,[r]),l=n(()=>t?[C(t,"Arguments example")]:void 0,[t]),o=L("arguments"),u=n(()=>({t:"arguments"}),[]);return r?m(P,{children:[r.description&&e(s,{children:e(c,{children:M(r.description)})}),t&&e(s,{panels:l,children:m(c,{children:[e(j,{id:A(o),children:m(b,{children:[o&&e(D,{to:o,label:"link to Arguments"}),a("openapi.mcp.inputSchema","Arguments")]})}),e(k.Provider,{value:u,children:e(S,{schema:t,expandByDefault:!0})})]})})]}):null}const G=f(v);export{G as McpPrompt};
1
+ import{jsx as e,jsxs as m}from"react/jsx-runtime";import{memo as h,useMemo as n}from"react";import{useAtomValue as g}from"jotai";import{storeAtom as M}from"../../jotai/store.js";import{useSpecTranslate as x}from"../../hooks/useTranslate.js";import{SchemaView as A}from"../Schema/SchemaView.js";import{ContentWrapper as c}from"../common/ContentWrapper.js";import{DeepLinkAnchor as S}from"../common/DeepLinkAnchor.js";import{Markdown as D}from"../common/Markdown.js";import{getDeepLinkId as k}from"../../utils/deep-link.js";import{DeepLinkSectionContext as L,useDeepLinkUrl as P}from"../../hooks/useDeepLinkSection.js";import{McpSection as b,McpSubRow as a,McpTitle as j,McpTitleWrapper as w}from"./styled.js";import{buildMcpExamplePanel as C,buildPromptArgumentsSchema as T,useMcpDescriptionAst as v}from"./utils.js";function V({name:p}){const i=g(M),l=x(),r=n(()=>i.mcp?.prompts?.find(f=>f.name===p),[i.mcp,p]),s=v(r?.description),t=n(()=>r?.arguments?.length?T(r.arguments):null,[r]),u=n(()=>t?[C(t,"Arguments example")]:void 0,[t]),o=P("arguments"),d=n(()=>({t:"arguments"}),[]);return r?m(b,{children:[s?e(c,{children:e(a,{children:e(D,{source:s})})}):null,t&&e(c,{panels:u,children:m(a,{children:[e(w,{id:k(o),children:m(j,{children:[o&&e(S,{to:o,label:"link to Arguments"}),l("openapi.mcp.inputSchema","Arguments")]})}),e(L.Provider,{value:d,children:e(A,{schema:t,expandByDefault:!0})})]})})]}):null}const J=h(V);export{J as McpPrompt};
@@ -1,3 +1,3 @@
1
- import{jsx as r,jsxs as n}from"react/jsx-runtime";import{memo as f,useMemo as m}from"react";import{useAtomValue as a}from"jotai";import{styled as h}from"styled-components";import{Tag as M}from"@redocly/theme/components/Tag/Tag";import{storeAtom as R}from"../../jotai/store.js";import{useSpecTranslate as T}from"../../hooks/useTranslate.js";import{ContentWrapper as p}from"../common/ContentWrapper.js";import{renderDescription as x}from"../graphql/renderDescription.js";import{McpSection as y,McpSubRow as s,McpRowLine as u}from"./styled.js";import{buildResourceContentPanel as j}from"./utils.js";const l=h(M)`
1
+ import{jsx as r,jsxs as n}from"react/jsx-runtime";import{memo as f,useMemo as p}from"react";import{useAtomValue as M}from"jotai";import{styled as h}from"styled-components";import{Tag as R}from"@redocly/theme/components/Tag/Tag";import{storeAtom as T}from"../../jotai/store.js";import{useSpecTranslate as x}from"../../hooks/useTranslate.js";import{ContentWrapper as m}from"../common/ContentWrapper.js";import{Markdown as y}from"../common/Markdown.js";import{McpSection as j,McpSubRow as u,McpRowLine as l}from"./styled.js";import{buildResourceContentPanel as A,useMcpDescriptionAst as S}from"./utils.js";const d=h(R)`
2
2
  text-transform: none;
3
- `;function S({name:t}){const i=a(R),c=T(),e=m(()=>i.mcp?.resources?.find(o=>o.name===t),[i.mcp,t]),d=m(()=>{if(!e)return;const o=j(e);return o?[o]:void 0},[e]);return e?n(y,{children:[e.description&&r(p,{children:r(s,{children:x(e.description)})}),r(p,{panels:d,children:n(s,{children:[n(u,{children:[c("openapi.mcp.uriTitle","Resource URI"),":"," ",r(l,{children:e.uri})]}),n(u,{children:[c("openapi.mcp.mimeTypeTitle","Resource MIME type"),":"," ",r(l,{children:e.mimeType})]})]})})]}):null}const U=f(S);export{U as McpResource};
3
+ `;function w({name:t}){const i=M(T),c=x(),e=p(()=>i.mcp?.resources?.find(o=>o.name===t),[i.mcp,t]),s=S(e?.description),a=p(()=>{if(!e)return;const o=A(e);return o?[o]:void 0},[e]);return e?n(j,{children:[s?r(m,{children:r(u,{children:r(y,{source:s})})}):null,r(m,{panels:a,children:n(u,{children:[n(l,{children:[c("openapi.mcp.uriTitle","Resource URI"),":"," ",r(d,{children:e.uri})]}),n(l,{children:[c("openapi.mcp.mimeTypeTitle","Resource MIME type"),":"," ",r(d,{children:e.mimeType})]})]})})]}):null}const V=f(w);export{V as McpResource};
@@ -1 +1 @@
1
- import{jsx as t,jsxs as o}from"react/jsx-runtime";import{memo as b,useMemo as n}from"react";import{useAtomValue as j}from"jotai";import{storeAtom as v}from"../../jotai/store.js";import{useSpecTranslate as I}from"../../hooks/useTranslate.js";import{SchemaView as l}from"../Schema/SchemaView.js";import{ContentWrapper as r}from"../common/ContentWrapper.js";import{DeepLinkAnchor as s}from"../common/DeepLinkAnchor.js";import{renderDescription as A}from"../graphql/renderDescription.js";import{getDeepLinkId as h}from"../../utils/deep-link.js";import{DeepLinkSectionContext as d,useDeepLinkUrl as f}from"../../hooks/useDeepLinkSection.js";import{McpSection as C,McpSubRow as m,McpTitle as S,McpTitleWrapper as x}from"./styled.js";import{buildMcpExamplePanel as D}from"./utils.js";function O({name:u}){const a=j(v),p=I(),e=n(()=>a.mcp?.tools?.find(P=>P.name===u),[a.mcp,u]),k=n(()=>e?.inputSchema?[D(e.inputSchema,"Input example")]:void 0,[e?.inputSchema]),M=n(()=>e?.outputSchema?[D(e.outputSchema,"Output example")]:void 0,[e?.outputSchema]),i=f("input-schema"),L=n(()=>({t:"input-schema"}),[]),c=f("output-schema"),T=n(()=>({t:"output-schema"}),[]);return e?o(C,{children:[t(r,{children:o(m,{children:[o("p",{children:[p("openapi.mcp.toolName","Tool name"),": ",t("code",{children:e.name})]}),e.description&&A(e.description)]})}),e.inputSchema&&t(r,{panels:k,children:o(m,{children:[t(x,{id:h(i),children:o(S,{children:[i&&t(s,{to:i,label:"link to Input schema"}),p("openapi.mcp.inputSchema","Input schema")]})}),t(d.Provider,{value:L,children:t(l,{schema:e.inputSchema,expandByDefault:!0})})]})}),e.outputSchema&&t(r,{panels:M,children:o(m,{children:[t(x,{id:h(c),children:o(S,{children:[c&&t(s,{to:c,label:"link to Output schema"}),p("openapi.mcp.outputSchema","Output schema")]})}),t(d.Provider,{value:T,children:t(l,{schema:e.outputSchema,expandByDefault:!0})})]})})]}):null}const F=b(O);export{F as McpTool};
1
+ import{jsx as t,jsxs as o}from"react/jsx-runtime";import{memo as b,useMemo as n}from"react";import{useAtomValue as j}from"jotai";import{storeAtom as v}from"../../jotai/store.js";import{useSpecTranslate as I}from"../../hooks/useTranslate.js";import{SchemaView as s}from"../Schema/SchemaView.js";import{ContentWrapper as r}from"../common/ContentWrapper.js";import{DeepLinkAnchor as h}from"../common/DeepLinkAnchor.js";import{Markdown as w}from"../common/Markdown.js";import{getDeepLinkId as d}from"../../utils/deep-link.js";import{DeepLinkSectionContext as f,useDeepLinkUrl as S}from"../../hooks/useDeepLinkSection.js";import{McpSection as C,McpSubRow as m,McpTitle as x,McpTitleWrapper as D}from"./styled.js";import{buildMcpExamplePanel as M,useMcpDescriptionAst as O}from"./utils.js";function y({name:u}){const a=j(v),p=I(),e=n(()=>a.mcp?.tools?.find(P=>P.name===u),[a.mcp,u]),l=O(e?.description),k=n(()=>e?.inputSchema?[M(e.inputSchema,"Input example")]:void 0,[e?.inputSchema]),L=n(()=>e?.outputSchema?[M(e.outputSchema,"Output example")]:void 0,[e?.outputSchema]),c=S("input-schema"),T=n(()=>({t:"input-schema"}),[]),i=S("output-schema"),A=n(()=>({t:"output-schema"}),[]);return e?o(C,{children:[t(r,{children:o(m,{children:[o("p",{children:[p("openapi.mcp.toolName","Tool name"),": ",t("code",{children:e.name})]}),l?t(w,{source:l}):null]})}),e.inputSchema&&t(r,{panels:k,children:o(m,{children:[t(D,{id:d(c),children:o(x,{children:[c&&t(h,{to:c,label:"link to Input schema"}),p("openapi.mcp.inputSchema","Input schema")]})}),t(f.Provider,{value:T,children:t(s,{schema:e.inputSchema,expandByDefault:!0})})]})}),e.outputSchema&&t(r,{panels:L,children:o(m,{children:[t(D,{id:d(i),children:o(x,{children:[i&&t(h,{to:i,label:"link to Output schema"}),p("openapi.mcp.outputSchema","Output schema")]})}),t(f.Provider,{value:A,children:t(s,{schema:e.outputSchema,expandByDefault:!0})})]})})]}):null}const H=b(y);export{H as McpTool};
@@ -1,5 +1,6 @@
1
1
  import type { McpExampleNode } from '../../types/content.js';
2
2
  import type { McpPromptArgument, McpResource, OpenAPISchema } from '../../types/openapi.js';
3
+ export declare function useMcpDescriptionAst(description: unknown): unknown;
3
4
  export declare function sampleSchema(schema: OpenAPISchema): unknown;
4
5
  export declare function buildMcpExamplePanel(schema: OpenAPISchema, headerTitle: string): McpExampleNode;
5
6
  export declare function buildResourceContentPanel(resource: McpResource): McpExampleNode | null;
@@ -1 +1 @@
1
- import*as r from"openapi-sampler";import{panelKind as n}from"../../types/common.js";function i(t){try{return r.sample(t,{quiet:!0})}catch{return{}}}function o(t,e){return{children:[{kind:n.MCP_EXAMPLE,headerTitle:e,data:i(t)}]}}function u(t){const e=t.text??t.blob;return e===void 0?null:{children:[{kind:n.MCP_EXAMPLE,headerTitle:"Resource content",data:e,language:t.mimeType}]}}function l(t){return t.length?{type:"object",properties:Object.fromEntries(t.map(e=>[e.name,{type:"string",example:e.example??"string",description:typeof e.description=="string"?e.description:void 0}])),required:t.filter(e=>e.required).map(e=>e.name)}:null}export{o as buildMcpExamplePanel,l as buildPromptArgumentsSchema,u as buildResourceContentPanel,i as sampleSchema};
1
+ import{useMemo as i}from"react";import*as p from"openapi-sampler";import{panelKind as o}from"../../types/common.js";import{resolveMarkdocHeadingIds as u}from"../../adapters/utils/markdoc.js";import{useMarkdownAdapter as m}from"../../contexts/markdownAdapter.js";import{useHashItemId as a}from"../../hooks/useDeepLinkSection.js";function M(t){const e=m(),n=a();return i(()=>{if(!t)return null;const r=e.parse(t);return n&&r&&typeof r=="object"&&u(r,n),r},[e,t,n])}function d(t){try{return p.sample(t,{quiet:!0})}catch{return{}}}function b(t,e){return{children:[{kind:o.MCP_EXAMPLE,headerTitle:e,data:d(t)}]}}function h(t){const e=t.text??t.blob;return e===void 0?null:{children:[{kind:o.MCP_EXAMPLE,headerTitle:"Resource content",data:e,language:t.mimeType}]}}function P(t){return t.length?{type:"object",properties:Object.fromEntries(t.map(e=>[e.name,{type:"string",example:e.example??"string",description:typeof e.description=="string"?e.description:void 0}])),required:t.filter(e=>e.required).map(e=>e.name)}:null}export{b as buildMcpExamplePanel,P as buildPromptArgumentsSchema,h as buildResourceContentPanel,d as sampleSchema,M as useMcpDescriptionAst};
@@ -1 +1 @@
1
- import{Fragment as se,jsx as o,jsxs as j}from"react/jsx-runtime";import{useAtom as _,useAtomValue as n}from"jotai";import{lazy as ie,memo as le,Suspense as pe,useCallback as d,useEffect as me,useMemo as f,useRef as ce,useState as B}from"react";import{Button as ue}from"@redocly/theme/components/Button/Button";import{useFocusTrap as de,useModalScrollLock as fe}from"@redocly/theme/core/openapi";import{RocketIcon as ye}from"@redocly/theme/icons/RocketIcon/RocketIcon";import{Spinner as N}from"@redocly/theme/icons/Spinner/Spinner";import{Portal as he}from"@redocly/theme/components/Portal/Portal";import{useConfigureReplay as Re}from"@redocly/theme/ext/use-configure-replay";import{ReplayGate as ve}from"@redocly/theme/components/ReplayGate/ReplayGate";import{ReplayTopBarActions as ge}from"@redocly/theme/components/ReplayTopBarActions/ReplayTopBarActions";import{createReplayOverlayConverter as Oe,handleReplayParamChange as Ie,pickRuntimeConfigureRequestValues as Ae,REPLAY_TRY_IT_LOADING_STATE as l,ReplayCodeSampleHTTPSnippet as Ce,useCodeSampleResolvers as Te}from"../../services/code-samples/index.js";import{useMarkdownAdapter as Se}from"../../contexts/markdownAdapter.js";import{adapterToMarkdownParser as Le}from"./adapterToMarkdownParser.js";import{resolveRequestValues as be}from"../../adapters/openapi/configure/resolve-request-values.js";import{createTryItOpenEvent as Ee,createTryItSentEvent as Pe}from"../../events/index.js";import{useSpecTranslate as xe}from"../../hooks/useTranslate.js";import{useTelemetry as ke}from"../../hooks/useTelemetry.js";import{useOpenApiDefinition as we}from"../../hoc/withReplayPrefetch.js";import{allowedEnvironmentsAtom as De,environmentAtom as Me,environmentsAtom as Ve,requestValuesAtom as $e,userClaimsAtom as qe}from"../../jotai/app.js";import{globalOptionsAtom as je,routingBasePathAtom as _e}from"../../jotai/store.js";import{routeIndexAtom as Be}from"../../jotai/routes.js";import{exampleStoreAtom as Ne}from"../../jotai/examples.js";import{joinWithSeparator as Ue}from"../../utils/url.js";import{encodeBackSlashes as Ge}from"../../utils/string.js";import{getDefaultCollectorUrl as Fe}from"../../utils/telemetry.js";const ze=ie(()=>import("@redocly/replay").then(p=>({default:p.ReplayOverlay})));function He({message:p}){return j("div",{style:{alignItems:"center",display:"flex",flexDirection:"column",gap:"1rem",justifyContent:"center",padding:"2rem"},children:[o(N,{color:"var(--primary-color, #333)"}),o("span",{children:p})]})}function We({node:p,onTryItLoadingStateChange:L,hideOtherSecuritySchemes:U}){const g=xe(),b=ce(null),a=n(je),{oAuth2RedirectURI:G,events:m}=a,E=Se(),O=f(()=>({...a,markdownParser:Le(E)}),[a,E]),F=ke(),c=n(_e),P=n(Be),I=n(qe),x=n(Ne),z=n(Ve),H=n(De),[[,W],k]=_(Me),[,w]=_($e),A=we(),[y,D]=B(!1),[u,C]=B(l.NOT_LOADED),M=Te();me(()=>{L?.(u)},[u,L]);const Y=d(()=>{C(l.LOADED)},[]),e=p.source,K=e.path,J=e.method,Q=`${e.method.toLowerCase()}:${e.path}`,h=e.openApiOperationId??Q,s=f(()=>({id:`${e.method}:${e.path}`,path:e.path,httpVerb:e.method,name:e.summary||`${e.method.toUpperCase()} ${e.path}`}),[e]),X=f(()=>e.servers.map(t=>({url:t.url,description:t.description,name:t.name,variables:t.variables?Object.fromEntries(Object.entries(t.variables).map(([i,r])=>[i,{default:r.default??"",enum:r.enum,description:r.description}])):void 0})),[e.servers]),{config:R,refresh:V}=Re({userClaims:I,info:A?.info??{},operation:{name:s.name,path:K,operationId:h,href:"",method:J},servers:X},y),Z=f(()=>{const t=new Map([[`${e.method.toLowerCase()}:${e.path}`,e]]);return Oe(t,M,O,R,x,(r,v)=>{const T=v.servers??[],S=r.servers??T;return be({operationInfo:r,info:v.info??{},servers:S,basePath:c,userClaims:I,dynamicRequestValues:O.dynamicRequestValues})})},[e,M,O,R,x,c,I]),ee=f(()=>Ae(a,R),[a,R]);de(b),fe(y);const te=d(()=>{V()},[V]),oe=d(t=>{m?.tryItSent&&s&&m.tryItSent(Pe({operation:s,isSuccess:t}))},[m,s]),re=d(t=>{Ie(t,k,(i,r,v)=>{const T=`${r.toLowerCase()}:${i}`;w(S=>({...S,[T]:v}))})},[k,w]),$=()=>{if(y){D(!1),C(l.NOT_LOADED);return}m?.tryItOpen&&s&&m.tryItOpen(Ee({operation:s})),F.sendTryItOpenedMessage([{id:"tryItButton",object:"button",uri:"urn:redocly:redoc:ui:button:tryItButton"}]),C(l.LOADING),D(!0)},ne=d(t=>{if(!t)return;if(t===h&&e.href)return Ue(c,e.href);const i=`/${Ge(t).toLowerCase()}`;return P?.allRoutes.find(r=>r.path.toLowerCase().endsWith(i))?.path},[c,e.href,h,P]),ae=A?.info,q=u===l.LOADING;return j(se,{children:[o(ue,{onClick:$,variant:"primary",iconPosition:"left",icon:q?o(N,{}):o(ye,{}),children:q?g("loading","Loading..."):g("tryIt","Try it")}),y&&o(he,{mountId:"api-content",children:o("div",{"aria-busy":u===l.LOADING,"data-try-it-loading-state":u,children:o(pe,{fallback:o(He,{message:g("loading","Loading...")}),children:o("div",{ref:b,children:o(ze,{ReplayGate:ve,ReplayTopBarActions:ge,activeOperationId:h,api:A,onLoad:Y,onRequestChange:re,onClose:$,settings:{corsProxyUrl:a.corsProxyUrl,selectedEnvironment:W,apiId:ae?.["x-metadata"]?.apiId,oAuth2RedirectURI:G,disableCollectionsTab:!0,storageKey:c,HTTPSnippet:Ce,convertOperationToReplayValue:Z,getOperationUrl:ne,onRequestReset:te,predefinedEnvValues:z,telemetry:{tracerName:"try-it",collectorUrl:Fe()},dynamicReplayValues:ee,onRequestSent:oe,hideOtherSecuritySchemes:U,allowedEnvironments:H??void 0}})})})})})]})}const Ot=le(We);export{Ot as Replay};
1
+ import{Fragment as pe,jsx as o,jsxs as _}from"react/jsx-runtime";import{useAtom as j,useAtomValue as a,useSetAtom as me}from"jotai";import{lazy as ce,memo as de,Suspense as ue,useCallback as p,useMemo as y,useRef as fe,useState as B}from"react";import{Button as ye}from"@redocly/theme/components/Button/Button";import{useFocusTrap as he,useModalScrollLock as Re}from"@redocly/theme/core/openapi";import{RocketIcon as ve}from"@redocly/theme/icons/RocketIcon/RocketIcon";import{Spinner as N}from"@redocly/theme/icons/Spinner/Spinner";import{Portal as ge}from"@redocly/theme/components/Portal/Portal";import{useConfigureReplay as Oe}from"@redocly/theme/ext/use-configure-replay";import{ReplayGate as Ae}from"@redocly/theme/components/ReplayGate/ReplayGate";import{ReplayTopBarActions as Ie}from"@redocly/theme/components/ReplayTopBarActions/ReplayTopBarActions";import{createReplayOverlayConverter as Te,handleReplayParamChange as Ce,pickRuntimeConfigureRequestValues as Se,REPLAY_TRY_IT_LOADING_STATE as s,ReplayCodeSampleHTTPSnippet as Le,useCodeSampleResolvers as De}from"../../services/code-samples/index.js";import{useMarkdownAdapter as be}from"../../contexts/markdownAdapter.js";import{adapterToMarkdownParser as we}from"./adapterToMarkdownParser.js";import{resolveRequestValues as Ee}from"../../adapters/openapi/configure/resolve-request-values.js";import{createTryItOpenEvent as Pe,createTryItSentEvent as ke}from"../../events/index.js";import{useSpecTranslate as xe}from"../../hooks/useTranslate.js";import{useTelemetry as Ve}from"../../hooks/useTelemetry.js";import{useOpenApiDefinition as Me}from"../../hoc/withReplayPrefetch.js";import{allowedEnvironmentsAtom as $e,environmentAtom as qe,environmentsAtom as Ue,requestValuesAtom as _e,userClaimsAtom as je}from"../../jotai/app.js";import{globalOptionsAtom as Be,routingBasePathAtom as Ne,setReplayDefinitionAtom as Ge}from"../../jotai/store.js";import{fetchOpenApiDefinitionCached as Fe,pickReplayDefinitionDownloadUrl as ze}from"../../utils/fetch-openapi-definition.js";import{routeIndexAtom as He}from"../../jotai/routes.js";import{exampleStoreAtom as We}from"../../jotai/examples.js";import{joinWithSeparator as Ye}from"../../utils/url.js";import{encodeBackSlashes as Ke}from"../../utils/string.js";import{getDefaultCollectorUrl as Je}from"../../utils/telemetry.js";const Qe=ce(()=>import("@redocly/replay").then(m=>({default:m.ReplayOverlay})));function Xe({message:m}){return _("div",{style:{alignItems:"center",display:"flex",flexDirection:"column",gap:"1rem",justifyContent:"center",padding:"2rem"},children:[o(N,{color:"var(--primary-color, #333)"}),o("span",{children:m})]})}function Ze({node:m,onTryItLoadingStateChange:D,hideOtherSecuritySchemes:G}){const g=xe(),b=fe(null),n=a(Be),{oAuth2RedirectURI:F,events:c}=n,w=be(),O=y(()=>({...n,markdownParser:we(w)}),[n,w]),z=Ve(),d=a(Ne),E=a(He),A=a(je),P=a(We),H=a(Ue),W=a($e),[[,Y],k]=j(qe),[,x]=j(_e),u=Me(),K=me(Ge),[V,I]=B(!1),T=V&&!!u,[C,J]=B(s.NOT_LOADED),M=De(),f=p(t=>{J(t),D?.(t)},[D]),Q=p(()=>{f(s.LOADED)},[f]),e=m.source,X=e.path,Z=e.method,ee=`${e.method.toLowerCase()}:${e.path}`,h=e.openApiOperationId??ee,i=y(()=>({id:`${e.method}:${e.path}`,path:e.path,httpVerb:e.method,name:e.summary||`${e.method.toUpperCase()} ${e.path}`}),[e]),te=y(()=>e.servers.map(t=>({url:t.url,description:t.description,name:t.name,variables:t.variables?Object.fromEntries(Object.entries(t.variables).map(([l,r])=>[l,{default:r.default??"",enum:r.enum,description:r.description}])):void 0})),[e.servers]),{config:R,refresh:$}=Oe({userClaims:A,info:u?.info??{},operation:{name:i.name,path:X,operationId:h,href:"",method:Z},servers:te},T),oe=y(()=>{const t=new Map([[`${e.method.toLowerCase()}:${e.path}`,e]]);return Te(t,M,O,R,P,(r,v)=>{const S=v.servers??[],L=r.servers??S;return Ee({operationInfo:r,info:v.info??{},servers:L,basePath:d,userClaims:A,dynamicRequestValues:O.dynamicRequestValues})})},[e,M,O,R,P,d,A]),re=y(()=>Se(n,R),[n,R]);he(b),Re(T);const ne=p(()=>{$()},[$]),ae=p(t=>{c?.tryItSent&&i&&c.tryItSent(ke({operation:i,isSuccess:t}))},[c,i]),se=p(t=>{Ce(t,k,(l,r,v)=>{const S=`${r.toLowerCase()}:${l}`;x(L=>({...L,[S]:v}))})},[k,x]),q=()=>{if(V){I(!1),f(s.NOT_LOADED);return}if(c?.tryItOpen&&i&&c.tryItOpen(Pe({operation:i})),z.sendTryItOpenedMessage([{id:"tryItButton",object:"button",uri:"urn:redocly:redoc:ui:button:tryItButton"}]),!u){const t=ze(n.downloadUrls);t&&Fe(t).then(K).catch(()=>{I(!1),f(s.NOT_LOADED)})}f(s.LOADING),I(!0)},ie=p(t=>{if(!t)return;if(t===h&&e.href)return Ye(d,e.href);const l=`/${Ke(t).toLowerCase()}`;return E?.allRoutes.find(r=>r.path.toLowerCase().endsWith(l))?.path},[d,e.href,h,E]),le=u?.info,U=C===s.LOADING;return _(pe,{children:[o(ye,{onClick:q,variant:"primary",iconPosition:"left",icon:U?o(N,{}):o(ve,{}),children:U?g("loading","Loading..."):g("tryIt","Try it")}),T&&o(ge,{mountId:"api-content",children:o("div",{"aria-busy":C===s.LOADING,"data-try-it-loading-state":C,children:o(ue,{fallback:o(Xe,{message:g("loading","Loading...")}),children:o("div",{ref:b,children:o(Qe,{ReplayGate:Ae,ReplayTopBarActions:Ie,activeOperationId:h,api:u,onLoad:Q,onRequestChange:se,onClose:q,settings:{corsProxyUrl:n.corsProxyUrl,selectedEnvironment:Y,apiId:le?.["x-metadata"]?.apiId,oAuth2RedirectURI:F,disableCollectionsTab:!0,storageKey:d,HTTPSnippet:Le,convertOperationToReplayValue:oe,getOperationUrl:ie,onRequestReset:ne,predefinedEnvValues:H,telemetry:{tracerName:"try-it",collectorUrl:Je()},dynamicReplayValues:re,onRequestSent:ae,hideOtherSecuritySchemes:G,allowedEnvironments:W??void 0}})})})})})]})}const Dt=de(Ze);export{Dt as Replay};
@@ -1 +1 @@
1
- import{Fragment as Pe,jsx as l,jsxs as te}from"react/jsx-runtime";import{useState as Ue,useMemo as p,useCallback as re,useEffect as $e}from"react";import{useAtom as ae}from"jotai";import{useAtomValue as O}from"jotai";import{buildCodeSampleHAR as Be,tryGenerateCodeSample as Me,mapReplayAtomValuesToHarRequestValues as we,useCodeSampleResolvers as De}from"../../../services/code-samples/index.js";import{findExampleIdByKey as Ne}from"../../../services/code-samples/example-key.js";import{exampleStoreAtom as je}from"../../../jotai/examples.js";import{DEFAULT_LANGUAGES as oe,getGeneratorKey as Ge,getLangKey as P,getSyntaxHighlightLang as Fe}from"../../../utils/languages.js";import{useSpecTranslate as We}from"../../../hooks/useTranslate.js";import{CodeBlockPanel as Ke,StyledCodeBlock as _e}from"../styled.js";import{useResolvedExamples as He}from"../../ItemContent/hooks.js";import{languageAtom as ze,environmentAtom as Je,selectedSecuritySchemeIdxAtom as Ye,requestValuesAtom as Qe}from"../../../jotai/app.js";import{useActiveVariantSchemaId as Xe,useSchemaVariantSelection as Ze,useMediaTypeContent as et}from"./hooks.js";import{isSequentialMediaType as tt}from"../../../utils/media-type.js";import{isRecord as se}from"../../../adapters/helpers.js";import{updateObjectProperties as rt}from"../../../adapters/openapi/configure/merge-utils.js";import{useCopyCodeTelemetry as at}from"../../../hooks/useCopyCodeTelemetry.js";import{VariantPicker as ot,ExampleSelector as st,MediaTypeSelector as nt,PanelDropdownSelect as lt,PayloadDisplay as it}from"./selectors.js";import{LanguageDropdown as ct}from"../LanguageItem/LanguageDropdown.js";import{StyledPanelHeader as pt,TryItPanelFooter as mt}from"./styled.js";import{MediaTypeRow as ut}from"./styled.js";import{ServerDropdown as dt}from"./ServerDropdown.js";import{replaceServerVariables as yt,serverMatchesUrl as ft}from"../../../services/code-samples/server-variables.js";import{globalOptionsAtom as ht}from"../../../jotai/store.js";import{createLanguageSwitchEvent as gt}from"../../../events/languageSwitch.js";import{createCodeSampleCopyEvent as St}from"../../../events/codeSampleCopy.js";import{Replay as vt}from"../../Replay/index.js";import{useOpenApiDefinition as bt}from"../../../hoc/withReplayPrefetch.js";const G=oe.find(r=>r.key==="payload")??oe[0],ne=[{key:G.key,lang:G.lang,title:G.label}];function Xt({node:r}){const[{activeLanguage:g,languages:i},S]=ae(ze),s=O(ht),v=We(),le=bt(),U=r.isWebhook?"payload":g||"curl",F=De(),e=r.source,k=r.definitionSamples,ie=O(Qe),q=O(je),ce=`${e.method.toLowerCase()}:${e.path}`,C=ie[ce],W=C?.activeExampleName,A=typeof W=="string"?W:void 0,{mediaTypes:K,activeMediaType:m,effectiveSchemaId:L,effectiveExampleIds:h,onMediaTypeChange:pe}=et(r),me=r.isWebhook?"response":"request",ue=Ze(L),de=Xe(L),ye=tt(m)?L:de,_=He(ye,h,me,m),[$,H]=Ue(0);$e(()=>{const t=A?q[A]?.key??A:void 0,a=Ne(h,t,n=>q[n]),o=a?h?.indexOf(a)??-1:-1;H(o>=0?o:0)},[h,m,A,q]);const V=_[$]??_[0],z=(h?.length??0)>0||!!L,T=p(()=>{if(!k?.length)return k;const t=new Set((i??[]).map(a=>a.key));return k.filter(a=>t.has(P(a)))},[k,i]),y=p(()=>{const t=(i??[]).map(({key:o,lang:n,title:E})=>({key:o,lang:n,title:E}));let a=z?t:t.filter(o=>o.key!=="payload");if(r.isWebhook){const o=new Set(T?.map(n=>P(n))??[]);a=a.filter(n=>n.key==="payload"||o.has(n.key))}return a},[z,i,r.isWebhook,T]),u=p(()=>(y.some(t=>t.key===U)?U:y[0]?.key)??"curl",[y,U]),I=O(Je),{activeServerUrl:J,activeServerSpecUrl:f}=p(()=>{const t=I[0].server,a=t?r.servers?.find(n=>ft(n,t)):void 0;if(t&&a)return{activeServerUrl:t,activeServerSpecUrl:a.url};const o=r.servers?.[0];return o?{activeServerUrl:yt(o),activeServerSpecUrl:o.url}:{activeServerUrl:e.servers[0]?.url,activeServerSpecUrl:e.servers[0]?.url}},[I,r.servers,e.servers]),[B,fe]=ae(Ye),c=e.securityGroups,he=!!(c&&c.length>1),Y=p(()=>{if(!c?.length)return;const t=c.length>1?c[B]??c[0]:c[0];return Object.keys(t)},[c,B]),Q=p(()=>{const t=we(C??{});return e.requestValues?.security?{...t,security:e.requestValues.security}:t},[C,e.requestValues?.security]),x=C?.body,M=h?.[$],R=M?q[M]?.key??M:void 0,b=p(()=>{const t=e.requestValues?.serverBody;return(f&&t?.[f])??e.requestValues?.body},[f,e.requestValues?.body,e.requestValues?.serverBody]),ge=p(()=>x!==void 0?kt(x):b!==void 0?V===void 0?b:se(V)&&se(b)?rt(V,b):b:V,[x,V,b]),Se=p(()=>{if(u==="payload")return"";const t=T?.find(d=>P(d)===u);if(t){let d=t.source;const j=e.requestValues?.envVariables,Te=e.requestValues?.serverEnvVariables,Ie={...j,...f&&Te?.[f]};for(const[Re,Oe]of Object.entries(Ie))d=d.replaceAll(`{{${Re}}}`,Oe);return d}const a=Be(e,{serverUrl:J,mediaType:m,environment:I[0]??{},requestValues:Q,activeSecuritySchemeIds:Y,replayBody:x,exampleName:R},{skipOptionalParameters:s.codeSamples?.skipOptionalParameters,withOAuth2Call:s.codeSamples?.withOAuth2Call,generatedPayloadSamplesMaxDepth:s.generatedSamplesMaxDepth},F),o=s.codeSamples?.languages?.find(d=>d.key===u),n=Me(o?Ge(o):u,a,o?.options);if(n.kind==="unsupported-language")return`// ${v("unsupportedLanguage","Language is not supported.")}`;if(n.kind==="error")return console.error(n.error),`// ${v("failedToGenerateCodeSample","Failed to generate code sample.")}`;let E=n.source;const Ce=e.requestValues?.envVariables,Ae=e.requestValues?.serverEnvVariables,Le={...Ce,...f&&Ae?.[f]};for(const[d,j]of Object.entries(Le))E=E.replaceAll(`{{${d}}}`,j);return E},[u,T,e,J,f,m,I,s,F,Q,Y,x,R,v]),w=y.find(t=>t.key===u)??y[0],X=k?.find(t=>P(t)===u),D=X?.lang??w?.lang,ve=D&&Fe(D),Z=at("request"),be=re(t=>()=>{Z(t)(),s.events?.codeSamplesCopy?.(St({operation:{id:`${e.method}:${e.path}`,path:e.path,httpVerb:e.method,name:`${e.method.toUpperCase()} ${e.path}`},type:"request",lang:t??"",label:w?.title??"",activeMimeName:m??"",activeExampleName:R}))},[Z,s.events,e.method,e.path,w,m,R]),ke=re(t=>{S(t);const a=(r.isWebhook?ne:y).find(o=>o.key===t);s.events?.codeSamplesLanguageSwitch&&a&&s.events.codeSamplesLanguageSwitch(gt({operation:{id:`${e.method}:${e.path}`,path:e.path,httpVerb:e.method,name:`${e.method.toUpperCase()} ${e.path}`},sample:{lang:a.lang,label:a.title}}))},[S,y,r.isWebhook,s.events,e.method,e.path]),Ve=e.method,xe=e.path,ee=!(s.hideReplay||r.hideReplay)&&!r.isWebhook&&!!le,N=u==="payload",Ee=!N&&!!X,qe=p(()=>ee?l(mt,{children:l(vt,{node:r})}):void 0,[ee,r]);return l(Pe,{children:te(Ke,{className:"panel-request-samples",footer:qe,header:()=>te(pt,{isExpandable:!1,children:[l(dt,{servers:r.servers??[],method:Ve,path:xe}),l(ct,{activeTab:u,samples:r.isWebhook?ne:y,onChange:ke})]}),isExpandable:!1,children:[he&&c&&l(Vt,{requirements:c,activeIdx:B,onSelect:fe}),K.length>1&&l(nt,{mediaTypes:K,value:m,onChange:pe,label:N?v("contentType","Payload media type"):v("contentType","Request media type")}),!Ee&&l(ot,{selection:ue}),l(st,{exampleIds:h,selectedIdx:$,onSelect:H}),N?l(it,{payload:ge,emptyMessage:`// ${v("noRequestPayload","No request payload")}`,mediaType:m,snippetType:"request"}):l(_e,{lang:ve,source:Se,header:{className:"code-block-header",controls:{copy:{onClick:be(D)}}}})]})})}function kt(r){if(typeof r!="string")return r;const g=r.trim();if(!g)return r;try{const i=JSON.parse(g);if(i!==null&&typeof i=="object")return i}catch{}return r}function Vt({requirements:r,activeIdx:g,onSelect:i}){return l(ut,{children:l(lt,{value:String(g),onChange:S=>i(Number(S)),"aria-label":"Security scheme",options:r.map((S,s)=>({key:String(s),value:String(s),label:Object.keys(S).join(" + ")||`Scheme ${s+1}`}))})})}export{Xt as CodeSampleItem};
1
+ import{Fragment as Oe,jsx as l,jsxs as te}from"react/jsx-runtime";import{useState as Pe,useMemo as p,useCallback as re,useEffect as we}from"react";import{useAtom as ae}from"jotai";import{useAtomValue as U}from"jotai";import{buildCodeSampleHAR as De,tryGenerateCodeSample as $e,mapReplayAtomValuesToHarRequestValues as Be,useCodeSampleResolvers as Me}from"../../../services/code-samples/index.js";import{findExampleIdByKey as Ne}from"../../../services/code-samples/example-key.js";import{exampleStoreAtom as je}from"../../../jotai/examples.js";import{DEFAULT_LANGUAGES as oe,getGeneratorKey as Ge,getLangKey as O,getSyntaxHighlightLang as Fe}from"../../../utils/languages.js";import{useSpecTranslate as We}from"../../../hooks/useTranslate.js";import{CodeBlockPanel as Ke,StyledCodeBlock as _e}from"../styled.js";import{useResolvedExamples as He}from"../../ItemContent/hooks.js";import{languageAtom as ze,environmentAtom as Je,selectedSecuritySchemeIdxAtom as Ye,requestValuesAtom as Qe}from"../../../jotai/app.js";import{useActiveVariantSchemaId as Xe,useSchemaVariantSelection as Ze,useMediaTypeContent as et}from"./hooks.js";import{isSequentialMediaType as tt}from"../../../utils/media-type.js";import{isRecord as se}from"../../../adapters/helpers.js";import{updateObjectProperties as rt}from"../../../adapters/openapi/configure/merge-utils.js";import{useCopyCodeTelemetry as at}from"../../../hooks/useCopyCodeTelemetry.js";import{VariantPicker as ot,ExampleSelector as st,MediaTypeSelector as nt,PanelDropdownSelect as lt,PayloadDisplay as it}from"./selectors.js";import{LanguageDropdown as ct}from"../LanguageItem/LanguageDropdown.js";import{StyledPanelHeader as pt,TryItPanelFooter as mt}from"./styled.js";import{MediaTypeRow as ut}from"./styled.js";import{ServerDropdown as dt}from"./ServerDropdown.js";import{replaceServerVariables as yt,serverMatchesUrl as ft}from"../../../services/code-samples/server-variables.js";import{globalOptionsAtom as ht}from"../../../jotai/store.js";import{createLanguageSwitchEvent as gt}from"../../../events/languageSwitch.js";import{createCodeSampleCopyEvent as St}from"../../../events/codeSampleCopy.js";import{Replay as vt}from"../../Replay/index.js";import{useOpenApiDefinition as bt}from"../../../hoc/withReplayPrefetch.js";import{pickReplayDefinitionDownloadUrl as kt}from"../../../utils/fetch-openapi-definition.js";const G=oe.find(r=>r.key==="payload")??oe[0],ne=[{key:G.key,lang:G.lang,title:G.label}];function er({node:r}){const[{activeLanguage:g,languages:i},S]=ae(ze),s=U(ht),v=We(),le=bt(),P=r.isWebhook?"payload":g||"curl",F=Me(),e=r.source,k=r.definitionSamples,ie=U(Qe),q=U(je),ce=`${e.method.toLowerCase()}:${e.path}`,C=ie[ce],W=C?.activeExampleName,A=typeof W=="string"?W:void 0,{mediaTypes:K,activeMediaType:m,effectiveSchemaId:L,effectiveExampleIds:h,onMediaTypeChange:pe}=et(r),me=r.isWebhook?"response":"request",ue=Ze(L),de=Xe(L),ye=tt(m)?L:de,_=He(ye,h,me,m),[w,H]=Pe(0);we(()=>{const t=A?q[A]?.key??A:void 0,a=Ne(h,t,n=>q[n]),o=a?h?.indexOf(a)??-1:-1;H(o>=0?o:0)},[h,m,A,q]);const V=_[w]??_[0],z=(h?.length??0)>0||!!L,T=p(()=>{if(!k?.length)return k;const t=new Set((i??[]).map(a=>a.key));return k.filter(a=>t.has(O(a)))},[k,i]),y=p(()=>{const t=(i??[]).map(({key:o,lang:n,title:E})=>({key:o,lang:n,title:E}));let a=z?t:t.filter(o=>o.key!=="payload");if(r.isWebhook){const o=new Set(T?.map(n=>O(n))??[]);a=a.filter(n=>n.key==="payload"||o.has(n.key))}return a},[z,i,r.isWebhook,T]),u=p(()=>(y.some(t=>t.key===P)?P:y[0]?.key)??"curl",[y,P]),I=U(Je),{activeServerUrl:J,activeServerSpecUrl:f}=p(()=>{const t=I[0].server,a=t?r.servers?.find(n=>ft(n,t)):void 0;if(t&&a)return{activeServerUrl:t,activeServerSpecUrl:a.url};const o=r.servers?.[0];return o?{activeServerUrl:yt(o),activeServerSpecUrl:o.url}:{activeServerUrl:e.servers[0]?.url,activeServerSpecUrl:e.servers[0]?.url}},[I,r.servers,e.servers]),[D,fe]=ae(Ye),c=e.securityGroups,he=!!(c&&c.length>1),Y=p(()=>{if(!c?.length)return;const t=c.length>1?c[D]??c[0]:c[0];return Object.keys(t)},[c,D]),Q=p(()=>{const t=Be(C??{});return e.requestValues?.security?{...t,security:e.requestValues.security}:t},[C,e.requestValues?.security]),x=C?.body,$=h?.[w],R=$?q[$]?.key??$:void 0,b=p(()=>{const t=e.requestValues?.serverBody;return(f&&t?.[f])??e.requestValues?.body},[f,e.requestValues?.body,e.requestValues?.serverBody]),ge=p(()=>x!==void 0?Vt(x):b!==void 0?V===void 0?b:se(V)&&se(b)?rt(V,b):b:V,[x,V,b]),Se=p(()=>{if(u==="payload")return"";const t=T?.find(d=>O(d)===u);if(t){let d=t.source;const j=e.requestValues?.envVariables,Te=e.requestValues?.serverEnvVariables,Ie={...j,...f&&Te?.[f]};for(const[Re,Ue]of Object.entries(Ie))d=d.replaceAll(`{{${Re}}}`,Ue);return d}const a=De(e,{serverUrl:J,mediaType:m,environment:I[0]??{},requestValues:Q,activeSecuritySchemeIds:Y,replayBody:x,exampleName:R},{skipOptionalParameters:s.codeSamples?.skipOptionalParameters,withOAuth2Call:s.codeSamples?.withOAuth2Call,generatedPayloadSamplesMaxDepth:s.generatedSamplesMaxDepth},F),o=s.codeSamples?.languages?.find(d=>d.key===u),n=$e(o?Ge(o):u,a,o?.options);if(n.kind==="unsupported-language")return`// ${v("unsupportedLanguage","Language is not supported.")}`;if(n.kind==="error")return console.error(n.error),`// ${v("failedToGenerateCodeSample","Failed to generate code sample.")}`;let E=n.source;const Ce=e.requestValues?.envVariables,Ae=e.requestValues?.serverEnvVariables,Le={...Ce,...f&&Ae?.[f]};for(const[d,j]of Object.entries(Le))E=E.replaceAll(`{{${d}}}`,j);return E},[u,T,e,J,f,m,I,s,F,Q,Y,x,R,v]),B=y.find(t=>t.key===u)??y[0],X=k?.find(t=>O(t)===u),M=X?.lang??B?.lang,ve=M&&Fe(M),Z=at("request"),be=re(t=>()=>{Z(t)(),s.events?.codeSamplesCopy?.(St({operation:{id:`${e.method}:${e.path}`,path:e.path,httpVerb:e.method,name:`${e.method.toUpperCase()} ${e.path}`},type:"request",lang:t??"",label:B?.title??"",activeMimeName:m??"",activeExampleName:R}))},[Z,s.events,e.method,e.path,B,m,R]),ke=re(t=>{S(t);const a=(r.isWebhook?ne:y).find(o=>o.key===t);s.events?.codeSamplesLanguageSwitch&&a&&s.events.codeSamplesLanguageSwitch(gt({operation:{id:`${e.method}:${e.path}`,path:e.path,httpVerb:e.method,name:`${e.method.toUpperCase()} ${e.path}`},sample:{lang:a.lang,label:a.title}}))},[S,y,r.isWebhook,s.events,e.method,e.path]),Ve=e.method,xe=e.path,ee=!(s.hideReplay||r.hideReplay)&&!r.isWebhook&&!!(le??kt(s.downloadUrls)),N=u==="payload",Ee=!N&&!!X,qe=p(()=>ee?l(mt,{children:l(vt,{node:r})}):void 0,[ee,r]);return l(Oe,{children:te(Ke,{className:"panel-request-samples",footer:qe,header:()=>te(pt,{isExpandable:!1,children:[l(dt,{servers:r.servers??[],method:Ve,path:xe}),l(ct,{activeTab:u,samples:r.isWebhook?ne:y,onChange:ke})]}),isExpandable:!1,children:[he&&c&&l(xt,{requirements:c,activeIdx:D,onSelect:fe}),K.length>1&&l(nt,{mediaTypes:K,value:m,onChange:pe,label:N?v("contentType","Payload media type"):v("contentType","Request media type")}),!Ee&&l(ot,{selection:ue}),l(st,{exampleIds:h,selectedIdx:w,onSelect:H}),N?l(it,{payload:ge,emptyMessage:`// ${v("noRequestPayload","No request payload")}`,mediaType:m,snippetType:"request"}):l(_e,{lang:ve,source:Se,header:{className:"code-block-header",controls:{copy:{onClick:be(M)}}}})]})})}function Vt(r){if(typeof r!="string")return r;const g=r.trim();if(!g)return r;try{const i=JSON.parse(g);if(i!==null&&typeof i=="object")return i}catch{}return r}function xt({requirements:r,activeIdx:g,onSelect:i}){return l(ut,{children:l(lt,{value:String(g),onChange:S=>i(Number(S)),"aria-label":"Security scheme",options:r.map((S,s)=>({key:String(s),value:String(s),label:Object.keys(S).join(" + ")||`Scheme ${s+1}`}))})})}export{er as CodeSampleItem};
@@ -1 +1 @@
1
- import{jsx as h,jsxs as C}from"react/jsx-runtime";import{useEffect as a,useId as x}from"react";import{useAtom as l,useAtomValue as S}from"jotai";import{environmentAtom as j,mediaTypeOverrideAtom as y,requestValuesAtom as A}from"../../jotai/app.js";import{exampleStoreAtom as k}from"../../jotai/examples.js";import{mediaTypeContainingKey as R}from"../../services/code-samples/example-key.js";import{CodeSampleItem as T}from"../panels/ExampleItem/CodeSampleItem.js";import{ContentWrapper as _}from"../common/ContentWrapper.js";import{ItemIdContext as b,SYNTHETIC_ITEM_ID_PREFIX as q}from"../../hooks/useDeepLinkSection.js";function $(e){return`${e.source.method.toLowerCase()}:${e.source.path}`}function M({node:e,mimeType:n,exampleKey:t,requestBody:u,parameters:o,environment:r,environments:s}){const[,c]=l(y),[,p]=l(A),[,E]=l(j),I=S(k);return a(()=>{if(n){c(n);return}const d=R(e.source.requestBody,t,m=>I[m]);d&&c(d)},[n,t,e,I,c]),a(()=>{(r!==void 0||s!==void 0)&&E({environment:r,environments:s})},[r,s,E]),a(()=>{const d=$(e),m=o&&Object.values(o).some(f=>f!=null&&typeof f=="object");!(u!==void 0)&&!m&&!(t!==void 0)||p(f=>{const i={...f[d]};return u!==void 0&&(i.body=u),o?.header&&(i.headers=o.header),o?.query&&(i.queryString=o.query),o?.path&&(i.path=o.path),o?.cookie&&(i.cookies=o.cookie),t!==void 0&&(i.activeExampleName=t),{...f,[d]:i}})},[e,u,o,t,p]),null}function W({node:e,...n}){const t=`${q}${x()}`;return h(b.Provider,{value:t,children:C(_,{children:[h(M,{node:e,...n}),h(T,{node:e})]})})}export{W as RedocCodeSample};
1
+ import{jsx as h,jsxs as C}from"react/jsx-runtime";import{useEffect as a,useId as x}from"react";import{useAtom as l,useAtomValue as y}from"jotai";import{environmentAtom as S,mediaTypeOverrideAtom as j,requestValuesAtom as A}from"../../jotai/app.js";import{exampleStoreAtom as R}from"../../jotai/examples.js";import{mediaTypeContainingKey as k}from"../../services/code-samples/example-key.js";import{CodeSampleItem as T}from"../panels/ExampleItem/CodeSampleItem.js";import{ContentWrapper as _}from"../common/ContentWrapper.js";import{ItemIdContext as b,SYNTHETIC_ITEM_ID_PREFIX as q}from"../../hooks/useDeepLinkSection.js";function $(e){return`${e.source.method.toLowerCase()}:${e.source.path}`}function M({node:e,mimeType:n,exampleKey:t,requestBody:f,parameters:o,environment:r,environments:s}){const[,c]=l(j),[,p]=l(A),[,E]=l(S),I=y(R);return a(()=>{if(n){c(n);return}const d=k(e.source.requestBody,t,m=>I[m]);d&&c(d)},[n,t,e,I,c]),a(()=>{(r!==void 0||s!==void 0)&&E({environment:r,environments:s})},[r,s,E]),a(()=>{const d=$(e),m=o&&Object.values(o).some(u=>u!=null&&typeof u=="object");!(f!==void 0)&&!m&&!(t!==void 0)||p(u=>{const i={...u[d]};return f!==void 0&&(i.body=f),o?.header&&(i.headers=o.header),o?.query&&(i.queryString=o.query),o?.path&&(i.path=o.path),o?.cookie&&(i.cookies=o.cookie),t!==void 0&&(i.activeExampleName=t),{...u,[d]:i}})},[e,f,o,t,p]),null}function W({node:e,...n}){const t=`${q}${x()}`;return h(b.Provider,{value:t,children:C(_,{children:[h(M,{node:e,...n}),h(T,{node:{...e,hideReplay:!0}})]})})}export{W as RedocCodeSample};
@@ -1 +1 @@
1
- import{useEffect as h,useLayoutEffect as m}from"react";import{useLocation as y,useNavigate as T}from"react-router";import{IS_BROWSER as g}from"@redocly/theme/core/openapi";import{SECTION_ATTR as w}from"../constants/openapi.js";import{hashToElementId as S,resolveLegacyHashToRoute as v,stripArrayMarkers as L,stripCallbacksSegment as b}from"../utils/deep-link.js";import{USER_SCROLL_INTENT_EVENTS as H,WHEEL_INTENT_THRESHOLD_PX as _,createScrollIntentTracker as A}from"./useUserScrollIntent.js";function M({activeRoute:t,routeIndex:n,basePath:e,isHydrated:r}){const i=y(),u=T(),l=t?.path;h(()=>{if(!g||!("scrollRestoration"in window.history))return;const c=window.history.scrollRestoration;return window.history.scrollRestoration="manual",()=>{window.history.scrollRestoration=c}},[]),m(()=>{if(!g)return;const{hash:c}=i,s=c?S(c):"";if(s&&!p(s)){const a=v(c,e,n);if(a&&a!==i.pathname){u(a,{replace:!0});return}}if(!(!s&&!l))return N(C(s,l))},[i,l,r,u,e,n])}function C(t,n){if(!t)return()=>R(n);let e=!1;return()=>{const r=p(t);return r?(e=!0,r):e?null:R(n)}}const k=_;function N(t){let n=t();if(n?.scrollIntoView({block:"start"}),typeof ResizeObserver>"u")return()=>{};const e=document.documentElement,r=new AbortController;let i=n?n.getBoundingClientRect().top:0,u=e.scrollHeight;function l(o){n=o,o.scrollIntoView({block:"start"}),i=o.getBoundingClientRect().top,u=e.scrollHeight}const c=new ResizeObserver(()=>{const o=t();o&&l(o)});c.observe(document.body);function s(){n&&(Math.abs(n.getBoundingClientRect().top-i)<=k||(e.scrollHeight===u?f():l(n)))}const a=A();function E(o){a(o)&&f()}function f(){c.disconnect(),r.abort()}const d={capture:!0,passive:!0,signal:r.signal};window.addEventListener("scroll",s,d);for(const o of H)window.addEventListener(o,E,d);return f}function p(t){if(!t)return null;const n=t.split("&")[0],e=n===t?[t]:[t,n];for(const r of e){const i=document.getElementById(r)??O(r);if(i)return i}return null}function O(t){return I(t)??B(t)}function I(t){if(t.includes("[]"))return null;for(const n of document.querySelectorAll('[id*="[]"]'))if(L(n.id)===t)return n;return null}function B(t){if(t.includes("/callbacks/"))return null;for(const n of document.querySelectorAll('[id*="/callbacks/"]'))if(b(n.id)===t)return n;return null}function R(t){if(!t)return null;const n=t.replace(/["\\]/g,"\\$&");return document.querySelector(`[${w}="${n}"]`)}export{M as useApiDocsScroll};
1
+ import{useEffect as E,useLayoutEffect as m}from"react";import{useLocation as y,useNavigate as T}from"react-router";import{IS_BROWSER as g}from"@redocly/theme/core/openapi";import{SECTION_ATTR as w}from"../constants/openapi.js";import{hashToElementId as S,resolveLegacyHashToRoute as v,stripArrayMarkers as L,stripCallbacksSegment as b}from"../utils/deep-link.js";import{USER_SCROLL_INTENT_EVENTS as H,WHEEL_INTENT_THRESHOLD_PX as _,createScrollIntentTracker as A}from"./useUserScrollIntent.js";function M({activeRoute:t,routeIndex:n,basePath:e,isHydrated:r}){const o=y(),u=T(),l=t?.path;E(()=>{if(!g||!("scrollRestoration"in window.history))return;const c=window.history.scrollRestoration;return window.history.scrollRestoration="manual",()=>{window.history.scrollRestoration=c}},[]),m(()=>{if(!g)return;const{hash:c}=o,s=c?S(c):"";if(s&&!p(s)){const a=v(c,e,n);if(a&&a!==o.pathname+o.hash){u(a,{replace:!0});return}}if(!(!s&&!l))return N(C(s,l))},[o,l,r,u,e,n])}function C(t,n){if(!t)return()=>h(n);let e=!1;return()=>{const r=p(t);return r?(e=!0,r):e?null:h(n)}}const k=_;function N(t){let n=t();if(n?.scrollIntoView({block:"start"}),typeof ResizeObserver>"u")return()=>{};const e=document.documentElement,r=new AbortController;let o=n?n.getBoundingClientRect().top:0,u=e.scrollHeight;function l(i){n=i,i.scrollIntoView({block:"start"}),o=i.getBoundingClientRect().top,u=e.scrollHeight}const c=new ResizeObserver(()=>{const i=t();i&&l(i)});c.observe(document.body);function s(){n&&(Math.abs(n.getBoundingClientRect().top-o)<=k||(e.scrollHeight===u?f():l(n)))}const a=A();function R(i){a(i)&&f()}function f(){c.disconnect(),r.abort()}const d={capture:!0,passive:!0,signal:r.signal};window.addEventListener("scroll",s,d);for(const i of H)window.addEventListener(i,R,d);return f}function p(t){if(!t)return null;const n=t.split("&")[0],e=n===t?[t]:[t,n];for(const r of e){const o=document.getElementById(r)??O(r);if(o)return o}return null}function O(t){return I(t)??B(t)}function I(t){if(t.includes("[]"))return null;for(const n of document.querySelectorAll('[id*="[]"]'))if(L(n.id)===t)return n;return null}function B(t){if(t.includes("/callbacks/"))return null;for(const n of document.querySelectorAll('[id*="/callbacks/"]'))if(b(n.id)===t)return n;return null}function h(t){if(!t)return null;const n=t.replace(/["\\]/g,"\\$&");return document.querySelector(`[${w}="${n}"]`)}export{M as useApiDocsScroll};
@@ -163,6 +163,8 @@ export declare function hashIsOutsideCallbacks(hashId: string, itemId: string):
163
163
  * Matches: #tag/..., #operation/..., #paths/...
164
164
  */
165
165
  export declare function getLegacyHash(hash: string): string;
166
- /** Map a legacy single-page hash (`#section/…`, `#tag/…`, `#operation/…`) to its route in the multi-page engine; `undefined` for a genuine in-page anchor (e.g. a field deep link). */
166
+ /** Map a legacy single-page hash (`#section/…`, `#tag/…`, `#operation/…`) to its route URL in
167
+ * the multi-page engine; `undefined` for a genuine in-page anchor (e.g. a field deep link).
168
+ * A sub-section tail past the route (`#operation/<id>/callbacks`) becomes the element-id hash. */
167
169
  export declare function resolveLegacyHashToRoute(hash: string, basePath: string, routeIndex: RouteIndex): string | undefined;
168
170
  export {};
@@ -1 +1 @@
1
- import{encodeBackSlashes as h,tryDecodeURIComponent as s}from"./string.js";import{joinWithSeparator as i,normalizePath as f}from"./url.js";import{resolveRouteByPathname as L}from"./routing.js";function p(t){const e=[];for(const[n,r]of Object.entries(t))r!==void 0&&e.push(`${n}=${r}`);return e.join("&")}function $(t,e){return t=h(t).replace(/^\/+/,""),(`/${t}#`+i(t,e)).toLowerCase()}function y(t,e,n){const r=$(e,n);return f(i(t,r))}function d(t){const e=t.startsWith("#")?t.slice(1):t;return s(e).toLowerCase()}function k(t){const e=s(t),n=e.indexOf("#");return n>=0?e.slice(n+1):""}function N(t){return p({t:t.t,in:t.in,c:t.c,cb:t.cb,ct:t.ct,path:t.path})}function _(t,e,n){let r=t;return n&&(r=`${r}&c=${n}`),e&&(r=i(r,e)),r}function K(t){const{section:e,messageKey:n,subsection:r}=t;if(!n)return e;let o=`${e}&m=${n}`;return r&&(o+=`&t=${r}`),o}function B(t){return p({t:t.t,path:t.path,arg:t.arg,rt:t.rt})}function D(t,e){return!t||!e?!1:s(t.startsWith("#")?t.slice(1):t).toLowerCase().includes(`path=${e.toLowerCase()}.`)}function P(t){return t&&k(t)||void 0}function F(t,e){const n=[...t??[]];return n.length>0?n[n.length-1]+=e:n.push(e),n}const S=/&(?:oneof|d)=\d+/g;function M(t){return t.replace(S,"")}function v(t){return t.replace(/\[\]/g,"")}function z(t){return(t??[]).filter(e=>e.includes("&")).map(e=>e.slice(e.indexOf("&")))}function H(t,e){return t?s(t.startsWith("#")?t.slice(1):t).toLowerCase().match(new RegExp(`(?:^|[&/])${e}=([^/&]+)`))?.[1]:void 0}const m="callbacks",u=`${m}/`,A="callback-request",b="callback-response",g=[`/${A}`,`/${b}`];function a(t){const e=t.indexOf("path=");return e===-1?t:t.slice(0,e)}function I(t){return t.replace(`/${u}`,"/")}function x(t,e){const n=`cb=${e}`;return t.endsWith(n)||t.includes(`${n}&`)}function E(t,e){const n=`/${e}`;return t.endsWith(n)||t.includes(`${n}/`)}function w(t,e){return t===e||t.startsWith(`${e}/`)}function j(t,e,n){if(!t||!e||!n)return!1;const r=d(t);if(!w(r,e))return!1;const o=a(r),c=n.toLowerCase();return x(o,c)||E(o,c)}function q(t,e,n){const r=a(t),o=n.toLowerCase();return r.startsWith(i(e,`${u}${o}/`))||r.startsWith(i(e,`${o}/`))||x(r,o)}function G(t,e){const n=a(t).slice(e.length);return!(n.startsWith(`/${u}`)||n.includes("cb=")||g.some(o=>n.includes(o)))}function O(t){const e=["#tag","#operation","#paths"];for(const n of e)if(t.includes(n))return t.replace(n,"").toLowerCase();return""}function U(t,e,n){const r=d(t);if(!r)return;const o=f(i(e,r));if(L(n,o))return o;const c=O(t);if(c){const l=n.allRoutes.find(C=>C.path.toLowerCase().endsWith(c));if(l)return l.path}}export{m as CALLBACKS_SECTION,A as CALLBACK_REQUEST_SECTION,b as CALLBACK_RESPONSE_SECTION,F as appendVariantSuffix,K as buildAsyncApiSuffix,y as buildDeepLinkUrl,B as buildGraphqlSuffix,N as buildOpenApiFieldSuffix,_ as buildOpenApiSectionSuffix,k as deepLinkToId,H as extractDeepLinkParamFromHash,P as getDeepLinkId,O as getLegacyHash,w as hashIsForItem,q as hashIsInsideCallback,G as hashIsOutsideCallbacks,j as hashTargetsCallback,d as hashToElementId,D as isGraphqlDeepLinkAncestor,$ as makeDeepLink,U as resolveLegacyHashToRoute,p as serializeFieldParams,v as stripArrayMarkers,I as stripCallbacksSegment,M as stripVariantMarkers,z as variantMarkersOnly};
1
+ import{encodeBackSlashes as k,tryDecodeURIComponent as a}from"./string.js";import{joinWithSeparator as i,normalizePath as x,toElementId as S}from"./url.js";import{resolveRouteByPathname as A}from"./routing.js";function C(t){const e=[];for(const[n,r]of Object.entries(t))r!==void 0&&e.push(`${n}=${r}`);return e.join("&")}function g(t,e){return t=k(t).replace(/^\/+/,""),(`/${t}#`+i(t,e)).toLowerCase()}function D(t,e,n){const r=g(e,n);return x(i(t,r))}function h(t){const e=t.startsWith("#")?t.slice(1):t;return a(e).toLowerCase()}function b(t){const e=a(t),n=e.indexOf("#");return n>=0?e.slice(n+1):""}function j(t){return C({t:t.t,in:t.in,c:t.c,cb:t.cb,ct:t.ct,path:t.path})}function F(t,e,n){let r=t;return n&&(r=`${r}&c=${n}`),e&&(r=i(r,e)),r}function I(t){const{section:e,messageKey:n,subsection:r}=t;if(!n)return e;let o=`${e}&m=${n}`;return r&&(o+=`&t=${r}`),o}function M(t){return C({t:t.t,path:t.path,arg:t.arg,rt:t.rt})}function P(t,e){return!t||!e?!1:a(t.startsWith("#")?t.slice(1):t).toLowerCase().includes(`path=${e.toLowerCase()}.`)}function v(t){return t&&b(t)||void 0}function z(t,e){const n=[...t??[]];return n.length>0?n[n.length-1]+=e:n.push(e),n}const E=/&(?:oneof|d)=\d+/g;function H(t){return t.replace(E,"")}function q(t){return t.replace(/\[\]/g,"")}function G(t){return(t??[]).filter(e=>e.includes("&")).map(e=>e.slice(e.indexOf("&")))}function U(t,e){return t?a(t.startsWith("#")?t.slice(1):t).toLowerCase().match(new RegExp(`(?:^|[&/])${e}=([^/&]+)`))?.[1]:void 0}const O="callbacks",f=`${O}/`,w="callback-request",T="callback-response",R=[`/${w}`,`/${T}`];function p(t){const e=t.indexOf("path=");return e===-1?t:t.slice(0,e)}function V(t){return t.replace(`/${f}`,"/")}function L(t,e){const n=`cb=${e}`;return t.endsWith(n)||t.includes(`${n}&`)}function W(t,e){const n=`/${e}`;return t.endsWith(n)||t.includes(`${n}/`)}function y(t,e){return t===e||t.startsWith(`${e}/`)}function Q(t,e,n){if(!t||!e||!n)return!1;const r=h(t);if(!y(r,e))return!1;const o=p(r),c=n.toLowerCase();return L(o,c)||W(o,c)}function J(t,e,n){const r=p(t),o=n.toLowerCase();return r.startsWith(i(e,`${f}${o}/`))||r.startsWith(i(e,`${o}/`))||L(r,o)}function X(t,e){const n=p(t).slice(e.length);return!(n.startsWith(`/${f}`)||n.includes("cb=")||R.some(o=>n.includes(o)))}function N(t){const e=["#tag","#operation","#paths"];for(const n of e)if(t.includes(n))return t.replace(n,"").toLowerCase();return""}function Y(t,e,n){const r=h(t);if(!r)return;const o=x(i(e,r));if(A(n,o))return o;const c=N(t);if(!c)return;const l=c.split("/").filter(Boolean);for(let s=l.length;s>0;s--){const $="/"+l.slice(0,s).join("/"),u=n.allRoutes.find(m=>m.path.endsWith($));if(!u)continue;const d=l.slice(s).join("/");return d?`${u.path}#${i(S(u.path,e),d)}`:u.path}}export{O as CALLBACKS_SECTION,w as CALLBACK_REQUEST_SECTION,T as CALLBACK_RESPONSE_SECTION,z as appendVariantSuffix,I as buildAsyncApiSuffix,D as buildDeepLinkUrl,M as buildGraphqlSuffix,j as buildOpenApiFieldSuffix,F as buildOpenApiSectionSuffix,b as deepLinkToId,U as extractDeepLinkParamFromHash,v as getDeepLinkId,N as getLegacyHash,y as hashIsForItem,J as hashIsInsideCallback,X as hashIsOutsideCallbacks,Q as hashTargetsCallback,h as hashToElementId,P as isGraphqlDeepLinkAncestor,g as makeDeepLink,Y as resolveLegacyHashToRoute,C as serializeFieldParams,q as stripArrayMarkers,V as stripCallbacksSegment,H as stripVariantMarkers,G as variantMarkersOnly};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/api-docs",
3
- "version": "0.1.0",
3
+ "version": "0.2.0-next.0",
4
4
  "description": "Redocly API Documentation Library",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE.md",
@@ -49,8 +49,8 @@
49
49
  "web-vitals": "3.3.1",
50
50
  "@redocly/config": "0.53.1",
51
51
  "@redocly/redoc-opentelemetry": "0.2.2",
52
- "@redocly/replay": "0.27.0",
53
- "@redocly/theme": "^0.68.0",
52
+ "@redocly/replay": "0.28.0-next.0",
53
+ "@redocly/theme": "^0.69.0-next.0",
54
54
  "@redocly/allof-merge": "0.6.9"
55
55
  },
56
56
  "devDependencies": {