@nodex.ui/core 1.0.0 → 1.0.1
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/CHANGELOG.md +70 -1
- package/README.md +21 -13
- package/bin/create-nodexui-app.mjs +13 -4
- package/bin/docs.mjs +340 -0
- package/dist/nodexui.apidoc.esm.js +45 -29
- package/dist/nodexui.apidoc.min.js +45 -29
- package/dist/nodexui.esm.js +38 -27
- package/dist/nodexui.min.css +1 -1
- package/dist/nodexui.min.js +61 -50
- package/dist/nodexui.pwa.esm.js +9 -5
- package/dist/nodexui.qr.esm.js +3 -3
- package/dist/nodexui.qr.min.js +3 -3
- package/dist/nodexui.registry.json +30 -15
- package/dist/nodexui.templates.xml +22 -6
- package/dist/nodexui.vite.esm.js +12 -8
- package/dist/runtime/lazy/apidoc.logic.js +19 -19
- package/dist/types/index.d.ts +297 -0
- package/dist/types/qr.d.ts +63 -1
- package/docs/analytics.md +6 -8
- package/docs/base-ui-skill.md +1 -1
- package/docs/blocks.md +4 -4
- package/docs/components/chart.md +1 -1
- package/docs/components/data-table.md +49 -5
- package/docs/components/doc-viewer.md +68 -0
- package/docs/components/markdown.md +27 -2
- package/docs/components/readme.md +85 -0
- package/docs/i18n.md +1 -1
- package/docs/icons.md +1 -1
- package/docs/index.md +132 -0
- package/docs/installation.md +2 -2
- package/docs/owl-components.md +1 -1
- package/docs/qr.md +44 -3
- package/docs/readme.md +26 -0
- package/docs/theming.md +2 -2
- package/docs/usage-guide.md +5 -5
- package/package.json +10 -8
- package/dist/nodexui.block-viewer.esm.js +0 -46
- /package/dist/runtime/mermaid/{mermaid.esm.min.mjs → mermaid.esm.min.js} +0 -0
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nodexui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.3.6",
|
|
4
4
|
"cdn": {
|
|
5
|
-
"css": "https://cdn.jsdelivr.net/npm/nodexui@
|
|
6
|
-
"js": "https://cdn.jsdelivr.net/npm/nodexui@
|
|
7
|
-
"esm": "https://cdn.jsdelivr.net/npm/nodexui@
|
|
8
|
-
"bootstrapJs": "https://cdn.jsdelivr.net/npm/nodexui@
|
|
9
|
-
"icons": "https://cdn.jsdelivr.net/npm/nodexui@
|
|
10
|
-
"templates": "https://cdn.jsdelivr.net/npm/nodexui@
|
|
11
|
-
"blockViewer": "https://cdn.jsdelivr.net/npm/nodexui@
|
|
5
|
+
"css": "https://cdn.jsdelivr.net/npm/nodexui@1.3.6/dist/nodexui.min.css",
|
|
6
|
+
"js": "https://cdn.jsdelivr.net/npm/nodexui@1.3.6/dist/nodexui.min.js",
|
|
7
|
+
"esm": "https://cdn.jsdelivr.net/npm/nodexui@1.3.6/dist/nodexui.esm.js",
|
|
8
|
+
"bootstrapJs": "https://cdn.jsdelivr.net/npm/nodexui@1.3.6/dist/bootstrap.bundle.min.js",
|
|
9
|
+
"icons": "https://cdn.jsdelivr.net/npm/nodexui@1.3.6/dist/nodexui.icons.esm.js",
|
|
10
|
+
"templates": "https://cdn.jsdelivr.net/npm/nodexui@1.3.6/dist/nodexui.templates.xml",
|
|
11
|
+
"blockViewer": "https://cdn.jsdelivr.net/npm/nodexui@1.3.6/dist/nodexui.block-viewer.esm.js"
|
|
12
12
|
},
|
|
13
13
|
"buildFiles": [
|
|
14
14
|
"nodexui.min.css",
|
|
@@ -970,6 +970,21 @@
|
|
|
970
970
|
],
|
|
971
971
|
"templateName": "nodexui.Marker"
|
|
972
972
|
},
|
|
973
|
+
{
|
|
974
|
+
"name": "doc-viewer",
|
|
975
|
+
"type": "owl",
|
|
976
|
+
"dependencies": [
|
|
977
|
+
"owl"
|
|
978
|
+
],
|
|
979
|
+
"attributes": [
|
|
980
|
+
"b-ui"
|
|
981
|
+
],
|
|
982
|
+
"events": [],
|
|
983
|
+
"owlComponents": [
|
|
984
|
+
"DocViewer"
|
|
985
|
+
],
|
|
986
|
+
"templateName": "nodexui.DocViewer"
|
|
987
|
+
},
|
|
973
988
|
{
|
|
974
989
|
"name": "markdown",
|
|
975
990
|
"type": "static",
|
|
@@ -1703,17 +1718,17 @@
|
|
|
1703
1718
|
}
|
|
1704
1719
|
],
|
|
1705
1720
|
"integrity": {
|
|
1706
|
-
"nodexui.min.css": "sha384-
|
|
1721
|
+
"nodexui.min.css": "sha384-ycMf1QigwmUgm4Y40MuMCxAF6au/cKVzGgiW3ML8tLhMRxpthsoRFNdtvr2VD9JR",
|
|
1707
1722
|
"bootstrap.bundle.min.js": "sha384-RMbllTJcplkCRnELNTOc5Kz/3AvFDE/rNlJqWqfgmRWruobClBdfwvl10akQZkR1",
|
|
1708
|
-
"nodexui.min.js": "sha384-
|
|
1709
|
-
"nodexui.esm.js": "sha384-
|
|
1723
|
+
"nodexui.min.js": "sha384-QHR/ZIIB382auFPyVAHmZoiI33O87ECuF+C93tIQDyLX4gH9RyKZAbpUoBE5jkAM",
|
|
1724
|
+
"nodexui.esm.js": "sha384-4Y4FwAOi78vg6LyuGg4N/MVEcoKEuCGQ0C7bb8IFzPXM1NLNxYMMIIfReX2vwZb+",
|
|
1710
1725
|
"nodexui.icons.esm.js": "sha384-oiMomQ/5qo3y+bvV7DIRuIVFhzswEpsDwkg1qQ1p3g7L1K8qonpW+YaQa6w8hcZN",
|
|
1711
|
-
"nodexui.templates.xml": "sha384-
|
|
1712
|
-
"nodexui.block-viewer.esm.js": "sha384-
|
|
1726
|
+
"nodexui.templates.xml": "sha384-zGy0lWgy1nW6RamPFP9uziFkJa1XDyu/ElC74HUv90K9yCP92l3VlWwWX2/SCH3q",
|
|
1727
|
+
"nodexui.block-viewer.esm.js": "sha384-WC2hrHzW+XaRvJvq4VfY9YAH71eL2dDNWgWzJuS2VwSdq0qzq2VlITUY9fkEgn+q",
|
|
1713
1728
|
"nodexui.analytics.esm.js": "sha384-M6TVmchmceTvpSzgI+DNA6zAn9xmz9a+YEexCLslSo/Ngxyp2kmzs9fm+PxWy+Da",
|
|
1714
1729
|
"nodexui.analytics.min.js": "sha384-B0hBkVDbT7gmDmUMazlN4Nc1KnYGSpL+IcW2hd8840knx73HGImPgGs84MvS3hKE",
|
|
1715
|
-
"nodexui.qr.esm.js": "sha384-
|
|
1716
|
-
"nodexui.qr.min.js": "sha384-
|
|
1730
|
+
"nodexui.qr.esm.js": "sha384-8Y2c26Qd9yX4Z3WFyiiZlwmBOcQJertQx+DfPXJWbmS1l08Hk47TwQBAnlB5Vj5s",
|
|
1731
|
+
"nodexui.qr.min.js": "sha384-1yeOG7HMZ8ibAjjLoNd7pzX7FMUWS8zgZIX967Jq/jevsO/eAfWpmxQu9NJdYXHw",
|
|
1717
1732
|
"icons/lucide.json": "sha384-mc5mzpmq9eOgZVa2IcjrL33Ty4nMXE8aoZMfy+lgkC/jMQ4aYnk2S58mFsSGFnW1",
|
|
1718
1733
|
"themes/nodexui-light.css": "sha384-D9HqkSS43qp8GFITlgaaknQ5m1BYd3NP0fEbHA0ghTlUi0keMMOGeA/xuiKLeb0i",
|
|
1719
1734
|
"themes/nodexui-dark.css": "sha384-6cZzE0FjNObxdFWPHCyA0zYf+jxkS98iIhy82tpA4NN9gzBL+2tGbIcq2fYw4AaQ",
|
|
@@ -1487,6 +1487,17 @@
|
|
|
1487
1487
|
<div t-att-class="'b-direction' + (props.className ? ' ' + props.className : '')" t-att-dir="dir" t-att-style="props.style"><t t-slot="default"/></div>
|
|
1488
1488
|
</t>
|
|
1489
1489
|
<t t-name="Direction" t-call="nodexui.Direction"/>
|
|
1490
|
+
<t t-name="nodexui.DocViewer">
|
|
1491
|
+
<div t-att-class="classNames" t-att-style="props.style" data-slot="doc-viewer">
|
|
1492
|
+
<nav t-if="props.part !== 'content'" class="b-doc-viewer-nav">
|
|
1493
|
+
<MarkdownTree src="props.tree" root="props.root" include="props.include" exclude="props.exclude" filter="props.filter" formatLabel="props.formatLabel" activePath="state.path" onSelect="select"/>
|
|
1494
|
+
</nav>
|
|
1495
|
+
<div t-if="props.part !== 'sidebar'" class="b-doc-viewer-content">
|
|
1496
|
+
<Markdown t-if="state.path" src="docSrc" tree="props.tree" onNavigate="select"/>
|
|
1497
|
+
</div>
|
|
1498
|
+
</div>
|
|
1499
|
+
</t>
|
|
1500
|
+
<t t-name="DocViewer" t-call="nodexui.DocViewer"/>
|
|
1490
1501
|
<t t-name="nodexui.drawer"><div b-ui="drawer"><div b-drawer-panel=""><t t-esc="props.content"/></div></div></t>
|
|
1491
1502
|
<t t-name="nodexui.Drawer"><t t-slot="default"/></t>
|
|
1492
1503
|
<t t-name="Drawer" t-call="nodexui.Drawer"/>
|
|
@@ -1902,7 +1913,7 @@
|
|
|
1902
1913
|
<div class="b-markdown"/>
|
|
1903
1914
|
</t>
|
|
1904
1915
|
<t t-name="nodexui.Markdown">
|
|
1905
|
-
<div t-ref="root" t-att-class="classNames" t-att-style="props.style" data-slot="markdown" t-att-data-status="state.status">
|
|
1916
|
+
<div t-ref="root" t-att-class="classNames" t-att-style="props.style" data-slot="markdown" t-att-data-status="state.status" t-on-click="onLinkClick">
|
|
1906
1917
|
<div t-if="state.status === 'loading'" class="b-markdown-loading" role="status">Loading…</div>
|
|
1907
1918
|
<div t-elif="state.status === 'error'" class="b-markdown-error" role="alert">
|
|
1908
1919
|
<t t-esc="state.error"/>
|
|
@@ -1938,7 +1949,7 @@
|
|
|
1938
1949
|
</div>
|
|
1939
1950
|
<SidebarGroup t-else="">
|
|
1940
1951
|
<SidebarMenu>
|
|
1941
|
-
<t t-foreach="
|
|
1952
|
+
<t t-foreach="rootNode.children || []" t-as="child" t-key="child.path || child.name">
|
|
1942
1953
|
<MarkdownTreeNode node="child" activePath="props.activePath" onSelect="props.onSelect"/>
|
|
1943
1954
|
</t>
|
|
1944
1955
|
</SidebarMenu>
|
|
@@ -1999,8 +2010,13 @@
|
|
|
1999
2010
|
</t>
|
|
2000
2011
|
<t t-else="">
|
|
2001
2012
|
<div class="b-markdown-tree-group">
|
|
2002
|
-
<SidebarGroupLabel
|
|
2003
|
-
|
|
2013
|
+
<SidebarGroupLabel>
|
|
2014
|
+
<button type="button" class="b-markdown-tree-group-toggle" t-att-aria-expanded="state.open ? 'true' : 'false'" t-on-click="toggle">
|
|
2015
|
+
<span><t t-esc="label"/></span>
|
|
2016
|
+
<Icon name="'chevron-right'" className="'b-markdown-tree-folder-trigger-icon'"/>
|
|
2017
|
+
</button>
|
|
2018
|
+
</SidebarGroupLabel>
|
|
2019
|
+
<SidebarMenu t-if="state.open">
|
|
2004
2020
|
<t t-foreach="props.node.children" t-as="child" t-key="child.path || child.name">
|
|
2005
2021
|
<MarkdownTreeNode node="child" activePath="props.activePath" onSelect="props.onSelect"/>
|
|
2006
2022
|
</t>
|
|
@@ -2557,7 +2573,7 @@
|
|
|
2557
2573
|
attrs="{ 'data-sidebar': 'group-action', 'data-slot': 'sidebar-group-action' }"
|
|
2558
2574
|
ariaLabel="ariaLabel"
|
|
2559
2575
|
icon="props.icon"
|
|
2560
|
-
onClick="
|
|
2576
|
+
onClick="props.onClick">
|
|
2561
2577
|
<t t-slot="default"/>
|
|
2562
2578
|
</Button>
|
|
2563
2579
|
</t>
|
|
@@ -2614,7 +2630,7 @@
|
|
|
2614
2630
|
attrs="{ 'data-sidebar': 'menu-action', 'data-slot': 'sidebar-menu-action' }"
|
|
2615
2631
|
ariaLabel="ariaLabel"
|
|
2616
2632
|
icon="props.icon"
|
|
2617
|
-
onClick="
|
|
2633
|
+
onClick="props.onClick">
|
|
2618
2634
|
<t t-slot="default"/>
|
|
2619
2635
|
</Button>
|
|
2620
2636
|
</t>
|
package/dist/nodexui.vite.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createHash as y}from"node:crypto";import{existsSync as E,readFileSync as C}from"node:fs";import{fileURLToPath as N}from"node:url";var p=["favicon.ico","favicon-16x16.png","favicon-32x32.png","apple-touch-icon.png","icon-192.png","icon-512.png"],h="/icons/";function k(e){return[{src:`${e}icon-192.png`,sizes:"192x192",type:"image/png",purpose:"any"},{src:`${e}icon-512.png`,sizes:"512x512",type:"image/png",purpose:"any"},{src:`${e}icon-512.png`,sizes:"512x512",type:"image/png",purpose:"maskable"}]}function u(e){let{name:t,shortName:n=t,description:r="",startUrl:i="/",scope:l="/",display:
|
|
1
|
+
import{createHash as y}from"node:crypto";import{existsSync as E,readFileSync as C}from"node:fs";import{fileURLToPath as N}from"node:url";var p=["favicon.ico","favicon-16x16.png","favicon-32x32.png","apple-touch-icon.png","icon-192.png","icon-512.png"],h="/icons/";function k(e){return[{src:`${e}icon-192.png`,sizes:"192x192",type:"image/png",purpose:"any"},{src:`${e}icon-512.png`,sizes:"512x512",type:"image/png",purpose:"any"},{src:`${e}icon-512.png`,sizes:"512x512",type:"image/png",purpose:"maskable"}]}function u(e){let{name:t,shortName:n=t,description:r="",startUrl:i="/",scope:l="/",display:o="standalone",orientation:a="portrait-primary",backgroundColor:c="#ffffff",themeColor:s="#0f172a",lang:g="en",iconsBase:v=h,icons:w=k(v)}=e;return{name:t,short_name:n,description:r,start_url:i,scope:l,display:o,orientation:a,background_color:c,theme_color:s,lang:g,icons:w}}function f(e){return JSON.stringify({version:e})+`
|
|
2
2
|
`}function d({swUrl:e="/sw.js"}={}){return`/** Registers the offline service worker and reloads the page whenever a new app version is deployed. */
|
|
3
3
|
if ("serviceWorker" in navigator) {
|
|
4
4
|
navigator.serviceWorker.addEventListener("message", (event) => {
|
|
@@ -13,8 +13,8 @@ if ("serviceWorker" in navigator) {
|
|
|
13
13
|
});
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
|
-
`}function m(e){let{cacheName:t,cdnVersion:n,iconsBase:r=h,manifestUrl:i="/manifest.webmanifest",appFiles:l=[],extraPrecacheUrls:
|
|
17
|
-
const NODEXUI_CDN = ${JSON.stringify(
|
|
16
|
+
`}function m(e){let{cacheName:t,cdnVersion:n,iconsBase:r=h,manifestUrl:i="/manifest.webmanifest",appFiles:l=[],extraPrecacheUrls:o=[]}=e,a=n?`https://cdn.jsdelivr.net/npm/nodexui@${n}/dist/`:null,c=["/",i,...p.map(s=>`${r}${s}`),...l,...o,...a?["nodexui.min.css","nodexui.esm.js","nodexui.templates.xml"].map(s=>`${a}${s}`):[]];return`const CACHE_NAME = ${JSON.stringify(t)};
|
|
17
|
+
const NODEXUI_CDN = ${JSON.stringify(a)};
|
|
18
18
|
|
|
19
19
|
const PRECACHE_URLS = ${JSON.stringify(c,null,2)};
|
|
20
20
|
|
|
@@ -40,11 +40,15 @@ async function runVersionCheck() {
|
|
|
40
40
|
const known = await store.match(VERSION_URL);
|
|
41
41
|
const previous = known ? await known.text() : null;
|
|
42
42
|
if (previous === latest) return;
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
if (previous === null) {
|
|
44
|
+
await store.put(VERSION_URL, new Response(latest));
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
45
47
|
const names = await caches.keys();
|
|
46
48
|
await Promise.all(names.filter((name) => name !== VERSION_CACHE).map((name) => caches.delete(name)));
|
|
47
49
|
await precache();
|
|
50
|
+
// Remember the new version only once its files are cached, so a failed precache is retried on the next check.
|
|
51
|
+
await store.put(VERSION_URL, new Response(latest));
|
|
48
52
|
const pages = await self.clients.matchAll({ type: "window" });
|
|
49
53
|
pages.forEach((page) => page.postMessage("version-changed"));
|
|
50
54
|
} catch {
|
|
@@ -101,7 +105,7 @@ self.addEventListener("fetch", (event) => {
|
|
|
101
105
|
event.respondWith(
|
|
102
106
|
caches.open(CACHE_NAME).then(async (cache) => {
|
|
103
107
|
try {
|
|
104
|
-
const response = await fetch(request);
|
|
108
|
+
const response = await fetch(request, { cache: "no-cache" });
|
|
105
109
|
if (response.ok) cache.put(request, response.clone());
|
|
106
110
|
return response;
|
|
107
111
|
} catch {
|
|
@@ -112,5 +116,5 @@ self.addEventListener("fetch", (event) => {
|
|
|
112
116
|
})
|
|
113
117
|
);
|
|
114
118
|
});
|
|
115
|
-
`}function R(e){let t=y("sha256");for(let n of Object.keys(e).sort()){let r=e[n];t.update(n).update(r.type==="chunk"?r.code:r.source)}return t.digest("hex").slice(0,12)}function S(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"app"}var _=N(new URL(E(new URL("./pwa-icons/",import.meta.url))?"./pwa-icons/":"../../pwa-icons/",import.meta.url));function I({name:e="Nodex UI App",cdnVersion:t,...n}={}){let r=S(e),i=n.themeColor??"#0f172a";return{name:"nodexui-pwa",apply:"build",transformIndexHtml:()=>[{tag:"link",attrs:{rel:"manifest",href:"/manifest.webmanifest"},injectTo:"head"},{tag:"link",attrs:{rel:"apple-touch-icon",href:"/icons/apple-touch-icon.png"},injectTo:"head"},{tag:"meta",attrs:{name:"theme-color",content:i},injectTo:"head"},{tag:"script",attrs:{type:"module",src:"/sw-register.js"},injectTo:"body"}],generateBundle(l,
|
|
116
|
-
`}),this.emitFile({type:"asset",fileName:"sw.js",source:m({cacheName:`${r}-cache-v1`,cdnVersion:t,appFiles:
|
|
119
|
+
`}function R(e){let t=y("sha256");for(let n of Object.keys(e).sort()){let r=e[n];t.update(n).update(r.type==="chunk"?r.code:r.source)}return t.digest("hex").slice(0,12)}function S(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"app"}var _=N(new URL(E(new URL("./pwa-icons/",import.meta.url))?"./pwa-icons/":"../../pwa-icons/",import.meta.url));function I({name:e="Nodex UI App",cdnVersion:t,...n}={}){let r=S(e),i=n.themeColor??"#0f172a";return{name:"nodexui-pwa",apply:"build",transformIndexHtml:()=>[{tag:"link",attrs:{rel:"manifest",href:"/manifest.webmanifest"},injectTo:"head"},{tag:"link",attrs:{rel:"apple-touch-icon",href:"/icons/apple-touch-icon.png"},injectTo:"head"},{tag:"meta",attrs:{name:"theme-color",content:i},injectTo:"head"},{tag:"script",attrs:{type:"module",src:"/sw-register.js"},injectTo:"body"}],generateBundle(l,o){let a=Object.keys(o).map(s=>`/${s}`),c=R(o);this.emitFile({type:"asset",fileName:"manifest.webmanifest",source:JSON.stringify(u({name:e,...n}),null,2)+`
|
|
120
|
+
`}),this.emitFile({type:"asset",fileName:"sw.js",source:m({cacheName:`${r}-cache-v1`,cdnVersion:t,appFiles:a})}),this.emitFile({type:"asset",fileName:"sw-register.js",source:d()}),this.emitFile({type:"asset",fileName:"version.json",source:f(c)});for(let s of p)this.emitFile({type:"asset",fileName:`icons/${s}`,source:C(`${_}${s}`)})}}}export{I as nodexuiPwa};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
var v=["get","post","put","patch","delete","options","head","trace","query"];function M(e,o,r){let t=String(e||"").trim();if(!t)return"";let n=t.replace(/\{([^}]+)\}/g,(a,h)=>{let m=r&&typeof r=="object"?r[h]:null;return m&&m.default!==void 0?String(m.default):`{${h}}`});try{return new URL(n,`${o}/`).href.replace(/\/$/,"")}catch{return n.replace(/\/$/,"")}}function y(e,o){if(e&&typeof e=="object"&&typeof e.$ref=="string"){let r=e.$ref.replace(/^#\//,"").split("/"),t=o;for(let n of r)t=t?.[decodeURIComponent(n.replace(/~1/g,"/").replace(/~0/g,"~"))];return t?{...t}:{}}return e}function A(e,o){if(!Array.isArray(e?.allOf))return e;let r={...e,properties:{...e.properties},required:[...e.required||[]]};delete r.allOf;for(let t of e.allOf){let n=A(y(t,o),o)||{};Object.assign(r.properties,n.properties),r.required.push(...n.required||[]),r.type||(r.type=n.type)}return r}function B(e,o){if(!e)return null;let r=y(e,o);return!r||typeof r!="object"?null:r}function U(e){return e&&typeof e.$ref=="string"?e.$ref.split("/").pop():null}function P(e,o){if(!e||typeof e!="object")return null;for(let[r,t]of Object.entries(e)){let n=B(t,o);if(n){if(n.dataValue!==void 0)return{key:r,label:n.summary||r,value:n.dataValue,isAuto:!1};if(n.serializedValue!==void 0)return{key:r,label:n.summary||r,value:n.serializedValue,isAuto:!1};if(n.value!==void 0)return{key:r,label:n.summary||r,value:n.value,isAuto:!1};if(n.externalValue)return{key:r,label:n.summary||r,value:n.externalValue,isAuto:!1}}}return null}function N(e){if(e){if(e.example!==void 0)return e.example;if(e.default!==void 0)return e.default;if(Array.isArray(e.enum)&&e.enum.length)return e.enum[0]}}function E(e,o){if(!e)return null;let r=P(e.examples,o);if(r)return r;if(e.example!==void 0)return{label:"media example",value:e.example,isAuto:!1};let t=y(e.schema,o),n=N(t);return n!==void 0?{label:"schema example",value:n,isAuto:!1}:null}function $(e,o){let r=P(e.examples,o);if(r)return r;if(e.example!==void 0)return{label:"example",value:e.example,isAuto:!1};let t=y(e.schema,o),n=N(t);return n!==void 0?{label:"schema example",value:n,isAuto:!1}:null}function x(e,o,r=new Set){if(!e)return null;let t=U(e);if(t){if(r.has(t))return{};r=new Set(r).add(t)}let n=A(y(e,o),o);if(!n)return null;let a=N(n);if(a!==void 0)return a;if(n.type==="array"||n.items)return[x(n.items||{},o,r)];if(n.properties||n.type==="object"){let h={};for(let[m,i]of Object.entries(n.properties||{}))h[m]=x(i,o,r);return h}switch(n.type){case"integer":return n.minimum??0;case"number":return n.minimum??0;case"boolean":return!0;case"string":return n.format==="date-time"?new Date().toISOString():n.format==="date"?new Date().toISOString().slice(0,10):n.format==="byte"?"base64==":n.title||"string";default:return null}}function j(e,o,{depth:r=0,prefix:t="",seen:n=new Set,required:a=!1,selfRow:h=!0}={}){if(!e||r>4)return[];let m=U(e);if(m){if(n.has(m))return[];n=new Set(n).add(m)}let i=A(y(e,o),o),l=[],p=i.contentMediaType||i.contentEncoding?[i.contentMediaType,i.contentEncoding&&`encoding:${i.contentEncoding}`].filter(Boolean).join(", "):"",d=i.discriminator?.propertyName?`discriminator: ${i.discriminator.propertyName}`:"";if(Array.isArray(i.prefixItems))return h&&l.push({path:t||"items",type:"tuple",required:a,description:i.description||""}),i.prefixItems.forEach((f,g)=>{l.push(...j(f,o,{depth:r+1,prefix:`${t}[${g}]`,seen:n,required:!1}))}),i.items&&l.push(...j(i.items,o,{depth:r+1,prefix:`${t}[n]`,seen:n,required:!1})),l;if(i.type==="array"||i.items)return h&&l.push({path:t||"items",type:"array",required:a,description:i.description||""}),l.push(...j(i.items||{},o,{depth:r+1,prefix:`${t}[]`,seen:n,required:!1})),l;if(i.properties||i.type==="object"||i.patternProperties){let f=new Set(i.required||[]);for(let[g,s]of Object.entries(i.properties||{})){let c=y(s,o),S=t?`${t}.${g}`:g;l.push({path:S,type:c.type||(c.$ref?U(s):"any")||"any",format:c.format||"",enum:c.enum,required:f.has(g),description:c.description||""}),(c.type==="object"||c.properties||c.type==="array"||c.items)&&l.push(...j(s,o,{depth:r+1,prefix:S,seen:n,required:f.has(g),selfRow:!1}))}for(let[g,s]of Object.entries(i.patternProperties||{})){let c=y(s,o);l.push({path:t?`${t}.<${g}>`:`<${g}>`,type:c.type||"any",format:c.format||"",required:!1,description:c.description||""})}return l}return l.push({path:t||"value",type:i.type||"any",format:i.format||"",enum:i.enum,required:a,description:[i.description,p,d].filter(Boolean).join(" \u2014 ")}),l}function z(e){let o=$(e,this);return{name:e.name,in:e.in,required:!!e.required,type:e.type||e.schema?.type||"string",format:e.format||e.schema?.format||"",description:e.description||"",default:e.default??e.schema?.default,enum:e.enum||e.schema?.enum,example:o?o.value:void 0,exampleLabel:o?o.label:""}}var F={authorizationCode:"accessCode",implicit:"implicit",password:"password",clientCredentials:"application"};function V(e){if(e.type==="http")return{...e,type:String(e.scheme).toLowerCase()==="basic"?"basic":"bearer"};if(e.type==="openIdConnect")return{...e,type:"bearer",oauth2MetadataUrl:e.openIdConnectUrl};if(e.type!=="oauth2"||!e.flows)return e;let[o,r]=Object.entries(e.flows)[0]||[];return{...e,...r,flow:F[o]||o,scopes:r?.scopes||{}}}function k(e){let o=e.securityDefinitions||e.components?.securitySchemes||{};return Object.fromEntries(Object.entries(o).map(([r,t])=>[r,V(y(t,e))]))}function W(e,o){let r=k(o),t=e.security||o.security||[],n=[];for(let a of t)for(let h of Object.keys(a)){let m=r[h];m&&n.push({key:h,...m})}return n}function O(e,o,r,t){let n={path:[],query:[],header:[],formData:[],body:null};for(let l of t.parameters||[]){let p=y(l,e);if(p.in==="body"){let d={schema:p.schema},f=E(d,e);n.body={required:!!p.required,schema:p.schema,description:p.description||"",contentType:"application/json",example:f?f.value:x(p.schema,e),exampleLabel:f?f.label:"auto",exampleIsAuto:!f}}else n[p.in]&&n[p.in].push(z.call(e,p))}if(t.requestBody){let l=y(t.requestBody,e)||{},[p,d]=Object.entries(l.content||{})[0]||[];if(p&&d){let f=E(d,e);n.body={required:!!l.required,schema:d.schema||null,description:l.description||"",contentType:p,encoding:d.encoding||null,itemSchema:d.itemSchema||null,example:f?f.value:x(d.schema,e),exampleLabel:f?f.label:"auto",exampleIsAuto:!f}}}let a=Object.entries(t.responses||{}).map(([l,p])=>{let d=y(p,e)||{},[f,g]=Object.entries(d.content||{})[0]||[],s=g?E(g,e):null;return{status:l,summary:d.summary||"",description:d.description||"",contentType:f||"application/json",schema:g?.schema||d.schema||null,encoding:g?.encoding||null,headers:G(d.headers,e),links:J(d.links,e),example:s?s.value:g?.schema?x(g.schema,e):null,exampleLabel:s?s.label:"auto",exampleIsAuto:!s&&!!g?.schema}}).sort((l,p)=>{let d=_(l.status),f=_(p.status);return d-f}),h=Q(t.callbacks,e),m=r.toUpperCase();return{id:(t.operationId||`${r}-${o}`).replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase(),method:m,path:o,tag:t.tags&&t.tags[0]||"default",summary:t.summary||t.operationId||`${m} ${o}`,description:t.description||"",deprecated:!!t.deprecated,produces:t.produces||e.produces||["application/json"],consumes:t.consumes||e.consumes||(n.body?["application/json"]:[]),parameters:n,responses:a,callbacks:h,externalDocs:t.externalDocs||null,security:W(t,e)}}function G(e,o){return!e||typeof e!="object"?[]:Object.entries(e).map(([r,t])=>{let n=y(t,o)||{},a=$({...n,in:"header"},o);return{name:r,required:!!n.required,deprecated:!!n.deprecated,type:n.schema?.type||"string",description:n.description||"",example:a?a.value:void 0}})}function J(e,o){return!e||typeof e!="object"?[]:Object.entries(e).map(([r,t])=>{let n=y(t,o)||{};return{name:r,operationId:n.operationId||"",operationRef:n.operationRef||"",description:n.description||"",parameters:n.parameters||{}}})}function Q(e,o){if(!e||typeof e!="object")return[];let r=[];for(let[t,n]of Object.entries(e)){let a=y(n,o)||{};for(let[h,m]of Object.entries(a)){let i=y(m,o)||{};for(let l of v)i[l]&&r.push({name:t,expression:h,method:l.toUpperCase(),summary:i[l].summary||"",description:i[l].description||""})}}return r}function _(e){if(e==="default")return 999;let o=parseInt(e,10);return Number.isNaN(o)?998:o}async function K(e,o=""){let r=await fetch(e);if(!r.ok)throw new Error(`Failed to fetch spec: HTTP ${r.status}`);return H(await r.json(),o)}function H(e,o=""){if(!e||typeof e!="object"||!e.paths&&!e.webhooks)throw new Error("Not an OpenAPI document (missing paths).");let r=e.schemes&&e.schemes.includes("https")?"https":e.schemes?.[0]||"https",t=e.host||location.host,n=e.basePath||"",a=`${r}://${t}${n}`.replace(/\/$/,""),h=o?[{name:"",url:o.replace(/\/$/,""),description:""}]:Array.isArray(e.servers)&&e.servers.length?e.servers.map(s=>({name:s?.name||"",url:M(s?.url,a,s?.variables),description:String(s?.description||"").trim()})).filter(s=>s.url):[{name:"",url:a,description:""}],m=h[0]?.url||a,i=(e.tags||[]).map(s=>s.name),l=new Map((e.tags||[]).map(s=>[s.name,s])),p=[];for(let[s,c]of Object.entries(e.paths||{})){let S=y(c,e)||{};for(let T of v)S[T]&&p.push(O(e,s,T,S[T]));for(let[T,D]of Object.entries(S.additionalOperations||{}))p.push(O(e,s,T.toLowerCase(),D))}let d=[];for(let[s,c]of Object.entries(e.webhooks||{})){let S=y(c,e)||{};for(let T of v)S[T]&&d.push(O(e,s,T,S[T]))}let g=[...new Set([...i,...p.map(s=>s.tag)])].map(s=>{let c=l.get(s);return{id:s.replace(/[^a-zA-Z0-9]+/g,"-").toLowerCase(),name:s,summary:c?.summary||"",description:c?.description||"",parent:c?.parent||"",kind:c?.kind||"",items:p.filter(S=>S.tag===s)}}).filter(s=>s.items.length);return{spec:e,info:e.info||{},baseUrl:m,derivedBaseUrl:a,servers:h,securityDefinitions:k(e),groups:g,webhooks:d,resolveRef:s=>y(s,e),generateExample:s=>x(s,e),schemaRows:s=>j(s,e),findOperation:s=>p.find(c=>c.id===s)||d.find(c=>c.id===s),firstOperation:()=>p[0]}}var q=[{id:"curl",label:"CURL",icon:"img/bash-plain.svg"},{id:"csharp",label:"CSHARP",icon:"img/csharp-original.svg"},{id:"go",label:"GO",icon:"img/go-original-wordmark.svg"},{id:"node",label:"NODEJS",icon:"img/nodejs-original.svg"},{id:"ruby",label:"RUBY",icon:"img/ruby-plain.svg"},{id:"php",label:"PHP",icon:"img/php-original.svg"},{id:"javascript",label:"JAVASCRIPT",icon:"img/javascript-original.svg"},{id:"python",label:"PYTHON",icon:"img/python-original.svg"},{id:"java",label:"JAVA",icon:"img/java-original.svg"},{id:"c",label:"C",icon:"img/c-original.svg"},{id:"swift",label:"SWIFT",icon:"img/swift-original.svg"},{id:"objc",label:"OBJECTIVE-C",icon:"img/objectivec-plain.svg"},{id:"kotlin",label:"KOTLIN",icon:"img/kotlin-original.svg"},{id:"rust",label:"RUST",icon:"img/rust-original.svg"},{id:"powershell",label:"POWERSHELL",icon:"img/windows8-original.svg"},{id:"dart",label:"DART",icon:"img/dart-original.svg"},{id:"lua",label:"LUA",icon:"img/lua.svg"}];function Y(e){let o=new URL(e.url);return(e.query||[]).forEach(([r,t])=>{r&&o.searchParams.set(r,String(t||""))}),o.toString()}function Z(e,o){let r=[];return(e.headers||[]).forEach(([n,a])=>{n&&r.push([n,String(a??"")])}),o&&e.bodyText&&!X(r,"Content-Type")&&r.push(["Content-Type",e.mimeType||"application/json"]),r}function X(e,o){let r=o.toLowerCase();return e.some(function(t){return String(t[0]||"").toLowerCase()===r})}function ee(e,o){return String(e||"").split(`
|
|
1
|
+
var U=["get","post","put","patch","delete","options","head","trace","query"];function B(e,o,r){let t=String(e||"").trim();if(!t)return"";let n=t.replace(/\{([^}]+)\}/g,(a,f)=>{let h=r&&typeof r=="object"?r[f]:null;return h&&h.default!==void 0?String(h.default):`{${f}}`});try{return new URL(n,`${o}/`).href.replace(/\/$/,"")}catch{return n.replace(/\/$/,"")}}function m(e,o){if(e&&typeof e=="object"&&typeof e.$ref=="string"){let r=e.$ref.replace(/^#\//,"").split("/"),t=o;for(let n of r)t=t?.[decodeURIComponent(n.replace(/~1/g,"/").replace(/~0/g,"~"))];return t?{...t}:{}}return e}function N(e,o){if(!Array.isArray(e?.allOf))return e;let r={...e,properties:{...e.properties},required:[...e.required||[]]};delete r.allOf;for(let t of e.allOf){let n=N(m(t,o),o)||{};Object.assign(r.properties,n.properties),r.required.push(...n.required||[]),r.type||(r.type=n.type)}return r}function z(e,o){if(!e)return null;let r=m(e,o);return!r||typeof r!="object"?null:r}function A(e){return e&&typeof e.$ref=="string"?e.$ref.split("/").pop():null}function $(e,o){if(!e||typeof e!="object")return null;for(let[r,t]of Object.entries(e)){let n=z(t,o);if(n){if(n.dataValue!==void 0)return{key:r,label:n.summary||r,value:n.dataValue,isAuto:!1};if(n.serializedValue!==void 0)return{key:r,label:n.summary||r,value:n.serializedValue,isAuto:!1};if(n.value!==void 0)return{key:r,label:n.summary||r,value:n.value,isAuto:!1};if(n.externalValue)return{key:r,label:n.summary||r,value:n.externalValue,isAuto:!1}}}return null}function _(e){if(e){if(e.example!==void 0)return e.example;if(e.default!==void 0)return e.default;if(Array.isArray(e.enum)&&e.enum.length)return e.enum[0]}}function O(e,o){if(!e)return null;let r=$(e.examples,o);if(r)return r;if(e.example!==void 0)return{label:"media example",value:e.example,isAuto:!1};let t=m(e.schema,o),n=_(t);return n!==void 0?{label:"schema example",value:n,isAuto:!1}:null}function k(e,o){let r=$(e.examples,o);if(r)return r;if(e.example!==void 0)return{label:"example",value:e.example,isAuto:!1};let t=m(e.schema,o),n=_(t);return n!==void 0?{label:"schema example",value:n,isAuto:!1}:null}function j(e,o,r=new Set){if(!e)return null;let t=A(e);if(t){if(r.has(t))return{};r=new Set(r).add(t)}let n=N(m(e,o),o);if(!n)return null;let a=_(n);if(a!==void 0)return a;if(n.type==="array"||n.items)return[j(n.items||{},o,r)];if(n.properties||n.type==="object"){let f={};for(let[h,i]of Object.entries(n.properties||{}))f[h]=j(i,o,r);return f}switch(n.type){case"integer":return n.minimum??0;case"number":return n.minimum??0;case"boolean":return!0;case"string":return n.format==="date-time"?new Date().toISOString():n.format==="date"?new Date().toISOString().slice(0,10):n.format==="byte"?"base64==":n.title||"string";default:return null}}function w(e,o,{depth:r=0,prefix:t="",seen:n=new Set,required:a=!1,selfRow:f=!0}={}){if(!e||r>4)return[];let h=A(e);if(h){if(n.has(h))return[];n=new Set(n).add(h)}let i=N(m(e,o),o),l=[],c=i.contentMediaType||i.contentEncoding?[i.contentMediaType,i.contentEncoding&&`encoding:${i.contentEncoding}`].filter(Boolean).join(", "):"",d=i.discriminator?.propertyName?`discriminator: ${i.discriminator.propertyName}`:"";if(Array.isArray(i.prefixItems))return f&&l.push({path:t||"items",type:"tuple",required:a,description:i.description||""}),i.prefixItems.forEach((p,g)=>{l.push(...w(p,o,{depth:r+1,prefix:`${t}[${g}]`,seen:n,required:!1}))}),i.items&&l.push(...w(i.items,o,{depth:r+1,prefix:`${t}[n]`,seen:n,required:!1})),l;if(i.type==="array"||i.items)return f&&l.push({path:t||"items",type:"array",required:a,description:i.description||""}),l.push(...w(i.items||{},o,{depth:r+1,prefix:`${t}[]`,seen:n,required:!1})),l;if(i.properties||i.type==="object"||i.patternProperties){let p=new Set(i.required||[]);for(let[g,b]of Object.entries(i.properties||{})){let s=m(b,o),S=t?`${t}.${g}`:g;l.push({path:S,type:s.type||(s.$ref?A(b):"any")||"any",format:s.format||"",enum:s.enum,required:p.has(g),description:s.description||""}),(s.type==="object"||s.properties||s.type==="array"||s.items)&&l.push(...w(b,o,{depth:r+1,prefix:S,seen:n,required:p.has(g),selfRow:!1}))}for(let[g,b]of Object.entries(i.patternProperties||{})){let s=m(b,o);l.push({path:t?`${t}.<${g}>`:`<${g}>`,type:s.type||"any",format:s.format||"",required:!1,description:s.description||""})}return l}return l.push({path:t||"value",type:i.type||"any",format:i.format||"",enum:i.enum,required:a,description:[i.description,c,d].filter(Boolean).join(" \u2014 ")}),l}function F(e){let o=k(e,this);return{name:e.name,in:e.in,required:!!e.required,type:e.type||e.schema?.type||"string",format:e.format||e.schema?.format||"",description:e.description||"",default:e.default??e.schema?.default,enum:e.enum||e.schema?.enum,example:o?o.value:void 0,exampleLabel:o?o.label:""}}var V={authorizationCode:"accessCode",implicit:"implicit",password:"password",clientCredentials:"application"};function W(e){if(e.type==="http")return{...e,type:String(e.scheme).toLowerCase()==="basic"?"basic":"bearer"};if(e.type==="openIdConnect")return{...e,type:"bearer",oauth2MetadataUrl:e.openIdConnectUrl};if(e.type!=="oauth2"||!e.flows)return e;let[o,r]=Object.entries(e.flows)[0]||[];return{...e,...r,flow:V[o]||o,scopes:r?.scopes||{}}}function H(e){let o=e.securityDefinitions||e.components?.securitySchemes||{};return Object.fromEntries(Object.entries(o).map(([r,t])=>[r,W(m(t,e))]))}function G(e,o){let r=H(o),t=e.security||o.security||[],n=[];for(let a of t)for(let f of Object.keys(a)){let h=r[f];h&&n.push({key:f,...h})}return n}function v(e,o,r,t){let n={path:[],query:[],header:[],formData:[],body:null};for(let l of t.parameters||[]){let c=m(l,e);if(c.in==="body"){let d={schema:c.schema},p=O(d,e);n.body={required:!!c.required,schema:c.schema,description:c.description||"",contentType:"application/json",example:p?p.value:j(c.schema,e),exampleLabel:p?p.label:"auto",exampleIsAuto:!p}}else n[c.in]&&n[c.in].push(F.call(e,c))}if(t.requestBody){let l=m(t.requestBody,e)||{},[c,d]=Object.entries(l.content||{})[0]||[];if(c&&d){let p=O(d,e);n.body={required:!!l.required,schema:d.schema||null,description:l.description||"",contentType:c,encoding:d.encoding||null,itemSchema:d.itemSchema||null,example:p?p.value:j(d.schema,e),exampleLabel:p?p.label:"auto",exampleIsAuto:!p}}}let a=Object.entries(t.responses||{}).map(([l,c])=>{let d=m(c,e)||{},[p,g]=Object.entries(d.content||{})[0]||[],b=g?O(g,e):null;return{status:l,summary:d.summary||"",description:d.description||"",contentType:p||"application/json",schema:g?.schema||d.schema||null,encoding:g?.encoding||null,headers:J(d.headers,e),links:Q(d.links,e),example:b?b.value:g?.schema?j(g.schema,e):null,exampleLabel:b?b.label:"auto",exampleIsAuto:!b&&!!g?.schema}}).sort((l,c)=>{let d=P(l.status),p=P(c.status);return d-p}),f=K(t.callbacks,e),h=r.toUpperCase();return{id:(t.operationId||`${r}-${o}`).replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase(),method:h,path:o,tag:t.tags&&t.tags[0]||"default",summary:t.summary||t.operationId||`${h} ${o}`,description:t.description||"",deprecated:!!t.deprecated,produces:t.produces||e.produces||["application/json"],consumes:t.consumes||e.consumes||(n.body?["application/json"]:[]),parameters:n,responses:a,callbacks:f,externalDocs:t.externalDocs||null,security:G(t,e)}}function J(e,o){return!e||typeof e!="object"?[]:Object.entries(e).map(([r,t])=>{let n=m(t,o)||{},a=k({...n,in:"header"},o);return{name:r,required:!!n.required,deprecated:!!n.deprecated,type:n.schema?.type||"string",description:n.description||"",example:a?a.value:void 0}})}function Q(e,o){return!e||typeof e!="object"?[]:Object.entries(e).map(([r,t])=>{let n=m(t,o)||{};return{name:r,operationId:n.operationId||"",operationRef:n.operationRef||"",description:n.description||"",parameters:n.parameters||{}}})}function K(e,o){if(!e||typeof e!="object")return[];let r=[];for(let[t,n]of Object.entries(e)){let a=m(n,o)||{};for(let[f,h]of Object.entries(a)){let i=m(h,o)||{};for(let l of U)i[l]&&r.push({name:t,expression:f,method:l.toUpperCase(),summary:i[l].summary||"",description:i[l].description||""})}}return r}function P(e){if(e==="default")return 999;let o=parseInt(e,10);return Number.isNaN(o)?998:o}async function Y(e,o=""){let r=await fetch(e);if(!r.ok)throw new Error(`Failed to fetch spec: HTTP ${r.status}`);return q(await r.json(),o)}function q(e,o=""){if(!e||typeof e!="object"||!e.paths&&!e.webhooks)throw new Error("Not an OpenAPI document (missing paths).");let r=e.schemes&&e.schemes.includes("https")?"https":e.schemes?.[0]||"https",t=e.host||location.host,n=e.basePath||"",a=`${r}://${t}${n}`.replace(/\/$/,""),f=o?[{name:"",url:o.replace(/\/$/,""),description:""}]:Array.isArray(e.servers)&&e.servers.length?e.servers.map(s=>({name:s?.name||"",url:B(s?.url,a,s?.variables),description:String(s?.description||"").trim()})).filter(s=>s.url):[{name:"",url:a,description:""}],h=f[0]?.url||a,i=(e.tags||[]).map(s=>s.name),l=new Map((e.tags||[]).map(s=>[s.name,s])),c=[];for(let[s,S]of Object.entries(e.paths||{})){let x=m(S,e)||{};for(let T of U)x[T]&&c.push(v(e,s,T,x[T]));for(let[T,M]of Object.entries(x.additionalOperations||{}))c.push(v(e,s,T.toLowerCase(),M))}let d=[];for(let[s,S]of Object.entries(e.webhooks||{})){let x=m(S,e)||{};for(let T of U)x[T]&&d.push(v(e,s,T,x[T]))}let p=new Map;for(let s of[...c,...d])p.has(s.id)||p.set(s.id,s);let b=[...new Set([...i,...c.map(s=>s.tag)])].map(s=>{let S=l.get(s);return{id:s.replace(/[^a-zA-Z0-9]+/g,"-").toLowerCase(),name:s,summary:S?.summary||"",description:S?.description||"",parent:S?.parent||"",kind:S?.kind||"",items:c.filter(x=>x.tag===s)}}).filter(s=>s.items.length);return{spec:e,info:e.info||{},baseUrl:h,derivedBaseUrl:a,servers:f,securityDefinitions:H(e),groups:b,webhooks:d,resolveRef:s=>m(s,e),generateExample:s=>j(s,e),schemaRows:s=>w(s,e),findOperation:s=>p.get(s),firstOperation:()=>c[0]}}var I=[{id:"curl",label:"CURL",icon:"img/bash-plain.svg"},{id:"csharp",label:"CSHARP",icon:"img/csharp-original.svg"},{id:"go",label:"GO",icon:"img/go-original-wordmark.svg"},{id:"node",label:"NODEJS",icon:"img/nodejs-original.svg"},{id:"ruby",label:"RUBY",icon:"img/ruby-plain.svg"},{id:"php",label:"PHP",icon:"img/php-original.svg"},{id:"javascript",label:"JAVASCRIPT",icon:"img/javascript-original.svg"},{id:"python",label:"PYTHON",icon:"img/python-original.svg"},{id:"java",label:"JAVA",icon:"img/java-original.svg"},{id:"c",label:"C",icon:"img/c-original.svg"},{id:"swift",label:"SWIFT",icon:"img/swift-original.svg"},{id:"objc",label:"OBJECTIVE-C",icon:"img/objectivec-plain.svg"},{id:"kotlin",label:"KOTLIN",icon:"img/kotlin-original.svg"},{id:"rust",label:"RUST",icon:"img/rust-original.svg"},{id:"powershell",label:"POWERSHELL",icon:"img/windows8-original.svg"},{id:"dart",label:"DART",icon:"img/dart-original.svg"},{id:"lua",label:"LUA",icon:"img/lua.svg"}];function Z(e){let o=new URL(e.url);return(e.query||[]).forEach(([r,t])=>{r&&o.searchParams.set(r,String(t||""))}),o.toString()}function X(e,o){let r=[];return(e.headers||[]).forEach(([n,a])=>{n&&r.push([n,String(a??"")])}),o&&e.bodyText&&!ee(r,"Content-Type")&&r.push(["Content-Type",e.mimeType||"application/json"]),r}function ee(e,o){let r=o.toLowerCase();return e.some(function(t){return String(t[0]||"").toLowerCase()===r})}function te(e,o){return String(e||"").split(`
|
|
2
2
|
`).map(function(r){return o+r}).join(`
|
|
3
|
-
`)}function
|
|
4
|
-
`)}function
|
|
5
|
-
`)}function
|
|
6
|
-
`)}function
|
|
7
|
-
`)}function
|
|
8
|
-
`)}function
|
|
9
|
-
`)}function
|
|
10
|
-
`)}function
|
|
11
|
-
`)}function
|
|
12
|
-
`)}function
|
|
13
|
-
`)}function
|
|
14
|
-
`)}function
|
|
15
|
-
`)}function
|
|
16
|
-
`)}function
|
|
17
|
-
`)}function
|
|
18
|
-
`)}function
|
|
19
|
-
`)}function
|
|
20
|
-
`)}var
|
|
3
|
+
`)}function y(e){return String(e).replace(/\\/g,"\\\\").replace(/'/g,"\\'")}function u(e){return String(e).replace(/\\/g,"\\\\").replace(/"/g,'\\"')}function ne(e){return String(e).replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")}function re(e){return String(e).replace(/`/g,'` + "`" + `')}function oe(e){return String(e).replace(/\\/g,"\\\\").replace(/"""/g,'\\"\\"\\"')}function R(e){return String(e).replace(/\\/g,"\\\\").replace(/'/g,"\\'")}function C(e){return String(e).replace(/\\/g,"\\\\").replace(/'/g,"\\\\'")}function L(e){return String(e).replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\r/g,"\\r").replace(/\n/g,"\\n")}function E(e){return String(e).replace(/`/g,"``").replace(/"/g,'`"')}function se(e){return String(e).replace(/\]=\]/g,']==] .. "]=" .. [=[')}function ie(e,o){let r=o&&o.quote==="double"?'"':"'";return e.map(function(n){let a=r==='"'?u(n[0]):y(n[0]),f=r==='"'?u(n[1]):y(n[1]);return r+a+r+": "+r+f+r}).join(`,
|
|
4
|
+
`)}function ae(e,o,r){let t=["curl --request "+e.method];return r.forEach(function(n){t.push("--header '"+y(n[0]+": "+n[1])+"'")}),e.bodyText&&t.push("--data '"+y(e.bodyText)+"'"),t.push("'"+y(o)+"'"),t.join(` \\
|
|
5
|
+
`)}function D(e,o,r){let t=["const url = '"+y(o)+"';","const options = {"," method: '"+y(e.method)+"',"];return r.length&&(t.push(" headers: {"),t.push(te(ie(r)," ")),t.push(" },")),e.bodyText&&t.push(" body: `"+ne(e.bodyText)+"`,"),t.push("};","","const response = await fetch(url, options);","const data = await response.text();","console.log(response.status, data);"),t.join(`
|
|
6
|
+
`)}function ue(e,o,r){return D(e,o,r)}function le(e,o,r){let t=["import requests","","url = '"+y(o)+"'"];return r.length?(t.push("headers = {"),r.forEach(function(n){t.push(" '"+y(n[0])+"': '"+y(n[1])+"',")}),t.push("}")):t.push("headers = {}"),e.bodyText?(t.push("",'payload = """'+oe(e.bodyText)+'"""'),t.push("response = requests.request('"+y(e.method)+"', url, headers=headers, data=payload)")):t.push("","response = requests.request('"+y(e.method)+"', url, headers=headers)"),t.push("print(response.status_code)","print(response.text)"),t.join(`
|
|
7
|
+
`)}function ce(e,o,r){let t=["package main","","import (",' "fmt"',' "io"',' "net/http"'];return e.bodyText&&t.push(' "strings"'),t.push(")","","func main() {"),e.bodyText?(t.push(" body := strings.NewReader(`"+re(e.bodyText)+"`)"),t.push(' req, err := http.NewRequest("'+e.method+'", "'+o+'", body)')):t.push(' req, err := http.NewRequest("'+e.method+'", "'+o+'", nil)'),t.push(" if err != nil {"," panic(err)"," }"),r.forEach(function(n){t.push(' req.Header.Set("'+u(n[0])+'", "'+u(n[1])+'")')}),t.push(""," res, err := http.DefaultClient.Do(req)"," if err != nil {"," panic(err)"," }"," defer res.Body.Close()",""," data, err := io.ReadAll(res.Body)"," if err != nil {"," panic(err)"," }",""," fmt.Println(res.StatusCode)"," fmt.Println(string(data))","}"),t.join(`
|
|
8
|
+
`)}function pe(e,o,r){let t=["OkHttpClient client = new OkHttpClient();","","Request.Builder builder = new Request.Builder()",' .url("'+u(o)+'")'];return r.forEach(function(n){t.push(' .addHeader("'+u(n[0])+'", "'+u(n[1])+'")')}),e.bodyText?t.push(";","",'MediaType mediaType = MediaType.parse("'+u(e.mimeType||"application/json")+'");','RequestBody body = RequestBody.create("""'+u(e.bodyText)+'""", mediaType);','Request request = builder.method("'+e.method+'", body).build();'):t.push(";","",'Request request = builder.method("'+e.method+'", null).build();'),t.push("","try (Response response = client.newCall(request).execute()) {"," System.out.println(response.code());",' System.out.println(response.body() != null ? response.body().string() : "");',"}"),t.join(`
|
|
9
|
+
`)}function de(e,o,r){let n=["using var client = new HttpClient();","using var request = new HttpRequestMessage(HttpMethod."+(e.method.charAt(0)+e.method.slice(1).toLowerCase())+', "'+u(o)+'");'];return r.forEach(function(a){n.push('request.Headers.TryAddWithoutValidation("'+u(a[0])+'", "'+u(a[1])+'");')}),e.bodyText&&n.push('request.Content = new StringContent("""'+u(e.bodyText)+'""", Encoding.UTF8, "'+u(e.mimeType||"application/json")+'");'),n.push("","using var response = await client.SendAsync(request);","var body = await response.Content.ReadAsStringAsync();","Console.WriteLine((int)response.StatusCode);","Console.WriteLine(body);"),n.join(`
|
|
10
|
+
`)}function fe(e,o,r){let t=["$ch = curl_init();","curl_setopt_array($ch, ["," CURLOPT_URL => '"+R(o)+"',"," CURLOPT_CUSTOMREQUEST => '"+R(e.method)+"',"," CURLOPT_RETURNTRANSFER => true,"];return r.length&&(t.push(" CURLOPT_HTTPHEADER => ["),r.forEach(function(n){t.push(" '"+R(n[0]+": "+n[1])+"',")}),t.push(" ],")),e.bodyText&&t.push(" CURLOPT_POSTFIELDS => '"+R(e.bodyText)+"',"),t.push("]);","","$response = curl_exec($ch);","echo curl_getinfo($ch, CURLINFO_RESPONSE_CODE) . PHP_EOL;","echo $response;","curl_close($ch);"),t.join(`
|
|
11
|
+
`)}function he(e,o,r){let t=e.method.charAt(0)+e.method.slice(1).toLowerCase(),n=['require "uri"','require "net/http"',"","uri = URI('"+C(o)+"')","http = Net::HTTP.new(uri.host, uri.port)",'http.use_ssl = uri.scheme == "https"',"","request = Net::HTTP::"+t+".new(uri)"];return r.forEach(function(a){n.push("request['"+C(a[0])+"'] = '"+C(a[1])+"'")}),e.bodyText&&n.push("request.body = '"+C(e.bodyText)+"'"),n.push("","response = http.request(request)","puts response.code","puts response.body"),n.join(`
|
|
12
|
+
`)}function me(e,o,r){let t=["#include <curl/curl.h>","","int main(void) {"," CURL *curl = curl_easy_init();"," if (!curl) return 1;",""," struct curl_slist *headers = NULL;"];return r.forEach(function(n){t.push(' headers = curl_slist_append(headers, "'+L(n[0]+": "+n[1])+'");')}),t.push(' curl_easy_setopt(curl, CURLOPT_URL, "'+L(o)+'");'),t.push(' curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "'+L(e.method)+'");'),r.length&&t.push(" curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);"),e.bodyText&&t.push(' curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "'+L(e.bodyText)+'");'),t.push(""," curl_easy_perform(curl);"," curl_slist_free_all(headers);"," curl_easy_cleanup(curl);"," return 0;","}"),t.join(`
|
|
13
|
+
`)}function ge(e,o,r){let t=['var request = URLRequest(url: URL(string: "'+u(o)+'")!)','request.httpMethod = "'+u(e.method)+'"'];return r.forEach(function(n){t.push('request.setValue("'+u(n[1])+'", forHTTPHeaderField: "'+u(n[0])+'")')}),e.bodyText&&t.push('request.httpBody = """',e.bodyText,'""".data(using: .utf8)'),t.push("","URLSession.shared.dataTask(with: request) { data, response, error in"," if let error = error {"," print(error)"," return"," }"," let status = (response as? HTTPURLResponse)?.statusCode ?? 0"," print(status)",' print(String(data: data ?? Data(), encoding: .utf8) ?? "")',"}.resume()"),t.join(`
|
|
14
|
+
`)}function ye(e,o,r){let t=['NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"'+u(o)+'"]];','request.HTTPMethod = @"'+u(e.method)+'";'];return r.forEach(function(n){t.push('[request setValue:@"'+u(n[1])+'" forHTTPHeaderField:@"'+u(n[0])+'"];')}),e.bodyText&&t.push('request.HTTPBody = [@"'+u(e.bodyText)+'" dataUsingEncoding:NSUTF8StringEncoding];'),t.push("","NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithRequest:request"," completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {"," if (error) {",' NSLog(@"%@", error);'," return;"," }"," NSInteger status = [(NSHTTPURLResponse *)response statusCode];"," NSString *body = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];",' NSLog(@"%ld", (long)status);',' NSLog(@"%@", body);',"}];","[task resume];"),t.join(`
|
|
15
|
+
`)}function be(e,o,r){let t=["val client = OkHttpClient()"];return e.bodyText&&t.push('val body = """',e.bodyText,'""".trimIndent().toRequestBody("'+u(e.mimeType||"application/json")+'".toMediaType())'),t.push("val request = Request.Builder()",' .url("'+u(o)+'")'),r.forEach(function(n){t.push(' .addHeader("'+u(n[0])+'", "'+u(n[1])+'")')}),t.push(e.bodyText?' .method("'+e.method+'", body)':' .method("'+e.method+'", null)'," .build()","","client.newCall(request).execute().use { response ->"," println(response.code)"," println(response.body?.string().orEmpty())","}"),t.join(`
|
|
16
|
+
`)}function Se(e,o,r){let t=["let client = reqwest::Client::new();","let response = client"," ."+e.method.toLowerCase()+'("'+u(o)+'")'];return r.forEach(function(n){t.push(' .header("'+u(n[0])+'", "'+u(n[1])+'")')}),e.bodyText&&t.push(' .body(r#"'+e.bodyText.replace(/"#/g,'"#""#')+'"#)'),t.push(" .send()"," .await?;","",'println!("{}", response.status());','println!("{}", response.text().await?);'),t.join(`
|
|
17
|
+
`)}function Te(e,o,r){let t=["$headers = @{"];return r.forEach(function(n){t.push(' "'+E(n[0])+'" = "'+E(n[1])+'"')}),t.push("}",""),e.bodyText&&t.push('$body = @"',e.bodyText,'"@',""),t.push("$response = Invoke-RestMethod -Method "+e.method+' -Uri "'+E(o)+'" -Headers $headers'+(e.bodyText?' -Body $body -ContentType "'+E(e.mimeType||"application/json")+'"':""),"$response | ConvertTo-Json -Depth 10"),t.join(`
|
|
18
|
+
`)}function xe(e,o,r){let t=["import 'package:http/http.dart' as http;","","final uri = Uri.parse('"+y(o)+"');","final headers = <String, String>{"];return r.forEach(function(n){t.push(" '"+y(n[0])+"': '"+y(n[1])+"',")}),t.push("};",""),e.bodyText?t.push("final response = await http."+e.method.toLowerCase()+"(uri, headers: headers, body: '''"+e.bodyText.replace(/'''/g,"'' '")+"''');"):t.push("final response = await http."+e.method.toLowerCase()+"(uri, headers: headers);"),t.push("print('Status: ${response.statusCode}');","print(response.body);"),t.join(`
|
|
19
|
+
`)}function je(e,o,r){let t=['local http = require("socket.http")','local ltn12 = require("ltn12")',"","local response_body = {}","local headers = {"];return r.forEach(function(n){t.push(' ["'+u(n[0])+'"] = "'+u(n[1])+'",')}),t.push("}",""),e.bodyText&&(t.push("local body = [==["+se(e.bodyText)+"]==]",""),t.push('headers["Content-Length"] = tostring(#body)')),t.push("local _, code = http.request{",' url = "'+u(o)+'",',' method = "'+u(e.method)+'",'," headers = headers,"),e.bodyText&&t.push(" source = ltn12.source.string(body),"),t.push(" sink = ltn12.sink.table(response_body),","}","",'print("Status: " .. tostring(code))',"print(table.concat(response_body))"),t.join(`
|
|
20
|
+
`)}var we={curl:ae,javascript:D,node:ue,python:le,go:ce,java:pe,csharp:de,php:fe,ruby:he,c:me,swift:ge,objc:ye,kotlin:be,rust:Se,powershell:Te,dart:xe,lua:je};async function Re(e,o){let r=I.find(function(a){return a.id===e});if(!r)throw new Error("Unknown language: "+e);let t=X(o,!0),n=Z(o);return we[r.id](o,n,t)}export{I as LANGUAGES,q as buildOpenApiDoc,Re as generateSnippet,Y as loadOpenApiDoc};
|