apiconnect-explorer
Version:
- [Getting Started](#getting-started) - [Configuration](#configuration) * [Required](#required) * [Optional](#optional) - [Usage in React](#usage-in-react) - [Usage outside of React](#usage-outside-of-react) - [Detailed description of options](#detail
1 lines • 4.84 kB
JavaScript
function a(a,d){return g(a)||f(a,d)||c(a,d)||b()}function b(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function c(b,c){if(b){if("string"==typeof b)return d(b,c);var a={}.toString.call(b).slice(8,-1);return"Object"===a&&b.constructor&&(a=b.constructor.name),"Map"===a||"Set"===a?Array.from(b):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?d(b,c):void 0}}function d(b,c){(null==c||c>b.length)&&(c=b.length);for(var d=0,f=Array(c);d<c;d++)f[d]=b[d];return f}function f(b,c){var d=null==b?null:"undefined"!=typeof Symbol&&b[Symbol.iterator]||b["@@iterator"];if(null!=d){var g,h,j,k,l=[],a=!0,m=!1;try{if(j=(d=d.call(b)).next,0===c){if(Object(d)!==d)return;a=!1}else for(;!(a=(g=j.call(d)).done)&&(l.push(g.value),l.length!==c);a=!0);}catch(a){m=!0,h=a}finally{try{if(!a&&null!=d["return"]&&(k=d["return"](),Object(k)!==k))return}finally{if(m)throw h}}return l}}function g(a){if(Array.isArray(a))return a}import h,{useEffect as i,useState as j}from"react";import{useTranslation as k}from"react-i18next";import{useConfig as l}from"./../contexts/config/index.js";import{useApi as m}from"contexts/ApiHandler";import{Switch as n,Route as o,Redirect as p,useParams as q,useHistory as r}from"react-router-dom";import{apiPath as s,decodeChannelName as t}from"./../utils/navigation.js";import{getAPIType as u}from"utils/APITypes";import v from"./Operation.tsx";import w from"./Overview";import x from"./AsyncApiOperationOverview";import y from"./AsyncApiOperationDetail.tsx";import z from"./Webhook.tsx";import A from"./Definitions";import B from"./DocumentationPage.tsx";import C from"./GraphQLDisplay";var D=function(a,b){if(b.includes("/")){var c=b.split("/"),d=D(a,c.shift());return b=c.join("/"),D(d.docs,b)}return a.find(function(a){return a.name===b})},E=function(a,b,c){return a?"/documentation/".concat(b[0].name):"/".concat(s(c[0]),"/overview")};function F(){var a=q(),b=t(a.channel);return h.createElement(x,{channelName:b})}function G(a){var b=a.apiState,c=a.apps,d=a.options,e=q(),f=decodeURIComponent(e.path);return h.createElement(v,{operation:b.currentApi.paths[f][e.method],operationPath:f,operationMethod:e.method,apps:c,"data-testid":"operation",options:d})}function H(a){var b=a.api,c=q(),d=c.event;return h.createElement(z,{api:b,event:d})}function I(a){var b=a.apiHandler,c=q(),d=t(c.channel),e=decodeURIComponent(c.operationId),f=b.api.operations().get(e).action();return h.createElement(y,{channelName:d,channelType:f,operationId:e})}function J(){var a=q(),b=t(a.channel);return h.createElement(y,{channelName:b,channelType:"publish"})}function K(){var a=q(),b=t(a.channel);return h.createElement(y,{channelName:b,channelType:"subscribe"})}function L(){var a=q(),b=t(a.channel);return h.createElement(y,{channelName:b,channelType:"publish"})}function M(a){var b=a.docs,c=a.options,d=a.apis,e=q(),f=D(b,e.docName);return h.createElement(B,{options:c,apis:d,doc:f})}function N(a){var b=a.api,c=a.options,d=a.apis,e=q(),f=D(b["x-embedded-doc"],e.docName);return h.createElement(B,{options:c,apis:d,doc:f})}function O(b){var c=b.apiState,d=l(),e=d.docs,f=d.apis,g=d.apps,q=d.options,s=m(),v=s.api,x=s.apiHandler,y=Array.isArray(e)&&0<e.length,z=j(function(){return E(y,e,f)}),B=a(z,2),D=B[0],O=B[1],P=k(),Q=P.t,t=r();return i(function(){var a=E(y,e,f);a!==D&&(O(a),t.push(a))},[f,e,y,D,t]),h.createElement(n,null,h.createElement(o,{exact:!0,path:["/:api/overview","/:api/try-it"]},"GraphQL"===u(v)?h.createElement(C,{options:q,api:v,infoSectionEntries:c.infoSectionEntries,documentationEntries:c.documentationEntries,apps:g}):h.createElement(w,{infoSectionEntries:c.infoSectionEntries,documentationEntries:c.documentationEntries})),h.createElement(o,{path:"/:api/operation/:path/:method"},h.createElement(G,{apiState:c,apps:g,options:q})),h.createElement(o,{path:"/:api/webhook/:event"},h.createElement(H,{api:v})),h.createElement(o,{path:"/:api/definitions"},h.createElement(A,{options:q,api:v,infoSectionEntries:c.infoSectionEntries})),h.createElement(o,{path:"/:api/:channel/overview"},h.createElement(F,null)),h.createElement(o,{path:"/:api/:channel/operation/:operationId"},h.createElement(I,{apiHandler:x})),h.createElement(o,{path:"/:api/:channel/send"},h.createElement(J,null)),h.createElement(o,{path:"/:api/:channel/subscribe"},h.createElement(K,null)),h.createElement(o,{path:"/:api/:channel/publish"},h.createElement(L,null)),h.createElement(o,{path:"/documentation/:docName+"},h.createElement(M,{docs:e,options:q,apis:f})),h.createElement(o,{path:"/:api/documentation/:docName+"},h.createElement(N,{api:v,options:q,apis:f})),h.createElement(p,{from:"/",to:D,exact:!0}),h.createElement(o,null,h.createElement("div",{"data-testid":"404Error"},Q("error_404"))))}export default O;