@redocly/reference-docs 2.42.4 → 2.42.5
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.
- package/bin/cli/commands/redocly-docs-cli.min.js +3 -3
- package/bin/cli/commands/redocly-docs-cli.min.js.LICENSE.txt +1 -1
- package/dist/console.redocly-reference-docs.min.js +1 -1
- package/dist/oauth2-redirect.js +1 -1
- package/dist/redocly-reference-docs.min.js +60 -60
- package/lib/services/ProStore.js +1 -1
- package/lib/services/code-samples/generator.js +1 -1
- package/lib/services/history/PushStateHistoryService.js +1 -1
- package/lib-esm/services/ProStore.js +1 -1
- package/lib-esm/services/code-samples/generator.js +1 -1
- package/lib-esm/services/history/PushStateHistoryService.js +1 -1
- package/package.json +1 -1
package/lib/services/ProStore.js
CHANGED
|
@@ -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);
|
|
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
|
|
@@ -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
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign}from"tslib";import{parse as parseQueryString,stringify as stringifyQueryString}from"query-string";import*as Sampler from"openapi-sampler";import merge from"deepmerge";import{toJS}from"mobx";import{deleteEmptyArrayItem,isArrayOfObjects,serializeParameterValue}from"../../redoc-lib";import{getSecurityDetails,getParameterValue}from"../../utils";import{normalizeMimeType,arrayMergeStrategy}from"../utils";import{MediaTypes}from"../../types";import{l}from"../../redoc-lib/src/services/Labels";import{HTTPSnippet}from"./httpsnippet";import StringUtility from"./httpsnippet/helpers/string-utility";function mapOperationToHAR(e,t){var a,r,i,n,s,o,l,u,p,d,c=t.exampleName,m=void 0===c?"":c,v=t.skipOptionalParameters,h=void 0!==v&&v,f=t.withOAuth2Call,y=void 0!==f&&f,g=t.spec,O=t.generatedPayloadSamplesMaxDepth,S=void 0===O?8:O,
|
|
1
|
+
import{__assign}from"tslib";import{parse as parseQueryString,stringify as stringifyQueryString}from"query-string";import*as Sampler from"openapi-sampler";import merge from"deepmerge";import{toJS}from"mobx";import{deleteEmptyArrayItem,isArrayOfObjects,serializeParameterValue}from"../../redoc-lib";import{getSecurityDetails,getParameterValue}from"../../utils";import{normalizeMimeType,arrayMergeStrategy}from"../utils";import{MediaTypes}from"../../types";import{l}from"../../redoc-lib/src/services/Labels";import{HTTPSnippet}from"./httpsnippet";import StringUtility from"./httpsnippet/helpers/string-utility";function mapOperationToHAR(e,t){var a,r,i,n,s,o,l,u,p,d,c=t.exampleName,m=void 0===c?"":c,v=t.skipOptionalParameters,h=void 0!==v&&v,f=t.withOAuth2Call,y=void 0!==f&&f,g=t.spec,O=t.generatedPayloadSamplesMaxDepth,S=void 0===O?8:O,T=t.pathParams,_=void 0===T?{}:T,C=t.properties,E=void 0===C?{}:C,b=getSecurityData(null===(a=e.security)||void 0===a?void 0:a[0],y),A=b.securityHeaders,P=b.securityCookies,R=b.securityQueries,w=b.securityOAuth2ExtraCalls,D=b.basicAuth,k=null===(i=null===(r=e.requestBody)||void 0===r?void 0:r.content)||void 0===i?void 0:i.active,q={skipNonRequired:h,skipReadOnly:!0,maxSampleDepth:S},H={path:toJS(null===(n=null==e?void 0:e.requestValues)||void 0===n?void 0:n.path),cookie:toJS(null===(s=null==e?void 0:e.requestValues)||void 0===s?void 0:s.cookie),header:toJS(null===(o=null==e?void 0:e.requestValues)||void 0===o?void 0:o.header),query:toJS(null===(l=null==e?void 0:e.requestValues)||void 0===l?void 0:l.query),body:toJS(null===(u=null==e?void 0:e.requestValues)||void 0===u?void 0:u.body)},M=!1,x=e.parameters.filter((function(e){return"header"===e.in})).filter((function(e){return!(h&&!e.required)})).map((function(e){var t;return{name:e.name,value:(null===(t=H.header)||void 0===t?void 0:t[e.name])||getParameterValue("header",e.name)||serializeParameterValue(e,Sampler.sample(e.schema.rawSchema,q,g))}})).map((function(e){return(null==k?void 0:k.name)&&"content-type"===e.name.toLowerCase()&&(M=!0,e.value=k.name),e})).concat(A);!M&&(null==k?void 0:k.name)&&x.unshift({name:"Content-Type",value:null==k?void 0:k.name});var N,U=e.parameters.filter((function(e){return"cookie"===e.in})).filter((function(e){return!(h&&!e.required)})).map((function(e){return parseQueryString(serializeParameterValue(e,Sampler.sample(e.schema.rawSchema,q,g)))})).reduce((function(e,t){for(var a,r=0,i=Object.entries(t);r<i.length;r++){var n=i[r],s=n[0],o=n[1];e.push({name:s,value:String((null===(a=H.cookie)||void 0===a?void 0:a[s])||o)})}return e}),[]).concat(P),j=e.parameters.filter((function(e){return"query"===e.in})).filter((function(e){return!(h&&!e.required)})).map((function(e){return parseQueryString(serializeParameterValue(e,Sampler.sample(e.schema.rawSchema,q,g)))})).reduce((function(e,t){for(var a,r,i,n=0,s=Object.entries(t);n<s.length;n++){var o=s[n],l=o[0],u=o[1];e.push({name:l,value:isArrayOfObjects(null===(a=H.query)||void 0===a?void 0:a[l])&&JSON.stringify(deleteEmptyArrayItem(null===(r=H.query)||void 0===r?void 0:r[l]))||String((null===(i=H.query)||void 0===i?void 0:i[l])||u)})}return e}),[]).concat(R),z=null===(p=e.activeServer)||void 0===p?void 0:p.url.replace(/\/$/,""),V=e.path.replace(/^\//,""),I=z.split("#")[0]+"/"+V,J=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=H.path)||void 0===a?void 0:a[i])||_[i]||getParameterValue(r,i),e}),{}),L=null===(d=null==k?void 0:k.examples)||void 0===d?void 0:d[m],Y=(null==k?void 0:k.examples)||{},Q=Object.values(Y)[0],B=H.body||(null==L?void 0:L.value)||(null==Q?void 0:Q.value)||(null==k?void 0:k.schema)&&Sampler.sample(null==k?void 0:k.schema.rawSchema,q,g),K=null==k?void 0:k.name.toLowerCase(),F=[];switch(normalizeMimeType(K)){case MediaTypes.JSON:case MediaTypes.XML:N=JSON.stringify(getDataRequest(B,E));break;case MediaTypes.URL_ENCODED:case MediaTypes.MULTIPART:N=stringifyQueryString(getDataRequest(B,E)),F=objectToHarParams(getDataRequest(B,E));break;default:N=String(B||"")}var G=N?{mimeType:(null==k?void 0:k.name)||MediaTypes.OCTET_STREAM,text:N,params:F}:void 0,X=e.responses.map((function(e){return e.code}));return{method:e.httpVerb,url:I,httpVersion:"HTTP/1.1",cookies:U,headers:x,queryString:j,postData:G,headersSize:-1,bodySize:-1,securityOAuth2ExtraCalls:w,basicAuth:D,pathParameters:J,serverVariables:e.activeServer.variables,allResponseCodes:X}}var defaultOptions={withImports:!0,withComments:!1},langToSnippetConfig={curl:{code:"shell",defaultTarget:"curl",defaultOptions:__assign(__assign({},defaultOptions),{short:!0})},JavaScript:{code:"javascript",defaultTarget:"fetch",defaultOptions:__assign(__assign({},defaultOptions),{withImports:!1})},"Node.js":{code:"node",defaultTarget:"fetch",defaultOptions:__assign({},defaultOptions)},Python:{code:"python",defaultTarget:"requests",defaultOptions:__assign({},defaultOptions)},"Java8+Apache":{code:"java8",defaultTarget:"apachehttp",defaultOptions:__assign({},defaultOptions)},Java:{code:"java",defaultTarget:"httpclient",defaultOptions:__assign({},defaultOptions)},"C#":{code:"csharp",defaultTarget:"httpclient",defaultOptions:__assign({},defaultOptions)},Go:{code:"go",defaultTarget:"http.DefaultClient",defaultOptions:__assign({},defaultOptions)},PHP:{code:"php",defaultTarget:"curl",defaultOptions:__assign({},defaultOptions)},Ruby:{code:"ruby",defaultTarget:"net::http",defaultOptions:__assign({},defaultOptions)},R:{code:"r",defaultTarget:"httr",defaultOptions:__assign({},defaultOptions)}};export function getCodeSample(e){var t=e.lang,a=e.operation,r=e.exampleName,i=e.pathParams,n=e.properties,s=e.options,o=void 0===s?{}:s;try{var l=mapOperationToHAR(a,{exampleName:r,pathParams:i,properties:n,skipOptionalParameters:o.skipOptionalParameters,withOAuth2Call:o.withOAuth2Call,spec:o.spec,generatedPayloadSamplesMaxDepth:o.generatedPayloadSamplesMaxDepth}),u=new HTTPSnippet(l);return langToSnippetConfig[t]?u.convert(langToSnippetConfig[t].code,langToSnippetConfig[t].defaultTarget,__assign(__assign({},langToSnippetConfig[t].defaultOptions),o)):"Language is not supported."}catch(e){return console.error(e),"Failed to generate code sample."}}function getSecurityData(e,t){for(var a,r,i,n,s={securityHeaders:[],securityCookies:[],securityQueries:[],securityOAuth2ExtraCalls:[],basicAuth:void 0},o=0,u=(null==e?void 0:e.schemes)||[];o<u.length;o++){var p=u[o],d=getSecurityDetails(p.id);switch(p.type){case"openIdConnect":null===(a=s.securityHeaders)||void 0===a||a.push({name:"Authorization",value:"Bearer <YOUR_TOKEN_HERE>"});break;case"oauth2":var c=d.token?(d.token.token_type||"Bearer")+" "+d.token.access_token:"Bearer <YOUR_TOKEN_HERE>";p.flows.clientCredentials&&t?s.securityOAuth2ExtraCalls.push(getOAuth2ClientCredsCallHar(p.flows.clientCredentials,p.scopes,d)):p.flows.password&&t&&s.securityOAuth2ExtraCalls.push(getOAuth2PasswordCallHar(p.flows.password,p.scopes,d)),null===(r=s.securityHeaders)||void 0===r||r.push({name:"Authorization",value:c});break;case"apiKey":var m=d.raw||"YOUR_API_KEY_HERE";"header"===p.in&&(null===(i=s.securityHeaders)||void 0===i||i.push({name:p.name,value:m})),"cookie"===p.in&&s.securityCookies.push({name:p.name,value:m}),"query"===p.in&&s.securityQueries.push({name:p.name,value:m});break;case"http":"basic"===p.scheme?s.basicAuth={username:d.username||"<"+StringUtility.toSnakeCase(l("tryItAuthBasicUsername"))+">",password:d.password||"<"+StringUtility.toSnakeCase(l("tryItAuthBasicPassword"))+">"}:null===(n=s.securityHeaders)||void 0===n||n.push({name:"Authorization",value:capitalizeFirst(p.scheme||"bearer")+" <YOUR_"+(p.bearerFormat||"TOKEN")+"_HERE>"})}}return s}function getOAuth2PasswordCallHar(e,t,a){return{method:"POST",url:e.tokenUrl,httpVersion:"HTTP/1.1",headers:[{name:"Content-Type",value:MediaTypes.URL_ENCODED},{name:"Accept",value:MediaTypes.JSON}],queryString:[],postData:{mimeType: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:MediaTypes.URL_ENCODED},{name:"Accept",value:MediaTypes.JSON}],queryString:[],postData:{mimeType: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 merge(e,t,{arrayMerge:arrayMergeStrategy});try{return merge(JSON.parse(e),t,{arrayMerge: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 n=i[r],s=n[0],o=n[1],l=t?t+"["+s+"]":s;"object"==typeof o&&null!==o?a.push.apply(a,objectToHarParams(o,l)):a.push({name:l,value:String(o)})}return a}export function isDefined(e){return void 0!==e}export function capitalizeFirst(e){return e.charAt(0).toUpperCase()+e.slice(1)}
|
|
2
2
|
//# sourceMappingURL=generator.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import{bind,debounce}from"decko";import EventEmitter from"eventemitter3";import{IS_BROWSER}from"../../redoc-lib";import{isSameHash,joinWithSeparator}from"./helpers";var 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 EventEmitter,this.bind()}return Object.defineProperty(e.prototype,"currentId",{get:function(){if(!IS_BROWSER)return"";var e=decodeURIComponent(window.location.hash.substr(1)),t=window.location.pathname.substring(1);
|
|
1
|
+
import{__decorate}from"tslib";import{bind,debounce}from"decko";import EventEmitter from"eventemitter3";import{IS_BROWSER}from"../../redoc-lib";import{isSameHash,joinWithSeparator}from"./helpers";var 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 EventEmitter,this.bind()}return Object.defineProperty(e.prototype,"currentId",{get:function(){if(!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/"))?joinWithSeparator(t,e):t?"item"===this.pagination&&e.startsWith(this.options.deepLinkPrefix)?joinWithSeparator(t,e,this.options.deepLinkPrefix):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 IS_BROWSER&&(r=window.location.search),(i=e.startsWith("/")?"/"+joinWithSeparator(this.basePath,e.substring(1),"/"):e)+r?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&&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,a=t,o="";if(e.startsWith("section/")||!e){var s=(e||"").split("/")[1];s&&"section"===this.markdownItemsPagination?(a=t+"/section/"+s,o=e):(a=t+"/",o=e)}if(e.startsWith("group/")){var l=e.match(/group\/(.*)\/(paths\/.*\/\w+|operation\/[^/]*)/);if(l)a=t+"/group/"+l[1],o=l[2]||"";else a=t+"/"+e,o=""}"section"===this.pagination&&e.startsWith("tag/")&&(a=t+"/"+(n=e.split("/")).slice(0,2).join("/"),o=n.slice(2).join("/"));"item"===this.pagination&&e.startsWith("tag/")&&(a=t+"/"+e,"section"===(n=e.split("/"))[2]&&(a=t+"/"+n.slice(0,2).join("/"),o=n.slice(2).join("/")));return this.makeUrl(a,o)}}),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(){IS_BROWSER&&window.addEventListener("popstate",this.emit,!1)}}),Object.defineProperty(e.prototype,"dispose",{enumerable:!1,configurable:!0,writable:!0,value:function(){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),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),IS_BROWSER&&null!=e&&!isSameHash(e,this.currentId)){var i=new URL(this.linkForId(e),window.location.href);t?IS_BROWSER&&window.history.replaceState(null,"",i.href):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)}}),__decorate([bind],e.prototype,"replace",null),__decorate([bind],e.prototype,"replaceForField",null),__decorate([bind,debounce],e.prototype,"replaceDebounced",null),e}();export{PushStateHistoryService};
|
|
2
2
|
//# sourceMappingURL=PushStateHistoryService.js.map
|