@redocly/reference-docs 2.45.9 → 2.45.12
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 +48 -48
- package/bin/cli/commands/redocly-docs-cli.min.js.LICENSE.txt +2 -2
- package/dist/console.redocly-reference-docs.min.js +78 -78
- package/dist/oauth2-redirect.js +1 -1
- package/dist/redocly-reference-docs.min.js +663 -664
- package/lib/components/OperationParameters/OperationParameters.js +1 -1
- package/lib/components/OperationParameters/utils.js +1 -1
- package/lib/components/Overlay/Overlay.js +1 -1
- package/lib/components/RedoclyReferenceDocs.js +1 -1
- package/lib/components/StoreProvider.js +1 -1
- package/lib/components/Tabs/CollapsingTabs/CollapsingTabsBase.js +1 -1
- package/lib/components/VersionSwitcher.js +1 -1
- package/lib/components/common/form.js +1 -1
- package/lib/components/console/ActionPanel.js +1 -1
- package/lib/components/console/AuthPanel.js +1 -1
- package/lib/components/console/Console.js +1 -1
- package/lib/components/console/ConsoleBadges.js +1 -1
- package/lib/components/console/OAuth2Flow.js +1 -1
- package/lib/components/console/OAuth2TokenInput.js +1 -1
- package/lib/components/console/ParameterArray.js +1 -1
- package/lib/components/console/RequestBody/RequestBody.js +1 -1
- package/lib/components/console/RequestBodyForm.js +1 -1
- package/lib/components/console/Scope.js +1 -1
- package/lib/components/console/ServersDropdown/ServersDropdown.js +1 -1
- package/lib/components/console/utils.js +1 -1
- package/lib/components/pluggable/PullRight.js +1 -1
- package/lib/components/shared/Button.js +1 -1
- package/lib/components/styled.elements.js +1 -1
- package/lib/redoc-lib/src/common-elements/Tooltip.js +1 -1
- package/lib/redoc-lib/src/common-elements/fields-layout.js +1 -1
- package/lib/redoc-lib/src/common-elements/fields.js +1 -1
- package/lib/redoc-lib/src/common-elements/icons.js +1 -1
- package/lib/redoc-lib/src/common-elements/panels.js +1 -1
- package/lib/redoc-lib/src/common-elements/perfect-scrollbar.js +1 -1
- package/lib/redoc-lib/src/components/CallbackSamples/CallbackSamples.js +1 -1
- package/lib/redoc-lib/src/components/DiscriminatorDropdown/DiscriminatorDropdown.js +1 -1
- package/lib/redoc-lib/src/components/Fields/EnumValues.js +1 -1
- package/lib/redoc-lib/src/components/Fields/FieldDetails.js +1 -1
- package/lib/redoc-lib/src/components/RequestSamples/useCodeSamples.js +1 -1
- package/lib/redoc-lib/src/components/Schema/ArraySchema.js +1 -1
- package/lib/redoc-lib/src/components/Schema/Schema.js +1 -1
- package/lib/redoc-lib/src/components/SecurityRequirement/SecurityRequirement.js +1 -1
- package/lib/redoc-lib/src/components/SecurityRequirement/SecurityRequirementElement.js +1 -1
- package/lib/redoc-lib/src/components/SecurityRequirement/SecurityRequirementPanelDescription.js +1 -1
- package/lib/redoc-lib/src/components/SideMenu/styled.elements.js +1 -1
- package/lib/redoc-lib/src/components/StickySidebar/ChevronSvg.js +1 -1
- package/lib/redoc-lib/src/components/StickySidebar/StickyResponsiveSidebar.js +1 -1
- package/lib/redoc-lib/src/services/MarkdownRenderer.js +1 -1
- package/lib/redoc-lib/src/services/MenuBuilder.js +1 -1
- package/lib/redoc-lib/src/services/OpenAPIParser.js +1 -1
- package/lib/redoc-lib/src/services/RedocNormalizedOptions.js +1 -1
- package/lib/redoc-lib/src/services/models/Example.js +1 -1
- package/lib/redoc-lib/src/services/models/Schema.js +1 -1
- package/lib/redoc-lib/src/services/models/SecurityRequirement.js +1 -1
- package/lib/redoc-lib/src/theme.js +1 -1
- package/lib/redoc-lib/src/utils/helpers.js +1 -1
- package/lib/redoc-lib/src/utils/index.d.ts +1 -0
- package/lib/redoc-lib/src/utils/index.js +1 -1
- package/lib/redoc-lib/src/utils/jsonToHtml.js +1 -1
- package/lib/redoc-lib/src/utils/media-css.js +1 -1
- package/lib/redoc-lib/src/utils/memoize.js +1 -1
- package/lib/redoc-lib/src/utils/openapi.js +1 -1
- package/lib/redoc-lib/src/utils/url.d.ts +1 -0
- package/lib/redoc-lib/src/utils/url.js +2 -0
- package/lib/services/OAuth2.js +1 -1
- package/lib/services/ProMenu.js +1 -1
- package/lib/services/ProStore.js +1 -1
- package/lib/services/SearchStore.js +1 -1
- package/lib/services/code-samples/generator.js +1 -1
- package/lib/services/code-samples/httpsnippet/helpers/code-builder.js +1 -1
- package/lib/services/code-samples/httpsnippet/helpers/code-helpers.js +1 -1
- package/lib/services/code-samples/httpsnippet/helpers/lodash-int.js +1 -1
- package/lib/services/code-samples/httpsnippet/index.js +1 -1
- package/lib/services/code-samples/httpsnippet/targets/csharp/httpclient.js +1 -1
- package/lib/services/code-samples/httpsnippet/targets/csharpNewtonsoft/httpclient.js +1 -1
- package/lib/services/code-samples/httpsnippet/targets/go/native.js +1 -1
- package/lib/services/code-samples/httpsnippet/targets/java/httpclient.js +1 -1
- package/lib/services/code-samples/httpsnippet/targets/java8/apachehttp.js +1 -1
- package/lib/services/code-samples/httpsnippet/targets/javascript/fetch.js +1 -1
- package/lib/services/code-samples/httpsnippet/targets/node/fetch.js +1 -1
- package/lib/services/code-samples/httpsnippet/targets/php/curl.js +1 -1
- package/lib/services/code-samples/httpsnippet/targets/php/utils.js +1 -1
- package/lib/services/code-samples/httpsnippet/targets/python/requests.js +1 -1
- package/lib/services/code-samples/httpsnippet/targets/r/httr.js +1 -1
- package/lib/services/code-samples/httpsnippet/targets/r/utils.js +1 -1
- package/lib/services/code-samples/httpsnippet/targets/ruby/native.js +1 -1
- package/lib/services/extendTheme.js +1 -1
- package/lib/services/utils.js +1 -1
- package/lib/utils.js +1 -1
- package/lib-browser/components/console/AuthPanel.js +1 -1
- package/lib-browser/redoc-lib/src/services/models/Example.js +1 -1
- package/lib-browser/redoc-lib/src/utils/helpers.js +1 -1
- package/lib-browser/redoc-lib/src/utils/index.d.ts +1 -0
- package/lib-browser/redoc-lib/src/utils/index.js +1 -1
- package/lib-browser/redoc-lib/src/utils/url.d.ts +1 -0
- package/lib-browser/redoc-lib/src/utils/url.js +2 -0
- package/lib-browser/services/code-samples/httpsnippet/index.js +1 -1
- package/lib-browser/services/utils.js +1 -1
- package/lib-esm/components/console/AuthPanel.js +1 -1
- package/lib-esm/redoc-lib/src/services/models/Example.js +1 -1
- package/lib-esm/redoc-lib/src/utils/helpers.js +1 -1
- package/lib-esm/redoc-lib/src/utils/index.d.ts +1 -0
- package/lib-esm/redoc-lib/src/utils/index.js +1 -1
- package/lib-esm/redoc-lib/src/utils/url.d.ts +1 -0
- package/lib-esm/redoc-lib/src/utils/url.js +2 -0
- package/lib-esm/services/code-samples/httpsnippet/index.js +1 -1
- package/lib-esm/services/utils.js +1 -1
- package/package.json +3 -4
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.info=void 0;var tslib_1=require("tslib"),stringify_object_1=(0,tslib_1.__importDefault)(require("stringify-object")),code_builder_1=require("../../helpers/code-builder"),__1=require("../.."),code_helpers_1=require("../../helpers/code-helpers"),utils_1=require("../../../../utils"),generator_1=require("../../../generator"),constants_1=require("../../helpers/constants"),types_1=require("../../../../../types"),handler=function(e,t,s){var a,n,i,r,o=s.target,p=s.client,u=Object.assign({indent:" ",withWrapper:!0},t),l=new code_builder_1.CodeBuilder({indentation:u.indent,variablesPrefix:u.variablesPrefix,capitalize:!0,lang:constants_1.Lang.CSHARPNEWTONSOFT}),c=formatHttpMethod(e.method);if(u.withComments&&addComments(l),u.withWrapper&&(l.push("using System;"),l.push("using System.Net.Http;"),l.push("using System.Threading.Tasks;"),(g(types_1.MediaTypes.JSON)||g(types_1.MediaTypes.XML)||e.basicAuth)&&l.push("using System.Text;"),(g(types_1.MediaTypes.URL_ENCODED)||(null===(a=e.securityOAuth2ExtraCalls)||void 0===a?void 0:a.length))&&l.push("using System.Collections.Generic;"),(g(types_1.MediaTypes.JSON)||(null===(n=e.securityOAuth2ExtraCalls)||void 0===n?void 0:n.length))&&l.push("using Newtonsoft.Json.Linq;"),T()&&l.push("using System.IO;"),(T()||e.basicAuth)&&l.push("using System.Net.Http.Headers;"),l.blank(),l.push("public class Program"),l.push("{"),l.push(1,"private readonly IHttpClientFactory _httpClientFactory;"),l.push(1,"public static async Task Main(string[] args)"),l.push(1,"{"),l.push(2,"var client = _httpClientFactory.CreateClient();")),null===(i=e.securityOAuth2ExtraCalls)||void 0===i?void 0:i.length){var h=new __1.HTTPSnippet(null===(r=e.securityOAuth2ExtraCalls)||void 0===r?void 0:r[0]).convert(o,p,(0,tslib_1.__assign)((0,tslib_1.__assign)({},u),{withImports:!1,withWrapper:!1,withComments:!1,variablesPrefix:"oauth2"}));l.push(h),l.push(2,"var oauth2Response = await oauth2Request.Content.ReadAsStringAsync();"),l.push(2,"JObject inputJObject = JObject.Parse(oauth2Response);"),l.push(2,'var accessToken = inputJObject["access_token"].ToString();'),l.blank()}var d=Object.keys(e.allHeaders).filter((function(e){switch(e.toLowerCase()){case"content-type":case"content-length":case"accept-encoding":return!1;default:return!0}}));if(d.length&&d.forEach((function(t){var s;l.push(2,'client.DefaultRequestHeaders.Add("%s", %s);',t,(null===(s=e.securityOAuth2ExtraCalls)||void 0===s?void 0:s.length)?'"Bearer " + accessToken':'"'
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.info=void 0;var tslib_1=require("tslib"),stringify_object_1=(0,tslib_1.__importDefault)(require("stringify-object")),code_builder_1=require("../../helpers/code-builder"),__1=require("../.."),code_helpers_1=require("../../helpers/code-helpers"),utils_1=require("../../../../utils"),generator_1=require("../../../generator"),constants_1=require("../../helpers/constants"),types_1=require("../../../../../types"),handler=function(e,t,s){var a,n,i,r,o=s.target,p=s.client,u=Object.assign({indent:" ",withWrapper:!0},t),l=new code_builder_1.CodeBuilder({indentation:u.indent,variablesPrefix:u.variablesPrefix,capitalize:!0,lang:constants_1.Lang.CSHARPNEWTONSOFT}),c=formatHttpMethod(e.method);if(u.withComments&&addComments(l),u.withWrapper&&(l.push("using System;"),l.push("using System.Net.Http;"),l.push("using System.Threading.Tasks;"),(g(types_1.MediaTypes.JSON)||g(types_1.MediaTypes.XML)||e.basicAuth)&&l.push("using System.Text;"),(g(types_1.MediaTypes.URL_ENCODED)||(null===(a=e.securityOAuth2ExtraCalls)||void 0===a?void 0:a.length))&&l.push("using System.Collections.Generic;"),(g(types_1.MediaTypes.JSON)||(null===(n=e.securityOAuth2ExtraCalls)||void 0===n?void 0:n.length))&&l.push("using Newtonsoft.Json.Linq;"),T()&&l.push("using System.IO;"),(T()||e.basicAuth)&&l.push("using System.Net.Http.Headers;"),l.blank(),l.push("public class Program"),l.push("{"),l.push(1,"private readonly IHttpClientFactory _httpClientFactory;"),l.push(1,"public static async Task Main(string[] args)"),l.push(1,"{"),l.push(2,"var client = _httpClientFactory.CreateClient();")),null===(i=e.securityOAuth2ExtraCalls)||void 0===i?void 0:i.length){var h=new __1.HTTPSnippet(null===(r=e.securityOAuth2ExtraCalls)||void 0===r?void 0:r[0]).convert(o,p,(0,tslib_1.__assign)((0,tslib_1.__assign)({},u),{withImports:!1,withWrapper:!1,withComments:!1,variablesPrefix:"oauth2"}));l.push(h),l.push(2,"var oauth2Response = await oauth2Request.Content.ReadAsStringAsync();"),l.push(2,"JObject inputJObject = JObject.Parse(oauth2Response);"),l.push(2,'var accessToken = inputJObject["access_token"].ToString();'),l.blank()}var d=Object.keys(e.allHeaders).filter((function(e){switch(e.toLowerCase()){case"content-type":case"content-length":case"accept-encoding":return!1;default:return!0}}));if(d.length&&d.forEach((function(t){var s;l.push(2,'client.DefaultRequestHeaders.Add("%s", %s);',t,(null===(s=e.securityOAuth2ExtraCalls)||void 0===s?void 0:s.length)?'"Bearer " + accessToken':'"'.concat(e.allHeaders[t],'"'))})),e.basicAuth){var m=e.basicAuth,y=m.username,_=m.password;l.push(2,'var base64String = Convert.ToBase64String(Encoding.ASCII.GetBytes("'.concat(y,":").concat(_,'"));')),l.push(2,'client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(@"Basic", base64String);')}if(e.postData)switch((0,utils_1.normalizeMimeType)(e.postData.mimeType)){case types_1.MediaTypes.URL_ENCODED:e.postData.params&&(l.blank(),l.push(2,"List<KeyValuePair<string, string>> postData = new List<KeyValuePair<string, string>>();"),e.postData.params.forEach((function(e){l.push(2,'postData.Add(new KeyValuePair<string, string>("%s", "%s"));',e.name,e.value)})),l.blank());break;case types_1.MediaTypes.MULTIPART:e.postData.params&&(l.blank(),l.push(2,"MultipartFormDataContent postData = new MultipartFormDataContent();"),e.postData.params.forEach((function(e){l.push(2,'postData.Add(new StringContent("%s"), "%s");',e.value,e.name)})));break;case types_1.MediaTypes.JSON:e.postData.jsonObj&&(l.push(2,'JObject json = JObject.Parse(@"'.concat((0,code_helpers_1.addIndentation)((0,stringify_object_1.default)(e.postData.jsonObj,{indent:u.indent,inlineCharacterLimit:25}).replace(/"/g,'""'),{level:3,firstLine:!1}),'");')),l.push(2,'var postData = new StringContent(json.ToString(), Encoding.UTF8, "%s");',e.postData.mimeType));break;case types_1.MediaTypes.XML:e.postData.text&&(e.postData.text.trim().split("\n").forEach((function(e,t){var s=(0===t?'string xml = @"':"")+e.replace(/"/g,'""');l.push(0===t?3:4,s)})),l.push(2,'";'),l.push(2,'var postData = new StringContent(xml, Encoding.UTF8, "%s");',e.postData.mimeType))}else T()&&(l.push(2,"var ms = new MemoryStream();"),l.push(2,"var postData = new StreamContent(ms);"),l.push(2,'postData.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");'));return(0,code_helpers_1.printUrlVariablesDeclarations)(e,l,3),l.push(2,"var %s = await client.%sAsync(%s%s);",l.var("request"),c,(0,code_helpers_1.buildUrlExpression)(e,l),u.withImports?isDataMethod(e.method)?(0,utils_1.normalizeMimeType)(e.postData&&e.postData.mimeType)===types_1.MediaTypes.URL_ENCODED?", new FormUrlEncodedContent(postData)":"delete"===e.method?"":e.postData&&e.postData.params||T()?", postData":", null":"":", new FormUrlEncodedContent(postData)"),u.withWrapper&&(l.push(2,"var response = await request.Content.ReadAsStringAsync();"),l.blank(),l.push(2,"Console.WriteLine(response);"),l.push(1,"}"),l.push("}")),l.join();function g(t){return e.postData&&(0,utils_1.normalizeMimeType)(e.postData.mimeType)===t}function T(){return e.headersObj&&e.headersObj["Content-Type"]===types_1.MediaTypes.OCTET_STREAM}};function addComments(e){e.push("/*"),e.push(" * Requires >= .NET 5"),e.push(" *"),e.push(' * Requires package "Newtonsoft.Json" >= 9.01'),e.push(" * See here for installation details:"),e.push(" * https://www.newtonsoft.com/json"),e.push(" */"),e.blank()}function formatHttpMethod(e){return(0,generator_1.capitalizeFirst)(e.toLowerCase())}function isDataMethod(e){return e&&["POST","PUT","DELETE","PATCH"].includes(e.toUpperCase())}exports.info={key:"httpclient",title:"HttpClient",link:"https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient",description:".NET Standard HTTP Client"},exports.default=handler;
|
|
2
2
|
//# sourceMappingURL=httpclient.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.info=void 0;var tslib_1=require("tslib"),code_builder_1=require("../../helpers/code-builder"),__1=require("../.."),constants_1=require("../../helpers/constants"),code_helpers_1=require("../../helpers/code-helpers"),utils_1=require("../../../../utils"),types_1=require("../../../../../types"),indent=1;function hasMimeType(e,t){return void 0===e&&(e={}),(0,utils_1.normalizeMimeType)(e.mimeType)===t}var handler=function(e,t,s){var
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.info=void 0;var tslib_1=require("tslib"),code_builder_1=require("../../helpers/code-builder"),__1=require("../.."),constants_1=require("../../helpers/constants"),code_helpers_1=require("../../helpers/code-helpers"),utils_1=require("../../../../utils"),types_1=require("../../../../../types"),indent=1;function hasMimeType(e,t){return void 0===e&&(e={}),(0,utils_1.normalizeMimeType)(e.mimeType)===t}var handler=function(e,t,s){var a,n,r,i,o,p,d=s.target,l=s.client,u=(0,tslib_1.__assign)({capitalize:!0,showBoilerplate:!0,checkErrors:!0,printBody:!0,timeout:-1,indent:" "},t),c=null===(a=e.securityOAuth2ExtraCalls)||void 0===a?void 0:a[0],h=u.checkErrors?"err":"_",y=e.method.toUpperCase(),v=new code_builder_1.CodeBuilder({indentation:u.indent,variablesPrefix:u.variablesPrefix,capitalize:u.capitalize,lang:constants_1.Lang.GO}),m=function(){u.checkErrors&&v.push(indent,"if err != nil {").push(indent+1,"panic(err)").push(indent,"}")};if(u.showBoilerplate&&(v.push("package main").blank().push("import (").push(indent,'"fmt"'),u.timeout>0&&v.push(indent,'"time"'),c&&v.push(indent,'"encoding/json"'),hasMimeType(e.postData,types_1.MediaTypes.MULTIPART)&&(v.push(indent,'"mime/multipart"'),v.push(indent,'"io"'),v.push(indent,'"bytes"')),(hasMimeType(e.postData,types_1.MediaTypes.URL_ENCODED)||hasMimeType(null===(r=null===(n=e.securityOAuth2ExtraCalls)||void 0===n?void 0:n[0])||void 0===r?void 0:r.postData,types_1.MediaTypes.URL_ENCODED))&&(v.push(indent,'"net/url"'),v.push(indent,'"strconv"')),(hasMimeType(e.postData,types_1.MediaTypes.JSON)||hasMimeType(null===(o=null===(i=e.securityOAuth2ExtraCalls)||void 0===i?void 0:i[0])||void 0===o?void 0:o.postData,types_1.MediaTypes.JSON))&&v.push(indent,'"bytes"'),(e.postData&&!hasMimeType(e.postData,types_1.MediaTypes.JSON)||c)&&v.push(indent,'"strings"'),v.push(indent,'"net/http"'),u.printBody&&v.push(indent,'"io/ioutil"'),v.push(")").blank().push("func main() {")),Object.keys(e.allHeaders).length&&Object.keys(e.allHeaders).forEach((function(t){e.allHeaders[t]='"'.concat(e.allHeaders[t],'"')})),c){var _="oAuth2",b=u.checkErrors?"".concat(h," := "):"",f=u.capitalize?"Res":"res",q=new __1.HTTPSnippet(c).convert(d,l,(0,tslib_1.__assign)((0,tslib_1.__assign)({},u),{printBody:!1,variablesPrefix:_,showBoilerplate:!1}));v.push(q).blank().push(indent,"var ".concat(_).concat(f,"Body struct {")).push(indent+1,"Access_token string").push(indent,"}").push(indent,"".concat(b,"json.NewDecoder(").concat(_).concat(f,".Body).Decode(&").concat(_).concat(f,"Body)")).blank(),m(),e.allHeaders.Authorization='"Bearer " + '.concat(_).concat(f,"Body.Access_token")}if((0,code_helpers_1.printUrlVariablesDeclarations)(e,v,indent),u.timeout>0&&(l=v.var("client"),v.push(indent,"%s := http.Client{",l).push(indent+1,"Timeout: time.Duration(%s * time.Second),",u.timeout).push(indent,"}").blank()),v.push(indent,"".concat(v.var("reqUrl")," := ").concat((0,code_helpers_1.buildUrlExpression)(e,v))),e.postData){var w=void 0;switch((0,utils_1.normalizeMimeType)(e.postData.mimeType)){case types_1.MediaTypes.URL_ENCODED:v.push(indent,"%s := url.Values{}",v.var("data")),e.postData.params.forEach((function(e){v.push(indent,'%s.Set("%s", "%s")',v.var("data"),e.name,e.value)})),v.push(indent,'%s, %s := http.NewRequest("%s", %s, strings.NewReader(%s.Encode()))',v.var("req"),h,y,v.var("reqUrl"),v.var("data")),e.allHeaders["Content-Length"]="strconv.Itoa(len(".concat(v.var("data"),".Encode()))");break;case types_1.MediaTypes.JSON:w=JSON.stringify(e.postData.jsonObj,null,2).split("\n").map((function(e){return u.indent+e})).join("\n").trim(),v.push(indent,"var ".concat(v.var("data")," = []byte(`").concat(w,"`)")),v.push(indent,'%s, %s := http.NewRequest("%s", %s, bytes.NewBuffer(%s))',v.var("req"),h,y,v.var("reqUrl"),v.var("data"));break;case types_1.MediaTypes.MULTIPART:v.push(indent,"%s := &bytes.Buffer{}",v.var("data")).push(indent,"writer := multipart.NewWriter(%s)",v.var("data")),e.postData.params.forEach((function(e){if(!e.fileName&&!e.contentType)return v.push(indent,'%s, _ := writer.CreateFormField("%s")',v.var("".concat(e.name,"Fw")),e.name).push(indent,'_, %s = io.Copy(%s, strings.NewReader("%s"))',h,v.var("".concat(e.name,"Fw")),e.value),void m();e.fileName&&(v.push(indent,'%s, %s = writer.CreateFormFile("%s", "%s")',v.var("".concat(e.name,"Fw")),h,e.name,e.fileName),m())})),v.push(indent,"writer.Close()").blank().push(indent,"%s := bytes.NewReader(%s.Bytes())",v.var("payload"),v.var("data")).push(indent,'%s, %s := http.NewRequest("%s", %s, %s)',v.var("req"),h,y,v.var("reqUrl"),v.var("payload")),e.allHeaders["Content-Type"]="writer.FormDataContentType()";break;default:e.postData.text&&v.push(indent,"%s := strings.NewReader(%s)",v.var("payload"),JSON.stringify(null===(p=e.postData)||void 0===p?void 0:p.text)).push(indent,'%s, %s := http.NewRequest("%s", %s, %s)',v.var("req"),h,y,v.var("reqUrl"),v.var("payload"))}}else v.push(indent,'%s, %s := http.NewRequest("%s", %s, nil)',v.var("req"),h,y,v.var("reqUrl"));if(Object.getOwnPropertyNames(e.queryObj).length){for(var T in v.blank().push(indent,"".concat(v.var("query")," := ").concat(v.var("req"),".URL.Query()")),e.queryObj){var g=e.queryObj[T],N="string"==typeof g&&/^\[.*\]$/.test(g)?"`".concat(g,"`"):'"'.concat(g,'"');v.push(indent,"".concat(v.var("query"),'.Add("').concat(T,'", ').concat(N,")"))}v.push(indent,"".concat(v.var("req"),".URL.RawQuery = ").concat(v.var("query"),".Encode()")).blank()}if(m(),e.basicAuth){var k=e.basicAuth,D=k.username,O=k.password;v.push(indent,'%s.SetBasicAuth("'.concat(D,'", "').concat(O,'")'),v.var("req"))}return Object.keys(e.allHeaders).length&&Object.keys(e.allHeaders).forEach((function(t){v.push(indent,'%s.Header.Add("%s", %s)',v.var("req"),t,e.allHeaders[t])})),v.push(indent,"%s, %s := %s.Do(%s)",v.var("res"),h,l,v.var("req")),m(),u.printBody&&(v.push(indent,"defer %s.Body.Close()",v.var("res")).push(indent,"%s, %s := ioutil.ReadAll(%s.Body)",v.var("body"),h,v.var("res")),m()),v.blank().push(indent,"fmt.Println(%s)",v.var("res")),u.printBody&&v.push(indent,"fmt.Println(string(%s))",v.var("body")),u.showBoilerplate&&v.push("}"),v.join()};exports.info={key:"native",title:"NewRequest",link:"http://golang.org/pkg/net/http/#NewRequest",description:"Golang HTTP client request"},exports.default=handler;
|
|
2
2
|
//# sourceMappingURL=native.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.info=void 0;var tslib_1=require("tslib"),code_builder_1=require("../../helpers/code-builder"),__1=require("../.."),utils_1=require("../../../../utils"),code_helpers_1=require("../../helpers/code-helpers"),constants_1=require("../../helpers/constants"),types_1=require("../../../../../types"),hasQueryParams=function(e){return!(!e.uriObj.query||!Object.keys(e.uriObj.query).length)},getBody=function(e){return e.postData&&e.postData.mimeType===types_1.MediaTypes.URL_ENCODED?"HttpRequest.BodyPublishers.ofString(form)":e.postData?"HttpRequest.BodyPublishers.ofString(payload)":["POST","PUT","PATCH"].includes(e.method.toUpperCase())?'HttpRequest.BodyPublishers.ofString("some body text")':""},handler=function(e,t,a){var s,r,i,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.info=void 0;var tslib_1=require("tslib"),code_builder_1=require("../../helpers/code-builder"),__1=require("../.."),utils_1=require("../../../../utils"),code_helpers_1=require("../../helpers/code-helpers"),constants_1=require("../../helpers/constants"),types_1=require("../../../../../types"),hasQueryParams=function(e){return!(!e.uriObj.query||!Object.keys(e.uriObj.query).length)},getBody=function(e){return e.postData&&e.postData.mimeType===types_1.MediaTypes.URL_ENCODED?"HttpRequest.BodyPublishers.ofString(form)":e.postData?"HttpRequest.BodyPublishers.ofString(payload)":["POST","PUT","PATCH"].includes(e.method.toUpperCase())?'HttpRequest.BodyPublishers.ofString("some body text")':""},handler=function(e,t,a){var s,r,i,n=a.target,p=a.client,o=Object.assign({indent:" ",withWrapper:!0},t),l=new code_builder_1.CodeBuilder({indentation:o.indent,variablesPrefix:o.variablesPrefix,capitalize:!0,lang:constants_1.Lang.JAVA});if(o.withComments&&addComments(l,e),o.withImports&&addImports(l,e),o.withWrapper&&(l.push("public class App {"),l.push(1,"public static void main(String[] args) throws Exception {"),l.push(2,"var httpClient = HttpClient.newBuilder().build();"),l.blank()),null===(s=e.securityOAuth2ExtraCalls)||void 0===s?void 0:s.length){var u=new __1.HTTPSnippet(null===(r=e.securityOAuth2ExtraCalls)||void 0===r?void 0:r[0]).convert(n,p,(0,tslib_1.__assign)((0,tslib_1.__assign)({},o),{withImports:!1,withWrapper:!1,withComments:!1,variablesPrefix:"oauth2"}));l.push(u),l.blank(),l.push(2,"var oauth2Response = httpClient.send(oauth2Request, HttpResponse.BodyHandlers.ofString());"),l.push(2,'var accessToken = new JSONObject(oauth2Response.body()).getString("access_token");'),l.blank()}if(e.postData)switch((0,utils_1.normalizeMimeType)(e.postData.mimeType)){case types_1.MediaTypes.URL_ENCODED:e.postData.params&&(l.push(2,"HashMap<String, String> params = new HashMap<>();"),e.postData.params.forEach((function(e){l.push(2,'params.put("%s", "%s");',e.name,e.value)})),l.blank(),l.push(2,"var form = params.keySet().stream()"),l.push(3,'.map(key -> key + "=" + URLEncoder.encode(params.get(key), StandardCharsets.UTF_8))'),l.push(3,'.collect(Collectors.joining("&"));'),l.blank());break;case types_1.MediaTypes.JSON:e.postData.jsonObj&&(l.push(2,'var payload = String.join("\\n"\n '.concat((0,code_helpers_1.addIndentation)(JSON.stringify(e.postData.jsonObj,null,1).replace(/"/g,'\\"').replace(/^/gm,', "').replace(/$/gm,'"'),{level:3,indent:o.indent,firstLine:!1}))),l.push(2,");"),l.blank());break;case types_1.MediaTypes.XML:e.postData.text&&(l.push(2,'var payload = String.join("\\n"'),e.postData.text.trim().split("\n").forEach((function(e){var t=e.replace(/"/g,'\\"');l.push(3,', "'.concat(t,'"'))})),l.push(2,");"),l.blank());break;case types_1.MediaTypes.MULTIPART:e.postData.params&&(l.push(2,"var multipartBody = MultipartBodyPublisher.newBuilder();"),e.postData.params&&e.postData.params.forEach((function(e){l.push(2,'multipartBody.append("%s", "%s");',e.name,e.value)})),l.push(2,"var body = multipartBody.build();"),l.blank())}if(hasQueryParams(e)){l.push(2,"HashMap<String, String> params = new HashMap<>();");for(var h=0,d=Object.entries(e.uriObj.query);h<d.length;h++){var c=d[h],m=c[0],v=c[1];l.push(2,'params.put("%s", "%s");',m,v)}l.blank(),l.push(2,"var query = params.keySet().stream()"),l.push(3,'.map(key -> key + "=" + URLEncoder.encode(params.get(key), StandardCharsets.UTF_8))'),l.push(3,'.collect(Collectors.joining("&"));'),l.blank()}l.push(2,"var ".concat(l.var("host"),' = "%s";'),e.uriObj.protocol+"//"+e.uriObj.host),(0,code_helpers_1.printUrlVariablesDeclarations)(e,l,2);var y=(0,tslib_1.__assign)((0,tslib_1.__assign)({},e),{pathname:e.uriObj.pathname});l.push(2,"var ".concat(l.var("pathname")," = %s;"),(0,code_helpers_1.buildUrlExpression)(y,l)),l.push(2,"var ".concat(l.var("request")," = HttpRequest.newBuilder()")),"PATCH"===e.method.toUpperCase()?l.push(3,'.method("PATCH", %s)',getBody(e)):l.push(3,".%s(%s)",e.method.toUpperCase(),getBody(e)),l.push(3,".uri(URI.create(".concat(l.var("host")," + ").concat(l.var("pathname")," %s))"),hasQueryParams(e)?"+ '?' + query":""),(null===(i=e.securityOAuth2ExtraCalls)||void 0===i?void 0:i.length)&&(e.allHeaders.Authorization='"Bearer " + accessToken');var b=Object.keys(e.allHeaders);if(b.length&&b.forEach((function(t){var a;l.push(3,'.header("%s", %s)',t,"Authorization"===t&&(null===(a=e.securityOAuth2ExtraCalls)||void 0===a?void 0:a.length)?e.allHeaders[t]:'"'.concat(e.allHeaders[t],'"'))})),e.basicAuth){var g=e.basicAuth,_=g.username,f=g.password;l.push(3,'.header("Authorization", "Basic " + Base64.getEncoder().encodeToString(("'.concat(_,":").concat(f,'").getBytes()))'))}return l.push(3,".build();"),o.withWrapper&&(l.blank(),l.push(2,"var response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());"),l.blank(),l.push(2,"System.out.println(response.body());"),l.push(1,"}"),l.push("}")),l.join()};function addComments(e,t){var a;e.push("/**"),e.push(" * Requires JDK >= 11"),(null===(a=t.securityOAuth2ExtraCalls)||void 0===a?void 0:a.length)&&(e.push(" *"),e.push(' * Requires package "org.json" >= 20201115'),e.push(" * See here for installation details:"),e.push(" * https://search.maven.org/artifact/org.json/json")),e.push(" */"),e.blank()}function addImports(e,t){var a,s,r,i;e.push("import java.net.*;"),e.push("import java.net.http.*;"),e.push("import java.util.*;"),((0,utils_1.normalizeMimeType)(null===(a=t.postData)||void 0===a?void 0:a.mimeType)===types_1.MediaTypes.URL_ENCODED&&(null===(s=t.postData)||void 0===s?void 0:s.params)||(null===(r=t.securityOAuth2ExtraCalls)||void 0===r?void 0:r.length)||hasQueryParams(t))&&(e.push("import java.nio.charset.StandardCharsets;"),e.push("import java.util.stream.Collectors;")),(null===(i=t.securityOAuth2ExtraCalls)||void 0===i?void 0:i.length)&&e.push("import org.json.JSONObject;"),e.blank()}exports.info={key:"httpclient",title:"HttpClient",link:"https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpClient.html",description:"HttpClient (Java SE 11 & JDK 11 )"},exports.default=handler;
|
|
2
2
|
//# sourceMappingURL=httpclient.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.info=void 0;var tslib_1=require("tslib"),code_builder_1=require("../../helpers/code-builder"),index_1=require("../../index"),utils_1=require("../../../../utils"),generator_1=require("../../../generator"),constants_1=require("../../helpers/constants"),code_helpers_1=require("../../helpers/code-helpers"),types_1=require("../../../../../types"),handler=function(t,e,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.info=void 0;var tslib_1=require("tslib"),code_builder_1=require("../../helpers/code-builder"),index_1=require("../../index"),utils_1=require("../../../../utils"),generator_1=require("../../../generator"),constants_1=require("../../helpers/constants"),code_helpers_1=require("../../helpers/code-helpers"),types_1=require("../../../../../types"),handler=function(t,e,a){var s,r,i=a.target,p=a.client,n=Object.assign({indent:" ",withWrapper:!0},e),o=new code_builder_1.CodeBuilder({indentation:n.indent,variablesPrefix:n.variablesPrefix,capitalize:!0,lang:constants_1.Lang.JAVA8}),u=formatHttpMethod(t.method);if(n.withComments&&addComments(o),n.withImports&&addImports(o,t),n.withWrapper&&(o.push("public class App {"),o.push(1,"public static void main(String[] args ) throws java.io.IOException {"),o.push(2,"HttpClient httpClient = HttpClientBuilder.create().build();"),o.blank()),null===(s=t.securityOAuth2ExtraCalls)||void 0===s?void 0:s.length){var h=new index_1.HTTPSnippet(null===(r=t.securityOAuth2ExtraCalls)||void 0===r?void 0:r[0]).convert(i,p,(0,tslib_1.__assign)((0,tslib_1.__assign)({},n),{withImports:!1,withWrapper:!1,withComments:!1,variablesPrefix:"oauth2"}));o.push(h),o.push(2,"JSONObject %s = new JSONObject(EntityUtils.toString(httpClient.execute(%s).getEntity()));","oauth2Response","oauth2Request"),o.push(2,'String accessToken = %s.getString("access_token");',"oauth2Response"),o.blank()}(0,code_helpers_1.printUrlVariablesDeclarations)(t,o,2);var l=(0,code_helpers_1.buildUrlExpression)(t,o);o.push(2,"%s ".concat(o.var("request")," = new %s(%s);"),u,u,l);var c=Object.keys(t.allHeaders);if(!c.length||t.postData&&t.postData.mimeType==types_1.MediaTypes.MULTIPART||c.forEach((function(e){var a;o.push(2,'%s.setHeader("%s", %s);',o.var("request"),e,(null===(a=t.securityOAuth2ExtraCalls)||void 0===a?void 0:a.length)?'"Bearer " + accessToken':'"'.concat(t.allHeaders[e],'"'))})),t.basicAuth){var d=t.basicAuth,m=d.username,y=d.password;o.push(2,'String encodedString = Base64.getEncoder().encodeToString("'.concat(m,":").concat(y,'".getBytes());')),o.push(2,'%s.setHeader("%s", "%s"+encodedString);',o.var("request"),"Authorization","Basic ")}if(t.postData)switch((0,utils_1.normalizeMimeType)(t.postData.mimeType)){case types_1.MediaTypes.URL_ENCODED:t.postData.params&&(o.blank(),o.push(2,"List<NameValuePair> params = new ArrayList<NameValuePair>();"),t.postData.params.forEach((function(t){o.push(2,'params.add(new BasicNameValuePair("%s", "%s"));',t.name,t.value)})),o.push(2,"%s.setEntity(new UrlEncodedFormEntity(params));",o.var("request")),o.blank());break;case types_1.MediaTypes.MULTIPART:t.postData.params&&(o.push(2,"MultipartEntity reqEntity = new MultipartEntity();"),t.postData.params.forEach((function(t){o.push(2,'reqEntity.addPart("%s", %s);',t.name,isString(t.value)?'new StringBody("'.concat(t.value,'")'):t.value)})),o.push(2,"%s.setEntity(reqEntity);",o.var("request")));break;case types_1.MediaTypes.JSON:if(t.postData.jsonObj){o.push(2,"JSONObject payload = new JSONObject();");for(var g=0,b=Object.entries(t.postData.jsonObj);g<b.length;g++){var v=b[g],f=v[0],O=v[1];Array.isArray(O)?(o.push(2,'payload.put("%s", new JSONArray()',f),O.forEach((function(t){isObject(t)?(o.push(3,".put(new JSONObject()"),j(t,4),o.push(3,")")):o.push(3,".put(%s)",formatValue(t))})),o.push(2,");")):isObject(O)?(o.push(2,'payload.put("%s", new JSONObject()%s',f,(0,utils_1.isEmptyObject)(O)?");":""),j(O,3),(0,utils_1.isEmptyObject)(O)||o.push(2,");")):o.push(2,'payload.put("%s", %s);',f,formatValue(O))}o.push(2,"%s.setEntity(new StringEntity(payload.toString()));",o.var("request"))}break;case types_1.MediaTypes.XML:t.postData.text&&(o.push(2,'String payload = String.join("\\n"'),t.postData.text.trim().split("\n").forEach((function(t){var e=t.replace(/"/g,'\\"');o.push(3,', "'.concat(e,'"'))})),o.push(2,");"),o.push(2,"%s.setEntity(new StringEntity(payload));",o.var("request")))}return n.withWrapper&&(o.push(2,"String ".concat(o.var("response")," = EntityUtils.toString(httpClient.execute(request).getEntity());")),o.blank(),o.push(2,"System.out.println(response);"),o.push(1,"}"),o.push("}")),o.join();function j(t,e){for(var a=0,s=Object.entries(t);a<s.length;a++){var r=s[a],i=r[0],p=r[1];isObject(p)?(o.push(e,'.put("%s", new JSONObject()',i),j(p,e+1),o.push(e,")")):o.push(e,'.put("%s", %s)',i,formatValue(p))}}};function addComments(t){t.push("/**"),t.push(" * Requires JDK >= 8"),t.push(" *"),t.push(" * Requires Apache HttpComponents Client >= 4.3.5"),t.push(" * See here for installation details:"),t.push(" * https://search.maven.org/artifact/org.apache.httpcomponents/httpcomponents-client"),t.push(" *"),t.push(' * Requires package "junit4"'),t.push(" * See here for installation details:"),t.push(" * https://junit.org/junit4"),t.push(" *"),t.push(' * Requires package "org.json" >= 20180130'),t.push(" * See here for installation details:"),t.push(" * https://search.maven.org/artifact/org.json/json"),t.push(" */"),t.blank()}function addImports(t,e){var a,s,r;t.push("import org.apache.http.util.EntityUtils;"),t.push("import org.apache.http.NameValuePair;"),t.push("import org.apache.http.client.HttpClient;"),t.push("import org.apache.http.client.entity.UrlEncodedFormEntity;"),e.method&&addHttpMethodImport(t,e.method),(null===(a=e.securityOAuth2ExtraCalls)||void 0===a?void 0:a.length)&&(null===(s=e.securityOAuth2ExtraCalls)||void 0===s?void 0:s[0].method.toLowerCase())!==e.method.toLowerCase()&&addHttpMethodImport(t,null===(r=e.securityOAuth2ExtraCalls)||void 0===r?void 0:r[0].method),t.push("import org.apache.http.impl.client.HttpClientBuilder;"),t.push("import org.apache.http.message.BasicNameValuePair;"),t.push("import org.apache.http.entity.StringEntity;"),t.push("import org.json.JSONObject;"),t.push("import org.json.JSONArray;"),t.push("import java.util.ArrayList;"),t.push("import java.util.List;"),t.push("import org.apache.http.entity.mime.MultipartEntity;"),t.push("import org.apache.http.entity.mime.content.StringBody;"),e.basicAuth&&t.push("import java.util.Base64;"),t.blank()}function addHttpMethodImport(t,e){var a=formatHttpMethod(e);t.push("import org.apache.http.client.methods.".concat(a,";"))}function formatHttpMethod(t){return"Http"+(0,generator_1.capitalizeFirst)(t.toLowerCase())}function isString(t){return"[object String]"===Object.prototype.toString.call(t)}function isObject(t){var e=typeof t;return"function"===e||"object"===e&&!!t}function formatValue(t){return isString(t)?JSON.stringify(t):null==t?"JSONObject.NULL":t}exports.info={key:"apachehttp",title:"Apache http",link:"https://hc.apache.org/httpcomponents-client-4.5.x/",description:"Apache HttpClient"},exports.default=handler;
|
|
2
2
|
//# sourceMappingURL=apachehttp.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.info=void 0;var tslib_1=require("tslib"),stringify_object_1=(0,tslib_1.__importDefault)(require("stringify-object")),code_builder_1=require("../../helpers/code-builder"),code_helpers_1=require("../../helpers/code-helpers"),utils_1=require("../../../../utils"),__1=require("../.."),constants_1=require("../../helpers/constants"),types_1=require("../../../../../types"),handler=function(e,t,a){var s,r,i,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.info=void 0;var tslib_1=require("tslib"),stringify_object_1=(0,tslib_1.__importDefault)(require("stringify-object")),code_builder_1=require("../../helpers/code-builder"),code_helpers_1=require("../../helpers/code-helpers"),utils_1=require("../../../../utils"),__1=require("../.."),constants_1=require("../../helpers/constants"),types_1=require("../../../../../types"),handler=function(e,t,a){var s,n,r,i,o,c,l=a.target,d=a.client,p=(0,tslib_1.__assign)({indent:" ",credentials:null},t),u=new code_builder_1.CodeBuilder({indentation:p.indent,variablesPrefix:p.variablesPrefix,capitalize:!0,lang:constants_1.Lang.JAVASCRIPT}),h={method:e.method.toUpperCase()};Object.keys(e.headersObj).length&&(h.headers=e.headersObj);var _=!1;if(p.withComments&&addComments(u),null===(s=e.securityOAuth2ExtraCalls)||void 0===s?void 0:s.length){var b=new __1.HTTPSnippet(null===(n=e.securityOAuth2ExtraCalls)||void 0===n?void 0:n[0]).convert(l,d,(0,tslib_1.__assign)((0,tslib_1.__assign)({},p),{withImports:!1,withComments:!1,variablesPrefix:"oAuth2"}));u.push(b),u.blank(),h.headers=h.headers||{},h.headers.Authorization="'Bearer ' + oAuth2Data.access_token",_=!0}null!==p.credentials&&(h.credentials=p.credentials);var m=Object.getOwnPropertyNames(e.queryObj).length;if(m&&u.push("const ".concat(u.var("query")," = new URLSearchParams(").concat((0,stringify_object_1.default)(e.queryObj,{indent:p.indent,inlineCharacterLimit:25}),").toString();")).blank(),e.postData)switch((0,utils_1.normalizeMimeType)(e.postData.mimeType)){case types_1.MediaTypes.URL_ENCODED:h.body=e.postData.paramsObj?"new URLSearchParams(".concat(u.var("formData"),").toString()"):e.postData.text,e.postData.paramsObj&&u.push("const ".concat(u.var("formData")," = ").concat((0,code_helpers_1.addIndentation)((0,stringify_object_1.default)(e.postData.paramsObj,{indent:p.indent,inlineCharacterLimit:25}),{level:0,firstLine:!1}),";")).blank();break;case types_1.MediaTypes.JSON:e.postData.jsonObj&&(h.body="JSON.stringify(".concat((0,code_helpers_1.addIndentation)((0,stringify_object_1.default)(e.postData.jsonObj,{indent:p.indent,inlineCharacterLimit:25}),{level:1,firstLine:!1}),")"));break;case types_1.MediaTypes.MULTIPART:u.push("const ".concat(u.var("form")," = new FormData();")),(null===(r=null==h?void 0:h.headers)||void 0===r?void 0:r["Content-Type"])&&(null===(i=h.headers)||void 0===i||delete i["Content-Type"]),e.postData.params.forEach((function(e){u.push("".concat(u.var("form"),".append(%s, %s);"),JSON.stringify(e.name),JSON.stringify(e.value||e.fileName||""))})),h.body=u.var("form"),u.blank();break;default:e.postData.text&&(h.body="`".concat((0,code_helpers_1.addIndentation)(e.postData.text,{level:2,indent:p.indent,firstLine:!1}).trim(),"`"))}var v=h.headers&&h.headers.Accept&&(0,utils_1.normalizeMimeType)(h.headers.Accept)===types_1.MediaTypes.JSON||(0,utils_1.normalizeMimeType)(null===(o=e.postData)||void 0===o?void 0:o.mimeType)===types_1.MediaTypes.JSON;if(e.basicAuth){var f=e.basicAuth,y=f.username,g=f.password;h.headers=h.headers||{},h.headers.Authorization="'Basic ' + btoa('".concat(y,":").concat(g,"')"),_=!0}(0,code_helpers_1.printUrlVariablesDeclarations)(e,u);var j=(0,code_helpers_1.buildUrlExpression)(e,u);return u.push("const ".concat(u.var("resp")," = await fetch(")).push(1,"`"+j+(m?"?${"+u.var("query")+"}":"")+"`,").push((0,code_helpers_1.addIndentation)((0,stringify_object_1.default)(h,{indent:p.indent,inlineCharacterLimit:25,transform:(0,code_helpers_1.getPreserveTransformer)({body:!0,authorizationHeader:_})}),{level:1,indent:p.indent})).push(");").blank(),(null===(c=e.allResponseCodes)||void 0===c?void 0:c.includes("204"))?(u.push("if (resp.status === 204) {").push(1,"console.log('success');").push("} else {"),u.push(1,"const ".concat(u.var("data")," = await ").concat(u.var("resp"),".").concat(v?"json()":"text()",";")).push(1,"console.log(".concat(u.var("data"),");")).push("}")):u.push("const ".concat(u.var("data")," = await ").concat(u.var("resp"),".").concat(v?"json()":"text()",";")).push("console.log(".concat(u.var("data"),");")),u.join()};function addComments(e){e.push("/**"),e.push(" * Requires ES8-compatible browser: https://caniuse.com/async-functions"),e.push(" */"),e.blank()}exports.info={key:"fetch",title:"fetch",link:"https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch",description:"Perform asynchronous HTTP requests with the Fetch API"},exports.default=handler;
|
|
2
2
|
//# sourceMappingURL=fetch.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.info=void 0;var tslib_1=require("tslib"),stringify_object_1=(0,tslib_1.__importDefault)(require("stringify-object")),code_builder_1=require("../../helpers/code-builder"),code_helpers_1=require("../../helpers/code-helpers"),constants_1=require("../../helpers/constants"),utils_1=require("../../../../utils"),__1=require("../.."),types_1=require("../../../../../types"),handler=function(e,t,a){var s,r,i,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.info=void 0;var tslib_1=require("tslib"),stringify_object_1=(0,tslib_1.__importDefault)(require("stringify-object")),code_builder_1=require("../../helpers/code-builder"),code_helpers_1=require("../../helpers/code-helpers"),constants_1=require("../../helpers/constants"),utils_1=require("../../../../utils"),__1=require("../.."),types_1=require("../../../../../types"),handler=function(e,t,a){var s,n,r,i,o,l,c=a.target,d=a.client,p=Object.assign({indent:" ",showBoilerplate:!0,level:1},t),h=p.level,u=!1,m=new code_builder_1.CodeBuilder({indentation:p.indent,variablesPrefix:p.variablesPrefix,capitalize:!0,lang:constants_1.Lang.NODEJS});p.withComments&&addComments(m),p.withImports&&(m.push("import fetch from 'node-fetch';"),m.blank()),p.showBoilerplate&&m.push("async function run() {");var f={method:e.method.toUpperCase()};Object.keys(e.headersObj).length&&(f.headers=e.headersObj);var _=!1;if(null===(s=e.securityOAuth2ExtraCalls)||void 0===s?void 0:s.length){var b=new __1.HTTPSnippet(null===(n=e.securityOAuth2ExtraCalls)||void 0===n?void 0:n[0]).convert(c,d,(0,tslib_1.__assign)((0,tslib_1.__assign)({},p),{withImports:!1,withComments:!1,variablesPrefix:"oAuth2",showBoilerplate:!1,level:1}));m.push(b),m.blank(),f.headers=f.headers||{},f.headers.Authorization="'Bearer ' + oAuth2Data.access_token",_=!0}var v=Object.getOwnPropertyNames(e.queryObj).length;if(v&&m.push(h,"const ".concat(m.var("query")," = new URLSearchParams(").concat((0,code_helpers_1.addIndentation)((0,stringify_object_1.default)(e.queryObj,{indent:p.indent,inlineCharacterLimit:25}),{level:h,indent:p.indent,firstLine:!1}),").toString();")).blank(),e.postData)switch((0,utils_1.normalizeMimeType)(e.postData.mimeType)){case types_1.MediaTypes.URL_ENCODED:f.body=e.postData.paramsObj?"new URLSearchParams(".concat(m.var("formData"),").toString()"):e.postData.text,e.postData.paramsObj&&m.push(h,"const ".concat(m.var("formData")," = ").concat((0,code_helpers_1.addIndentation)((0,stringify_object_1.default)(e.postData.paramsObj,{indent:p.indent,inlineCharacterLimit:25}),{level:h,firstLine:!1}),";")).blank();break;case types_1.MediaTypes.JSON:e.postData.jsonObj&&(f.body="JSON.stringify(".concat((0,code_helpers_1.addIndentation)((0,stringify_object_1.default)(e.postData.jsonObj,{indent:p.indent,inlineCharacterLimit:25}),{level:h,firstLine:!1}),")"));break;case types_1.MediaTypes.MULTIPART:(null===(r=null==f?void 0:f.headers)||void 0===r?void 0:r["Content-Type"])&&(null===(i=f.headers)||void 0===i||delete i["Content-Type"]),p.withImports&&m.unshift("import FormData from 'form-data';"),m.push(h,"const ".concat(m.var("form")," = new FormData();")),e.postData.params.forEach((function(e){e.fileName||e.fileName||e.contentType?e.fileName&&(u=!0,m.blank(),m.push(h,"".concat(m.var("form"),".append('\" + param.name + \"', fs.createReadStream('\" + param.fileName + \"'));"))):m.push(h,"form.append('"+e.name+"','"+e.value+"');")})),f.body=m.var("form"),m.blank();break;default:e.postData.text&&(f.body="`".concat((0,code_helpers_1.addIndentation)(e.postData.text,{level:h+1,indent:p.indent,firstLine:!1}).trim(),"`"))}if(e.cookies.length){var y="";e.cookies.forEach((function(e){y=y+encodeURIComponent(e.name)+"="+encodeURIComponent(e.value)+"; "})),y=y.trim(),f.headers||(f.headers={}),f.headers.cookie=y}if(e.basicAuth){var g=e.basicAuth,j=g.username,w=g.password;f.headers=f.headers||{},f.headers.Authorization="'Basic ' + Buffer.from('".concat(j,":").concat(w,"').toString('base64')"),_=!0}u&&p.withImports&&m.unshift("import fs from 'fs';");var D=f.headers&&f.headers.Accept&&(0,utils_1.normalizeMimeType)(f.headers.Accept)===types_1.MediaTypes.JSON||(0,utils_1.normalizeMimeType)(null===(o=e.postData)||void 0===o?void 0:o.mimeType)===types_1.MediaTypes.JSON;(0,code_helpers_1.printUrlVariablesDeclarations)(e,m,h);var O=(0,code_helpers_1.buildUrlExpression)(e,m);return m.push(h,"const ".concat(m.var("resp")," = await fetch(")).push(h+1,"`"+O+(v?"?${"+m.var("query")+"}":"")+"`,").push(h+1,(0,code_helpers_1.addIndentation)((0,stringify_object_1.default)(f,{indent:p.indent,inlineCharacterLimit:25,transform:(0,code_helpers_1.getPreserveTransformer)({body:!0,authorizationHeader:_})}),{level:h+1,indent:p.indent,firstLine:!1})).push(h,");").blank(),(null===(l=e.allResponseCodes)||void 0===l?void 0:l.includes("204"))?(m.push(h,"if (resp.status === 204) {").push(h+1,"console.log('success');").push(h,"} else {"),m.push(h+1,"const ".concat(m.var("data")," = await ").concat(m.var("resp"),".").concat(D?"json()":"text()",";")).push(h+1,"console.log(".concat(m.var("data"),");")).push(h,"}")):m.push(h,"const ".concat(m.var("data")," = await ").concat(m.var("resp"),".").concat(D?"json()":"text()",";")).push(h,"console.log(".concat(m.var("data"),");")),p.showBoilerplate&&m.push("}").blank().push("run();"),m.join().replace(/"fs\.createReadStream\(\\"(.+)\\"\)"/,'fs.createReadStream("$1")')};function addComments(e){e.push("/**"),e.push(" * Requires Node.js >= 14"),e.push(" *"),e.push(' * Requires module "node-fetch" >= 2.6.1'),e.push(" * See here for installation details:"),e.push(" * https://www.npmjs.com/package/node-fetch"),e.push(" */"),e.blank()}exports.info={key:"fetch",title:"Fetch",link:"https://github.com/bitinn/node-fetch",description:"Simplified HTTP node-fetch client"},exports.default=handler;
|
|
2
2
|
//# sourceMappingURL=fetch.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.info=void 0;var tslib_1=require("tslib"),util_1=require("util"),code_builder_1=require("../../helpers/code-builder"),__1=require("../.."),constants_1=require("../../helpers/constants"),code_helpers_1=require("../../helpers/code-helpers"),lodash_int_1=require("../../helpers/lodash-int"),utils_1=require("../../../../utils"),types_1=require("../../../../../types"),utils_2=require("./utils");function getVariableName(e,a){return a?"$"
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.info=void 0;var tslib_1=require("tslib"),util_1=require("util"),code_builder_1=require("../../helpers/code-builder"),__1=require("../.."),constants_1=require("../../helpers/constants"),code_helpers_1=require("../../helpers/code-helpers"),lodash_int_1=require("../../helpers/lodash-int"),utils_1=require("../../../../utils"),types_1=require("../../../../../types"),utils_2=require("./utils");function getVariableName(e,a){return a?"$".concat(a).concat((0,lodash_int_1.startCase)(e)):"$".concat(e)}var handler=function(e,a,t){var n,r,s=t.target,o=t.client,i=(0,tslib_1.__assign)({showBoilerplate:!0,checkErrors:!1,printBody:!0,indent:" ",noTags:!0,shortTags:!1,maxRedirects:10,namedErrors:!1,closingTag:!1},a),c=!1,l=new code_builder_1.CodeBuilder({indentation:i.indent,capitalize:!0,lang:constants_1.Lang.PHP}),u=null===(n=e.securityOAuth2ExtraCalls)||void 0===n?void 0:n[0],p=getVariableName("curl",i.variablesPrefix),h=getVariableName("response",i.variablesPrefix),d=getVariableName("error",i.variablesPrefix);if(i.noTags||l.push(i.shortTags?"<?":"<?php").blank(),u){var _="oAuth2",b=new __1.HTTPSnippet(u).convert(s,o,(0,tslib_1.__assign)((0,tslib_1.__assign)({},i),{showBoilerplate:!1,variablesPrefix:_}));l.push(b),l.blank(),e.allHeaders.Authorization='Bearer " . '.concat(getVariableName("response",_),".access_token")}var v=Object.keys(e.headersObj).sort().map((function(a){return"Authorization"===a&&u?(0,util_1.format)('"%s: %s',a,e.allHeaders.Authorization):(0,util_1.format)('"%s: %s"',a,e.headersObj[a])}));if(e.basicAuth){var m=e.basicAuth,y=m.username,T=m.password;v.push('"Authorization: Basic " . base64_encode("'.concat(y,":").concat(T,'")'))}i.showBoilerplate&&l.push("/**").push(" * Requires libcurl").push(" */").blank(),(0,code_helpers_1.printUrlVariablesDeclarations)(e,l);var f="";if(Object.keys(e.queryObj||{}).length){var g=(0,utils_2.objectToPhpArray)(e.queryObj||{},{indent:i.indent});f="$query",l.push("".concat(f," = ").concat(g,";")).blank()}if(l.push("".concat(p," = curl_init();")),l.blank(),e.postData)switch((0,utils_1.normalizeMimeType)(e.postData.mimeType)){case types_1.MediaTypes.JSON:var P=(0,utils_2.objectToPhpArray)(e.postData.jsonObj||{},{indent:i.indent});c=!0,r="json_encode($payload)",l.push("$payload = ".concat(P,";")).blank();break;case types_1.MediaTypes.MULTIPART:var O=e.postData.params.map((function(e){var a=e.name,t=e.value;return"".concat(i.indent,'"').concat(a,'" => "').concat(t,'",\n')})).join("");c=!0,r="$payload",l.push("$payload = array(\n".concat(O,");")).blank();break;case types_1.MediaTypes.URL_ENCODED:var k=e.postData.params.map((function(e){var a=e.name,t=e.value;return"".concat(a,"=").concat(t)})).join("&");c=!0,r="$payload",l.push('$payload = "'.concat(k,'";')).blank();break;default:r=e.postData.text}var R=(0,code_helpers_1.buildUrlExpression)(e,l);f&&(R.endsWith('"')?R=R.slice(0,-1)+'?" . http_build_query('.concat(f,")"):R+=' . "?" . http_build_query('.concat(f,")"));var U=[{escape:!c,name:"CURLOPT_POSTFIELDS",value:r},{escape:!0,name:"CURLOPT_PORT",value:e.uriObj.port},{escape:!1,name:"CURLOPT_URL",value:R},{escape:!1,name:"CURLOPT_RETURNTRANSFER",value:"true"},{escape:!0,name:"CURLOPT_CUSTOMREQUEST",value:e.method.toUpperCase()}];l.push("curl_setopt_array(".concat(p,", ["));var j=new code_builder_1.CodeBuilder({indentation:i.indent,lineJoin:"\n".concat(i.indent),variablesPrefix:i.variablesPrefix,capitalize:!0,lang:constants_1.Lang.PHP});v.length&&j.push("CURLOPT_HTTPHEADER => [").push(1,v.join(",\n"+i.indent+i.indent)).push("],"),U.forEach((function(e){[null,void 0].includes(e.value)||j.push((0,util_1.format)("%s => %s,",e.name,e.escape?JSON.stringify(e.value):e.value))}));var C=e.cookies.map((function(e){return encodeURIComponent(e.name)+"="+encodeURIComponent(e.value)}));return C.length&&j.push((0,util_1.format)('CURLOPT_COOKIE => "%s",',C.join("; "))),l.push(1,j.join()).push("]);").blank().push("".concat(h," = curl_exec(").concat(p,");")).push("".concat(d," = curl_error(").concat(p,");")).blank().push("curl_close(".concat(p,");")).blank().push("if (".concat(d,") {")),i.namedErrors?l.push(1,'echo array_flip(get_defined_constants(true)["curl"])['.concat(d,"];")):l.push(1,'echo "cURL Error #:" . '.concat(d,";")),l.push("} else {").push(1,"echo ".concat(h,";")).push("}"),!i.noTags&&i.closingTag&&l.blank().push("?>"),l.join()};exports.info={key:"curl",title:"cURL",link:"http://php.net/manual/en/book.curl.php",description:"PHP with ext-curl"},exports.default=handler;
|
|
2
2
|
//# sourceMappingURL=curl.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.objectToPhpArray=void 0;var simpleTypes=["number","boolean","function","symbol"];function isRegexp(e){return"[object RegExp]"===Object.prototype.toString.call(e)}function isObject(e){var n=typeof e;return null!==e&&("object"===n||"function"===n)}function objectToPhpArray(e,n,r){void 0===r&&(r="");var t=[];return function e(n,r,i){void 0===r&&(r={}),void 0===i&&(i=""),r.indent=r.indent||"\t";var a={newLine:"\n",newLineOrSpace:"\n",pad:i,indent:i+r.indent},o=function(e){if(void 0===r.inlineCharacterLimit)return e;var n=e.replace(new RegExp(a.newLine,"g"),"").replace(new RegExp(a.newLineOrSpace,"g")," ").replace(new RegExp(a.pad+"|"+a.indent,"g"),"");return n.length<=r.inlineCharacterLimit?n:e.replace(new RegExp(a.newLine+"|"+a.newLineOrSpace,"g"),"\n").replace(new RegExp(a.pad,"g"),i).replace(new RegExp(a.indent,"g"),i+r.indent)};if(-1!==t.indexOf(n))return'"Circular"';if(null===n)return"NULL";if(void 0===n||simpleTypes.includes(typeof n)||isRegexp(n))return String(n);if(n instanceof Date)return"date('"
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.objectToPhpArray=void 0;var simpleTypes=["number","boolean","function","symbol"];function isRegexp(e){return"[object RegExp]"===Object.prototype.toString.call(e)}function isObject(e){var n=typeof e;return null!==e&&("object"===n||"function"===n)}function objectToPhpArray(e,n,r){void 0===r&&(r="");var t=[];return function e(n,r,i){void 0===r&&(r={}),void 0===i&&(i=""),r.indent=r.indent||"\t";var a={newLine:"\n",newLineOrSpace:"\n",pad:i,indent:i+r.indent},o=function(e){if(void 0===r.inlineCharacterLimit)return e;var n=e.replace(new RegExp(a.newLine,"g"),"").replace(new RegExp(a.newLineOrSpace,"g")," ").replace(new RegExp(a.pad+"|"+a.indent,"g"),"");return n.length<=r.inlineCharacterLimit?n:e.replace(new RegExp(a.newLine+"|"+a.newLineOrSpace,"g"),"\n").replace(new RegExp(a.pad,"g"),i).replace(new RegExp(a.indent,"g"),i+r.indent)};if(-1!==t.indexOf(n))return'"Circular"';if(null===n)return"NULL";if(void 0===n||simpleTypes.includes(typeof n)||isRegexp(n))return String(n);if(n instanceof Date)return"date('".concat(n.toISOString(),"')");if(Array.isArray(n)){if(0===n.length)return"array()";t.push(n);var c="array("+a.newLine+n.map((function(t,o){var c=n.length-1===o?a.newLine:","+a.newLineOrSpace,p=e(t,r,i+r.indent);return r.transform&&(p=r.transform(n,o,p)),a.indent+p+c})).join("")+a.pad+")";return t.pop(),o(c)}if(isObject(n)){var p=Object.keys(n);if(r.filter&&(p=p.filter((function(e){var t;return null===(t=r.filter)||void 0===t?void 0:t.call(r,n,e)}))),0===p.length)return Array.isArray(n)?"array()":"(object)[]";t.push(n);c="array("+a.newLine+p.map((function(t,o){var c=p.length-1===o?a.newLine:","+a.newLineOrSpace,u="symbol"==typeof t,l=!u&&/^[a-z$_][a-z$_0-9]*$/i.test(t),f=u||l?t:e(t,r),s=e(n[t],r,i+r.indent);return r.transform&&(s=r.transform(n,t,s)),"".concat(a.indent,'"').concat(String(f),'" => ').concat(s).concat(c)})).join("")+a.pad+")";return t.pop(),o(c)}return n=String(n).replace(/[\r\n]/g,(function(e){return"\n"===e?"\\n":"\\r"})),!1===r.singleQuotes?(n=n.replace(/"/g,'\\"'),'"'.concat(n,'"')):(n=n.replace(/\\?'/g,"\\'"),'"'.concat(n,'"'))}(e,n,r)}exports.objectToPhpArray=objectToPhpArray;
|
|
2
2
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var tslib_1=require("tslib"),util_1=require("util"),code_builder_1=require("../../helpers/code-builder"),utils_1=require("../../../../utils"),code_helpers_1=require("../../helpers/code-helpers"),__1=require("../.."),constants_1=require("../../helpers/constants"),types_1=require("../../../../../types"),handler=function(e,t,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var tslib_1=require("tslib"),util_1=require("util"),code_builder_1=require("../../helpers/code-builder"),utils_1=require("../../../../utils"),code_helpers_1=require("../../helpers/code-helpers"),__1=require("../.."),constants_1=require("../../helpers/constants"),types_1=require("../../../../../types"),handler=function(e,t,a){var s,o,n,r,i=a.target,c=a.client,l=Object.assign({indent:" "},t),u=l.level,p=void 0===u?0:u,d=new code_builder_1.CodeBuilder({indentation:l.indent,variablesPrefix:l.variablesPrefix,lang:constants_1.Lang.PYTHON});l.withComments&&addComments(d),l.withImports&&d.push("import requests").blank();var h,_,v,b=!1,y=e.allHeaders;if(null===(s=e.securityOAuth2ExtraCalls)||void 0===s?void 0:s.length){var f=new __1.HTTPSnippet(null===(o=e.securityOAuth2ExtraCalls)||void 0===o?void 0:o[0]).convert(i,c,(0,tslib_1.__assign)((0,tslib_1.__assign)({},l),{withImports:!1,withComments:!1,variablesPrefix:"oauth2_"}));d.push(f),d.blank(),(y=y||{}).Authorization='"Bearer " + oauth2_data["access_token"]',b=!0}((0,code_helpers_1.printUrlVariablesDeclarations)(e,d),d.push("".concat(d.var("url").toLowerCase()," = %s"),(0,code_helpers_1.buildUrlExpression)(e,d)).blank(),Object.keys(e.queryObj||{}).length)&&(h="query = "+jsObjectToPythonDict(e.queryObj,l.indent),d.push(h).blank());var C,m=(0,utils_1.normalizeMimeType)(null===(n=e.postData)||void 0===n?void 0:n.mimeType),L=[];if(e.postData)switch(m){case types_1.MediaTypes.URL_ENCODED:_=e.postData.paramsObj?"".concat((0,code_helpers_1.addIndentation)(jsObjectToPythonDict(e.postData.paramsObj,l.indent),{level:0,firstLine:!1})):e.postData.text;break;case types_1.MediaTypes.JSON:e.postData.jsonObj&&(_=(0,code_helpers_1.addIndentation)(jsObjectToPythonDict(e.postData.jsonObj,l.indent),{level:0,firstLine:!1}));break;case types_1.MediaTypes.MULTIPART:if(e.postData.params)for(var j=0,w=e.postData.params;j<w.length;j++){var O=w[j];L.push('"'.concat(O.name,'": "').concat(O.value,'"'))}if(L.length){var D=L.map((function(e){return" ".concat(e)})).join(",\n");v="data = {\n".concat(D,"\n}")}v&&d.push(v).blank();break;default:e.postData.text&&(_="'''\n".concat((0,code_helpers_1.addIndentation)(e.postData.text.trim(),{level:1,indent:l.indent,firstLine:!0}),"\n'''"))}_&&d.push("".concat(d.var("payload").toLowerCase()," = %s"),_).blank();var T=Object.keys(y).length,q=function(e,t){return"Authorization"===e&&b?t:'"'.concat(t,'"')};if(1===T)for(C in y)d.push("".concat(d.var("headers").toLowerCase(),' = {"').concat(C,'": ').concat(q(C,y[C]),"}")).blank();else if(T>1){var k=1;for(C in d.push("".concat(d.var("headers").toLowerCase()," = {")),y)k++!==T?d.push(1,'"'.concat(C,'": ').concat(q(C,y[C]),",")):d.push(1,'"'.concat(C,'": ').concat(q(C,y[C])));d.push(0,"}").blank()}var g=e.method.toLowerCase(),P=(0,util_1.format)("".concat(d.var("response").toLowerCase()," = requests.").concat(g,"(").concat(d.var("url").toLowerCase()));if(m===types_1.MediaTypes.MULTIPART&&v&&(P+=", data=data"),_){var x=m===types_1.MediaTypes.JSON?"json":"data";P+=", ".concat(x,"=").concat(d.var("payload").toLowerCase())}return T>0&&(P+=", headers=".concat(d.var("headers").toLowerCase())),h&&(P+=", params=".concat(d.var("query").toLowerCase())),e.basicAuth&&(P+=", auth=('".concat(e.basicAuth.username,"','").concat(e.basicAuth.password,"')")),P+=")",d.push(P).blank(),(null===(r=e.allResponseCodes)||void 0===r?void 0:r.includes("204"))?d.push("if response.status_code == 204:").push(p+1,'print("success")').push("else:").push(p+1,"".concat(d.var("data").toLowerCase()," = ").concat(d.var("response").toLowerCase(),".json()")).push(p+1,"print(".concat(d.var("data").toLowerCase(),")")):d.push("".concat(d.var("data").toLowerCase()," = ").concat(d.var("response").toLowerCase(),".json()")).push("print(".concat(d.var("data").toLowerCase(),")")),d.join()};function addComments(e){e.push('"""'),e.push("Requires python >= 3"),e.blank(),e.push('Requires module "requests" >= 2.25.1'),e.push("See here for installation details:"),e.push(" https://requests.readthedocs.io/"),e.push('"""'),e.blank()}function jsObjectToPythonDict(e,t){return JSON.stringify(e,(function(e,t){return e&&"boolean"==typeof t?t?"__REDOCLY_<True>__":"__REDOCLY_<False>__":null===t?"__REDOCLY_<None>__":t}),t).replace(/"__REDOCLY_<(\w+)>__"/g,"$1")}exports.default=handler;
|
|
2
2
|
//# sourceMappingURL=requests.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var tslib_1=require("tslib"),code_builder_1=require("../../helpers/code-builder"),code_helpers_1=require("../../helpers/code-helpers"),constants_1=require("../../helpers/constants"),__1=require("../.."),utils_1=require("../../../../utils"),types_1=require("../../../../../types"),utils_2=require("./utils"),indent=1,handler=function(e,t,a){var s,r,i,l
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var tslib_1=require("tslib"),code_builder_1=require("../../helpers/code-builder"),code_helpers_1=require("../../helpers/code-helpers"),constants_1=require("../../helpers/constants"),__1=require("../.."),utils_1=require("../../../../utils"),types_1=require("../../../../../types"),utils_2=require("./utils"),indent=1,handler=function(e,t,a){var s,n,r,o,i,l=a.target,c=a.client,p=Object.assign({indent:" ",showBoilerplate:!0,printBody:!0},t),u=new code_builder_1.CodeBuilder({indentation:p.indent,variablesPrefix:p.variablesPrefix,lang:constants_1.Lang.R}),d=e.method.toUpperCase(),_=null===(s=e.securityOAuth2ExtraCalls)||void 0===s?void 0:s[0];if(p.showBoilerplate&&u.push("library(httr)").blank(),_){var b="oauth2_",h=new __1.HTTPSnippet(_).convert(l,c,(0,tslib_1.__assign)((0,tslib_1.__assign)({},p),{variablesPrefix:b,showBoilerplate:!1})),v="".concat(b,"data_req");u.push(h).push("access_token = content(".concat(v,', "parsed")$access_token')).blank(),e.allHeaders.Authorization='paste("Bearer", access_token)'}var y="";if(null==e?void 0:e.postData)switch((0,utils_1.normalizeMimeType)(null===(n=null==e?void 0:e.postData)||void 0===n?void 0:n.mimeType)){case types_1.MediaTypes.URL_ENCODED:i="form",y=u.var("body");var k=(0,utils_2.postDataToRListBody)(e.postData.params,p);u.push("".concat(y," <- list(").concat(k,")")).blank();break;case types_1.MediaTypes.JSON:i="json",y=u.var("body");k=(0,utils_2.objectToRString)(e.postData.jsonObj,p);u.push("".concat(y," = '").concat(k,"'")).blank();break;case types_1.MediaTypes.MULTIPART:i="multipart",y=u.var("body");k=(0,utils_2.postDataToRListBody)(e.postData.params,p);u.push("".concat(y," <- list(").concat(k,")")).blank();break;default:(null===(r=e.postData)||void 0===r?void 0:r.text)&&(y=u.var("body"),i="raw",u.push("".concat(y," = ").concat((0,utils_2.objectToRString)(null===(o=e.postData)||void 0===o?void 0:o.text))).blank())}(0,code_helpers_1.printUrlVariablesDeclarations)(e,u),Object.keys((0,tslib_1.__assign)((0,tslib_1.__assign)({},e.pathParameters),e.serverVariables)).length&&u.blank().push("# create you own operator").push('"%&%" <- function(x, y)paste0(x,y)').blank();var f=(0,code_helpers_1.buildUrlExpression)(e,u);u.push("url = ".concat(f)).blank();var T=u.var("data_req");if(u.push("".concat(T," <- ").concat(d,"(")),u.push(indent,"url,"),e.basicAuth){var g=e.basicAuth,j=g.username,m=g.password;u.push(indent,'authenticate("'.concat(j,'", "').concat(m,'")'))}if(Object.keys(e.allHeaders).length){var x="".concat(Object.keys(e.allHeaders).map((function(t){return'"'.concat(t,'" = ').concat(e.allHeaders[t].startsWith("paste")?e.allHeaders[t]:'"'.concat(e.allHeaders[t],'"'))})).join(", "));x&&u.push(indent,"add_headers(".concat(x,"),"))}return y&&(u.push(indent,"body = ".concat(y,",")),u.push(indent,'encode = "'.concat(i,'",'))),u.push(indent,"verbose()"),u.push(")"),p.printBody&&u.blank().push("content(".concat(T).concat("raw"===i?', "text"':"",")")),u.join()};exports.default=handler;
|
|
2
2
|
//# sourceMappingURL=httr.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";function objectToRString(t,o){return t?"string"==typeof t?JSON.stringify(t):JSON.stringify(t,null,1).split("\n").map((function(t,n,i){return n===i.length-1?t:((null==o?void 0:o.indent)||" ")+t})).join("\n").trim():""}function postDataToRListBody(t,o){return"\n"+t.map((function(t){var n=t.name,i=t.value;return((null==o?void 0:o.indent)||"")+(n
|
|
1
|
+
"use strict";function objectToRString(t,o){return t?"string"==typeof t?JSON.stringify(t):JSON.stringify(t,null,1).split("\n").map((function(t,n,i){return n===i.length-1?t:((null==o?void 0:o.indent)||" ")+t})).join("\n").trim():""}function postDataToRListBody(t,o){return"\n"+t.map((function(t){var n=t.name,i=t.value;return((null==o?void 0:o.indent)||"")+"".concat(n,' = "').concat(i,'"')})).join(",\n")+"\n"}Object.defineProperty(exports,"__esModule",{value:!0}),exports.postDataToRListBody=exports.objectToRString=void 0,exports.objectToRString=objectToRString,exports.postDataToRListBody=postDataToRListBody;
|
|
2
2
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.info=void 0;var tslib_1=require("tslib"),stringify_object_1=(0,tslib_1.__importDefault)(require("stringify-object")),code_builder_1=require("../../helpers/code-builder"),__1=require("../.."),constants_1=require("../../helpers/constants"),code_helpers_1=require("../../helpers/code-helpers"),utils_1=require("../../../../utils"),types_1=require("../../../../../types"),indent=1;function hasMimeType(e,t){return void 0===e&&(e={}),(0,utils_1.normalizeMimeType)(e.mimeType)===t}var handler=function(e,t,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.info=void 0;var tslib_1=require("tslib"),stringify_object_1=(0,tslib_1.__importDefault)(require("stringify-object")),code_builder_1=require("../../helpers/code-builder"),__1=require("../.."),constants_1=require("../../helpers/constants"),code_helpers_1=require("../../helpers/code-helpers"),utils_1=require("../../../../utils"),types_1=require("../../../../../types"),indent=1;function hasMimeType(e,t){return void 0===e&&(e={}),(0,utils_1.normalizeMimeType)(e.mimeType)===t}var handler=function(e,t,a){var s,r,n,o,i,c=a.target,l=a.client,p=e.method.toUpperCase(),u=null===(s=e.securityOAuth2ExtraCalls)||void 0===s?void 0:s[0],d=(0,tslib_1.__assign)({capitalize:!0,showBoilerplate:!0,indent:" "},t),h=new code_builder_1.CodeBuilder({indentation:d.indent,variablesPrefix:d.variablesPrefix,capitalize:d.capitalize,lang:constants_1.Lang.RUBY});d.showBoilerplate&&(h.push("require 'uri'").push("require 'net/http'"),"https:"===e.uriObj.protocol&&h.push("require 'openssl'"),(hasMimeType(e.postData,types_1.MediaTypes.JSON)||u)&&h.unshift("require 'json'"),h.blank()),Object.keys(e.allHeaders).length&&Object.keys(e.allHeaders).forEach((function(t){e.allHeaders[t]="'".concat(e.allHeaders[t],"'")}));var _=p.charAt(0)+p.substring(1).toLowerCase();if(["GET","POST","HEAD","DELETE","PATCH","PUT","OPTIONS","COPY","LOCK","UNLOCK","MOVE","TRACE"].indexOf(p)<0&&h.push("class Net::HTTP::%s < Net::HTTPRequest",_).push(" METHOD = '%s'",p.toUpperCase()).push(" REQUEST_HAS_BODY = '%s'",(null===(r=e.postData)||void 0===r?void 0:r.text)?"true":"false").push(" RESPONSE_HAS_BODY = true").push("end").blank(),u){var b="oAuth2",v=new __1.HTTPSnippet(u).convert(c,l,(0,tslib_1.__assign)((0,tslib_1.__assign)({},d),{variablesPrefix:b,showBoilerplate:!1})),y="".concat(b).concat(d.capitalize?"Response":"response");h.push(v).push("access_token = JSON.parse(".concat(y,".body)['access_token']")).blank(),e.allHeaders.Authorization='"Bearer " + access_token'}if((0,code_helpers_1.printUrlVariablesDeclarations)(e,h),h.push("".concat(h.var("url")," = URI(").concat((0,code_helpers_1.buildUrlExpression)(e,h),")")),Object.getOwnPropertyNames(e.queryObj).length&&(h.push("".concat(h.var("params")," = ").concat((0,stringify_object_1.default)(e.queryObj,{indent:d.indent,inlineCharacterLimit:25}))),h.push("".concat(h.var("url"),".query = URI.encode_www_form(").concat(h.var("params"),")"))),h.blank().push("".concat(h.var("http")," = Net::HTTP.new(").concat(h.var("url"),".host, ").concat(h.var("url"),".port)")),"https:"===e.uriObj.protocol&&h.push("".concat(h.var("http"),".use_ssl = true")),h.blank().push("".concat(h.var("request")," = Net::HTTP::%s.new(").concat(h.var("url"),")"),_),Object.keys(e.allHeaders).length&&Object.keys(e.allHeaders).forEach((function(t){e.allHeaders[t]!=="'".concat(types_1.MediaTypes.MULTIPART,"'")&&h.push("".concat(h.var("request"),"['%s'] = %s"),t,e.allHeaders[t])})),null==e?void 0:e.postData){var T={};switch((0,utils_1.normalizeMimeType)(null===(n=null==e?void 0:e.postData)||void 0===n?void 0:n.mimeType)){case types_1.MediaTypes.URL_ENCODED:e.postData.params.forEach((function(e){T[e.name]=e.value})),h.push("".concat(h.var("request"),".body = URI.encode_www_form(").concat((0,stringify_object_1.default)(T,{indent:d.indent,inlineCharacterLimit:25}),")"));break;case types_1.MediaTypes.JSON:h.push("".concat(h.var("request"),".body = ").concat((0,stringify_object_1.default)(e.postData.jsonObj,{indent:d.indent,inlineCharacterLimit:25}).replace(/null/g,"nil"),".to_json"));break;case types_1.MediaTypes.MULTIPART:e.postData.params&&(h.push("".concat(h.var("form_data")," = [")),e.postData.params.forEach((function(e){h.push(indent,"['".concat(e.name,"', '").concat(e.value,"'],"))})),h.push("]")),h.push("".concat(h.var("request"),".set_form(").concat(h.var("form_data"),", '").concat(types_1.MediaTypes.MULTIPART,"')"));break;default:(null===(o=e.postData)||void 0===o?void 0:o.text)&&h.push("".concat(h.var("request"),".body = ").concat(JSON.stringify(null===(i=e.postData)||void 0===i?void 0:i.text)))}}if(e.basicAuth){var f=e.basicAuth,m=f.username,O=f.password;h.push("".concat(h.var("request"),".basic_auth('").concat(m,"', '").concat(O,"')"))}return h.blank().push("".concat(h.var("response")," = ").concat(h.var("http"),".request(").concat(h.var("request"),")")).push("puts ".concat(h.var("response"),".read_body")).blank(),h.join()};exports.info={key:"native",title:"net::http",link:"http://ruby-doc.org/stdlib-2.2.1/libdoc/net/http/rdoc/Net/HTTP.html",description:"Ruby HTTP client"},exports.default=handler;
|
|
2
2
|
//# sourceMappingURL=native.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.extendTheme=void 0;var tslib_1=require("tslib"),deepmerge_1=(0,tslib_1.__importDefault)(require("deepmerge")),redoc_lib_1=require("../redoc-lib");function extendTheme(e){var t,n,o,r,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.extendTheme=void 0;var tslib_1=require("tslib"),deepmerge_1=(0,tslib_1.__importDefault)(require("deepmerge")),redoc_lib_1=require("../redoc-lib");function extendTheme(e){var t,n,o,a,r,l,i,d,c,p,m,h;return e.theme?(e.theme=(0,deepmerge_1.default)(defaultProTheme,e.theme),e.theme.extensionsHook=extensionsHook,(null===(t=e.theme)||void 0===t?void 0:t.menu)&&!(null===(n=e.theme)||void 0===n?void 0:n.sidebar)&&(console.warn('Theme setting "menu" is deprecated. Rename to "sidebar"'),e.theme.sidebar=e.theme.menu),(null===(o=e.theme)||void 0===o?void 0:o.codeSample)&&(console.warn('Theme setting "codeSample" is deprecated. Rename to "codeBlock"'),Object.assign(null===(a=e.theme)||void 0===a?void 0:a.codeBlock,e.theme.codeSample)),(null===(i=null===(l=null===(r=e.theme)||void 0===r?void 0:r.typography)||void 0===l?void 0:l.code)||void 0===i?void 0:i.tokens)&&(console.warn('Theme setting "typography.code.tokens" is deprecated. Move to "codeBlock.tokens"'),e.theme.codeBlock=(null===(d=e.theme)||void 0===d?void 0:d.codeBlock)||{},Object.assign(null===(p=null===(c=e.theme)||void 0===c?void 0:c.codeBlock)||void 0===p?void 0:p.tokens,(null===(h=null===(m=e.theme)||void 0===m?void 0:m.typography)||void 0===h?void 0:h.code).tokens)),e):(e.theme=defaultProTheme,e)}exports.extendTheme=extendTheme;var defaultProTheme={overrides:{DownloadButton:{custom:""},NextSectionButton:{custom:""}},codeBlock:{borderRadius:function(e){return e.components.panels.borderRadius},tokens:{}},schema:{constraints:{},examples:{}},rightPanel:{textColor:"#eeeeee"},typography:{heading1:{},heading2:{},heading3:{},rightPanelHeading:{}}};function optional(e,t){return t?"".concat(e,": ").concat(t,";"):""}function typography(e){return e?(0,redoc_lib_1.css)(templateObject_1||(templateObject_1=(0,tslib_1.__makeTemplateObject)(["\n ","\n "],["\n ","\n "])),(0,redoc_lib_1.mediaCSS)({fontSize:e.fontSize||"",fontWeight:e.fontWeight||"",fontFamily:e.fontFamily||"",lineHeight:e.lineHeight||"",color:e.color||"",textTransform:e.transform||""})):""}function genTokens(e){if(!e)return"";for(var t="",n=0,o=Object.keys(e);n<o.length;n++){var a=o[n];"default"!==a&&(t+=".token.".concat(a," { color: ").concat(e[a].color,"; }\n"))}return e.default?(0,redoc_lib_1.css)(templateObject_2||(templateObject_2=(0,tslib_1.__makeTemplateObject)(["\n pre& {\n ","\n }\n ","\n "],["\n pre& {\n ","\n }\n ","\n "])),typography(e.default),t):t}var templateObject_1,templateObject_2,templateObject_3,templateObject_4,templateObject_5,templateObject_6,templateObject_7,EXTENSIONS={DownloadButton:function(e){var t=e.theme;return void 0!==t.overrides&&t.overrides.DownloadButton&&t.overrides.DownloadButton.custom||""},H1:function(e){return typography(e.theme.typography.heading1)},H2:function(e){return typography(e.theme.typography.heading2)},H3:function(e){return typography(e.theme.typography.heading3)},RightPanelHeader:function(e){return typography(e.theme.typography.rightPanelHeading)},PropertyNameCell:function(e){var t=e.theme;return t.schema.breakFieldNames?(0,redoc_lib_1.css)(templateObject_3||(templateObject_3=(0,tslib_1.__makeTemplateObject)(["\n ","\n ","\n "],["\n ","\n ","\n "])),typography(t.typography.fieldName),"\n && span:last-child {\n white-space: normal;\n word-break: break-word;\n vertical-align: top;\n max-width: calc(100% - 21px);\n display: inline-flex;\n }\n "):typography(t.typography.fieldName)},ClickablePropertyNameCell:function(e){var t=e.theme;return t.schema.breakFieldNames?(0,redoc_lib_1.css)(templateObject_4||(templateObject_4=(0,tslib_1.__makeTemplateObject)(["\n ","\n ","\n "],["\n ","\n ","\n "])),typography(t.typography.fieldName),"\n && button {\n max-width: calc(100% - 21px); /* left padding + toggle button width: 16px/2 + 13px */\n text-align: left;\n span {\n white-space: normal;\n word-break: break-word;\n vertical-align: top;\n display: inline-flex;\n }\n }\n "):typography(t.typography.fieldName)},Markdown:function(e){var t,n,o,a,r=e.theme;return(0,redoc_lib_1.css)(templateObject_5||(templateObject_5=(0,tslib_1.__makeTemplateObject)(["\n h1 {\n ","\n clear: both;\n }\n h2 {\n ","\n clear: both;\n }\n h3 {\n ","\n clear: both;\n }\n\n pre {\n border-radius: ",";\n }\n\n code {\n ","\n }\n "],["\n h1 {\n ","\n clear: both;\n }\n h2 {\n ","\n clear: both;\n }\n h3 {\n ","\n clear: both;\n }\n\n pre {\n border-radius: ",";\n }\n\n code {\n ","\n }\n "])),typography(r.typography.heading1),typography(r.typography.heading2),typography(r.typography.heading3),null!==(n=null===(t=r.codeBlock)||void 0===t?void 0:t.borderRadius)&&void 0!==n?n:0,optional("word-break",null===(a=null===(o=r.typography)||void 0===o?void 0:o.code)||void 0===a?void 0:a.wordBreak))},ConstraintItem:function(e){var t,n,o,a,r=e.theme;return(0,redoc_lib_1.css)(templateObject_6||(templateObject_6=(0,tslib_1.__makeTemplateObject)(["\n ",";\n ",";\n ","\n ","\n "],["\n ",";\n ",";\n ","\n ","\n "])),typography(r.schema.constraints),optional("background-color",null===(t=r.schema.constraints)||void 0===t?void 0:t.backgroundColor),optional("border",null===(n=r.schema.constraints)||void 0===n?void 0:n.border),optional("word-break",null===(a=null===(o=r.typography)||void 0===o?void 0:o.code)||void 0===a?void 0:a.wordBreak))},ExampleValue:function(e){var t,n,o,a,r=e.theme;return(0,redoc_lib_1.css)(templateObject_7||(templateObject_7=(0,tslib_1.__makeTemplateObject)(["\n ",";\n ",";\n ","\n ","\n "],["\n ",";\n ",";\n ","\n ","\n "])),typography(r.schema.examples),optional("background-color",null===(t=r.schema.examples)||void 0===t?void 0:t.backgroundColor),optional("border",null===(n=r.schema.examples)||void 0===n?void 0:n.border),optional("word-break",null===(a=null===(o=r.typography)||void 0===o?void 0:o.code)||void 0===a?void 0:a.wordBreak))},Prism:function(e){var t,n,o,a=e.theme;return genTokens(null===(t=null==a?void 0:a.codeBlock)||void 0===t?void 0:t.tokens)+optional("word-break",null===(o=null===(n=a.typography)||void 0===n?void 0:n.code)||void 0===o?void 0:o.wordBreak)}};function extensionsHook(e,t){return EXTENSIONS[e]&&EXTENSIONS[e](t)}
|
|
2
2
|
//# sourceMappingURL=extendTheme.js.map
|
package/lib/services/utils.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.base64UrlEncode=exports.sha256=exports.encodeState=exports.randString=exports.cryptoLib=exports.isEmptyObject=exports.arrayMergeStrategy=exports.unescapeServerVariables=exports.normalizeMimeType=exports.isSameMime=exports.normalizePath=void 0;var tslib_1=require("tslib"),deepmerge_1=(0,tslib_1.__importDefault)(require("deepmerge")),helpers_1=require("../redoc-lib/src/utils/helpers");function normalizePath(e){return e.startsWith("/")||(e="/"+e),e.endsWith("/")&&(e=e.slice(0,-1)),e}function isSameMime(e,r){return!(!e||!r)&&normalizeMimeType(e)===normalizeMimeType(r)}function normalizeMimeType(e){if(e){var r=e.split(";")[0].toLowerCase().split("/"),t=r[0],n=r[1];
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.base64UrlEncode=exports.sha256=exports.encodeState=exports.randString=exports.cryptoLib=exports.isEmptyObject=exports.arrayMergeStrategy=exports.unescapeServerVariables=exports.normalizeMimeType=exports.isSameMime=exports.normalizePath=void 0;var tslib_1=require("tslib"),deepmerge_1=(0,tslib_1.__importDefault)(require("deepmerge")),helpers_1=require("../redoc-lib/src/utils/helpers");function normalizePath(e){return e.startsWith("/")||(e="/"+e),e.endsWith("/")&&(e=e.slice(0,-1)),e}function isSameMime(e,r){return!(!e||!r)&&normalizeMimeType(e)===normalizeMimeType(r)}function normalizeMimeType(e){if(e){var r=e.split(";")[0].toLowerCase().split("/"),t=r[0],n=r[1];if(void 0===n)return t;var i=n.split("+").pop();return"".concat(t,"/").concat(i)}}function unescapeServerVariables(e){var r=new RegExp("%7B","g"),t=new RegExp("%7D","g");return e.replace(r,"{").replace(t,"}").replace("///","//").replace("./",".")}function arrayMergeStrategy(e,r){if(!e.length||!hasObjectOrArray(e))return r;var t=e.filter((function(e){return Object.keys(e).length>0}));return r.forEach((function(r,n){(0,helpers_1.isMergeableObject)(r)?t[n]=(0,deepmerge_1.default)(e[n],r,{arrayMerge:arrayMergeStrategy}):Array.isArray(r)?t.push(r):t[n]=r})),t}exports.normalizePath=normalizePath,exports.isSameMime=isSameMime,exports.normalizeMimeType=normalizeMimeType,exports.unescapeServerVariables=unescapeServerVariables,exports.arrayMergeStrategy=arrayMergeStrategy;var hasObjectOrArray=function(e){return e.some((function(e){return(0,helpers_1.isObject)(e)&&Object.keys(e).length>0}))};function isEmptyObject(e){return!!e&&0===Object.keys(e).length}function randString(e){void 0===e&&(e=32);for(var r="";r.length<e;)r+=Math.random().toString(32).substring(2);return r.substring(0,e)}function encodeState(e){var r=(0,tslib_1.__assign)({randomStr:randString()},e);return btoa(JSON.stringify(r))}function sha256(e){return(0,tslib_1.__awaiter)(this,void 0,void 0,(function(){var r;return(0,tslib_1.__generator)(this,(function(t){return r=(new TextEncoder).encode(e),[2,null===exports.cryptoLib||void 0===exports.cryptoLib?void 0:exports.cryptoLib.subtle.digest("SHA-256",r)]}))}))}function base64UrlEncode(e){if(e)return btoa(String.fromCharCode.apply(null,new Uint8Array(e))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}exports.isEmptyObject=isEmptyObject,exports.cryptoLib="undefined"!=typeof window&&(window.crypto||window.msCrypto)||void 0,exports.randString=randString,exports.encodeState=encodeState,exports.sha256=sha256,exports.base64UrlEncode=base64UrlEncode;
|
|
2
2
|
//# sourceMappingURL=utils.js.map
|
package/lib/utils.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getJsUrl=exports.getWindowReferenceOptions=exports.dottedString=exports.joinStringFactory=exports.get=exports.getSecurityDetailsOptions=exports.getSecurityDetails=exports.setSecurityDetailsVariants=exports.setSecurityDetails=exports.unescapeFormId=exports.escapeFormId=exports.fromLocalStorage=exports.toLocalStorage=exports.getParameterValue=exports.setParameterValue=exports.fromSessionStorage=exports.toSessionStorage=exports.debounce=exports.setGlobalStore=exports.getGlobalStore=void 0;var _store,utils_1=require("./redoc-lib/src/utils"),getGlobalStore=function(){return _store};exports.getGlobalStore=getGlobalStore;var setGlobalStore=function(e){return _store=e};function debounce(e,t,o){var r,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getJsUrl=exports.getWindowReferenceOptions=exports.dottedString=exports.joinStringFactory=exports.get=exports.getSecurityDetailsOptions=exports.getSecurityDetails=exports.setSecurityDetailsVariants=exports.setSecurityDetails=exports.unescapeFormId=exports.escapeFormId=exports.fromLocalStorage=exports.toLocalStorage=exports.getParameterValue=exports.setParameterValue=exports.fromSessionStorage=exports.toSessionStorage=exports.debounce=exports.setGlobalStore=exports.getGlobalStore=void 0;var _store,utils_1=require("./redoc-lib/src/utils"),getGlobalStore=function(){return _store};exports.getGlobalStore=getGlobalStore;var setGlobalStore=function(e){return _store=e};function debounce(e,t,o){var r,n=0;return function(){for(var s=[],a=0;a<arguments.length;a++)s[a]=arguments[a];n++,r?clearTimeout(r):o&&e.apply(void 0,s),r=setTimeout((function(){n>1&&e.apply(void 0,s),n=0,r=null}),t)}}function toSessionStorage(e,t){utils_1.IS_BROWSER&&window.sessionStorage.setItem("redoc."+e,t)}function fromSessionStorage(e){return utils_1.IS_BROWSER&&window.sessionStorage.getItem("redoc."+e)||""}function setParameterValue(e,t,o){toSessionStorage("".concat(e,".").concat(t),JSON.stringify(o))}function getParameterValue(e,t){try{return JSON.parse(fromSessionStorage("".concat(e,".").concat(t))||fromSessionStorage("".concat(e,".").concat(decodeURIComponent(t))))}catch(e){return null}}function toLocalStorage(e,t){window.localStorage.setItem("redoc."+e,t)}function fromLocalStorage(e){return utils_1.IS_BROWSER&&window.localStorage.getItem("redoc."+e)||""}function escapeFormId(e){return e.replace(/[.[\]]/g,(function(e){return{".":"%2e","[":"%5b","]":"%5d"}[e]||""}))}function unescapeFormId(e){return e.replace(/%2e|%5b|%5d/g,(function(e){return{"%2e":".","%5b":"[","%5d":"]"}[e]||""}))}function setSecurityDetails(e,t){e=escapeFormId(e),"string"==typeof t?toSessionStorage("auth."+e,t):t&&(toSessionStorage("auth.".concat(e,".password"),t.password||""),toSessionStorage("auth.".concat(e,".username"),t.username||""),toSessionStorage("auth.".concat(e,".token"),t.token&&JSON.stringify(t.token)||""),toSessionStorage("auth.".concat(e,".client_id"),t.client_id||""),toSessionStorage("auth.".concat(e,".client_secret"),t.client_secret||""),toSessionStorage("auth.".concat(e,".scopes"),t.scopes&&JSON.stringify(t.scopes)||""))}function setSecurityDetailsVariants(e,t){e=escapeFormId(e),toSessionStorage("auth.".concat(e,".variants"),JSON.stringify(t))}function getSecurityDetails(e){e=escapeFormId(e);var t=fromSessionStorage("auth.".concat(e)),o=fromSessionStorage("auth.".concat(e,".token"));return{raw:t,password:fromSessionStorage("auth.".concat(e,".password")),username:fromSessionStorage("auth.".concat(e,".username")),token:o&&JSON.parse(o)||null,client_id:fromSessionStorage("auth.".concat(e,".client_id")),client_secret:fromSessionStorage("auth.".concat(e,".client_secret")),scopes:fromSessionStorage("auth.".concat(e,".scopes"))}}function getSecurityDetailsOptions(e,t){e=escapeFormId(e);var o=fromSessionStorage("auth.".concat(e,".variants"));if(!o)return null;var r=JSON.parse(o);return r&&Array.isArray(r)?r.map((function(e){return e.details?""===t&&e.details&&"string"==typeof e.details?{label:e.label,value:e.details}:"object"==typeof e.details?{label:e.label,value:e.details[t]}:null:null})).filter(notNull):null}function notNull(e){return null!==e}function get(e,t,o){return void 0===e&&(e={}),"string"==typeof t&&(t=t.split(".")),t.reduce((function(e,t){return e&&e[t]?e[t]:o}),e)}function joinStringFactory(e){return function(){for(var t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];return t.filter(Boolean).join(e)}}function getWindowReferenceOptions(e){var t;return utils_1.IS_BROWSER?null===(t=null===window||void 0===window?void 0:window.REFERENCE_DOCS_OPTIONS)||void 0===t?void 0:t[e]:null}function getJsUrl(){var e;if(!utils_1.IS_BROWSER)return"";var t=+new Date+Math.random();try{return document.currentScript&&(document.currentScript.async||document.currentScript.defer)||document.write('<script id="dummy'.concat(t,'"><\/script>')),(null===(e=document.getElementById("dummy"+t))||void 0===e?void 0:e.previousSibling).src}catch(e){return""}}exports.setGlobalStore=setGlobalStore,exports.debounce=debounce,exports.toSessionStorage=toSessionStorage,exports.fromSessionStorage=fromSessionStorage,exports.setParameterValue=setParameterValue,exports.getParameterValue=getParameterValue,exports.toLocalStorage=toLocalStorage,exports.fromLocalStorage=fromLocalStorage,exports.escapeFormId=escapeFormId,exports.unescapeFormId=unescapeFormId,exports.setSecurityDetails=setSecurityDetails,exports.setSecurityDetailsVariants=setSecurityDetailsVariants,exports.getSecurityDetails=getSecurityDetails,exports.getSecurityDetailsOptions=getSecurityDetailsOptions,exports.get=get,exports.joinStringFactory=joinStringFactory,exports.dottedString=joinStringFactory("."),exports.getWindowReferenceOptions=getWindowReferenceOptions,exports.getJsUrl=getJsUrl;
|
|
2
2
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";import{Component,Fragment}from"react";import{fromSessionStorage,getSecurityDetailsOptions,toSessionStorage,escapeFormId}from"../../utils";import{FormDropdown,FormTextField}from"../common/TextField";import{FormControl,FormLabel,FormWrapper}from"../common/form";import{l}from"../../redoc-lib/src/services/Labels";import{Dropdown}from"../common/Dropdown";import{OpenIDConnect,Error}from"./OpenIDConnect";import{OAuth2Flow}from"./OAuth2Flow";import OAuth2TokenInput from"./OAuth2TokenInput";export function requiredValidator(e){if(!e)return"Field is required"}const getCookie=function(e){const o=document.cookie.match("\\b"+e+"=([^;]*)\\b");return o?o[1]:void 0};function fromCookie(e){if("cookie"===e.in)return getCookie(e.name)}export class AuthPanel extends Component{constructor(){super(...arguments),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:{activeScheme:0}}),Object.defineProperty(this,"handleSchemeChange",{enumerable:!0,configurable:!0,writable:!0,value:e=>{this.setState({activeScheme:e.idx}),toSessionStorage("securityRequirementName",e.value)}})}static getDerivedStateFromProps(e){const o=e.operation.security.map((e=>e.schemes.map((e=>e.id)).join(" and "))),t=fromSessionStorage("securityRequirementName"),i=o.findIndex((e=>e===t));return{activeScheme:i<0?0:i}}render(){const{securityDefaults:e}=this.props,{activeScheme:o}=this.state,t=this.props.operation.security,i=t.map((e=>e.schemes.map((e=>e.id)).join(" and "))).filter(Boolean).map(((e,o)=>({value:e,idx:o})));return 0===i.length?_jsx(Error,{message:"Cannot find security schema in the definition"},void 0):_jsxs(_Fragment,{children:[_jsxs(FormWrapper,{children:[i.length>1&&_jsxs(FormControl,{children:[_jsx(FormLabel,{children:" Security scheme: "},void 0),_jsx(Dropdown,{variant:"dark",fullWidth:!0,options:i,value:i[o].value,onChange:this.handleSchemeChange},void 0)]},void 0)||null,t[o].schemes.map((o=>{var t,i,r,s,n,a,d;const
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";import{Component,Fragment}from"react";import{fromSessionStorage,getSecurityDetailsOptions,toSessionStorage,escapeFormId}from"../../utils";import{FormDropdown,FormTextField}from"../common/TextField";import{FormControl,FormLabel,FormWrapper}from"../common/form";import{l}from"../../redoc-lib/src/services/Labels";import{Dropdown}from"../common/Dropdown";import{OpenIDConnect,Error}from"./OpenIDConnect";import{OAuth2Flow}from"./OAuth2Flow";import OAuth2TokenInput from"./OAuth2TokenInput";export function requiredValidator(e){if(!e)return"Field is required"}const getCookie=function(e){const o=document.cookie.match("\\b"+e+"=([^;]*)\\b");return o?o[1]:void 0};function fromCookie(e){if("cookie"===e.in)return getCookie(e.name)}export class AuthPanel extends Component{constructor(){super(...arguments),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:{activeScheme:0}}),Object.defineProperty(this,"handleSchemeChange",{enumerable:!0,configurable:!0,writable:!0,value:e=>{this.setState({activeScheme:e.idx}),toSessionStorage("securityRequirementName",e.value)}})}static getDerivedStateFromProps(e){const o=e.operation.security.map((e=>e.schemes.map((e=>e.id)).join(" and "))),t=fromSessionStorage("securityRequirementName"),i=o.findIndex((e=>e===t));return{activeScheme:i<0?0:i}}render(){const{securityDefaults:e}=this.props,{activeScheme:o}=this.state,t=this.props.operation.security,i=t.map((e=>e.schemes.map((e=>e.id)).join(" and "))).filter(Boolean).map(((e,o)=>({value:e,idx:o})));return 0===i.length?_jsx(Error,{message:"Cannot find security schema in the definition"},void 0):_jsxs(_Fragment,{children:[_jsxs(FormWrapper,{children:[i.length>1&&_jsxs(FormControl,{children:[_jsx(FormLabel,{children:" Security scheme: "},void 0),_jsx(Dropdown,{variant:"dark",fullWidth:!0,options:i,value:i[o].value,onChange:this.handleSchemeChange},void 0)]},void 0)||null,t[o].schemes.map((o=>{var t,i,r,s,n,a,d,u;const h=escapeFormId(o.id);if("apiKey"===o.type){const t=getSecurityDetailsOptions(h,""),i={field:`auth.${h}`,fullWidth:!0,initialValue:fromCookie(o)||fromSessionStorage(`auth.${h}`)||(null==e?void 0:e[h]),initValue:fromCookie(o)||fromSessionStorage(`auth.${h}`)||(null==e?void 0:e[h]),validate:requiredValidator,validateOnBlur:!0,validateOnChange:!0};return _jsxs(FormControl,{children:[_jsxs(FormLabel,{children:[" ",o.name,": "]},void 0),t?_jsx(FormDropdown,Object.assign({},i,{options:t}),void 0):_jsx(FormTextField,Object.assign({},i,{type:"password","data-cy":"apiKey-auth-password"}),void 0)]},h)}if("http"===o.type){if("basic"===o.scheme){const o=getSecurityDetailsOptions(h,"username"),s={field:`auth.${h}.username`,fullWidth:!0,initialValue:fromSessionStorage(`auth.${h}.username`)||(null===(t=null==e?void 0:e[h])||void 0===t?void 0:t.username),initValue:fromSessionStorage(`auth.${h}.username`)||(null===(i=null==e?void 0:e[h])||void 0===i?void 0:i.username),validate:requiredValidator,validateOnBlur:!0,validateOnChange:!0};return _jsxs(Fragment,{children:[_jsxs(FormControl,{children:[_jsxs(FormLabel,{children:[" ",l("tryItAuthBasicUsername"),": "]},void 0),o?_jsx(FormDropdown,Object.assign({},s,{options:o}),void 0):_jsx(FormTextField,Object.assign({},s),void 0)]},void 0),_jsxs(FormControl,{children:[_jsxs(FormLabel,{children:[" ",l("tryItAuthBasicPassword"),": "]},void 0),_jsx(FormTextField,{type:"password","data-cy":"http-auth-password",fullWidth:!0,field:`auth.${h}.password`,initialValue:fromSessionStorage(`auth.${h}.password`)||(null===(r=null==e?void 0:e[h])||void 0===r?void 0:r.password)||"",validateOnBlur:!0,validateOnChange:!0},void 0)]},void 0)]},h)}if("bearer"===o.scheme){const o=getSecurityDetailsOptions(h,""),t={field:`auth.${h}`,fullWidth:!0,initialValue:fromSessionStorage(`auth.${h}`)||(null==e?void 0:e[h]),initValue:fromSessionStorage(`auth.${h}`)||(null==e?void 0:e[h]),validate:requiredValidator,validateOnBlur:!0,validateOnChange:!0};return _jsx(Fragment,{children:_jsxs(FormControl,{children:[_jsx(FormLabel,{children:" Bearer Token: "},void 0),o?_jsx(FormDropdown,Object.assign({},t,{options:o}),void 0):_jsx(FormTextField,Object.assign({},t,{type:"password",placeholder:"(without 'Bearer')"}),void 0)]},void 0)},h)}}else{if("oauth2"===o.type&&o.flows&&o.flows.clientCredentials)return _jsx(OAuth2TokenInput,{flow:Object.assign(Object.assign({},o.flows.clientCredentials),{"x-tokenEndpointAuthMethod":null!==(s=o.flows.clientCredentials["x-tokenEndpointAuthMethod"])&&void 0!==s?s:o["x-tokenEndpointAuthMethod"]}),server:this.props.activeServer,authCorsProxyUrl:this.props.authCorsProxyUrl,id:h,form:this.props.form,formApi:this.props.formApi,clientId:o.flows.clientCredentials["x-defaultClientId"]||o["x-defaultClientId"],defaultValues:null==e?void 0:e[h]},h);if("oauth2"===o.type&&o.flows&&o.flows.implicit)return _jsx(OAuth2Flow,{authorizationUrl:o.flows.implicit.authorizationUrl,authCorsProxyUrl:this.props.authCorsProxyUrl,scopes:Object.keys((null===(a=null===(n=null==o?void 0:o.flows)||void 0===n?void 0:n.implicit)||void 0===a?void 0:a.scopes)||{}),server:this.props.activeServer,id:h,form:this.props.form,formApi:this.props.formApi,clientId:o.flows.implicit["x-defaultClientId"]||o["x-defaultClientId"],flow:"implicit",defaultValues:null==e?void 0:e[h]},h);if("oauth2"===o.type&&o.flows&&o.flows.authorizationCode)return _jsx(OAuth2Flow,{authorizationUrl:o.flows.authorizationCode.authorizationUrl,tokenUrl:o.flows.authorizationCode.tokenUrl,authCorsProxyUrl:this.props.authCorsProxyUrl,scopes:Object.keys((null===(d=o.flows.authorizationCode)||void 0===d?void 0:d.scopes)||{}),server:this.props.activeServer,id:h,form:this.props.form,formApi:this.props.formApi,clientId:o.flows.authorizationCode["x-defaultClientId"]||o["x-defaultClientId"],flow:"authorizationCode",tokenEndpointAuthMethod:o.flows.authorizationCode["x-tokenEndpointAuthMethod"]||o["x-tokenEndpointAuthMethod"],usePkce:o.flows.authorizationCode["x-usePkce"],defaultValues:null==e?void 0:e[h]},h);if("oauth2"===o.type){let o=fromSessionStorage(`auth.${h}.token`)||JSON.stringify(null===(u=null==e?void 0:e[h])||void 0===u?void 0:u.token);return o=o?JSON.parse(o):{},_jsxs(Fragment,{children:[_jsxs(FormControl,{children:[_jsx(FormLabel,{children:" Access Token Type: "},void 0),_jsx(FormTextField,{fullWidth:!0,field:`auth.${h}.token.token_type`,initialValue:o.token_type||"Bearer"},void 0)]},void 0),_jsxs(FormControl,{children:[_jsx(FormLabel,{children:" Access Token: "},void 0),_jsx(FormTextField,{type:"password",fullWidth:!0,field:`auth.${h}.token.access_token`,validate:requiredValidator,initialValue:o.access_token,validateOnBlur:!0,validateOnChange:!0},void 0)]},void 0)]},h)}if("openIdConnect"===o.type)return _jsx(OpenIDConnect,{server:this.props.activeServer,authCorsProxyUrl:this.props.authCorsProxyUrl,id:h,form:this.props.form,formApi:this.props.formApi,scheme:o,clientId:o["x-defaultClientId"],defaultValues:null==e?void 0:e[h]},h);if("none"===o.type)return _jsx("span",{children:"None"},h)}}))]},void 0),_jsxs("small",{children:[_jsx("strong",{children:"Note"},void 0),": Your credentials will be saved until the end of the browser session"]},void 0)]},void 0)}}
|
|
2
2
|
//# sourceMappingURL=AuthPanel.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{isJsonLike,resolveUrl}from"../../utils";const externalExamplesCache={};export class ExampleModel{constructor(e,r,l,t){Object.defineProperty(this,"mime",{enumerable:!0,configurable:!0,writable:!0,value:l}),Object.defineProperty(this,"encoding",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"value",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"rawValue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"summary",{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,"externalValueUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0});const{resolved:a}=e.deref(r);this.rawValue=a.value,this.value=a.value,this.summary=a.summary,this.description=a.description,a.externalValue&&(this.externalValueUrl=resolveUrl(e.definitionUrl||"",a.externalValue))}getExternalValue(e){return this.externalValueUrl?(this.externalValueUrl in externalExamplesCache||(externalExamplesCache[this.externalValueUrl]=fetch(this.externalValueUrl).then((r=>r.text().then((l=>{if(!r.ok)return Promise.reject(new Error(l));if(!isJsonLike(e))return l;try{return JSON.parse(l)}catch(e){return l}}))))),externalExamplesCache[this.externalValueUrl]):Promise.resolve(void 0)}}
|
|
2
2
|
//# sourceMappingURL=Example.js.map
|