@redocly/reference-docs 2.42.4 → 2.43.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,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Console=void 0;var tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),informed_1=require("informed"),mobx_react_1=require("mobx-react"),swagger_client_1=(0,tslib_1.__importDefault)(require("swagger-client")),react_1=require("react"),utils_1=require("../../utils"),redoc_lib_1=require("../../redoc-lib"),RenderHook_1=require("../../redoc-lib/src/components/RenderHook"),Labels_1=require("../../redoc-lib/src/services/Labels"),Panel_1=require("../Panel"),OAuth2_1=require("../../services/OAuth2"),helper_1=require("../common/FileUpload/helper"),OperationParameters_1=require("../OperationParameters"),hooks_1=require("../../hooks"),events_1=require("../../events"),utils_2=require("./utils"),AuthPanel_1=require("./AuthPanel"),ConsoleBadges_1=require("./ConsoleBadges"),RequestBody_1=require("./RequestBody"),ResponsePanel_1=require("./ResponsePanel"),ActionPanel_1=require("./ActionPanel"),ServersDropdown_1=require("./ServersDropdown"),TryItPanel_1=require("./TryItPanel"),styled_1=require("./styled");function normalizeUrlProtocol(e){return e.startsWith("//")?"https:"+e:e}var flexColumn={flex:1,display:"flex",flexDirection:"column"},Console=function(e){function t(t){var r=e.call(this,t)||this;return Object.defineProperty(r,"formApi",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"setFormApi",{enumerable:!0,configurable:!0,writable:!0,value:function(e){r.formApi=e;var t=e.getState(),s=t.values,i=(0,tslib_1.__rest)(t,["values"]);setTimeout((function(){var e=(0,tslib_1.__assign)((0,tslib_1.__assign)({},i),{values:(0,tslib_1.__assign)((0,tslib_1.__assign)({},s),{query:(0,utils_2.unescapeQueryParams)(s.query||{})})});r.setState({form:e})}),0)}}),Object.defineProperty(r,"handleValueChange",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var t=(0,tslib_1.__assign)((0,tslib_1.__assign)({},e),{query:(0,utils_2.unescapeQueryParams)(e.query||{})});r.setState((function(e){return{form:(0,tslib_1.__assign)((0,tslib_1.__assign)({},e.form),{values:t})}}),(function(){(0,utils_2.updateStorage)(r.state.form),r.props.operation.setRequestValues(e)}))}}),Object.defineProperty(r,"handleTabChange",{enumerable:!0,configurable:!0,writable:!0,value:function(e){r.setState({activeTab:e})}}),Object.defineProperty(r,"handleServerChange",{enumerable:!0,configurable:!0,writable:!0,value:function(e){r.setState({server:e}),r.props.operation.setActiveServer(e)}}),Object.defineProperty(r,"handleExecute",{enumerable:!0,configurable:!0,writable:!0,value:function(){return(0,tslib_1.__awaiter)(r,void 0,void 0,(function(){var e,t,r,s,i,o,n,a,l,u,_,d,c,p,h,v,m,b,g,y,f,x,j,P,q,S,A,C,w,k,I,O,T,R,B,F,H,V,D,E,U,N,L=this;return(0,tslib_1.__generator)(this,(function(W){switch(W.label){case 0:if(e=this.props,t=e.store,r=e.operation,s=e.onResponse,null===(T=this.formApi)||void 0===T||T.submitForm(),((null===(R=this.formApi)||void 0===R?void 0:R.getState())||this.state.form).invalid)return this.setState({shaking:!0}),setTimeout((function(){return L.setState({shaking:!1})}),1e3),null===(F=null===(B=null==t?void 0:t.options.events)||void 0===B?void 0:B.tryItSent)||void 0===F||F.call(B,{eventType:events_1.AnalyticsEventType.TryItSent,resource:"Redocly_OperationTryIt",action:"ValidationFailed",operationId:r.operationId,operationPath:r.path,operationHttpVerb:r.httpVerb,operationSummary:r.description}),[2];if(i=(this.state.form||(null===(H=this.formApi)||void 0===H?void 0:H.getState())).values,o=this.props.operation,n=o.servers,a=o.requestBody,l=a&&a.content&&a.content.active&&a.content.active.name||"",u=i.body,/json/.test(l))try{u=JSON.parse(u)}catch(e){console.error(e)}if(this.setState({loading:!0}),_=this.state.resolvedRawSpec,d=(r.httpVerb||"").toLowerCase(),!n)throw console.error("Servers are not specified in your OpenAPI file. You can't use Try It Out console without specifying servers. If you use OpenAPI 2, make sure you configured host and basepath"),new Error("Servers are not specified");c=n.find((function(e){return L.state.server.url.endsWith(e.url.endsWith("/")?e.url.substring(0,e.url.length-1):e.url)})),p=Date.now(),h=!!window.document.documentMode,m=i.auth,i.auth?(b=Object.keys(i.auth)[0],g=(0,utils_1.unescapeFormId)(b),v=(0,tslib_1.__assign)((0,tslib_1.__assign)({},_),{components:(0,tslib_1.__assign)((0,tslib_1.__assign)({},null==_?void 0:_.components),{securitySchemes:(0,tslib_1.__assign)((0,tslib_1.__assign)({},null==_?void 0:_.components.securitySchemes),(w={},w[g]=(0,tslib_1.__assign)((0,tslib_1.__assign)({},null==_?void 0:_.components.securitySchemes[g]),{type:"openIdConnect"===(null==_?void 0:_.components.securitySchemes[g].type)?"oauth2":null==_?void 0:_.components.securitySchemes[g].type}),w))})}),m=(0,tslib_1.__assign)((0,tslib_1.__assign)({},m),((k={})[g]=m[b],k))):v=(0,tslib_1.__assign)({},_),v.servers=n,(y=t.options.corsProxyUrl)&&n.length&&(v.servers=n.map((function(e){return(0,tslib_1.__assign)((0,tslib_1.__assign)({},e),{url:y+normalizeUrlProtocol(e.url)})})),v.paths=(0,tslib_1.__assign)((0,tslib_1.__assign)({},v.paths),((I={})[r.path]=(0,tslib_1.__assign)((0,tslib_1.__assign)({},v.paths[r.path]),((O={})[d]=(0,tslib_1.__assign)((0,tslib_1.__assign)({},v.paths[r.path][d]),{servers:void 0}),O.servers=void 0,O)),I))),(f=(null===(D=null===(V=null==a?void 0:a.content)||void 0===V?void 0:V.active)||void 0===D?void 0:D.name)||null)&&u&&(0,helper_1.isFileUploadMime)(f)&&(x=Object.values(u),u=x.length>1?x:x[0]),j={userFetch:h&&require("cross-fetch").fetch,server:y?y+normalizeUrlProtocol(c.url):c.url,serverVariables:this.state.server.variables,spec:v,pathName:r.path,method:r.httpVerb,parameters:(0,tslib_1.__assign)((0,tslib_1.__assign)((0,tslib_1.__assign)((0,tslib_1.__assign)({},i.path),i.query),i.header),i.cookie),securities:{authorized:m},requestBody:u,requestContentType:f,responseContentType:(null===(E=i.header)||void 0===E?void 0:E.Accept)||null,requestInterceptor:(0,utils_2.makeRequestInterceptor)(t.options,r,null==m?void 0:m.Authorization)},W.label=1;case 1:return W.trys.push([1,5,8,9]),[4,swagger_client_1.default.execute(j)];case 2:return P=W.sent(),(q=null==P?void 0:P.data)instanceof Blob?((0,helper_1.isFileUploadMime)(q.type)&&(P.fileInfo={rawData:q,fileName:(0,utils_2.getFileNameFromHeaders)(P.headers)}),S=P,[4,q.text()]):[3,4];case 3:S.data=W.sent(),W.label=4;case 4:return null==s||s({request:j,response:P}),this.setState({response:P,error:void 0}),[3,9];case 5:return(A=W.sent())&&A.response&&A.response.data instanceof Blob?(C=A.response,[4,A.response.data.text()]):[3,7];case 6:C.data=W.sent(),null==s||s({request:j,response:A.response}),W.label=7;case 7:return this.setState({response:void 0,error:A}),[3,9];case 8:return this.setState({loading:!1,activeTab:1,time:Date.now()-p}),null===(N=null===(U=null==t?void 0:t.options.events)||void 0===U?void 0:U.tryItSent)||void 0===N||N.call(U,{eventType:events_1.AnalyticsEventType.TryItSent,resource:"Redocly_OperationTryIt",action:"Sent",operationId:r.operationId,operationPath:r.path,operationHttpVerb:r.httpVerb,operationSummary:r.description}),[7];case 9:return[2]}}))}))}}),r.state={form:{values:{path:(0,utils_2.getParameters)(t.operation.parameters,"path"),cookie:(0,utils_2.getParameters)(t.operation.parameters,"cookie"),header:(0,utils_2.getParameters)(t.operation.parameters,"header"),query:(0,utils_2.getParameters)(t.operation.parameters,"query")}},shaking:!1,loading:!1,activeTab:0,server:{}},r}return(0,tslib_1.__extends)(t,e),Object.defineProperty(t.prototype,"componentDidMount",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e;return(0,tslib_1.__awaiter)(this,void 0,void 0,(function(){var t,r,s,i;return(0,tslib_1.__generator)(this,(function(o){switch(o.label){case 0:return t=this.props,r=t.store,s=t.operation,[4,r.dereferenceSpecForTryIt(s)];case 1:return i=o.sent(),this.setState({resolvedRawSpec:i}),null===(e=this.formApi)||void 0===e||e.setValues({}),[2]}}))}))}}),Object.defineProperty(t.prototype,"componentDidUpdate",{enumerable:!1,configurable:!0,writable:!0,value:function(e){e.operation!==this.props.operation&&this.setState({response:void 0,error:void 0,activeTab:0})}}),Object.defineProperty(t.prototype,"render",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.props,t=e.operation,r=e.className,s=e.rootElement,i=this.state,o=i.shaking,n=i.activeTab,a=i.form,l=i.response,u=i.loading,_=i.error,d=!(!l&&!_);return(0,jsx_runtime_1.jsxs)(ConsoleWrapHook,(0,tslib_1.__assign)({shaking:o,className:r,rootElement:s},{children:[(0,jsx_runtime_1.jsxs)(Panel_1.CodeHeader,{children:[(0,jsx_runtime_1.jsx)(ConsoleBadges_1.ConsoleBadges,{active:n,hasResponse:d,onChange:this.handleTabChange},void 0),this.props.onClose&&(0,jsx_runtime_1.jsx)(styled_1.CloseButton,(0,tslib_1.__assign)({onClick:this.props.onClose},{children:" ✕ "}),void 0)]},void 0),(0,jsx_runtime_1.jsx)(styled_1.ConsoleBody,(0,tslib_1.__assign)({hidden:0!==n,"data-cy":"console-request-body"},{children:this.renderRequest()}),void 0),(0,jsx_runtime_1.jsx)(styled_1.ConsoleBody,(0,tslib_1.__assign)({hidden:1!==n,"data-cy":"console-response-body"},{children:this.renderResponse()}),void 0),(0,jsx_runtime_1.jsx)(ActionPanel_1.ActionPanel,{hasResponse:d,params:a.values,operation:t,loading:u,execute:this.handleExecute},void 0)]}),void 0)}}),Object.defineProperty(t.prototype,"renderRequest",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e,t=this.props,r=t.operation,s=t.store,i=t.properties,o=t.securityDefaults,n=this.state,a=n.form,l=n.resolvedRawSpec,u=n.server,_=a.errors||{},d=_.path||_.cookie||_.header||_.query,c=l&&redoc_lib_1.JsonPointer.get(l,r.pointer),p=a.values&&a.values.auth&&Object.keys(a.values.auth)[0];p&&a.values.auth[p]||(p=void 0),!p||void 0===a.values.auth[p].token&&void 0===a.values.auth[p].client_id&&void 0===a.values.auth[p].client_secret||a.values.auth[p].token&&a.values.auth[p].token.access_token||(p=void 0),p&&null!=a.values.auth[p].username&&(a.values.auth[p].username&&a.values.auth[p].password||(p=void 0));var h=r.parameters||[],v=null===(e=null==s?void 0:s.options.hooks)||void 0===e?void 0:e.ReplaceTryItSecurityPanel;return!l&&(0,jsx_runtime_1.jsx)(jsx_runtime_1.Fragment,{children:"Loading..."},void 0)||(0,jsx_runtime_1.jsxs)(informed_1.Form,(0,tslib_1.__assign)({onValueChange:this.handleValueChange,getApi:this.setFormApi,style:(0,tslib_1.__assign)((0,tslib_1.__assign)({},flexColumn),{margin:0})},{children:[(0,jsx_runtime_1.jsx)(ServersDropdown_1.ServersDropdown,{operation:r,onChange:this.handleServerChange},void 0),(0,jsx_runtime_1.jsxs)(Panel_1.Accordion,(0,tslib_1.__assign)({initialActiveIdx:r.security.length&&p?1:0},{children:[r.security.length&&this.formApi&&(0,jsx_runtime_1.jsx)(TryItPanel_1.TryItPanel,(0,tslib_1.__assign)({header:(0,Labels_1.l)("tryItAuth"),"data-cy":"security-trigger",renderChildrenHidden:!0,error:!p&&!!_.auth,success:!!p},{children:v?(0,jsx_runtime_1.jsx)(AuthPanelHook,(0,tslib_1.__assign)({field:"auth",validate:AuthPanel_1.requiredValidator},{children:function(e){return(0,jsx_runtime_1.jsx)(RenderHook_1.RenderHook,{Hook:v,props:{server:u,operation:r,onChange:e,OAuth2:OAuth2_1.OAuth2}},void 0)}}),void 0):(0,jsx_runtime_1.jsx)(AuthPanel_1.AuthPanel,{formApi:this.formApi,form:a,operation:r,activeServer:u.url,authCorsProxyUrl:s.options.authCorsProxyUrl,securityDefaults:o},void 0)}),void 0)||null,r.requestBody&&this.formApi&&(0,jsx_runtime_1.jsx)(TryItPanel_1.TryItPanel,(0,tslib_1.__assign)({header:(0,Labels_1.l)("tryItBody"),"data-cy":"body-trigger",renderChildrenHidden:!0,error:!!_.body},{children:(0,jsx_runtime_1.jsx)(RequestBody_1.RequestBody,{validate:allowBodyErrors,formApi:this.formApi,body:r.requestBody,id:r.id,resolvedBody:null==c?void 0:c.requestBody,properties:i},void 0)}),void 0)||null,h.length&&(0,jsx_runtime_1.jsx)(TryItPanel_1.TryItPanel,(0,tslib_1.__assign)({header:(0,Labels_1.l)("tryItParameters"),"data-cy":"parameters-trigger",error:d,renderChildrenHidden:!0},{children:(0,jsx_runtime_1.jsx)(OperationParameters_1.OperationParameters,{operation:r,values:a.values,errors:a.errors||{}},void 0)}),void 0)||null]}),void 0)]}),void 0)}}),Object.defineProperty(t.prototype,"renderResponse",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.state,t=e.response,r=e.error,s=e.time;return(0,jsx_runtime_1.jsx)(ResponsePanel_1.ResponsePanel,{response:t,error:r,time:s},void 0)}}),t=(0,tslib_1.__decorate)([mobx_react_1.observer],t)}(react_1.Component);function allowBodyErrors(){}function ConsoleWrapHook(e){var t=e.shaking,r=e.className,s=e.children,i=e.rootElement,o=(0,hooks_1.useDimensions)(i)[0];return(0,jsx_runtime_1.jsx)(styled_1.ConsoleWrap,(0,tslib_1.__assign)({shaking:t,className:r,"data-cy":"console",fullWidth:null==o?void 0:o.width},{children:s}),void 0)}function AuthPanelHook(e){var t=(0,informed_1.useField)((0,tslib_1.__assign)({},e)),r=t.fieldApi,s=t.render,i=t.userProps,o=r.setValue,n=i.children;return s((0,jsx_runtime_1.jsx)(jsx_runtime_1.Fragment,{children:n(o)},void 0))}exports.Console=Console;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Console=void 0;var tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),informed_1=require("informed"),mobx_react_1=require("mobx-react"),swagger_client_1=(0,tslib_1.__importDefault)(require("swagger-client")),react_1=require("react"),utils_1=require("../../utils"),redoc_lib_1=require("../../redoc-lib"),RenderHook_1=require("../../redoc-lib/src/components/RenderHook"),Labels_1=require("../../redoc-lib/src/services/Labels"),Panel_1=require("../Panel"),OAuth2_1=require("../../services/OAuth2"),helper_1=require("../common/FileUpload/helper"),OperationParameters_1=require("../OperationParameters"),hooks_1=require("../../hooks"),events_1=require("../../events"),utils_2=require("./utils"),AuthPanel_1=require("./AuthPanel"),ConsoleBadges_1=require("./ConsoleBadges"),RequestBody_1=require("./RequestBody"),ResponsePanel_1=require("./ResponsePanel"),ActionPanel_1=require("./ActionPanel"),ServersDropdown_1=require("./ServersDropdown"),TryItPanel_1=require("./TryItPanel"),styled_1=require("./styled");function normalizeUrlProtocol(e){return e.startsWith("//")?"https:"+e:e}var flexColumn={flex:1,display:"flex",flexDirection:"column"},Console=function(e){function t(t){var r=e.call(this,t)||this;return Object.defineProperty(r,"formApi",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(r,"setFormApi",{enumerable:!0,configurable:!0,writable:!0,value:function(e){r.formApi=e;var t=e.getState(),s=t.values,i=(0,tslib_1.__rest)(t,["values"]);setTimeout((function(){var e=(0,tslib_1.__assign)((0,tslib_1.__assign)({},i),{values:(0,tslib_1.__assign)((0,tslib_1.__assign)({},s),{query:(0,utils_2.unescapeQueryParams)(s.query||{})})});r.setState({form:e})}),0)}}),Object.defineProperty(r,"handleValueChange",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var t=(0,tslib_1.__assign)((0,tslib_1.__assign)({},e),{query:(0,utils_2.unescapeQueryParams)(e.query||{})});r.setState((function(e){return{form:(0,tslib_1.__assign)((0,tslib_1.__assign)({},e.form),{values:t})}}),(function(){(0,utils_2.updateStorage)(r.state.form),r.props.operation.setRequestValues(e)}))}}),Object.defineProperty(r,"handleTabChange",{enumerable:!0,configurable:!0,writable:!0,value:function(e){r.setState({activeTab:e})}}),Object.defineProperty(r,"handleServerChange",{enumerable:!0,configurable:!0,writable:!0,value:function(e){r.setState({server:e}),r.props.operation.setActiveServer(e)}}),Object.defineProperty(r,"handleExecute",{enumerable:!0,configurable:!0,writable:!0,value:function(){return(0,tslib_1.__awaiter)(r,void 0,void 0,(function(){var e,t,r,s,i,o,n,a,l,u,_,d,c,p,h,v,m,b,y,g,f,x,j,P,q,S,A,C,w,k,I,O,T,R,B,F,H,V,D,E,U,N,L,W,M=this;return(0,tslib_1.__generator)(this,(function(z){switch(z.label){case 0:if(e=this.props,t=e.store,r=e.operation,s=e.onResponse,null===(B=this.formApi)||void 0===B||B.submitForm(),((null===(F=this.formApi)||void 0===F?void 0:F.getState())||this.state.form).invalid)return this.setState({shaking:!0}),setTimeout((function(){return M.setState({shaking:!1})}),1e3),null===(V=null===(H=null==t?void 0:t.options.events)||void 0===H?void 0:H.tryItSent)||void 0===V||V.call(H,{eventType:events_1.AnalyticsEventType.TryItSent,resource:"Redocly_OperationTryIt",action:"ValidationFailed",operationId:r.operationId,operationPath:r.path,operationHttpVerb:r.httpVerb,operationSummary:r.description}),[2];if(i=(this.state.form||(null===(D=this.formApi)||void 0===D?void 0:D.getState())).values,o=this.props.operation,n=o.servers,a=o.requestBody,l=a&&a.content&&a.content.active&&a.content.active.name||"",u=i.body,/json/.test(l))try{u=JSON.parse(u)}catch(e){console.error(e)}if(this.setState({loading:!0}),_=this.state.resolvedRawSpec,d=(r.httpVerb||"").toLowerCase(),!n)throw console.error("Servers are not specified in your OpenAPI file. You can't use Try It Out console without specifying servers. If you use OpenAPI 2, make sure you configured host and basepath"),new Error("Servers are not specified");c=n.find((function(e){return M.state.server.url.endsWith(e.url.endsWith("/")?e.url.substring(0,e.url.length-1):e.url)})),p=Date.now(),h=!!window.document.documentMode,m=i.auth,i.auth?(b=Object.keys(i.auth)[0],y=(0,utils_1.unescapeFormId)(b),v=(0,tslib_1.__assign)((0,tslib_1.__assign)({},_),{components:(0,tslib_1.__assign)((0,tslib_1.__assign)({},null==_?void 0:_.components),{securitySchemes:(0,tslib_1.__assign)((0,tslib_1.__assign)({},null==_?void 0:_.components.securitySchemes),(I={},I[y]=(0,tslib_1.__assign)((0,tslib_1.__assign)({},null==_?void 0:_.components.securitySchemes[y]),{type:"openIdConnect"===(null==_?void 0:_.components.securitySchemes[y].type)?"oauth2":null==_?void 0:_.components.securitySchemes[y].type}),I))})}),g="cookie"===(null==_?void 0:_.components.securitySchemes[y].in)?"Cookie":y,f="cookie"===(null==_?void 0:_.components.securitySchemes[y].in)?(null==_?void 0:_.components.securitySchemes[y].name)+"="+m[b]:m[b],m=(0,tslib_1.__assign)((0,tslib_1.__assign)({},m),((O={})[g]=f,O))):v=(0,tslib_1.__assign)({},_),v.servers=n,(x=t.options.corsProxyUrl)&&n.length&&(v.servers=n.map((function(e){return(0,tslib_1.__assign)((0,tslib_1.__assign)({},e),{url:x+normalizeUrlProtocol(e.url)})})),v.paths=(0,tslib_1.__assign)((0,tslib_1.__assign)({},v.paths),((T={})[r.path]=(0,tslib_1.__assign)((0,tslib_1.__assign)({},v.paths[r.path]),((R={})[d]=(0,tslib_1.__assign)((0,tslib_1.__assign)({},v.paths[r.path][d]),{servers:void 0}),R.servers=void 0,R)),T))),(j=(null===(U=null===(E=null==a?void 0:a.content)||void 0===E?void 0:E.active)||void 0===U?void 0:U.name)||null)&&u&&(0,helper_1.isFileUploadMime)(j)&&(P=Object.values(u),u=P.length>1?P:P[0]),q={userFetch:h&&require("cross-fetch").fetch,server:x?x+normalizeUrlProtocol(c.url):c.url,serverVariables:this.state.server.variables,spec:v,pathName:r.path,method:r.httpVerb,parameters:(0,tslib_1.__assign)((0,tslib_1.__assign)((0,tslib_1.__assign)((0,tslib_1.__assign)({},i.path),i.query),i.header),i.cookie),securities:{authorized:m},requestBody:u,requestContentType:j,responseContentType:(null===(N=i.header)||void 0===N?void 0:N.Accept)||null,requestInterceptor:(0,utils_2.makeRequestInterceptor)(t.options,r,m)},z.label=1;case 1:return z.trys.push([1,5,8,9]),[4,swagger_client_1.default.execute(q)];case 2:return S=z.sent(),(A=null==S?void 0:S.data)instanceof Blob?((0,helper_1.isFileUploadMime)(A.type)&&(S.fileInfo={rawData:A,fileName:(0,utils_2.getFileNameFromHeaders)(S.headers)}),C=S,[4,A.text()]):[3,4];case 3:C.data=z.sent(),z.label=4;case 4:return null==s||s({request:q,response:S}),this.setState({response:S,error:void 0}),[3,9];case 5:return(w=z.sent())&&w.response&&w.response.data instanceof Blob?(k=w.response,[4,w.response.data.text()]):[3,7];case 6:k.data=z.sent(),null==s||s({request:q,response:w.response}),z.label=7;case 7:return this.setState({response:void 0,error:w}),[3,9];case 8:return this.setState({loading:!1,activeTab:1,time:Date.now()-p}),null===(W=null===(L=null==t?void 0:t.options.events)||void 0===L?void 0:L.tryItSent)||void 0===W||W.call(L,{eventType:events_1.AnalyticsEventType.TryItSent,resource:"Redocly_OperationTryIt",action:"Sent",operationId:r.operationId,operationPath:r.path,operationHttpVerb:r.httpVerb,operationSummary:r.description}),[7];case 9:return[2]}}))}))}}),r.state={form:{values:{path:(0,utils_2.getParameters)(t.operation.parameters,"path"),cookie:(0,utils_2.getParameters)(t.operation.parameters,"cookie"),header:(0,utils_2.getParameters)(t.operation.parameters,"header"),query:(0,utils_2.getParameters)(t.operation.parameters,"query")}},shaking:!1,loading:!1,activeTab:0,server:{}},r}return(0,tslib_1.__extends)(t,e),Object.defineProperty(t.prototype,"componentDidMount",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e;return(0,tslib_1.__awaiter)(this,void 0,void 0,(function(){var t,r,s,i;return(0,tslib_1.__generator)(this,(function(o){switch(o.label){case 0:return t=this.props,r=t.store,s=t.operation,[4,r.dereferenceSpecForTryIt(s)];case 1:return i=o.sent(),this.setState({resolvedRawSpec:i}),null===(e=this.formApi)||void 0===e||e.setValues({}),[2]}}))}))}}),Object.defineProperty(t.prototype,"componentDidUpdate",{enumerable:!1,configurable:!0,writable:!0,value:function(e){e.operation!==this.props.operation&&this.setState({response:void 0,error:void 0,activeTab:0})}}),Object.defineProperty(t.prototype,"render",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.props,t=e.operation,r=e.className,s=e.rootElement,i=this.state,o=i.shaking,n=i.activeTab,a=i.form,l=i.response,u=i.loading,_=i.error,d=!(!l&&!_);return(0,jsx_runtime_1.jsxs)(ConsoleWrapHook,(0,tslib_1.__assign)({shaking:o,className:r,rootElement:s},{children:[(0,jsx_runtime_1.jsxs)(Panel_1.CodeHeader,{children:[(0,jsx_runtime_1.jsx)(ConsoleBadges_1.ConsoleBadges,{active:n,hasResponse:d,onChange:this.handleTabChange},void 0),this.props.onClose&&(0,jsx_runtime_1.jsx)(styled_1.CloseButton,(0,tslib_1.__assign)({onClick:this.props.onClose},{children:" ✕ "}),void 0)]},void 0),(0,jsx_runtime_1.jsx)(styled_1.ConsoleBody,(0,tslib_1.__assign)({hidden:0!==n,"data-cy":"console-request-body"},{children:this.renderRequest()}),void 0),(0,jsx_runtime_1.jsx)(styled_1.ConsoleBody,(0,tslib_1.__assign)({hidden:1!==n,"data-cy":"console-response-body"},{children:this.renderResponse()}),void 0),(0,jsx_runtime_1.jsx)(ActionPanel_1.ActionPanel,{hasResponse:d,params:a.values,operation:t,loading:u,execute:this.handleExecute},void 0)]}),void 0)}}),Object.defineProperty(t.prototype,"renderRequest",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e,t=this.props,r=t.operation,s=t.store,i=t.properties,o=t.securityDefaults,n=this.state,a=n.form,l=n.resolvedRawSpec,u=n.server,_=a.errors||{},d=_.path||_.cookie||_.header||_.query,c=l&&redoc_lib_1.JsonPointer.get(l,r.pointer),p=a.values&&a.values.auth&&Object.keys(a.values.auth)[0];p&&a.values.auth[p]||(p=void 0),!p||void 0===a.values.auth[p].token&&void 0===a.values.auth[p].client_id&&void 0===a.values.auth[p].client_secret||a.values.auth[p].token&&a.values.auth[p].token.access_token||(p=void 0),p&&null!=a.values.auth[p].username&&(a.values.auth[p].username&&a.values.auth[p].password||(p=void 0));var h=r.parameters||[],v=null===(e=null==s?void 0:s.options.hooks)||void 0===e?void 0:e.ReplaceTryItSecurityPanel;return!l&&(0,jsx_runtime_1.jsx)(jsx_runtime_1.Fragment,{children:"Loading..."},void 0)||(0,jsx_runtime_1.jsxs)(informed_1.Form,(0,tslib_1.__assign)({onValueChange:this.handleValueChange,getApi:this.setFormApi,style:(0,tslib_1.__assign)((0,tslib_1.__assign)({},flexColumn),{margin:0})},{children:[(0,jsx_runtime_1.jsx)(ServersDropdown_1.ServersDropdown,{operation:r,onChange:this.handleServerChange},void 0),(0,jsx_runtime_1.jsxs)(Panel_1.Accordion,(0,tslib_1.__assign)({initialActiveIdx:r.security.length&&p?1:0},{children:[r.security.length&&this.formApi&&(0,jsx_runtime_1.jsx)(TryItPanel_1.TryItPanel,(0,tslib_1.__assign)({header:(0,Labels_1.l)("tryItAuth"),"data-cy":"security-trigger",renderChildrenHidden:!0,error:!p&&!!_.auth,success:!!p},{children:v?(0,jsx_runtime_1.jsx)(AuthPanelHook,(0,tslib_1.__assign)({field:"auth",validate:AuthPanel_1.requiredValidator},{children:function(e){return(0,jsx_runtime_1.jsx)(RenderHook_1.RenderHook,{Hook:v,props:{server:u,operation:r,onChange:e,OAuth2:OAuth2_1.OAuth2}},void 0)}}),void 0):(0,jsx_runtime_1.jsx)(AuthPanel_1.AuthPanel,{formApi:this.formApi,form:a,operation:r,activeServer:u.url,authCorsProxyUrl:s.options.authCorsProxyUrl,securityDefaults:o},void 0)}),void 0)||null,r.requestBody&&this.formApi&&(0,jsx_runtime_1.jsx)(TryItPanel_1.TryItPanel,(0,tslib_1.__assign)({header:(0,Labels_1.l)("tryItBody"),"data-cy":"body-trigger",renderChildrenHidden:!0,error:!!_.body},{children:(0,jsx_runtime_1.jsx)(RequestBody_1.RequestBody,{validate:allowBodyErrors,formApi:this.formApi,body:r.requestBody,id:r.id,resolvedBody:null==c?void 0:c.requestBody,properties:i},void 0)}),void 0)||null,h.length&&(0,jsx_runtime_1.jsx)(TryItPanel_1.TryItPanel,(0,tslib_1.__assign)({header:(0,Labels_1.l)("tryItParameters"),"data-cy":"parameters-trigger",error:d,renderChildrenHidden:!0},{children:(0,jsx_runtime_1.jsx)(OperationParameters_1.OperationParameters,{operation:r,values:a.values,errors:a.errors||{}},void 0)}),void 0)||null]}),void 0)]}),void 0)}}),Object.defineProperty(t.prototype,"renderResponse",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.state,t=e.response,r=e.error,s=e.time;return(0,jsx_runtime_1.jsx)(ResponsePanel_1.ResponsePanel,{response:t,error:r,time:s},void 0)}}),t=(0,tslib_1.__decorate)([mobx_react_1.observer],t)}(react_1.Component);function allowBodyErrors(){}function ConsoleWrapHook(e){var t=e.shaking,r=e.className,s=e.children,i=e.rootElement,o=(0,hooks_1.useDimensions)(i)[0];return(0,jsx_runtime_1.jsx)(styled_1.ConsoleWrap,(0,tslib_1.__assign)({shaking:t,className:r,"data-cy":"console",fullWidth:null==o?void 0:o.width},{children:s}),void 0)}function AuthPanelHook(e){var t=(0,informed_1.useField)((0,tslib_1.__assign)({},e)),r=t.fieldApi,s=t.render,i=t.userProps,o=r.setValue,n=i.children;return s((0,jsx_runtime_1.jsx)(jsx_runtime_1.Fragment,{children:n(o)},void 0))}exports.Console=Console;
2
2
  //# sourceMappingURL=Console.js.map
@@ -1,4 +1,5 @@
1
- import type { FieldModel, OpenAPIServer, Server, ServerVariables, OperationModel, ExampleModel } from '../../redoc-lib';
1
+ import type { RequestAuth } from '../../types';
2
+ import type { ExampleModel, FieldModel, OpenAPIServer, OperationModel, Server, ServerVariables } from '../../redoc-lib';
2
3
  import type { RedocProNormalizedOptions } from '../../services';
3
4
  import type { RequestBodyProps } from './RequestBody';
4
5
  export declare function normalizeUrlProtocol(url: string): string;
@@ -12,7 +13,7 @@ export declare function getDefaultOrStoredVariables(server?: OpenAPIServer): Ser
12
13
  export declare function updateVariablesStorage(name: string, value: string): void;
13
14
  export declare function unescapeQueryParams(params: GenericObject): GenericObject;
14
15
  export declare function getFileNameFromHeaders(headers: Record<string, string>): string;
15
- export declare const makeRequestInterceptor: ({ requestInterceptor, sendXUserAgentInTryIt, disableTryItRequestUrlEncoding, }: Pick<RedocProNormalizedOptions, 'requestInterceptor' | 'sendXUserAgentInTryIt' | 'disableTryItRequestUrlEncoding'>, operation: OperationModel, securitySchemaAuth?: string | undefined) => (req: Request) => void | Request;
16
+ export declare const makeRequestInterceptor: ({ requestInterceptor, sendXUserAgentInTryIt, disableTryItRequestUrlEncoding, }: Pick<RedocProNormalizedOptions, 'requestInterceptor' | 'sendXUserAgentInTryIt' | 'disableTryItRequestUrlEncoding'>, operation: OperationModel, auth?: RequestAuth | undefined) => (req: Request) => void | Request;
16
17
  export declare const validateTokenEndpointMethod: (token: string[] | string | undefined) => boolean;
17
18
  export declare const getOAuth2TokenEndpointAuthHeader: ({ authMethod, clientId, clientSecret, }: {
18
19
  authMethod?: string | string[] | undefined;
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getStorageExampleKey=exports.encodeSample=exports.getOAuth2TokenEndpointAuthHeader=exports.validateTokenEndpointMethod=exports.makeRequestInterceptor=exports.getFileNameFromHeaders=exports.unescapeQueryParams=exports.updateVariablesStorage=exports.getDefaultOrStoredVariables=exports.expandDefaultServerVariables=exports.expandVariables=exports.getInitialServerWithVariables=exports.getServerWithVariables=exports.getParameters=exports.updateStorage=exports.normalizeUrlProtocol=void 0;var tslib_1=require("tslib"),deepmerge_1=(0,tslib_1.__importDefault)(require("deepmerge")),types_1=require("../../types"),utils_1=require("../../services/utils"),utils_2=require("../../utils");function normalizeUrlProtocol(e){return e.startsWith("//")?"https:"+e:e}function updateStorage(e){if(e.values.auth)for(var r=0,t=Object.keys(e.values.auth);r<t.length;r++){var a=t[r],i=e.values.auth[a];(0,utils_2.setSecurityDetails)(a,i)}updateParameterStorage(e)}function updateParameterStorage(e){for(var r,t=0,a=["path","query","header","cookie"];t<a.length;t++){var i=a[t];if(null===(r=e.values)||void 0===r?void 0:r[i])for(var s=0,n=Object.keys(e.values[i]);s<n.length;s++){var o=n[s];(0,utils_2.setParameterValue)(i,o,e.values[i][o])}}}exports.normalizeUrlProtocol=normalizeUrlProtocol,exports.updateStorage=updateStorage;var getParameters=function(e,r){return e.filter((function(e){return e.in===r})).reduce((function(e,r){var t=r.in,a=r.name;return e[a]=(0,utils_2.getParameterValue)(t||"",a),e}),{})};exports.getParameters=getParameters;var pathTemplateRegExp=/(?:{)(\w+)(?:})/g;function getServerWithVariables(e,r){void 0===r&&(r=0);var t=e[r],a=getDefaultOrStoredVariables(t);return(0,tslib_1.__assign)((0,tslib_1.__assign)({},t),{variables:a})}function getInitialServerWithVariables(e){var r=(0,utils_2.fromSessionStorage)("serverUrl"),t=e.find((function(e){return e.url===r}))||e[0],a=getDefaultOrStoredVariables(t);return(0,tslib_1.__assign)((0,tslib_1.__assign)({},t),{variables:a})}function expandVariables(e,r){return void 0===r&&(r={}),e.replace(pathTemplateRegExp,(function(e,t){return r[t]||e}))}function expandDefaultServerVariables(e,r){return void 0===r&&(r={}),e.replace(pathTemplateRegExp,(function(e,t){return r[t]&&r[t].default||e}))}function getDefaultOrStoredVariables(e){if(!(null==e?void 0:e.variables))return{};var r=(0,utils_2.fromSessionStorage)("variables"),t=r&&JSON.parse(r)||{},a={};return Object.entries(e.variables||{}).forEach((function(e){var r=e[0],i=e[1];a[r]=t[r]||i.default||""})),a}function updateVariablesStorage(e,r){var t,a=(0,utils_2.fromSessionStorage)("variables"),i=a&&JSON.parse(a)||{};(0,utils_2.toSessionStorage)("variables",JSON.stringify((0,tslib_1.__assign)((0,tslib_1.__assign)({},i),((t={})[e]=r,t))))}function unescapeQueryParams(e){return Object.entries(e).reduce((function(e,r){var t=r[0],a=r[1];return e[(0,utils_2.unescapeFormId)(t)]=a,e}),{})}function getFileNameFromHeaders(e){for(var r="filename=",t=0,a=Object.entries(e);t<a.length;t++){var i=a[t],s=i[0],n=i[1];if("content-disposition"===s.toLowerCase()){var o=n.split(";").find((function(e){return e.trim().startsWith(r)}));if(o)return o.split(r)[1]}}return""}exports.getServerWithVariables=getServerWithVariables,exports.getInitialServerWithVariables=getInitialServerWithVariables,exports.expandVariables=expandVariables,exports.expandDefaultServerVariables=expandDefaultServerVariables,exports.getDefaultOrStoredVariables=getDefaultOrStoredVariables,exports.updateVariablesStorage=updateVariablesStorage,exports.unescapeQueryParams=unescapeQueryParams,exports.getFileNameFromHeaders=getFileNameFromHeaders;var makeRequestInterceptor=function(e,r,t){var a=e.requestInterceptor,i=e.sendXUserAgentInTryIt,s=e.disableTryItRequestUrlEncoding;return function(e){var n,o,l,u;s&&(e=(0,tslib_1.__assign)((0,tslib_1.__assign)({},e),{url:decodeURIComponent(e.url)})),i&&(e.headers["X-User-Agent"]="Redocly Try it API console");var p=(null===(o=null===(n=null==r?void 0:r.requestValues)||void 0===n?void 0:n.header)||void 0===o?void 0:o.authorization)||(null===(u=null===(l=null==r?void 0:r.requestValues)||void 0===l?void 0:l.header)||void 0===u?void 0:u.Authorization);return!t&&p&&(e.headers.Authorization=p),a?a(e,r):e}};exports.makeRequestInterceptor=makeRequestInterceptor;var validateTokenEndpointMethod=function(e){if(!e)return!0;var r=Array.isArray(e)?e:[e];return!(r.length&&!r.includes("none")&&!r.includes("client_secret_basic"))};exports.validateTokenEndpointMethod=validateTokenEndpointMethod;var getOAuth2TokenEndpointAuthHeader=function(e){var r=e.authMethod,t=e.clientId,a=e.clientSecret;return"client_secret_basic"===r||Array.isArray(r)&&r.includes("client_secret_basic")?{Authorization:"Basic "+btoa(t+":"+a)}:{}};function encodeSample(e,r){if(!e)return"";if(e.mime===types_1.MediaTypes.URL_ENCODED)return e.value;var t=e.value,a=r?(0,deepmerge_1.default)(t,r,{arrayMerge:utils_1.arrayMergeStrategy}):t;return JSON.stringify(a,null,2)}exports.getOAuth2TokenEndpointAuthHeader=getOAuth2TokenEndpointAuthHeader,exports.encodeSample=encodeSample;var getStorageExampleKey=function(e,r,t,a){var i=e+"_"+r;return t&&a&&Object.keys(a).includes(t)&&(i+="_"+t),i};exports.getStorageExampleKey=getStorageExampleKey;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getStorageExampleKey=exports.encodeSample=exports.getOAuth2TokenEndpointAuthHeader=exports.validateTokenEndpointMethod=exports.makeRequestInterceptor=exports.getFileNameFromHeaders=exports.unescapeQueryParams=exports.updateVariablesStorage=exports.getDefaultOrStoredVariables=exports.expandDefaultServerVariables=exports.expandVariables=exports.getInitialServerWithVariables=exports.getServerWithVariables=exports.getParameters=exports.updateStorage=exports.normalizeUrlProtocol=void 0;var tslib_1=require("tslib"),deepmerge_1=(0,tslib_1.__importDefault)(require("deepmerge")),types_1=require("../../types"),utils_1=require("../../services/utils"),utils_2=require("../../utils");function normalizeUrlProtocol(e){return e.startsWith("//")?"https:"+e:e}function updateStorage(e){if(e.values.auth)for(var r=0,t=Object.keys(e.values.auth);r<t.length;r++){var a=t[r],i=e.values.auth[a];(0,utils_2.setSecurityDetails)(a,i)}updateParameterStorage(e)}function updateParameterStorage(e){for(var r,t=0,a=["path","query","header","cookie"];t<a.length;t++){var i=a[t];if(null===(r=e.values)||void 0===r?void 0:r[i])for(var o=0,n=Object.keys(e.values[i]);o<n.length;o++){var s=n[o];(0,utils_2.setParameterValue)(i,s,e.values[i][s])}}}exports.normalizeUrlProtocol=normalizeUrlProtocol,exports.updateStorage=updateStorage;var getParameters=function(e,r){return e.filter((function(e){return e.in===r})).reduce((function(e,r){var t=r.in,a=r.name;return e[a]=(0,utils_2.getParameterValue)(t||"",a),e}),{})};exports.getParameters=getParameters;var pathTemplateRegExp=/(?:{)(\w+)(?:})/g;function getServerWithVariables(e,r){void 0===r&&(r=0);var t=e[r],a=getDefaultOrStoredVariables(t);return(0,tslib_1.__assign)((0,tslib_1.__assign)({},t),{variables:a})}function getInitialServerWithVariables(e){var r=(0,utils_2.fromSessionStorage)("serverUrl"),t=e.find((function(e){return e.url===r}))||e[0],a=getDefaultOrStoredVariables(t);return(0,tslib_1.__assign)((0,tslib_1.__assign)({},t),{variables:a})}function expandVariables(e,r){return void 0===r&&(r={}),e.replace(pathTemplateRegExp,(function(e,t){return r[t]||e}))}function expandDefaultServerVariables(e,r){return void 0===r&&(r={}),e.replace(pathTemplateRegExp,(function(e,t){return r[t]&&r[t].default||e}))}function getDefaultOrStoredVariables(e){if(!(null==e?void 0:e.variables))return{};var r=(0,utils_2.fromSessionStorage)("variables"),t=r&&JSON.parse(r)||{},a={};return Object.entries(e.variables||{}).forEach((function(e){var r=e[0],i=e[1];a[r]=t[r]||i.default||""})),a}function updateVariablesStorage(e,r){var t,a=(0,utils_2.fromSessionStorage)("variables"),i=a&&JSON.parse(a)||{};(0,utils_2.toSessionStorage)("variables",JSON.stringify((0,tslib_1.__assign)((0,tslib_1.__assign)({},i),((t={})[e]=r,t))))}function unescapeQueryParams(e){return Object.entries(e).reduce((function(e,r){var t=r[0],a=r[1];return e[(0,utils_2.unescapeFormId)(t)]=a,e}),{})}function getFileNameFromHeaders(e){for(var r="filename=",t=0,a=Object.entries(e);t<a.length;t++){var i=a[t],o=i[0],n=i[1];if("content-disposition"===o.toLowerCase()){var s=n.split(";").find((function(e){return e.trim().startsWith(r)}));if(s)return s.split(r)[1]}}return""}exports.getServerWithVariables=getServerWithVariables,exports.getInitialServerWithVariables=getInitialServerWithVariables,exports.expandVariables=expandVariables,exports.expandDefaultServerVariables=expandDefaultServerVariables,exports.getDefaultOrStoredVariables=getDefaultOrStoredVariables,exports.updateVariablesStorage=updateVariablesStorage,exports.unescapeQueryParams=unescapeQueryParams,exports.getFileNameFromHeaders=getFileNameFromHeaders;var makeRequestInterceptor=function(e,r,t){var a=e.requestInterceptor,i=e.sendXUserAgentInTryIt,o=e.disableTryItRequestUrlEncoding;return function(e){var n,s,l,u;o&&(e=(0,tslib_1.__assign)((0,tslib_1.__assign)({},e),{url:decodeURIComponent(e.url)})),i&&(e.headers["X-User-Agent"]="Redocly Try it API console");var d=(null===(s=null===(n=null==r?void 0:r.requestValues)||void 0===n?void 0:n.header)||void 0===s?void 0:s.authorization)||(null===(u=null===(l=null==r?void 0:r.requestValues)||void 0===l?void 0:l.header)||void 0===u?void 0:u.Authorization);return!(null==t?void 0:t.Authorization)&&d&&(e.headers.Authorization=d),(null==t?void 0:t.Cookie)&&(e.headers["X-Redocly-Cookie"]=t.Cookie),a?a(e,r):e}};exports.makeRequestInterceptor=makeRequestInterceptor;var validateTokenEndpointMethod=function(e){if(!e)return!0;var r=Array.isArray(e)?e:[e];return!(r.length&&!r.includes("none")&&!r.includes("client_secret_basic"))};exports.validateTokenEndpointMethod=validateTokenEndpointMethod;var getOAuth2TokenEndpointAuthHeader=function(e){var r=e.authMethod,t=e.clientId,a=e.clientSecret;return"client_secret_basic"===r||Array.isArray(r)&&r.includes("client_secret_basic")?{Authorization:"Basic "+btoa(t+":"+a)}:{}};function encodeSample(e,r){if(!e)return"";if(e.mime===types_1.MediaTypes.URL_ENCODED)return e.value;var t=e.value,a=r?(0,deepmerge_1.default)(t,r,{arrayMerge:utils_1.arrayMergeStrategy}):t;return JSON.stringify(a,null,2)}exports.getOAuth2TokenEndpointAuthHeader=getOAuth2TokenEndpointAuthHeader,exports.encodeSample=encodeSample;var getStorageExampleKey=function(e,r,t,a){var i=e+"_"+r;return t&&a&&Object.keys(a).includes(t)&&(i+="_"+t),i};exports.getStorageExampleKey=getStorageExampleKey;
2
2
  //# sourceMappingURL=utils.js.map
@@ -1,2 +1,2 @@
1
- "use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.ProStore=exports.NestingGroup=void 0;var tslib_1=require("tslib"),mobx_1=require("mobx"),openapi_core_1=require("@redocly/openapi-core"),decko_1=require("decko"),redoc_lib_1=require("../redoc-lib"),pluggable_1=require("../components/pluggable"),utils_1=require("../utils"),SecurityDefs_1=require("../redoc-lib/src/components/SecurityRequirement/SecurityDefs"),types_1=require("../types"),history_1=require("./history"),ProMenu_1=require("./ProMenu"),SearchStore_1=require("./SearchStore"),extendTheme_1=require("./extendTheme"),VersionedSpecStore_1=require("./VersionedSpecStore"),check_1=(0,tslib_1.__importDefault)(require("./check")),utils_2=require("./utils"),store_types_1=require("./store-types"),types_2=require("./types"),global="undefined"==typeof window?{__REDOCLY_SEARCH_URL:void 0}:window,NestingGroup=function(){function e(e,t,i,o){var n=this;Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"absoluteIdx",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"description",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"linkable",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"items",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"parent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"externalDocs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"active",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"expanded",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"depth",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"level",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),(0,mobx_1.makeObservable)(this),this.id="section/"+e,this.type="nesting-group",this.name=i||"",this.level=1,this.depth=1,this.description="",this.parent=void 0,this.expanded=!1,this.items=t,this.linkable=!!o,t.forEach((function(e){return e.parent=n})),increaseDepthDeep(t)}return Object.defineProperty(e.prototype,"activate",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.active=!0}}),Object.defineProperty(e.prototype,"expand",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.expanded=!0,this.parent&&this.parent.expand()}}),Object.defineProperty(e.prototype,"collapse",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.expanded=!1}}),Object.defineProperty(e.prototype,"deactivate",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.active=!1}}),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"active",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"expanded",void 0),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"activate",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"expand",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"collapse",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"deactivate",null),e}();function increaseDepthDeep(e){Array.isArray(e)&&e.forEach((function(e){e.depth++,e.parent&&"group"===e.parent.type&&(e.depth=e.parent.depth),increaseDepthDeep(e.items)}))}exports.NestingGroup=NestingGroup;var ProStore=function(){function e(e,t,i,o){var n=this;void 0===i&&(i={}),void 0===o&&(o=!0),Object.defineProperty(this,"rawOptions",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"menu",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"definition",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"marker",{enumerable:!0,configurable:!0,writable:!0,value:new redoc_lib_1.MarkerService}),Object.defineProperty(this,"scroll",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"disposer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"search",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tryItOperation",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"showRightPanel",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"layout",{enumerable:!0,configurable:!0,writable:!0,value:store_types_1.LayoutVariant.THREE_PANEL}),Object.defineProperty(this,"activeSampleLanguage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isLoading",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"l",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),(0,mobx_1.makeObservable)(this),this.initProOptions(i),redoc_lib_1.IS_BROWSER&&(this.l=(0,check_1.default)(i.licenseKey),this.l.then((function(e){e.valid&&e.allowed&&!e.expired||e.local||e.plugin||(n.menu.items=[],n.menu.flatItems=n.menu.flatItems.slice(0,1),n.menu.renderItems=[])})));var r="object"==typeof e&&"versions"in e,a=this.options.disableSidebar?new history_1.FakeHistoryService(this.options):"browser"===this.options.routingStrategy?new history_1.PushStateHistoryService(this.options,r):new history_1.ProHashHistoryService(this.options,r);this.definition=r?new VersionedSpecStore_1.VersionedSpecStore(e,this.options,a.currentId.split("/")[0]):new redoc_lib_1.SpecStore(e,t,this.options),i.downloadDefinitionUrl&&(this.definition.info.downloadFileName=""),this.scroll=new redoc_lib_1.ScrollService(this.options),this.options.disableSidebar||ProMenu_1.ProMenu.updateOnHistory(a.currentId,this.scroll),this.menu=new ProMenu_1.ProMenu(this.definition,this.scroll,this.options,a),this.menu.initOnHistory(),this.options.disableSearch||this.initSearch(this.options,o),this.disposer=(0,mobx_1.observe)(this.menu,"none"===this.options.pagination?"activeItemIdx":"activeRenderItemIdx",(function(e){setTimeout((function(){return n.updateMarkOnMenu(e.newValue)}))})),(0,utils_1.setGlobalStore)(this)}return Object.defineProperty(e.prototype,"initProOptions",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,i,o,n,r,a;e=deepClone(e),this.rawOptions=(0,extendTheme_1.extendTheme)(e),this.options=new redoc_lib_1.RedocNormalizedOptions(this.rawOptions,DEFAULT_OPTIONS),null!=this.rawOptions.showConsole&&console.warn('"showConsole" option is deprecated. Please, use "hideTryItPanel" instead.'),this.options.showConsole=null!=this.rawOptions.hideTryItPanel?!this.rawOptions.hideTryItPanel:null===(t=this.rawOptions.showConsole)||void 0===t||t,this.options.hideRightPanel=null!==(i=this.rawOptions.hideRightPanel)&&void 0!==i&&i,this.showRightPanel=!this.options.hideRightPanel,this.options.showRightPanelToggle=null===(o=this.rawOptions.showRightPanelToggle)||void 0===o||o,this.options.showChangeLayoutButton=null===(n=this.rawOptions.showChangeLayoutButton)||void 0===n||n,this.options.layout=this.rawOptions.layout||store_types_1.LayoutVariant.THREE_PANEL,this.options.defaultSampleLanguage=this.rawOptions.defaultSampleLanguage||"",this.options.deepLinkSeparator=this.rawOptions.deepLinkSeparator||"/",this.options.deepLinkPrefix=this.rawOptions.deepLinkPrefix||"!",this.options.disableDeepLinks=this.rawOptions.disableDeepLinks||!1,this.options.sideNavStyle=this.rawOptions.sideNavStyle||types_2.SideNavStyle.SummaryOnly,this.options.whiteLabel=!!this.rawOptions.whiteLabel,this.options.hideLogo=!!this.rawOptions.hideLogo,this.options.hideInfoSection=!!this.rawOptions.hideInfoSection,this.options.oAuth2RedirectURI=this.rawOptions.oAuth2RedirectURI||null,this.options.unstable_hideServerUrlInTryIt=this.rawOptions.unstable_hideServerUrlInTryIt||!1,this.options.oAuth2RedirectURI=this.rawOptions.oAuth2RedirectURI||null,this.options.events=this.rawOptions.events||{},this.options.mockServer=(null===(r=this.rawOptions.mockServer)||void 0===r?void 0:r.url)?{url:this.rawOptions.mockServer.url,position:this.rawOptions.mockServer.position||"first",description:this.rawOptions.mockServer.description||"Mock server"}:null,this.options.corsProxyUrl=this.rawOptions.corsProxyUrl?addTrailingSlash(this.rawOptions.corsProxyUrl):null,this.options.authCorsProxyUrl=this.rawOptions.authCorsProxyUrl?addTrailingSlash(this.rawOptions.authCorsProxyUrl):null,this.options.theme.scrollYOffset=this.options.scrollYOffset,this.options.linkForId=this.rawOptions.linkForId||(0,utils_1.getWindowReferenceOptions)(types_1.WindowReferenceOptions.LINK_FOR_ID)||null,this.options.generateDeepLink=this.rawOptions.generateDeepLink||(0,utils_1.getWindowReferenceOptions)(types_1.WindowReferenceOptions.GENERATE_DEEP_LINK)||null,this.options.onDeepLinkClick=this.rawOptions.onDeepLinkClick||(0,utils_1.getWindowReferenceOptions)(types_1.WindowReferenceOptions.ON_DEEP_LINK_CLICK)||null,this.options.requestInterceptor=this.rawOptions.requestInterceptor||(0,utils_1.getWindowReferenceOptions)(types_1.WindowReferenceOptions.REQUEST_INTERCEPTOR)||null,this.options.sidebarLinks=this.rawOptions.sidebarLinks||{};var s="object"==typeof this.rawOptions.layout?this.rawOptions.layout:null;if(this.options.pagination=this.rawOptions.pagination||"none",this.options.routingStrategy=void 0!==this.rawOptions.routingStrategy?this.rawOptions.routingStrategy:"none"===this.options.pagination?"hash":"browser",!(null===(a=this.rawOptions)||void 0===a?void 0:a.pagination)&&(null==s?void 0:s.scope))switch(console.warn('"layout.scope" and "routingStrategy" settings are deprecated. Please, use "pagination" instead.'),null==s?void 0:s.scope){case"all":default:this.options.pagination="none",this.options.routingStrategy="hash";break;case"section":this.options.pagination="section",this.options.routingStrategy="browser";break;case"item":this.options.pagination="item",this.options.routingStrategy="browser"}this.options.markdownItemsPagination="none",!1!==this.rawOptions.showNextButton&&(this.options.showNextButton=!0),this.options.disableSidebar=!!e.disableSidebar,this.options.disableSidebar&&(this.options.theme.sidebar.width="0px"),this.options.skipBundleAndConvert=!!e.skipBundleAndConvert,this.options.routingBasePath=e.routingBasePath&&(0,utils_2.normalizePath)(e.routingBasePath)||"",this.options.searchAutoExpand=!1!==e.searchAutoExpand,this.options.searchMode=e.searchMode||"default",this.options.ctrlFHijack=void 0===e.ctrlFHijack||e.ctrlFHijack,this.options.disablePaginationLoadingAnimation=!!e.disablePaginationLoadingAnimation||"none"===this.options.pagination,this.options.showConsole,this.options.generateCodeSamples=e.generateCodeSamples||{languages:[]},this.options.searchMaxDepth=this.rawOptions.searchMaxDepth||SearchStore_1.DEFAULT_SEARCH_MAX_DEPTH}}),Object.defineProperty(e.prototype,"initSearch",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var i=this;global.__REDOCLY_SEARCH_URL?this.search=new SearchStore_1.RemoteSearch(global.__REDOCLY_SEARCH_URL):this.search=new SearchStore_1.DeepSearchStore(e),t&&setTimeout((function(){var e;return null===(e=i.search)||void 0===e?void 0:e.indexItems(i.menu.items)}),50),this.definition instanceof VersionedSpecStore_1.VersionedSpecStore&&(0,mobx_1.observe)(this.definition,"activeVersionIdx",(function(t){var o,n,r=i.definition;null===(o=i.search)||void 0===o||o.dispose(),i.search=new SearchStore_1.DeepSearchStore(e);var a=r.versions[t.newValue]._searchIndexName;if(redoc_lib_1.IS_BROWSER&&a){var s=r.versions[t.newValue]._searchIndexName,l=new URL(window.location.href);l.pathname=joinURLs(i.options.routingBasePath,s),null===(n=i.search)||void 0===n||n.fromExternalJS(l.toString(),__redoc_state.searchIndexExport),i.observeAllAndRemark()}else setTimeout((function(){var e;null===(e=i.search)||void 0===e||e.indexItems(i.menu.items)}),0)})),redoc_lib_1.IS_BROWSER&&this.observeAllAndRemark()}}),Object.defineProperty(e.prototype,"onDidMount",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(this.menu.updateOnHistory(),this.updateMarkOnMenu(this.menu.activeItemIdx),this.layout=(0,utils_1.fromLocalStorage)("layoutVariant")||this.options.layout||this.layout,this.activeSampleLanguage=(0,utils_1.fromLocalStorage)("activeSampleLanguage")||this.options.defaultSampleLanguage,this.options.showRightPanelToggle){var e=(0,utils_1.fromSessionStorage)("showRightPanelToggleState");e&&(this.showRightPanel="true"===e)}}}),Object.defineProperty(e.prototype,"toggleRightPanel",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.showRightPanel=null!=e?e:!this.showRightPanel,(0,utils_1.toSessionStorage)("showRightPanelToggleState",JSON.stringify(this.showRightPanel))}}),Object.defineProperty(e.prototype,"toggleLayout",{enumerable:!1,configurable:!0,writable:!0,value:function(e){void 0===e&&(e=store_types_1.LayoutVariant.THREE_PANEL),this.layout=e,(0,utils_1.toLocalStorage)("layoutVariant",e)}}),Object.defineProperty(e.prototype,"disableConsole",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.options.showConsole=!1}}),Object.defineProperty(e.prototype,"enableConsole",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.options.showConsole=!0}}),Object.defineProperty(e.prototype,"tryItOut",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.tryItOperation=e}}),Object.defineProperty(e.prototype,"setActiveSampleLanguage",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this.activeSampleLanguage===e)return this.stopLoader();this.activeSampleLanguage=e,(0,utils_1.toLocalStorage)("activeSampleLanguage",e)}}),Object.defineProperty(e.prototype,"activateSampleLanguage",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.setActiveSampleLanguage(e)}}),Object.defineProperty(e.prototype,"startLoader",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.isLoading||(this.isLoading=!0)}}),Object.defineProperty(e.prototype,"stopLoader",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.isLoading&&(this.isLoading=!1)}}),Object.defineProperty(e.prototype,"dereferenceSpecForTryIt",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,i,o,n;return(0,tslib_1.__awaiter)(this,void 0,void 0,(function(){var r,a,s,l,p,u,c,d;return(0,tslib_1.__generator)(this,(function(h){switch(h.label){case 0:return r=this.definition.parser.definition,a=JSON.parse(JSON.stringify(r)),s=(0,tslib_1.__assign)((0,tslib_1.__assign)({},getSpecVersionObj(a)),{components:a.components,paths:(c={},c[e.path]=(d={},d[e.httpVerb]=null===(i=null===(t=a.paths)||void 0===t?void 0:t[e.path])||void 0===i?void 0:i[e.httpVerb],d.parameters=null===(n=null===(o=a.paths)||void 0===o?void 0:o[e.path])||void 0===n?void 0:n.parameters,d),c)}),l=new openapi_core_1.Config({}),p=(0,redoc_lib_1.createParsedDocument)(s),u={config:l,doc:p,dereference:!0},[4,(0,openapi_core_1.bundle)(u)];case 1:return h.sent(),[2,a]}}))}))}}),Object.defineProperty(e.prototype,"observeAllAndRemark",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this,t=function(i){for(var o=0,n=i;o<n.length;o++){var r=n[o];if("operation"===r.type)for(var a=0,s=r.responses;a<s.length;a++){var l=s[a];(0,mobx_1.observe)(l,"expanded",(function(t){return e.remark(t)}))}else"tag"===r.type&&t(r.items||[])}};t(this.menu.renderItems),"none"!==this.options.pagination&&(0,mobx_1.observe)(this.menu,"renderItems",(function(){return t(e.menu.renderItems)}))}}),Object.defineProperty(e.prototype,"remark",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;e.newValue&&setTimeout((function(){return t.marker.mark()}),0)}}),Object.defineProperty(e,"fromJS",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var i,o=new e(t.definition.data,t.definition.url,t.options,!1);(0,utils_1.setGlobalStore)(o),o.menu.activeItemIdx=void 0!==t.menu.activeItemIdx?t.menu.activeItemIdx:-1,o.definition instanceof VersionedSpecStore_1.VersionedSpecStore&&t.definition.activeVersionIdx&&(o.definition.activeVersionIdx=t.definition.activeVersionIdx||0);var n=o.menu.flatItems[o.menu.activeItemIdx];if(n&&o.menu.activate(n,!1),!o.options.disableSearch){var r=new URL(window.location.href);r.pathname=t.searchIndexPath&&t.searchIndexPath.startsWith("/")?t.searchIndexPath:r.pathname+(r.pathname.endsWith("/")?"":"/")+t.searchIndexPath,null===(i=o.search)||void 0===i||i.fromExternalJS(r.toString(),t.searchIndexExport)}return t.tryItOperationId&&(o.tryItOperation=o.menu.flatItems.find((function(e){return e.id===t.tryItOperationId}))),setTimeout((function(){return o.observeAllAndRemark()}),0),o}}),Object.defineProperty(e.prototype,"toJS",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e;return(0,tslib_1.__awaiter)(this,void 0,void 0,(function(){var t,i;return(0,tslib_1.__generator)(this,(function(o){switch(o.label){case 0:return i={menu:{activeItemIdx:this.menu.activeItemIdx},definition:this.definition instanceof VersionedSpecStore_1.VersionedSpecStore?{url:void 0,data:this.definition.toJS()}:{url:this.definition.parser.definitionUrl,data:this.definition.parser.definition}},this.search?[4,this.search.toJS()]:[3,2];case 1:return t=o.sent(),[3,3];case 2:t=void 0,o.label=3;case 3:return[2,(i.searchIndex=t,i.options=this.rawOptions,i.tryItOperationId=null===(e=this.tryItOperation)||void 0===e?void 0:e.id,i)]}}))}))}}),Object.defineProperty(e.prototype,"dispose",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.scroll.dispose(),this.menu.dispose(),this.search&&this.search.dispose(),this.disposer()}}),Object.defineProperty(e.prototype,"updateMarkOnMenu",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var t=Math.max(0,e),i=Math.min(this.menu.flatItems.length,t+5),o=[],n=t;n<i;n++){(r=this.menu.getElementAt(n))&&(r&&o.push(r))}if("item"===this.options.pagination){var r,a=(this.menu.flatItems[e]||{}).parent;if(null==a?void 0:a.absoluteIdx)(r=this.menu.getElementAt(a.absoluteIdx))&&o.push(r)}this.marker.addOnly(o),this.marker.mark()}}),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"search",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"tryItOperation",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"showRightPanel",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"layout",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"activeSampleLanguage",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"isLoading",void 0),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"onDidMount",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"toggleRightPanel",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"toggleLayout",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"disableConsole",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"enableConsole",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"tryItOut",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"setActiveSampleLanguage",null),(0,tslib_1.__decorate)([decko_1.bind,(0,decko_1.debounce)(500)],e.prototype,"activateSampleLanguage",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"startLoader",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"stopLoader",null),e}();exports.ProStore=ProStore;var DEFAULT_OPTIONS={ignoreNamedSchemas:["java.io.ObjectStreamField"],allowedMdComponents:(_a={RedocResponse:{component:pluggable_1.RedocResponse,propsSelector:function(e){return{store:e}}},PullRight:{component:pluggable_1.PullRight,propsSelector:function(){return{}}}},_a[redoc_lib_1.SCHEMA_DEFINITION_JSX_NAME]={component:redoc_lib_1.SchemaDefinition,propsSelector:function(e){return{parser:e.definition.parser,options:e.options,layout:e.layout,showRightPanel:e.showRightPanel}}},_a[redoc_lib_1.SECURITY_DEFINITIONS_COMPONENT_NAME]={component:SecurityDefs_1.SecurityDefs,propsSelector:function(e){return{securitySchemes:e.definition.securitySchemes}}},_a[redoc_lib_1.SECURITY_DEFINITIONS_JSX_NAME]={component:SecurityDefs_1.SecurityDefs,propsSelector:function(e){return{securitySchemes:e.definition.securitySchemes}}},_a)};function joinURLs(e,t){return e.endsWith("/")&&(e=e.slice(0,-1)),t.startsWith("/")&&(t=t.substring(1)),e+"/"+t}function addTrailingSlash(e){return e.endsWith("/")?e:e+"/"}function getSpecVersionObj(e){return e.openapi?{openapi:e.openapi}:e.swagger?{swagger:e.swagger}:void 0}function deepClone(e){if("object"!=typeof e||null===e)return e;var t=Array.isArray(e)?[]:{};for(var i in e){var o=e[i];t[i]=deepClone(o)}return t}
1
+ "use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.ProStore=exports.NestingGroup=void 0;var tslib_1=require("tslib"),mobx_1=require("mobx"),openapi_core_1=require("@redocly/openapi-core"),decko_1=require("decko"),redoc_lib_1=require("../redoc-lib"),pluggable_1=require("../components/pluggable"),utils_1=require("../utils"),SecurityDefs_1=require("../redoc-lib/src/components/SecurityRequirement/SecurityDefs"),types_1=require("../types"),history_1=require("./history"),ProMenu_1=require("./ProMenu"),SearchStore_1=require("./SearchStore"),extendTheme_1=require("./extendTheme"),VersionedSpecStore_1=require("./VersionedSpecStore"),check_1=(0,tslib_1.__importDefault)(require("./check")),utils_2=require("./utils"),store_types_1=require("./store-types"),types_2=require("./types"),global="undefined"==typeof window?{__REDOCLY_SEARCH_URL:void 0}:window,NestingGroup=function(){function e(e,t,i,o){var n=this;Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"absoluteIdx",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"description",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"linkable",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"items",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"parent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"externalDocs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"active",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"expanded",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"depth",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"level",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),(0,mobx_1.makeObservable)(this),this.id="section/"+e,this.type="nesting-group",this.name=i||"",this.level=1,this.depth=1,this.description="",this.parent=void 0,this.expanded=!1,this.items=t,this.linkable=!!o,t.forEach((function(e){return e.parent=n})),increaseDepthDeep(t)}return Object.defineProperty(e.prototype,"activate",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.active=!0}}),Object.defineProperty(e.prototype,"expand",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.expanded=!0,this.parent&&this.parent.expand()}}),Object.defineProperty(e.prototype,"collapse",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.expanded=!1}}),Object.defineProperty(e.prototype,"deactivate",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.active=!1}}),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"active",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"expanded",void 0),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"activate",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"expand",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"collapse",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"deactivate",null),e}();function increaseDepthDeep(e){Array.isArray(e)&&e.forEach((function(e){e.depth++,e.parent&&"group"===e.parent.type&&(e.depth=e.parent.depth),increaseDepthDeep(e.items)}))}exports.NestingGroup=NestingGroup;var ProStore=function(){function e(e,t,i,o){var n=this;void 0===i&&(i={}),void 0===o&&(o=!0),Object.defineProperty(this,"rawOptions",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"menu",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"definition",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"marker",{enumerable:!0,configurable:!0,writable:!0,value:new redoc_lib_1.MarkerService}),Object.defineProperty(this,"scroll",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"disposer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"search",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tryItOperation",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"showRightPanel",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"layout",{enumerable:!0,configurable:!0,writable:!0,value:(0,utils_1.fromLocalStorage)("layoutVariant")||store_types_1.LayoutVariant.THREE_PANEL}),Object.defineProperty(this,"activeSampleLanguage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isLoading",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"l",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),(0,mobx_1.makeObservable)(this),this.initProOptions(i),redoc_lib_1.IS_BROWSER&&(this.l=(0,check_1.default)(i.licenseKey),this.l.then((function(e){e.valid&&e.allowed&&!e.expired||e.local||e.plugin||(n.menu.items=[],n.menu.flatItems=n.menu.flatItems.slice(0,1),n.menu.renderItems=[])})));var r="object"==typeof e&&"versions"in e,a=this.options.disableSidebar?new history_1.FakeHistoryService(this.options):"browser"===this.options.routingStrategy?new history_1.PushStateHistoryService(this.options,r):new history_1.ProHashHistoryService(this.options,r);this.definition=r?new VersionedSpecStore_1.VersionedSpecStore(e,this.options,a.currentId.split("/")[0]):new redoc_lib_1.SpecStore(e,t,this.options),i.downloadDefinitionUrl&&(this.definition.info.downloadFileName=""),this.scroll=new redoc_lib_1.ScrollService(this.options),this.options.disableSidebar||ProMenu_1.ProMenu.updateOnHistory(a.currentId,this.scroll),this.menu=new ProMenu_1.ProMenu(this.definition,this.scroll,this.options,a),this.menu.initOnHistory(),this.options.disableSearch||this.initSearch(this.options,o),this.disposer=(0,mobx_1.observe)(this.menu,"none"===this.options.pagination?"activeItemIdx":"activeRenderItemIdx",(function(e){setTimeout((function(){return n.updateMarkOnMenu(e.newValue)}))})),(0,utils_1.setGlobalStore)(this)}return Object.defineProperty(e.prototype,"initProOptions",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,i,o,n,r,a;e=deepClone(e),this.rawOptions=(0,extendTheme_1.extendTheme)(e),this.options=new redoc_lib_1.RedocNormalizedOptions(this.rawOptions,DEFAULT_OPTIONS),null!=this.rawOptions.showConsole&&console.warn('"showConsole" option is deprecated. Please, use "hideTryItPanel" instead.'),this.options.showConsole=null!=this.rawOptions.hideTryItPanel?!this.rawOptions.hideTryItPanel:null===(t=this.rawOptions.showConsole)||void 0===t||t,this.options.hideRightPanel=null!==(i=this.rawOptions.hideRightPanel)&&void 0!==i&&i,this.showRightPanel=!this.options.hideRightPanel,this.options.showRightPanelToggle=null===(o=this.rawOptions.showRightPanelToggle)||void 0===o||o,this.options.showChangeLayoutButton=null===(n=this.rawOptions.showChangeLayoutButton)||void 0===n||n,this.options.layout=this.rawOptions.layout||store_types_1.LayoutVariant.THREE_PANEL,this.options.defaultSampleLanguage=this.rawOptions.defaultSampleLanguage||"",this.options.deepLinkSeparator=this.rawOptions.deepLinkSeparator||"/",this.options.deepLinkPrefix=this.rawOptions.deepLinkPrefix||"!",this.options.disableDeepLinks=this.rawOptions.disableDeepLinks||!1,this.options.sideNavStyle=this.rawOptions.sideNavStyle||types_2.SideNavStyle.SummaryOnly,this.options.whiteLabel=!!this.rawOptions.whiteLabel,this.options.hideLogo=!!this.rawOptions.hideLogo,this.options.hideInfoSection=!!this.rawOptions.hideInfoSection,this.options.oAuth2RedirectURI=this.rawOptions.oAuth2RedirectURI||null,this.options.unstable_hideServerUrlInTryIt=this.rawOptions.unstable_hideServerUrlInTryIt||!1,this.options.oAuth2RedirectURI=this.rawOptions.oAuth2RedirectURI||null,this.options.events=this.rawOptions.events||{},this.options.mockServer=(null===(r=this.rawOptions.mockServer)||void 0===r?void 0:r.url)?{url:this.rawOptions.mockServer.url,position:this.rawOptions.mockServer.position||"first",description:this.rawOptions.mockServer.description||"Mock server"}:null,this.options.corsProxyUrl=this.rawOptions.corsProxyUrl?addTrailingSlash(this.rawOptions.corsProxyUrl):null,this.options.authCorsProxyUrl=this.rawOptions.authCorsProxyUrl?addTrailingSlash(this.rawOptions.authCorsProxyUrl):null,this.options.theme.scrollYOffset=this.options.scrollYOffset,this.options.linkForId=this.rawOptions.linkForId||(0,utils_1.getWindowReferenceOptions)(types_1.WindowReferenceOptions.LINK_FOR_ID)||null,this.options.generateDeepLink=this.rawOptions.generateDeepLink||(0,utils_1.getWindowReferenceOptions)(types_1.WindowReferenceOptions.GENERATE_DEEP_LINK)||null,this.options.onDeepLinkClick=this.rawOptions.onDeepLinkClick||(0,utils_1.getWindowReferenceOptions)(types_1.WindowReferenceOptions.ON_DEEP_LINK_CLICK)||null,this.options.requestInterceptor=this.rawOptions.requestInterceptor||(0,utils_1.getWindowReferenceOptions)(types_1.WindowReferenceOptions.REQUEST_INTERCEPTOR)||null,this.options.sidebarLinks=this.rawOptions.sidebarLinks||{};var s="object"==typeof this.rawOptions.layout?this.rawOptions.layout:null;if(this.options.pagination=this.rawOptions.pagination||"none",this.options.routingStrategy=void 0!==this.rawOptions.routingStrategy?this.rawOptions.routingStrategy:"none"===this.options.pagination?"hash":"browser",!(null===(a=this.rawOptions)||void 0===a?void 0:a.pagination)&&(null==s?void 0:s.scope))switch(console.warn('"layout.scope" and "routingStrategy" settings are deprecated. Please, use "pagination" instead.'),null==s?void 0:s.scope){case"all":default:this.options.pagination="none",this.options.routingStrategy="hash";break;case"section":this.options.pagination="section",this.options.routingStrategy="browser";break;case"item":this.options.pagination="item",this.options.routingStrategy="browser"}this.options.markdownItemsPagination="none",!1!==this.rawOptions.showNextButton&&(this.options.showNextButton=!0),this.options.disableSidebar=!!e.disableSidebar,this.options.disableSidebar&&(this.options.theme.sidebar.width="0px"),this.options.skipBundleAndConvert=!!e.skipBundleAndConvert,this.options.routingBasePath=e.routingBasePath&&(0,utils_2.normalizePath)(e.routingBasePath)||"",this.options.searchAutoExpand=!1!==e.searchAutoExpand,this.options.searchMode=e.searchMode||"default",this.options.ctrlFHijack=void 0===e.ctrlFHijack||e.ctrlFHijack,this.options.disablePaginationLoadingAnimation=!!e.disablePaginationLoadingAnimation||"none"===this.options.pagination,this.options.showConsole,this.options.generateCodeSamples=e.generateCodeSamples||{languages:[]},this.options.searchMaxDepth=this.rawOptions.searchMaxDepth||SearchStore_1.DEFAULT_SEARCH_MAX_DEPTH}}),Object.defineProperty(e.prototype,"initSearch",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var i=this;global.__REDOCLY_SEARCH_URL?this.search=new SearchStore_1.RemoteSearch(global.__REDOCLY_SEARCH_URL):this.search=new SearchStore_1.DeepSearchStore(e),t&&setTimeout((function(){var e;return null===(e=i.search)||void 0===e?void 0:e.indexItems(i.menu.items)}),50),this.definition instanceof VersionedSpecStore_1.VersionedSpecStore&&(0,mobx_1.observe)(this.definition,"activeVersionIdx",(function(t){var o,n,r=i.definition;null===(o=i.search)||void 0===o||o.dispose(),i.search=new SearchStore_1.DeepSearchStore(e);var a=r.versions[t.newValue]._searchIndexName;if(redoc_lib_1.IS_BROWSER&&a){var s=r.versions[t.newValue]._searchIndexName,l=new URL(window.location.href);l.pathname=joinURLs(i.options.routingBasePath,s),null===(n=i.search)||void 0===n||n.fromExternalJS(l.toString(),__redoc_state.searchIndexExport),i.observeAllAndRemark()}else setTimeout((function(){var e;null===(e=i.search)||void 0===e||e.indexItems(i.menu.items)}),0)})),redoc_lib_1.IS_BROWSER&&this.observeAllAndRemark()}}),Object.defineProperty(e.prototype,"onDidMount",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(this.menu.updateOnHistory(),this.updateMarkOnMenu(this.menu.activeItemIdx),this.layout=(0,utils_1.fromLocalStorage)("layoutVariant")||this.options.layout||this.layout,this.activeSampleLanguage=(0,utils_1.fromLocalStorage)("activeSampleLanguage")||this.options.defaultSampleLanguage,this.options.showRightPanelToggle){var e=(0,utils_1.fromSessionStorage)("showRightPanelToggleState");e&&(this.showRightPanel="true"===e)}}}),Object.defineProperty(e.prototype,"toggleRightPanel",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.showRightPanel=null!=e?e:!this.showRightPanel,(0,utils_1.toSessionStorage)("showRightPanelToggleState",JSON.stringify(this.showRightPanel))}}),Object.defineProperty(e.prototype,"toggleLayout",{enumerable:!1,configurable:!0,writable:!0,value:function(e){void 0===e&&(e=store_types_1.LayoutVariant.THREE_PANEL),this.layout=e,(0,utils_1.toLocalStorage)("layoutVariant",e)}}),Object.defineProperty(e.prototype,"disableConsole",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.options.showConsole=!1}}),Object.defineProperty(e.prototype,"enableConsole",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.options.showConsole=!0}}),Object.defineProperty(e.prototype,"tryItOut",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.tryItOperation=e}}),Object.defineProperty(e.prototype,"setActiveSampleLanguage",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this.activeSampleLanguage===e)return this.stopLoader();this.activeSampleLanguage=e,(0,utils_1.toLocalStorage)("activeSampleLanguage",e)}}),Object.defineProperty(e.prototype,"activateSampleLanguage",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.setActiveSampleLanguage(e)}}),Object.defineProperty(e.prototype,"startLoader",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.isLoading||(this.isLoading=!0)}}),Object.defineProperty(e.prototype,"stopLoader",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.isLoading&&(this.isLoading=!1)}}),Object.defineProperty(e.prototype,"dereferenceSpecForTryIt",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,i,o,n;return(0,tslib_1.__awaiter)(this,void 0,void 0,(function(){var r,a,s,l,p,u,c,d;return(0,tslib_1.__generator)(this,(function(h){switch(h.label){case 0:return r=this.definition.parser.definition,a=JSON.parse(JSON.stringify(r)),s=(0,tslib_1.__assign)((0,tslib_1.__assign)({},getSpecVersionObj(a)),{components:a.components,paths:(c={},c[e.path]=(d={},d[e.httpVerb]=null===(i=null===(t=a.paths)||void 0===t?void 0:t[e.path])||void 0===i?void 0:i[e.httpVerb],d.parameters=null===(n=null===(o=a.paths)||void 0===o?void 0:o[e.path])||void 0===n?void 0:n.parameters,d),c)}),l=new openapi_core_1.Config({}),p=(0,redoc_lib_1.createParsedDocument)(s),u={config:l,doc:p,dereference:!0},[4,(0,openapi_core_1.bundle)(u)];case 1:return h.sent(),[2,a]}}))}))}}),Object.defineProperty(e.prototype,"observeAllAndRemark",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this,t=function(i){for(var o=0,n=i;o<n.length;o++){var r=n[o];if("operation"===r.type)for(var a=0,s=r.responses;a<s.length;a++){var l=s[a];(0,mobx_1.observe)(l,"expanded",(function(t){return e.remark(t)}))}else"tag"===r.type&&t(r.items||[])}};t(this.menu.renderItems),"none"!==this.options.pagination&&(0,mobx_1.observe)(this.menu,"renderItems",(function(){return t(e.menu.renderItems)}))}}),Object.defineProperty(e.prototype,"remark",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;e.newValue&&setTimeout((function(){return t.marker.mark()}),0)}}),Object.defineProperty(e,"fromJS",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var i,o=new e(t.definition.data,t.definition.url,t.options,!1);(0,utils_1.setGlobalStore)(o),o.menu.activeItemIdx=void 0!==t.menu.activeItemIdx?t.menu.activeItemIdx:-1,o.definition instanceof VersionedSpecStore_1.VersionedSpecStore&&t.definition.activeVersionIdx&&(o.definition.activeVersionIdx=t.definition.activeVersionIdx||0);var n=o.menu.flatItems[o.menu.activeItemIdx];if(n&&o.menu.activate(n,!1),!o.options.disableSearch){var r=new URL(window.location.href);r.pathname=t.searchIndexPath&&t.searchIndexPath.startsWith("/")?t.searchIndexPath:r.pathname+(r.pathname.endsWith("/")?"":"/")+t.searchIndexPath,null===(i=o.search)||void 0===i||i.fromExternalJS(r.toString(),t.searchIndexExport)}return t.tryItOperationId&&(o.tryItOperation=o.menu.flatItems.find((function(e){return e.id===t.tryItOperationId}))),setTimeout((function(){return o.observeAllAndRemark()}),0),o}}),Object.defineProperty(e.prototype,"toJS",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e;return(0,tslib_1.__awaiter)(this,void 0,void 0,(function(){var t,i;return(0,tslib_1.__generator)(this,(function(o){switch(o.label){case 0:return i={menu:{activeItemIdx:this.menu.activeItemIdx},definition:this.definition instanceof VersionedSpecStore_1.VersionedSpecStore?{url:void 0,data:this.definition.toJS()}:{url:this.definition.parser.definitionUrl,data:this.definition.parser.definition}},this.search?[4,this.search.toJS()]:[3,2];case 1:return t=o.sent(),[3,3];case 2:t=void 0,o.label=3;case 3:return[2,(i.searchIndex=t,i.options=this.rawOptions,i.tryItOperationId=null===(e=this.tryItOperation)||void 0===e?void 0:e.id,i)]}}))}))}}),Object.defineProperty(e.prototype,"dispose",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.scroll.dispose(),this.menu.dispose(),this.search&&this.search.dispose(),this.disposer()}}),Object.defineProperty(e.prototype,"updateMarkOnMenu",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var t=Math.max(0,e),i=Math.min(this.menu.flatItems.length,t+5),o=[],n=t;n<i;n++){(r=this.menu.getElementAt(n))&&(r&&o.push(r))}if("item"===this.options.pagination){var r,a=(this.menu.flatItems[e]||{}).parent;if(null==a?void 0:a.absoluteIdx)(r=this.menu.getElementAt(a.absoluteIdx))&&o.push(r)}this.marker.addOnly(o),this.marker.mark()}}),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"search",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"tryItOperation",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"showRightPanel",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"layout",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"activeSampleLanguage",void 0),(0,tslib_1.__decorate)([mobx_1.observable],e.prototype,"isLoading",void 0),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"onDidMount",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"toggleRightPanel",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"toggleLayout",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"disableConsole",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"enableConsole",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"tryItOut",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"setActiveSampleLanguage",null),(0,tslib_1.__decorate)([decko_1.bind,(0,decko_1.debounce)(500)],e.prototype,"activateSampleLanguage",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"startLoader",null),(0,tslib_1.__decorate)([mobx_1.action],e.prototype,"stopLoader",null),e}();exports.ProStore=ProStore;var DEFAULT_OPTIONS={ignoreNamedSchemas:["java.io.ObjectStreamField"],allowedMdComponents:(_a={RedocResponse:{component:pluggable_1.RedocResponse,propsSelector:function(e){return{store:e}}},PullRight:{component:pluggable_1.PullRight,propsSelector:function(){return{}}}},_a[redoc_lib_1.SCHEMA_DEFINITION_JSX_NAME]={component:redoc_lib_1.SchemaDefinition,propsSelector:function(e){return{parser:e.definition.parser,options:e.options,layout:e.layout,showRightPanel:e.showRightPanel}}},_a[redoc_lib_1.SECURITY_DEFINITIONS_COMPONENT_NAME]={component:SecurityDefs_1.SecurityDefs,propsSelector:function(e){return{securitySchemes:e.definition.securitySchemes}}},_a[redoc_lib_1.SECURITY_DEFINITIONS_JSX_NAME]={component:SecurityDefs_1.SecurityDefs,propsSelector:function(e){return{securitySchemes:e.definition.securitySchemes}}},_a)};function joinURLs(e,t){return e.endsWith("/")&&(e=e.slice(0,-1)),t.startsWith("/")&&(t=t.substring(1)),e+"/"+t}function addTrailingSlash(e){return e.endsWith("/")?e:e+"/"}function getSpecVersionObj(e){return e.openapi?{openapi:e.openapi}:e.swagger?{swagger:e.swagger}:void 0}function deepClone(e){if("object"!=typeof e||null===e)return e;var t=Array.isArray(e)?[]:{};for(var i in e){var o=e[i];t[i]=deepClone(o)}return t}
2
2
  //# sourceMappingURL=ProStore.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.capitalizeFirst=exports.isDefined=exports.getCodeSample=void 0;var tslib_1=require("tslib"),query_string_1=require("query-string"),Sampler=(0,tslib_1.__importStar)(require("openapi-sampler")),deepmerge_1=(0,tslib_1.__importDefault)(require("deepmerge")),mobx_1=require("mobx"),redoc_lib_1=require("../../redoc-lib"),utils_1=require("../../utils"),utils_2=require("../utils"),types_1=require("../../types"),Labels_1=require("../../redoc-lib/src/services/Labels"),httpsnippet_1=require("./httpsnippet"),string_utility_1=(0,tslib_1.__importDefault)(require("./httpsnippet/helpers/string-utility"));function mapOperationToHAR(e,t){var a,r,i,s,l,n,o,u,p,d,c=t.exampleName,_=void 0===c?"":c,m=t.skipOptionalParameters,v=void 0!==m&&m,h=t.withOAuth2Call,y=void 0!==h&&h,f=t.spec,g=t.generatedPayloadSamplesMaxDepth,O=void 0===g?8:g,b=t.pathParams,S=void 0===b?{}:b,T=t.properties,C=void 0===T?{}:T,q=getSecurityData(null===(a=e.security)||void 0===a?void 0:a[0],y),E=q.securityHeaders,D=q.securityCookies,A=q.securityQueries,x=q.securityOAuth2ExtraCalls,P=q.basicAuth,R=null===(i=null===(r=e.requestBody)||void 0===r?void 0:r.content)||void 0===i?void 0:i.active,w={skipNonRequired:v,skipReadOnly:!0,maxSampleDepth:O},k={path:(0,mobx_1.toJS)(null===(s=null==e?void 0:e.requestValues)||void 0===s?void 0:s.path),cookie:(0,mobx_1.toJS)(null===(l=null==e?void 0:e.requestValues)||void 0===l?void 0:l.cookie),header:(0,mobx_1.toJS)(null===(n=null==e?void 0:e.requestValues)||void 0===n?void 0:n.header),query:(0,mobx_1.toJS)(null===(o=null==e?void 0:e.requestValues)||void 0===o?void 0:o.query),body:(0,mobx_1.toJS)(null===(u=null==e?void 0:e.requestValues)||void 0===u?void 0:u.body)},H=!1,N=e.parameters.filter((function(e){return"header"===e.in})).filter((function(e){return!(v&&!e.required)})).map((function(e){var t;return{name:e.name,value:(null===(t=k.header)||void 0===t?void 0:t[e.name])||(0,utils_1.getParameterValue)("header",e.name)||(0,redoc_lib_1.serializeParameterValue)(e,Sampler.sample(e.schema.rawSchema,w,f))}})).map((function(e){return(null==R?void 0:R.name)&&"content-type"===e.name.toLowerCase()&&(H=!0,e.value=R.name),e})).concat(E);!H&&(null==R?void 0:R.name)&&N.unshift({name:"Content-Type",value:null==R?void 0:R.name});var M,z=e.parameters.filter((function(e){return"cookie"===e.in})).filter((function(e){return!(v&&!e.required)})).map((function(e){return(0,query_string_1.parse)((0,redoc_lib_1.serializeParameterValue)(e,Sampler.sample(e.schema.rawSchema,w,f)))})).reduce((function(e,t){for(var a,r=0,i=Object.entries(t);r<i.length;r++){var s=i[r],l=s[0],n=s[1];e.push({name:l,value:String((null===(a=k.cookie)||void 0===a?void 0:a[l])||n)})}return e}),[]).concat(D),U=e.parameters.filter((function(e){return"query"===e.in})).filter((function(e){return!(v&&!e.required)})).map((function(e){return(0,query_string_1.parse)((0,redoc_lib_1.serializeParameterValue)(e,Sampler.sample(e.schema.rawSchema,w,f)))})).reduce((function(e,t){for(var a,r,i,s=0,l=Object.entries(t);s<l.length;s++){var n=l[s],o=n[0],u=n[1];e.push({name:o,value:(0,redoc_lib_1.isArrayOfObjects)(null===(a=k.query)||void 0===a?void 0:a[o])&&JSON.stringify((0,redoc_lib_1.deleteEmptyArrayItem)(null===(r=k.query)||void 0===r?void 0:r[o]))||String((null===(i=k.query)||void 0===i?void 0:i[o])||u)})}return e}),[]).concat(A),L=null===(p=e.activeServer)||void 0===p?void 0:p.url.replace(/\/$/,""),j=e.path.replace(/^\//,""),V=L.split("#")[0]+"/"+j,I=e.parameters.filter((function(e){return"path"===e.in})).reduce((function(e,t){var a,r=t.in,i=t.name;return e[i]=(null===(a=k.path)||void 0===a?void 0:a[i])||S[i]||(0,utils_1.getParameterValue)(r,i),e}),{}),J=null===(d=null==R?void 0:R.examples)||void 0===d?void 0:d[_],Y=(null==R?void 0:R.examples)||{},F=Object.values(Y)[0],B=k.body||(null==J?void 0:J.value)||(null==F?void 0:F.value)||(null==R?void 0:R.schema)&&Sampler.sample(null==R?void 0:R.schema.rawSchema,w,f),K=null==R?void 0:R.name.toLowerCase(),Q=[];switch((0,utils_2.normalizeMimeType)(K)){case types_1.MediaTypes.JSON:M=JSON.stringify(getDataRequest(B,C));break;case types_1.MediaTypes.URL_ENCODED:case types_1.MediaTypes.MULTIPART:M=(0,query_string_1.stringify)(getDataRequest(B,C)),Q=objectToHarParams(getDataRequest(B,C));break;default:M=String(B||"")}var G=M?{mimeType:(null==R?void 0:R.name)||types_1.MediaTypes.OCTET_STREAM,text:M,params:Q}:void 0,$=e.responses.map((function(e){return e.code}));return{method:e.httpVerb,url:V,httpVersion:"HTTP/1.1",cookies:z,headers:N,queryString:U,postData:G,headersSize:-1,bodySize:-1,securityOAuth2ExtraCalls:x,basicAuth:P,pathParameters:I,serverVariables:e.activeServer.variables,allResponseCodes:$}}var defaultOptions={withImports:!0,withComments:!1},langToSnippetConfig={curl:{code:"shell",defaultTarget:"curl",defaultOptions:(0,tslib_1.__assign)((0,tslib_1.__assign)({},defaultOptions),{short:!0})},JavaScript:{code:"javascript",defaultTarget:"fetch",defaultOptions:(0,tslib_1.__assign)((0,tslib_1.__assign)({},defaultOptions),{withImports:!1})},"Node.js":{code:"node",defaultTarget:"fetch",defaultOptions:(0,tslib_1.__assign)({},defaultOptions)},Python:{code:"python",defaultTarget:"requests",defaultOptions:(0,tslib_1.__assign)({},defaultOptions)},"Java8+Apache":{code:"java8",defaultTarget:"apachehttp",defaultOptions:(0,tslib_1.__assign)({},defaultOptions)},Java:{code:"java",defaultTarget:"httpclient",defaultOptions:(0,tslib_1.__assign)({},defaultOptions)},"C#":{code:"csharp",defaultTarget:"httpclient",defaultOptions:(0,tslib_1.__assign)({},defaultOptions)},Go:{code:"go",defaultTarget:"http.DefaultClient",defaultOptions:(0,tslib_1.__assign)({},defaultOptions)},PHP:{code:"php",defaultTarget:"curl",defaultOptions:(0,tslib_1.__assign)({},defaultOptions)},Ruby:{code:"ruby",defaultTarget:"net::http",defaultOptions:(0,tslib_1.__assign)({},defaultOptions)},R:{code:"r",defaultTarget:"httr",defaultOptions:(0,tslib_1.__assign)({},defaultOptions)}};function getCodeSample(e){var t=e.lang,a=e.operation,r=e.exampleName,i=e.pathParams,s=e.properties,l=e.options,n=void 0===l?{}:l;try{var o=mapOperationToHAR(a,{exampleName:r,pathParams:i,properties:s,skipOptionalParameters:n.skipOptionalParameters,withOAuth2Call:n.withOAuth2Call,spec:n.spec,generatedPayloadSamplesMaxDepth:n.generatedPayloadSamplesMaxDepth}),u=new httpsnippet_1.HTTPSnippet(o);return langToSnippetConfig[t]?u.convert(langToSnippetConfig[t].code,langToSnippetConfig[t].defaultTarget,(0,tslib_1.__assign)((0,tslib_1.__assign)({},langToSnippetConfig[t].defaultOptions),n)):"Language is not supported."}catch(e){return console.error(e),"Failed to generate code sample."}}function getSecurityData(e,t){for(var a,r,i,s,l={securityHeaders:[],securityCookies:[],securityQueries:[],securityOAuth2ExtraCalls:[],basicAuth:void 0},n=0,o=(null==e?void 0:e.schemes)||[];n<o.length;n++){var u=o[n],p=(0,utils_1.getSecurityDetails)(u.id);switch(u.type){case"openIdConnect":null===(a=l.securityHeaders)||void 0===a||a.push({name:"Authorization",value:"Bearer <YOUR_TOKEN_HERE>"});break;case"oauth2":var d=p.token?(p.token.token_type||"Bearer")+" "+p.token.access_token:"Bearer <YOUR_TOKEN_HERE>";u.flows.clientCredentials&&t?l.securityOAuth2ExtraCalls.push(getOAuth2ClientCredsCallHar(u.flows.clientCredentials,u.scopes,p)):u.flows.password&&t&&l.securityOAuth2ExtraCalls.push(getOAuth2PasswordCallHar(u.flows.password,u.scopes,p)),null===(r=l.securityHeaders)||void 0===r||r.push({name:"Authorization",value:d});break;case"apiKey":var c=p.raw||"YOUR_API_KEY_HERE";"header"===u.in&&(null===(i=l.securityHeaders)||void 0===i||i.push({name:u.name,value:c})),"cookie"===u.in&&l.securityCookies.push({name:u.name,value:c}),"query"===u.in&&l.securityQueries.push({name:u.name,value:c});break;case"http":"basic"===u.scheme?l.basicAuth={username:p.username||"<"+string_utility_1.default.toSnakeCase((0,Labels_1.l)("tryItAuthBasicUsername"))+">",password:p.password||"<"+string_utility_1.default.toSnakeCase((0,Labels_1.l)("tryItAuthBasicPassword"))+">"}:null===(s=l.securityHeaders)||void 0===s||s.push({name:"Authorization",value:capitalizeFirst(u.scheme||"bearer")+" <YOUR_"+(u.bearerFormat||"TOKEN")+"_HERE>"})}}return l}function getOAuth2PasswordCallHar(e,t,a){return{method:"POST",url:e.tokenUrl,httpVersion:"HTTP/1.1",headers:[{name:"Content-Type",value:types_1.MediaTypes.URL_ENCODED},{name:"Accept",value:types_1.MediaTypes.JSON}],queryString:[],postData:{mimeType:types_1.MediaTypes.URL_ENCODED,text:"",params:[{name:"grant_type",value:"password"},{name:"client_id",value:a.client_id||"YOUR_CLIENT_ID"},{name:"client_secret",value:a.client_secret||"YOUR_CLIENT_SECRET"},{name:"username",value:a.username||"<username>"},{name:"password",value:a.password||"<password>"},t.length?{name:"scope",value:t.join(" ")}:void 0].filter(isDefined)},cookies:[],headersSize:-1,bodySize:-1,securityOAuth2ExtraCalls:[]}}function getOAuth2ClientCredsCallHar(e,t,a){return{method:"POST",url:e.tokenUrl,httpVersion:"HTTP/1.1",headers:[{name:"Content-Type",value:types_1.MediaTypes.URL_ENCODED},{name:"Accept",value:types_1.MediaTypes.JSON}],queryString:[],postData:{mimeType:types_1.MediaTypes.URL_ENCODED,text:"",params:[{name:"grant_type",value:"client_credentials"},{name:"client_id",value:a.client_id||"YOUR_CLIENT_ID"},{name:"client_secret",value:a.client_secret||"YOUR_CLIENT_SECRET"},t.length?{name:"scope",value:t.join(" ")}:void 0].filter(isDefined)},cookies:[],headersSize:-1,bodySize:-1,securityOAuth2ExtraCalls:[]}}function getDataRequest(e,t){if(e){if("object"==typeof e)return(0,deepmerge_1.default)(e,t,{arrayMerge:utils_2.arrayMergeStrategy});try{return(0,deepmerge_1.default)(JSON.parse(e),t,{arrayMerge:utils_2.arrayMergeStrategy})}catch(e){return!1}}return!1}function objectToHarParams(e){for(var t=[],a=0,r=Object.entries(e);a<r.length;a++){var i=r[a],s=i[0],l=i[1];t.push({name:s,value:String(l)})}return t}function isDefined(e){return void 0!==e}function capitalizeFirst(e){return e.charAt(0).toUpperCase()+e.slice(1)}exports.getCodeSample=getCodeSample,exports.isDefined=isDefined,exports.capitalizeFirst=capitalizeFirst;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.capitalizeFirst=exports.isDefined=exports.getCodeSample=void 0;var tslib_1=require("tslib"),query_string_1=require("query-string"),Sampler=(0,tslib_1.__importStar)(require("openapi-sampler")),deepmerge_1=(0,tslib_1.__importDefault)(require("deepmerge")),mobx_1=require("mobx"),redoc_lib_1=require("../../redoc-lib"),utils_1=require("../../utils"),utils_2=require("../utils"),types_1=require("../../types"),Labels_1=require("../../redoc-lib/src/services/Labels"),httpsnippet_1=require("./httpsnippet"),string_utility_1=(0,tslib_1.__importDefault)(require("./httpsnippet/helpers/string-utility"));function mapOperationToHAR(e,t){var a,r,i,s,l,n,o,u,p,d,c=t.exampleName,_=void 0===c?"":c,m=t.skipOptionalParameters,v=void 0!==m&&m,h=t.withOAuth2Call,y=void 0!==h&&h,f=t.spec,g=t.generatedPayloadSamplesMaxDepth,O=void 0===g?8:g,b=t.pathParams,T=void 0===b?{}:b,S=t.properties,C=void 0===S?{}:S,q=getSecurityData(null===(a=e.security)||void 0===a?void 0:a[0],y),E=q.securityHeaders,D=q.securityCookies,A=q.securityQueries,x=q.securityOAuth2ExtraCalls,P=q.basicAuth,R=null===(i=null===(r=e.requestBody)||void 0===r?void 0:r.content)||void 0===i?void 0:i.active,w={skipNonRequired:v,skipReadOnly:!0,maxSampleDepth:O},k={path:(0,mobx_1.toJS)(null===(s=null==e?void 0:e.requestValues)||void 0===s?void 0:s.path),cookie:(0,mobx_1.toJS)(null===(l=null==e?void 0:e.requestValues)||void 0===l?void 0:l.cookie),header:(0,mobx_1.toJS)(null===(n=null==e?void 0:e.requestValues)||void 0===n?void 0:n.header),query:(0,mobx_1.toJS)(null===(o=null==e?void 0:e.requestValues)||void 0===o?void 0:o.query),body:(0,mobx_1.toJS)(null===(u=null==e?void 0:e.requestValues)||void 0===u?void 0:u.body)},H=!1,M=e.parameters.filter((function(e){return"header"===e.in})).filter((function(e){return!(v&&!e.required)})).map((function(e){var t;return{name:e.name,value:(null===(t=k.header)||void 0===t?void 0:t[e.name])||(0,utils_1.getParameterValue)("header",e.name)||(0,redoc_lib_1.serializeParameterValue)(e,Sampler.sample(e.schema.rawSchema,w,f))}})).map((function(e){return(null==R?void 0:R.name)&&"content-type"===e.name.toLowerCase()&&(H=!0,e.value=R.name),e})).concat(E);!H&&(null==R?void 0:R.name)&&M.unshift({name:"Content-Type",value:null==R?void 0:R.name});var N,z=e.parameters.filter((function(e){return"cookie"===e.in})).filter((function(e){return!(v&&!e.required)})).map((function(e){return(0,query_string_1.parse)((0,redoc_lib_1.serializeParameterValue)(e,Sampler.sample(e.schema.rawSchema,w,f)))})).reduce((function(e,t){for(var a,r=0,i=Object.entries(t);r<i.length;r++){var s=i[r],l=s[0],n=s[1];e.push({name:l,value:String((null===(a=k.cookie)||void 0===a?void 0:a[l])||n)})}return e}),[]).concat(D),L=e.parameters.filter((function(e){return"query"===e.in})).filter((function(e){return!(v&&!e.required)})).map((function(e){return(0,query_string_1.parse)((0,redoc_lib_1.serializeParameterValue)(e,Sampler.sample(e.schema.rawSchema,w,f)))})).reduce((function(e,t){for(var a,r,i,s=0,l=Object.entries(t);s<l.length;s++){var n=l[s],o=n[0],u=n[1];e.push({name:o,value:(0,redoc_lib_1.isArrayOfObjects)(null===(a=k.query)||void 0===a?void 0:a[o])&&JSON.stringify((0,redoc_lib_1.deleteEmptyArrayItem)(null===(r=k.query)||void 0===r?void 0:r[o]))||String((null===(i=k.query)||void 0===i?void 0:i[o])||u)})}return e}),[]).concat(A),U=null===(p=e.activeServer)||void 0===p?void 0:p.url.replace(/\/$/,""),j=e.path.replace(/^\//,""),V=U.split("#")[0]+"/"+j,I=e.parameters.filter((function(e){return"path"===e.in})).reduce((function(e,t){var a,r=t.in,i=t.name;return e[i]=(null===(a=k.path)||void 0===a?void 0:a[i])||T[i]||(0,utils_1.getParameterValue)(r,i),e}),{}),J=null===(d=null==R?void 0:R.examples)||void 0===d?void 0:d[_],Y=(null==R?void 0:R.examples)||{},F=Object.values(Y)[0],B=k.body||(null==J?void 0:J.value)||(null==F?void 0:F.value)||(null==R?void 0:R.schema)&&Sampler.sample(null==R?void 0:R.schema.rawSchema,w,f),K=null==R?void 0:R.name.toLowerCase(),Q=[];switch((0,utils_2.normalizeMimeType)(K)){case types_1.MediaTypes.JSON:case types_1.MediaTypes.XML:N=JSON.stringify(getDataRequest(B,C));break;case types_1.MediaTypes.URL_ENCODED:case types_1.MediaTypes.MULTIPART:N=(0,query_string_1.stringify)(getDataRequest(B,C)),Q=objectToHarParams(getDataRequest(B,C));break;default:N=String(B||"")}var G=N?{mimeType:(null==R?void 0:R.name)||types_1.MediaTypes.OCTET_STREAM,text:N,params:Q}:void 0,X=e.responses.map((function(e){return e.code}));return{method:e.httpVerb,url:V,httpVersion:"HTTP/1.1",cookies:z,headers:M,queryString:L,postData:G,headersSize:-1,bodySize:-1,securityOAuth2ExtraCalls:x,basicAuth:P,pathParameters:I,serverVariables:e.activeServer.variables,allResponseCodes:X}}var defaultOptions={withImports:!0,withComments:!1},langToSnippetConfig={curl:{code:"shell",defaultTarget:"curl",defaultOptions:(0,tslib_1.__assign)((0,tslib_1.__assign)({},defaultOptions),{short:!0})},JavaScript:{code:"javascript",defaultTarget:"fetch",defaultOptions:(0,tslib_1.__assign)((0,tslib_1.__assign)({},defaultOptions),{withImports:!1})},"Node.js":{code:"node",defaultTarget:"fetch",defaultOptions:(0,tslib_1.__assign)({},defaultOptions)},Python:{code:"python",defaultTarget:"requests",defaultOptions:(0,tslib_1.__assign)({},defaultOptions)},"Java8+Apache":{code:"java8",defaultTarget:"apachehttp",defaultOptions:(0,tslib_1.__assign)({},defaultOptions)},Java:{code:"java",defaultTarget:"httpclient",defaultOptions:(0,tslib_1.__assign)({},defaultOptions)},"C#":{code:"csharp",defaultTarget:"httpclient",defaultOptions:(0,tslib_1.__assign)({},defaultOptions)},Go:{code:"go",defaultTarget:"http.DefaultClient",defaultOptions:(0,tslib_1.__assign)({},defaultOptions)},PHP:{code:"php",defaultTarget:"curl",defaultOptions:(0,tslib_1.__assign)({},defaultOptions)},Ruby:{code:"ruby",defaultTarget:"net::http",defaultOptions:(0,tslib_1.__assign)({},defaultOptions)},R:{code:"r",defaultTarget:"httr",defaultOptions:(0,tslib_1.__assign)({},defaultOptions)}};function getCodeSample(e){var t=e.lang,a=e.operation,r=e.exampleName,i=e.pathParams,s=e.properties,l=e.options,n=void 0===l?{}:l;try{var o=mapOperationToHAR(a,{exampleName:r,pathParams:i,properties:s,skipOptionalParameters:n.skipOptionalParameters,withOAuth2Call:n.withOAuth2Call,spec:n.spec,generatedPayloadSamplesMaxDepth:n.generatedPayloadSamplesMaxDepth}),u=new httpsnippet_1.HTTPSnippet(o);return langToSnippetConfig[t]?u.convert(langToSnippetConfig[t].code,langToSnippetConfig[t].defaultTarget,(0,tslib_1.__assign)((0,tslib_1.__assign)({},langToSnippetConfig[t].defaultOptions),n)):"Language is not supported."}catch(e){return console.error(e),"Failed to generate code sample."}}function getSecurityData(e,t){for(var a,r,i,s,l={securityHeaders:[],securityCookies:[],securityQueries:[],securityOAuth2ExtraCalls:[],basicAuth:void 0},n=0,o=(null==e?void 0:e.schemes)||[];n<o.length;n++){var u=o[n],p=(0,utils_1.getSecurityDetails)(u.id);switch(u.type){case"openIdConnect":null===(a=l.securityHeaders)||void 0===a||a.push({name:"Authorization",value:"Bearer <YOUR_TOKEN_HERE>"});break;case"oauth2":var d=p.token?(p.token.token_type||"Bearer")+" "+p.token.access_token:"Bearer <YOUR_TOKEN_HERE>";u.flows.clientCredentials&&t?l.securityOAuth2ExtraCalls.push(getOAuth2ClientCredsCallHar(u.flows.clientCredentials,u.scopes,p)):u.flows.password&&t&&l.securityOAuth2ExtraCalls.push(getOAuth2PasswordCallHar(u.flows.password,u.scopes,p)),null===(r=l.securityHeaders)||void 0===r||r.push({name:"Authorization",value:d});break;case"apiKey":var c=p.raw||"YOUR_API_KEY_HERE";"header"===u.in&&(null===(i=l.securityHeaders)||void 0===i||i.push({name:u.name,value:c})),"cookie"===u.in&&l.securityCookies.push({name:u.name,value:c}),"query"===u.in&&l.securityQueries.push({name:u.name,value:c});break;case"http":"basic"===u.scheme?l.basicAuth={username:p.username||"<"+string_utility_1.default.toSnakeCase((0,Labels_1.l)("tryItAuthBasicUsername"))+">",password:p.password||"<"+string_utility_1.default.toSnakeCase((0,Labels_1.l)("tryItAuthBasicPassword"))+">"}:null===(s=l.securityHeaders)||void 0===s||s.push({name:"Authorization",value:capitalizeFirst(u.scheme||"bearer")+" <YOUR_"+(u.bearerFormat||"TOKEN")+"_HERE>"})}}return l}function getOAuth2PasswordCallHar(e,t,a){return{method:"POST",url:e.tokenUrl,httpVersion:"HTTP/1.1",headers:[{name:"Content-Type",value:types_1.MediaTypes.URL_ENCODED},{name:"Accept",value:types_1.MediaTypes.JSON}],queryString:[],postData:{mimeType:types_1.MediaTypes.URL_ENCODED,text:"",params:[{name:"grant_type",value:"password"},{name:"client_id",value:a.client_id||"YOUR_CLIENT_ID"},{name:"client_secret",value:a.client_secret||"YOUR_CLIENT_SECRET"},{name:"username",value:a.username||"<username>"},{name:"password",value:a.password||"<password>"},t.length?{name:"scope",value:t.join(" ")}:void 0].filter(isDefined)},cookies:[],headersSize:-1,bodySize:-1,securityOAuth2ExtraCalls:[]}}function getOAuth2ClientCredsCallHar(e,t,a){return{method:"POST",url:e.tokenUrl,httpVersion:"HTTP/1.1",headers:[{name:"Content-Type",value:types_1.MediaTypes.URL_ENCODED},{name:"Accept",value:types_1.MediaTypes.JSON}],queryString:[],postData:{mimeType:types_1.MediaTypes.URL_ENCODED,text:"",params:[{name:"grant_type",value:"client_credentials"},{name:"client_id",value:a.client_id||"YOUR_CLIENT_ID"},{name:"client_secret",value:a.client_secret||"YOUR_CLIENT_SECRET"},t.length?{name:"scope",value:t.join(" ")}:void 0].filter(isDefined)},cookies:[],headersSize:-1,bodySize:-1,securityOAuth2ExtraCalls:[]}}function getDataRequest(e,t){if(e){if("object"==typeof e)return(0,deepmerge_1.default)(e,t,{arrayMerge:utils_2.arrayMergeStrategy});try{return(0,deepmerge_1.default)(JSON.parse(e),t,{arrayMerge:utils_2.arrayMergeStrategy})}catch(e){return!1}}return!1}function objectToHarParams(e,t){void 0===t&&(t="");for(var a=[],r=0,i=Object.entries(e);r<i.length;r++){var s=i[r],l=s[0],n=s[1],o=t?t+"["+l+"]":l;"object"==typeof n&&null!==n?a.push.apply(a,objectToHarParams(n,o)):a.push({name:o,value:String(n)})}return a}function isDefined(e){return void 0!==e}function capitalizeFirst(e){return e.charAt(0).toUpperCase()+e.slice(1)}exports.getCodeSample=getCodeSample,exports.isDefined=isDefined,exports.capitalizeFirst=capitalizeFirst;
2
2
  //# sourceMappingURL=generator.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PushStateHistoryService=void 0;var tslib_1=require("tslib"),decko_1=require("decko"),eventemitter3_1=(0,tslib_1.__importDefault)(require("eventemitter3")),redoc_lib_1=require("../../redoc-lib"),helpers_1=require("./helpers"),PushStateHistoryService=function(){function e(e,t){var i=this;Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"multispec",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_emiter",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"basePath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"markdownItemsPagination",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pagination",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"emit",{enumerable:!0,configurable:!0,writable:!0,value:function(){i._emiter.emit("popstate",i.currentId)}});var r=e.routingBasePath;this.markdownItemsPagination=e.markdownItemsPagination,this.pagination=e.pagination,this.basePath=r.endsWith("/")?r.substring(0,r.length-1):r,this.basePath.startsWith("/")&&(this.basePath=this.basePath.substring(1)),this._emiter=new eventemitter3_1.default,this.bind()}return Object.defineProperty(e.prototype,"currentId",{get:function(){if(!redoc_lib_1.IS_BROWSER)return"";var e=decodeURIComponent(window.location.hash.substr(1)),t=window.location.pathname.substring(1);if(t.startsWith(this.basePath+"/")&&(t=t.substring(this.basePath.length+1)),t.endsWith("/")&&(t=t.substring(0,t.length-1)),null==e?void 0:e.startsWith("section/")){if(this.multispec){var i=t.split("/")[0];return(0,helpers_1.joinWithSeparator)(i,e)}return(0,helpers_1.joinWithSeparator)(t,e)}return(null==e?void 0:e.startsWith("operation/"))?(0,helpers_1.joinWithSeparator)(t,e):t?"item"===this.pagination&&e.startsWith(this.options.deepLinkPrefix)?(0,helpers_1.joinWithSeparator)(t,e,this.options.deepLinkPrefix):(0,helpers_1.joinWithSeparator)(t,e):e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"makeUrl",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var i,r="";return redoc_lib_1.IS_BROWSER&&(r=window.location.search),(i=e.startsWith("/")?"/"+(0,helpers_1.joinWithSeparator)(this.basePath,e.substring(1),"/"):e)+r?(0,helpers_1.joinWithSeparator)(i+r,t,"#"):"#"+t}}),Object.defineProperty(e.prototype,"generateDeepLink",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return t?t+("item"===this.options.pagination?"#":"")+this.options.deepLinkPrefix+e:null}}),Object.defineProperty(e.prototype,"linkForId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(void 0===e&&(e=""),""===e)return this.makeUrl("/","");var t="";if(this.multispec&&(t="/"+e.split("/")[0],e=e.split("/").slice(1).join("/")),e.startsWith("operation/")){if(this.multispec&&redoc_lib_1.IS_BROWSER){var i=window.location.pathname.substring(1);i.startsWith(this.basePath)&&(i=i.substring(this.basePath.length)).startsWith("/")&&(i=i.substring(1));var r="/"+i.split("/")[0];return t===r?this.makeUrl("",e):this.makeUrl(i.replace(r,t),e)}return this.makeUrl("",e)}var n,o=t,a="";if(e.startsWith("section/")||!e){var s=(e||"").split("/")[1];s&&"section"===this.markdownItemsPagination?(o=t+"/section/"+s,a=e):(o=t+"/",a=e)}if(e.startsWith("group/")){var l=e.match(/group\/(.*)\/(paths\/.*\/\w+|operation\/[^/]*)/);if(l)o=t+"/group/"+l[1],a=l[2]||"";else o=t+"/"+e,a=""}"section"===this.pagination&&e.startsWith("tag/")&&(o=t+"/"+(n=e.split("/")).slice(0,2).join("/"),a=n.slice(2).join("/"));"item"===this.pagination&&e.startsWith("tag/")&&(o=t+"/"+e,"section"===(n=e.split("/"))[2]&&(o=t+"/"+n.slice(0,2).join("/"),a=n.slice(2).join("/")));return this.makeUrl(o,a)}}),Object.defineProperty(e.prototype,"subscribe",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this._emiter.addListener("popstate",e);return function(){return t.removeListener("popstate",e)}}}),Object.defineProperty(e.prototype,"bind",{enumerable:!1,configurable:!0,writable:!0,value:function(){redoc_lib_1.IS_BROWSER&&window.addEventListener("popstate",this.emit,!1)}}),Object.defineProperty(e.prototype,"dispose",{enumerable:!1,configurable:!0,writable:!0,value:function(){redoc_lib_1.IS_BROWSER&&window.removeEventListener("popstate",this.emit)}}),Object.defineProperty(e.prototype,"replace",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(void 0===t&&(t=!1),t)return this.replaceDebounced(e);this.replaceNow(e,t)}}),Object.defineProperty(e.prototype,"replaceForField",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(void 0===t&&(t=!1),redoc_lib_1.IS_BROWSER&&e){var i,r=new URL(e,window.location.href);i=r,t&&window.history.replaceState(null,"",i),window.history.pushState(null,"",i),this.emit()}}}),Object.defineProperty(e.prototype,"replaceNow",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(void 0===t&&(t=!1),redoc_lib_1.IS_BROWSER&&null!=e&&!(0,helpers_1.isSameHash)(e,this.currentId)){var i=new URL(this.linkForId(e),window.location.href);t?redoc_lib_1.IS_BROWSER&&window.history.replaceState(null,"",i.href):redoc_lib_1.IS_BROWSER&&(window.history.pushState(null,"",i.href),this.emit())}}}),Object.defineProperty(e.prototype,"replaceDebounced",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.replaceNow(e,!0)}}),(0,tslib_1.__decorate)([decko_1.bind],e.prototype,"replace",null),(0,tslib_1.__decorate)([decko_1.bind],e.prototype,"replaceForField",null),(0,tslib_1.__decorate)([decko_1.bind,decko_1.debounce],e.prototype,"replaceDebounced",null),e}();exports.PushStateHistoryService=PushStateHistoryService;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PushStateHistoryService=void 0;var tslib_1=require("tslib"),decko_1=require("decko"),eventemitter3_1=(0,tslib_1.__importDefault)(require("eventemitter3")),redoc_lib_1=require("../../redoc-lib"),helpers_1=require("./helpers"),PushStateHistoryService=function(){function e(e,t){var i=this;Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"multispec",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_emiter",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"basePath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"markdownItemsPagination",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pagination",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"emit",{enumerable:!0,configurable:!0,writable:!0,value:function(){i._emiter.emit("popstate",i.currentId)}});var r=e.routingBasePath;this.markdownItemsPagination=e.markdownItemsPagination,this.pagination=e.pagination,this.basePath=r.endsWith("/")?r.substring(0,r.length-1):r,this.basePath.startsWith("/")&&(this.basePath=this.basePath.substring(1)),this._emiter=new eventemitter3_1.default,this.bind()}return Object.defineProperty(e.prototype,"currentId",{get:function(){if(!redoc_lib_1.IS_BROWSER)return"";var e=decodeURIComponent(window.location.hash.substr(1)),t=window.location.pathname.substring(1);return t.startsWith(this.basePath+"/")&&(t=t.substring(this.basePath.length+1)),t.endsWith("/")&&(t=t.substring(0,t.length-1)),(null==e?void 0:e.startsWith("section/"))||(null==e?void 0:e.startsWith("operation/"))?(0,helpers_1.joinWithSeparator)(t,e):t?"item"===this.pagination&&e.startsWith(this.options.deepLinkPrefix)?(0,helpers_1.joinWithSeparator)(t,e,this.options.deepLinkPrefix):(0,helpers_1.joinWithSeparator)(t,e):e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"makeUrl",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var i,r="";return redoc_lib_1.IS_BROWSER&&(r=window.location.search),(i=e.startsWith("/")?"/"+(0,helpers_1.joinWithSeparator)(this.basePath,e.substring(1),"/"):e)+r?(0,helpers_1.joinWithSeparator)(i+r,t,"#"):"#"+t}}),Object.defineProperty(e.prototype,"generateDeepLink",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return t?t+("item"===this.options.pagination?"#":"")+this.options.deepLinkPrefix+e:null}}),Object.defineProperty(e.prototype,"linkForId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(void 0===e&&(e=""),""===e)return this.makeUrl("/","");var t="";if(this.multispec&&(t="/"+e.split("/")[0],e=e.split("/").slice(1).join("/")),e.startsWith("operation/")){if(this.multispec&&redoc_lib_1.IS_BROWSER){var i=window.location.pathname.substring(1);i.startsWith(this.basePath)&&(i=i.substring(this.basePath.length)).startsWith("/")&&(i=i.substring(1));var r="/"+i.split("/")[0];return t===r?this.makeUrl("",e):this.makeUrl(i.replace(r,t),e)}return this.makeUrl("",e)}var n,o=t,a="";if(e.startsWith("section/")||!e){var s=(e||"").split("/")[1];s&&"section"===this.markdownItemsPagination?(o=t+"/section/"+s,a=e):(o=t+"/",a=e)}if(e.startsWith("group/")){var l=e.match(/group\/(.*)\/(paths\/.*\/\w+|operation\/[^/]*)/);if(l)o=t+"/group/"+l[1],a=l[2]||"";else o=t+"/"+e,a=""}"section"===this.pagination&&e.startsWith("tag/")&&(o=t+"/"+(n=e.split("/")).slice(0,2).join("/"),a=n.slice(2).join("/"));"item"===this.pagination&&e.startsWith("tag/")&&(o=t+"/"+e,"section"===(n=e.split("/"))[2]&&(o=t+"/"+n.slice(0,2).join("/"),a=n.slice(2).join("/")));return this.makeUrl(o,a)}}),Object.defineProperty(e.prototype,"subscribe",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this._emiter.addListener("popstate",e);return function(){return t.removeListener("popstate",e)}}}),Object.defineProperty(e.prototype,"bind",{enumerable:!1,configurable:!0,writable:!0,value:function(){redoc_lib_1.IS_BROWSER&&window.addEventListener("popstate",this.emit,!1)}}),Object.defineProperty(e.prototype,"dispose",{enumerable:!1,configurable:!0,writable:!0,value:function(){redoc_lib_1.IS_BROWSER&&window.removeEventListener("popstate",this.emit)}}),Object.defineProperty(e.prototype,"replace",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(void 0===t&&(t=!1),t)return this.replaceDebounced(e);this.replaceNow(e,t)}}),Object.defineProperty(e.prototype,"replaceForField",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(void 0===t&&(t=!1),redoc_lib_1.IS_BROWSER&&e){var i,r=new URL(e,window.location.href);i=r,t&&window.history.replaceState(null,"",i),window.history.pushState(null,"",i),this.emit()}}}),Object.defineProperty(e.prototype,"replaceNow",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(void 0===t&&(t=!1),redoc_lib_1.IS_BROWSER&&null!=e&&!(0,helpers_1.isSameHash)(e,this.currentId)){var i=new URL(this.linkForId(e),window.location.href);t?redoc_lib_1.IS_BROWSER&&window.history.replaceState(null,"",i.href):redoc_lib_1.IS_BROWSER&&(window.history.pushState(null,"",i.href),this.emit())}}}),Object.defineProperty(e.prototype,"replaceDebounced",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.replaceNow(e,!0)}}),(0,tslib_1.__decorate)([decko_1.bind],e.prototype,"replace",null),(0,tslib_1.__decorate)([decko_1.bind],e.prototype,"replaceForField",null),(0,tslib_1.__decorate)([decko_1.bind,decko_1.debounce],e.prototype,"replaceDebounced",null),e}();exports.PushStateHistoryService=PushStateHistoryService;
2
2
  //# sourceMappingURL=PushStateHistoryService.js.map
package/lib/types.d.ts CHANGED
@@ -23,3 +23,7 @@ export declare type SecurityDetails = {
23
23
  client_secret?: string;
24
24
  scopes?: string;
25
25
  };
26
+ export declare type RequestAuth = {
27
+ Authorization?: string;
28
+ Cookie?: string;
29
+ };
@@ -1,2 +1,2 @@
1
- import{__assign,__awaiter,__decorate,__extends,__generator,__rest}from"tslib";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";import{Form,useField}from"informed";import{observer}from"mobx-react";import Swagger from"swagger-client";import{Component}from"react";import{unescapeFormId}from"../../utils";import{JsonPointer}from"../../redoc-lib";import{RenderHook}from"../../redoc-lib/src/components/RenderHook";import{l}from"../../redoc-lib/src/services/Labels";import{CodeHeader,Accordion}from"../Panel";import{OAuth2}from"../../services/OAuth2";import{isFileUploadMime}from"../common/FileUpload/helper";import{OperationParameters}from"../OperationParameters";import{useDimensions}from"../../hooks";import{AnalyticsEventType}from"../../events";import{getFileNameFromHeaders,getParameters,makeRequestInterceptor,unescapeQueryParams,updateStorage}from"./utils";import{AuthPanel,requiredValidator}from"./AuthPanel";import{ConsoleBadges}from"./ConsoleBadges";import{RequestBody}from"./RequestBody";import{ResponsePanel}from"./ResponsePanel";import{ActionPanel}from"./ActionPanel";import{ServersDropdown}from"./ServersDropdown";import{TryItPanel}from"./TryItPanel";import{CloseButton,ConsoleBody,ConsoleWrap}from"./styled";function normalizeUrlProtocol(e){return e.startsWith("//")?"https:"+e:e}var flexColumn={flex:1,display:"flex",flexDirection:"column"},Console=function(e){function r(r){var t=e.call(this,r)||this;return Object.defineProperty(t,"formApi",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(t,"setFormApi",{enumerable:!0,configurable:!0,writable:!0,value:function(e){t.formApi=e;var r=e.getState(),o=r.values,s=__rest(r,["values"]);setTimeout((function(){var e=__assign(__assign({},s),{values:__assign(__assign({},o),{query:unescapeQueryParams(o.query||{})})});t.setState({form:e})}),0)}}),Object.defineProperty(t,"handleValueChange",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var r=__assign(__assign({},e),{query:unescapeQueryParams(e.query||{})});t.setState((function(e){return{form:__assign(__assign({},e.form),{values:r})}}),(function(){updateStorage(t.state.form),t.props.operation.setRequestValues(e)}))}}),Object.defineProperty(t,"handleTabChange",{enumerable:!0,configurable:!0,writable:!0,value:function(e){t.setState({activeTab:e})}}),Object.defineProperty(t,"handleServerChange",{enumerable:!0,configurable:!0,writable:!0,value:function(e){t.setState({server:e}),t.props.operation.setActiveServer(e)}}),Object.defineProperty(t,"handleExecute",{enumerable:!0,configurable:!0,writable:!0,value:function(){return __awaiter(t,void 0,void 0,(function(){var e,r,t,o,s,n,a,i,l,u,d,p,c,h,m,v,_,g,f,y,b,P,x,S,j,C,A,w,I,k,q,T,O,R,F,B,H,V,D,E,U,N,W=this;return __generator(this,(function(z){switch(z.label){case 0:if(e=this.props,r=e.store,t=e.operation,o=e.onResponse,null===(O=this.formApi)||void 0===O||O.submitForm(),((null===(R=this.formApi)||void 0===R?void 0:R.getState())||this.state.form).invalid)return this.setState({shaking:!0}),setTimeout((function(){return W.setState({shaking:!1})}),1e3),null===(B=null===(F=null==r?void 0:r.options.events)||void 0===F?void 0:F.tryItSent)||void 0===B||B.call(F,{eventType:AnalyticsEventType.TryItSent,resource:"Redocly_OperationTryIt",action:"ValidationFailed",operationId:t.operationId,operationPath:t.path,operationHttpVerb:t.httpVerb,operationSummary:t.description}),[2];if(s=(this.state.form||(null===(H=this.formApi)||void 0===H?void 0:H.getState())).values,n=this.props.operation,a=n.servers,i=n.requestBody,l=i&&i.content&&i.content.active&&i.content.active.name||"",u=s.body,/json/.test(l))try{u=JSON.parse(u)}catch(e){console.error(e)}if(this.setState({loading:!0}),d=this.state.resolvedRawSpec,p=(t.httpVerb||"").toLowerCase(),!a)throw console.error("Servers are not specified in your OpenAPI file. You can't use Try It Out console without specifying servers. If you use OpenAPI 2, make sure you configured host and basepath"),new Error("Servers are not specified");c=a.find((function(e){return W.state.server.url.endsWith(e.url.endsWith("/")?e.url.substring(0,e.url.length-1):e.url)})),h=Date.now(),m=!!window.document.documentMode,_=s.auth,s.auth?(g=Object.keys(s.auth)[0],f=unescapeFormId(g),v=__assign(__assign({},d),{components:__assign(__assign({},null==d?void 0:d.components),{securitySchemes:__assign(__assign({},null==d?void 0:d.components.securitySchemes),(I={},I[f]=__assign(__assign({},null==d?void 0:d.components.securitySchemes[f]),{type:"openIdConnect"===(null==d?void 0:d.components.securitySchemes[f].type)?"oauth2":null==d?void 0:d.components.securitySchemes[f].type}),I))})}),_=__assign(__assign({},_),((k={})[f]=_[g],k))):v=__assign({},d),v.servers=a,(y=r.options.corsProxyUrl)&&a.length&&(v.servers=a.map((function(e){return __assign(__assign({},e),{url:y+normalizeUrlProtocol(e.url)})})),v.paths=__assign(__assign({},v.paths),((q={})[t.path]=__assign(__assign({},v.paths[t.path]),((T={})[p]=__assign(__assign({},v.paths[t.path][p]),{servers:void 0}),T.servers=void 0,T)),q))),(b=(null===(D=null===(V=null==i?void 0:i.content)||void 0===V?void 0:V.active)||void 0===D?void 0:D.name)||null)&&u&&isFileUploadMime(b)&&(P=Object.values(u),u=P.length>1?P:P[0]),x={userFetch:m&&require("cross-fetch").fetch,server:y?y+normalizeUrlProtocol(c.url):c.url,serverVariables:this.state.server.variables,spec:v,pathName:t.path,method:t.httpVerb,parameters:__assign(__assign(__assign(__assign({},s.path),s.query),s.header),s.cookie),securities:{authorized:_},requestBody:u,requestContentType:b,responseContentType:(null===(E=s.header)||void 0===E?void 0:E.Accept)||null,requestInterceptor:makeRequestInterceptor(r.options,t,null==_?void 0:_.Authorization)},z.label=1;case 1:return z.trys.push([1,5,8,9]),[4,Swagger.execute(x)];case 2:return S=z.sent(),(j=null==S?void 0:S.data)instanceof Blob?(isFileUploadMime(j.type)&&(S.fileInfo={rawData:j,fileName:getFileNameFromHeaders(S.headers)}),C=S,[4,j.text()]):[3,4];case 3:C.data=z.sent(),z.label=4;case 4:return null==o||o({request:x,response:S}),this.setState({response:S,error:void 0}),[3,9];case 5:return(A=z.sent())&&A.response&&A.response.data instanceof Blob?(w=A.response,[4,A.response.data.text()]):[3,7];case 6:w.data=z.sent(),null==o||o({request:x,response:A.response}),z.label=7;case 7:return this.setState({response:void 0,error:A}),[3,9];case 8:return this.setState({loading:!1,activeTab:1,time:Date.now()-h}),null===(N=null===(U=null==r?void 0:r.options.events)||void 0===U?void 0:U.tryItSent)||void 0===N||N.call(U,{eventType:AnalyticsEventType.TryItSent,resource:"Redocly_OperationTryIt",action:"Sent",operationId:t.operationId,operationPath:t.path,operationHttpVerb:t.httpVerb,operationSummary:t.description}),[7];case 9:return[2]}}))}))}}),t.state={form:{values:{path:getParameters(r.operation.parameters,"path"),cookie:getParameters(r.operation.parameters,"cookie"),header:getParameters(r.operation.parameters,"header"),query:getParameters(r.operation.parameters,"query")}},shaking:!1,loading:!1,activeTab:0,server:{}},t}return __extends(r,e),Object.defineProperty(r.prototype,"componentDidMount",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e;return __awaiter(this,void 0,void 0,(function(){var r,t,o,s;return __generator(this,(function(n){switch(n.label){case 0:return r=this.props,t=r.store,o=r.operation,[4,t.dereferenceSpecForTryIt(o)];case 1:return s=n.sent(),this.setState({resolvedRawSpec:s}),null===(e=this.formApi)||void 0===e||e.setValues({}),[2]}}))}))}}),Object.defineProperty(r.prototype,"componentDidUpdate",{enumerable:!1,configurable:!0,writable:!0,value:function(e){e.operation!==this.props.operation&&this.setState({response:void 0,error:void 0,activeTab:0})}}),Object.defineProperty(r.prototype,"render",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.props,r=e.operation,t=e.className,o=e.rootElement,s=this.state,n=s.shaking,a=s.activeTab,i=s.form,l=s.response,u=s.loading,d=s.error,p=!(!l&&!d);return _jsxs(ConsoleWrapHook,__assign({shaking:n,className:t,rootElement:o},{children:[_jsxs(CodeHeader,{children:[_jsx(ConsoleBadges,{active:a,hasResponse:p,onChange:this.handleTabChange},void 0),this.props.onClose&&_jsx(CloseButton,__assign({onClick:this.props.onClose},{children:" ✕ "}),void 0)]},void 0),_jsx(ConsoleBody,__assign({hidden:0!==a,"data-cy":"console-request-body"},{children:this.renderRequest()}),void 0),_jsx(ConsoleBody,__assign({hidden:1!==a,"data-cy":"console-response-body"},{children:this.renderResponse()}),void 0),_jsx(ActionPanel,{hasResponse:p,params:i.values,operation:r,loading:u,execute:this.handleExecute},void 0)]}),void 0)}}),Object.defineProperty(r.prototype,"renderRequest",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e,r=this.props,t=r.operation,o=r.store,s=r.properties,n=r.securityDefaults,a=this.state,i=a.form,u=a.resolvedRawSpec,d=a.server,p=i.errors||{},c=p.path||p.cookie||p.header||p.query,h=u&&JsonPointer.get(u,t.pointer),m=i.values&&i.values.auth&&Object.keys(i.values.auth)[0];m&&i.values.auth[m]||(m=void 0),!m||void 0===i.values.auth[m].token&&void 0===i.values.auth[m].client_id&&void 0===i.values.auth[m].client_secret||i.values.auth[m].token&&i.values.auth[m].token.access_token||(m=void 0),m&&null!=i.values.auth[m].username&&(i.values.auth[m].username&&i.values.auth[m].password||(m=void 0));var v=t.parameters||[],_=null===(e=null==o?void 0:o.options.hooks)||void 0===e?void 0:e.ReplaceTryItSecurityPanel;return!u&&_jsx(_Fragment,{children:"Loading..."},void 0)||_jsxs(Form,__assign({onValueChange:this.handleValueChange,getApi:this.setFormApi,style:__assign(__assign({},flexColumn),{margin:0})},{children:[_jsx(ServersDropdown,{operation:t,onChange:this.handleServerChange},void 0),_jsxs(Accordion,__assign({initialActiveIdx:t.security.length&&m?1:0},{children:[t.security.length&&this.formApi&&_jsx(TryItPanel,__assign({header:l("tryItAuth"),"data-cy":"security-trigger",renderChildrenHidden:!0,error:!m&&!!p.auth,success:!!m},{children:_?_jsx(AuthPanelHook,__assign({field:"auth",validate:requiredValidator},{children:function(e){return _jsx(RenderHook,{Hook:_,props:{server:d,operation:t,onChange:e,OAuth2:OAuth2}},void 0)}}),void 0):_jsx(AuthPanel,{formApi:this.formApi,form:i,operation:t,activeServer:d.url,authCorsProxyUrl:o.options.authCorsProxyUrl,securityDefaults:n},void 0)}),void 0)||null,t.requestBody&&this.formApi&&_jsx(TryItPanel,__assign({header:l("tryItBody"),"data-cy":"body-trigger",renderChildrenHidden:!0,error:!!p.body},{children:_jsx(RequestBody,{validate:allowBodyErrors,formApi:this.formApi,body:t.requestBody,id:t.id,resolvedBody:null==h?void 0:h.requestBody,properties:s},void 0)}),void 0)||null,v.length&&_jsx(TryItPanel,__assign({header:l("tryItParameters"),"data-cy":"parameters-trigger",error:c,renderChildrenHidden:!0},{children:_jsx(OperationParameters,{operation:t,values:i.values,errors:i.errors||{}},void 0)}),void 0)||null]}),void 0)]}),void 0)}}),Object.defineProperty(r.prototype,"renderResponse",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.state,r=e.response,t=e.error,o=e.time;return _jsx(ResponsePanel,{response:r,error:t,time:o},void 0)}}),r=__decorate([observer],r)}(Component);export{Console};function allowBodyErrors(){}function ConsoleWrapHook(e){var r=e.shaking,t=e.className,o=e.children,s=e.rootElement,n=useDimensions(s)[0];return _jsx(ConsoleWrap,__assign({shaking:r,className:t,"data-cy":"console",fullWidth:null==n?void 0:n.width},{children:o}),void 0)}function AuthPanelHook(e){var r=useField(__assign({},e)),t=r.fieldApi,o=r.render,s=r.userProps,n=t.setValue,a=s.children;return o(_jsx(_Fragment,{children:a(n)},void 0))}
1
+ import{__assign,__awaiter,__decorate,__extends,__generator,__rest}from"tslib";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";import{Form,useField}from"informed";import{observer}from"mobx-react";import Swagger from"swagger-client";import{Component}from"react";import{unescapeFormId}from"../../utils";import{JsonPointer}from"../../redoc-lib";import{RenderHook}from"../../redoc-lib/src/components/RenderHook";import{l}from"../../redoc-lib/src/services/Labels";import{CodeHeader,Accordion}from"../Panel";import{OAuth2}from"../../services/OAuth2";import{isFileUploadMime}from"../common/FileUpload/helper";import{OperationParameters}from"../OperationParameters";import{useDimensions}from"../../hooks";import{AnalyticsEventType}from"../../events";import{getFileNameFromHeaders,getParameters,makeRequestInterceptor,unescapeQueryParams,updateStorage}from"./utils";import{AuthPanel,requiredValidator}from"./AuthPanel";import{ConsoleBadges}from"./ConsoleBadges";import{RequestBody}from"./RequestBody";import{ResponsePanel}from"./ResponsePanel";import{ActionPanel}from"./ActionPanel";import{ServersDropdown}from"./ServersDropdown";import{TryItPanel}from"./TryItPanel";import{CloseButton,ConsoleBody,ConsoleWrap}from"./styled";function normalizeUrlProtocol(e){return e.startsWith("//")?"https:"+e:e}var flexColumn={flex:1,display:"flex",flexDirection:"column"},Console=function(e){function r(r){var t=e.call(this,r)||this;return Object.defineProperty(t,"formApi",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(t,"setFormApi",{enumerable:!0,configurable:!0,writable:!0,value:function(e){t.formApi=e;var r=e.getState(),o=r.values,s=__rest(r,["values"]);setTimeout((function(){var e=__assign(__assign({},s),{values:__assign(__assign({},o),{query:unescapeQueryParams(o.query||{})})});t.setState({form:e})}),0)}}),Object.defineProperty(t,"handleValueChange",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var r=__assign(__assign({},e),{query:unescapeQueryParams(e.query||{})});t.setState((function(e){return{form:__assign(__assign({},e.form),{values:r})}}),(function(){updateStorage(t.state.form),t.props.operation.setRequestValues(e)}))}}),Object.defineProperty(t,"handleTabChange",{enumerable:!0,configurable:!0,writable:!0,value:function(e){t.setState({activeTab:e})}}),Object.defineProperty(t,"handleServerChange",{enumerable:!0,configurable:!0,writable:!0,value:function(e){t.setState({server:e}),t.props.operation.setActiveServer(e)}}),Object.defineProperty(t,"handleExecute",{enumerable:!0,configurable:!0,writable:!0,value:function(){return __awaiter(t,void 0,void 0,(function(){var e,r,t,o,s,n,a,i,l,u,d,p,c,m,h,v,_,g,f,y,b,P,S,x,C,j,A,w,k,I,q,T,O,R,F,B,H,V,D,E,U,N,W,M,z=this;return __generator(this,(function(J){switch(J.label){case 0:if(e=this.props,r=e.store,t=e.operation,o=e.onResponse,null===(F=this.formApi)||void 0===F||F.submitForm(),((null===(B=this.formApi)||void 0===B?void 0:B.getState())||this.state.form).invalid)return this.setState({shaking:!0}),setTimeout((function(){return z.setState({shaking:!1})}),1e3),null===(V=null===(H=null==r?void 0:r.options.events)||void 0===H?void 0:H.tryItSent)||void 0===V||V.call(H,{eventType:AnalyticsEventType.TryItSent,resource:"Redocly_OperationTryIt",action:"ValidationFailed",operationId:t.operationId,operationPath:t.path,operationHttpVerb:t.httpVerb,operationSummary:t.description}),[2];if(s=(this.state.form||(null===(D=this.formApi)||void 0===D?void 0:D.getState())).values,n=this.props.operation,a=n.servers,i=n.requestBody,l=i&&i.content&&i.content.active&&i.content.active.name||"",u=s.body,/json/.test(l))try{u=JSON.parse(u)}catch(e){console.error(e)}if(this.setState({loading:!0}),d=this.state.resolvedRawSpec,p=(t.httpVerb||"").toLowerCase(),!a)throw console.error("Servers are not specified in your OpenAPI file. You can't use Try It Out console without specifying servers. If you use OpenAPI 2, make sure you configured host and basepath"),new Error("Servers are not specified");c=a.find((function(e){return z.state.server.url.endsWith(e.url.endsWith("/")?e.url.substring(0,e.url.length-1):e.url)})),m=Date.now(),h=!!window.document.documentMode,_=s.auth,s.auth?(g=Object.keys(s.auth)[0],f=unescapeFormId(g),v=__assign(__assign({},d),{components:__assign(__assign({},null==d?void 0:d.components),{securitySchemes:__assign(__assign({},null==d?void 0:d.components.securitySchemes),(q={},q[f]=__assign(__assign({},null==d?void 0:d.components.securitySchemes[f]),{type:"openIdConnect"===(null==d?void 0:d.components.securitySchemes[f].type)?"oauth2":null==d?void 0:d.components.securitySchemes[f].type}),q))})}),y="cookie"===(null==d?void 0:d.components.securitySchemes[f].in)?"Cookie":f,b="cookie"===(null==d?void 0:d.components.securitySchemes[f].in)?(null==d?void 0:d.components.securitySchemes[f].name)+"="+_[g]:_[g],_=__assign(__assign({},_),((T={})[y]=b,T))):v=__assign({},d),v.servers=a,(P=r.options.corsProxyUrl)&&a.length&&(v.servers=a.map((function(e){return __assign(__assign({},e),{url:P+normalizeUrlProtocol(e.url)})})),v.paths=__assign(__assign({},v.paths),((O={})[t.path]=__assign(__assign({},v.paths[t.path]),((R={})[p]=__assign(__assign({},v.paths[t.path][p]),{servers:void 0}),R.servers=void 0,R)),O))),(S=(null===(U=null===(E=null==i?void 0:i.content)||void 0===E?void 0:E.active)||void 0===U?void 0:U.name)||null)&&u&&isFileUploadMime(S)&&(x=Object.values(u),u=x.length>1?x:x[0]),C={userFetch:h&&require("cross-fetch").fetch,server:P?P+normalizeUrlProtocol(c.url):c.url,serverVariables:this.state.server.variables,spec:v,pathName:t.path,method:t.httpVerb,parameters:__assign(__assign(__assign(__assign({},s.path),s.query),s.header),s.cookie),securities:{authorized:_},requestBody:u,requestContentType:S,responseContentType:(null===(N=s.header)||void 0===N?void 0:N.Accept)||null,requestInterceptor:makeRequestInterceptor(r.options,t,_)},J.label=1;case 1:return J.trys.push([1,5,8,9]),[4,Swagger.execute(C)];case 2:return j=J.sent(),(A=null==j?void 0:j.data)instanceof Blob?(isFileUploadMime(A.type)&&(j.fileInfo={rawData:A,fileName:getFileNameFromHeaders(j.headers)}),w=j,[4,A.text()]):[3,4];case 3:w.data=J.sent(),J.label=4;case 4:return null==o||o({request:C,response:j}),this.setState({response:j,error:void 0}),[3,9];case 5:return(k=J.sent())&&k.response&&k.response.data instanceof Blob?(I=k.response,[4,k.response.data.text()]):[3,7];case 6:I.data=J.sent(),null==o||o({request:C,response:k.response}),J.label=7;case 7:return this.setState({response:void 0,error:k}),[3,9];case 8:return this.setState({loading:!1,activeTab:1,time:Date.now()-m}),null===(M=null===(W=null==r?void 0:r.options.events)||void 0===W?void 0:W.tryItSent)||void 0===M||M.call(W,{eventType:AnalyticsEventType.TryItSent,resource:"Redocly_OperationTryIt",action:"Sent",operationId:t.operationId,operationPath:t.path,operationHttpVerb:t.httpVerb,operationSummary:t.description}),[7];case 9:return[2]}}))}))}}),t.state={form:{values:{path:getParameters(r.operation.parameters,"path"),cookie:getParameters(r.operation.parameters,"cookie"),header:getParameters(r.operation.parameters,"header"),query:getParameters(r.operation.parameters,"query")}},shaking:!1,loading:!1,activeTab:0,server:{}},t}return __extends(r,e),Object.defineProperty(r.prototype,"componentDidMount",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e;return __awaiter(this,void 0,void 0,(function(){var r,t,o,s;return __generator(this,(function(n){switch(n.label){case 0:return r=this.props,t=r.store,o=r.operation,[4,t.dereferenceSpecForTryIt(o)];case 1:return s=n.sent(),this.setState({resolvedRawSpec:s}),null===(e=this.formApi)||void 0===e||e.setValues({}),[2]}}))}))}}),Object.defineProperty(r.prototype,"componentDidUpdate",{enumerable:!1,configurable:!0,writable:!0,value:function(e){e.operation!==this.props.operation&&this.setState({response:void 0,error:void 0,activeTab:0})}}),Object.defineProperty(r.prototype,"render",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.props,r=e.operation,t=e.className,o=e.rootElement,s=this.state,n=s.shaking,a=s.activeTab,i=s.form,l=s.response,u=s.loading,d=s.error,p=!(!l&&!d);return _jsxs(ConsoleWrapHook,__assign({shaking:n,className:t,rootElement:o},{children:[_jsxs(CodeHeader,{children:[_jsx(ConsoleBadges,{active:a,hasResponse:p,onChange:this.handleTabChange},void 0),this.props.onClose&&_jsx(CloseButton,__assign({onClick:this.props.onClose},{children:" ✕ "}),void 0)]},void 0),_jsx(ConsoleBody,__assign({hidden:0!==a,"data-cy":"console-request-body"},{children:this.renderRequest()}),void 0),_jsx(ConsoleBody,__assign({hidden:1!==a,"data-cy":"console-response-body"},{children:this.renderResponse()}),void 0),_jsx(ActionPanel,{hasResponse:p,params:i.values,operation:r,loading:u,execute:this.handleExecute},void 0)]}),void 0)}}),Object.defineProperty(r.prototype,"renderRequest",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e,r=this.props,t=r.operation,o=r.store,s=r.properties,n=r.securityDefaults,a=this.state,i=a.form,u=a.resolvedRawSpec,d=a.server,p=i.errors||{},c=p.path||p.cookie||p.header||p.query,m=u&&JsonPointer.get(u,t.pointer),h=i.values&&i.values.auth&&Object.keys(i.values.auth)[0];h&&i.values.auth[h]||(h=void 0),!h||void 0===i.values.auth[h].token&&void 0===i.values.auth[h].client_id&&void 0===i.values.auth[h].client_secret||i.values.auth[h].token&&i.values.auth[h].token.access_token||(h=void 0),h&&null!=i.values.auth[h].username&&(i.values.auth[h].username&&i.values.auth[h].password||(h=void 0));var v=t.parameters||[],_=null===(e=null==o?void 0:o.options.hooks)||void 0===e?void 0:e.ReplaceTryItSecurityPanel;return!u&&_jsx(_Fragment,{children:"Loading..."},void 0)||_jsxs(Form,__assign({onValueChange:this.handleValueChange,getApi:this.setFormApi,style:__assign(__assign({},flexColumn),{margin:0})},{children:[_jsx(ServersDropdown,{operation:t,onChange:this.handleServerChange},void 0),_jsxs(Accordion,__assign({initialActiveIdx:t.security.length&&h?1:0},{children:[t.security.length&&this.formApi&&_jsx(TryItPanel,__assign({header:l("tryItAuth"),"data-cy":"security-trigger",renderChildrenHidden:!0,error:!h&&!!p.auth,success:!!h},{children:_?_jsx(AuthPanelHook,__assign({field:"auth",validate:requiredValidator},{children:function(e){return _jsx(RenderHook,{Hook:_,props:{server:d,operation:t,onChange:e,OAuth2:OAuth2}},void 0)}}),void 0):_jsx(AuthPanel,{formApi:this.formApi,form:i,operation:t,activeServer:d.url,authCorsProxyUrl:o.options.authCorsProxyUrl,securityDefaults:n},void 0)}),void 0)||null,t.requestBody&&this.formApi&&_jsx(TryItPanel,__assign({header:l("tryItBody"),"data-cy":"body-trigger",renderChildrenHidden:!0,error:!!p.body},{children:_jsx(RequestBody,{validate:allowBodyErrors,formApi:this.formApi,body:t.requestBody,id:t.id,resolvedBody:null==m?void 0:m.requestBody,properties:s},void 0)}),void 0)||null,v.length&&_jsx(TryItPanel,__assign({header:l("tryItParameters"),"data-cy":"parameters-trigger",error:c,renderChildrenHidden:!0},{children:_jsx(OperationParameters,{operation:t,values:i.values,errors:i.errors||{}},void 0)}),void 0)||null]}),void 0)]}),void 0)}}),Object.defineProperty(r.prototype,"renderResponse",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.state,r=e.response,t=e.error,o=e.time;return _jsx(ResponsePanel,{response:r,error:t,time:o},void 0)}}),r=__decorate([observer],r)}(Component);export{Console};function allowBodyErrors(){}function ConsoleWrapHook(e){var r=e.shaking,t=e.className,o=e.children,s=e.rootElement,n=useDimensions(s)[0];return _jsx(ConsoleWrap,__assign({shaking:r,className:t,"data-cy":"console",fullWidth:null==n?void 0:n.width},{children:o}),void 0)}function AuthPanelHook(e){var r=useField(__assign({},e)),t=r.fieldApi,o=r.render,s=r.userProps,n=t.setValue,a=s.children;return o(_jsx(_Fragment,{children:a(n)},void 0))}
2
2
  //# sourceMappingURL=Console.js.map
@@ -1,4 +1,5 @@
1
- import type { FieldModel, OpenAPIServer, Server, ServerVariables, OperationModel, ExampleModel } from '../../redoc-lib';
1
+ import type { RequestAuth } from '../../types';
2
+ import type { ExampleModel, FieldModel, OpenAPIServer, OperationModel, Server, ServerVariables } from '../../redoc-lib';
2
3
  import type { RedocProNormalizedOptions } from '../../services';
3
4
  import type { RequestBodyProps } from './RequestBody';
4
5
  export declare function normalizeUrlProtocol(url: string): string;
@@ -12,7 +13,7 @@ export declare function getDefaultOrStoredVariables(server?: OpenAPIServer): Ser
12
13
  export declare function updateVariablesStorage(name: string, value: string): void;
13
14
  export declare function unescapeQueryParams(params: GenericObject): GenericObject;
14
15
  export declare function getFileNameFromHeaders(headers: Record<string, string>): string;
15
- export declare const makeRequestInterceptor: ({ requestInterceptor, sendXUserAgentInTryIt, disableTryItRequestUrlEncoding, }: Pick<RedocProNormalizedOptions, 'requestInterceptor' | 'sendXUserAgentInTryIt' | 'disableTryItRequestUrlEncoding'>, operation: OperationModel, securitySchemaAuth?: string | undefined) => (req: Request) => void | Request;
16
+ export declare const makeRequestInterceptor: ({ requestInterceptor, sendXUserAgentInTryIt, disableTryItRequestUrlEncoding, }: Pick<RedocProNormalizedOptions, 'requestInterceptor' | 'sendXUserAgentInTryIt' | 'disableTryItRequestUrlEncoding'>, operation: OperationModel, auth?: RequestAuth | undefined) => (req: Request) => void | Request;
16
17
  export declare const validateTokenEndpointMethod: (token: string[] | string | undefined) => boolean;
17
18
  export declare const getOAuth2TokenEndpointAuthHeader: ({ authMethod, clientId, clientSecret, }: {
18
19
  authMethod?: string | string[] | undefined;
@@ -1,2 +1,2 @@
1
- import{__assign}from"tslib";import merge from"deepmerge";import{MediaTypes}from"../../types";import{arrayMergeStrategy}from"../../services/utils";import{fromSessionStorage,getParameterValue,setParameterValue,setSecurityDetails,toSessionStorage,unescapeFormId}from"../../utils";export function normalizeUrlProtocol(e){return e.startsWith("//")?"https:"+e:e}export function updateStorage(e){if(e.values.auth)for(var r=0,t=Object.keys(e.values.auth);r<t.length;r++){var a=t[r],n=e.values.auth[a];setSecurityDetails(a,n)}updateParameterStorage(e)}function updateParameterStorage(e){for(var r,t=0,a=["path","query","header","cookie"];t<a.length;t++){var n=a[t];if(null===(r=e.values)||void 0===r?void 0:r[n])for(var i=0,o=Object.keys(e.values[n]);i<o.length;i++){var s=o[i];setParameterValue(n,s,e.values[n][s])}}}export var getParameters=function(e,r){return e.filter((function(e){return e.in===r})).reduce((function(e,r){var t=r.in,a=r.name;return e[a]=getParameterValue(t||"",a),e}),{})};var pathTemplateRegExp=/(?:{)(\w+)(?:})/g;export function getServerWithVariables(e,r){void 0===r&&(r=0);var t=e[r],a=getDefaultOrStoredVariables(t);return __assign(__assign({},t),{variables:a})}export function getInitialServerWithVariables(e){var r=fromSessionStorage("serverUrl"),t=e.find((function(e){return e.url===r}))||e[0],a=getDefaultOrStoredVariables(t);return __assign(__assign({},t),{variables:a})}export function expandVariables(e,r){return void 0===r&&(r={}),e.replace(pathTemplateRegExp,(function(e,t){return r[t]||e}))}export function expandDefaultServerVariables(e,r){return void 0===r&&(r={}),e.replace(pathTemplateRegExp,(function(e,t){return r[t]&&r[t].default||e}))}export function getDefaultOrStoredVariables(e){if(!(null==e?void 0:e.variables))return{};var r=fromSessionStorage("variables"),t=r&&JSON.parse(r)||{},a={};return Object.entries(e.variables||{}).forEach((function(e){var r=e[0],n=e[1];a[r]=t[r]||n.default||""})),a}export function updateVariablesStorage(e,r){var t,a=fromSessionStorage("variables"),n=a&&JSON.parse(a)||{};toSessionStorage("variables",JSON.stringify(__assign(__assign({},n),((t={})[e]=r,t))))}export function unescapeQueryParams(e){return Object.entries(e).reduce((function(e,r){var t=r[0],a=r[1];return e[unescapeFormId(t)]=a,e}),{})}export function getFileNameFromHeaders(e){for(var r="filename=",t=0,a=Object.entries(e);t<a.length;t++){var n=a[t],i=n[0],o=n[1];if("content-disposition"===i.toLowerCase()){var s=o.split(";").find((function(e){return e.trim().startsWith(r)}));if(s)return s.split(r)[1]}}return""}export var makeRequestInterceptor=function(e,r,t){var a=e.requestInterceptor,n=e.sendXUserAgentInTryIt,i=e.disableTryItRequestUrlEncoding;return function(e){var o,s,u,l;i&&(e=__assign(__assign({},e),{url:decodeURIComponent(e.url)})),n&&(e.headers["X-User-Agent"]="Redocly Try it API console");var c=(null===(s=null===(o=null==r?void 0:r.requestValues)||void 0===o?void 0:o.header)||void 0===s?void 0:s.authorization)||(null===(l=null===(u=null==r?void 0:r.requestValues)||void 0===u?void 0:u.header)||void 0===l?void 0:l.Authorization);return!t&&c&&(e.headers.Authorization=c),a?a(e,r):e}};export var validateTokenEndpointMethod=function(e){if(!e)return!0;var r=Array.isArray(e)?e:[e];return!(r.length&&!r.includes("none")&&!r.includes("client_secret_basic"))};export var getOAuth2TokenEndpointAuthHeader=function(e){var r=e.authMethod,t=e.clientId,a=e.clientSecret;return"client_secret_basic"===r||Array.isArray(r)&&r.includes("client_secret_basic")?{Authorization:"Basic "+btoa(t+":"+a)}:{}};export function encodeSample(e,r){if(!e)return"";if(e.mime===MediaTypes.URL_ENCODED)return e.value;var t=e.value,a=r?merge(t,r,{arrayMerge:arrayMergeStrategy}):t;return JSON.stringify(a,null,2)}export var getStorageExampleKey=function(e,r,t,a){var n=e+"_"+r;return t&&a&&Object.keys(a).includes(t)&&(n+="_"+t),n};
1
+ import{__assign}from"tslib";import merge from"deepmerge";import{MediaTypes}from"../../types";import{arrayMergeStrategy}from"../../services/utils";import{fromSessionStorage,getParameterValue,setParameterValue,setSecurityDetails,toSessionStorage,unescapeFormId}from"../../utils";export function normalizeUrlProtocol(e){return e.startsWith("//")?"https:"+e:e}export function updateStorage(e){if(e.values.auth)for(var r=0,t=Object.keys(e.values.auth);r<t.length;r++){var a=t[r],n=e.values.auth[a];setSecurityDetails(a,n)}updateParameterStorage(e)}function updateParameterStorage(e){for(var r,t=0,a=["path","query","header","cookie"];t<a.length;t++){var n=a[t];if(null===(r=e.values)||void 0===r?void 0:r[n])for(var i=0,o=Object.keys(e.values[n]);i<o.length;i++){var u=o[i];setParameterValue(n,u,e.values[n][u])}}}export var getParameters=function(e,r){return e.filter((function(e){return e.in===r})).reduce((function(e,r){var t=r.in,a=r.name;return e[a]=getParameterValue(t||"",a),e}),{})};var pathTemplateRegExp=/(?:{)(\w+)(?:})/g;export function getServerWithVariables(e,r){void 0===r&&(r=0);var t=e[r],a=getDefaultOrStoredVariables(t);return __assign(__assign({},t),{variables:a})}export function getInitialServerWithVariables(e){var r=fromSessionStorage("serverUrl"),t=e.find((function(e){return e.url===r}))||e[0],a=getDefaultOrStoredVariables(t);return __assign(__assign({},t),{variables:a})}export function expandVariables(e,r){return void 0===r&&(r={}),e.replace(pathTemplateRegExp,(function(e,t){return r[t]||e}))}export function expandDefaultServerVariables(e,r){return void 0===r&&(r={}),e.replace(pathTemplateRegExp,(function(e,t){return r[t]&&r[t].default||e}))}export function getDefaultOrStoredVariables(e){if(!(null==e?void 0:e.variables))return{};var r=fromSessionStorage("variables"),t=r&&JSON.parse(r)||{},a={};return Object.entries(e.variables||{}).forEach((function(e){var r=e[0],n=e[1];a[r]=t[r]||n.default||""})),a}export function updateVariablesStorage(e,r){var t,a=fromSessionStorage("variables"),n=a&&JSON.parse(a)||{};toSessionStorage("variables",JSON.stringify(__assign(__assign({},n),((t={})[e]=r,t))))}export function unescapeQueryParams(e){return Object.entries(e).reduce((function(e,r){var t=r[0],a=r[1];return e[unescapeFormId(t)]=a,e}),{})}export function getFileNameFromHeaders(e){for(var r="filename=",t=0,a=Object.entries(e);t<a.length;t++){var n=a[t],i=n[0],o=n[1];if("content-disposition"===i.toLowerCase()){var u=o.split(";").find((function(e){return e.trim().startsWith(r)}));if(u)return u.split(r)[1]}}return""}export var makeRequestInterceptor=function(e,r,t){var a=e.requestInterceptor,n=e.sendXUserAgentInTryIt,i=e.disableTryItRequestUrlEncoding;return function(e){var o,u,s,l;i&&(e=__assign(__assign({},e),{url:decodeURIComponent(e.url)})),n&&(e.headers["X-User-Agent"]="Redocly Try it API console");var c=(null===(u=null===(o=null==r?void 0:r.requestValues)||void 0===o?void 0:o.header)||void 0===u?void 0:u.authorization)||(null===(l=null===(s=null==r?void 0:r.requestValues)||void 0===s?void 0:s.header)||void 0===l?void 0:l.Authorization);return!(null==t?void 0:t.Authorization)&&c&&(e.headers.Authorization=c),(null==t?void 0:t.Cookie)&&(e.headers["X-Redocly-Cookie"]=t.Cookie),a?a(e,r):e}};export var validateTokenEndpointMethod=function(e){if(!e)return!0;var r=Array.isArray(e)?e:[e];return!(r.length&&!r.includes("none")&&!r.includes("client_secret_basic"))};export var getOAuth2TokenEndpointAuthHeader=function(e){var r=e.authMethod,t=e.clientId,a=e.clientSecret;return"client_secret_basic"===r||Array.isArray(r)&&r.includes("client_secret_basic")?{Authorization:"Basic "+btoa(t+":"+a)}:{}};export function encodeSample(e,r){if(!e)return"";if(e.mime===MediaTypes.URL_ENCODED)return e.value;var t=e.value,a=r?merge(t,r,{arrayMerge:arrayMergeStrategy}):t;return JSON.stringify(a,null,2)}export var getStorageExampleKey=function(e,r,t,a){var n=e+"_"+r;return t&&a&&Object.keys(a).includes(t)&&(n+="_"+t),n};
2
2
  //# sourceMappingURL=utils.js.map
@@ -1,2 +1,2 @@
1
- var _a;import{__assign,__awaiter,__decorate,__generator}from"tslib";import{action,makeObservable,observable,observe}from"mobx";import{bundle,Config}from"@redocly/openapi-core";import{bind,debounce}from"decko";import{createParsedDocument,IS_BROWSER,MarkerService,RedocNormalizedOptions,SCHEMA_DEFINITION_JSX_NAME,SchemaDefinition,ScrollService,SECURITY_DEFINITIONS_COMPONENT_NAME,SECURITY_DEFINITIONS_JSX_NAME,SpecStore}from"../redoc-lib";import{PullRight,RedocResponse}from"../components/pluggable";import{fromLocalStorage,fromSessionStorage,getWindowReferenceOptions,setGlobalStore,toLocalStorage,toSessionStorage}from"../utils";import{SecurityDefs}from"../redoc-lib/src/components/SecurityRequirement/SecurityDefs";import{WindowReferenceOptions}from"../types";import{FakeHistoryService,ProHashHistoryService,PushStateHistoryService}from"./history";import{ProMenu}from"./ProMenu";import{DeepSearchStore,DEFAULT_SEARCH_MAX_DEPTH,RemoteSearch}from"./SearchStore";import{extendTheme}from"./extendTheme";import{VersionedSpecStore}from"./VersionedSpecStore";import parseToken from"./check";import{normalizePath}from"./utils";import{LayoutVariant}from"./store-types";import{SideNavStyle}from"./types";var global="undefined"==typeof window?{__REDOCLY_SEARCH_URL:void 0}:window,NestingGroup=function(){function e(e,t,i,o){var n=this;Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"absoluteIdx",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"description",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"linkable",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"items",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"parent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"externalDocs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"active",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"expanded",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"depth",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"level",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),makeObservable(this),this.id="section/"+e,this.type="nesting-group",this.name=i||"",this.level=1,this.depth=1,this.description="",this.parent=void 0,this.expanded=!1,this.items=t,this.linkable=!!o,t.forEach((function(e){return e.parent=n})),increaseDepthDeep(t)}return Object.defineProperty(e.prototype,"activate",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.active=!0}}),Object.defineProperty(e.prototype,"expand",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.expanded=!0,this.parent&&this.parent.expand()}}),Object.defineProperty(e.prototype,"collapse",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.expanded=!1}}),Object.defineProperty(e.prototype,"deactivate",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.active=!1}}),__decorate([observable],e.prototype,"active",void 0),__decorate([observable],e.prototype,"expanded",void 0),__decorate([action],e.prototype,"activate",null),__decorate([action],e.prototype,"expand",null),__decorate([action],e.prototype,"collapse",null),__decorate([action],e.prototype,"deactivate",null),e}();export{NestingGroup};function increaseDepthDeep(e){Array.isArray(e)&&e.forEach((function(e){e.depth++,e.parent&&"group"===e.parent.type&&(e.depth=e.parent.depth),increaseDepthDeep(e.items)}))}var ProStore=function(){function e(e,t,i,o){var n=this;void 0===i&&(i={}),void 0===o&&(o=!0),Object.defineProperty(this,"rawOptions",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"menu",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"definition",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"marker",{enumerable:!0,configurable:!0,writable:!0,value:new MarkerService}),Object.defineProperty(this,"scroll",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"disposer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"search",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tryItOperation",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"showRightPanel",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"layout",{enumerable:!0,configurable:!0,writable:!0,value:LayoutVariant.THREE_PANEL}),Object.defineProperty(this,"activeSampleLanguage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isLoading",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"l",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),makeObservable(this),this.initProOptions(i),IS_BROWSER&&(this.l=parseToken(i.licenseKey),this.l.then((function(e){e.valid&&e.allowed&&!e.expired||e.local||e.plugin||(n.menu.items=[],n.menu.flatItems=n.menu.flatItems.slice(0,1),n.menu.renderItems=[])})));var r="object"==typeof e&&"versions"in e,a=this.options.disableSidebar?new FakeHistoryService(this.options):"browser"===this.options.routingStrategy?new PushStateHistoryService(this.options,r):new ProHashHistoryService(this.options,r);this.definition=r?new VersionedSpecStore(e,this.options,a.currentId.split("/")[0]):new SpecStore(e,t,this.options),i.downloadDefinitionUrl&&(this.definition.info.downloadFileName=""),this.scroll=new ScrollService(this.options),this.options.disableSidebar||ProMenu.updateOnHistory(a.currentId,this.scroll),this.menu=new ProMenu(this.definition,this.scroll,this.options,a),this.menu.initOnHistory(),this.options.disableSearch||this.initSearch(this.options,o),this.disposer=observe(this.menu,"none"===this.options.pagination?"activeItemIdx":"activeRenderItemIdx",(function(e){setTimeout((function(){return n.updateMarkOnMenu(e.newValue)}))})),setGlobalStore(this)}return Object.defineProperty(e.prototype,"initProOptions",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,i,o,n,r,a;e=deepClone(e),this.rawOptions=extendTheme(e),this.options=new RedocNormalizedOptions(this.rawOptions,DEFAULT_OPTIONS),null!=this.rawOptions.showConsole&&console.warn('"showConsole" option is deprecated. Please, use "hideTryItPanel" instead.'),this.options.showConsole=null!=this.rawOptions.hideTryItPanel?!this.rawOptions.hideTryItPanel:null===(t=this.rawOptions.showConsole)||void 0===t||t,this.options.hideRightPanel=null!==(i=this.rawOptions.hideRightPanel)&&void 0!==i&&i,this.showRightPanel=!this.options.hideRightPanel,this.options.showRightPanelToggle=null===(o=this.rawOptions.showRightPanelToggle)||void 0===o||o,this.options.showChangeLayoutButton=null===(n=this.rawOptions.showChangeLayoutButton)||void 0===n||n,this.options.layout=this.rawOptions.layout||LayoutVariant.THREE_PANEL,this.options.defaultSampleLanguage=this.rawOptions.defaultSampleLanguage||"",this.options.deepLinkSeparator=this.rawOptions.deepLinkSeparator||"/",this.options.deepLinkPrefix=this.rawOptions.deepLinkPrefix||"!",this.options.disableDeepLinks=this.rawOptions.disableDeepLinks||!1,this.options.sideNavStyle=this.rawOptions.sideNavStyle||SideNavStyle.SummaryOnly,this.options.whiteLabel=!!this.rawOptions.whiteLabel,this.options.hideLogo=!!this.rawOptions.hideLogo,this.options.hideInfoSection=!!this.rawOptions.hideInfoSection,this.options.oAuth2RedirectURI=this.rawOptions.oAuth2RedirectURI||null,this.options.unstable_hideServerUrlInTryIt=this.rawOptions.unstable_hideServerUrlInTryIt||!1,this.options.oAuth2RedirectURI=this.rawOptions.oAuth2RedirectURI||null,this.options.events=this.rawOptions.events||{},this.options.mockServer=(null===(r=this.rawOptions.mockServer)||void 0===r?void 0:r.url)?{url:this.rawOptions.mockServer.url,position:this.rawOptions.mockServer.position||"first",description:this.rawOptions.mockServer.description||"Mock server"}:null,this.options.corsProxyUrl=this.rawOptions.corsProxyUrl?addTrailingSlash(this.rawOptions.corsProxyUrl):null,this.options.authCorsProxyUrl=this.rawOptions.authCorsProxyUrl?addTrailingSlash(this.rawOptions.authCorsProxyUrl):null,this.options.theme.scrollYOffset=this.options.scrollYOffset,this.options.linkForId=this.rawOptions.linkForId||getWindowReferenceOptions(WindowReferenceOptions.LINK_FOR_ID)||null,this.options.generateDeepLink=this.rawOptions.generateDeepLink||getWindowReferenceOptions(WindowReferenceOptions.GENERATE_DEEP_LINK)||null,this.options.onDeepLinkClick=this.rawOptions.onDeepLinkClick||getWindowReferenceOptions(WindowReferenceOptions.ON_DEEP_LINK_CLICK)||null,this.options.requestInterceptor=this.rawOptions.requestInterceptor||getWindowReferenceOptions(WindowReferenceOptions.REQUEST_INTERCEPTOR)||null,this.options.sidebarLinks=this.rawOptions.sidebarLinks||{};var s="object"==typeof this.rawOptions.layout?this.rawOptions.layout:null;if(this.options.pagination=this.rawOptions.pagination||"none",this.options.routingStrategy=void 0!==this.rawOptions.routingStrategy?this.rawOptions.routingStrategy:"none"===this.options.pagination?"hash":"browser",!(null===(a=this.rawOptions)||void 0===a?void 0:a.pagination)&&(null==s?void 0:s.scope))switch(console.warn('"layout.scope" and "routingStrategy" settings are deprecated. Please, use "pagination" instead.'),null==s?void 0:s.scope){case"all":default:this.options.pagination="none",this.options.routingStrategy="hash";break;case"section":this.options.pagination="section",this.options.routingStrategy="browser";break;case"item":this.options.pagination="item",this.options.routingStrategy="browser"}this.options.markdownItemsPagination="none",!1!==this.rawOptions.showNextButton&&(this.options.showNextButton=!0),this.options.disableSidebar=!!e.disableSidebar,this.options.disableSidebar&&(this.options.theme.sidebar.width="0px"),this.options.skipBundleAndConvert=!!e.skipBundleAndConvert,this.options.routingBasePath=e.routingBasePath&&normalizePath(e.routingBasePath)||"",this.options.searchAutoExpand=!1!==e.searchAutoExpand,this.options.searchMode=e.searchMode||"default",this.options.ctrlFHijack=void 0===e.ctrlFHijack||e.ctrlFHijack,this.options.disablePaginationLoadingAnimation=!!e.disablePaginationLoadingAnimation||"none"===this.options.pagination,this.options.showConsole,this.options.generateCodeSamples=e.generateCodeSamples||{languages:[]},this.options.searchMaxDepth=this.rawOptions.searchMaxDepth||DEFAULT_SEARCH_MAX_DEPTH}}),Object.defineProperty(e.prototype,"initSearch",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var i=this;global.__REDOCLY_SEARCH_URL?this.search=new RemoteSearch(global.__REDOCLY_SEARCH_URL):this.search=new DeepSearchStore(e),t&&setTimeout((function(){var e;return null===(e=i.search)||void 0===e?void 0:e.indexItems(i.menu.items)}),50),this.definition instanceof VersionedSpecStore&&observe(this.definition,"activeVersionIdx",(function(t){var o,n,r=i.definition;null===(o=i.search)||void 0===o||o.dispose(),i.search=new DeepSearchStore(e);var a=r.versions[t.newValue]._searchIndexName;if(IS_BROWSER&&a){var s=r.versions[t.newValue]._searchIndexName,l=new URL(window.location.href);l.pathname=joinURLs(i.options.routingBasePath,s),null===(n=i.search)||void 0===n||n.fromExternalJS(l.toString(),__redoc_state.searchIndexExport),i.observeAllAndRemark()}else setTimeout((function(){var e;null===(e=i.search)||void 0===e||e.indexItems(i.menu.items)}),0)})),IS_BROWSER&&this.observeAllAndRemark()}}),Object.defineProperty(e.prototype,"onDidMount",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(this.menu.updateOnHistory(),this.updateMarkOnMenu(this.menu.activeItemIdx),this.layout=fromLocalStorage("layoutVariant")||this.options.layout||this.layout,this.activeSampleLanguage=fromLocalStorage("activeSampleLanguage")||this.options.defaultSampleLanguage,this.options.showRightPanelToggle){var e=fromSessionStorage("showRightPanelToggleState");e&&(this.showRightPanel="true"===e)}}}),Object.defineProperty(e.prototype,"toggleRightPanel",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.showRightPanel=null!=e?e:!this.showRightPanel,toSessionStorage("showRightPanelToggleState",JSON.stringify(this.showRightPanel))}}),Object.defineProperty(e.prototype,"toggleLayout",{enumerable:!1,configurable:!0,writable:!0,value:function(e){void 0===e&&(e=LayoutVariant.THREE_PANEL),this.layout=e,toLocalStorage("layoutVariant",e)}}),Object.defineProperty(e.prototype,"disableConsole",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.options.showConsole=!1}}),Object.defineProperty(e.prototype,"enableConsole",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.options.showConsole=!0}}),Object.defineProperty(e.prototype,"tryItOut",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.tryItOperation=e}}),Object.defineProperty(e.prototype,"setActiveSampleLanguage",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this.activeSampleLanguage===e)return this.stopLoader();this.activeSampleLanguage=e,toLocalStorage("activeSampleLanguage",e)}}),Object.defineProperty(e.prototype,"activateSampleLanguage",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.setActiveSampleLanguage(e)}}),Object.defineProperty(e.prototype,"startLoader",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.isLoading||(this.isLoading=!0)}}),Object.defineProperty(e.prototype,"stopLoader",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.isLoading&&(this.isLoading=!1)}}),Object.defineProperty(e.prototype,"dereferenceSpecForTryIt",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,i,o,n;return __awaiter(this,void 0,void 0,(function(){var r,a,s,l,p,u,c;return __generator(this,(function(h){switch(h.label){case 0:return r=this.definition.parser.definition,a=JSON.parse(JSON.stringify(r)),s=__assign(__assign({},getSpecVersionObj(a)),{components:a.components,paths:(u={},u[e.path]=(c={},c[e.httpVerb]=null===(i=null===(t=a.paths)||void 0===t?void 0:t[e.path])||void 0===i?void 0:i[e.httpVerb],c.parameters=null===(n=null===(o=a.paths)||void 0===o?void 0:o[e.path])||void 0===n?void 0:n.parameters,c),u)}),l=new Config({}),p=createParsedDocument(s),[4,bundle({config:l,doc:p,dereference:!0})];case 1:return h.sent(),[2,a]}}))}))}}),Object.defineProperty(e.prototype,"observeAllAndRemark",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this,t=function(i){for(var o=0,n=i;o<n.length;o++){var r=n[o];if("operation"===r.type)for(var a=0,s=r.responses;a<s.length;a++){var l=s[a];observe(l,"expanded",(function(t){return e.remark(t)}))}else"tag"===r.type&&t(r.items||[])}};t(this.menu.renderItems),"none"!==this.options.pagination&&observe(this.menu,"renderItems",(function(){return t(e.menu.renderItems)}))}}),Object.defineProperty(e.prototype,"remark",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;e.newValue&&setTimeout((function(){return t.marker.mark()}),0)}}),Object.defineProperty(e,"fromJS",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var i,o=new e(t.definition.data,t.definition.url,t.options,!1);setGlobalStore(o),o.menu.activeItemIdx=void 0!==t.menu.activeItemIdx?t.menu.activeItemIdx:-1,o.definition instanceof VersionedSpecStore&&t.definition.activeVersionIdx&&(o.definition.activeVersionIdx=t.definition.activeVersionIdx||0);var n=o.menu.flatItems[o.menu.activeItemIdx];if(n&&o.menu.activate(n,!1),!o.options.disableSearch){var r=new URL(window.location.href);r.pathname=t.searchIndexPath&&t.searchIndexPath.startsWith("/")?t.searchIndexPath:r.pathname+(r.pathname.endsWith("/")?"":"/")+t.searchIndexPath,null===(i=o.search)||void 0===i||i.fromExternalJS(r.toString(),t.searchIndexExport)}return t.tryItOperationId&&(o.tryItOperation=o.menu.flatItems.find((function(e){return e.id===t.tryItOperationId}))),setTimeout((function(){return o.observeAllAndRemark()}),0),o}}),Object.defineProperty(e.prototype,"toJS",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e;return __awaiter(this,void 0,void 0,(function(){var t,i;return __generator(this,(function(o){switch(o.label){case 0:return i={menu:{activeItemIdx:this.menu.activeItemIdx},definition:this.definition instanceof VersionedSpecStore?{url:void 0,data:this.definition.toJS()}:{url:this.definition.parser.definitionUrl,data:this.definition.parser.definition}},this.search?[4,this.search.toJS()]:[3,2];case 1:return t=o.sent(),[3,3];case 2:t=void 0,o.label=3;case 3:return[2,(i.searchIndex=t,i.options=this.rawOptions,i.tryItOperationId=null===(e=this.tryItOperation)||void 0===e?void 0:e.id,i)]}}))}))}}),Object.defineProperty(e.prototype,"dispose",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.scroll.dispose(),this.menu.dispose(),this.search&&this.search.dispose(),this.disposer()}}),Object.defineProperty(e.prototype,"updateMarkOnMenu",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var t=Math.max(0,e),i=Math.min(this.menu.flatItems.length,t+5),o=[],n=t;n<i;n++){(r=this.menu.getElementAt(n))&&(r&&o.push(r))}if("item"===this.options.pagination){var r,a=(this.menu.flatItems[e]||{}).parent;if(null==a?void 0:a.absoluteIdx)(r=this.menu.getElementAt(a.absoluteIdx))&&o.push(r)}this.marker.addOnly(o),this.marker.mark()}}),__decorate([observable],e.prototype,"search",void 0),__decorate([observable],e.prototype,"tryItOperation",void 0),__decorate([observable],e.prototype,"showRightPanel",void 0),__decorate([observable],e.prototype,"layout",void 0),__decorate([observable],e.prototype,"activeSampleLanguage",void 0),__decorate([observable],e.prototype,"isLoading",void 0),__decorate([action],e.prototype,"onDidMount",null),__decorate([action],e.prototype,"toggleRightPanel",null),__decorate([action],e.prototype,"toggleLayout",null),__decorate([action],e.prototype,"disableConsole",null),__decorate([action],e.prototype,"enableConsole",null),__decorate([action],e.prototype,"tryItOut",null),__decorate([action],e.prototype,"setActiveSampleLanguage",null),__decorate([bind,debounce(500)],e.prototype,"activateSampleLanguage",null),__decorate([action],e.prototype,"startLoader",null),__decorate([action],e.prototype,"stopLoader",null),e}();export{ProStore};var DEFAULT_OPTIONS={ignoreNamedSchemas:["java.io.ObjectStreamField"],allowedMdComponents:(_a={RedocResponse:{component:RedocResponse,propsSelector:function(e){return{store:e}}},PullRight:{component:PullRight,propsSelector:function(){return{}}}},_a[SCHEMA_DEFINITION_JSX_NAME]={component:SchemaDefinition,propsSelector:function(e){return{parser:e.definition.parser,options:e.options,layout:e.layout,showRightPanel:e.showRightPanel}}},_a[SECURITY_DEFINITIONS_COMPONENT_NAME]={component:SecurityDefs,propsSelector:function(e){return{securitySchemes:e.definition.securitySchemes}}},_a[SECURITY_DEFINITIONS_JSX_NAME]={component:SecurityDefs,propsSelector:function(e){return{securitySchemes:e.definition.securitySchemes}}},_a)};function joinURLs(e,t){return e.endsWith("/")&&(e=e.slice(0,-1)),t.startsWith("/")&&(t=t.substring(1)),e+"/"+t}function addTrailingSlash(e){return e.endsWith("/")?e:e+"/"}function getSpecVersionObj(e){return e.openapi?{openapi:e.openapi}:e.swagger?{swagger:e.swagger}:void 0}function deepClone(e){if("object"!=typeof e||null===e)return e;var t=Array.isArray(e)?[]:{};for(var i in e){var o=e[i];t[i]=deepClone(o)}return t}
1
+ var _a;import{__assign,__awaiter,__decorate,__generator}from"tslib";import{action,makeObservable,observable,observe}from"mobx";import{bundle,Config}from"@redocly/openapi-core";import{bind,debounce}from"decko";import{createParsedDocument,IS_BROWSER,MarkerService,RedocNormalizedOptions,SCHEMA_DEFINITION_JSX_NAME,SchemaDefinition,ScrollService,SECURITY_DEFINITIONS_COMPONENT_NAME,SECURITY_DEFINITIONS_JSX_NAME,SpecStore}from"../redoc-lib";import{PullRight,RedocResponse}from"../components/pluggable";import{fromLocalStorage,fromSessionStorage,getWindowReferenceOptions,setGlobalStore,toLocalStorage,toSessionStorage}from"../utils";import{SecurityDefs}from"../redoc-lib/src/components/SecurityRequirement/SecurityDefs";import{WindowReferenceOptions}from"../types";import{FakeHistoryService,ProHashHistoryService,PushStateHistoryService}from"./history";import{ProMenu}from"./ProMenu";import{DeepSearchStore,DEFAULT_SEARCH_MAX_DEPTH,RemoteSearch}from"./SearchStore";import{extendTheme}from"./extendTheme";import{VersionedSpecStore}from"./VersionedSpecStore";import parseToken from"./check";import{normalizePath}from"./utils";import{LayoutVariant}from"./store-types";import{SideNavStyle}from"./types";var global="undefined"==typeof window?{__REDOCLY_SEARCH_URL:void 0}:window,NestingGroup=function(){function e(e,t,i,o){var n=this;Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"absoluteIdx",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"description",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"linkable",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"items",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"parent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"externalDocs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"active",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"expanded",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"depth",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"level",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),makeObservable(this),this.id="section/"+e,this.type="nesting-group",this.name=i||"",this.level=1,this.depth=1,this.description="",this.parent=void 0,this.expanded=!1,this.items=t,this.linkable=!!o,t.forEach((function(e){return e.parent=n})),increaseDepthDeep(t)}return Object.defineProperty(e.prototype,"activate",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.active=!0}}),Object.defineProperty(e.prototype,"expand",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.expanded=!0,this.parent&&this.parent.expand()}}),Object.defineProperty(e.prototype,"collapse",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.expanded=!1}}),Object.defineProperty(e.prototype,"deactivate",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.active=!1}}),__decorate([observable],e.prototype,"active",void 0),__decorate([observable],e.prototype,"expanded",void 0),__decorate([action],e.prototype,"activate",null),__decorate([action],e.prototype,"expand",null),__decorate([action],e.prototype,"collapse",null),__decorate([action],e.prototype,"deactivate",null),e}();export{NestingGroup};function increaseDepthDeep(e){Array.isArray(e)&&e.forEach((function(e){e.depth++,e.parent&&"group"===e.parent.type&&(e.depth=e.parent.depth),increaseDepthDeep(e.items)}))}var ProStore=function(){function e(e,t,i,o){var n=this;void 0===i&&(i={}),void 0===o&&(o=!0),Object.defineProperty(this,"rawOptions",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"menu",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"definition",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"marker",{enumerable:!0,configurable:!0,writable:!0,value:new MarkerService}),Object.defineProperty(this,"scroll",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"disposer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"search",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tryItOperation",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"showRightPanel",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"layout",{enumerable:!0,configurable:!0,writable:!0,value:fromLocalStorage("layoutVariant")||LayoutVariant.THREE_PANEL}),Object.defineProperty(this,"activeSampleLanguage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isLoading",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"l",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),makeObservable(this),this.initProOptions(i),IS_BROWSER&&(this.l=parseToken(i.licenseKey),this.l.then((function(e){e.valid&&e.allowed&&!e.expired||e.local||e.plugin||(n.menu.items=[],n.menu.flatItems=n.menu.flatItems.slice(0,1),n.menu.renderItems=[])})));var r="object"==typeof e&&"versions"in e,a=this.options.disableSidebar?new FakeHistoryService(this.options):"browser"===this.options.routingStrategy?new PushStateHistoryService(this.options,r):new ProHashHistoryService(this.options,r);this.definition=r?new VersionedSpecStore(e,this.options,a.currentId.split("/")[0]):new SpecStore(e,t,this.options),i.downloadDefinitionUrl&&(this.definition.info.downloadFileName=""),this.scroll=new ScrollService(this.options),this.options.disableSidebar||ProMenu.updateOnHistory(a.currentId,this.scroll),this.menu=new ProMenu(this.definition,this.scroll,this.options,a),this.menu.initOnHistory(),this.options.disableSearch||this.initSearch(this.options,o),this.disposer=observe(this.menu,"none"===this.options.pagination?"activeItemIdx":"activeRenderItemIdx",(function(e){setTimeout((function(){return n.updateMarkOnMenu(e.newValue)}))})),setGlobalStore(this)}return Object.defineProperty(e.prototype,"initProOptions",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,i,o,n,r,a;e=deepClone(e),this.rawOptions=extendTheme(e),this.options=new RedocNormalizedOptions(this.rawOptions,DEFAULT_OPTIONS),null!=this.rawOptions.showConsole&&console.warn('"showConsole" option is deprecated. Please, use "hideTryItPanel" instead.'),this.options.showConsole=null!=this.rawOptions.hideTryItPanel?!this.rawOptions.hideTryItPanel:null===(t=this.rawOptions.showConsole)||void 0===t||t,this.options.hideRightPanel=null!==(i=this.rawOptions.hideRightPanel)&&void 0!==i&&i,this.showRightPanel=!this.options.hideRightPanel,this.options.showRightPanelToggle=null===(o=this.rawOptions.showRightPanelToggle)||void 0===o||o,this.options.showChangeLayoutButton=null===(n=this.rawOptions.showChangeLayoutButton)||void 0===n||n,this.options.layout=this.rawOptions.layout||LayoutVariant.THREE_PANEL,this.options.defaultSampleLanguage=this.rawOptions.defaultSampleLanguage||"",this.options.deepLinkSeparator=this.rawOptions.deepLinkSeparator||"/",this.options.deepLinkPrefix=this.rawOptions.deepLinkPrefix||"!",this.options.disableDeepLinks=this.rawOptions.disableDeepLinks||!1,this.options.sideNavStyle=this.rawOptions.sideNavStyle||SideNavStyle.SummaryOnly,this.options.whiteLabel=!!this.rawOptions.whiteLabel,this.options.hideLogo=!!this.rawOptions.hideLogo,this.options.hideInfoSection=!!this.rawOptions.hideInfoSection,this.options.oAuth2RedirectURI=this.rawOptions.oAuth2RedirectURI||null,this.options.unstable_hideServerUrlInTryIt=this.rawOptions.unstable_hideServerUrlInTryIt||!1,this.options.oAuth2RedirectURI=this.rawOptions.oAuth2RedirectURI||null,this.options.events=this.rawOptions.events||{},this.options.mockServer=(null===(r=this.rawOptions.mockServer)||void 0===r?void 0:r.url)?{url:this.rawOptions.mockServer.url,position:this.rawOptions.mockServer.position||"first",description:this.rawOptions.mockServer.description||"Mock server"}:null,this.options.corsProxyUrl=this.rawOptions.corsProxyUrl?addTrailingSlash(this.rawOptions.corsProxyUrl):null,this.options.authCorsProxyUrl=this.rawOptions.authCorsProxyUrl?addTrailingSlash(this.rawOptions.authCorsProxyUrl):null,this.options.theme.scrollYOffset=this.options.scrollYOffset,this.options.linkForId=this.rawOptions.linkForId||getWindowReferenceOptions(WindowReferenceOptions.LINK_FOR_ID)||null,this.options.generateDeepLink=this.rawOptions.generateDeepLink||getWindowReferenceOptions(WindowReferenceOptions.GENERATE_DEEP_LINK)||null,this.options.onDeepLinkClick=this.rawOptions.onDeepLinkClick||getWindowReferenceOptions(WindowReferenceOptions.ON_DEEP_LINK_CLICK)||null,this.options.requestInterceptor=this.rawOptions.requestInterceptor||getWindowReferenceOptions(WindowReferenceOptions.REQUEST_INTERCEPTOR)||null,this.options.sidebarLinks=this.rawOptions.sidebarLinks||{};var s="object"==typeof this.rawOptions.layout?this.rawOptions.layout:null;if(this.options.pagination=this.rawOptions.pagination||"none",this.options.routingStrategy=void 0!==this.rawOptions.routingStrategy?this.rawOptions.routingStrategy:"none"===this.options.pagination?"hash":"browser",!(null===(a=this.rawOptions)||void 0===a?void 0:a.pagination)&&(null==s?void 0:s.scope))switch(console.warn('"layout.scope" and "routingStrategy" settings are deprecated. Please, use "pagination" instead.'),null==s?void 0:s.scope){case"all":default:this.options.pagination="none",this.options.routingStrategy="hash";break;case"section":this.options.pagination="section",this.options.routingStrategy="browser";break;case"item":this.options.pagination="item",this.options.routingStrategy="browser"}this.options.markdownItemsPagination="none",!1!==this.rawOptions.showNextButton&&(this.options.showNextButton=!0),this.options.disableSidebar=!!e.disableSidebar,this.options.disableSidebar&&(this.options.theme.sidebar.width="0px"),this.options.skipBundleAndConvert=!!e.skipBundleAndConvert,this.options.routingBasePath=e.routingBasePath&&normalizePath(e.routingBasePath)||"",this.options.searchAutoExpand=!1!==e.searchAutoExpand,this.options.searchMode=e.searchMode||"default",this.options.ctrlFHijack=void 0===e.ctrlFHijack||e.ctrlFHijack,this.options.disablePaginationLoadingAnimation=!!e.disablePaginationLoadingAnimation||"none"===this.options.pagination,this.options.showConsole,this.options.generateCodeSamples=e.generateCodeSamples||{languages:[]},this.options.searchMaxDepth=this.rawOptions.searchMaxDepth||DEFAULT_SEARCH_MAX_DEPTH}}),Object.defineProperty(e.prototype,"initSearch",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var i=this;global.__REDOCLY_SEARCH_URL?this.search=new RemoteSearch(global.__REDOCLY_SEARCH_URL):this.search=new DeepSearchStore(e),t&&setTimeout((function(){var e;return null===(e=i.search)||void 0===e?void 0:e.indexItems(i.menu.items)}),50),this.definition instanceof VersionedSpecStore&&observe(this.definition,"activeVersionIdx",(function(t){var o,n,r=i.definition;null===(o=i.search)||void 0===o||o.dispose(),i.search=new DeepSearchStore(e);var a=r.versions[t.newValue]._searchIndexName;if(IS_BROWSER&&a){var s=r.versions[t.newValue]._searchIndexName,l=new URL(window.location.href);l.pathname=joinURLs(i.options.routingBasePath,s),null===(n=i.search)||void 0===n||n.fromExternalJS(l.toString(),__redoc_state.searchIndexExport),i.observeAllAndRemark()}else setTimeout((function(){var e;null===(e=i.search)||void 0===e||e.indexItems(i.menu.items)}),0)})),IS_BROWSER&&this.observeAllAndRemark()}}),Object.defineProperty(e.prototype,"onDidMount",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(this.menu.updateOnHistory(),this.updateMarkOnMenu(this.menu.activeItemIdx),this.layout=fromLocalStorage("layoutVariant")||this.options.layout||this.layout,this.activeSampleLanguage=fromLocalStorage("activeSampleLanguage")||this.options.defaultSampleLanguage,this.options.showRightPanelToggle){var e=fromSessionStorage("showRightPanelToggleState");e&&(this.showRightPanel="true"===e)}}}),Object.defineProperty(e.prototype,"toggleRightPanel",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.showRightPanel=null!=e?e:!this.showRightPanel,toSessionStorage("showRightPanelToggleState",JSON.stringify(this.showRightPanel))}}),Object.defineProperty(e.prototype,"toggleLayout",{enumerable:!1,configurable:!0,writable:!0,value:function(e){void 0===e&&(e=LayoutVariant.THREE_PANEL),this.layout=e,toLocalStorage("layoutVariant",e)}}),Object.defineProperty(e.prototype,"disableConsole",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.options.showConsole=!1}}),Object.defineProperty(e.prototype,"enableConsole",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.options.showConsole=!0}}),Object.defineProperty(e.prototype,"tryItOut",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.tryItOperation=e}}),Object.defineProperty(e.prototype,"setActiveSampleLanguage",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this.activeSampleLanguage===e)return this.stopLoader();this.activeSampleLanguage=e,toLocalStorage("activeSampleLanguage",e)}}),Object.defineProperty(e.prototype,"activateSampleLanguage",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.setActiveSampleLanguage(e)}}),Object.defineProperty(e.prototype,"startLoader",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.isLoading||(this.isLoading=!0)}}),Object.defineProperty(e.prototype,"stopLoader",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.isLoading&&(this.isLoading=!1)}}),Object.defineProperty(e.prototype,"dereferenceSpecForTryIt",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,i,o,n;return __awaiter(this,void 0,void 0,(function(){var r,a,s,l,p,u,c;return __generator(this,(function(h){switch(h.label){case 0:return r=this.definition.parser.definition,a=JSON.parse(JSON.stringify(r)),s=__assign(__assign({},getSpecVersionObj(a)),{components:a.components,paths:(u={},u[e.path]=(c={},c[e.httpVerb]=null===(i=null===(t=a.paths)||void 0===t?void 0:t[e.path])||void 0===i?void 0:i[e.httpVerb],c.parameters=null===(n=null===(o=a.paths)||void 0===o?void 0:o[e.path])||void 0===n?void 0:n.parameters,c),u)}),l=new Config({}),p=createParsedDocument(s),[4,bundle({config:l,doc:p,dereference:!0})];case 1:return h.sent(),[2,a]}}))}))}}),Object.defineProperty(e.prototype,"observeAllAndRemark",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this,t=function(i){for(var o=0,n=i;o<n.length;o++){var r=n[o];if("operation"===r.type)for(var a=0,s=r.responses;a<s.length;a++){var l=s[a];observe(l,"expanded",(function(t){return e.remark(t)}))}else"tag"===r.type&&t(r.items||[])}};t(this.menu.renderItems),"none"!==this.options.pagination&&observe(this.menu,"renderItems",(function(){return t(e.menu.renderItems)}))}}),Object.defineProperty(e.prototype,"remark",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;e.newValue&&setTimeout((function(){return t.marker.mark()}),0)}}),Object.defineProperty(e,"fromJS",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var i,o=new e(t.definition.data,t.definition.url,t.options,!1);setGlobalStore(o),o.menu.activeItemIdx=void 0!==t.menu.activeItemIdx?t.menu.activeItemIdx:-1,o.definition instanceof VersionedSpecStore&&t.definition.activeVersionIdx&&(o.definition.activeVersionIdx=t.definition.activeVersionIdx||0);var n=o.menu.flatItems[o.menu.activeItemIdx];if(n&&o.menu.activate(n,!1),!o.options.disableSearch){var r=new URL(window.location.href);r.pathname=t.searchIndexPath&&t.searchIndexPath.startsWith("/")?t.searchIndexPath:r.pathname+(r.pathname.endsWith("/")?"":"/")+t.searchIndexPath,null===(i=o.search)||void 0===i||i.fromExternalJS(r.toString(),t.searchIndexExport)}return t.tryItOperationId&&(o.tryItOperation=o.menu.flatItems.find((function(e){return e.id===t.tryItOperationId}))),setTimeout((function(){return o.observeAllAndRemark()}),0),o}}),Object.defineProperty(e.prototype,"toJS",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e;return __awaiter(this,void 0,void 0,(function(){var t,i;return __generator(this,(function(o){switch(o.label){case 0:return i={menu:{activeItemIdx:this.menu.activeItemIdx},definition:this.definition instanceof VersionedSpecStore?{url:void 0,data:this.definition.toJS()}:{url:this.definition.parser.definitionUrl,data:this.definition.parser.definition}},this.search?[4,this.search.toJS()]:[3,2];case 1:return t=o.sent(),[3,3];case 2:t=void 0,o.label=3;case 3:return[2,(i.searchIndex=t,i.options=this.rawOptions,i.tryItOperationId=null===(e=this.tryItOperation)||void 0===e?void 0:e.id,i)]}}))}))}}),Object.defineProperty(e.prototype,"dispose",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.scroll.dispose(),this.menu.dispose(),this.search&&this.search.dispose(),this.disposer()}}),Object.defineProperty(e.prototype,"updateMarkOnMenu",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var t=Math.max(0,e),i=Math.min(this.menu.flatItems.length,t+5),o=[],n=t;n<i;n++){(r=this.menu.getElementAt(n))&&(r&&o.push(r))}if("item"===this.options.pagination){var r,a=(this.menu.flatItems[e]||{}).parent;if(null==a?void 0:a.absoluteIdx)(r=this.menu.getElementAt(a.absoluteIdx))&&o.push(r)}this.marker.addOnly(o),this.marker.mark()}}),__decorate([observable],e.prototype,"search",void 0),__decorate([observable],e.prototype,"tryItOperation",void 0),__decorate([observable],e.prototype,"showRightPanel",void 0),__decorate([observable],e.prototype,"layout",void 0),__decorate([observable],e.prototype,"activeSampleLanguage",void 0),__decorate([observable],e.prototype,"isLoading",void 0),__decorate([action],e.prototype,"onDidMount",null),__decorate([action],e.prototype,"toggleRightPanel",null),__decorate([action],e.prototype,"toggleLayout",null),__decorate([action],e.prototype,"disableConsole",null),__decorate([action],e.prototype,"enableConsole",null),__decorate([action],e.prototype,"tryItOut",null),__decorate([action],e.prototype,"setActiveSampleLanguage",null),__decorate([bind,debounce(500)],e.prototype,"activateSampleLanguage",null),__decorate([action],e.prototype,"startLoader",null),__decorate([action],e.prototype,"stopLoader",null),e}();export{ProStore};var DEFAULT_OPTIONS={ignoreNamedSchemas:["java.io.ObjectStreamField"],allowedMdComponents:(_a={RedocResponse:{component:RedocResponse,propsSelector:function(e){return{store:e}}},PullRight:{component:PullRight,propsSelector:function(){return{}}}},_a[SCHEMA_DEFINITION_JSX_NAME]={component:SchemaDefinition,propsSelector:function(e){return{parser:e.definition.parser,options:e.options,layout:e.layout,showRightPanel:e.showRightPanel}}},_a[SECURITY_DEFINITIONS_COMPONENT_NAME]={component:SecurityDefs,propsSelector:function(e){return{securitySchemes:e.definition.securitySchemes}}},_a[SECURITY_DEFINITIONS_JSX_NAME]={component:SecurityDefs,propsSelector:function(e){return{securitySchemes:e.definition.securitySchemes}}},_a)};function joinURLs(e,t){return e.endsWith("/")&&(e=e.slice(0,-1)),t.startsWith("/")&&(t=t.substring(1)),e+"/"+t}function addTrailingSlash(e){return e.endsWith("/")?e:e+"/"}function getSpecVersionObj(e){return e.openapi?{openapi:e.openapi}:e.swagger?{swagger:e.swagger}:void 0}function deepClone(e){if("object"!=typeof e||null===e)return e;var t=Array.isArray(e)?[]:{};for(var i in e){var o=e[i];t[i]=deepClone(o)}return t}
2
2
  //# sourceMappingURL=ProStore.js.map