@powerduck/openapi-request 0.2.2
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/README.md +711 -0
- package/dist/credentials-Cl0G4KpE.d.cts +783 -0
- package/dist/credentials-rqEKODvf.d.ts +783 -0
- package/dist/index-1jRrFc3d.d.cts +215 -0
- package/dist/index-CsRXyS7O.d.ts +215 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +350 -0
- package/dist/index.d.ts +350 -0
- package/dist/index.js +1 -0
- package/dist/protocol-D7sEx8IP.d.ts +62 -0
- package/dist/protocol-Dh-wN2nY.d.cts +62 -0
- package/dist/protocols/graphql/index.cjs +1 -0
- package/dist/protocols/graphql/index.d.cts +95 -0
- package/dist/protocols/graphql/index.d.ts +95 -0
- package/dist/protocols/graphql/index.js +1 -0
- package/dist/protocols/grpc/index.cjs +1 -0
- package/dist/protocols/grpc/index.d.cts +61 -0
- package/dist/protocols/grpc/index.d.ts +61 -0
- package/dist/protocols/grpc/index.js +1 -0
- package/dist/protocols/http/index.cjs +1 -0
- package/dist/protocols/http/index.d.cts +161 -0
- package/dist/protocols/http/index.d.ts +161 -0
- package/dist/protocols/http/index.js +1 -0
- package/dist/protocols/mcp/index.cjs +1 -0
- package/dist/protocols/mcp/index.d.cts +3 -0
- package/dist/protocols/mcp/index.d.ts +3 -0
- package/dist/protocols/mcp/index.js +1 -0
- package/dist/protocols/ws/index.cjs +1 -0
- package/dist/protocols/ws/index.d.cts +35 -0
- package/dist/protocols/ws/index.d.ts +35 -0
- package/dist/protocols/ws/index.js +1 -0
- package/dist/types-C9ifzKqk.d.cts +1226 -0
- package/dist/types-C9ifzKqk.d.ts +1226 -0
- package/package.json +93 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e,t=Object.create,r=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,a=(e,t,i,a)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let u of o(t))s.call(e,u)||u===i||r(e,u,{get:()=>t[u],enumerable:!(a=n(t,u))||a.enumerable});return e},u=(e,n,o)=>(o=null!=e?t(i(e)):{},a(!n&&e&&e.__esModule?o:r(o,"default",{value:e,enumerable:!0}),e)),c={};((e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0})})(c,{HttpAdapter:()=>ot,SseParser:()=>$e,buildCollection:()=>ge,buildEnvironment:()=>J,buildRunOptions:()=>Te,createResolver:()=>Ze,locateOperation:()=>et,resolveServerUrl:()=>V,runWithPostman:()=>Le}),module.exports=(e=c,a(r({},"__esModule",{value:!0}),e));var l=new Set(["__proto__","constructor","prototype"]),f="2024-01-01T00:00:00.000Z",p=12,d=2,m=5,y=256;function h(e,t=0,r={}){const n=r.maxDepth??p;if(!e||"object"!=typeof e||Array.isArray(e))return null;if(t>n)return null;if("string"==typeof e.$ref)return null;if(void 0!==e.example)return e.example;const o=function(e){if(null==e)return;if(Array.isArray(e))return e.length?e[0]:void 0;if("object"==typeof e)for(const t of Object.values(e))if(void 0!==t){if(t&&"object"==typeof t){if("value"in t)return t.value;if("externalValue"in t)continue}return t}return}(e.examples);if(void 0!==o)return o;if(void 0!==e.default)return e.default;if(void 0!==e.const)return e.const;if(Array.isArray(e.enum)&&e.enum.length){const t=e.enum.find(e=>null!==e);return void 0!==t?t:e.enum[0]}if(Array.isArray(e.allOf)&&e.allOf.length)return function(e,t,r){let n,o;for(const i of e.allOf){const e=h(i,t+1,r);null===e||"object"!=typeof e||Array.isArray(e)?null!=e&&(o=e):n={...n??{},...e}}if(e.properties||e.required){const o=g(e,t,r);o&&"object"==typeof o&&(n={...n??{},...o})}return n||(void 0!==o?o:{})}(e,t,r);for(const n of["oneOf","anyOf"]){const o=e[n];if(Array.isArray(o)&&o.length){return h(o.find(e=>e&&"object"==typeof e&&"null"!==e.type)??o[0],t+1,r)}}const i=function(e){const t=Array.isArray(e.type)?e.type.find(e=>"string"==typeof e&&"null"!==e)??(e.type.includes("null")?"null":void 0):"string"==typeof e.type?e.type:void 0;if(t)return t;if(e.properties||e.additionalProperties||e.required)return"object";if(e.items||e.prefixItems)return"array";if(void 0!==e.minimum||void 0!==e.maximum||void 0!==e.multipleOf)return"number";return"string"}(e);switch(i){case"object":return g(e,t,r);case"array":return function(e,t,r){const n=[];if(Array.isArray(e.prefixItems))for(const o of e.prefixItems)n.push(h(o,t+1,r));const o=w(e.minItems)??1,i=w(e.maxItems);let s=Math.max(o,n.length,1);s=Math.min(s,m),void 0!==i&&(s=Math.min(s,Math.max(i,0)));const a=e.items&&"object"==typeof e.items?e.items:void 0;if(!a&&Array.isArray(e.prefixItems))return n.slice(0,0===s?0:Math.max(s,n.length));for(;n.length<s;){const o=h(a??{},t+1,r);if(!0===e.uniqueItems&&n.length>0)break;n.push(o)}return void 0!==i?n.slice(0,Math.max(i,0)):n}(e,t,r);case"integer":return function(e){const{min:t,max:r}=b(e,!0);let n=0;void 0!==t&&n<t&&(n=Math.ceil(t));void 0!==r&&n>r&&(n=Math.floor(r));const o=A(e.multipleOf);if(void 0!==o&&o>0){const e=Math.ceil(n/o)*o;(void 0===r||e<=r)&&(n=e)}return Math.trunc(n)}(e);case"number":return function(e){const{min:t,max:r}=b(e,!1);let n=0;void 0!==t&&n<t&&(n=t);void 0!==r&&n>r&&(n=r);const o=A(e.multipleOf);if(void 0!==o&&o>0){const e=Math.ceil(n/o)*o;(void 0===r||e<=r)&&(n=e)}return n}(e);case"boolean":return!1;case"null":return null;default:return function(e){const t="string"==typeof e.format?e.format:void 0,r=t?function(e){switch(e){case"date-time":return f;case"date":return f.slice(0,10);case"time":return f.slice(11,19);case"duration":return"PT1S";case"uuid":return"00000000-0000-4000-8000-000000000000";case"email":case"idn-email":return"user@example.com";case"hostname":case"idn-hostname":return"example.com";case"ipv4":return"127.0.0.1";case"ipv6":return"::1";case"uri":case"url":case"iri":return"https://example.com";case"uri-reference":case"iri-reference":case"json-pointer":return"/example";case"uri-template":return"https://example.com/{id}";case"relative-json-pointer":return"0/example";case"regex":return"^example$";case"byte":return"ZXhhbXBsZQ==";case"binary":return"";case"password":return"password";default:return}}(t):void 0;return void 0!==r?v(r,e):"string"==typeof e.pattern&&e.pattern.length?"":v("string",e)}(e)}}function g(e,t,r){const n={},o=Array.isArray(e.required)?e.required.filter(e=>"string"==typeof e):[],i=e.properties&&"object"==typeof e.properties?e.properties:{},s=!0===r.includeReadOnly,a=!1!==r.includeWriteOnly;for(const[e,u]of Object.entries(i))l.has(e)||!s&&u&&!0===u.readOnly||!a&&u&&!0===u.writeOnly||t>d&&o.length&&!o.includes(e)||(n[e]=h(u,t+1,r));for(const e of o)l.has(e)||e in n||(n[e]=h(i[e]??{},t+1,r));!Object.keys(n).length&&e.additionalProperties&&"object"==typeof e.additionalProperties&&(n.key=h(e.additionalProperties,t+1,r));const u=w(e.minProperties);if(void 0!==u){const o=e.additionalProperties&&"object"==typeof e.additionalProperties?e.additionalProperties:{};let i=1;for(;Object.keys(n).length<Math.min(u,20);){const e=`additionalProp${i}`;i+=1,e in n||(n[e]=h(o,t+1,r))}}return n}function b(e,t){const r=t?1:Number.EPSILON>0?1e-6:1;let n=A(e.minimum),o=A(e.maximum);const i=e.exclusiveMinimum,s=e.exclusiveMaximum;if("number"==typeof i&&Number.isFinite(i)){const e=i+r;n=void 0===n?e:Math.max(n,e)}else!0===i&&void 0!==n&&(n+=r);if("number"==typeof s&&Number.isFinite(s)){const e=s-r;o=void 0===o?e:Math.min(o,e)}else!0===s&&void 0!==o&&(o-=r);return{min:n,max:o}}function v(e,t){const r=w(t.minLength),n=w(t.maxLength);let o=e;return void 0!==r&&o.length<r&&(o=o.padEnd(Math.min(r,y),"x")),void 0!==n&&o.length>n&&(o=o.slice(0,Math.max(n,0))),o}function A(e){if("number"==typeof e&&Number.isFinite(e))return e}function w(e){const t=A(e);if(void 0===t)return;const r=Math.floor(t);return r<0?0:r}var j=new Set(["__proto__","constructor","prototype"]);function x(e){return j.has(e)}function O(e){if(null===e||"object"!=typeof e)return e;if("function"==typeof globalThis.structuredClone)try{return globalThis.structuredClone(e)}catch{}return S(e)}function S(e){return k(e,new Set)}function k(e,t){if(null===e)return null;const r=typeof e;if("string"===r||"boolean"===r)return e;if("number"===r)return Number.isFinite(e)?e:null;if("bigint"===r)return e.toString();if("object"!==r)return;const n=e;if(t.has(n))return null;const o=n.toJSON;if("function"==typeof o){let e;try{e=o.call(n)}catch{return null}return e===n?null:k(e,t)}t.add(n);try{if(Array.isArray(n)){const e=new Array(n.length);for(let r=0;r<n.length;r+=1){const o=k(n[r],t);e[r]=void 0===o?null:o}return e}const e={};for(const r of Object.keys(n)){if(x(r))continue;let o;try{o=n[r]}catch{continue}const i=k(o,t);void 0!==i&&(e[r]=i)}return e}finally{t.delete(n)}}var $=64;function E(e,t){return _(e,t,0)}function _(e,t,r){if(!t||!C(t))return e;if(r>=$)return t;const n={...e};for(const e of Object.keys(t)){if(x(e))continue;const o=t[e];if(void 0===o)continue;const i=n[e];C(i)&&C(o)?n[e]=_(i,o,r+1):n[e]=o}return n}function C(e){if(null===e||"object"!=typeof e||Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function R(e){if(e)try{clearTimeout(e)}catch{}return null}function q(e,t,r=Number.MAX_SAFE_INTEGER){const n="number"==typeof e?e:Number(e);if(!Number.isFinite(n))return t;const o=Math.floor(n);return o<=0?t:Math.min(o,r)}var M=/(token|secret|password|passwd|apikey|api_key|credential|private|authorization)/i;function N(e){return M.test(e)}var I=Symbol.for("@powerduck/openapi-request.ProtoKitError"),P=class e extends Error{code;details;[I]=!0;constructor(t,r,n,o){if(super(t),this.name="ProtoKitError",this.code="string"==typeof r&&r?r:"UNKNOWN",this.details=n,o&&"cause"in o)try{Object.defineProperty(this,"cause",{value:o.cause,configurable:!0,writable:!0,enumerable:!1})}catch{}Object.setPrototypeOf(this,e.prototype),"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,e)}static isProtoKitError(e){return"object"==typeof e&&null!==e&&!0===e[I]}toJSON(){return{name:this.name,code:this.code,message:this.message,...void 0===this.details?{}:{details:this.details}}}};function T(e,t,r,n){return new P(t,e,r,n)}function U(e){const t=typeof e;if(null===e)return"null";if("undefined"===t)return"undefined";if("function"===t){const t=e.name;return t?`[Function: ${t}]`:"[Function (anonymous)]"}if("symbol"===t)return String(e);if("bigint"===t)return`${String(e)}n`;try{const t=JSON.stringify(e);if("string"==typeof t)return t}catch{}try{return String(e)}catch{return"[unserializable value]"}}function B(e){if(P.isProtoKitError(e))return{message:e.message||"Unknown ProtoKitError",code:e.code,name:e.name};if(e instanceof Error){const t=e.code,r="string"==typeof t||"number"==typeof t?String(t):void 0;return{message:e.message||e.name||"Unknown error",...r?{code:r}:{},name:e.name||"Error"}}if("object"==typeof e&&null!==e&&"string"==typeof e.message){const t=e,r="string"==typeof t.code||"number"==typeof t.code?String(t.code):void 0;return{message:t.message||"Unknown error",...r?{code:r}:{},..."string"==typeof t.name?{name:t.name}:{}}}return"string"==typeof e?{message:e||"Unknown error"}:{message:U(e)}}var D="\0PK_OPEN\0",L="\0PK_CLOSE\0",z=0;function F(e){z=(z+1)%65535;const t=Date.now().toString(36),r=Math.floor(65535*Math.random()).toString(36);return`${e}-${t}-${z.toString(36)}${r}`}function V(e,t){const r="string"==typeof t.serverUrl?t.serverUrl.trim():"";if(r)return K(W(r),"options.serverUrl");const n=Array.isArray(e)?e.filter(C):[],o=n[Number.isInteger(t.serverIndex)?Math.max(0,t.serverIndex):0]??n[0];let i=o&&"string"==typeof o.url&&o.url.trim()?o.url.trim():"";if(!i)throw T("NO_SERVER_URL","The document declares no usable server URL. Pass options.serverUrl to specify one.");return i=function(e,t,r){const n=C(t)?t:{};let o=e;for(const[e,t]of Object.entries(n)){const n=r?.[e];let i;if(null!=n){if(i=n,Array.isArray(t?.enum)&&t.enum.length&&!t.enum.some(e=>String(e)===String(n)))throw T("BAD_SERVER_VARIABLE",`Server variable "${e}" must be one of: ${t.enum.join(", ")}`,{provided:n,allowed:t.enum})}else if(void 0!==t?.default)i=t.default;else{if(!Array.isArray(t?.enum)||!t.enum.length)throw T("BAD_SERVER_VARIABLE",`Server variable "${e}" has no default; pass serverVariables["${e}"].`);i=t.enum[0]}o=o.split(`{${e}}`).join(String(i??""))}for(const[e,t]of Object.entries(r??{}))Object.prototype.hasOwnProperty.call(n,e)||null!=t&&(o=o.split(`{${e}}`).join(String(t)));return o}(i,o?.variables,t.serverVariables),K(W(i),"spec.servers")}function W(e){return e.replace(/\/+$/,"")||e}function K(e,t){const r=function(e){return-1===e.indexOf("{")?e:e.split("{{").join(D).split("}}").join(L).replace(/\{[^{}]*\}/g,"").split(D).join("{{").split(L).join("}}")}(e);if(!r)throw T("BAD_SERVER_URL",`${t} resolved to an empty URL`);if(r.includes("{{"))return r;if(!/^[a-z][a-z0-9+.-]*:\/\//i.test(r))throw T("RELATIVE_SERVER_URL",`${t} resolved to the relative URL "${r}". A request needs an absolute origin; pass options.serverUrl.`,{url:r});return r}function J(e,t,r={},n={}){const o=!1!==n.maskSecrets,i=!0===n.allowBaseUrlOverride,s=C(r)?r:{},a=[],u=new Set,c=(e,t,r)=>{"string"==typeof e&&e&&(u.has(e)||(u.add(e),a.push({key:e,value:null==t?"":String(t),type:r,enabled:!0})))};i||c("baseUrl",t,"default");for(const[e,t]of Object.entries(s))c(e,t,o&&N(e)?"secret":"default");return i&&c("baseUrl",t,"default"),{id:F("protokit-env"),name:"string"==typeof e&&e.trim()?e:"protokit",values:a,_postman_variable_scope:"environment",_postman_exported_at:(new Date).toISOString()}}var H=["text/event-stream","application/json-seq","application/x-ndjson","application/ndjson","application/jsonl","application/x-jsonlines"];function X(e){return"default"!==e&&(!!/^2\d\d$/.test(e)||/^2xx$/i.test(e))}function G(e,t){const r=function(e){if(C(e?.header))for(const[t,r]of Object.entries(e.header))if("accept"===t.toLowerCase())return"string"==typeof r?r:Array.isArray(r)?r.map(e=>String(e)).join(", "):null==r?void 0:String(r)}(t);if(r&&Q(r))return!0;if(!C(e))return!1;const n=e["x-protocol"];if("string"==typeof n){const e=n.toLowerCase();if("sse"===e||"eventsource"===e)return!0;if("websocket"===e||"grpc"===e)return!1}if(C(e["x-sse"]))return!0;const o=e.responses;if(!C(o))return!1;for(const[e,t]of Object.entries(o)){if(e.startsWith("x-"))continue;if(!C(t))continue;const r=t.content;if(C(r))for(const[e,t]of Object.entries(r)){const r=e.toLowerCase();if(r.startsWith("text/event-stream"))return!0;if(C(t)&&void 0!==t.itemSchema&&H.some(e=>r.startsWith(e)))return!0}}return!1}function Z(e){return"string"==typeof e&&/(^|[\s,;])text\/event-stream\b/i.test(e)}function Q(e){if("string"!=typeof e||!e)return!1;return e.split(",").map(e=>e.split(";")[0].trim().toLowerCase()).filter(Boolean).some(e=>H.some(t=>e===t||e.startsWith(t)))}var Y=8,ee=2e3,te=2e5;function re(e){if(!e)return[];return(Array.isArray(e)?e:[e]).filter(e=>C(e)&&("string"==typeof e.exec||Array.isArray(e.exec)))}function ne(e,t,r){const n=[],o=new Set;return r.forEach((r,i)=>{const s=function(e){const t=(Array.isArray(e)?e.map(e=>"string"==typeof e?e:String(e??"")):String(e).split(/\r?\n/)).slice(0,ee);let r=0;const n=[];for(const e of t){if(r+=e.length+1,r>te)break;n.push(e)}return n}(r.exec);if(!s.some(e=>e.trim().length>0))return;let a="string"==typeof r.id&&r.id.trim()?r.id.trim():`protokit-${t}-${e}-${i}`;for(;o.has(a);)a=`${a}-b`;o.add(a),n.push({listen:e,script:{id:a,type:"text/javascript",exec:s}})}),n}function oe(e,t){const r=e?.["x-postman-scripts"];if(!C(r))return{pre:[],test:[]};const n=e=>{if(null==e)return[];if("string"==typeof e)return[{exec:e}];if(Array.isArray(e))return e.length?e.every(e=>"string"==typeof e)?[{exec:e}]:e.filter(e=>C(e)&&("string"==typeof e.exec||Array.isArray(e.exec))).slice(0,Y):[];if(C(e)){const t=e;if("string"==typeof t.exec||Array.isArray(t.exec))return[t]}return[]},o="collection"===t?r.collectionPreRequest??r.preRequest??r.prerequest:r.preRequest??r.prerequest,i="collection"===t?r.collectionTest??r.test??r.tests:r.test??r.tests;return{pre:n(o).slice(0,Y),test:n(i).slice(0,Y)}}var ie=new Set(["GET","PUT","POST","DELETE","OPTIONS","HEAD","PATCH","TRACE"]),se=/^(accept|content-type|authorization)$/i,ae=0;function ue(e){ae=(ae+1)%65535;const t=Date.now().toString(36),r=Math.floor(65535*Math.random()).toString(36);return`${e}-${t}-${ae.toString(36)}${r}`}function ce(e){return"string"==typeof e&&e.length?e:void 0}function le(e){const t=e.toLowerCase();return"application/json"===t?0:t.includes("json-seq")||t.includes("ndjson")?40:t.endsWith("+json")?10:t.includes("json")?20:t.includes("x-www-form-urlencoded")?30:t.includes("multipart/form-data")?35:50}function fe(e){if(null==e)return"";const t=typeof e;if("string"===t)return e;if("number"===t||"boolean"===t||"bigint"===t)return String(e);if("object"===t)try{const t=JSON.stringify(e);return"string"==typeof t?t:""}catch{return""}return""}var pe={spaceDelimited:" ",pipeDelimited:"|",form:",",simple:","};function de(e,t){const r=String(e.name),n=ce(e.style)??"form",o="boolean"==typeof e.explode?e.explode:"form"===n||"deepObject"===n;if(Array.isArray(t)){if(!t.length)return[{key:r,value:""}];if(o&&"deepObject"!==n)return t.map(e=>({key:r,value:fe(e)}));if("deepObject"===n)return t.map((e,t)=>({key:`${r}[${t}]`,value:fe(e)}));const e=pe[n]??",";return[{key:r,value:t.map(fe).join(e)}]}if(C(t)){const e=Object.entries(t);return e.length?"deepObject"===n?e.map(([e,t])=>({key:`${r}[${e}]`,value:fe(t)})):o?e.map(([e,t])=>({key:e,value:fe(t)})):[{key:r,value:e.flatMap(([e,t])=>[e,fe(t)]).join(",")}]:[{key:r,value:""}]}return[{key:r,value:fe(t)}]}function me(e,t){const r=ce(e.style)??"simple",n=!0===e.explode,o=String(e.name),i=(e,t)=>e.map(fe).join(t);if("label"===r){if(Array.isArray(t))return`.${i(t,n?".":",")}`;if(C(t)){const e=Object.entries(t);return n?e.map(([e,t])=>`.${e}=${fe(t)}`).join(""):`.${e.flatMap(([e,t])=>[e,fe(t)]).join(",")}`}return`.${fe(t)}`}if("matrix"===r){if(Array.isArray(t))return n?t.map(e=>`;${o}=${fe(e)}`).join(""):`;${o}=${i(t,",")}`;if(C(t)){const e=Object.entries(t);return n?e.map(([e,t])=>`;${e}=${fe(t)}`).join(""):`;${o}=${e.flatMap(([e,t])=>[e,fe(t)]).join(",")}`}return`;${o}=${fe(t)}`}if(Array.isArray(t))return i(t,",");if(C(t)){const e=Object.entries(t);return n?e.map(([e,t])=>`${e}=${fe(t)}`).join(","):e.flatMap(([e,t])=>[e,fe(t)]).join(",")}return fe(t)}function ye(e,t){const r=!0===e.explode;if(Array.isArray(t))return t.map(fe).join(",");if(C(t)){const e=Object.entries(t);return r?e.map(([e,t])=>`${e}=${fe(t)}`).join(","):e.flatMap(([e,t])=>[e,fe(t)]).join(",")}return fe(t)}function he(e,t){const r=String(e.name),n=!0===e.explode;if(Array.isArray(t))return n?t.map(e=>[r,fe(e)]):[[r,t.map(fe).join(",")]];if(C(t)){const e=Object.entries(t);return n?e.map(([e,t])=>[e,fe(t)]):[[r,e.flatMap(([e,t])=>[e,fe(t)]).join(",")]]}return[[r,fe(t)]]}function ge(e,t,r){const n=r.values??{},o=[],i=V(e.servers,r),s=Array.isArray(e.parameters)?e.parameters:[],a=e=>s.filter(t=>t&&"object"==typeof t&&t.in===e&&"string"==typeof t.name),{contentType:u,undeclared:c}=function(e,t){const r=e?.requestBody?.content,n=C(r)?Object.keys(r):[],o=ce(t.contentType);if(o){const e=o.split(";")[0].trim().toLowerCase(),t=n.some(t=>t.toLowerCase()===e);return{contentType:o,undeclared:n.length>0&&!t}}return n.length?{contentType:n.slice().sort((e,t)=>le(e)-le(t))[0],undeclared:!1}:{contentType:void 0,undeclared:!1}}(e.operation,n);c&&u&&o.push(`Content type "${u}" is not declared by the operation's requestBody.`);const l=[];for(const e of a("path")){const t=n.path?.[e.name],r=null!=t,i=me(e,r?t:h(e.schema??{}));i?r||o.push(`Path parameter "${e.name}" was synthesized from its schema as "${i}".`):o.push(`Path parameter "${e.name}" resolved to an empty value; pass values.path["${e.name}"] to control it.`),l.push({key:e.name,value:i})}const f=String(e.path).replace(/^\//,"").split("/").filter(e=>e.length>0).map(e=>e.replace(/\{([^}]+)\}/g,(e,t)=>`:${t}`)),p=[],d=new Set;for(const e of a("query")){d.add(e.name);const t=C(n.query)&&Object.prototype.hasOwnProperty.call(n.query,e.name),r=t?n.query[e.name]:void 0;if(t&&void 0!==r)p.push(...de(e,null===r?"":r));else{if(!0===e.required){const t=h(e.schema??{});p.push(...de(e,null===t?"":t));continue}!0!==e.allowEmptyValue?p.push({key:e.name,value:"",disabled:!0}):p.push({key:e.name,value:""})}}if(C(n.query))for(const[e,t]of Object.entries(n.query))if(!d.has(e)&&null!=t)if(Array.isArray(t))for(const r of t)p.push({key:e,value:fe(r)});else p.push({key:e,value:fe(t)});"string"==typeof n.querystring&&n.querystring.length&&p.push(...function(e){const t=[],r=e.replace(/^[?&]+/,"");if(!r)return t;for(const e of r.split("&")){if(!e)continue;const r=e.indexOf("=");r<0?t.push({key:e,value:"",__raw:!0}):t.push({key:e.slice(0,r),value:e.slice(r+1),__raw:!0})}return t}(n.querystring));const m=[],y=new Set,g=(e,t)=>{if(!e)return;const r=e.toLowerCase();y.has(r)||(y.add(r),m.push({key:e,value:t}))};if(C(n.header))for(const[e,t]of Object.entries(n.header))null!=t&&g(e,fe(t));for(const e of a("header")){if(se.test(e.name))continue;if(!0!==e.required)continue;const t=h(e.schema??{});if(null==t)continue;const r=ye(e,t);""!==r&&g(e.name,r)}u&&g("Content-Type",u);const b=function(e){if(!C(e))return;const t=e.responses;if(!C(t))return;const r=new Set,n=new Set;for(const[e,o]of Object.entries(t)){if(e.startsWith("x-"))continue;if(!C(o))continue;const t=o.content;if(!C(t))continue;const i=X(e)?r:n;for(const e of Object.keys(t))"string"==typeof e&&e.trim()&&"*/*"!==e&&i.add(e.trim())}const o=r.size?r:n;if(!o.size)return;const i=Array.from(o);return i.sort((e,t)=>{const r=e=>{const t=e.toLowerCase();return t.startsWith("text/event-stream")?0:H.some(e=>t.startsWith(e))?1:"application/json"===t?2:t.endsWith("+json")?3:4},n=r(e)-r(t);return 0!==n?n:e.localeCompare(t)}),i.slice(0,8).join(", ")}(e.operation);b&&g("Accept",b);const v=a("cookie"),A=[],w=(e,t)=>{A.push(`${e}=${encodeURIComponent(t)}`)};for(const e of v){const t=n.cookie?.[e.name],r=null!=t?t:!0===e.required?h(e.schema??{}):void 0;if(null!=r)for(const[t,n]of he(e,r))w(t,n)}if(C(n.cookie))for(const[e,t]of Object.entries(n.cookie))v.some(t=>t.name===e)||null!=t&&w(e,fe(t));A.length&&g("Cookie",A.join("; "));const j=function(e,t,r,n){const o=e?.requestBody,i=void 0!==t.body;if(!o&&!i)return;const s=r??(i?"application/json":void 0);if(!s)return void(o&&n.push("The operation declares a requestBody but no media type could be resolved; no body was sent."));!r&&i&&n.push("No request media type was declared; defaulted to application/json for the supplied body.");const a=function(e,t){const r=e?.content;if(!C(r))return;if(C(r[t]))return r[t].schema;const n=t.split(";")[0].trim().toLowerCase();for(const e of Object.keys(r)){if(e.toLowerCase()!==n)continue;const t=r[e];if(C(t))return t.schema}}(o,s),u=i?t.body:h(a??{}),c=s.split(";")[0].trim().toLowerCase(),l=c.includes("json-seq")||c.includes("ndjson");if(!l&&("application/json"===c||c.endsWith("+json")||c.includes("json"))){let e;if("string"==typeof u)e=u;else if(void 0===u)e="{}";else try{e=JSON.stringify(u,null,2)??"null"}catch{n.push("The request body could not be serialized as JSON."),e="{}"}return{mode:"raw",raw:e,options:{raw:{language:"json"}}}}if(c.includes("x-www-form-urlencoded"))return{mode:"urlencoded",urlencoded:be(u).map(([e,t])=>({key:e,value:fe(t),type:"text"}))};if(c.includes("multipart/form-data"))return{mode:"formdata",formdata:be(u).map(([e,t])=>C(t)&&"__file"in t?{key:e,type:"file",src:String(t.__file)}:{key:e,type:"text",value:fe(t)})};if(c.includes("xml")||c.startsWith("text/")||l)return{mode:"raw",raw:"string"==typeof u?u:fe(u),...c.includes("xml")?{options:{raw:{language:"xml"}}}:{}};return{mode:"raw",raw:"string"==typeof u?u:fe(u)}}(e.operation,n,u,o),x=p.filter(e=>!e.disabled).map(e=>e.__raw?`${e.key}${""===e.value?"":`=${e.value}`}`:`${encodeURIComponent(e.key)}=${encodeURIComponent(e.value)}`).join("&");let O=`{{baseUrl}}/${f.join("/")}`;x&&(O+=`?${x}`);const S={raw:O,host:["{{baseUrl}}"],path:f};p.length&&(S.query=p.map(({__raw:e,...t})=>t)),l.length&&(S.variable=l);const k=String(e.method).toUpperCase(),$={method:k,header:m,url:S},E=ce(e.operation?.description)??ce(e.operation?.summary);E&&($.description=E),j&&($.body=j);const _=function(e,t){const r=!1===t?.fromSpecExtensions?{pre:[],test:[]}:oe(e,"item");return[...ne("prerequest","item",[...r.pre,...re(t?.preRequest)]),...ne("test","item",[...r.test,...re(t?.test)])]}(e.operation,r.scripts)??[],R=function(e,t){const r=!1===t?.fromSpecExtensions?{pre:[],test:[]}:oe(e,"collection");return[...ne("prerequest","collection",[...r.pre,...re(t?.collectionPreRequest)]),...ne("test","collection",[...r.test,...re(t?.collectionTest)])]}(t,r.scripts)??[],q=function(e){if(e&&"object"==typeof e&&"none"!==e.type)switch(e.type){case"bearer":return{type:"bearer",bearer:[{key:"token",value:e.token??"",type:"string"}]};case"basic":return{type:"basic",basic:[{key:"username",value:e.username??"",type:"string"},{key:"password",value:e.password??"",type:"string"}]};case"apikey":return{type:"apikey",apikey:[{key:"key",value:e.key??"X-API-Key",type:"string"},{key:"value",value:e.value??"",type:"string"},{key:"in",value:"query"===e.in?"query":"header",type:"string"}]};default:return}}(r.auth),M=ce(e.operation?.operationId)??`${k} ${e.path}`,N={info:{_postman_id:ue("protokit"),name:(I=t?.info?.title,P="OpenAPI Debug Session","string"==typeof I&&I.trim()?I:P),schema:"https://schema.getpostman.com/json/collection/v2.1.0/collection.json"},item:[{name:M,..._.length?{event:_}:{},request:$,response:[]}],variable:[{key:"baseUrl",value:i}]};var I,P;const T=ce(t?.info?.description);return T&&(N.info.description=T),q&&(N.auth=q),R.length&&(N.event=R),{collection:N,baseUrl:i,contentType:u,isCustomMethod:!ie.has(k),warnings:o}}function be(e){return C(e)?Object.entries(e):[]}var ve=u(require("http"),1),Ae=u(require("https"),1),we=u(require("postman-runtime"),1),je=u(require("postman-collection"),1),xe=new Set(["[DONE]","DONE","[done]","done"]),Oe=/\r\n\r\n|\n\n|\r\r/,Se=/^\d+$/;function ke(e,t){const r="number"==typeof e?e:Number(e);return Number.isFinite(r)&&r>0?Math.floor(r):t}var $e=class{buffer="";decoder=new TextDecoder("utf-8");lastEventId;bomChecked=!1;overflowed=!1;sequence=0;maxBufferChars;maxEventChars;inheritEventId;droppedEvents=0;constructor(e={}){this.maxBufferChars=ke(e.maxBufferChars,4194304),this.maxEventChars=ke(e.maxEventChars,1048576),this.inheritEventId=!1!==e.inheritEventId}get truncated(){return this.overflowed}get count(){return this.sequence}push(e){if(null==e)return[];if("string"==typeof e)this.buffer+=e;else{let t;if(e instanceof Uint8Array)t=e;else try{t=new Uint8Array(e)}catch{return[]}try{this.buffer+=this.decoder.decode(t,{stream:!0})}catch{return[]}}!this.bomChecked&&this.buffer.length&&(this.bomChecked=!0,65279===this.buffer.charCodeAt(0)&&(this.buffer=this.buffer.slice(1)));const t=this.drain();return this.buffer.length>this.maxBufferChars&&(this.overflowed=!0,this.droppedEvents+=1,this.buffer=this.buffer.slice(-8)),t}flush(){try{this.buffer+=this.decoder.decode()}catch{}const e=this.drain(),t=this.buffer;if(this.buffer="",t.trim()){const r=this.parseBlock(t);r&&e.push(r)}return e}reset(){this.buffer="",this.lastEventId=void 0,this.bomChecked=!1,this.overflowed=!1,this.sequence=0,this.droppedEvents=0;try{this.decoder.decode()}catch{}}drain(){const e=[];for(;;){const t=Oe.exec(this.buffer);if(!t)break;const r=this.buffer.slice(0,t.index);this.buffer=this.buffer.slice(t.index+t[0].length);const n=this.parseBlock(r);n&&e.push(n)}return e}parseBlock(e){const t=e.split(/\r\n|\n|\r/),r=[],n={data:"",receivedAt:Date.now(),direction:"in"};let o=!1,i=0,s=!1;for(const e of t){if(""===e)continue;if(58===e.charCodeAt(0))continue;const t=e.indexOf(":"),a=-1===t?e:e.slice(0,t);let u=-1===t?"":e.slice(t+1);switch(32===u.charCodeAt(0)&&(u=u.slice(1)),a){case"data":{if(o=!0,s)break;const e=this.maxEventChars-i;u.length>e?(r.push(u.slice(0,Math.max(0,e))),s=!0,this.overflowed=!0,this.droppedEvents+=1):(r.push(u),i+=u.length+1);break}case"event":n.event=u,o=!0;break;case"id":u.includes("\0")||(n.id=u,this.lastEventId=u),o=!0;break;case"retry":if(Se.test(u)&&u.length<=15){const e=Number(u);Number.isSafeInteger(e)&&(n.retry=e)}o=!0}}if(!o)return null;if(n.data=r.join("\n"),void 0===n.id&&this.inheritEventId&&void 0!==this.lastEventId&&(n.id=this.lastEventId),!s){const e=n.data.trim();if(e&&!xe.has(e)&&function(e){const t=e.charCodeAt(0);return 123===t||91===t||34===t}(e))try{n.parsed=JSON.parse(n.data)}catch{}}return this.sequence+=1,n}};var Ee=u(require("postman-collection"),1),_e=864e5,Ce=15e3,Re=3e4,qe=3e4,Me=15e3;function Ne(e){if(null==e)return;const t="number"==typeof e?e:Number(e);return!Number.isFinite(t)||t<0?void 0:Math.min(Math.floor(t),_e)}function Ie(e,t=[]){const r=[];for(const[t,n]of Object.entries(e??{}))"string"==typeof t&&t&&r.push({key:t,value:null==n?"":String(n)});r.push(...t);const n=new Map;for(const e of r)n.set(e.key,e);return new Ee.default.VariableScope({values:Array.from(n.values())})}function Pe(e){if(!C(e))return;if("maxResponseSize"in e){const t=e.maxResponseSize;if(null!=t){const e="number"==typeof t?t:Number(t);if(!Number.isFinite(e)||e<=0)throw T("BAD_RUN_OPTIONS","runner.requester.maxResponseSize must be a positive number of bytes. Omit it to leave the response size unbounded.",{provided:t})}}if("maxRedirects"in e){const t=e.maxRedirects;if(null!=t){const e="number"==typeof t?t:Number(t);if(!Number.isInteger(e)||e<0)throw T("BAD_RUN_OPTIONS","runner.requester.maxRedirects must be a non-negative integer.",{provided:t})}}const t=e.protocolVersion;if(void 0!==t&&"http1"!==t&&"http2"!==t&&"auto"!==t)throw T("BAD_RUN_OPTIONS",'runner.requester.protocolVersion must be "http1", "http2" or "auto".',{provided:t})}function Te(e,t){if(!e||"object"!=typeof e)throw T("BAD_RUN_OPTIONS","send options are required");Pe(e.runner?.requester);const r=Ne(e.runner?.timeout?.request)??Ne(e.timeout)??Re,n=t.streaming?Ne(e.maxStreamMs)??qe:0,o=E({iterationCount:1,stopOnError:!1,abortOnError:!1,stopOnFailure:!1,abortOnFailure:!1,timeout:{request:r,script:Ne(e.runner?.timeout?.script)??Me,global:0===r?0:Math.min(r+n+Ce,_e)},delay:{item:0,iteration:0},script:{serializeLogs:!1},ignoreProxyEnvironmentVariables:!1,requester:{strictSSL:!0,followRedirects:!0,followOriginalHttpMethod:!1,maxRedirects:10,useWhatWGUrlParser:!0,removeRefererHeaderOnRedirect:!1,insecureHTTPParser:!1,timings:!0,verbose:!0,implicitCacheControl:!0,implicitTraceHeader:!0,disableCookies:!1,protocolVersion:"http1",maxInvokableNestedRequests:5,encoding:null}},e.runner??{});Pe(o.requester),o.environment||(o.environment=Ie(e.variables,[{key:"baseUrl",value:t.baseUrl}])),!o.globals&&e.globals&&(o.globals=Ie(e.globals)),!o.localVariables&&e.localVariables&&(o.localVariables=Ie(e.localVariables)),Array.isArray(o.data)&&o.data.length&&void 0===e.runner?.iterationCount&&(o.iterationCount=o.data.length);const i=Number(o.iterationCount);if(!Number.isInteger(i)||i<1)throw T("BAD_RUN_OPTIONS","runner.iterationCount must be an integer of at least 1.",{provided:o.iterationCount});return o}function Ue(e){const t={},r="function"==typeof e?.all?e.all():[];for(const e of r??[]){if(!e||e.disabled)continue;const r=String(e.key??"");r&&(t[r]=t[r]?`${t[r]}, ${String(e.value??"")}`:String(e.value??""))}return t}function Be(e){if(e)try{const t=e.values??e,r="function"==typeof t.toJSON?t.toJSON():t;if(!Array.isArray(r))return;const n={};for(const e of r){if(!e||!1===e.enabled||null==e.key)continue;const t=String(e.key);"__proto__"!==t&&"constructor"!==t&&(n[t]=null==e.value?"":String(e.value))}return n}catch{return}}function De(e){const t=e?.body;if(t)try{if("raw"===t.mode)return t.raw;if("function"==typeof t.toString){return t.toString()||void 0}return S(t)}catch{return}}function Le(e,t,r){const n=function(){let e,t,r=!1;const n=new Promise((r,n)=>{e=r,t=n});return n.catch(()=>{}),{promise:n,get settled(){return r},resolve:t=>!r&&(r=!0,e(t),!0),reject:e=>!r&&(r=!0,t(e),!0)}}(),o=Date.now();let i,s,a,u="initialized",c=e.streamingHint,l=!1;const f=q(t.maxEvents,100),p=q(t.maxStreamMs,3e4),d=q(t.runner?.timeout?.request??t.timeout,3e4),m="number"==typeof t.maxResponseSize?t.maxResponseSize:void 0,y=new $e({maxBufferChars:t.maxBufferChars,maxEventChars:t.maxEventChars,inheritEventId:t.inheritEventId}),h=[],g=[];let b=0,v=!1;const A={prerequest:[],test:[],assertions:[],console:[],passed:!0,skipped:!1},w=[];let j=null,x=null,O=null,k=null,$=null,E=null;const _=function(e){const t=e.runner?.requester;return!(!t?.agents&&!t?.agent)}(t)?null:function(){try{const e=new Set,t=t=>{if(!t||"function"!=typeof t.destroy)return t;e.add(t);const r=()=>e.delete(t);return t.once?.("close",r),t.once?.("error",r),t},r=new ve.default.Agent({keepAlive:!1}),n=new Ae.default.Agent({keepAlive:!1});return r.createConnection=function(e,r){return t(ve.default.Agent.prototype.createConnection.call(this,e,r))},n.createConnection=function(e,r){return t(Ae.default.Agent.prototype.createConnection.call(this,e,r))},{agents:{http:r,https:n},destroyAll(){let t=0;for(const r of Array.from(e))try{r.destroy(),t+=1}catch{}e.clear();try{r.destroy(),n.destroy()}catch{}return t}}}catch{return null}}(),C=(e,t)=>{A.console.push({level:e,messages:[t],at:Date.now()})},M=e=>(e&&"function"==typeof e.unref&&e.unref(),e),N=(e,t)=>{if("stopping"===u||"finalized"===u)return;u="stopping",s=e,l=!0,C("debug",`[protokit] stopping run: ${t??e}`);try{x?.abort?.()}catch{}const r=_?.destroyAll()??0;r>0&&C("debug",`[protokit] destroyed ${r} open socket(s)`),$=M(setTimeout(()=>{"finalized"!==u&&(C("warn","[protokit] runtime did not report completion after stop"),P())},250))},I=(e,t)=>({target:t,scriptId:e?.script?.id??e?.event?.script?.id,error:e?.error?{name:e.error.name,message:e.error.message}:void 0,environment:Be(e?.result?.environment),globals:Be(e?.result?.globals),return:e?.result?.return}),P=()=>{if("finalized"===u)return;if(u="finalized",O=R(O),k=R(k),$=R($),E?.(),E=null,_?.destroyAll(),c){for(const e of y.flush())h.length<f?(h.push(e),ze(()=>t.onEvent?.(e))):l=!0;y.truncated&&(l=!0)}const e=Date.now();if(j)c&&(j.response.events=h),l&&(j.response.truncated=!0),j.response.timings={...j.response.timings,startedAt:o,endedAt:e,durationMs:e-o,firstByteMs:i?i-o:void 0,...void 0!==a?{networkDurationMs:a}:{}};else{const t=!!s&&h.length>0;j={protocol:c?"sse":"http",request:{method:"",url:"",headers:{}},response:{status:t?200:0,statusText:t?"Stream sampling stopped":"No response received",headers:{},contentType:c?"text/event-stream":void 0,...c?{events:h}:{},timings:{startedAt:o,endedAt:e,durationMs:e-o,firstByteMs:i?i-o:void 0},sizeBytes:b,...l?{truncated:!0}:{}},...t?{}:{error:{message:"aborted"===s?"Run aborted before a response was received":"Runner finished without a response",code:s}}}}s&&(j.response.stopReason=s),y.droppedEvents&&(j.response.droppedEvents=y.droppedEvents),j.scripts=A,n.resolve(j)};if(r?.signal){const e=r.signal;if(e.aborted)return N("aborted","signal already aborted"),P(),n.promise;const t=()=>N("aborted","caller aborted the request");e.addEventListener("abort",t,{once:!0}),E=()=>e.removeEventListener("abort",t)}k=M(setTimeout(()=>{if("finalized"!==u){C("error","[protokit] hard timeout reached, forcing completion"),s??="hardTimeout",l=!0;try{x?.abort?.()}catch{}_?.destroyAll(),P()}},d+p+3e4));const U=(e,t,r)=>(u="finalized",k=R(k),E?.(),_?.destroyAll(),Promise.reject(T(e,t,r)));let D,L,z;try{D=new je.default.Collection(S(e.collectionJson))}catch(e){return U("BAD_COLLECTION",`Failed to construct collection: ${B(e).message}`,e)}try{L=Te(t,{baseUrl:e.baseUrl,streaming:e.streamingHint}),_&&(L.requester={...L.requester??{},agents:_.agents})}catch(e){return U("BAD_RUN_OPTIONS",`Failed to build runtime options: ${B(e).message}`,e)}try{z=new we.default.Runner}catch(e){return U("RUNTIME_INIT",`Failed to create runner: ${B(e).message}`,e)}function F(e){let r;try{r=y.push(e)}catch(e){return void C("error",`[protokit] SSE parse failure: ${B(e).message}`)}for(const e of r){if(h.length>=f)return l=!0,void N("maxEvents",`maxEvents (${f}) reached`);if(h.push(e),ze(()=>t.onEvent?.(e)),h.length>=f)return void N("maxEvents",`maxEvents (${f}) reached`)}}return z.run(D,L,(r,f)=>{if(r)return u="finalized",k=R(k),E?.(),_?.destroyAll(),void n.reject(T("RUNTIME_INIT",r.message??"Runner initialization failed",r));if(x=f,"stopping"===u){try{f.abort?.()}catch{}_?.destroyAll()}f.start({console(e,r,...n){const o={level:"string"==typeof r?r:"log",messages:n,at:Date.now()};A.console.push(o),ze(()=>t.onConsole?.(o))},assertion(e,r){for(const e of r??[]){const r={name:e?.name??"assertion",passed:!e?.error&&!e?.skipped,skipped:!!e?.skipped,index:"number"==typeof e?.index?e.index:0,error:e?.error?{name:e.error.name,message:e.error.message??String(e.error),stack:e.error.stack}:void 0};r.passed||r.skipped||(A.passed=!1),A.assertions.push(r),ze(()=>t.onAssertion?.(r))}},prerequest(e,t,r){for(const e of r??[])A.prerequest.push(I(e,"prerequest"))},test(e,t,r){for(const e of r??[])A.test.push(I(e,"test"))},item(e,t,r,n,o){o?.isSkipped&&(A.skipped=!0)},responseStart(r,n,o){"initialized"===u&&(u="headers"),i??=Date.now();const s=Fe(o,"content-type");(Z(s)||Q(s))&&(c=!0),ze(()=>t.onResponseStart?.({status:o?.code??0,headers:Ue(o?.headers),contentType:s,streaming:c,protocol:c?"sse":"http",url:e.baseUrl})),c&&("headers"===u&&(u="streaming"),O||(O=M(setTimeout(()=>N("maxStreamMs",`maxStreamMs (${p}ms) reached`),p))))},responseData(e,t){if("finalized"===u||null==t)return;let r;try{r=Buffer.isBuffer(t)?t:Buffer.from(t)}catch{return}if(v=!0,b+=r.length,void 0!==m&&b>m&&"stopping"!==u)return c&&F(r),void N("maxResponseSize",`maxResponseSize (${m} bytes) exceeded`);c?F(r):g.push(r)},request(e,t,r,n,f,p){const d=Date.now(),m={method:n?.method??"",url:We(n),headers:Ue(n?.headers),body:De(n)};"number"==typeof r?.responseTime&&(a=r.responseTime);if(e&&!("stopping"===u||!!s))return void(j={protocol:c?"sse":"http",request:m,response:{status:0,statusText:"Request failed",headers:{},timings:{startedAt:o,endedAt:d,durationMs:d-o,firstByteMs:i?i-o:void 0,...void 0!==a?{networkDurationMs:a}:{}},sizeBytes:b},error:B(e),replays:w});e&&C("debug",`[protokit] transport closed by sampler: ${B(e).message}`);const y=Fe(r,"content-type");let A,x;(Z(y)||Q(y))&&(c=!0);let O=0;if(!c){const e=g.length?Buffer.concat(g):function(e){if(!e)return Buffer.alloc(0);if(Buffer.isBuffer(e))return e;try{return Buffer.from(e)}catch{return Buffer.alloc(0)}}(r?.stream);O=e.length,A=function(e){const t=Math.min(e.length,1024);for(let r=0;r<t;r+=1)if(0===e[r])return!0;return!1}(e)?void 0:e.toString("utf8"),x=function(e,t){if(!e)return;if(t&&!/json/i.test(t))return;const r=e.trim();if(r&&/^[[{"\-\d]|^(true|false|null)$/.test(r))try{return JSON.parse(r)}catch{return}}(A,y)}j={protocol:c?"sse":"http",request:m,response:{status:"number"==typeof r?.code?r.code:0,statusText:Ve(r),headers:Ue(r?.headers),contentType:y,...c?{streaming:!0,events:h,body:Object.assign({},...h.map(e=>e.parsed))}:{body:x,text:A},timings:{startedAt:o,endedAt:d,durationMs:d-o,firstByteMs:i?i-o:void 0,...void 0!==a?{networkDurationMs:a}:{}},sizeBytes:v?b:O,...l?{truncated:!0}:{}},cookies:Array.isArray(p)?p.map(e=>({name:String(e?.name??""),value:String(e?.value??""),domain:e?.domain,path:e?.path})):[],replays:w}},io(e,t,r,n,o){"http"===r?.type&&r.source&&"collection"!==r.source&&w.push({url:We(o),method:o?.method??"",status:"number"==typeof n?.code?n.code:0,reason:String(r.source)})},exception(e,t){C("error",`[exception] ${B(t).message}`)},done(e){if(e&&!j&&!(!!s||"stopping"===u))return u="finalized",O=R(O),k=R(k),$=R($),E?.(),_?.destroyAll(),void n.reject(T("RUNTIME_RUN",e.message??"Run failed",e));P()}})}),n.promise}function ze(e){try{e()}catch{}}function Fe(e,t){try{const r=e?.headers?.get?.(t);return null==r?void 0:String(r)}catch{return}}function Ve(e){try{return String("function"==typeof e?.reason?e.reason()??"":e?.status??"")}catch{return""}}function We(e){try{return"function"==typeof e?.url?.toString?e.url.toString():""}catch{return""}}var Ke=Symbol("protokit.cycle"),Je=new Set(["__proto__","constructor","prototype"]),He=32,Xe=100,Ge=2e5;function Ze(e,t={}){const r=Qe(t.maxDepth,He),n=Qe(t.maxNodes,Ge),o=new Map;function i(e,t){let r=e;try{r=decodeURIComponent(e)}catch{r=e}const n=r.replace(/~1/g,"/").replace(/~0/g,"~");if(Je.has(n))throw T("BAD_REF",`Pointer "${t}" traverses a forbidden key "${n}"`);return n}function s(t){if("string"!=typeof t||!t.length)throw T("EXTERNAL_REF","A $ref pointer must be a non-empty string");if("#"===t||"#/"===t)return e;if(!t.startsWith("#/"))throw T("EXTERNAL_REF",`Only local $ref pointers are supported, got: ${t}`);let r=e;for(const e of t.slice(2).split("/")){if(null===r||"object"!=typeof r)throw T("BAD_REF",`Cannot resolve pointer "${t}"`);const n=i(e,t);if(!Object.prototype.hasOwnProperty.call(r,n))throw T("BAD_REF",`Pointer "${t}" resolves to undefined`);r=r[n]}if(void 0===r)throw T("BAD_REF",`Pointer "${t}" resolves to undefined`);return r}function a(e){let t=e;const r=new Set;let n,o=0;for(;null!==t&&"object"==typeof t&&"string"==typeof t.$ref;){const e=t.$ref;if(r.has(e)||++o>Xe)return c();r.add(e);const i=u(t);i&&(n={...i,...n??{}}),t=s(e)}return n?null===t||"object"!=typeof t||Array.isArray(t)?t:{...t,...n}:t}function u(e){let t;for(const r of Object.keys(e))"$ref"===r||Je.has(r)||((t??={})[r]=e[r]);return t}function c(){return{type:"object",[Ke]:!0}}function l(e,t,o,i){if(null===e||"object"!=typeof e)return e;if(t>r)return{type:"object"};if(++i.nodes>n)return{type:"object"};let s;try{s=a(e)}catch(e){if("EXTERNAL_REF"===e?.code)throw e;return{type:"object"}}if(null===s||"object"!=typeof s)return s;if(s[Ke])return{type:"object"};if(o.has(s))return{type:"object"};o.add(s);try{if(Array.isArray(s)){const e=new Array(s.length);for(let r=0;r<s.length;r+=1)e[r]=l(s[r],t+1,o,i);return e}const e={};for(const r of Object.keys(s))Je.has(r)||(e[r]=l(s[r],t+1,o,i));return e}finally{o.delete(s)}}function f(e){return l(e,0,new Set,{nodes:0})}return{deref:a,deepDeref:function(e){const t=null!==e&&"object"==typeof e?e.$ref:void 0,r="string"==typeof t&&1===Object.keys(e).length;if(r&&o.has(t))return O(o.get(t));const n=f(e);return r?(o.set(t,n),O(n)):n},byPointer:s}}function Qe(e,t){const r="number"==typeof e?e:Number(e);return!Number.isFinite(r)||r<=0?t:Math.floor(r)}var Ye=["get","put","post","delete","options","head","patch","trace","query"];function et(e,t){if(!e||"object"!=typeof e||Array.isArray(e))throw T("BAD_SPEC","spec must be an object");if("string"!=typeof e.openapi||!e.openapi.trim())throw T("BAD_SPEC","spec.openapi version string is required");if(!t||"object"!=typeof t)throw T("BAD_TARGET","target is required");const r=Ze(e),n=e.paths;if(!n||"object"!=typeof n||Array.isArray(n))throw T("BAD_SPEC","spec.paths is missing or invalid");const o=function(e,t){const r=[];for(const[n,o]of Object.entries(e)){if(n.startsWith("x-"))continue;let e;try{e=t.deref(o)}catch{continue}if(!e||"object"!=typeof e||Array.isArray(e))continue;for(const t of Ye){const o=e[t];o&&"object"==typeof o&&!Array.isArray(o)&&r.push({path:n,method:t,rawOperation:o,pathItem:e,isCustomMethod:!1})}const i=e.additionalOperations;if(i&&"object"==typeof i&&!Array.isArray(i))for(const[t,o]of Object.entries(i))o&&"object"==typeof o&&!Array.isArray(o)&&r.push({path:n,method:t.toLowerCase(),rawOperation:o,pathItem:e,isCustomMethod:!0,customMethodKey:t})}return r}(n,r);if(!o.length)throw T("EMPTY_SPEC","The document does not declare any operation");const i=t.operationId?function(e,t,r){const n=e.filter(e=>{try{return t.deref(e.rawOperation)?.operationId===r}catch{return!1}});if(!n.length)throw T("OP_NOT_FOUND",`operationId "${r}" was not found`,{available:tt(e,t)});if(n.length>1)throw T("AMBIGUOUS_OPERATION_ID",`operationId "${r}" is declared ${n.length} times`,{matches:n.map(e=>`${e.method.toUpperCase()} ${e.path}`)});return n[0]}(o,r,t.operationId):function(e,t){if(!t.path||!t.method)throw T("BAD_TARGET","Provide either operationId, or both path and method");const r=String(t.method).toLowerCase(),n=String(t.path),o=[n,n.startsWith("/")?n.slice(1):`/${n}`];for(const t of o){const n=e.find(e=>e.path===t&&e.method===r);if(n)return n}throw T("OP_NOT_FOUND",`Operation "${String(t.method).toUpperCase()} ${n}" was not found`,{available:e.map(e=>`${e.method.toUpperCase()} ${e.path}`).slice(0,50)})}(o,t),s=r.deepDeref(i.rawOperation)??{},a=i.pathItem??{};return{path:i.path,method:i.method,isCustomMethod:i.isCustomMethod,...i.customMethodKey?{customMethodKey:i.customMethodKey}:{},operation:s,pathItem:a,parameters:rt(r,a,s),servers:nt(e,a,s),security:Array.isArray(s.security)?s.security:Array.isArray(e.security)?e.security:void 0}}function tt(e,t){const r=new Set;for(const n of e)try{const e=t.deref(n.rawOperation)?.operationId;"string"==typeof e&&e&&r.add(e)}catch{}return Array.from(r).slice(0,50)}function rt(e,t,r){const n=new Map,o=t=>{if(Array.isArray(t))for(const r of t){let t;try{t=e.deepDeref(r)}catch{continue}t&&"object"==typeof t&&"string"==typeof t.name&&t.name.length>0&&"string"==typeof t.in&&n.set(`${t.in.toLowerCase()}:${t.name}`,t)}};return o(t?.parameters),o(r?.parameters),Array.from(n.values())}function nt(e,t,r){const n=e=>{if(!Array.isArray(e))return;const t=e.filter(e=>e&&"object"==typeof e&&"string"==typeof e.url&&e.url.length>0);return t.length?t:void 0};return n(r?.servers)??n(t?.servers)??n(e?.servers)??[{url:"/"}]}var ot=class{name="http";supports(e){const t=e.located.operation?.["x-protocol"];return"string"==typeof t&&"http"!==t&&"sse"!==t?0:1}plan(e){const t=ge(e.located,e.spec,e.options);return{...t,environment:J(`${e.spec?.info?.title??"API"} Environment`,t.baseUrl,e.options.variables),streaming:G(e.located.operation,e.options.values)}}execute(e,t,r){return Le({collectionJson:e.collection,baseUrl:e.baseUrl,streamingHint:e.streaming},t,r)}};
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { L as LocatedOperation, E as ExecuteContext, P as ProtocolAdapter, A as AdapterContext } from '../../protocol-Dh-wN2nY.cjs';
|
|
2
|
+
export { l as locateOperation } from '../../protocol-Dh-wN2nY.cjs';
|
|
3
|
+
import { a as SendOptions, av as StreamEvent, an as RuntimeRunOptions, E as ExecResult } from '../../types-C9ifzKqk.cjs';
|
|
4
|
+
|
|
5
|
+
interface BuiltCollection {
|
|
6
|
+
collection: Record<string, any>;
|
|
7
|
+
baseUrl: string;
|
|
8
|
+
contentType?: string;
|
|
9
|
+
isCustomMethod: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Non-fatal problems detected while building the request, such as a required
|
|
12
|
+
* path value that had to be synthesized. Surfaced so callers can log them
|
|
13
|
+
* instead of debugging a silently malformed URL.
|
|
14
|
+
*/
|
|
15
|
+
warnings: string[];
|
|
16
|
+
}
|
|
17
|
+
declare function buildCollection(located: LocatedOperation, spec: any, options: SendOptions): BuiltCollection;
|
|
18
|
+
|
|
19
|
+
interface ResolverOptions {
|
|
20
|
+
/** Maximum expansion depth. Defaults to 32. */
|
|
21
|
+
maxDepth?: number;
|
|
22
|
+
/** Maximum nodes produced by a single deepDeref call. Defaults to 200000. */
|
|
23
|
+
maxNodes?: number;
|
|
24
|
+
}
|
|
25
|
+
interface Resolver {
|
|
26
|
+
/** Resolve only the top-level $ref chain, keeping sibling keys. */
|
|
27
|
+
deref<T = any>(node: any): T;
|
|
28
|
+
/** Fully expand a subtree, collapsing cycles into a generic object schema. */
|
|
29
|
+
deepDeref(node: any): any;
|
|
30
|
+
/** Resolve a local JSON pointer against the document root. */
|
|
31
|
+
byPointer(pointer: string): any;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Resolver for local JSON pointers. External references are rejected explicitly
|
|
35
|
+
* rather than silently producing an empty schema.
|
|
36
|
+
*
|
|
37
|
+
* Results handed back by `deepDeref` are always freshly owned by the caller, so
|
|
38
|
+
* mutating them can never corrupt the resolver cache or the source document.
|
|
39
|
+
*/
|
|
40
|
+
declare function createResolver(root: any, options?: ResolverOptions): Resolver;
|
|
41
|
+
|
|
42
|
+
interface ResolveServerOptions {
|
|
43
|
+
/** Index into the server list. Defaults to 0. */
|
|
44
|
+
serverIndex?: number;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Resolve the effective base URL, expanding OpenAPI server variables.
|
|
48
|
+
*
|
|
49
|
+
* A relative server URL (`/` or `/v1`) cannot be used to make a real request,
|
|
50
|
+
* so it is rejected with an actionable error rather than producing a
|
|
51
|
+
* protocol-relative URL that silently resolves to the wrong host.
|
|
52
|
+
*/
|
|
53
|
+
declare function resolveServerUrl(servers: any[], options: SendOptions & ResolveServerOptions): string;
|
|
54
|
+
interface BuildEnvironmentOptions {
|
|
55
|
+
/** Mark values whose key looks like a credential as secret. Defaults to true. */
|
|
56
|
+
maskSecrets?: boolean;
|
|
57
|
+
/** Allow `variables.baseUrl` to override the resolved base URL. Defaults to false. */
|
|
58
|
+
allowBaseUrlOverride?: boolean;
|
|
59
|
+
}
|
|
60
|
+
declare function buildEnvironment(name: string, baseUrl: string, variables?: Record<string, string>, options?: BuildEnvironmentOptions): Record<string, any>;
|
|
61
|
+
|
|
62
|
+
interface SseParserOptions {
|
|
63
|
+
/**
|
|
64
|
+
* Maximum characters buffered while waiting for an event boundary. A peer that
|
|
65
|
+
* never terminates an event would otherwise grow the buffer without bound.
|
|
66
|
+
* Defaults to 4 Mi characters.
|
|
67
|
+
*/
|
|
68
|
+
maxBufferChars?: number;
|
|
69
|
+
/** Maximum characters retained in a single event's `data`. Defaults to 1 Mi. */
|
|
70
|
+
maxEventChars?: number;
|
|
71
|
+
/**
|
|
72
|
+
* Attach the last seen `id` to events that omit one. Defaults to true.
|
|
73
|
+
*
|
|
74
|
+
* The specification uses the last event id only for the `Last-Event-ID`
|
|
75
|
+
* header on reconnect, not as a property of subsequent events. Inheriting it
|
|
76
|
+
* is convenient when debugging, but it makes `id` look universally present to
|
|
77
|
+
* schema inference. Set to false for a spec-faithful stream.
|
|
78
|
+
*/
|
|
79
|
+
inheritEventId?: boolean;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Incremental Server-Sent Events parser following the WHATWG event stream rules.
|
|
83
|
+
* postman-runtime usually hands over complete events, but chunk boundaries are
|
|
84
|
+
* not guaranteed, so buffering is still required.
|
|
85
|
+
*
|
|
86
|
+
* The parser is deliberately defensive about size: the peer controls how much
|
|
87
|
+
* data arrives before a boundary appears, so both the pending buffer and any
|
|
88
|
+
* single event are capped instead of growing until the process runs out of memory.
|
|
89
|
+
*/
|
|
90
|
+
declare class SseParser {
|
|
91
|
+
private buffer;
|
|
92
|
+
private readonly decoder;
|
|
93
|
+
private lastEventId;
|
|
94
|
+
private bomChecked;
|
|
95
|
+
private overflowed;
|
|
96
|
+
private sequence;
|
|
97
|
+
private readonly maxBufferChars;
|
|
98
|
+
private readonly maxEventChars;
|
|
99
|
+
private readonly inheritEventId;
|
|
100
|
+
/** Number of events or blocks discarded because a size cap was exceeded. */
|
|
101
|
+
droppedEvents: number;
|
|
102
|
+
constructor(options?: SseParserOptions);
|
|
103
|
+
/** True once a size cap forced data to be discarded. */
|
|
104
|
+
get truncated(): boolean;
|
|
105
|
+
/** Number of events emitted so far. */
|
|
106
|
+
get count(): number;
|
|
107
|
+
/** Feed a chunk and return every complete event it produced. */
|
|
108
|
+
push(chunk: Buffer | Uint8Array | string): StreamEvent[];
|
|
109
|
+
/** Emit whatever remains once the stream has ended. */
|
|
110
|
+
flush(): StreamEvent[];
|
|
111
|
+
reset(): void;
|
|
112
|
+
/** Consume every complete block currently in the buffer. */
|
|
113
|
+
private drain;
|
|
114
|
+
private parseBlock;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
interface BuildRunOptionsInput {
|
|
118
|
+
baseUrl: string;
|
|
119
|
+
/** True when the operation is expected to stream, which relaxes the global timeout. */
|
|
120
|
+
streaming: boolean;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Compose the final postman-runtime options object.
|
|
124
|
+
*
|
|
125
|
+
* Precedence, lowest to highest:
|
|
126
|
+
* 1. Library defaults
|
|
127
|
+
* 2. Convenience fields on SendOptions (timeout, maxStreamMs, variables, ...)
|
|
128
|
+
* 3. `options.runner` — every documented runtime option, passed straight through
|
|
129
|
+
*
|
|
130
|
+
* Variable scopes are only synthesized when the caller did not supply one.
|
|
131
|
+
*/
|
|
132
|
+
declare function buildRunOptions(options: SendOptions, input: BuildRunOptionsInput): RuntimeRunOptions;
|
|
133
|
+
|
|
134
|
+
/** Why sampling ended, surfaced on the result so callers can distinguish causes. */
|
|
135
|
+
type StopReason = "maxEvents" | "maxStreamMs" | "maxResponseSize" | "aborted" | "hardTimeout";
|
|
136
|
+
interface RunInput {
|
|
137
|
+
collectionJson: any;
|
|
138
|
+
baseUrl: string;
|
|
139
|
+
/** Derived from the spec; the live content-type still has the final say. */
|
|
140
|
+
streamingHint: boolean;
|
|
141
|
+
}
|
|
142
|
+
declare function runWithPostman(input: RunInput, options: SendOptions, ctx?: ExecuteContext): Promise<ExecResult>;
|
|
143
|
+
|
|
144
|
+
interface HttpPlan extends BuiltCollection {
|
|
145
|
+
environment: Record<string, any>;
|
|
146
|
+
streaming: boolean;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Default adapter for HTTP and Server-Sent Events.
|
|
150
|
+
* Both share a single postman-runtime execution path so that scripts,
|
|
151
|
+
* variable scopes, cookies and auth helpers behave identically.
|
|
152
|
+
*/
|
|
153
|
+
declare class HttpAdapter implements ProtocolAdapter<HttpPlan> {
|
|
154
|
+
readonly name = "http";
|
|
155
|
+
/** Lowest priority: acts as the fallback when no other adapter claims the operation. */
|
|
156
|
+
supports(ctx: AdapterContext): number;
|
|
157
|
+
plan(ctx: AdapterContext): HttpPlan;
|
|
158
|
+
execute(plan: HttpPlan, options: SendOptions, ctx?: ExecuteContext): Promise<ExecResult>;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export { HttpAdapter, type HttpPlan, type RunInput, SseParser, type StopReason, buildCollection, buildEnvironment, buildRunOptions, createResolver, resolveServerUrl, runWithPostman };
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { L as LocatedOperation, E as ExecuteContext, P as ProtocolAdapter, A as AdapterContext } from '../../protocol-D7sEx8IP.js';
|
|
2
|
+
export { l as locateOperation } from '../../protocol-D7sEx8IP.js';
|
|
3
|
+
import { a as SendOptions, av as StreamEvent, an as RuntimeRunOptions, E as ExecResult } from '../../types-C9ifzKqk.js';
|
|
4
|
+
|
|
5
|
+
interface BuiltCollection {
|
|
6
|
+
collection: Record<string, any>;
|
|
7
|
+
baseUrl: string;
|
|
8
|
+
contentType?: string;
|
|
9
|
+
isCustomMethod: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Non-fatal problems detected while building the request, such as a required
|
|
12
|
+
* path value that had to be synthesized. Surfaced so callers can log them
|
|
13
|
+
* instead of debugging a silently malformed URL.
|
|
14
|
+
*/
|
|
15
|
+
warnings: string[];
|
|
16
|
+
}
|
|
17
|
+
declare function buildCollection(located: LocatedOperation, spec: any, options: SendOptions): BuiltCollection;
|
|
18
|
+
|
|
19
|
+
interface ResolverOptions {
|
|
20
|
+
/** Maximum expansion depth. Defaults to 32. */
|
|
21
|
+
maxDepth?: number;
|
|
22
|
+
/** Maximum nodes produced by a single deepDeref call. Defaults to 200000. */
|
|
23
|
+
maxNodes?: number;
|
|
24
|
+
}
|
|
25
|
+
interface Resolver {
|
|
26
|
+
/** Resolve only the top-level $ref chain, keeping sibling keys. */
|
|
27
|
+
deref<T = any>(node: any): T;
|
|
28
|
+
/** Fully expand a subtree, collapsing cycles into a generic object schema. */
|
|
29
|
+
deepDeref(node: any): any;
|
|
30
|
+
/** Resolve a local JSON pointer against the document root. */
|
|
31
|
+
byPointer(pointer: string): any;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Resolver for local JSON pointers. External references are rejected explicitly
|
|
35
|
+
* rather than silently producing an empty schema.
|
|
36
|
+
*
|
|
37
|
+
* Results handed back by `deepDeref` are always freshly owned by the caller, so
|
|
38
|
+
* mutating them can never corrupt the resolver cache or the source document.
|
|
39
|
+
*/
|
|
40
|
+
declare function createResolver(root: any, options?: ResolverOptions): Resolver;
|
|
41
|
+
|
|
42
|
+
interface ResolveServerOptions {
|
|
43
|
+
/** Index into the server list. Defaults to 0. */
|
|
44
|
+
serverIndex?: number;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Resolve the effective base URL, expanding OpenAPI server variables.
|
|
48
|
+
*
|
|
49
|
+
* A relative server URL (`/` or `/v1`) cannot be used to make a real request,
|
|
50
|
+
* so it is rejected with an actionable error rather than producing a
|
|
51
|
+
* protocol-relative URL that silently resolves to the wrong host.
|
|
52
|
+
*/
|
|
53
|
+
declare function resolveServerUrl(servers: any[], options: SendOptions & ResolveServerOptions): string;
|
|
54
|
+
interface BuildEnvironmentOptions {
|
|
55
|
+
/** Mark values whose key looks like a credential as secret. Defaults to true. */
|
|
56
|
+
maskSecrets?: boolean;
|
|
57
|
+
/** Allow `variables.baseUrl` to override the resolved base URL. Defaults to false. */
|
|
58
|
+
allowBaseUrlOverride?: boolean;
|
|
59
|
+
}
|
|
60
|
+
declare function buildEnvironment(name: string, baseUrl: string, variables?: Record<string, string>, options?: BuildEnvironmentOptions): Record<string, any>;
|
|
61
|
+
|
|
62
|
+
interface SseParserOptions {
|
|
63
|
+
/**
|
|
64
|
+
* Maximum characters buffered while waiting for an event boundary. A peer that
|
|
65
|
+
* never terminates an event would otherwise grow the buffer without bound.
|
|
66
|
+
* Defaults to 4 Mi characters.
|
|
67
|
+
*/
|
|
68
|
+
maxBufferChars?: number;
|
|
69
|
+
/** Maximum characters retained in a single event's `data`. Defaults to 1 Mi. */
|
|
70
|
+
maxEventChars?: number;
|
|
71
|
+
/**
|
|
72
|
+
* Attach the last seen `id` to events that omit one. Defaults to true.
|
|
73
|
+
*
|
|
74
|
+
* The specification uses the last event id only for the `Last-Event-ID`
|
|
75
|
+
* header on reconnect, not as a property of subsequent events. Inheriting it
|
|
76
|
+
* is convenient when debugging, but it makes `id` look universally present to
|
|
77
|
+
* schema inference. Set to false for a spec-faithful stream.
|
|
78
|
+
*/
|
|
79
|
+
inheritEventId?: boolean;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Incremental Server-Sent Events parser following the WHATWG event stream rules.
|
|
83
|
+
* postman-runtime usually hands over complete events, but chunk boundaries are
|
|
84
|
+
* not guaranteed, so buffering is still required.
|
|
85
|
+
*
|
|
86
|
+
* The parser is deliberately defensive about size: the peer controls how much
|
|
87
|
+
* data arrives before a boundary appears, so both the pending buffer and any
|
|
88
|
+
* single event are capped instead of growing until the process runs out of memory.
|
|
89
|
+
*/
|
|
90
|
+
declare class SseParser {
|
|
91
|
+
private buffer;
|
|
92
|
+
private readonly decoder;
|
|
93
|
+
private lastEventId;
|
|
94
|
+
private bomChecked;
|
|
95
|
+
private overflowed;
|
|
96
|
+
private sequence;
|
|
97
|
+
private readonly maxBufferChars;
|
|
98
|
+
private readonly maxEventChars;
|
|
99
|
+
private readonly inheritEventId;
|
|
100
|
+
/** Number of events or blocks discarded because a size cap was exceeded. */
|
|
101
|
+
droppedEvents: number;
|
|
102
|
+
constructor(options?: SseParserOptions);
|
|
103
|
+
/** True once a size cap forced data to be discarded. */
|
|
104
|
+
get truncated(): boolean;
|
|
105
|
+
/** Number of events emitted so far. */
|
|
106
|
+
get count(): number;
|
|
107
|
+
/** Feed a chunk and return every complete event it produced. */
|
|
108
|
+
push(chunk: Buffer | Uint8Array | string): StreamEvent[];
|
|
109
|
+
/** Emit whatever remains once the stream has ended. */
|
|
110
|
+
flush(): StreamEvent[];
|
|
111
|
+
reset(): void;
|
|
112
|
+
/** Consume every complete block currently in the buffer. */
|
|
113
|
+
private drain;
|
|
114
|
+
private parseBlock;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
interface BuildRunOptionsInput {
|
|
118
|
+
baseUrl: string;
|
|
119
|
+
/** True when the operation is expected to stream, which relaxes the global timeout. */
|
|
120
|
+
streaming: boolean;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Compose the final postman-runtime options object.
|
|
124
|
+
*
|
|
125
|
+
* Precedence, lowest to highest:
|
|
126
|
+
* 1. Library defaults
|
|
127
|
+
* 2. Convenience fields on SendOptions (timeout, maxStreamMs, variables, ...)
|
|
128
|
+
* 3. `options.runner` — every documented runtime option, passed straight through
|
|
129
|
+
*
|
|
130
|
+
* Variable scopes are only synthesized when the caller did not supply one.
|
|
131
|
+
*/
|
|
132
|
+
declare function buildRunOptions(options: SendOptions, input: BuildRunOptionsInput): RuntimeRunOptions;
|
|
133
|
+
|
|
134
|
+
/** Why sampling ended, surfaced on the result so callers can distinguish causes. */
|
|
135
|
+
type StopReason = "maxEvents" | "maxStreamMs" | "maxResponseSize" | "aborted" | "hardTimeout";
|
|
136
|
+
interface RunInput {
|
|
137
|
+
collectionJson: any;
|
|
138
|
+
baseUrl: string;
|
|
139
|
+
/** Derived from the spec; the live content-type still has the final say. */
|
|
140
|
+
streamingHint: boolean;
|
|
141
|
+
}
|
|
142
|
+
declare function runWithPostman(input: RunInput, options: SendOptions, ctx?: ExecuteContext): Promise<ExecResult>;
|
|
143
|
+
|
|
144
|
+
interface HttpPlan extends BuiltCollection {
|
|
145
|
+
environment: Record<string, any>;
|
|
146
|
+
streaming: boolean;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Default adapter for HTTP and Server-Sent Events.
|
|
150
|
+
* Both share a single postman-runtime execution path so that scripts,
|
|
151
|
+
* variable scopes, cookies and auth helpers behave identically.
|
|
152
|
+
*/
|
|
153
|
+
declare class HttpAdapter implements ProtocolAdapter<HttpPlan> {
|
|
154
|
+
readonly name = "http";
|
|
155
|
+
/** Lowest priority: acts as the fallback when no other adapter claims the operation. */
|
|
156
|
+
supports(ctx: AdapterContext): number;
|
|
157
|
+
plan(ctx: AdapterContext): HttpPlan;
|
|
158
|
+
execute(plan: HttpPlan, options: SendOptions, ctx?: ExecuteContext): Promise<ExecResult>;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export { HttpAdapter, type HttpPlan, type RunInput, SseParser, type StopReason, buildCollection, buildEnvironment, buildRunOptions, createResolver, resolveServerUrl, runWithPostman };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=new Set(["__proto__","constructor","prototype"]),t="2024-01-01T00:00:00.000Z";function r(e,c=0,u={}){const l=u.maxDepth??12;if(!e||"object"!=typeof e||Array.isArray(e))return null;if(c>l)return null;if("string"==typeof e.$ref)return null;if(void 0!==e.example)return e.example;const f=function(e){if(null==e)return;if(Array.isArray(e))return e.length?e[0]:void 0;if("object"==typeof e)for(const t of Object.values(e))if(void 0!==t){if(t&&"object"==typeof t){if("value"in t)return t.value;if("externalValue"in t)continue}return t}return}(e.examples);if(void 0!==f)return f;if(void 0!==e.default)return e.default;if(void 0!==e.const)return e.const;if(Array.isArray(e.enum)&&e.enum.length){const t=e.enum.find(e=>null!==e);return void 0!==t?t:e.enum[0]}if(Array.isArray(e.allOf)&&e.allOf.length)return function(e,t,o){let i,s;for(const n of e.allOf){const e=r(n,t+1,o);null===e||"object"!=typeof e||Array.isArray(e)?null!=e&&(s=e):i={...i??{},...e}}if(e.properties||e.required){const r=n(e,t,o);r&&"object"==typeof r&&(i={...i??{},...r})}return i||(void 0!==s?s:{})}(e,c,u);for(const t of["oneOf","anyOf"]){const n=e[t];if(Array.isArray(n)&&n.length){return r(n.find(e=>e&&"object"==typeof e&&"null"!==e.type)??n[0],c+1,u)}}const p=function(e){const t=Array.isArray(e.type)?e.type.find(e=>"string"==typeof e&&"null"!==e)??(e.type.includes("null")?"null":void 0):"string"==typeof e.type?e.type:void 0;if(t)return t;if(e.properties||e.additionalProperties||e.required)return"object";if(e.items||e.prefixItems)return"array";if(void 0!==e.minimum||void 0!==e.maximum||void 0!==e.multipleOf)return"number";return"string"}(e);switch(p){case"object":return n(e,c,u);case"array":return function(e,t,n){const o=[];if(Array.isArray(e.prefixItems))for(const i of e.prefixItems)o.push(r(i,t+1,n));const i=a(e.minItems)??1,s=a(e.maxItems);let c=Math.max(i,o.length,1);c=Math.min(c,5),void 0!==s&&(c=Math.min(c,Math.max(s,0)));const u=e.items&&"object"==typeof e.items?e.items:void 0;if(!u&&Array.isArray(e.prefixItems))return o.slice(0,0===c?0:Math.max(c,o.length));for(;o.length<c;){const i=r(u??{},t+1,n);if(!0===e.uniqueItems&&o.length>0)break;o.push(i)}return void 0!==s?o.slice(0,Math.max(s,0)):o}(e,c,u);case"integer":return function(e){const{min:t,max:r}=o(e,!0);let n=0;void 0!==t&&n<t&&(n=Math.ceil(t));void 0!==r&&n>r&&(n=Math.floor(r));const i=s(e.multipleOf);if(void 0!==i&&i>0){const e=Math.ceil(n/i)*i;(void 0===r||e<=r)&&(n=e)}return Math.trunc(n)}(e);case"number":return function(e){const{min:t,max:r}=o(e,!1);let n=0;void 0!==t&&n<t&&(n=t);void 0!==r&&n>r&&(n=r);const i=s(e.multipleOf);if(void 0!==i&&i>0){const e=Math.ceil(n/i)*i;(void 0===r||e<=r)&&(n=e)}return n}(e);case"boolean":return!1;case"null":return null;default:return function(e){const r="string"==typeof e.format?e.format:void 0,n=r?function(e){switch(e){case"date-time":return t;case"date":return t.slice(0,10);case"time":return t.slice(11,19);case"duration":return"PT1S";case"uuid":return"00000000-0000-4000-8000-000000000000";case"email":case"idn-email":return"user@example.com";case"hostname":case"idn-hostname":return"example.com";case"ipv4":return"127.0.0.1";case"ipv6":return"::1";case"uri":case"url":case"iri":return"https://example.com";case"uri-reference":case"iri-reference":case"json-pointer":return"/example";case"uri-template":return"https://example.com/{id}";case"relative-json-pointer":return"0/example";case"regex":return"^example$";case"byte":return"ZXhhbXBsZQ==";case"binary":return"";case"password":return"password";default:return}}(r):void 0;return void 0!==n?i(n,e):"string"==typeof e.pattern&&e.pattern.length?"":i("string",e)}(e)}}function n(t,n,o){const i={},s=Array.isArray(t.required)?t.required.filter(e=>"string"==typeof e):[],c=t.properties&&"object"==typeof t.properties?t.properties:{},u=!0===o.includeReadOnly,l=!1!==o.includeWriteOnly;for(const[t,a]of Object.entries(c))e.has(t)||!u&&a&&!0===a.readOnly||!l&&a&&!0===a.writeOnly||n>2&&s.length&&!s.includes(t)||(i[t]=r(a,n+1,o));for(const t of s)e.has(t)||t in i||(i[t]=r(c[t]??{},n+1,o));!Object.keys(i).length&&t.additionalProperties&&"object"==typeof t.additionalProperties&&(i.key=r(t.additionalProperties,n+1,o));const f=a(t.minProperties);if(void 0!==f){const e=t.additionalProperties&&"object"==typeof t.additionalProperties?t.additionalProperties:{};let s=1;for(;Object.keys(i).length<Math.min(f,20);){const t=`additionalProp${s}`;s+=1,t in i||(i[t]=r(e,n+1,o))}}return i}function o(e,t){const r=t?1:Number.EPSILON>0?1e-6:1;let n=s(e.minimum),o=s(e.maximum);const i=e.exclusiveMinimum,a=e.exclusiveMaximum;if("number"==typeof i&&Number.isFinite(i)){const e=i+r;n=void 0===n?e:Math.max(n,e)}else!0===i&&void 0!==n&&(n+=r);if("number"==typeof a&&Number.isFinite(a)){const e=a-r;o=void 0===o?e:Math.min(o,e)}else!0===a&&void 0!==o&&(o-=r);return{min:n,max:o}}function i(e,t){const r=a(t.minLength),n=a(t.maxLength);let o=e;return void 0!==r&&o.length<r&&(o=o.padEnd(Math.min(r,256),"x")),void 0!==n&&o.length>n&&(o=o.slice(0,Math.max(n,0))),o}function s(e){if("number"==typeof e&&Number.isFinite(e))return e}function a(e){const t=s(e);if(void 0===t)return;const r=Math.floor(t);return r<0?0:r}var c=new Set(["__proto__","constructor","prototype"]);function u(e){return c.has(e)}function l(e){if(null===e||"object"!=typeof e)return e;if("function"==typeof globalThis.structuredClone)try{return globalThis.structuredClone(e)}catch{}return f(e)}function f(e){return p(e,new Set)}function p(e,t){if(null===e)return null;const r=typeof e;if("string"===r||"boolean"===r)return e;if("number"===r)return Number.isFinite(e)?e:null;if("bigint"===r)return e.toString();if("object"!==r)return;const n=e;if(t.has(n))return null;const o=n.toJSON;if("function"==typeof o){let e;try{e=o.call(n)}catch{return null}return e===n?null:p(e,t)}t.add(n);try{if(Array.isArray(n)){const e=new Array(n.length);for(let r=0;r<n.length;r+=1){const o=p(n[r],t);e[r]=void 0===o?null:o}return e}const e={};for(const r of Object.keys(n)){if(u(r))continue;let o;try{o=n[r]}catch{continue}const i=p(o,t);void 0!==i&&(e[r]=i)}return e}finally{t.delete(n)}}function d(e,t){return m(e,t,0)}function m(e,t,r){if(!t||!h(t))return e;if(r>=64)return t;const n={...e};for(const e of Object.keys(t)){if(u(e))continue;const o=t[e];if(void 0===o)continue;const i=n[e];h(i)&&h(o)?n[e]=m(i,o,r+1):n[e]=o}return n}function h(e){if(null===e||"object"!=typeof e||Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function y(e){if(e)try{clearTimeout(e)}catch{}return null}function g(e,t,r=Number.MAX_SAFE_INTEGER){const n="number"==typeof e?e:Number(e);if(!Number.isFinite(n))return t;const o=Math.floor(n);return o<=0?t:Math.min(o,r)}var b=/(token|secret|password|passwd|apikey|api_key|credential|private|authorization)/i;function v(e){return b.test(e)}var A=Symbol.for("@powerduck/openapi-request.ProtoKitError"),w=class e extends Error{code;details;[A]=!0;constructor(t,r,n,o){if(super(t),this.name="ProtoKitError",this.code="string"==typeof r&&r?r:"UNKNOWN",this.details=n,o&&"cause"in o)try{Object.defineProperty(this,"cause",{value:o.cause,configurable:!0,writable:!0,enumerable:!1})}catch{}Object.setPrototypeOf(this,e.prototype),"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,e)}static isProtoKitError(e){return"object"==typeof e&&null!==e&&!0===e[A]}toJSON(){return{name:this.name,code:this.code,message:this.message,...void 0===this.details?{}:{details:this.details}}}};function j(e,t,r,n){return new w(t,e,r,n)}function x(e){const t=typeof e;if(null===e)return"null";if("undefined"===t)return"undefined";if("function"===t){const t=e.name;return t?`[Function: ${t}]`:"[Function (anonymous)]"}if("symbol"===t)return String(e);if("bigint"===t)return`${String(e)}n`;try{const t=JSON.stringify(e);if("string"==typeof t)return t}catch{}try{return String(e)}catch{return"[unserializable value]"}}function S(e){if(w.isProtoKitError(e))return{message:e.message||"Unknown ProtoKitError",code:e.code,name:e.name};if(e instanceof Error){const t=e.code,r="string"==typeof t||"number"==typeof t?String(t):void 0;return{message:e.message||e.name||"Unknown error",...r?{code:r}:{},name:e.name||"Error"}}if("object"==typeof e&&null!==e&&"string"==typeof e.message){const t=e,r="string"==typeof t.code||"number"==typeof t.code?String(t.code):void 0;return{message:t.message||"Unknown error",...r?{code:r}:{},..."string"==typeof t.name?{name:t.name}:{}}}return"string"==typeof e?{message:e||"Unknown error"}:{message:x(e)}}var O="\0PK_OPEN\0",k="\0PK_CLOSE\0",$=0;function E(e){$=($+1)%65535;const t=Date.now().toString(36),r=Math.floor(65535*Math.random()).toString(36);return`${e}-${t}-${$.toString(36)}${r}`}function _(e,t){const r="string"==typeof t.serverUrl?t.serverUrl.trim():"";if(r)return R(C(r),"options.serverUrl");const n=Array.isArray(e)?e.filter(h):[],o=n[Number.isInteger(t.serverIndex)?Math.max(0,t.serverIndex):0]??n[0];let i=o&&"string"==typeof o.url&&o.url.trim()?o.url.trim():"";if(!i)throw j("NO_SERVER_URL","The document declares no usable server URL. Pass options.serverUrl to specify one.");return i=function(e,t,r){const n=h(t)?t:{};let o=e;for(const[e,t]of Object.entries(n)){const n=r?.[e];let i;if(null!=n){if(i=n,Array.isArray(t?.enum)&&t.enum.length&&!t.enum.some(e=>String(e)===String(n)))throw j("BAD_SERVER_VARIABLE",`Server variable "${e}" must be one of: ${t.enum.join(", ")}`,{provided:n,allowed:t.enum})}else if(void 0!==t?.default)i=t.default;else{if(!Array.isArray(t?.enum)||!t.enum.length)throw j("BAD_SERVER_VARIABLE",`Server variable "${e}" has no default; pass serverVariables["${e}"].`);i=t.enum[0]}o=o.split(`{${e}}`).join(String(i??""))}for(const[e,t]of Object.entries(r??{}))Object.prototype.hasOwnProperty.call(n,e)||null!=t&&(o=o.split(`{${e}}`).join(String(t)));return o}(i,o?.variables,t.serverVariables),R(C(i),"spec.servers")}function C(e){return e.replace(/\/+$/,"")||e}function R(e,t){const r=function(e){return-1===e.indexOf("{")?e:e.split("{{").join(O).split("}}").join(k).replace(/\{[^{}]*\}/g,"").split(O).join("{{").split(k).join("}}")}(e);if(!r)throw j("BAD_SERVER_URL",`${t} resolved to an empty URL`);if(r.includes("{{"))return r;if(!/^[a-z][a-z0-9+.-]*:\/\//i.test(r))throw j("RELATIVE_SERVER_URL",`${t} resolved to the relative URL "${r}". A request needs an absolute origin; pass options.serverUrl.`,{url:r});return r}function N(e,t,r={},n={}){const o=!1!==n.maskSecrets,i=!0===n.allowBaseUrlOverride,s=h(r)?r:{},a=[],c=new Set,u=(e,t,r)=>{"string"==typeof e&&e&&(c.has(e)||(c.add(e),a.push({key:e,value:null==t?"":String(t),type:r,enabled:!0})))};i||u("baseUrl",t,"default");for(const[e,t]of Object.entries(s))u(e,t,o&&v(e)?"secret":"default");return i&&u("baseUrl",t,"default"),{id:E("protokit-env"),name:"string"==typeof e&&e.trim()?e:"protokit",values:a,_postman_variable_scope:"environment",_postman_exported_at:(new Date).toISOString()}}var M=["text/event-stream","application/json-seq","application/x-ndjson","application/ndjson","application/jsonl","application/x-jsonlines"];function q(e){return"default"!==e&&(!!/^2\d\d$/.test(e)||/^2xx$/i.test(e))}function I(e,t){const r=function(e){if(h(e?.header))for(const[t,r]of Object.entries(e.header))if("accept"===t.toLowerCase())return"string"==typeof r?r:Array.isArray(r)?r.map(e=>String(e)).join(", "):null==r?void 0:String(r)}(t);if(r&&P(r))return!0;if(!h(e))return!1;const n=e["x-protocol"];if("string"==typeof n){const e=n.toLowerCase();if("sse"===e||"eventsource"===e)return!0;if("websocket"===e||"grpc"===e)return!1}if(h(e["x-sse"]))return!0;const o=e.responses;if(!h(o))return!1;for(const[e,t]of Object.entries(o)){if(e.startsWith("x-"))continue;if(!h(t))continue;const r=t.content;if(h(r))for(const[e,t]of Object.entries(r)){const r=e.toLowerCase();if(r.startsWith("text/event-stream"))return!0;if(h(t)&&void 0!==t.itemSchema&&M.some(e=>r.startsWith(e)))return!0}}return!1}function T(e){return"string"==typeof e&&/(^|[\s,;])text\/event-stream\b/i.test(e)}function P(e){if("string"!=typeof e||!e)return!1;return e.split(",").map(e=>e.split(";")[0].trim().toLowerCase()).filter(Boolean).some(e=>M.some(t=>e===t||e.startsWith(t)))}function U(e){if(!e)return[];return(Array.isArray(e)?e:[e]).filter(e=>h(e)&&("string"==typeof e.exec||Array.isArray(e.exec)))}function B(e,t,r){const n=[],o=new Set;return r.forEach((r,i)=>{const s=function(e){const t=(Array.isArray(e)?e.map(e=>"string"==typeof e?e:String(e??"")):String(e).split(/\r?\n/)).slice(0,2e3);let r=0;const n=[];for(const e of t){if(r+=e.length+1,r>2e5)break;n.push(e)}return n}(r.exec);if(!s.some(e=>e.trim().length>0))return;let a="string"==typeof r.id&&r.id.trim()?r.id.trim():`protokit-${t}-${e}-${i}`;for(;o.has(a);)a=`${a}-b`;o.add(a),n.push({listen:e,script:{id:a,type:"text/javascript",exec:s}})}),n}function D(e,t){const r=e?.["x-postman-scripts"];if(!h(r))return{pre:[],test:[]};const n=e=>{if(null==e)return[];if("string"==typeof e)return[{exec:e}];if(Array.isArray(e))return e.length?e.every(e=>"string"==typeof e)?[{exec:e}]:e.filter(e=>h(e)&&("string"==typeof e.exec||Array.isArray(e.exec))).slice(0,8):[];if(h(e)){const t=e;if("string"==typeof t.exec||Array.isArray(t.exec))return[t]}return[]},o="collection"===t?r.collectionPreRequest??r.preRequest??r.prerequest:r.preRequest??r.prerequest,i="collection"===t?r.collectionTest??r.test??r.tests:r.test??r.tests;return{pre:n(o).slice(0,8),test:n(i).slice(0,8)}}var L=new Set(["GET","PUT","POST","DELETE","OPTIONS","HEAD","PATCH","TRACE"]),z=/^(accept|content-type|authorization)$/i,F=0;function V(e){F=(F+1)%65535;const t=Date.now().toString(36),r=Math.floor(65535*Math.random()).toString(36);return`${e}-${t}-${F.toString(36)}${r}`}function W(e){return"string"==typeof e&&e.length?e:void 0}function K(e){const t=e.toLowerCase();return"application/json"===t?0:t.includes("json-seq")||t.includes("ndjson")?40:t.endsWith("+json")?10:t.includes("json")?20:t.includes("x-www-form-urlencoded")?30:t.includes("multipart/form-data")?35:50}function J(e){if(null==e)return"";const t=typeof e;if("string"===t)return e;if("number"===t||"boolean"===t||"bigint"===t)return String(e);if("object"===t)try{const t=JSON.stringify(e);return"string"==typeof t?t:""}catch{return""}return""}var H={spaceDelimited:" ",pipeDelimited:"|",form:",",simple:","};function X(e,t){const r=String(e.name),n=W(e.style)??"form",o="boolean"==typeof e.explode?e.explode:"form"===n||"deepObject"===n;if(Array.isArray(t)){if(!t.length)return[{key:r,value:""}];if(o&&"deepObject"!==n)return t.map(e=>({key:r,value:J(e)}));if("deepObject"===n)return t.map((e,t)=>({key:`${r}[${t}]`,value:J(e)}));const e=H[n]??",";return[{key:r,value:t.map(J).join(e)}]}if(h(t)){const e=Object.entries(t);return e.length?"deepObject"===n?e.map(([e,t])=>({key:`${r}[${e}]`,value:J(t)})):o?e.map(([e,t])=>({key:e,value:J(t)})):[{key:r,value:e.flatMap(([e,t])=>[e,J(t)]).join(",")}]:[{key:r,value:""}]}return[{key:r,value:J(t)}]}function G(e,t){const r=W(e.style)??"simple",n=!0===e.explode,o=String(e.name),i=(e,t)=>e.map(J).join(t);if("label"===r){if(Array.isArray(t))return`.${i(t,n?".":",")}`;if(h(t)){const e=Object.entries(t);return n?e.map(([e,t])=>`.${e}=${J(t)}`).join(""):`.${e.flatMap(([e,t])=>[e,J(t)]).join(",")}`}return`.${J(t)}`}if("matrix"===r){if(Array.isArray(t))return n?t.map(e=>`;${o}=${J(e)}`).join(""):`;${o}=${i(t,",")}`;if(h(t)){const e=Object.entries(t);return n?e.map(([e,t])=>`;${e}=${J(t)}`).join(""):`;${o}=${e.flatMap(([e,t])=>[e,J(t)]).join(",")}`}return`;${o}=${J(t)}`}if(Array.isArray(t))return i(t,",");if(h(t)){const e=Object.entries(t);return n?e.map(([e,t])=>`${e}=${J(t)}`).join(","):e.flatMap(([e,t])=>[e,J(t)]).join(",")}return J(t)}function Z(e,t){const r=!0===e.explode;if(Array.isArray(t))return t.map(J).join(",");if(h(t)){const e=Object.entries(t);return r?e.map(([e,t])=>`${e}=${J(t)}`).join(","):e.flatMap(([e,t])=>[e,J(t)]).join(",")}return J(t)}function Q(e,t){const r=String(e.name),n=!0===e.explode;if(Array.isArray(t))return n?t.map(e=>[r,J(e)]):[[r,t.map(J).join(",")]];if(h(t)){const e=Object.entries(t);return n?e.map(([e,t])=>[e,J(t)]):[[r,e.flatMap(([e,t])=>[e,J(t)]).join(",")]]}return[[r,J(t)]]}function Y(e,t,n){const o=n.values??{},i=[],s=_(e.servers,n),a=Array.isArray(e.parameters)?e.parameters:[],c=e=>a.filter(t=>t&&"object"==typeof t&&t.in===e&&"string"==typeof t.name),{contentType:u,undeclared:l}=function(e,t){const r=e?.requestBody?.content,n=h(r)?Object.keys(r):[],o=W(t.contentType);if(o){const e=o.split(";")[0].trim().toLowerCase(),t=n.some(t=>t.toLowerCase()===e);return{contentType:o,undeclared:n.length>0&&!t}}return n.length?{contentType:n.slice().sort((e,t)=>K(e)-K(t))[0],undeclared:!1}:{contentType:void 0,undeclared:!1}}(e.operation,o);l&&u&&i.push(`Content type "${u}" is not declared by the operation's requestBody.`);const f=[];for(const e of c("path")){const t=o.path?.[e.name],n=null!=t,s=G(e,n?t:r(e.schema??{}));s?n||i.push(`Path parameter "${e.name}" was synthesized from its schema as "${s}".`):i.push(`Path parameter "${e.name}" resolved to an empty value; pass values.path["${e.name}"] to control it.`),f.push({key:e.name,value:s})}const p=String(e.path).replace(/^\//,"").split("/").filter(e=>e.length>0).map(e=>e.replace(/\{([^}]+)\}/g,(e,t)=>`:${t}`)),d=[],m=new Set;for(const e of c("query")){m.add(e.name);const t=h(o.query)&&Object.prototype.hasOwnProperty.call(o.query,e.name),n=t?o.query[e.name]:void 0;if(t&&void 0!==n)d.push(...X(e,null===n?"":n));else{if(!0===e.required){const t=r(e.schema??{});d.push(...X(e,null===t?"":t));continue}!0!==e.allowEmptyValue?d.push({key:e.name,value:"",disabled:!0}):d.push({key:e.name,value:""})}}if(h(o.query))for(const[e,t]of Object.entries(o.query))if(!m.has(e)&&null!=t)if(Array.isArray(t))for(const r of t)d.push({key:e,value:J(r)});else d.push({key:e,value:J(t)});"string"==typeof o.querystring&&o.querystring.length&&d.push(...function(e){const t=[],r=e.replace(/^[?&]+/,"");if(!r)return t;for(const e of r.split("&")){if(!e)continue;const r=e.indexOf("=");r<0?t.push({key:e,value:"",__raw:!0}):t.push({key:e.slice(0,r),value:e.slice(r+1),__raw:!0})}return t}(o.querystring));const y=[],g=new Set,b=(e,t)=>{if(!e)return;const r=e.toLowerCase();g.has(r)||(g.add(r),y.push({key:e,value:t}))};if(h(o.header))for(const[e,t]of Object.entries(o.header))null!=t&&b(e,J(t));for(const e of c("header")){if(z.test(e.name))continue;if(!0!==e.required)continue;const t=r(e.schema??{});if(null==t)continue;const n=Z(e,t);""!==n&&b(e.name,n)}u&&b("Content-Type",u);const v=function(e){if(!h(e))return;const t=e.responses;if(!h(t))return;const r=new Set,n=new Set;for(const[e,o]of Object.entries(t)){if(e.startsWith("x-"))continue;if(!h(o))continue;const t=o.content;if(!h(t))continue;const i=q(e)?r:n;for(const e of Object.keys(t))"string"==typeof e&&e.trim()&&"*/*"!==e&&i.add(e.trim())}const o=r.size?r:n;if(!o.size)return;const i=Array.from(o);return i.sort((e,t)=>{const r=e=>{const t=e.toLowerCase();return t.startsWith("text/event-stream")?0:M.some(e=>t.startsWith(e))?1:"application/json"===t?2:t.endsWith("+json")?3:4},n=r(e)-r(t);return 0!==n?n:e.localeCompare(t)}),i.slice(0,8).join(", ")}(e.operation);v&&b("Accept",v);const A=c("cookie"),w=[],j=(e,t)=>{w.push(`${e}=${encodeURIComponent(t)}`)};for(const e of A){const t=o.cookie?.[e.name],n=null!=t?t:!0===e.required?r(e.schema??{}):void 0;if(null!=n)for(const[t,r]of Q(e,n))j(t,r)}if(h(o.cookie))for(const[e,t]of Object.entries(o.cookie))A.some(t=>t.name===e)||null!=t&&j(e,J(t));w.length&&b("Cookie",w.join("; "));const x=function(e,t,n,o){const i=e?.requestBody,s=void 0!==t.body;if(!i&&!s)return;const a=n??(s?"application/json":void 0);if(!a)return void(i&&o.push("The operation declares a requestBody but no media type could be resolved; no body was sent."));!n&&s&&o.push("No request media type was declared; defaulted to application/json for the supplied body.");const c=function(e,t){const r=e?.content;if(!h(r))return;if(h(r[t]))return r[t].schema;const n=t.split(";")[0].trim().toLowerCase();for(const e of Object.keys(r)){if(e.toLowerCase()!==n)continue;const t=r[e];if(h(t))return t.schema}}(i,a),u=s?t.body:r(c??{}),l=a.split(";")[0].trim().toLowerCase(),f=l.includes("json-seq")||l.includes("ndjson");if(!f&&("application/json"===l||l.endsWith("+json")||l.includes("json"))){let e;if("string"==typeof u)e=u;else if(void 0===u)e="{}";else try{e=JSON.stringify(u,null,2)??"null"}catch{o.push("The request body could not be serialized as JSON."),e="{}"}return{mode:"raw",raw:e,options:{raw:{language:"json"}}}}if(l.includes("x-www-form-urlencoded"))return{mode:"urlencoded",urlencoded:ee(u).map(([e,t])=>({key:e,value:J(t),type:"text"}))};if(l.includes("multipart/form-data"))return{mode:"formdata",formdata:ee(u).map(([e,t])=>h(t)&&"__file"in t?{key:e,type:"file",src:String(t.__file)}:{key:e,type:"text",value:J(t)})};if(l.includes("xml")||l.startsWith("text/")||f)return{mode:"raw",raw:"string"==typeof u?u:J(u),...l.includes("xml")?{options:{raw:{language:"xml"}}}:{}};return{mode:"raw",raw:"string"==typeof u?u:J(u)}}(e.operation,o,u,i),S=d.filter(e=>!e.disabled).map(e=>e.__raw?`${e.key}${""===e.value?"":`=${e.value}`}`:`${encodeURIComponent(e.key)}=${encodeURIComponent(e.value)}`).join("&");let O=`{{baseUrl}}/${p.join("/")}`;S&&(O+=`?${S}`);const k={raw:O,host:["{{baseUrl}}"],path:p};d.length&&(k.query=d.map(({__raw:e,...t})=>t)),f.length&&(k.variable=f);const $=String(e.method).toUpperCase(),E={method:$,header:y,url:k},C=W(e.operation?.description)??W(e.operation?.summary);C&&(E.description=C),x&&(E.body=x);const R=function(e,t){const r=!1===t?.fromSpecExtensions?{pre:[],test:[]}:D(e,"item");return[...B("prerequest","item",[...r.pre,...U(t?.preRequest)]),...B("test","item",[...r.test,...U(t?.test)])]}(e.operation,n.scripts)??[],N=function(e,t){const r=!1===t?.fromSpecExtensions?{pre:[],test:[]}:D(e,"collection");return[...B("prerequest","collection",[...r.pre,...U(t?.collectionPreRequest)]),...B("test","collection",[...r.test,...U(t?.collectionTest)])]}(t,n.scripts)??[],I=function(e){if(e&&"object"==typeof e&&"none"!==e.type)switch(e.type){case"bearer":return{type:"bearer",bearer:[{key:"token",value:e.token??"",type:"string"}]};case"basic":return{type:"basic",basic:[{key:"username",value:e.username??"",type:"string"},{key:"password",value:e.password??"",type:"string"}]};case"apikey":return{type:"apikey",apikey:[{key:"key",value:e.key??"X-API-Key",type:"string"},{key:"value",value:e.value??"",type:"string"},{key:"in",value:"query"===e.in?"query":"header",type:"string"}]};default:return}}(n.auth),T=W(e.operation?.operationId)??`${$} ${e.path}`,P={info:{_postman_id:V("protokit"),name:(F=t?.info?.title,H="OpenAPI Debug Session","string"==typeof F&&F.trim()?F:H),schema:"https://schema.getpostman.com/json/collection/v2.1.0/collection.json"},item:[{name:T,...R.length?{event:R}:{},request:E,response:[]}],variable:[{key:"baseUrl",value:s}]};var F,H;const Y=W(t?.info?.description);return Y&&(P.info.description=Y),I&&(P.auth=I),N.length&&(P.event=N),{collection:P,baseUrl:s,contentType:u,isCustomMethod:!L.has($),warnings:i}}function ee(e){return h(e)?Object.entries(e):[]}import te from"http";import re from"https";import ne from"postman-runtime";import oe from"postman-collection";var ie=new Set(["[DONE]","DONE","[done]","done"]),se=/\r\n\r\n|\n\n|\r\r/,ae=/^\d+$/;function ce(e,t){const r="number"==typeof e?e:Number(e);return Number.isFinite(r)&&r>0?Math.floor(r):t}var ue=class{buffer="";decoder=new TextDecoder("utf-8");lastEventId;bomChecked=!1;overflowed=!1;sequence=0;maxBufferChars;maxEventChars;inheritEventId;droppedEvents=0;constructor(e={}){this.maxBufferChars=ce(e.maxBufferChars,4194304),this.maxEventChars=ce(e.maxEventChars,1048576),this.inheritEventId=!1!==e.inheritEventId}get truncated(){return this.overflowed}get count(){return this.sequence}push(e){if(null==e)return[];if("string"==typeof e)this.buffer+=e;else{let t;if(e instanceof Uint8Array)t=e;else try{t=new Uint8Array(e)}catch{return[]}try{this.buffer+=this.decoder.decode(t,{stream:!0})}catch{return[]}}!this.bomChecked&&this.buffer.length&&(this.bomChecked=!0,65279===this.buffer.charCodeAt(0)&&(this.buffer=this.buffer.slice(1)));const t=this.drain();return this.buffer.length>this.maxBufferChars&&(this.overflowed=!0,this.droppedEvents+=1,this.buffer=this.buffer.slice(-8)),t}flush(){try{this.buffer+=this.decoder.decode()}catch{}const e=this.drain(),t=this.buffer;if(this.buffer="",t.trim()){const r=this.parseBlock(t);r&&e.push(r)}return e}reset(){this.buffer="",this.lastEventId=void 0,this.bomChecked=!1,this.overflowed=!1,this.sequence=0,this.droppedEvents=0;try{this.decoder.decode()}catch{}}drain(){const e=[];for(;;){const t=se.exec(this.buffer);if(!t)break;const r=this.buffer.slice(0,t.index);this.buffer=this.buffer.slice(t.index+t[0].length);const n=this.parseBlock(r);n&&e.push(n)}return e}parseBlock(e){const t=e.split(/\r\n|\n|\r/),r=[],n={data:"",receivedAt:Date.now(),direction:"in"};let o=!1,i=0,s=!1;for(const e of t){if(""===e)continue;if(58===e.charCodeAt(0))continue;const t=e.indexOf(":"),a=-1===t?e:e.slice(0,t);let c=-1===t?"":e.slice(t+1);switch(32===c.charCodeAt(0)&&(c=c.slice(1)),a){case"data":{if(o=!0,s)break;const e=this.maxEventChars-i;c.length>e?(r.push(c.slice(0,Math.max(0,e))),s=!0,this.overflowed=!0,this.droppedEvents+=1):(r.push(c),i+=c.length+1);break}case"event":n.event=c,o=!0;break;case"id":c.includes("\0")||(n.id=c,this.lastEventId=c),o=!0;break;case"retry":if(ae.test(c)&&c.length<=15){const e=Number(c);Number.isSafeInteger(e)&&(n.retry=e)}o=!0}}if(!o)return null;if(n.data=r.join("\n"),void 0===n.id&&this.inheritEventId&&void 0!==this.lastEventId&&(n.id=this.lastEventId),!s){const e=n.data.trim();if(e&&!ie.has(e)&&function(e){const t=e.charCodeAt(0);return 123===t||91===t||34===t}(e))try{n.parsed=JSON.parse(n.data)}catch{}}return this.sequence+=1,n}};import le from"postman-collection";var fe=864e5;function pe(e){if(null==e)return;const t="number"==typeof e?e:Number(e);return!Number.isFinite(t)||t<0?void 0:Math.min(Math.floor(t),fe)}function de(e,t=[]){const r=[];for(const[t,n]of Object.entries(e??{}))"string"==typeof t&&t&&r.push({key:t,value:null==n?"":String(n)});r.push(...t);const n=new Map;for(const e of r)n.set(e.key,e);return new le.VariableScope({values:Array.from(n.values())})}function me(e){if(!h(e))return;if("maxResponseSize"in e){const t=e.maxResponseSize;if(null!=t){const e="number"==typeof t?t:Number(t);if(!Number.isFinite(e)||e<=0)throw j("BAD_RUN_OPTIONS","runner.requester.maxResponseSize must be a positive number of bytes. Omit it to leave the response size unbounded.",{provided:t})}}if("maxRedirects"in e){const t=e.maxRedirects;if(null!=t){const e="number"==typeof t?t:Number(t);if(!Number.isInteger(e)||e<0)throw j("BAD_RUN_OPTIONS","runner.requester.maxRedirects must be a non-negative integer.",{provided:t})}}const t=e.protocolVersion;if(void 0!==t&&"http1"!==t&&"http2"!==t&&"auto"!==t)throw j("BAD_RUN_OPTIONS",'runner.requester.protocolVersion must be "http1", "http2" or "auto".',{provided:t})}function he(e,t){if(!e||"object"!=typeof e)throw j("BAD_RUN_OPTIONS","send options are required");me(e.runner?.requester);const r=pe(e.runner?.timeout?.request)??pe(e.timeout)??3e4,n=t.streaming?pe(e.maxStreamMs)??3e4:0,o=d({iterationCount:1,stopOnError:!1,abortOnError:!1,stopOnFailure:!1,abortOnFailure:!1,timeout:{request:r,script:pe(e.runner?.timeout?.script)??15e3,global:0===r?0:Math.min(r+n+15e3,fe)},delay:{item:0,iteration:0},script:{serializeLogs:!1},ignoreProxyEnvironmentVariables:!1,requester:{strictSSL:!0,followRedirects:!0,followOriginalHttpMethod:!1,maxRedirects:10,useWhatWGUrlParser:!0,removeRefererHeaderOnRedirect:!1,insecureHTTPParser:!1,timings:!0,verbose:!0,implicitCacheControl:!0,implicitTraceHeader:!0,disableCookies:!1,protocolVersion:"http1",maxInvokableNestedRequests:5,encoding:null}},e.runner??{});me(o.requester),o.environment||(o.environment=de(e.variables,[{key:"baseUrl",value:t.baseUrl}])),!o.globals&&e.globals&&(o.globals=de(e.globals)),!o.localVariables&&e.localVariables&&(o.localVariables=de(e.localVariables)),Array.isArray(o.data)&&o.data.length&&void 0===e.runner?.iterationCount&&(o.iterationCount=o.data.length);const i=Number(o.iterationCount);if(!Number.isInteger(i)||i<1)throw j("BAD_RUN_OPTIONS","runner.iterationCount must be an integer of at least 1.",{provided:o.iterationCount});return o}function ye(e){const t={},r="function"==typeof e?.all?e.all():[];for(const e of r??[]){if(!e||e.disabled)continue;const r=String(e.key??"");r&&(t[r]=t[r]?`${t[r]}, ${String(e.value??"")}`:String(e.value??""))}return t}function ge(e){if(e)try{const t=e.values??e,r="function"==typeof t.toJSON?t.toJSON():t;if(!Array.isArray(r))return;const n={};for(const e of r){if(!e||!1===e.enabled||null==e.key)continue;const t=String(e.key);"__proto__"!==t&&"constructor"!==t&&(n[t]=null==e.value?"":String(e.value))}return n}catch{return}}function be(e){const t=e?.body;if(t)try{if("raw"===t.mode)return t.raw;if("function"==typeof t.toString){return t.toString()||void 0}return f(t)}catch{return}}function ve(e,t,r){const n=function(){let e,t,r=!1;const n=new Promise((r,n)=>{e=r,t=n});return n.catch(()=>{}),{promise:n,get settled(){return r},resolve:t=>!r&&(r=!0,e(t),!0),reject:e=>!r&&(r=!0,t(e),!0)}}(),o=Date.now();let i,s,a,c="initialized",u=e.streamingHint,l=!1;const p=g(t.maxEvents,100),d=g(t.maxStreamMs,3e4),m=g(t.runner?.timeout?.request??t.timeout,3e4),h="number"==typeof t.maxResponseSize?t.maxResponseSize:void 0,b=new ue({maxBufferChars:t.maxBufferChars,maxEventChars:t.maxEventChars,inheritEventId:t.inheritEventId}),v=[],A=[];let w=0,x=!1;const O={prerequest:[],test:[],assertions:[],console:[],passed:!0,skipped:!1},k=[];let $=null,E=null,_=null,C=null,R=null,N=null;const M=function(e){const t=e.runner?.requester;return!(!t?.agents&&!t?.agent)}(t)?null:function(){try{const e=new Set,t=t=>{if(!t||"function"!=typeof t.destroy)return t;e.add(t);const r=()=>e.delete(t);return t.once?.("close",r),t.once?.("error",r),t},r=new te.Agent({keepAlive:!1}),n=new re.Agent({keepAlive:!1});return r.createConnection=function(e,r){return t(te.Agent.prototype.createConnection.call(this,e,r))},n.createConnection=function(e,r){return t(re.Agent.prototype.createConnection.call(this,e,r))},{agents:{http:r,https:n},destroyAll(){let t=0;for(const r of Array.from(e))try{r.destroy(),t+=1}catch{}e.clear();try{r.destroy(),n.destroy()}catch{}return t}}}catch{return null}}(),q=(e,t)=>{O.console.push({level:e,messages:[t],at:Date.now()})},I=e=>(e&&"function"==typeof e.unref&&e.unref(),e),U=(e,t)=>{if("stopping"===c||"finalized"===c)return;c="stopping",s=e,l=!0,q("debug",`[protokit] stopping run: ${t??e}`);try{E?.abort?.()}catch{}const r=M?.destroyAll()??0;r>0&&q("debug",`[protokit] destroyed ${r} open socket(s)`),R=I(setTimeout(()=>{"finalized"!==c&&(q("warn","[protokit] runtime did not report completion after stop"),D())},250))},B=(e,t)=>({target:t,scriptId:e?.script?.id??e?.event?.script?.id,error:e?.error?{name:e.error.name,message:e.error.message}:void 0,environment:ge(e?.result?.environment),globals:ge(e?.result?.globals),return:e?.result?.return}),D=()=>{if("finalized"===c)return;if(c="finalized",_=y(_),C=y(C),R=y(R),N?.(),N=null,M?.destroyAll(),u){for(const e of b.flush())v.length<p?(v.push(e),Ae(()=>t.onEvent?.(e))):l=!0;b.truncated&&(l=!0)}const e=Date.now();if($)u&&($.response.events=v),l&&($.response.truncated=!0),$.response.timings={...$.response.timings,startedAt:o,endedAt:e,durationMs:e-o,firstByteMs:i?i-o:void 0,...void 0!==a?{networkDurationMs:a}:{}};else{const t=!!s&&v.length>0;$={protocol:u?"sse":"http",request:{method:"",url:"",headers:{}},response:{status:t?200:0,statusText:t?"Stream sampling stopped":"No response received",headers:{},contentType:u?"text/event-stream":void 0,...u?{events:v}:{},timings:{startedAt:o,endedAt:e,durationMs:e-o,firstByteMs:i?i-o:void 0},sizeBytes:w,...l?{truncated:!0}:{}},...t?{}:{error:{message:"aborted"===s?"Run aborted before a response was received":"Runner finished without a response",code:s}}}}s&&($.response.stopReason=s),b.droppedEvents&&($.response.droppedEvents=b.droppedEvents),$.scripts=O,n.resolve($)};if(r?.signal){const e=r.signal;if(e.aborted)return U("aborted","signal already aborted"),D(),n.promise;const t=()=>U("aborted","caller aborted the request");e.addEventListener("abort",t,{once:!0}),N=()=>e.removeEventListener("abort",t)}C=I(setTimeout(()=>{if("finalized"!==c){q("error","[protokit] hard timeout reached, forcing completion"),s??="hardTimeout",l=!0;try{E?.abort?.()}catch{}M?.destroyAll(),D()}},m+d+3e4));const L=(e,t,r)=>(c="finalized",C=y(C),N?.(),M?.destroyAll(),Promise.reject(j(e,t,r)));let z,F,V;try{z=new oe.Collection(f(e.collectionJson))}catch(e){return L("BAD_COLLECTION",`Failed to construct collection: ${S(e).message}`,e)}try{F=he(t,{baseUrl:e.baseUrl,streaming:e.streamingHint}),M&&(F.requester={...F.requester??{},agents:M.agents})}catch(e){return L("BAD_RUN_OPTIONS",`Failed to build runtime options: ${S(e).message}`,e)}try{V=new ne.Runner}catch(e){return L("RUNTIME_INIT",`Failed to create runner: ${S(e).message}`,e)}function W(e){let r;try{r=b.push(e)}catch(e){return void q("error",`[protokit] SSE parse failure: ${S(e).message}`)}for(const e of r){if(v.length>=p)return l=!0,void U("maxEvents",`maxEvents (${p}) reached`);if(v.push(e),Ae(()=>t.onEvent?.(e)),v.length>=p)return void U("maxEvents",`maxEvents (${p}) reached`)}}return V.run(z,F,(r,f)=>{if(r)return c="finalized",C=y(C),N?.(),M?.destroyAll(),void n.reject(j("RUNTIME_INIT",r.message??"Runner initialization failed",r));if(E=f,"stopping"===c){try{f.abort?.()}catch{}M?.destroyAll()}f.start({console(e,r,...n){const o={level:"string"==typeof r?r:"log",messages:n,at:Date.now()};O.console.push(o),Ae(()=>t.onConsole?.(o))},assertion(e,r){for(const e of r??[]){const r={name:e?.name??"assertion",passed:!e?.error&&!e?.skipped,skipped:!!e?.skipped,index:"number"==typeof e?.index?e.index:0,error:e?.error?{name:e.error.name,message:e.error.message??String(e.error),stack:e.error.stack}:void 0};r.passed||r.skipped||(O.passed=!1),O.assertions.push(r),Ae(()=>t.onAssertion?.(r))}},prerequest(e,t,r){for(const e of r??[])O.prerequest.push(B(e,"prerequest"))},test(e,t,r){for(const e of r??[])O.test.push(B(e,"test"))},item(e,t,r,n,o){o?.isSkipped&&(O.skipped=!0)},responseStart(r,n,o){"initialized"===c&&(c="headers"),i??=Date.now();const s=we(o,"content-type");(T(s)||P(s))&&(u=!0),Ae(()=>t.onResponseStart?.({status:o?.code??0,headers:ye(o?.headers),contentType:s,streaming:u,protocol:u?"sse":"http",url:e.baseUrl})),u&&("headers"===c&&(c="streaming"),_||(_=I(setTimeout(()=>U("maxStreamMs",`maxStreamMs (${d}ms) reached`),d))))},responseData(e,t){if("finalized"===c||null==t)return;let r;try{r=Buffer.isBuffer(t)?t:Buffer.from(t)}catch{return}if(x=!0,w+=r.length,void 0!==h&&w>h&&"stopping"!==c)return u&&W(r),void U("maxResponseSize",`maxResponseSize (${h} bytes) exceeded`);u?W(r):A.push(r)},request(e,t,r,n,f,p){const d=Date.now(),m={method:n?.method??"",url:xe(n),headers:ye(n?.headers),body:be(n)};"number"==typeof r?.responseTime&&(a=r.responseTime);if(e&&!("stopping"===c||!!s))return void($={protocol:u?"sse":"http",request:m,response:{status:0,statusText:"Request failed",headers:{},timings:{startedAt:o,endedAt:d,durationMs:d-o,firstByteMs:i?i-o:void 0,...void 0!==a?{networkDurationMs:a}:{}},sizeBytes:w},error:S(e),replays:k});e&&q("debug",`[protokit] transport closed by sampler: ${S(e).message}`);const h=we(r,"content-type");let y,g;(T(h)||P(h))&&(u=!0);let b=0;if(!u){const e=A.length?Buffer.concat(A):function(e){if(!e)return Buffer.alloc(0);if(Buffer.isBuffer(e))return e;try{return Buffer.from(e)}catch{return Buffer.alloc(0)}}(r?.stream);b=e.length,y=function(e){const t=Math.min(e.length,1024);for(let r=0;r<t;r+=1)if(0===e[r])return!0;return!1}(e)?void 0:e.toString("utf8"),g=function(e,t){if(!e)return;if(t&&!/json/i.test(t))return;const r=e.trim();if(r&&/^[[{"\-\d]|^(true|false|null)$/.test(r))try{return JSON.parse(r)}catch{return}}(y,h)}$={protocol:u?"sse":"http",request:m,response:{status:"number"==typeof r?.code?r.code:0,statusText:je(r),headers:ye(r?.headers),contentType:h,...u?{streaming:!0,events:v,body:Object.assign({},...v.map(e=>e.parsed))}:{body:g,text:y},timings:{startedAt:o,endedAt:d,durationMs:d-o,firstByteMs:i?i-o:void 0,...void 0!==a?{networkDurationMs:a}:{}},sizeBytes:x?w:b,...l?{truncated:!0}:{}},cookies:Array.isArray(p)?p.map(e=>({name:String(e?.name??""),value:String(e?.value??""),domain:e?.domain,path:e?.path})):[],replays:k}},io(e,t,r,n,o){"http"===r?.type&&r.source&&"collection"!==r.source&&k.push({url:xe(o),method:o?.method??"",status:"number"==typeof n?.code?n.code:0,reason:String(r.source)})},exception(e,t){q("error",`[exception] ${S(t).message}`)},done(e){if(e&&!$&&!(!!s||"stopping"===c))return c="finalized",_=y(_),C=y(C),R=y(R),N?.(),M?.destroyAll(),void n.reject(j("RUNTIME_RUN",e.message??"Run failed",e));D()}})}),n.promise}function Ae(e){try{e()}catch{}}function we(e,t){try{const r=e?.headers?.get?.(t);return null==r?void 0:String(r)}catch{return}}function je(e){try{return String("function"==typeof e?.reason?e.reason()??"":e?.status??"")}catch{return""}}function xe(e){try{return"function"==typeof e?.url?.toString?e.url.toString():""}catch{return""}}var Se=Symbol("protokit.cycle"),Oe=new Set(["__proto__","constructor","prototype"]);function ke(e,t={}){const r=$e(t.maxDepth,32),n=$e(t.maxNodes,2e5),o=new Map;function i(e,t){let r=e;try{r=decodeURIComponent(e)}catch{r=e}const n=r.replace(/~1/g,"/").replace(/~0/g,"~");if(Oe.has(n))throw j("BAD_REF",`Pointer "${t}" traverses a forbidden key "${n}"`);return n}function s(t){if("string"!=typeof t||!t.length)throw j("EXTERNAL_REF","A $ref pointer must be a non-empty string");if("#"===t||"#/"===t)return e;if(!t.startsWith("#/"))throw j("EXTERNAL_REF",`Only local $ref pointers are supported, got: ${t}`);let r=e;for(const e of t.slice(2).split("/")){if(null===r||"object"!=typeof r)throw j("BAD_REF",`Cannot resolve pointer "${t}"`);const n=i(e,t);if(!Object.prototype.hasOwnProperty.call(r,n))throw j("BAD_REF",`Pointer "${t}" resolves to undefined`);r=r[n]}if(void 0===r)throw j("BAD_REF",`Pointer "${t}" resolves to undefined`);return r}function a(e){let t=e;const r=new Set;let n,o=0;for(;null!==t&&"object"==typeof t&&"string"==typeof t.$ref;){const e=t.$ref;if(r.has(e)||++o>100)return u();r.add(e);const i=c(t);i&&(n={...i,...n??{}}),t=s(e)}return n?null===t||"object"!=typeof t||Array.isArray(t)?t:{...t,...n}:t}function c(e){let t;for(const r of Object.keys(e))"$ref"===r||Oe.has(r)||((t??={})[r]=e[r]);return t}function u(){return{type:"object",[Se]:!0}}function f(e,t,o,i){if(null===e||"object"!=typeof e)return e;if(t>r)return{type:"object"};if(++i.nodes>n)return{type:"object"};let s;try{s=a(e)}catch(e){if("EXTERNAL_REF"===e?.code)throw e;return{type:"object"}}if(null===s||"object"!=typeof s)return s;if(s[Se])return{type:"object"};if(o.has(s))return{type:"object"};o.add(s);try{if(Array.isArray(s)){const e=new Array(s.length);for(let r=0;r<s.length;r+=1)e[r]=f(s[r],t+1,o,i);return e}const e={};for(const r of Object.keys(s))Oe.has(r)||(e[r]=f(s[r],t+1,o,i));return e}finally{o.delete(s)}}function p(e){return f(e,0,new Set,{nodes:0})}return{deref:a,deepDeref:function(e){const t=null!==e&&"object"==typeof e?e.$ref:void 0,r="string"==typeof t&&1===Object.keys(e).length;if(r&&o.has(t))return l(o.get(t));const n=p(e);return r?(o.set(t,n),l(n)):n},byPointer:s}}function $e(e,t){const r="number"==typeof e?e:Number(e);return!Number.isFinite(r)||r<=0?t:Math.floor(r)}var Ee=["get","put","post","delete","options","head","patch","trace","query"];function _e(e,t){if(!e||"object"!=typeof e||Array.isArray(e))throw j("BAD_SPEC","spec must be an object");if("string"!=typeof e.openapi||!e.openapi.trim())throw j("BAD_SPEC","spec.openapi version string is required");if(!t||"object"!=typeof t)throw j("BAD_TARGET","target is required");const r=ke(e),n=e.paths;if(!n||"object"!=typeof n||Array.isArray(n))throw j("BAD_SPEC","spec.paths is missing or invalid");const o=function(e,t){const r=[];for(const[n,o]of Object.entries(e)){if(n.startsWith("x-"))continue;let e;try{e=t.deref(o)}catch{continue}if(!e||"object"!=typeof e||Array.isArray(e))continue;for(const t of Ee){const o=e[t];o&&"object"==typeof o&&!Array.isArray(o)&&r.push({path:n,method:t,rawOperation:o,pathItem:e,isCustomMethod:!1})}const i=e.additionalOperations;if(i&&"object"==typeof i&&!Array.isArray(i))for(const[t,o]of Object.entries(i))o&&"object"==typeof o&&!Array.isArray(o)&&r.push({path:n,method:t.toLowerCase(),rawOperation:o,pathItem:e,isCustomMethod:!0,customMethodKey:t})}return r}(n,r);if(!o.length)throw j("EMPTY_SPEC","The document does not declare any operation");const i=t.operationId?function(e,t,r){const n=e.filter(e=>{try{return t.deref(e.rawOperation)?.operationId===r}catch{return!1}});if(!n.length)throw j("OP_NOT_FOUND",`operationId "${r}" was not found`,{available:Ce(e,t)});if(n.length>1)throw j("AMBIGUOUS_OPERATION_ID",`operationId "${r}" is declared ${n.length} times`,{matches:n.map(e=>`${e.method.toUpperCase()} ${e.path}`)});return n[0]}(o,r,t.operationId):function(e,t){if(!t.path||!t.method)throw j("BAD_TARGET","Provide either operationId, or both path and method");const r=String(t.method).toLowerCase(),n=String(t.path),o=[n,n.startsWith("/")?n.slice(1):`/${n}`];for(const t of o){const n=e.find(e=>e.path===t&&e.method===r);if(n)return n}throw j("OP_NOT_FOUND",`Operation "${String(t.method).toUpperCase()} ${n}" was not found`,{available:e.map(e=>`${e.method.toUpperCase()} ${e.path}`).slice(0,50)})}(o,t),s=r.deepDeref(i.rawOperation)??{},a=i.pathItem??{};return{path:i.path,method:i.method,isCustomMethod:i.isCustomMethod,...i.customMethodKey?{customMethodKey:i.customMethodKey}:{},operation:s,pathItem:a,parameters:Re(r,a,s),servers:Ne(e,a,s),security:Array.isArray(s.security)?s.security:Array.isArray(e.security)?e.security:void 0}}function Ce(e,t){const r=new Set;for(const n of e)try{const e=t.deref(n.rawOperation)?.operationId;"string"==typeof e&&e&&r.add(e)}catch{}return Array.from(r).slice(0,50)}function Re(e,t,r){const n=new Map,o=t=>{if(Array.isArray(t))for(const r of t){let t;try{t=e.deepDeref(r)}catch{continue}t&&"object"==typeof t&&"string"==typeof t.name&&t.name.length>0&&"string"==typeof t.in&&n.set(`${t.in.toLowerCase()}:${t.name}`,t)}};return o(t?.parameters),o(r?.parameters),Array.from(n.values())}function Ne(e,t,r){const n=e=>{if(!Array.isArray(e))return;const t=e.filter(e=>e&&"object"==typeof e&&"string"==typeof e.url&&e.url.length>0);return t.length?t:void 0};return n(r?.servers)??n(t?.servers)??n(e?.servers)??[{url:"/"}]}var Me=class{name="http";supports(e){const t=e.located.operation?.["x-protocol"];return"string"==typeof t&&"http"!==t&&"sse"!==t?0:1}plan(e){const t=Y(e.located,e.spec,e.options);return{...t,environment:N(`${e.spec?.info?.title??"API"} Environment`,t.baseUrl,e.options.variables),streaming:I(e.located.operation,e.options.values)}}execute(e,t,r){return ve({collectionJson:e.collection,baseUrl:e.baseUrl,streamingHint:e.streaming},t,r)}};export{Me as HttpAdapter,ue as SseParser,Y as buildCollection,N as buildEnvironment,he as buildRunOptions,ke as createResolver,_e as locateOperation,_ as resolveServerUrl,ve as runWithPostman};
|