@nice2dev/ui-api 1.4.32 → 1.4.33

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 CHANGED
@@ -1,5 +1,31 @@
1
1
  # @nice2dev/ui-api
2
2
 
3
+ ## 1.4.33
4
+
5
+ ### Patch Changes
6
+
7
+ - acc59d7: NiceIntegrationBuilder on the shared workflow designer (round 44, 1.4.33).
8
+
9
+ - **NiceIntegrationBuilder** is now a flow of `NiceWorkflowDesigner` (`@nice2dev/ui-diagrams`) — one
10
+ interface for workflows and integrations — with the steps an integration needs:
11
+ - Start: the trigger is optional (manual unless a schedule, a webhook or an event is picked);
12
+ - Call a function: picked by path from the catalog (`functions`) — the module's scripts and the
13
+ integrations' endpoints as functions (new core `integrationFunctions(file)`:
14
+ `integrations/<key>/<operationId>`), with arguments and a variable for the result;
15
+ - For each: a loop over a list (a dictionary synced item by item) — its "each" transition runs the
16
+ body, which comes back; "done" goes on;
17
+ - Map fields, Condition (yes / no), End, Error.
18
+ New props `workflow` / `defaultWorkflow` / `onChange` (a `NiceWorkflowDefinition`), `functions`,
19
+ `stepTypes`, `onSave` (Publish), `onRun` (Test), `readOnly`, `height`; new exports
20
+ `integrationStepTypes`, `newIntegrationFlow`, `integrationFunctions`, `NiceFlowFunction`. The old
21
+ canvas and its `flow` / `connectors` props are gone; its flow types stay exported, deprecated.
22
+ `@nice2dev/ui-diagrams` is a new peer of `@nice2dev/ui-api`.
23
+ - **NiceWorkflowDesigner**: a step kind declares its fields (`fields`: text, long text, a list, a
24
+ number, a switch — new type `NiceWorkflowStepField`), edited in the step's properties and kept in
25
+ the step's new `config`; an empty required field is a validation warning; `summary(config)` shows
26
+ the configured value under the step's name.
27
+ - Translations for the new texts in all twelve dictionaries.
28
+
3
29
  ## 1.4.32
4
30
 
5
31
  ### Patch Changes
@@ -1,7 +1,39 @@
1
+ import { NiceWorkflowDefinition } from '@nice2dev/ui';
2
+ import { NiceComponentTutorial, NiceTranslateFn } from '@nice2dev/ui-core';
3
+ import { NiceWorkflowStepType } from '@nice2dev/ui-diagrams';
1
4
  import { default as React } from 'react';
2
- import { NiceIntegrationBuilderProps } from './types';
5
+ import { NiceFlowFunction } from './core';
6
+ export interface NiceIntegrationBuilderProps {
7
+ /** The flow (controlled) — a workflow of the shared designer. */
8
+ workflow?: NiceWorkflowDefinition;
9
+ /** The flow to start from (uncontrolled). Default: Start → End. */
10
+ defaultWorkflow?: NiceWorkflowDefinition;
11
+ onChange?: (workflow: NiceWorkflowDefinition) => void;
12
+ /**
13
+ * The function catalog a Call step picks from: the module's scripts, the integrations' endpoints
14
+ * (`integrationFunctions(file)`), the host's functions.
15
+ */
16
+ functions?: NiceFlowFunction[];
17
+ /** More kinds of step, merged by id over the integration ones. */
18
+ stepTypes?: NiceWorkflowStepType[];
19
+ /** The designer's Publish. */
20
+ onSave?: (workflow: NiceWorkflowDefinition) => void;
21
+ /** The designer's Test. */
22
+ onRun?: (workflow: NiceWorkflowDefinition) => void;
23
+ readOnly?: boolean;
24
+ /** Height. Default 560. */
25
+ height?: number | string;
26
+ className?: string;
27
+ style?: React.CSSProperties;
28
+ /** Optional guided tour. `true` = built-in; array/object = custom steps. Shows a "?" button. */
29
+ tutorial?: NiceComponentTutorial;
30
+ }
3
31
  /**
4
- * NiceIntegrationBuilder - Visual Flow Builder
32
+ * The integration steps of the designer — Start (optional trigger), Call a function (from
33
+ * `functions`), For each, Map fields, Condition, End, Error.
5
34
  */
6
- export declare function NiceIntegrationBuilder({ flow: initialFlow, connectors, onChange, onSave, onRun, className, tutorial, }: NiceIntegrationBuilderProps): React.ReactElement;
7
- export default NiceIntegrationBuilder;
35
+ export declare function integrationStepTypes(functions: readonly NiceFlowFunction[], t: NiceTranslateFn): NiceWorkflowStepType[];
36
+ /** A new flow: Start → End. */
37
+ export declare function newIntegrationFlow(name?: string): NiceWorkflowDefinition;
38
+ /** An integration's flow on the shared workflow designer, with the integration steps. */
39
+ export declare function NiceIntegrationBuilder({ workflow, defaultWorkflow, onChange, functions, stepTypes, onSave, onRun, readOnly, height, className, style, tutorial, }: NiceIntegrationBuilderProps): React.ReactElement;
@@ -168,6 +168,24 @@ export declare function validateIntegrations(file: NiceIntegrationsFile, sets?:
168
168
  * (named schemas resolved, `allOf` merged).
169
169
  */
170
170
  export declare function responseFieldPaths(endpoints: NiceApiCollection | undefined, requestId: string | undefined): string[];
171
+ /**
172
+ * 1.4.33: a function a flow step can call (NiceIntegrationBuilder): a module script, an integration's
173
+ * endpoint, any function of the host — picked by its path from the catalog.
174
+ */
175
+ export interface NiceFlowFunction {
176
+ /** Unique: `scripts/syncCurrencies`, `integrations/psd2-accounts/listAccounts`. */
177
+ path: string;
178
+ name?: string;
179
+ kind?: 'script' | 'endpoint' | 'function';
180
+ /** The heading it is listed under (an integration's name, `Scripts`…). */
181
+ group?: string;
182
+ description?: string;
183
+ }
184
+ /**
185
+ * 1.4.33: every consumed endpoint of the integrations as a function with a path —
186
+ * `integrations/<integration key>/<operationId or request name>` — listed under its integration.
187
+ */
188
+ export declare function integrationFunctions(file: NiceIntegrationsFile): NiceFlowFunction[];
171
189
  export declare function groupIntegrations(integrations: readonly NiceIntegrationDef[]): {
172
190
  package: string;
173
191
  directions: {
package/dist/core.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var In=Object.defineProperty;var Pn=(e,t,n)=>t in e?In(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var xe=(e,t,n)=>Pn(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ln=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","TRACE"],Rn=["inherit","none","apiKey","bearer","basic","digest","oauth2","awsSigV4","hmac","mtls","custom"];let Ve=0;function $e(e="r"){return Ve=(Ve+1)%1e6,`${e}${Date.now().toString(36)}${Ve.toString(36)}${Math.random().toString(36).slice(2,6)}`}function ye(e={}){return{...e,kind:"request",id:e.id??$e("r"),name:e.name??"New request",method:e.method??"GET",url:e.url??"",params:e.params??[],body:e.body??{kind:"none"}}}function be(e={}){return{...e,kind:"folder",id:e.id??$e("f"),name:e.name??"New folder",items:e.items??[]}}function ge(e={}){return{...e,id:e.id??$e("c"),name:e.name??"New API",items:e.items??[],variables:e.variables??[]}}function le(e,t=[]){const n=[];for(const s of e)s.kind==="folder"?n.push(...le(s.items,[...t,s])):n.push({request:s,folders:[...t]});return n}const Nt="#/components/schemas/";function Dn(e,t,n){var a;if(!n||t===n||!((a=e.schemas)!=null&&a[t])||e.schemas[n])return e;const s=Nt+t,r=Nt+n,o=c=>Array.isArray(c)?c.map(o):c&&typeof c=="object"?Object.fromEntries(Object.entries(c).map(([p,u])=>[p,p==="$ref"&&u===s?r:o(u)])):c,i=Object.fromEntries(Object.entries(e.schemas).map(([c,p])=>[c===t?n:c,p]));return o({...e,schemas:i})}function Dt(e,t){for(const n of e){if(n.id===t)return n;if(n.kind==="folder"){const s=Dt(n.items,t);if(s)return s}}}function Ht(e,t,n){const s=[];for(const r of e)if(r.id===t){const o=n(r);o&&s.push(o)}else r.kind==="folder"?s.push({...r,items:Ht(r.items,t,n)}):s.push(r);return s}function I(e){return e.enabled!==!1}function Hn(e){const t={};for(const n of e)I(n)&&(t[n.key]=n.value);return t}function Mt(e,t){return e.params.filter(n=>n.in===t&&I(n))}function Mn(e,t){var s;const n=t.toLowerCase();return(s=Mt(e,"header").find(r=>r.key.toLowerCase()===n))==null?void 0:s.value}function zt(e,t=[],n){const s=[e.auth,...[...t].reverse().map(r=>r.auth),n==null?void 0:n.auth];for(const r of s)if(r&&r.type!=="inherit")return r;return{type:"none"}}function we(e){switch(e.kind){case"json":case"graphql":return"application/json";case"xml":return"application/xml";case"text":return e.contentType??"text/plain";case"form":return"application/x-www-form-urlencoded";case"multipart":return"multipart/form-data";case"binary":return e.contentType??"application/octet-stream";case"soap":return e.version==="1.2"?`application/soap+xml; charset=utf-8${e.action?`; action="${e.action}"`:""}`:"text/xml; charset=utf-8";default:return}}function re(e){var t;switch(e.kind){case"json":case"xml":case"text":return e.text;case"form":return e.fields.filter(I).map(n=>`${encodeURIComponent(n.key)}=${encodeURIComponent(n.value)}`).join("&");case"graphql":{const n={query:e.query};if((t=e.variables)!=null&&t.trim())try{n.variables=JSON.parse(e.variables)}catch{n.variables=e.variables}return e.operationName&&(n.operationName=e.operationName),JSON.stringify(n)}case"soap":return e.envelope;default:return}}function ft(e,t){const n=(t??"").toLowerCase();return n.includes("x-www-form-urlencoded")?{kind:"form",fields:dt(e)}:n.includes("soap+xml")?{kind:"soap",envelope:e,version:"1.2"}:n.includes("xml")?/<(\w+:)?Envelope[\s>]/.test(e)?{kind:"soap",envelope:e,version:"1.1"}:{kind:"xml",text:e}:n.includes("json")||!n&&/^\s*[[{]/.test(e)?zn(e)??{kind:"json",text:e}:{kind:"text",text:e,contentType:t||void 0}}function dt(e){return e?e.split("&").map(t=>{const n=t.indexOf("="),s=r=>{try{return decodeURIComponent(r.replace(/\+/g," "))}catch{return r}};return n<0?{key:s(t),value:""}:{key:s(t.slice(0,n)),value:s(t.slice(n+1))}}):[]}function zn(e){try{const t=JSON.parse(e);if(t&&typeof t=="object"&&typeof t.query=="string"&&/^\s*(query|mutation|subscription|\{|fragment)/.test(t.query))return{kind:"graphql",query:t.query,variables:t.variables===void 0?void 0:JSON.stringify(t.variables,null,2),operationName:typeof t.operationName=="string"?t.operationName:void 0}}catch{}return null}const Wt=/\{\{\s*([^{}]+?)\s*\}\}/g;function mt(e){const t=new Set;for(const n of e.matchAll(Wt))t.add(n[1]);return[...t]}function Wn(e){const t=s=>Array.from({length:s},()=>Math.floor(e()*16).toString(16)).join(""),n=(8+Math.floor(e()*4)).toString(16);return`${t(8)}-${t(4)}-4${t(3)}-${n}${t(3)}-${t(12)}`}function ht(e,t,n={}){const s=typeof t=="function"?t:c=>t[c],r=n.random??Math.random,o=n.now??(()=>new Date),i=c=>{var p;if(c.startsWith("secret:"))return(p=n.resolveSecret)==null?void 0:p.call(n,c.slice(7).trim());switch(c){case"$guid":case"$randomUUID":return Wn(r);case"$timestamp":return String(Math.floor(o().getTime()/1e3));case"$isoTimestamp":return o().toISOString();case"$randomInt":return String(Math.floor(r()*1001));default:return s(c)}};let a=e;for(let c=0;c<5&&a.includes("{{");c++){const p=a.replace(Wt,(u,d)=>i(d)??u);if(p===a)break;a=p}return a}function Bn(e,t,n={}){return mt(ht(e,t,n))}function Fn(e,t){const n=[];for(const s of e)for(const r of(s==null?void 0:s.variableSets)??[]){const o=t.find(i=>i.id===r);o&&n.push(o)}return n}function Vn(e,t,n,s){const r={},o=i=>{for(const a of i??[])I(a)&&a.key&&(r[a.key]=a.value)};o(e==null?void 0:e.variables),o(t==null?void 0:t.values);for(const i of s??[])o(i.values);return{...r,...n}}function ce(e){let t=e.trim(),n="";const s=t.indexOf("#");s>=0&&(n=t.slice(s),t=t.slice(0,s));const r=t.indexOf("?");return r<0?{base:t,query:[],hash:n}:{base:t.slice(0,r),query:dt(t.slice(r+1)),hash:n}}function Bt(e){const t=ce(e).base,n=[],s=t.replace(/^[a-z][\w+.-]*:\/\/[^/]*/i,"").replace(/^\{\{[^}]+\}\}/,"");for(const r of s.matchAll(new RegExp("(?<!\\{)\\{([A-Za-z_][\\w.-]*)\\}(?!\\})|(?:^|\\/):([A-Za-z_][\\w-]*)","g"))){const o=r[1]??r[2];n.includes(o)||n.push(o)}return n}function Ft(e){const t=Bt(e.url),n=e.params.filter(r=>r.in!=="path");return[...t.map(r=>e.params.find(o=>o.in==="path"&&o.key===r)??{key:r,value:"",in:"path",required:!0}),...n]}function Vt(e,t){const{base:n,query:s,hash:r}=ce(t),o={...e,url:n+r,params:[...e.params.filter(i=>i.in!=="query"),...s.map(i=>({...i,in:"query"}))]};return{...o,params:Ft(o)}}function Kn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function jt(e){return encodeURIComponent(e).replace(/[!'()*]/g,t=>`%${t.charCodeAt(0).toString(16).toUpperCase()}`)}function ve(e,t=n=>n){const{base:n,query:s,hash:r}=ce(e.url);let o=t(n);for(const a of e.params){if(a.in!=="path"||!I(a))continue;const c=encodeURIComponent(t(a.value)),p=new RegExp(`(^|/):${Kn(a.key)}(?=/|$)`);o=o.split(`{${a.key}}`).join(c).replace(p,(u,d)=>d+c)}const i=[...s,...e.params.filter(a=>a.in==="query"&&I(a))].map(a=>{const c=jt(t(a.key)),p=t(a.value);return p===""&&!("in"in a)?c:`${c}=${jt(p)}`});return o+(i.length?`?${i.join("&")}`:"")+t(r)}function Jn(e,t){return e?t?`${e.replace(/\/+$/,"")}/${t.replace(/^\/+/,"")}`:e:t}function Kt(e){return/^\s*(?:\$\s*)?curl(?:\.exe)?(?:\s|$)/i.test(e)}function Gn(e){return/\^\r?\n/.test(e)||/\^"/.test(e)?"cmd":/`\r?\n/.test(e)||/^\s*curl\.exe\b/i.test(e)?"powershell":"bash"}function Jt(e,t=Gn(e)){var c;let n=e.replace(/\r\n?/g,`
1
+ "use strict";var In=Object.defineProperty;var Pn=(e,t,n)=>t in e?In(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var xe=(e,t,n)=>Pn(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ln=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","TRACE"],Rn=["inherit","none","apiKey","bearer","basic","digest","oauth2","awsSigV4","hmac","mtls","custom"];let Ve=0;function $e(e="r"){return Ve=(Ve+1)%1e6,`${e}${Date.now().toString(36)}${Ve.toString(36)}${Math.random().toString(36).slice(2,6)}`}function ye(e={}){return{...e,kind:"request",id:e.id??$e("r"),name:e.name??"New request",method:e.method??"GET",url:e.url??"",params:e.params??[],body:e.body??{kind:"none"}}}function be(e={}){return{...e,kind:"folder",id:e.id??$e("f"),name:e.name??"New folder",items:e.items??[]}}function ge(e={}){return{...e,id:e.id??$e("c"),name:e.name??"New API",items:e.items??[],variables:e.variables??[]}}function pe(e,t=[]){const n=[];for(const s of e)s.kind==="folder"?n.push(...pe(s.items,[...t,s])):n.push({request:s,folders:[...t]});return n}const Nt="#/components/schemas/";function Dn(e,t,n){var a;if(!n||t===n||!((a=e.schemas)!=null&&a[t])||e.schemas[n])return e;const s=Nt+t,r=Nt+n,o=c=>Array.isArray(c)?c.map(o):c&&typeof c=="object"?Object.fromEntries(Object.entries(c).map(([p,u])=>[p,p==="$ref"&&u===s?r:o(u)])):c,i=Object.fromEntries(Object.entries(e.schemas).map(([c,p])=>[c===t?n:c,p]));return o({...e,schemas:i})}function Dt(e,t){for(const n of e){if(n.id===t)return n;if(n.kind==="folder"){const s=Dt(n.items,t);if(s)return s}}}function Ht(e,t,n){const s=[];for(const r of e)if(r.id===t){const o=n(r);o&&s.push(o)}else r.kind==="folder"?s.push({...r,items:Ht(r.items,t,n)}):s.push(r);return s}function I(e){return e.enabled!==!1}function Hn(e){const t={};for(const n of e)I(n)&&(t[n.key]=n.value);return t}function Mt(e,t){return e.params.filter(n=>n.in===t&&I(n))}function Mn(e,t){var s;const n=t.toLowerCase();return(s=Mt(e,"header").find(r=>r.key.toLowerCase()===n))==null?void 0:s.value}function zt(e,t=[],n){const s=[e.auth,...[...t].reverse().map(r=>r.auth),n==null?void 0:n.auth];for(const r of s)if(r&&r.type!=="inherit")return r;return{type:"none"}}function we(e){switch(e.kind){case"json":case"graphql":return"application/json";case"xml":return"application/xml";case"text":return e.contentType??"text/plain";case"form":return"application/x-www-form-urlencoded";case"multipart":return"multipart/form-data";case"binary":return e.contentType??"application/octet-stream";case"soap":return e.version==="1.2"?`application/soap+xml; charset=utf-8${e.action?`; action="${e.action}"`:""}`:"text/xml; charset=utf-8";default:return}}function re(e){var t;switch(e.kind){case"json":case"xml":case"text":return e.text;case"form":return e.fields.filter(I).map(n=>`${encodeURIComponent(n.key)}=${encodeURIComponent(n.value)}`).join("&");case"graphql":{const n={query:e.query};if((t=e.variables)!=null&&t.trim())try{n.variables=JSON.parse(e.variables)}catch{n.variables=e.variables}return e.operationName&&(n.operationName=e.operationName),JSON.stringify(n)}case"soap":return e.envelope;default:return}}function ft(e,t){const n=(t??"").toLowerCase();return n.includes("x-www-form-urlencoded")?{kind:"form",fields:dt(e)}:n.includes("soap+xml")?{kind:"soap",envelope:e,version:"1.2"}:n.includes("xml")?/<(\w+:)?Envelope[\s>]/.test(e)?{kind:"soap",envelope:e,version:"1.1"}:{kind:"xml",text:e}:n.includes("json")||!n&&/^\s*[[{]/.test(e)?zn(e)??{kind:"json",text:e}:{kind:"text",text:e,contentType:t||void 0}}function dt(e){return e?e.split("&").map(t=>{const n=t.indexOf("="),s=r=>{try{return decodeURIComponent(r.replace(/\+/g," "))}catch{return r}};return n<0?{key:s(t),value:""}:{key:s(t.slice(0,n)),value:s(t.slice(n+1))}}):[]}function zn(e){try{const t=JSON.parse(e);if(t&&typeof t=="object"&&typeof t.query=="string"&&/^\s*(query|mutation|subscription|\{|fragment)/.test(t.query))return{kind:"graphql",query:t.query,variables:t.variables===void 0?void 0:JSON.stringify(t.variables,null,2),operationName:typeof t.operationName=="string"?t.operationName:void 0}}catch{}return null}const Wt=/\{\{\s*([^{}]+?)\s*\}\}/g;function mt(e){const t=new Set;for(const n of e.matchAll(Wt))t.add(n[1]);return[...t]}function Wn(e){const t=s=>Array.from({length:s},()=>Math.floor(e()*16).toString(16)).join(""),n=(8+Math.floor(e()*4)).toString(16);return`${t(8)}-${t(4)}-4${t(3)}-${n}${t(3)}-${t(12)}`}function ht(e,t,n={}){const s=typeof t=="function"?t:c=>t[c],r=n.random??Math.random,o=n.now??(()=>new Date),i=c=>{var p;if(c.startsWith("secret:"))return(p=n.resolveSecret)==null?void 0:p.call(n,c.slice(7).trim());switch(c){case"$guid":case"$randomUUID":return Wn(r);case"$timestamp":return String(Math.floor(o().getTime()/1e3));case"$isoTimestamp":return o().toISOString();case"$randomInt":return String(Math.floor(r()*1001));default:return s(c)}};let a=e;for(let c=0;c<5&&a.includes("{{");c++){const p=a.replace(Wt,(u,d)=>i(d)??u);if(p===a)break;a=p}return a}function Bn(e,t,n={}){return mt(ht(e,t,n))}function Fn(e,t){const n=[];for(const s of e)for(const r of(s==null?void 0:s.variableSets)??[]){const o=t.find(i=>i.id===r);o&&n.push(o)}return n}function Vn(e,t,n,s){const r={},o=i=>{for(const a of i??[])I(a)&&a.key&&(r[a.key]=a.value)};o(e==null?void 0:e.variables),o(t==null?void 0:t.values);for(const i of s??[])o(i.values);return{...r,...n}}function ce(e){let t=e.trim(),n="";const s=t.indexOf("#");s>=0&&(n=t.slice(s),t=t.slice(0,s));const r=t.indexOf("?");return r<0?{base:t,query:[],hash:n}:{base:t.slice(0,r),query:dt(t.slice(r+1)),hash:n}}function Bt(e){const t=ce(e).base,n=[],s=t.replace(/^[a-z][\w+.-]*:\/\/[^/]*/i,"").replace(/^\{\{[^}]+\}\}/,"");for(const r of s.matchAll(new RegExp("(?<!\\{)\\{([A-Za-z_][\\w.-]*)\\}(?!\\})|(?:^|\\/):([A-Za-z_][\\w-]*)","g"))){const o=r[1]??r[2];n.includes(o)||n.push(o)}return n}function Ft(e){const t=Bt(e.url),n=e.params.filter(r=>r.in!=="path");return[...t.map(r=>e.params.find(o=>o.in==="path"&&o.key===r)??{key:r,value:"",in:"path",required:!0}),...n]}function Vt(e,t){const{base:n,query:s,hash:r}=ce(t),o={...e,url:n+r,params:[...e.params.filter(i=>i.in!=="query"),...s.map(i=>({...i,in:"query"}))]};return{...o,params:Ft(o)}}function Kn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function jt(e){return encodeURIComponent(e).replace(/[!'()*]/g,t=>`%${t.charCodeAt(0).toString(16).toUpperCase()}`)}function ve(e,t=n=>n){const{base:n,query:s,hash:r}=ce(e.url);let o=t(n);for(const a of e.params){if(a.in!=="path"||!I(a))continue;const c=encodeURIComponent(t(a.value)),p=new RegExp(`(^|/):${Kn(a.key)}(?=/|$)`);o=o.split(`{${a.key}}`).join(c).replace(p,(u,d)=>d+c)}const i=[...s,...e.params.filter(a=>a.in==="query"&&I(a))].map(a=>{const c=jt(t(a.key)),p=t(a.value);return p===""&&!("in"in a)?c:`${c}=${jt(p)}`});return o+(i.length?`?${i.join("&")}`:"")+t(r)}function Jn(e,t){return e?t?`${e.replace(/\/+$/,"")}/${t.replace(/^\/+/,"")}`:e:t}function Kt(e){return/^\s*(?:\$\s*)?curl(?:\.exe)?(?:\s|$)/i.test(e)}function Gn(e){return/\^\r?\n/.test(e)||/\^"/.test(e)?"cmd":/`\r?\n/.test(e)||/^\s*curl\.exe\b/i.test(e)?"powershell":"bash"}function Jt(e,t=Gn(e)){var c;let n=e.replace(/\r\n?/g,`
2
2
  `);t==="cmd"?n=n.replace(/\^\n/g," ").replace(/\^([\s\S])/g,"$1"):t==="powershell"?n=n.replace(/`\n/g," "):n=n.replace(/\\\n/g," ");const s=[];let r="",o=!1,i=0;const a=()=>{o&&s.push(r),r="",o=!1};for(;i<n.length;){const p=n[i];if(p===" "||p===" "||p===`
3
3
  `){a(),i++;continue}if(p==="#"&&!o&&t==="bash"){for(;i<n.length&&n[i]!==`
4
4
  `;)i++;continue}if(o=!0,p==="'"&&t!=="cmd"){for(i++;i<n.length;){if(n[i]==="'"){if(t==="powershell"&&n[i+1]==="'"){r+="'",i+=2;continue}break}r+=n[i++]}i++;continue}if(p==="$"&&n[i+1]==="'"&&t==="bash"){for(i+=2;i<n.length&&n[i]!=="'";){if(n[i]==="\\"&&i+1<n.length){const u=n[i+1],d={n:`
@@ -51,10 +51,10 @@ ${`
51
51
 
52
52
  `)?"+":"":"-";n.push(`${s}|${i?"2":""}${c}`);for(const p of o)n.push(p?a+p:"");return}n.push(s+ds(e))}function sn(e){const t=[];return tt(e,0,t,""),`${t.join(`
53
53
  `)}
54
- `}function De(e,t=en){const n=e.trimStart();if(n.startsWith("{")||n.startsWith("["))try{return JSON.parse(n)}catch{}return t(e)}function Fe(e){return t=>{var s;const n=(s=/^#\/(?:components\/schemas|definitions)\/(.+)$/.exec(t))==null?void 0:s[1];return n?e==null?void 0:e[decodeURIComponent(n.replace(/~1/g,"/").replace(/~0/g,"~"))]:void 0}}function hs(e){if(Array.isArray(e.type))return e.type.find(t=>t!=="null")??e.type[0];if(e.type)return e.type;if(e.properties||e.additionalProperties)return"object";if(e.items)return"array"}function ys(e,t){switch(e.format){case"email":return"user@example.com";case"date":return t().toISOString().slice(0,10);case"date-time":return t().toISOString();case"time":return t().toISOString().slice(11,19);case"uuid":return"3fa85f64-5717-4562-b3fc-2c963f66afa6";case"uri":case"url":return"https://example.com";case"hostname":return"example.com";case"ipv4":return"192.168.0.1";case"ipv6":return"::1";case"byte":return"U3dhZ2dlciByb2Nrcw==";case"binary":return"";case"password":return"********";default:{const n=e.title??"string";return e.minLength&&n.length<e.minLength?n.padEnd(e.minLength,"x"):e.maxLength&&n.length>e.maxLength?n.slice(0,e.maxLength):n}}}function bt(e,t={}){const n=t.maxDepth??6,s=t.arrayItems??1,r=t.now??(()=>new Date),o=(i,a,c)=>{var u,d,f,l,m,k;if(!i)return null;if(i.$ref){if(c.has(i.$ref)||a>n)return null;const y=(u=t.resolveRef)==null?void 0:u.call(t,i.$ref);return y?o(y,a,new Set([...c,i.$ref])):null}if(i.example!==void 0)return i.example;if((d=i.examples)!=null&&d.length)return i.examples[0];if(i.const!==void 0)return i.const;if(i.default!==void 0)return i.default;if((f=i.enum)!=null&&f.length)return i.enum[0];if((l=i.allOf)!=null&&l.length){const y={};let v;for(const $ of i.allOf){const T=o($,a,c);T&&typeof T=="object"&&!Array.isArray(T)?Object.assign(y,T):T!=null&&(v=T)}return i.properties&&Object.assign(y,o({...i,allOf:void 0},a,c)),Object.keys(y).length?y:v??null}const p=((m=i.oneOf)==null?void 0:m[0])??((k=i.anyOf)==null?void 0:k[0]);if(p)return o(p,a,c);switch(hs(i)){case"string":return ys(i,r);case"integer":return i.minimum??0;case"number":return i.minimum??0;case"boolean":return!0;case"array":return a>=n?[]:Array.from({length:s},()=>o(i.items,a+1,c));case"object":{if(a>=n)return{};const y={};for(const[v,$]of Object.entries(i.properties??{}))t.usage==="request"&&$.readOnly||t.usage==="response"&&$.writeOnly||(y[v]=o($,a+1,c));return!i.properties&&i.additionalProperties&&typeof i.additionalProperties=="object"&&(y.key=o(i.additionalProperties,a+1,c)),y}case"null":return null;default:return null}};return o(e,0,new Set)}function He(e){if(e===null)return{type:"null"};if(Array.isArray(e))return e.length?{type:"array",items:He(e[0])}:{type:"array"};switch(typeof e){case"string":return/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(e)?{type:"string",format:"date-time"}:/^\d{4}-\d{2}-\d{2}$/.test(e)?{type:"string",format:"date"}:/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)?{type:"string",format:"uuid"}:/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(e)?{type:"string",format:"email"}:{type:"string"};case"number":return{type:Number.isInteger(e)?"integer":"number"};case"boolean":return{type:"boolean"};case"object":{const t={};for(const[n,s]of Object.entries(e))t[n]=He(s);return{type:"object",properties:t}}default:return{}}}function gs(e,t){var p;const n=(p=e.examples)==null?void 0:p[0];if(n){const u={};for(const d of n.headers??[])u[d.key]=d.value;return{status:n.status,headers:u,body:n.body??""}}const s=Object.entries(e.responses??{}),[r,o]=s.find(([u])=>/^2\d\d$/.test(u))??s.find(([u])=>u==="default")??["200",void 0],i=/^\d{3}$/.test(r)?Number(r):200;if(!o)return{status:i,headers:{},body:""};const a=o.contentType??"application/json";let c=o.example??"";if(!c&&o.schema){const u=bt(o.schema,{resolveRef:Fe(t==null?void 0:t.schemas),usage:"response"});c=typeof u=="string"?u:JSON.stringify(u,null,2)}return{status:i,headers:{"Content-Type":a},body:c}}const j=e=>!!e&&typeof e=="object"&&!Array.isArray(e),z=e=>typeof e=="string"?e:void 0,rn=["get","put","post","delete","options","head","patch","trace"],bs=["query","path","header","cookie"];function nt(e,t){const n=t.indexOf("#"),s=n>=0?t.slice(n+1):"";if(!s||s==="/")return e;let r=e;for(const o of s.split("/").slice(1)){const i=decodeURIComponent(o).replace(/~1/g,"/").replace(/~0/g,"~");if(j(r))r=r[i];else if(Array.isArray(r))r=r[Number(i)];else return}return r}function fe(e){return e==null?"":typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):JSON.stringify(e)}function Ge(e){const t=Object.keys(e),n=[s=>s==="application/json",s=>/\+json$|\/json/.test(s),s=>s==="application/x-www-form-urlencoded",s=>s==="multipart/form-data",s=>/xml/.test(s),s=>s.startsWith("text/"),()=>!0];for(const s of n){const r=t.find(s);if(r)return[r,j(e[r])?e[r]:{}]}}function on(e,t={}){var x,U,D;let n=typeof e=="string"?De(e,t.parseYaml):e;if(!j(n))throw new Error("Not an OpenAPI document");if(typeof n.swagger=="string")n=an(n);else if(typeof n.openapi!="string")throw new Error('Not an OpenAPI document: no "openapi" or "swagger" version');const s=n,r=t.baseUrlVariable??"baseUrl",o=new Map,i=h=>{var A;if(h.startsWith("#"))return nt(s,h);const g=h.split("#")[0];if(!o.has(g)){const E=(A=t.resolveRef)==null?void 0:A.call(t,g);o.set(g,typeof E=="string"?De(E,t.parseYaml):E)}return nt(o.get(g),h)},a=h=>{let g=h;for(let A=0;A<20&&j(g)&&typeof g.$ref=="string";A++)g=i(g.$ref);return g},c=(h,g=0)=>{if(!j(h))return;if(typeof h.$ref=="string")return/^#\/components\/schemas\//.test(h.$ref)?{$ref:h.$ref}:g>12?{}:c(i(h.$ref),g+1);const A={...h};if(j(h.properties)){A.properties={};for(const[E,C]of Object.entries(h.properties))A.properties[E]=c(C,g+1)??{}}h.items!==void 0&&(A.items=c(h.items,g+1)),j(h.additionalProperties)&&(A.additionalProperties=c(h.additionalProperties,g+1));for(const E of["allOf","oneOf","anyOf"]){const C=h[E];Array.isArray(C)&&(A[E]=C.map(q=>c(q,g+1)??{}))}return A},p=j(s.components)?s.components:{},u={};if(j(p.schemas))for(const[h,g]of Object.entries(p.schemas))u[h]=c(g)??{};const d=Fe(u),f=h=>{if(!j(h))return;const g=Object.values(h)[0],A=a(g);return j(A)?A.value:void 0},l=new Map,m=(h,g=!1)=>(l.has(h)||l.set(h,{key:h,value:"",secret:g||void 0}),`{{${h}}}`),k=j(p.securitySchemes)?p.securitySchemes:{},y=(h,g)=>{const A=a(k[h]);if(!j(A))return;const E=h.replace(/[^\w.-]/g,"_");switch(A.type){case"apiKey":{const C=A.in==="query"||A.in==="cookie"?A.in:"header";return{type:"apiKey",key:z(A.name)??"X-API-Key",value:m(E,!0),in:C}}case"http":{const C=(z(A.scheme)??"").toLowerCase();return C==="basic"?{type:"basic",username:m("username"),password:m("password",!0)}:C==="digest"?{type:"digest",username:m("username"),password:m("password",!0)}:C==="bearer"?{type:"bearer",token:m(E,!0)}:{type:"custom",headers:[{key:"Authorization",value:`${z(A.scheme)??""} ${m(E,!0)}`}]}}case"oauth2":{const C=j(A.flows)?A.flows:{},P=["authorizationCode","clientCredentials","password","implicit"].find(ie=>j(C[ie]))??"clientCredentials",H=C[P]??{},B=Array.isArray(g)&&g.length?g.join(" "):void 0;return{type:"oauth2",grant:P,tokenUrl:z(H.tokenUrl),authUrl:z(H.authorizationUrl),clientId:m("clientId"),clientSecret:P==="implicit"?void 0:m("clientSecret",!0),scope:B,usePkce:P==="authorizationCode"||void 0,username:P==="password"?m("username"):void 0,password:P==="password"?m("password",!0):void 0}}case"openIdConnect":return{type:"oauth2",grant:"authorizationCode",authUrl:z(A.openIdConnectUrl),clientId:m("clientId"),usePkce:!0,scope:Array.isArray(g)&&g.length?g.join(" "):"openid"};case"mutualTLS":return{type:"mtls"};default:return}},v=h=>{if(Array.isArray(h)){if(!h.length)return{type:"none"};for(const g of h){if(!j(g))continue;const A=Object.keys(g);if(!A.length)return{type:"none"};const E=y(A[0],g[A[0]]);if(E)return E}}},$=h=>{var B,ie;const g=a(h);if(!j(g)||typeof g.name!="string")return null;const A=bs.find(oe=>oe===g.in);if(!A||A==="header"&&/^(accept|content-type|authorization)$/i.test(g.name))return null;const E=c(g.schema)??(j(g.content)?c((B=Ge(g.content))==null?void 0:B[1].schema):void 0),C=E!=null&&E.$ref?d(E.$ref):E,q=g.example??f(g.examples)??(C==null?void 0:C.example)??(C==null?void 0:C.default)??((ie=C==null?void 0:C.enum)==null?void 0:ie[0]),P=A==="path"||g.required===!0,H={key:g.name,value:fe(q),in:A};return P&&(H.required=!0),!P&&q===void 0&&(H.enabled=!1),typeof g.description=="string"&&(H.description=g.description),E&&(H.schema=E),typeof g.style=="string"&&(H.style=g.style),typeof g.explode=="boolean"&&(H.explode=g.explode),H},T=(h,g)=>{const A=c(g.schema),E=g.example??f(g.examples),C=E!==void 0?E:bt(A,{resolveRef:d,usage:"request"}),q=P=>{const H=P!=null&&P.$ref?d(P.$ref):P;return(H==null?void 0:H.properties)??{}};if(h==="application/x-www-form-urlencoded"){const P=j(C)?C:{};return{kind:"form",fields:(Object.keys(P).length?Object.keys(P):Object.keys(q(A))).map(B=>({key:B,value:fe(P[B])}))}}if(h.startsWith("multipart/")){const P=j(C)?C:{};return{kind:"multipart",parts:Object.entries(q(A)).map(([H,B])=>{var oe;return B.format==="binary"||B.format==="base64"||B.contentMediaType!==void 0||B.type==="array"&&((oe=B.items)==null?void 0:oe.format)==="binary"?{key:H,value:"",type:"file"}:{key:H,value:fe(P[H]),type:"text"}})}}return/json/.test(h)?{kind:"json",text:typeof C=="string"?C:JSON.stringify(C??{},null,2)}:h==="application/graphql"?{kind:"graphql",query:fe(C)}:/xml/.test(h)?{kind:"xml",text:typeof C=="string"?C:""}:h.startsWith("text/")?{kind:"text",text:fe(C),contentType:h==="text/plain"?void 0:h}:{kind:"binary",contentType:h}},b=h=>{const g=a(h);if(!j(g))return{};const A={};typeof g.description=="string"&&(A.description=g.description);const E=j(g.content)?Ge(g.content):void 0;if(E){const[C,q]=E;A.contentType=C;const P=c(q.schema);P&&(A.schema=P);const H=q.example??f(q.examples);H!==void 0&&(A.example=typeof H=="string"?H:JSON.stringify(H,null,2))}return j(g.headers)&&(A.headers=Object.entries(g.headers).map(([C,q])=>{const P=a(q);return{key:C,value:"",description:j(P)?z(P.description):void 0}})),A},S=v(s.security),w=[],N=j(s.paths)?s.paths:{};for(const[h,g]of Object.entries(N)){const A=a(g);if(!j(A))continue;const E=Array.isArray(A.parameters)?A.parameters:[];for(const C of rn){const q=A[C];if(!j(q))continue;const P=[];for(const Y of[...E,...Array.isArray(q.parameters)?q.parameters:[]]){const pe=$(Y);if(!pe)continue;const St=P.findIndex(Ot=>Ot.key===pe.key&&Ot.in===pe.in);St>=0?P[St]=pe:P.push(pe)}let H={kind:"none"};const B=a(q.requestBody);if(j(B)&&j(B.content)){const Y=Ge(B.content);Y&&(H=T(Y[0],Y[1]),((x=we(H))==null?void 0:x.split(";")[0])!==Y[0]&&H.kind!=="multipart"&&P.push({key:"Content-Type",value:Y[0],in:"header"}))}const ie={};if(j(q.responses))for(const[Y,pe]of Object.entries(q.responses))ie[Y]=b(pe);const oe=(U=Object.entries(ie).find(([Y])=>/^2/.test(Y)))==null?void 0:U[1];oe!=null&&oe.contentType&&oe.contentType!=="*/*"&&P.push({key:"Accept",value:oe.contentType,in:"header"});let qe=v(q.security);qe&&S&&JSON.stringify(qe)===JSON.stringify(S)&&(qe=void 0);const ue=Array.isArray(q.tags)?q.tags.filter(Y=>typeof Y=="string"):void 0,qn=ye({name:z(q.summary)??z(q.operationId)??`${C.toUpperCase()} ${h}`,method:C.toUpperCase(),url:`{{${r}}}${h}`,params:P,body:H,auth:qe,description:z(q.description),operationId:z(q.operationId),tags:ue!=null&&ue.length?ue:void 0,deprecated:q.deprecated===!0||void 0,responses:Object.keys(ie).length?ie:void 0});w.push({request:qn,tag:ue==null?void 0:ue[0],segment:h.split("/").filter(Boolean)[0]})}}const L=[],R=t.groupBy??"tag";if(R==="none")L.push(...w.map(h=>h.request));else{const h=new Map,g=Array.isArray(s.tags)?s.tags.filter(j):[];if(R==="tag")for(const A of g)typeof A.name=="string"&&h.set(A.name,be({name:A.name,description:z(A.description)}));for(const{request:A,tag:E,segment:C}of w){const q=R==="tag"?E:C;if(!q){L.push(A);continue}h.has(q)||h.set(q,be({name:q})),h.get(q).items.push(A)}L.unshift(...[...h.values()].filter(A=>A.items.length))}const M=(Array.isArray(s.servers)?s.servers.filter(j):[]).map(h=>{let g=z(h.url)??"";if(j(h.variables))for(const[A,E]of Object.entries(h.variables))j(E)&&(g=g.split(`{${A}}`).join(fe(E.default)));return{url:g,description:z(h.description)}}),O=j(s.info)?s.info:{};return ge({name:z(O.title)??"API",description:z(O.description),version:O.version===void 0?void 0:fe(O.version),items:L,variables:[{key:r,value:((D=M[0])==null?void 0:D.url)??""},...l.values()],auth:S,servers:M.length?M:void 0,schemas:Object.keys(u).length?u:void 0})}function an(e){const t=y=>{if(Array.isArray(y))return y.map(t);if(!j(y))return y;const v={};for(const[$,T]of Object.entries(y))v[$]=$==="$ref"&&typeof T=="string"?T.replace("#/definitions/","#/components/schemas/").replace("#/responses/","#/components/responses/"):t(T);return v},n=t(e),s=Array.isArray(n.consumes)?n.consumes:["application/json"],r=Array.isArray(n.produces)?n.produces:["application/json"],o=j(n.parameters)?n.parameters:{},i=y=>{if(j(y)){if(typeof y.$ref=="string"&&y.$ref.startsWith("#/parameters/")){const v=o[y.$ref.slice(13)];return j(v)?v:void 0}return y}},a=y=>{const v={};for(const $ of["type","format","items","enum","default","minimum","maximum","pattern","minLength","maxLength"])y[$]!==void 0&&(v[$]=y[$]);return v.type==="file"&&(v.type="string",v.format="binary"),v},c=(y,v)=>{if(!j(y)||typeof y.$ref=="string")return y;const $={description:y.description??""};if(y.schema!==void 0){const T=j(y.examples)?y.examples:{};$.content=Object.fromEntries(v.map(b=>[b,T[b]!==void 0?{schema:y.schema,example:T[b]}:{schema:y.schema}]))}return j(y.headers)&&($.headers=Object.fromEntries(Object.entries(y.headers).map(([T,b])=>[T,j(b)?{description:b.description,schema:a(b)}:b]))),$},p=(y,v)=>{const $=Array.isArray(y.consumes)?y.consumes:s,T={...y};delete T.consumes,delete T.produces,delete T.schemes;const b=[],S=[];for(const w of[...v,...Array.isArray(y.parameters)?y.parameters:[]]){const N=i(w);if(N)if(N.in==="body")T.requestBody={description:N.description,required:N.required,content:Object.fromEntries($.map(L=>[L,{schema:N.schema}]))};else if(N.in==="formData")S.push(N);else{const L={name:N.name,in:N.in,description:N.description,required:N.required,schema:a(N)};N["x-example"]!==void 0&&(L.example=N["x-example"]),b.push(L)}}if(S.length){const N=$.includes("multipart/form-data")||S.some(R=>R.type==="file")?"multipart/form-data":"application/x-www-form-urlencoded",L=S.filter(R=>R.required).map(R=>String(R.name));T.requestBody={content:{[N]:{schema:{type:"object",properties:Object.fromEntries(S.map(R=>[String(R.name),{...a(R),description:R.description}])),...L.length?{required:L}:{}}}}}}if(T.parameters=b,j(y.responses)){const w=Array.isArray(y.produces)?y.produces:r;T.responses=Object.fromEntries(Object.entries(y.responses).map(([N,L])=>[N,c(L,w)]))}return T},u={};if(j(n.paths))for(const[y,v]of Object.entries(n.paths)){if(!j(v))continue;const $=Array.isArray(v.parameters)?v.parameters:[],T={};for(const[b,S]of Object.entries(v))rn.includes(b)&&j(S)?T[b]=p(S,$):b!=="parameters"&&(T[b]=S);u[y]=T}const d={};if(j(n.securityDefinitions)){const y={implicit:"implicit",password:"password",application:"clientCredentials",accessCode:"authorizationCode"};for(const[v,$]of Object.entries(n.securityDefinitions))j($)&&($.type==="basic"?d[v]={type:"http",scheme:"basic",description:$.description}:$.type==="apiKey"?d[v]={type:"apiKey",name:$.name,in:$.in,description:$.description}:$.type==="oauth2"&&(d[v]={type:"oauth2",description:$.description,flows:{[y[String($.flow)]??"clientCredentials"]:{authorizationUrl:$.authorizationUrl,tokenUrl:$.tokenUrl,scopes:$.scopes??{}}}}))}const f={};if(j(n.responses))for(const[y,v]of Object.entries(n.responses))f[y]=c(v,r);const l=z(n.host),m=z(n.basePath)??"",k=Array.isArray(n.schemes)&&typeof n.schemes[0]=="string"?n.schemes[0]:"https";return{openapi:"3.0.3",info:n.info,servers:l?[{url:`${k}://${l}${m}`}]:m?[{url:m}]:void 0,tags:n.tags,security:n.security,paths:u,components:{schemas:n.definitions,responses:f,securitySchemes:d}}}function ks(e){const t=new Map,n=(s,r)=>{if(!s||s.type==="none"||s.type==="inherit")return;const o=cn(s);if(!o)return;const i=t.get(o.name)??{name:o.name,scheme:o.scheme,scopes:o.scopes,collectionDefault:!1,requestIds:[]};r?i.requestIds.push(r):i.collectionDefault=!0,t.set(o.name,i)};n(e.auth);for(const{request:s,folders:r}of le(e.items)){let o=s.auth;for(let i=r.length-1;(!o||o.type==="inherit")&&i>=0;i--)o=r[i].auth;n(!o||o.type==="inherit"?e.auth:o,s.id)}return[...t.values()]}function cn(e){switch(e.type){case"bearer":return{name:"bearerAuth",scheme:{type:"http",scheme:"bearer"},scopes:[]};case"basic":return{name:"basicAuth",scheme:{type:"http",scheme:"basic"},scopes:[]};case"digest":return{name:"digestAuth",scheme:{type:"http",scheme:"digest"},scopes:[]};case"apiKey":return{name:`${e.key.replace(/[^\w.-]/g,"_")}Auth`,scheme:{type:"apiKey",in:e.in,name:e.key},scopes:[]};case"oauth2":{const t=(e.scope??"").split(/\s+/).filter(Boolean),n=e.grant==="deviceCode"?"clientCredentials":e.grant,s={scopes:Object.fromEntries(t.map(r=>[r,""]))};return e.tokenUrl&&(s.tokenUrl=e.tokenUrl),e.authUrl&&(s.authorizationUrl=e.authUrl),{name:"oauth2",scheme:{type:"oauth2",flows:{[n]:s}},scopes:t}}case"mtls":return{name:"mutualTLS",scheme:{type:"mutualTLS"},scopes:[]};case"awsSigV4":return{name:"awsSigV4",scheme:{type:"apiKey",in:"header",name:"Authorization","x-amazon-apigateway-authtype":"awsSigv4"},scopes:[]};case"hmac":return{name:"hmacAuth",scheme:{type:"apiKey",in:"header",name:e.header},scopes:[]};case"custom":{const t=e.headers.find(I);return t?{name:`${t.key.replace(/[^\w.-]/g,"_")}Auth`,scheme:{type:"apiKey",in:"header",name:t.key},scopes:[]}:void 0}default:return}}function Me(e){if(e!==void 0)try{return JSON.parse(e)}catch{return e}}function $s(e,t){let n=e.split("?")[0].split("#")[0];for(const s of t)if(s&&n.startsWith(s)){n=n.slice(s.length);break}return n=n.replace(/^[a-z][\w+.-]*:\/\/[^/]*/i,"").replace(/^\{\{[^}]+\}\}/,""),n=n.replace(/(^|\/):([A-Za-z_][\w-]*)/g,"$1{$2}"),n.startsWith("/")?n:`/${n}`}function ws(e,t){const n=t==null?void 0:t.split(";")[0].trim();switch(e.kind){case"none":return;case"json":{const s=Me(e.text);return{content:{[n??"application/json"]:{schema:He(s),example:s}}}}case"xml":return{content:{[n??"application/xml"]:{schema:{type:"string"},example:e.text}}};case"text":return{content:{[n??e.contentType??"text/plain"]:{schema:{type:"string"},example:e.text}}};case"form":return{content:{"application/x-www-form-urlencoded":{schema:{type:"object",properties:Object.fromEntries(e.fields.filter(I).map(s=>[s.key,{type:"string",example:s.value||void 0}]))}}}};case"multipart":return{content:{"multipart/form-data":{schema:{type:"object",properties:Object.fromEntries(e.parts.filter(I).map(s=>[s.key,s.type==="file"?{type:"string",format:"binary"}:{type:"string",example:s.value||void 0}]))}}}};case"binary":return{content:{[n??e.contentType??"application/octet-stream"]:{schema:{type:"string",format:"binary"}}}};case"graphql":return{content:{"application/json":{schema:{type:"object",properties:{query:{type:"string"},variables:{type:"object"},operationName:{type:"string"}},required:["query"]},example:Me(re(e))}}};case"soap":return{content:{[n??"text/xml"]:{schema:{type:"string"},example:e.envelope}}};default:return}}function pn(e,t={}){var l,m,k,y,v,$,T;const n=t.baseUrlVariable??"baseUrl",s=(l=e.variables.find(b=>b.key===n))==null?void 0:l.value,r=(m=e.servers)!=null&&m.length?e.servers:s?[{url:s}]:void 0,o=[`{{${n}}}`,...(r??[]).map(b=>b.url)],i={},a=b=>{if(!b||b.type==="inherit")return;if(b.type==="none")return e.auth&&e.auth.type!=="none"?[]:void 0;const S=cn(b);if(S)return i[S.name]=S.scheme,[{[S.name]:S.scopes}]},c=a(e.auth),p={},u=new Map;for(const{request:b,folders:S}of le(e.items)){const w=$s(b.url,o),N=b.method.toLowerCase();if(p[w]??(p[w]={}),p[w][N])continue;for(const h of S)u.set(h.name,h.description);const L=(k=b.tags)!=null&&k.length?b.tags:S.length?[S[S.length-1].name]:void 0,R=b.params.filter(h=>!(h.in==="header"&&/^(accept|content-type|authorization)$/i.test(h.key))).map(h=>{const g={name:h.key,in:h.in};return h.description&&(g.description=h.description),(h.in==="path"||h.required)&&(g.required=!0),g.schema=h.schema??{type:"string"},h.value&&(g.example=h.value),h.style&&(g.style=h.style),h.explode!==void 0&&(g.explode=h.explode),g}),M=(y=b.params.find(h=>h.in==="header"&&/^content-type$/i.test(h.key)))==null?void 0:y.value,O={summary:b.name};b.operationId&&(O.operationId=b.operationId),b.description&&(O.description=b.description),L&&(O.tags=L),b.deprecated&&(O.deprecated=!0),R.length&&(O.parameters=R);const x=ws(b.body,M);x&&(O.requestBody=x);const U={};for(const[h,g]of Object.entries(b.responses??{})){const A={description:g.description??""};if(g.contentType){const E={};g.schema&&(E.schema=g.schema),g.example!==void 0&&(E.example=/json/.test(g.contentType)?Me(g.example):g.example),A.content={[g.contentType]:E}}U[h]=A}for(const h of b.examples??[]){const g=String(h.status);if(U[g])continue;const A=((T=($=(v=h.headers)==null?void 0:v.find(E=>/^content-type$/i.test(E.key)))==null?void 0:$.value)==null?void 0:T.split(";")[0])??"application/json";U[g]={description:h.name,content:{[A]:{example:/json/.test(A)?Me(h.body):h.body}}}}O.responses=Object.keys(U).length?U:{200:{description:"OK"}};const D=a(b.auth);D&&(O.security=D),p[w][N]=O}const d={openapi:"3.1.0",info:{title:e.name,version:e.version??"1.0.0",...e.description?{description:e.description}:{}}};r&&(d.servers=r.map(b=>b.description?b:{url:b.url})),u.size&&(d.tags=[...u].map(([b,S])=>S?{name:b,description:S}:{name:b})),c&&(d.security=c),d.paths=p;const f={};return e.schemas&&Object.keys(e.schemas).length&&(f.schemas=e.schemas),Object.keys(i).length&&(f.securitySchemes=i),Object.keys(f).length&&(d.components=f),d}function vs(e,t={}){return sn(pn(e,t))}const W=e=>!!e&&typeof e=="object"&&!Array.isArray(e),_=e=>typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):void 0,Ae=e=>Array.isArray(e)?e.filter(W):[],ln="https://schema.getpostman.com/json/collection/v2.1.0/collection.json";function kt(e){return W(e)&&W(e.info)&&Array.isArray(e.item)}function ke(e){if(typeof e=="string")return e||void 0;if(W(e))return _(e.content)}function Ce(e){return Ae(e).map(t=>{const n={key:_(t.key)??"",value:_(t.value)??""};t.disabled===!0&&(n.enabled=!1);const s=ke(t.description);return s&&(n.description=s),n})}function $t(e){if(!W(e)||typeof e.type!="string")return;const t=e[e.type],n=s=>{var r;if(Array.isArray(t))return _((r=t.filter(W).find(o=>o.key===s))==null?void 0:r.value);if(W(t))return _(t[s])};switch(e.type){case"noauth":return{type:"none"};case"bearer":return{type:"bearer",token:n("token")??""};case"basic":return{type:"basic",username:n("username")??"",password:n("password")??""};case"digest":return{type:"digest",username:n("username")??"",password:n("password")??"",realm:n("realm"),nonce:n("nonce"),qop:n("qop"),algorithm:n("algorithm"),opaque:n("opaque")};case"apikey":{const s=n("in");return{type:"apiKey",key:n("key")??"X-API-Key",value:n("value")??"",in:s==="query"?"query":"header"}}case"oauth2":{const s=n("grant_type")??"authorization_code";return{type:"oauth2",grant:s==="client_credentials"?"clientCredentials":s==="password_credentials"||s==="password"?"password":s==="implicit"?"implicit":"authorizationCode",tokenUrl:n("accessTokenUrl"),authUrl:n("authUrl"),clientId:n("clientId")??"",clientSecret:n("clientSecret"),scope:n("scope"),username:n("username"),password:n("password"),redirectUri:n("redirect_uri"),usePkce:s==="authorization_code_with_pkce"||void 0,clientAuth:n("client_authentication")==="body"?"body":void 0,accessToken:n("accessToken"),tokenType:n("tokenType")}}case"awsv4":return{type:"awsSigV4",accessKeyId:n("accessKey")??"",secretAccessKey:n("secretKey")??"",region:n("region")??"",service:n("service")??"",sessionToken:n("sessionToken")};default:return}}function As(e){if(typeof e=="string"){const{base:o,query:i,hash:a}=ce(e);return{url:o+a,params:i.map(c=>({...c,in:"query"}))}}if(!W(e))return{url:"",params:[]};const t=_(e.raw);let n;if(t!==void 0)n=ce(t).base;else{const o=_(e.protocol),i=Array.isArray(e.host)?e.host.join("."):_(e.host)??"",a=_(e.port),c=Array.isArray(e.path)?e.path.map(p=>(W(p)?_(p.value):_(p))??"").join("/"):_(e.path)??"";n=`${o?`${o}://`:""}${i}${a?`:${a}`:""}${c?`/${c.replace(/^\//,"")}`:""}`}const s=Array.isArray(e.query)?Ce(e.query).map(o=>({...o,in:"query"})):t!==void 0?ce(t).query.map(o=>({...o,in:"query"})):[],r=Ce(e.variable).map(o=>({...o,in:"path",required:!0}));return{url:n,params:[...r,...s]}}function xs(e){if(!W(e))return{kind:"none"};switch(e.mode){case"raw":{const t=_(e.raw)??"",n=W(e.options)&&W(e.options.raw)?_(e.options.raw.language):void 0;return n==="json"?{kind:"json",text:t}:n==="xml"?/<(\w+:)?Envelope[\s>]/.test(t)?{kind:"soap",envelope:t,version:"1.1"}:{kind:"xml",text:t}:n==="html"?{kind:"text",text:t,contentType:"text/html"}:n==="javascript"?{kind:"text",text:t,contentType:"application/javascript"}:!n&&/^\s*[[{]/.test(t)?{kind:"json",text:t}:{kind:"text",text:t}}case"urlencoded":return{kind:"form",fields:Ce(e.urlencoded)};case"formdata":return{kind:"multipart",parts:Ae(e.formdata).map(t=>{const n=t.type==="file",s=Array.isArray(t.src)?_(t.src[0]):_(t.src),r={key:_(t.key)??"",value:n?"":_(t.value)??"",type:n?"file":"text",...n&&s?{fileName:s}:{},..._(t.contentType)?{contentType:_(t.contentType)}:{}};return t.disabled===!0?{...r,enabled:!1}:r})};case"file":return{kind:"binary",fileName:W(e.file)?_(e.file.src):void 0};case"graphql":{const t=W(e.graphql)?e.graphql:{};return{kind:"graphql",query:_(t.query)??"",variables:_(t.variables)}}default:return{kind:"none"}}}function un(e){const t={};for(const n of Ae(e)){const s=W(n.script)?n.script:{},r=Array.isArray(s.exec)?s.exec.map(o=>_(o)??"").join(`
54
+ `}function De(e,t=en){const n=e.trimStart();if(n.startsWith("{")||n.startsWith("["))try{return JSON.parse(n)}catch{}return t(e)}function Fe(e){return t=>{var s;const n=(s=/^#\/(?:components\/schemas|definitions)\/(.+)$/.exec(t))==null?void 0:s[1];return n?e==null?void 0:e[decodeURIComponent(n.replace(/~1/g,"/").replace(/~0/g,"~"))]:void 0}}function hs(e){if(Array.isArray(e.type))return e.type.find(t=>t!=="null")??e.type[0];if(e.type)return e.type;if(e.properties||e.additionalProperties)return"object";if(e.items)return"array"}function ys(e,t){switch(e.format){case"email":return"user@example.com";case"date":return t().toISOString().slice(0,10);case"date-time":return t().toISOString();case"time":return t().toISOString().slice(11,19);case"uuid":return"3fa85f64-5717-4562-b3fc-2c963f66afa6";case"uri":case"url":return"https://example.com";case"hostname":return"example.com";case"ipv4":return"192.168.0.1";case"ipv6":return"::1";case"byte":return"U3dhZ2dlciByb2Nrcw==";case"binary":return"";case"password":return"********";default:{const n=e.title??"string";return e.minLength&&n.length<e.minLength?n.padEnd(e.minLength,"x"):e.maxLength&&n.length>e.maxLength?n.slice(0,e.maxLength):n}}}function bt(e,t={}){const n=t.maxDepth??6,s=t.arrayItems??1,r=t.now??(()=>new Date),o=(i,a,c)=>{var u,d,f,l,m,k;if(!i)return null;if(i.$ref){if(c.has(i.$ref)||a>n)return null;const y=(u=t.resolveRef)==null?void 0:u.call(t,i.$ref);return y?o(y,a,new Set([...c,i.$ref])):null}if(i.example!==void 0)return i.example;if((d=i.examples)!=null&&d.length)return i.examples[0];if(i.const!==void 0)return i.const;if(i.default!==void 0)return i.default;if((f=i.enum)!=null&&f.length)return i.enum[0];if((l=i.allOf)!=null&&l.length){const y={};let v;for(const $ of i.allOf){const T=o($,a,c);T&&typeof T=="object"&&!Array.isArray(T)?Object.assign(y,T):T!=null&&(v=T)}return i.properties&&Object.assign(y,o({...i,allOf:void 0},a,c)),Object.keys(y).length?y:v??null}const p=((m=i.oneOf)==null?void 0:m[0])??((k=i.anyOf)==null?void 0:k[0]);if(p)return o(p,a,c);switch(hs(i)){case"string":return ys(i,r);case"integer":return i.minimum??0;case"number":return i.minimum??0;case"boolean":return!0;case"array":return a>=n?[]:Array.from({length:s},()=>o(i.items,a+1,c));case"object":{if(a>=n)return{};const y={};for(const[v,$]of Object.entries(i.properties??{}))t.usage==="request"&&$.readOnly||t.usage==="response"&&$.writeOnly||(y[v]=o($,a+1,c));return!i.properties&&i.additionalProperties&&typeof i.additionalProperties=="object"&&(y.key=o(i.additionalProperties,a+1,c)),y}case"null":return null;default:return null}};return o(e,0,new Set)}function He(e){if(e===null)return{type:"null"};if(Array.isArray(e))return e.length?{type:"array",items:He(e[0])}:{type:"array"};switch(typeof e){case"string":return/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(e)?{type:"string",format:"date-time"}:/^\d{4}-\d{2}-\d{2}$/.test(e)?{type:"string",format:"date"}:/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)?{type:"string",format:"uuid"}:/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(e)?{type:"string",format:"email"}:{type:"string"};case"number":return{type:Number.isInteger(e)?"integer":"number"};case"boolean":return{type:"boolean"};case"object":{const t={};for(const[n,s]of Object.entries(e))t[n]=He(s);return{type:"object",properties:t}}default:return{}}}function gs(e,t){var p;const n=(p=e.examples)==null?void 0:p[0];if(n){const u={};for(const d of n.headers??[])u[d.key]=d.value;return{status:n.status,headers:u,body:n.body??""}}const s=Object.entries(e.responses??{}),[r,o]=s.find(([u])=>/^2\d\d$/.test(u))??s.find(([u])=>u==="default")??["200",void 0],i=/^\d{3}$/.test(r)?Number(r):200;if(!o)return{status:i,headers:{},body:""};const a=o.contentType??"application/json";let c=o.example??"";if(!c&&o.schema){const u=bt(o.schema,{resolveRef:Fe(t==null?void 0:t.schemas),usage:"response"});c=typeof u=="string"?u:JSON.stringify(u,null,2)}return{status:i,headers:{"Content-Type":a},body:c}}const j=e=>!!e&&typeof e=="object"&&!Array.isArray(e),z=e=>typeof e=="string"?e:void 0,rn=["get","put","post","delete","options","head","patch","trace"],bs=["query","path","header","cookie"];function nt(e,t){const n=t.indexOf("#"),s=n>=0?t.slice(n+1):"";if(!s||s==="/")return e;let r=e;for(const o of s.split("/").slice(1)){const i=decodeURIComponent(o).replace(/~1/g,"/").replace(/~0/g,"~");if(j(r))r=r[i];else if(Array.isArray(r))r=r[Number(i)];else return}return r}function fe(e){return e==null?"":typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):JSON.stringify(e)}function Ge(e){const t=Object.keys(e),n=[s=>s==="application/json",s=>/\+json$|\/json/.test(s),s=>s==="application/x-www-form-urlencoded",s=>s==="multipart/form-data",s=>/xml/.test(s),s=>s.startsWith("text/"),()=>!0];for(const s of n){const r=t.find(s);if(r)return[r,j(e[r])?e[r]:{}]}}function on(e,t={}){var x,U,D;let n=typeof e=="string"?De(e,t.parseYaml):e;if(!j(n))throw new Error("Not an OpenAPI document");if(typeof n.swagger=="string")n=an(n);else if(typeof n.openapi!="string")throw new Error('Not an OpenAPI document: no "openapi" or "swagger" version');const s=n,r=t.baseUrlVariable??"baseUrl",o=new Map,i=h=>{var A;if(h.startsWith("#"))return nt(s,h);const g=h.split("#")[0];if(!o.has(g)){const E=(A=t.resolveRef)==null?void 0:A.call(t,g);o.set(g,typeof E=="string"?De(E,t.parseYaml):E)}return nt(o.get(g),h)},a=h=>{let g=h;for(let A=0;A<20&&j(g)&&typeof g.$ref=="string";A++)g=i(g.$ref);return g},c=(h,g=0)=>{if(!j(h))return;if(typeof h.$ref=="string")return/^#\/components\/schemas\//.test(h.$ref)?{$ref:h.$ref}:g>12?{}:c(i(h.$ref),g+1);const A={...h};if(j(h.properties)){A.properties={};for(const[E,C]of Object.entries(h.properties))A.properties[E]=c(C,g+1)??{}}h.items!==void 0&&(A.items=c(h.items,g+1)),j(h.additionalProperties)&&(A.additionalProperties=c(h.additionalProperties,g+1));for(const E of["allOf","oneOf","anyOf"]){const C=h[E];Array.isArray(C)&&(A[E]=C.map(q=>c(q,g+1)??{}))}return A},p=j(s.components)?s.components:{},u={};if(j(p.schemas))for(const[h,g]of Object.entries(p.schemas))u[h]=c(g)??{};const d=Fe(u),f=h=>{if(!j(h))return;const g=Object.values(h)[0],A=a(g);return j(A)?A.value:void 0},l=new Map,m=(h,g=!1)=>(l.has(h)||l.set(h,{key:h,value:"",secret:g||void 0}),`{{${h}}}`),k=j(p.securitySchemes)?p.securitySchemes:{},y=(h,g)=>{const A=a(k[h]);if(!j(A))return;const E=h.replace(/[^\w.-]/g,"_");switch(A.type){case"apiKey":{const C=A.in==="query"||A.in==="cookie"?A.in:"header";return{type:"apiKey",key:z(A.name)??"X-API-Key",value:m(E,!0),in:C}}case"http":{const C=(z(A.scheme)??"").toLowerCase();return C==="basic"?{type:"basic",username:m("username"),password:m("password",!0)}:C==="digest"?{type:"digest",username:m("username"),password:m("password",!0)}:C==="bearer"?{type:"bearer",token:m(E,!0)}:{type:"custom",headers:[{key:"Authorization",value:`${z(A.scheme)??""} ${m(E,!0)}`}]}}case"oauth2":{const C=j(A.flows)?A.flows:{},P=["authorizationCode","clientCredentials","password","implicit"].find(ie=>j(C[ie]))??"clientCredentials",H=C[P]??{},B=Array.isArray(g)&&g.length?g.join(" "):void 0;return{type:"oauth2",grant:P,tokenUrl:z(H.tokenUrl),authUrl:z(H.authorizationUrl),clientId:m("clientId"),clientSecret:P==="implicit"?void 0:m("clientSecret",!0),scope:B,usePkce:P==="authorizationCode"||void 0,username:P==="password"?m("username"):void 0,password:P==="password"?m("password",!0):void 0}}case"openIdConnect":return{type:"oauth2",grant:"authorizationCode",authUrl:z(A.openIdConnectUrl),clientId:m("clientId"),usePkce:!0,scope:Array.isArray(g)&&g.length?g.join(" "):"openid"};case"mutualTLS":return{type:"mtls"};default:return}},v=h=>{if(Array.isArray(h)){if(!h.length)return{type:"none"};for(const g of h){if(!j(g))continue;const A=Object.keys(g);if(!A.length)return{type:"none"};const E=y(A[0],g[A[0]]);if(E)return E}}},$=h=>{var B,ie;const g=a(h);if(!j(g)||typeof g.name!="string")return null;const A=bs.find(oe=>oe===g.in);if(!A||A==="header"&&/^(accept|content-type|authorization)$/i.test(g.name))return null;const E=c(g.schema)??(j(g.content)?c((B=Ge(g.content))==null?void 0:B[1].schema):void 0),C=E!=null&&E.$ref?d(E.$ref):E,q=g.example??f(g.examples)??(C==null?void 0:C.example)??(C==null?void 0:C.default)??((ie=C==null?void 0:C.enum)==null?void 0:ie[0]),P=A==="path"||g.required===!0,H={key:g.name,value:fe(q),in:A};return P&&(H.required=!0),!P&&q===void 0&&(H.enabled=!1),typeof g.description=="string"&&(H.description=g.description),E&&(H.schema=E),typeof g.style=="string"&&(H.style=g.style),typeof g.explode=="boolean"&&(H.explode=g.explode),H},T=(h,g)=>{const A=c(g.schema),E=g.example??f(g.examples),C=E!==void 0?E:bt(A,{resolveRef:d,usage:"request"}),q=P=>{const H=P!=null&&P.$ref?d(P.$ref):P;return(H==null?void 0:H.properties)??{}};if(h==="application/x-www-form-urlencoded"){const P=j(C)?C:{};return{kind:"form",fields:(Object.keys(P).length?Object.keys(P):Object.keys(q(A))).map(B=>({key:B,value:fe(P[B])}))}}if(h.startsWith("multipart/")){const P=j(C)?C:{};return{kind:"multipart",parts:Object.entries(q(A)).map(([H,B])=>{var oe;return B.format==="binary"||B.format==="base64"||B.contentMediaType!==void 0||B.type==="array"&&((oe=B.items)==null?void 0:oe.format)==="binary"?{key:H,value:"",type:"file"}:{key:H,value:fe(P[H]),type:"text"}})}}return/json/.test(h)?{kind:"json",text:typeof C=="string"?C:JSON.stringify(C??{},null,2)}:h==="application/graphql"?{kind:"graphql",query:fe(C)}:/xml/.test(h)?{kind:"xml",text:typeof C=="string"?C:""}:h.startsWith("text/")?{kind:"text",text:fe(C),contentType:h==="text/plain"?void 0:h}:{kind:"binary",contentType:h}},b=h=>{const g=a(h);if(!j(g))return{};const A={};typeof g.description=="string"&&(A.description=g.description);const E=j(g.content)?Ge(g.content):void 0;if(E){const[C,q]=E;A.contentType=C;const P=c(q.schema);P&&(A.schema=P);const H=q.example??f(q.examples);H!==void 0&&(A.example=typeof H=="string"?H:JSON.stringify(H,null,2))}return j(g.headers)&&(A.headers=Object.entries(g.headers).map(([C,q])=>{const P=a(q);return{key:C,value:"",description:j(P)?z(P.description):void 0}})),A},S=v(s.security),w=[],N=j(s.paths)?s.paths:{};for(const[h,g]of Object.entries(N)){const A=a(g);if(!j(A))continue;const E=Array.isArray(A.parameters)?A.parameters:[];for(const C of rn){const q=A[C];if(!j(q))continue;const P=[];for(const Y of[...E,...Array.isArray(q.parameters)?q.parameters:[]]){const le=$(Y);if(!le)continue;const St=P.findIndex(Ot=>Ot.key===le.key&&Ot.in===le.in);St>=0?P[St]=le:P.push(le)}let H={kind:"none"};const B=a(q.requestBody);if(j(B)&&j(B.content)){const Y=Ge(B.content);Y&&(H=T(Y[0],Y[1]),((x=we(H))==null?void 0:x.split(";")[0])!==Y[0]&&H.kind!=="multipart"&&P.push({key:"Content-Type",value:Y[0],in:"header"}))}const ie={};if(j(q.responses))for(const[Y,le]of Object.entries(q.responses))ie[Y]=b(le);const oe=(U=Object.entries(ie).find(([Y])=>/^2/.test(Y)))==null?void 0:U[1];oe!=null&&oe.contentType&&oe.contentType!=="*/*"&&P.push({key:"Accept",value:oe.contentType,in:"header"});let qe=v(q.security);qe&&S&&JSON.stringify(qe)===JSON.stringify(S)&&(qe=void 0);const ue=Array.isArray(q.tags)?q.tags.filter(Y=>typeof Y=="string"):void 0,qn=ye({name:z(q.summary)??z(q.operationId)??`${C.toUpperCase()} ${h}`,method:C.toUpperCase(),url:`{{${r}}}${h}`,params:P,body:H,auth:qe,description:z(q.description),operationId:z(q.operationId),tags:ue!=null&&ue.length?ue:void 0,deprecated:q.deprecated===!0||void 0,responses:Object.keys(ie).length?ie:void 0});w.push({request:qn,tag:ue==null?void 0:ue[0],segment:h.split("/").filter(Boolean)[0]})}}const L=[],R=t.groupBy??"tag";if(R==="none")L.push(...w.map(h=>h.request));else{const h=new Map,g=Array.isArray(s.tags)?s.tags.filter(j):[];if(R==="tag")for(const A of g)typeof A.name=="string"&&h.set(A.name,be({name:A.name,description:z(A.description)}));for(const{request:A,tag:E,segment:C}of w){const q=R==="tag"?E:C;if(!q){L.push(A);continue}h.has(q)||h.set(q,be({name:q})),h.get(q).items.push(A)}L.unshift(...[...h.values()].filter(A=>A.items.length))}const M=(Array.isArray(s.servers)?s.servers.filter(j):[]).map(h=>{let g=z(h.url)??"";if(j(h.variables))for(const[A,E]of Object.entries(h.variables))j(E)&&(g=g.split(`{${A}}`).join(fe(E.default)));return{url:g,description:z(h.description)}}),O=j(s.info)?s.info:{};return ge({name:z(O.title)??"API",description:z(O.description),version:O.version===void 0?void 0:fe(O.version),items:L,variables:[{key:r,value:((D=M[0])==null?void 0:D.url)??""},...l.values()],auth:S,servers:M.length?M:void 0,schemas:Object.keys(u).length?u:void 0})}function an(e){const t=y=>{if(Array.isArray(y))return y.map(t);if(!j(y))return y;const v={};for(const[$,T]of Object.entries(y))v[$]=$==="$ref"&&typeof T=="string"?T.replace("#/definitions/","#/components/schemas/").replace("#/responses/","#/components/responses/"):t(T);return v},n=t(e),s=Array.isArray(n.consumes)?n.consumes:["application/json"],r=Array.isArray(n.produces)?n.produces:["application/json"],o=j(n.parameters)?n.parameters:{},i=y=>{if(j(y)){if(typeof y.$ref=="string"&&y.$ref.startsWith("#/parameters/")){const v=o[y.$ref.slice(13)];return j(v)?v:void 0}return y}},a=y=>{const v={};for(const $ of["type","format","items","enum","default","minimum","maximum","pattern","minLength","maxLength"])y[$]!==void 0&&(v[$]=y[$]);return v.type==="file"&&(v.type="string",v.format="binary"),v},c=(y,v)=>{if(!j(y)||typeof y.$ref=="string")return y;const $={description:y.description??""};if(y.schema!==void 0){const T=j(y.examples)?y.examples:{};$.content=Object.fromEntries(v.map(b=>[b,T[b]!==void 0?{schema:y.schema,example:T[b]}:{schema:y.schema}]))}return j(y.headers)&&($.headers=Object.fromEntries(Object.entries(y.headers).map(([T,b])=>[T,j(b)?{description:b.description,schema:a(b)}:b]))),$},p=(y,v)=>{const $=Array.isArray(y.consumes)?y.consumes:s,T={...y};delete T.consumes,delete T.produces,delete T.schemes;const b=[],S=[];for(const w of[...v,...Array.isArray(y.parameters)?y.parameters:[]]){const N=i(w);if(N)if(N.in==="body")T.requestBody={description:N.description,required:N.required,content:Object.fromEntries($.map(L=>[L,{schema:N.schema}]))};else if(N.in==="formData")S.push(N);else{const L={name:N.name,in:N.in,description:N.description,required:N.required,schema:a(N)};N["x-example"]!==void 0&&(L.example=N["x-example"]),b.push(L)}}if(S.length){const N=$.includes("multipart/form-data")||S.some(R=>R.type==="file")?"multipart/form-data":"application/x-www-form-urlencoded",L=S.filter(R=>R.required).map(R=>String(R.name));T.requestBody={content:{[N]:{schema:{type:"object",properties:Object.fromEntries(S.map(R=>[String(R.name),{...a(R),description:R.description}])),...L.length?{required:L}:{}}}}}}if(T.parameters=b,j(y.responses)){const w=Array.isArray(y.produces)?y.produces:r;T.responses=Object.fromEntries(Object.entries(y.responses).map(([N,L])=>[N,c(L,w)]))}return T},u={};if(j(n.paths))for(const[y,v]of Object.entries(n.paths)){if(!j(v))continue;const $=Array.isArray(v.parameters)?v.parameters:[],T={};for(const[b,S]of Object.entries(v))rn.includes(b)&&j(S)?T[b]=p(S,$):b!=="parameters"&&(T[b]=S);u[y]=T}const d={};if(j(n.securityDefinitions)){const y={implicit:"implicit",password:"password",application:"clientCredentials",accessCode:"authorizationCode"};for(const[v,$]of Object.entries(n.securityDefinitions))j($)&&($.type==="basic"?d[v]={type:"http",scheme:"basic",description:$.description}:$.type==="apiKey"?d[v]={type:"apiKey",name:$.name,in:$.in,description:$.description}:$.type==="oauth2"&&(d[v]={type:"oauth2",description:$.description,flows:{[y[String($.flow)]??"clientCredentials"]:{authorizationUrl:$.authorizationUrl,tokenUrl:$.tokenUrl,scopes:$.scopes??{}}}}))}const f={};if(j(n.responses))for(const[y,v]of Object.entries(n.responses))f[y]=c(v,r);const l=z(n.host),m=z(n.basePath)??"",k=Array.isArray(n.schemes)&&typeof n.schemes[0]=="string"?n.schemes[0]:"https";return{openapi:"3.0.3",info:n.info,servers:l?[{url:`${k}://${l}${m}`}]:m?[{url:m}]:void 0,tags:n.tags,security:n.security,paths:u,components:{schemas:n.definitions,responses:f,securitySchemes:d}}}function ks(e){const t=new Map,n=(s,r)=>{if(!s||s.type==="none"||s.type==="inherit")return;const o=cn(s);if(!o)return;const i=t.get(o.name)??{name:o.name,scheme:o.scheme,scopes:o.scopes,collectionDefault:!1,requestIds:[]};r?i.requestIds.push(r):i.collectionDefault=!0,t.set(o.name,i)};n(e.auth);for(const{request:s,folders:r}of pe(e.items)){let o=s.auth;for(let i=r.length-1;(!o||o.type==="inherit")&&i>=0;i--)o=r[i].auth;n(!o||o.type==="inherit"?e.auth:o,s.id)}return[...t.values()]}function cn(e){switch(e.type){case"bearer":return{name:"bearerAuth",scheme:{type:"http",scheme:"bearer"},scopes:[]};case"basic":return{name:"basicAuth",scheme:{type:"http",scheme:"basic"},scopes:[]};case"digest":return{name:"digestAuth",scheme:{type:"http",scheme:"digest"},scopes:[]};case"apiKey":return{name:`${e.key.replace(/[^\w.-]/g,"_")}Auth`,scheme:{type:"apiKey",in:e.in,name:e.key},scopes:[]};case"oauth2":{const t=(e.scope??"").split(/\s+/).filter(Boolean),n=e.grant==="deviceCode"?"clientCredentials":e.grant,s={scopes:Object.fromEntries(t.map(r=>[r,""]))};return e.tokenUrl&&(s.tokenUrl=e.tokenUrl),e.authUrl&&(s.authorizationUrl=e.authUrl),{name:"oauth2",scheme:{type:"oauth2",flows:{[n]:s}},scopes:t}}case"mtls":return{name:"mutualTLS",scheme:{type:"mutualTLS"},scopes:[]};case"awsSigV4":return{name:"awsSigV4",scheme:{type:"apiKey",in:"header",name:"Authorization","x-amazon-apigateway-authtype":"awsSigv4"},scopes:[]};case"hmac":return{name:"hmacAuth",scheme:{type:"apiKey",in:"header",name:e.header},scopes:[]};case"custom":{const t=e.headers.find(I);return t?{name:`${t.key.replace(/[^\w.-]/g,"_")}Auth`,scheme:{type:"apiKey",in:"header",name:t.key},scopes:[]}:void 0}default:return}}function Me(e){if(e!==void 0)try{return JSON.parse(e)}catch{return e}}function $s(e,t){let n=e.split("?")[0].split("#")[0];for(const s of t)if(s&&n.startsWith(s)){n=n.slice(s.length);break}return n=n.replace(/^[a-z][\w+.-]*:\/\/[^/]*/i,"").replace(/^\{\{[^}]+\}\}/,""),n=n.replace(/(^|\/):([A-Za-z_][\w-]*)/g,"$1{$2}"),n.startsWith("/")?n:`/${n}`}function ws(e,t){const n=t==null?void 0:t.split(";")[0].trim();switch(e.kind){case"none":return;case"json":{const s=Me(e.text);return{content:{[n??"application/json"]:{schema:He(s),example:s}}}}case"xml":return{content:{[n??"application/xml"]:{schema:{type:"string"},example:e.text}}};case"text":return{content:{[n??e.contentType??"text/plain"]:{schema:{type:"string"},example:e.text}}};case"form":return{content:{"application/x-www-form-urlencoded":{schema:{type:"object",properties:Object.fromEntries(e.fields.filter(I).map(s=>[s.key,{type:"string",example:s.value||void 0}]))}}}};case"multipart":return{content:{"multipart/form-data":{schema:{type:"object",properties:Object.fromEntries(e.parts.filter(I).map(s=>[s.key,s.type==="file"?{type:"string",format:"binary"}:{type:"string",example:s.value||void 0}]))}}}};case"binary":return{content:{[n??e.contentType??"application/octet-stream"]:{schema:{type:"string",format:"binary"}}}};case"graphql":return{content:{"application/json":{schema:{type:"object",properties:{query:{type:"string"},variables:{type:"object"},operationName:{type:"string"}},required:["query"]},example:Me(re(e))}}};case"soap":return{content:{[n??"text/xml"]:{schema:{type:"string"},example:e.envelope}}};default:return}}function pn(e,t={}){var l,m,k,y,v,$,T;const n=t.baseUrlVariable??"baseUrl",s=(l=e.variables.find(b=>b.key===n))==null?void 0:l.value,r=(m=e.servers)!=null&&m.length?e.servers:s?[{url:s}]:void 0,o=[`{{${n}}}`,...(r??[]).map(b=>b.url)],i={},a=b=>{if(!b||b.type==="inherit")return;if(b.type==="none")return e.auth&&e.auth.type!=="none"?[]:void 0;const S=cn(b);if(S)return i[S.name]=S.scheme,[{[S.name]:S.scopes}]},c=a(e.auth),p={},u=new Map;for(const{request:b,folders:S}of pe(e.items)){const w=$s(b.url,o),N=b.method.toLowerCase();if(p[w]??(p[w]={}),p[w][N])continue;for(const h of S)u.set(h.name,h.description);const L=(k=b.tags)!=null&&k.length?b.tags:S.length?[S[S.length-1].name]:void 0,R=b.params.filter(h=>!(h.in==="header"&&/^(accept|content-type|authorization)$/i.test(h.key))).map(h=>{const g={name:h.key,in:h.in};return h.description&&(g.description=h.description),(h.in==="path"||h.required)&&(g.required=!0),g.schema=h.schema??{type:"string"},h.value&&(g.example=h.value),h.style&&(g.style=h.style),h.explode!==void 0&&(g.explode=h.explode),g}),M=(y=b.params.find(h=>h.in==="header"&&/^content-type$/i.test(h.key)))==null?void 0:y.value,O={summary:b.name};b.operationId&&(O.operationId=b.operationId),b.description&&(O.description=b.description),L&&(O.tags=L),b.deprecated&&(O.deprecated=!0),R.length&&(O.parameters=R);const x=ws(b.body,M);x&&(O.requestBody=x);const U={};for(const[h,g]of Object.entries(b.responses??{})){const A={description:g.description??""};if(g.contentType){const E={};g.schema&&(E.schema=g.schema),g.example!==void 0&&(E.example=/json/.test(g.contentType)?Me(g.example):g.example),A.content={[g.contentType]:E}}U[h]=A}for(const h of b.examples??[]){const g=String(h.status);if(U[g])continue;const A=((T=($=(v=h.headers)==null?void 0:v.find(E=>/^content-type$/i.test(E.key)))==null?void 0:$.value)==null?void 0:T.split(";")[0])??"application/json";U[g]={description:h.name,content:{[A]:{example:/json/.test(A)?Me(h.body):h.body}}}}O.responses=Object.keys(U).length?U:{200:{description:"OK"}};const D=a(b.auth);D&&(O.security=D),p[w][N]=O}const d={openapi:"3.1.0",info:{title:e.name,version:e.version??"1.0.0",...e.description?{description:e.description}:{}}};r&&(d.servers=r.map(b=>b.description?b:{url:b.url})),u.size&&(d.tags=[...u].map(([b,S])=>S?{name:b,description:S}:{name:b})),c&&(d.security=c),d.paths=p;const f={};return e.schemas&&Object.keys(e.schemas).length&&(f.schemas=e.schemas),Object.keys(i).length&&(f.securitySchemes=i),Object.keys(f).length&&(d.components=f),d}function vs(e,t={}){return sn(pn(e,t))}const W=e=>!!e&&typeof e=="object"&&!Array.isArray(e),_=e=>typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):void 0,Ae=e=>Array.isArray(e)?e.filter(W):[],ln="https://schema.getpostman.com/json/collection/v2.1.0/collection.json";function kt(e){return W(e)&&W(e.info)&&Array.isArray(e.item)}function ke(e){if(typeof e=="string")return e||void 0;if(W(e))return _(e.content)}function Ce(e){return Ae(e).map(t=>{const n={key:_(t.key)??"",value:_(t.value)??""};t.disabled===!0&&(n.enabled=!1);const s=ke(t.description);return s&&(n.description=s),n})}function $t(e){if(!W(e)||typeof e.type!="string")return;const t=e[e.type],n=s=>{var r;if(Array.isArray(t))return _((r=t.filter(W).find(o=>o.key===s))==null?void 0:r.value);if(W(t))return _(t[s])};switch(e.type){case"noauth":return{type:"none"};case"bearer":return{type:"bearer",token:n("token")??""};case"basic":return{type:"basic",username:n("username")??"",password:n("password")??""};case"digest":return{type:"digest",username:n("username")??"",password:n("password")??"",realm:n("realm"),nonce:n("nonce"),qop:n("qop"),algorithm:n("algorithm"),opaque:n("opaque")};case"apikey":{const s=n("in");return{type:"apiKey",key:n("key")??"X-API-Key",value:n("value")??"",in:s==="query"?"query":"header"}}case"oauth2":{const s=n("grant_type")??"authorization_code";return{type:"oauth2",grant:s==="client_credentials"?"clientCredentials":s==="password_credentials"||s==="password"?"password":s==="implicit"?"implicit":"authorizationCode",tokenUrl:n("accessTokenUrl"),authUrl:n("authUrl"),clientId:n("clientId")??"",clientSecret:n("clientSecret"),scope:n("scope"),username:n("username"),password:n("password"),redirectUri:n("redirect_uri"),usePkce:s==="authorization_code_with_pkce"||void 0,clientAuth:n("client_authentication")==="body"?"body":void 0,accessToken:n("accessToken"),tokenType:n("tokenType")}}case"awsv4":return{type:"awsSigV4",accessKeyId:n("accessKey")??"",secretAccessKey:n("secretKey")??"",region:n("region")??"",service:n("service")??"",sessionToken:n("sessionToken")};default:return}}function As(e){if(typeof e=="string"){const{base:o,query:i,hash:a}=ce(e);return{url:o+a,params:i.map(c=>({...c,in:"query"}))}}if(!W(e))return{url:"",params:[]};const t=_(e.raw);let n;if(t!==void 0)n=ce(t).base;else{const o=_(e.protocol),i=Array.isArray(e.host)?e.host.join("."):_(e.host)??"",a=_(e.port),c=Array.isArray(e.path)?e.path.map(p=>(W(p)?_(p.value):_(p))??"").join("/"):_(e.path)??"";n=`${o?`${o}://`:""}${i}${a?`:${a}`:""}${c?`/${c.replace(/^\//,"")}`:""}`}const s=Array.isArray(e.query)?Ce(e.query).map(o=>({...o,in:"query"})):t!==void 0?ce(t).query.map(o=>({...o,in:"query"})):[],r=Ce(e.variable).map(o=>({...o,in:"path",required:!0}));return{url:n,params:[...r,...s]}}function xs(e){if(!W(e))return{kind:"none"};switch(e.mode){case"raw":{const t=_(e.raw)??"",n=W(e.options)&&W(e.options.raw)?_(e.options.raw.language):void 0;return n==="json"?{kind:"json",text:t}:n==="xml"?/<(\w+:)?Envelope[\s>]/.test(t)?{kind:"soap",envelope:t,version:"1.1"}:{kind:"xml",text:t}:n==="html"?{kind:"text",text:t,contentType:"text/html"}:n==="javascript"?{kind:"text",text:t,contentType:"application/javascript"}:!n&&/^\s*[[{]/.test(t)?{kind:"json",text:t}:{kind:"text",text:t}}case"urlencoded":return{kind:"form",fields:Ce(e.urlencoded)};case"formdata":return{kind:"multipart",parts:Ae(e.formdata).map(t=>{const n=t.type==="file",s=Array.isArray(t.src)?_(t.src[0]):_(t.src),r={key:_(t.key)??"",value:n?"":_(t.value)??"",type:n?"file":"text",...n&&s?{fileName:s}:{},..._(t.contentType)?{contentType:_(t.contentType)}:{}};return t.disabled===!0?{...r,enabled:!1}:r})};case"file":return{kind:"binary",fileName:W(e.file)?_(e.file.src):void 0};case"graphql":{const t=W(e.graphql)?e.graphql:{};return{kind:"graphql",query:_(t.query)??"",variables:_(t.variables)}}default:return{kind:"none"}}}function un(e){const t={};for(const n of Ae(e)){const s=W(n.script)?n.script:{},r=Array.isArray(s.exec)?s.exec.map(o=>_(o)??"").join(`
55
55
  `):_(s.exec)??"";r.trim()&&(n.listen==="prerequest"&&(t.preRequest=r),n.listen==="test"&&(t.test=r))}return t.preRequest||t.test?t:void 0}function Ts(e){const t=W(e.request)?e.request:typeof e.request=="string"?{url:e.request}:{},{url:n,params:s}=As(t.url),r=Ce(t.header).map(i=>({...i,in:"header"})),o=Ae(e.response).map(i=>({name:_(i.name)??"Example",status:Number(i.code??200)||200,headers:Ce(i.header),body:_(i.body)}));return ye({id:_(e.id)??void 0,name:_(e.name)??"Request",method:(_(t.method)??"GET").toUpperCase(),url:n,params:[...s,...r],body:xs(t.body),auth:$t(t.auth),description:ke(t.description)??ke(e.description),scripts:un(e.event),examples:o.length?o:void 0})}function fn(e){return Ae(e).map(t=>Array.isArray(t.item)?be({id:_(t.id)??void 0,name:_(t.name)??"Folder",description:ke(t.description),items:fn(t.item),auth:$t(t.auth)}):Ts(t))}function dn(e){return Ae(e).map(t=>{const n={key:_(t.key)??"",value:_(t.value)??""};t.type==="secret"&&(n.secret=!0),(t.disabled===!0||t.enabled===!1)&&(n.enabled=!1);const s=ke(t.description);return s&&(n.description=s),n})}function mn(e){const t=typeof e=="string"?JSON.parse(e):e;if(!kt(t))throw new Error("Not a Postman collection");const n=t,s=n.info,r=un(n.event),o=ge({id:_(s._postman_id)??void 0,name:_(s.name)??"Postman collection",description:ke(s.description),version:W(s.version)?_(s.version.raw):_(s.version),items:fn(n.item),variables:dn(n.variable),auth:$t(n.auth)});if(r){const i=a=>a.map(c=>c.kind==="folder"?{...c,items:i(c.items)}:c.scripts?c:{...c,scripts:r});o.items=i(o.items)}return o}function hn(e){const t=typeof e=="string"?JSON.parse(e):e;if(!W(t)||!Array.isArray(t.values))throw new Error("Not a Postman environment");return{id:_(t.id)??$e("e"),name:_(t.name)??"Environment",values:dn(t.values)}}const V=(e,t)=>({key:e,value:t??"",type:"string"});function st(e){switch(e==null?void 0:e.type){case void 0:case"inherit":return;case"none":return{type:"noauth"};case"bearer":return{type:"bearer",bearer:[V("token",e.token)]};case"basic":return{type:"basic",basic:[V("username",e.username),V("password",e.password)]};case"digest":return{type:"digest",digest:[V("username",e.username),V("password",e.password),...["realm","nonce","qop","algorithm","opaque"].filter(t=>e[t]).map(t=>V(t,e[t]))]};case"apiKey":return{type:"apikey",apikey:[V("key",e.key),V("value",e.value),V("in",e.in==="query"?"query":"header")]};case"oauth2":return{type:"oauth2",oauth2:[["grant_type",e.grant==="clientCredentials"?"client_credentials":e.grant==="password"?"password_credentials":e.grant==="implicit"?"implicit":e.usePkce?"authorization_code_with_pkce":"authorization_code"],["accessTokenUrl",e.tokenUrl],["authUrl",e.authUrl],["clientId",e.clientId],["clientSecret",e.clientSecret],["scope",e.scope],["username",e.username],["password",e.password],["redirect_uri",e.redirectUri],["client_authentication",e.clientAuth],["accessToken",e.accessToken],["tokenType",e.tokenType]].filter(([,s])=>s!==void 0).map(([s,r])=>V(s,r))};case"awsSigV4":return{type:"awsv4",awsv4:[V("accessKey",e.accessKeyId),V("secretKey",e.secretAccessKey),V("region",e.region),V("service",e.service),...e.sessionToken?[V("sessionToken",e.sessionToken)]:[]]};default:return}}const Ee=e=>{const t={key:e.key,value:e.value};return I(e)||(t.disabled=!0),e.description&&(t.description=e.description),t};function Ss(e){const t=e.params.filter(d=>d.in==="query"),n=ve({...e,params:e.params.filter(d=>d.in==="query"&&I(d))}).replace(/%7B%7B(.*?)%7D%7D/g,"{{$1}}").replace(new RegExp("(?<!\\{)\\{([A-Za-z_][\\w.-]*)\\}(?!\\})","g"),":$1"),s=ce(e.url).base,r=/^([a-z][\w+.-]*):\/\//i.exec(s),o=r?s.slice(r[0].length):s,i=o.indexOf("/"),a=i<0?o:o.slice(0,i),c=i<0?[]:o.slice(i+1).split("/"),p={raw:n,host:a?a.startsWith("{{")?[a]:a.split("."):[],path:c.map(d=>d.replace(/^\{([A-Za-z_][\w.-]*)\}$/,":$1"))};r&&(p.protocol=r[1]),t.length&&(p.query=t.map(Ee));const u=e.params.filter(d=>d.in==="path");return u.length&&(p.variable=u.map(Ee)),p}function Os(e){switch(e.kind){case"none":return;case"json":return{mode:"raw",raw:e.text,options:{raw:{language:"json"}}};case"xml":return{mode:"raw",raw:e.text,options:{raw:{language:"xml"}}};case"soap":return{mode:"raw",raw:e.envelope,options:{raw:{language:"xml"}}};case"text":return{mode:"raw",raw:e.text,options:{raw:{language:e.contentType==="text/html"?"html":"text"}}};case"form":return{mode:"urlencoded",urlencoded:e.fields.map(Ee)};case"multipart":return{mode:"formdata",formdata:e.parts.map(t=>{const n=t.type==="file"?{key:t.key,type:"file",src:t.fileName??""}:{key:t.key,value:t.value,type:"text"};return t.contentType&&(n.contentType=t.contentType),I(t)||(n.disabled=!0),n})};case"binary":return{mode:"file",file:{src:e.fileName??""}};case"graphql":return{mode:"graphql",graphql:{query:e.query,variables:e.variables??""}};default:return}}function Ns(e){const t=[];return e!=null&&e.preRequest&&t.push({listen:"prerequest",script:{type:"text/javascript",exec:e.preRequest.split(`
56
56
  `)}}),e!=null&&e.test&&t.push({listen:"test",script:{type:"text/javascript",exec:e.test.split(`
57
- `)}}),t.length?t:void 0}function yn(e){if(e.kind==="folder"){const a={name:e.name,item:e.items.map(yn)};e.description&&(a.description=e.description);const c=st(e.auth);return c&&(a.auth=c),a}const t={method:e.method,header:e.params.filter(a=>a.in==="header").map(Ee),url:Ss(e)},n=Os(e.body);n&&(t.body=n);const s=st(e.auth);s&&(t.auth=s),e.description&&(t.description=e.description);const r=e.params.filter(a=>a.in==="cookie"&&I(a));r.length&&t.header.push({key:"Cookie",value:r.map(a=>`${a.key}=${a.value}`).join("; ")});const o={name:e.name,request:t},i=Ns(e.scripts);return i&&(o.event=i),o.response=(e.examples??[]).map(a=>({name:a.name,code:a.status,header:(a.headers??[]).map(Ee),body:a.body??""})),o}function js(e){const t={info:{_postman_id:e.id,name:e.name,...e.description?{description:e.description}:{},schema:ln},item:e.items.map(yn)};e.variables.length&&(t.variable=e.variables.map(s=>{const r={key:s.key,value:s.value,type:s.secret?"secret":"string"};return s.enabled===!1&&(r.disabled=!0),r}));const n=st(e.auth);return n&&(t.auth=n),t}function Cs(e){return{id:e.id,name:e.name,values:e.values.map(t=>({key:t.key,value:t.value,type:t.secret?"secret":"default",enabled:t.enabled!==!1})),_postman_variable_scope:"environment"}}const me=e=>!!e&&typeof e=="object"&&!Array.isArray(e),K=e=>typeof e=="string"?e:void 0,rt=e=>Array.isArray(e)?e.filter(me):[],Es=/^(image|font|audio|video)\/|^text\/css|javascript|^application\/(x-)?font|wasm/;function Te(e){return rt(e).map(t=>({key:K(t.name)??"",value:K(t.value)??""}))}function wt(e){return me(e)&&me(e.log)&&Array.isArray(e.log.entries)}function gn(e,t={}){const n=typeof e=="string"?JSON.parse(e):e;if(!wt(n))throw new Error("Not a HAR log");const s=rt(n.log.entries),r=t.skipStatic??!0,o=[];for(const i of s){if(t.filter&&!t.filter(i))continue;const a=me(i.request)?i.request:{},c=me(i.response)?i.response:{},p=me(c.content)?c.content:{},u=(K(p.mimeType)??"").toLowerCase();if(r&&Es.test(u))continue;const{base:d,query:f}=ce(K(a.url)??""),l=Array.isArray(a.queryString)?Te(a.queryString):f,m=Te(a.cookies),k=Te(a.headers).filter(w=>!w.key.startsWith(":")&&!/^(content-length|host|connection)$/i.test(w.key)&&!(m.length&&/^cookie$/i.test(w.key))),y=[...l.map(w=>({...w,in:"query"})),...k.map(w=>({...w,in:"header"})),...m.map(w=>({...w,in:"cookie"}))];let v={kind:"none"};const $=me(a.postData)?a.postData:void 0;if($){const w=K($.mimeType)??"",N=rt($.params);N.length&&w.includes("multipart")?v={kind:"multipart",parts:N.map(L=>L.fileName!==void 0?{key:K(L.name)??"",value:"",type:"file",fileName:K(L.fileName),contentType:K(L.contentType)}:{key:K(L.name)??"",value:K(L.value)??"",type:"text"})}:N.length?v={kind:"form",fields:Te(N)}:K($.text)!==void 0&&(v=ft(K($.text)??"",w||void 0))}const T=(K(a.method)??"GET").toUpperCase(),b=[],S=Number(c.status);if(Number.isFinite(S)&&S>0){let w=K(p.text);w!==void 0&&p.encoding==="base64"&&/json|xml|text|javascript/.test(u)&&(w=yt(w)),b.push({name:`${S} ${K(c.statusText)??""}`.trim(),status:S,headers:Te(c.headers).filter(N=>!N.key.startsWith(":")),body:w})}o.push(ye({name:gt(T,d),method:T,url:d,params:y,body:v,examples:b.length?b:void 0}))}return ge({name:t.name??"HAR import",items:o})}const Qe=e=>({name:e.key,value:e.value});function _s(e,t={}){const n=Array.isArray(e)?e:le(e.items).map(i=>i.request),s=t.transform??(i=>i),r=(t.now??(()=>new Date))().toISOString(),o=n.map(i=>{var k,y,v,$,T;const a=ve(i,s),c=i.params.filter(b=>b.in==="header"&&I(b)).map(b=>({key:s(b.key),value:s(b.value)})),p=i.params.filter(b=>b.in==="cookie"&&I(b)).map(b=>({key:s(b.key),value:s(b.value)})),u=((k=c.find(b=>/^content-type$/i.test(b.key)))==null?void 0:k.value)??we(i.body),d={method:i.method.toUpperCase(),url:a,httpVersion:"HTTP/1.1",headers:c.map(Qe),queryString:i.params.filter(b=>b.in==="query"&&I(b)).map(b=>({name:s(b.key),value:s(b.value)})),cookies:p.map(Qe),headersSize:-1,bodySize:-1},f=i.body;f.kind==="form"?d.postData={mimeType:u,params:f.fields.filter(I).map(b=>({name:s(b.key),value:s(b.value)})),text:s(re(f)??"")}:f.kind==="multipart"?d.postData={mimeType:u,params:f.parts.filter(I).map(b=>b.type==="file"?{name:s(b.key),fileName:b.fileName??"",contentType:b.contentType}:{name:s(b.key),value:s(b.value)})}:f.kind!=="none"&&f.kind!=="binary"&&(d.postData={mimeType:u,text:s(re(f)??"")});const l=(y=i.examples)==null?void 0:y[0],m=(($=(v=l==null?void 0:l.headers)==null?void 0:v.find(b=>/^content-type$/i.test(b.key)))==null?void 0:$.value)??"";return{startedDateTime:r,time:0,request:d,response:{status:(l==null?void 0:l.status)??0,statusText:l?l.name.replace(new RegExp(`^${l.status}\\s*`),""):"",httpVersion:"HTTP/1.1",headers:((l==null?void 0:l.headers)??[]).map(Qe),cookies:[],content:{size:((T=l==null?void 0:l.body)==null?void 0:T.length)??0,mimeType:m,...(l==null?void 0:l.body)!==void 0?{text:l.body}:{}},redirectURL:"",headersSize:-1,bodySize:-1},cache:{},timings:{send:0,wait:0,receive:0}}});return{log:{version:"1.2",creator:{name:t.creator??"Nice2Dev",version:"1"},entries:o}}}const Us=`query IntrospectionQuery {
57
+ `)}}),t.length?t:void 0}function yn(e){if(e.kind==="folder"){const a={name:e.name,item:e.items.map(yn)};e.description&&(a.description=e.description);const c=st(e.auth);return c&&(a.auth=c),a}const t={method:e.method,header:e.params.filter(a=>a.in==="header").map(Ee),url:Ss(e)},n=Os(e.body);n&&(t.body=n);const s=st(e.auth);s&&(t.auth=s),e.description&&(t.description=e.description);const r=e.params.filter(a=>a.in==="cookie"&&I(a));r.length&&t.header.push({key:"Cookie",value:r.map(a=>`${a.key}=${a.value}`).join("; ")});const o={name:e.name,request:t},i=Ns(e.scripts);return i&&(o.event=i),o.response=(e.examples??[]).map(a=>({name:a.name,code:a.status,header:(a.headers??[]).map(Ee),body:a.body??""})),o}function js(e){const t={info:{_postman_id:e.id,name:e.name,...e.description?{description:e.description}:{},schema:ln},item:e.items.map(yn)};e.variables.length&&(t.variable=e.variables.map(s=>{const r={key:s.key,value:s.value,type:s.secret?"secret":"string"};return s.enabled===!1&&(r.disabled=!0),r}));const n=st(e.auth);return n&&(t.auth=n),t}function Cs(e){return{id:e.id,name:e.name,values:e.values.map(t=>({key:t.key,value:t.value,type:t.secret?"secret":"default",enabled:t.enabled!==!1})),_postman_variable_scope:"environment"}}const me=e=>!!e&&typeof e=="object"&&!Array.isArray(e),K=e=>typeof e=="string"?e:void 0,rt=e=>Array.isArray(e)?e.filter(me):[],Es=/^(image|font|audio|video)\/|^text\/css|javascript|^application\/(x-)?font|wasm/;function Te(e){return rt(e).map(t=>({key:K(t.name)??"",value:K(t.value)??""}))}function wt(e){return me(e)&&me(e.log)&&Array.isArray(e.log.entries)}function gn(e,t={}){const n=typeof e=="string"?JSON.parse(e):e;if(!wt(n))throw new Error("Not a HAR log");const s=rt(n.log.entries),r=t.skipStatic??!0,o=[];for(const i of s){if(t.filter&&!t.filter(i))continue;const a=me(i.request)?i.request:{},c=me(i.response)?i.response:{},p=me(c.content)?c.content:{},u=(K(p.mimeType)??"").toLowerCase();if(r&&Es.test(u))continue;const{base:d,query:f}=ce(K(a.url)??""),l=Array.isArray(a.queryString)?Te(a.queryString):f,m=Te(a.cookies),k=Te(a.headers).filter(w=>!w.key.startsWith(":")&&!/^(content-length|host|connection)$/i.test(w.key)&&!(m.length&&/^cookie$/i.test(w.key))),y=[...l.map(w=>({...w,in:"query"})),...k.map(w=>({...w,in:"header"})),...m.map(w=>({...w,in:"cookie"}))];let v={kind:"none"};const $=me(a.postData)?a.postData:void 0;if($){const w=K($.mimeType)??"",N=rt($.params);N.length&&w.includes("multipart")?v={kind:"multipart",parts:N.map(L=>L.fileName!==void 0?{key:K(L.name)??"",value:"",type:"file",fileName:K(L.fileName),contentType:K(L.contentType)}:{key:K(L.name)??"",value:K(L.value)??"",type:"text"})}:N.length?v={kind:"form",fields:Te(N)}:K($.text)!==void 0&&(v=ft(K($.text)??"",w||void 0))}const T=(K(a.method)??"GET").toUpperCase(),b=[],S=Number(c.status);if(Number.isFinite(S)&&S>0){let w=K(p.text);w!==void 0&&p.encoding==="base64"&&/json|xml|text|javascript/.test(u)&&(w=yt(w)),b.push({name:`${S} ${K(c.statusText)??""}`.trim(),status:S,headers:Te(c.headers).filter(N=>!N.key.startsWith(":")),body:w})}o.push(ye({name:gt(T,d),method:T,url:d,params:y,body:v,examples:b.length?b:void 0}))}return ge({name:t.name??"HAR import",items:o})}const Qe=e=>({name:e.key,value:e.value});function _s(e,t={}){const n=Array.isArray(e)?e:pe(e.items).map(i=>i.request),s=t.transform??(i=>i),r=(t.now??(()=>new Date))().toISOString(),o=n.map(i=>{var k,y,v,$,T;const a=ve(i,s),c=i.params.filter(b=>b.in==="header"&&I(b)).map(b=>({key:s(b.key),value:s(b.value)})),p=i.params.filter(b=>b.in==="cookie"&&I(b)).map(b=>({key:s(b.key),value:s(b.value)})),u=((k=c.find(b=>/^content-type$/i.test(b.key)))==null?void 0:k.value)??we(i.body),d={method:i.method.toUpperCase(),url:a,httpVersion:"HTTP/1.1",headers:c.map(Qe),queryString:i.params.filter(b=>b.in==="query"&&I(b)).map(b=>({name:s(b.key),value:s(b.value)})),cookies:p.map(Qe),headersSize:-1,bodySize:-1},f=i.body;f.kind==="form"?d.postData={mimeType:u,params:f.fields.filter(I).map(b=>({name:s(b.key),value:s(b.value)})),text:s(re(f)??"")}:f.kind==="multipart"?d.postData={mimeType:u,params:f.parts.filter(I).map(b=>b.type==="file"?{name:s(b.key),fileName:b.fileName??"",contentType:b.contentType}:{name:s(b.key),value:s(b.value)})}:f.kind!=="none"&&f.kind!=="binary"&&(d.postData={mimeType:u,text:s(re(f)??"")});const l=(y=i.examples)==null?void 0:y[0],m=(($=(v=l==null?void 0:l.headers)==null?void 0:v.find(b=>/^content-type$/i.test(b.key)))==null?void 0:$.value)??"";return{startedDateTime:r,time:0,request:d,response:{status:(l==null?void 0:l.status)??0,statusText:l?l.name.replace(new RegExp(`^${l.status}\\s*`),""):"",httpVersion:"HTTP/1.1",headers:((l==null?void 0:l.headers)??[]).map(Qe),cookies:[],content:{size:((T=l==null?void 0:l.body)==null?void 0:T.length)??0,mimeType:m,...(l==null?void 0:l.body)!==void 0?{text:l.body}:{}},redirectURL:"",headersSize:-1,bodySize:-1},cache:{},timings:{send:0,wait:0,receive:0}}});return{log:{version:"1.2",creator:{name:t.creator??"Nice2Dev",version:"1"},entries:o}}}const Us=`query IntrospectionQuery {
58
58
  __schema {
59
59
  queryType { name }
60
60
  mutationType { name }
@@ -118,4 +118,4 @@ ${n}`}function Zs(e,t,n,s,r,o){var f;const i="#".repeat(o),a=[],c=e.url.replace(
118
118
  `).replace(/\n{3,}/g,`
119
119
 
120
120
  `).trimEnd()}
121
- `}function _n(e,t){try{return De(e,t)}catch{return}}function Un(e,t={}){const n=e.trim();if(!n)return;if(Kt(n))return"curl";if(n.startsWith("<"))return/<(\w+:)?definitions[\s>]/.test(n)&&/schemas\.xmlsoap\.org\/wsdl/.test(n)?"wsdl":void 0;const s=_n(n,t.parseYaml);if(!s||typeof s!="object")return;const r=s;if(typeof r.openapi=="string"||typeof r.swagger=="string")return"openapi";if(kt(r))return"postman";if(Array.isArray(r.values)&&(r._postman_variable_scope!==void 0||typeof r.name=="string"))return"postman-environment";if(wt(r))return"har";const o=r.data;if(r.__schema||o!=null&&o.__schema)return"graphql"}function tr(e,t={}){const n=Un(e,t),s=()=>_n(e.trim(),t.parseYaml);switch(n){case"curl":return{kind:n,request:Gt(e)};case"openapi":return{kind:n,collection:on(s(),t)};case"postman":return{kind:n,collection:mn(s())};case"postman-environment":return{kind:n,environment:hn(s())};case"har":return{kind:n,collection:gn(s())};case"graphql":return{kind:n,collection:vn(s())};case"wsdl":return{kind:n,collection:Sn(e,{parser:t.xmlParser})};default:throw new Error("Unknown API document: expected curl, OpenAPI, Swagger, Postman, HAR, GraphQL introspection or WSDL")}}const nr=["rest","graphql","soap","odata","grpc","websocket","sse","webhook","database","sftp"];function sr(e={}){return{...e,key:e.key??$e("i"),name:e.name??"New integration",direction:e.direction??"outbound",connection:e.connection??{protocol:"rest",baseUrl:""},endpoints:e.endpoints??ge({name:e.name??"API"})}}function Tt(e,t){const n=[],s=new Set;let r=e.sets.find(i=>i.id===t);for(;r&&!s.has(r.id);)s.add(r.id),n.push(r),r=r.extends?e.sets.find(i=>i.id===r.extends):void 0;const o={};for(const i of e.variables)i.defaultValue!==void 0&&(o[i.key]=i.defaultValue);for(const i of n.reverse())Object.assign(o,i.values);for(const i of e.variables)i.secret&&o[i.key]===void 0&&(o[i.key]=`{{secret:${i.key}}}`);return o}function rr(e,t,n){const s=new Set;let r=e.sets.find(a=>a.id===t),o=!0;for(;r&&!s.has(r.id);){if(s.add(r.id),n in r.values)return{value:r.values[n],from:o?"own":"inherited",set:r.id};o=!1,r=r.extends?e.sets.find(a=>a.id===r.extends):void 0}const i=e.variables.find(a=>a.key===n);return(i==null?void 0:i.defaultValue)!==void 0?{value:i.defaultValue,from:"default"}:{from:"none"}}function ir(e){return e.sets.map(t=>({id:t.id,name:t.name,values:Object.entries(Tt(e,t.id)).map(([n,s])=>{var r;return{key:n,value:s,secret:((r=e.variables.find(o=>o.key===n))==null?void 0:r.secret)||void 0}})}))}function or(e,t){return(t?e.sets.find(n=>{var s;return((s=n.appliesTo)==null?void 0:s.database)===t}):void 0)??e.sets.find(n=>{var s;return!((s=n.appliesTo)!=null&&s.database)})}function ut(e,t=[]){if(typeof e=="string")t.push(e);else if(Array.isArray(e))for(const n of e)ut(n,t);else if(e&&typeof e=="object")for(const n of Object.values(e))ut(n,t);return t}function ar(e,t={variables:[],sets:[]},n={}){var a,c;const s=[],r=new Set(t.variables.map(p=>p.key)),o=new Set;for(const p of e.integrations){const u=p.key;o.has(u)&&s.push({severity:"error",integration:u,code:"keyDuplicate",message:`Duplicate key ${u}`}),o.add(u),!p.connection.baseUrl.trim()&&p.connection.protocol!=="webhook"&&s.push({severity:"warning",integration:u,code:"baseUrlMissing",message:`${u}: no base URL`});const d=new Set(ut([p.connection,p.endpoints]).flatMap(mt).filter(m=>!m.startsWith("$")&&!m.startsWith("secret:")));for(const m of d)!r.has(m)&&!p.endpoints.variables.some(k=>k.key===m)&&s.push({severity:"warning",integration:u,code:"variableUndeclared",message:`${u}: {{${m}}} is not declared in the environment variables`});const f=new Set(le(p.endpoints.items).map(({request:m})=>m.id)),l=new Set((p.expose??[]).map(m=>m.key));for(const m of p.operations??[])m.endpoint&&!f.has(m.endpoint)&&!l.has(m.endpoint)&&s.push({severity:"error",integration:u,code:"endpointMissing",message:`${u}/${m.key}: endpoint ${m.endpoint} does not exist`});for(const m of((a=p.requires)==null?void 0:a.modules)??[])n.modules&&!n.modules.includes(m)&&s.push({severity:"warning",integration:u,code:"requiresMissing",message:`${u}: module ${m} is not installed`});for(const m of((c=p.requires)==null?void 0:c.dataSources)??[])n.dataSources&&!n.dataSources.includes(m)&&s.push({severity:"warning",integration:u,code:"requiresMissing",message:`${u}: data source ${m} does not exist`})}const i=new Set(t.sets.map(p=>p.id));for(const p of t.sets){p.extends&&!i.has(p.extends)&&s.push({severity:"error",code:"extendsMissing",message:`${p.id} extends ${p.extends}, which does not exist`});for(const d of t.variables){const f=p.values[d.key];d.secret&&f!==void 0&&f!==""&&!/^\{\{\s*secret:/.test(f)&&s.push({severity:"error",code:"secretInSeed",message:`${p.id}: ${d.key} is a secret — write {{secret:${d.key}}}, not the value`})}const u=Tt(t,p.id);for(const d of t.variables)d.required&&!u[d.key]&&s.push({severity:"warning",code:"requiredUnset",message:`${p.id}: ${d.key} has no value`})}return s}function cr(e,t){var p,u,d;if(!e||!t)return[];const n=(p=le(e.items).find(f=>f.request.id===t))==null?void 0:p.request,s=((u=n==null?void 0:n.responses)==null?void 0:u["200"])??((d=n==null?void 0:n.responses)==null?void 0:d["201"]),r=Fe(e.schemas),o=(f,l=0)=>{if(!f||l>8)return{};if(f.$ref)return o(r(f.$ref),l+1);const m={...f.properties??{}};for(const k of f.allOf??[])Object.assign(m,o(k,l+1));return m},i=f=>f!=null&&f.$ref?r(f.$ref):f,a=[],c=i(s==null?void 0:s.schema);if(!c)return a;if(c.type==="array"||c.items){for(const f of Object.keys(o(c.items)))a.push(`$[*].${f}`);return a}for(const[f,l]of Object.entries(o(c))){const m=i(l);if(m&&(m.type==="array"||m.items)){const k=Object.keys(o(m.items));if(k.length){k.forEach(y=>a.push(`$.${f}[*].${y}`));continue}}a.push(`$.${f}`)}return a}function pr(e){const t=new Map;for(const s of e){const r=s.package??"";t.has(r)||t.set(r,new Map);const o=t.get(r);o.has(s.direction)||o.set(s.direction,[]),o.get(s.direction).push(s)}const n=["inbound","outbound","bidirectional"];return[...t].sort(([s],[r])=>s.localeCompare(r)).map(([s,r])=>({package:s,directions:n.filter(o=>r.has(o)).map(o=>({direction:o,integrations:r.get(o)}))}))}function lr(e){const t=le(e.endpoints.items).map(({request:s})=>({id:s.id,label:`${s.method} ${s.name}`,exposed:!1})),n=(e.expose??[]).map(s=>({id:s.key,label:`${s.method} ${s.path}`,exposed:!0}));return[...t,...n]}exports.GRAPHQL_INTROSPECTION_QUERY=Us;exports.NICE_API_AUTH_TYPES=Rn;exports.NICE_API_CODE_LANGUAGES=Qt;exports.NICE_API_MARKDOWN_LABELS=En;exports.NICE_API_METHODS=Ln;exports.NICE_CONNECTION_PROTOCOLS=nr;exports.NiceYamlError=Q;exports.POSTMAN_SCHEMA_V21=ln;exports.apiSecuritySchemes=ks;exports.assignedVariableSets=Fn;exports.bodyContentType=we;exports.bodyFromText=ft;exports.bodyText=re;exports.buildAuthorizationUrl=Vs;exports.buildGraphqlOperation=wn;exports.buildRequestUrl=ve;exports.buildSoapEnvelope=Tn;exports.collectionToMarkdown=er;exports.createPkcePair=Fs;exports.detectApiDocument=Un;exports.digest=_e;exports.digestAuthorization=Nn;exports.effectiveAuth=zt;exports.environmentSetFor=or;exports.exchangeAuthorizationCode=Js;exports.exportHar=_s;exports.exportOpenApi=pn;exports.exportOpenApiYaml=vs;exports.exportPostman=js;exports.exportPostmanEnvironment=Cs;exports.fetchOAuth2Token=Ks;exports.fetchTransport=Bs;exports.findApiItem=Dt;exports.findVariables=mt;exports.flattenApiRequests=le;exports.fromBase64=yt;exports.generateCode=Zt;exports.graphqlExampleValue=Ne;exports.graphqlOperations=kn;exports.graphqlTypeName=ze;exports.groupIntegrations=pr;exports.headerValue=Mn;exports.hmac=de;exports.importApiDocument=tr;exports.importGraphqlIntrospection=vn;exports.importHar=gn;exports.importOpenApi=on;exports.importPostman=mn;exports.importPostmanEnvironment=hn;exports.importWsdl=Sn;exports.inferSchema=He;exports.integrationEndpoints=lr;exports.interpolate=ht;exports.isCurlCommand=Kt;exports.isEnabled=I;exports.isHar=wt;exports.isPostmanCollection=kt;exports.joinUrl=Jn;exports.jsonPointer=nt;exports.md5Hex=At;exports.mockFromSchema=bt;exports.mockResponse=gs;exports.namedType=vt;exports.newApiCollection=ge;exports.newApiFolder=be;exports.newApiId=$e;exports.newApiRequest=ye;exports.newIntegration=sr;exports.paramsIn=Mt;exports.parseCurl=Gt;exports.parseDigestChallenge=On;exports.parseFormEncoded=dt;exports.parseGraphqlIntrospection=bn;exports.parseJsonOrYaml=De;exports.parseWsdl=An;exports.parseYaml=en;exports.pathParamNames=Bt;exports.pollDeviceToken=Ys;exports.refreshOAuth2Token=Gs;exports.renameApiSchema=Dn;exports.requestName=gt;exports.resolveEnvironmentSet=Tt;exports.resolvePlainScalar=Be;exports.resolveRequest=pt;exports.responseFieldPaths=cr;exports.rowsToRecord=Hn;exports.schemaResolver=Fe;exports.sendApiRequest=zs;exports.setRequestUrl=Vt;exports.signAwsV4=jn;exports.signHmac=Cn;exports.splitUrl=ce;exports.startDeviceAuthorization=Qs;exports.stringifyYaml=sn;exports.swagger2ToOpenApi3=an;exports.syncPathParams=Ft;exports.toApiEnvironments=ir;exports.toBase64=We;exports.toCurl=Pe;exports.tokenizeCommand=Jt;exports.unresolvedVariables=Bn;exports.updateApiItem=Ht;exports.validateIntegrations=ar;exports.valueOrigin=rr;exports.variableScope=Vn;
121
+ `}function _n(e,t){try{return De(e,t)}catch{return}}function Un(e,t={}){const n=e.trim();if(!n)return;if(Kt(n))return"curl";if(n.startsWith("<"))return/<(\w+:)?definitions[\s>]/.test(n)&&/schemas\.xmlsoap\.org\/wsdl/.test(n)?"wsdl":void 0;const s=_n(n,t.parseYaml);if(!s||typeof s!="object")return;const r=s;if(typeof r.openapi=="string"||typeof r.swagger=="string")return"openapi";if(kt(r))return"postman";if(Array.isArray(r.values)&&(r._postman_variable_scope!==void 0||typeof r.name=="string"))return"postman-environment";if(wt(r))return"har";const o=r.data;if(r.__schema||o!=null&&o.__schema)return"graphql"}function tr(e,t={}){const n=Un(e,t),s=()=>_n(e.trim(),t.parseYaml);switch(n){case"curl":return{kind:n,request:Gt(e)};case"openapi":return{kind:n,collection:on(s(),t)};case"postman":return{kind:n,collection:mn(s())};case"postman-environment":return{kind:n,environment:hn(s())};case"har":return{kind:n,collection:gn(s())};case"graphql":return{kind:n,collection:vn(s())};case"wsdl":return{kind:n,collection:Sn(e,{parser:t.xmlParser})};default:throw new Error("Unknown API document: expected curl, OpenAPI, Swagger, Postman, HAR, GraphQL introspection or WSDL")}}const nr=["rest","graphql","soap","odata","grpc","websocket","sse","webhook","database","sftp"];function sr(e={}){return{...e,key:e.key??$e("i"),name:e.name??"New integration",direction:e.direction??"outbound",connection:e.connection??{protocol:"rest",baseUrl:""},endpoints:e.endpoints??ge({name:e.name??"API"})}}function Tt(e,t){const n=[],s=new Set;let r=e.sets.find(i=>i.id===t);for(;r&&!s.has(r.id);)s.add(r.id),n.push(r),r=r.extends?e.sets.find(i=>i.id===r.extends):void 0;const o={};for(const i of e.variables)i.defaultValue!==void 0&&(o[i.key]=i.defaultValue);for(const i of n.reverse())Object.assign(o,i.values);for(const i of e.variables)i.secret&&o[i.key]===void 0&&(o[i.key]=`{{secret:${i.key}}}`);return o}function rr(e,t,n){const s=new Set;let r=e.sets.find(a=>a.id===t),o=!0;for(;r&&!s.has(r.id);){if(s.add(r.id),n in r.values)return{value:r.values[n],from:o?"own":"inherited",set:r.id};o=!1,r=r.extends?e.sets.find(a=>a.id===r.extends):void 0}const i=e.variables.find(a=>a.key===n);return(i==null?void 0:i.defaultValue)!==void 0?{value:i.defaultValue,from:"default"}:{from:"none"}}function ir(e){return e.sets.map(t=>({id:t.id,name:t.name,values:Object.entries(Tt(e,t.id)).map(([n,s])=>{var r;return{key:n,value:s,secret:((r=e.variables.find(o=>o.key===n))==null?void 0:r.secret)||void 0}})}))}function or(e,t){return(t?e.sets.find(n=>{var s;return((s=n.appliesTo)==null?void 0:s.database)===t}):void 0)??e.sets.find(n=>{var s;return!((s=n.appliesTo)!=null&&s.database)})}function ut(e,t=[]){if(typeof e=="string")t.push(e);else if(Array.isArray(e))for(const n of e)ut(n,t);else if(e&&typeof e=="object")for(const n of Object.values(e))ut(n,t);return t}function ar(e,t={variables:[],sets:[]},n={}){var a,c;const s=[],r=new Set(t.variables.map(p=>p.key)),o=new Set;for(const p of e.integrations){const u=p.key;o.has(u)&&s.push({severity:"error",integration:u,code:"keyDuplicate",message:`Duplicate key ${u}`}),o.add(u),!p.connection.baseUrl.trim()&&p.connection.protocol!=="webhook"&&s.push({severity:"warning",integration:u,code:"baseUrlMissing",message:`${u}: no base URL`});const d=new Set(ut([p.connection,p.endpoints]).flatMap(mt).filter(m=>!m.startsWith("$")&&!m.startsWith("secret:")));for(const m of d)!r.has(m)&&!p.endpoints.variables.some(k=>k.key===m)&&s.push({severity:"warning",integration:u,code:"variableUndeclared",message:`${u}: {{${m}}} is not declared in the environment variables`});const f=new Set(pe(p.endpoints.items).map(({request:m})=>m.id)),l=new Set((p.expose??[]).map(m=>m.key));for(const m of p.operations??[])m.endpoint&&!f.has(m.endpoint)&&!l.has(m.endpoint)&&s.push({severity:"error",integration:u,code:"endpointMissing",message:`${u}/${m.key}: endpoint ${m.endpoint} does not exist`});for(const m of((a=p.requires)==null?void 0:a.modules)??[])n.modules&&!n.modules.includes(m)&&s.push({severity:"warning",integration:u,code:"requiresMissing",message:`${u}: module ${m} is not installed`});for(const m of((c=p.requires)==null?void 0:c.dataSources)??[])n.dataSources&&!n.dataSources.includes(m)&&s.push({severity:"warning",integration:u,code:"requiresMissing",message:`${u}: data source ${m} does not exist`})}const i=new Set(t.sets.map(p=>p.id));for(const p of t.sets){p.extends&&!i.has(p.extends)&&s.push({severity:"error",code:"extendsMissing",message:`${p.id} extends ${p.extends}, which does not exist`});for(const d of t.variables){const f=p.values[d.key];d.secret&&f!==void 0&&f!==""&&!/^\{\{\s*secret:/.test(f)&&s.push({severity:"error",code:"secretInSeed",message:`${p.id}: ${d.key} is a secret — write {{secret:${d.key}}}, not the value`})}const u=Tt(t,p.id);for(const d of t.variables)d.required&&!u[d.key]&&s.push({severity:"warning",code:"requiredUnset",message:`${p.id}: ${d.key} has no value`})}return s}function cr(e,t){var p,u,d;if(!e||!t)return[];const n=(p=pe(e.items).find(f=>f.request.id===t))==null?void 0:p.request,s=((u=n==null?void 0:n.responses)==null?void 0:u["200"])??((d=n==null?void 0:n.responses)==null?void 0:d["201"]),r=Fe(e.schemas),o=(f,l=0)=>{if(!f||l>8)return{};if(f.$ref)return o(r(f.$ref),l+1);const m={...f.properties??{}};for(const k of f.allOf??[])Object.assign(m,o(k,l+1));return m},i=f=>f!=null&&f.$ref?r(f.$ref):f,a=[],c=i(s==null?void 0:s.schema);if(!c)return a;if(c.type==="array"||c.items){for(const f of Object.keys(o(c.items)))a.push(`$[*].${f}`);return a}for(const[f,l]of Object.entries(o(c))){const m=i(l);if(m&&(m.type==="array"||m.items)){const k=Object.keys(o(m.items));if(k.length){k.forEach(y=>a.push(`$.${f}[*].${y}`));continue}}a.push(`$.${f}`)}return a}function pr(e){return e.split(/[^A-Za-z0-9]+/).filter(Boolean).map((n,s)=>(s===0?n.charAt(0).toLowerCase():n.charAt(0).toUpperCase())+n.slice(1)).join("")||"call"}function lr(e){var n;const t=[];for(const s of e.integrations)for(const{request:r}of pe(((n=s.endpoints)==null?void 0:n.items)??[]))t.push({path:`integrations/${s.key}/${r.operationId||pr(r.name)}`,name:r.name,kind:"endpoint",group:s.name,description:`${r.method.toUpperCase()} ${r.url}`});return t}function ur(e){const t=new Map;for(const s of e){const r=s.package??"";t.has(r)||t.set(r,new Map);const o=t.get(r);o.has(s.direction)||o.set(s.direction,[]),o.get(s.direction).push(s)}const n=["inbound","outbound","bidirectional"];return[...t].sort(([s],[r])=>s.localeCompare(r)).map(([s,r])=>({package:s,directions:n.filter(o=>r.has(o)).map(o=>({direction:o,integrations:r.get(o)}))}))}function fr(e){const t=pe(e.endpoints.items).map(({request:s})=>({id:s.id,label:`${s.method} ${s.name}`,exposed:!1})),n=(e.expose??[]).map(s=>({id:s.key,label:`${s.method} ${s.path}`,exposed:!0}));return[...t,...n]}exports.GRAPHQL_INTROSPECTION_QUERY=Us;exports.NICE_API_AUTH_TYPES=Rn;exports.NICE_API_CODE_LANGUAGES=Qt;exports.NICE_API_MARKDOWN_LABELS=En;exports.NICE_API_METHODS=Ln;exports.NICE_CONNECTION_PROTOCOLS=nr;exports.NiceYamlError=Q;exports.POSTMAN_SCHEMA_V21=ln;exports.apiSecuritySchemes=ks;exports.assignedVariableSets=Fn;exports.bodyContentType=we;exports.bodyFromText=ft;exports.bodyText=re;exports.buildAuthorizationUrl=Vs;exports.buildGraphqlOperation=wn;exports.buildRequestUrl=ve;exports.buildSoapEnvelope=Tn;exports.collectionToMarkdown=er;exports.createPkcePair=Fs;exports.detectApiDocument=Un;exports.digest=_e;exports.digestAuthorization=Nn;exports.effectiveAuth=zt;exports.environmentSetFor=or;exports.exchangeAuthorizationCode=Js;exports.exportHar=_s;exports.exportOpenApi=pn;exports.exportOpenApiYaml=vs;exports.exportPostman=js;exports.exportPostmanEnvironment=Cs;exports.fetchOAuth2Token=Ks;exports.fetchTransport=Bs;exports.findApiItem=Dt;exports.findVariables=mt;exports.flattenApiRequests=pe;exports.fromBase64=yt;exports.generateCode=Zt;exports.graphqlExampleValue=Ne;exports.graphqlOperations=kn;exports.graphqlTypeName=ze;exports.groupIntegrations=ur;exports.headerValue=Mn;exports.hmac=de;exports.importApiDocument=tr;exports.importGraphqlIntrospection=vn;exports.importHar=gn;exports.importOpenApi=on;exports.importPostman=mn;exports.importPostmanEnvironment=hn;exports.importWsdl=Sn;exports.inferSchema=He;exports.integrationEndpoints=fr;exports.integrationFunctions=lr;exports.interpolate=ht;exports.isCurlCommand=Kt;exports.isEnabled=I;exports.isHar=wt;exports.isPostmanCollection=kt;exports.joinUrl=Jn;exports.jsonPointer=nt;exports.md5Hex=At;exports.mockFromSchema=bt;exports.mockResponse=gs;exports.namedType=vt;exports.newApiCollection=ge;exports.newApiFolder=be;exports.newApiId=$e;exports.newApiRequest=ye;exports.newIntegration=sr;exports.paramsIn=Mt;exports.parseCurl=Gt;exports.parseDigestChallenge=On;exports.parseFormEncoded=dt;exports.parseGraphqlIntrospection=bn;exports.parseJsonOrYaml=De;exports.parseWsdl=An;exports.parseYaml=en;exports.pathParamNames=Bt;exports.pollDeviceToken=Ys;exports.refreshOAuth2Token=Gs;exports.renameApiSchema=Dn;exports.requestName=gt;exports.resolveEnvironmentSet=Tt;exports.resolvePlainScalar=Be;exports.resolveRequest=pt;exports.responseFieldPaths=cr;exports.rowsToRecord=Hn;exports.schemaResolver=Fe;exports.sendApiRequest=zs;exports.setRequestUrl=Vt;exports.signAwsV4=jn;exports.signHmac=Cn;exports.splitUrl=ce;exports.startDeviceAuthorization=Qs;exports.stringifyYaml=sn;exports.swagger2ToOpenApi3=an;exports.syncPathParams=Ft;exports.toApiEnvironments=ir;exports.toBase64=We;exports.toCurl=Pe;exports.tokenizeCommand=Jt;exports.unresolvedVariables=Bn;exports.updateApiItem=Ht;exports.validateIntegrations=ar;exports.valueOrigin=rr;exports.variableScope=Vn;