@powerduck/request 0.1.0

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.
@@ -0,0 +1,372 @@
1
+ type Json = null | boolean | number | string | Json[] | {
2
+ [key: string]: Json;
3
+ };
4
+ type ProtocolName = "http" | "sse" | "websocket" | "grpc" | "mcp";
5
+ /** Identifies a single operation inside an OpenAPI document. */
6
+ interface OperationTarget {
7
+ /** Templated path, e.g. '/users/{id}'. Requires `method`. */
8
+ path?: string;
9
+ /** HTTP method, case-insensitive. Requires `path`. */
10
+ method?: string;
11
+ /** Alternative lookup key; takes precedence over path + method. */
12
+ operationId?: string;
13
+ }
14
+ /** User-supplied values injected into the generated request. */
15
+ interface RequestValues {
16
+ path?: Record<string, unknown>;
17
+ query?: Record<string, unknown>;
18
+ header?: Record<string, unknown>;
19
+ cookie?: Record<string, unknown>;
20
+ /** OpenAPI 3.2 `querystring` parameter location: a raw, pre-encoded query string. */
21
+ querystring?: string;
22
+ body?: unknown;
23
+ /** Force a specific request media type when the operation declares several. */
24
+ contentType?: string;
25
+ }
26
+ interface AuthConfig {
27
+ type: "bearer" | "basic" | "apikey" | "none";
28
+ token?: string;
29
+ username?: string;
30
+ password?: string;
31
+ key?: string;
32
+ value?: string;
33
+ in?: "header" | "query";
34
+ }
35
+ interface ScriptSource {
36
+ /** Script body, either a single string or an array of lines. */
37
+ exec: string | string[];
38
+ /** Optional identifier surfaced in script results. */
39
+ id?: string;
40
+ }
41
+ interface ScriptConfig {
42
+ collectionPreRequest?: ScriptSource | ScriptSource[];
43
+ collectionTest?: ScriptSource | ScriptSource[];
44
+ preRequest?: ScriptSource | ScriptSource[];
45
+ test?: ScriptSource | ScriptSource[];
46
+ /** Read `x-postman-scripts` from the spec. Defaults to true. */
47
+ fromSpecExtensions?: boolean;
48
+ }
49
+ interface AssertionResult {
50
+ name: string;
51
+ passed: boolean;
52
+ skipped: boolean;
53
+ index: number;
54
+ error?: {
55
+ name?: string;
56
+ message: string;
57
+ stack?: string;
58
+ };
59
+ }
60
+ interface ConsoleLog {
61
+ level: "log" | "info" | "warn" | "error" | "debug";
62
+ messages: unknown[];
63
+ at: number;
64
+ }
65
+ interface ScriptOutcome {
66
+ target: "prerequest" | "test";
67
+ scriptId?: string;
68
+ error?: {
69
+ name?: string;
70
+ message: string;
71
+ };
72
+ /** Full variable scope snapshot after the script ran (not a diff). */
73
+ environment?: Record<string, string>;
74
+ globals?: Record<string, string>;
75
+ /** Values produced by pm.execution.setNextRequest / skipRequest, etc. */
76
+ return?: Record<string, unknown>;
77
+ }
78
+ interface ScriptReport {
79
+ prerequest: ScriptOutcome[];
80
+ test: ScriptOutcome[];
81
+ assertions: AssertionResult[];
82
+ console: ConsoleLog[];
83
+ /** False when at least one non-skipped assertion failed. */
84
+ passed: boolean;
85
+ /** True when the item was skipped via pm.execution.skipRequest(). */
86
+ skipped: boolean;
87
+ }
88
+ interface StreamEvent {
89
+ /** SSE `id` field, or a synthetic sequence number for WebSocket frames. */
90
+ id?: string;
91
+ /** SSE `event` field, or the WebSocket frame kind ('text' | 'binary' | 'ping'). */
92
+ event?: string;
93
+ data: string;
94
+ /** Populated when `data` parses as JSON. */
95
+ parsed?: Json;
96
+ retry?: number;
97
+ receivedAt: number;
98
+ /** Message direction. WebSocket only; SSE is always inbound. */
99
+ direction?: "in" | "out";
100
+ }
101
+ interface ReplayRecord {
102
+ url: string;
103
+ method: string;
104
+ status: number;
105
+ /** Origin reported by the runtime, e.g. 'authorizer' or 'redirect'. */
106
+ reason?: string;
107
+ }
108
+ interface ExecResult {
109
+ protocol: ProtocolName;
110
+ request: {
111
+ method: string;
112
+ url: string;
113
+ headers: Record<string, string>;
114
+ body?: unknown;
115
+ };
116
+ response: {
117
+ status: number;
118
+ statusText: string;
119
+ headers: Record<string, string>;
120
+ contentType?: string;
121
+ /** Parsed body for non-streaming responses. */
122
+ body?: unknown;
123
+ text?: string;
124
+ /** Collected events for streaming protocols. */
125
+ events?: StreamEvent[];
126
+ timings: {
127
+ startedAt: number;
128
+ endedAt: number;
129
+ durationMs: number;
130
+ firstByteMs?: number;
131
+ };
132
+ sizeBytes: number;
133
+ /** True when sampling stopped before the stream ended naturally. */
134
+ truncated?: boolean;
135
+ };
136
+ scripts?: ScriptReport;
137
+ cookies?: Array<{
138
+ name: string;
139
+ value: string;
140
+ domain?: string;
141
+ path?: string;
142
+ }>;
143
+ replays?: ReplayRecord[];
144
+ error?: {
145
+ message: string;
146
+ code?: string;
147
+ name?: string;
148
+ };
149
+ }
150
+ /**
151
+ * Raw postman-runtime options. Every documented field is passed straight through
152
+ * to `runner.run()`. Anything set here wins over the library defaults.
153
+ */
154
+ interface RuntimeRunOptions {
155
+ data?: Array<Record<string, unknown>>;
156
+ timeout?: {
157
+ request?: number;
158
+ script?: number;
159
+ global?: number;
160
+ };
161
+ iterationCount?: number;
162
+ stopOnError?: boolean;
163
+ abortOnError?: boolean;
164
+ stopOnFailure?: boolean;
165
+ abortOnFailure?: boolean;
166
+ environment?: any;
167
+ globals?: any;
168
+ localVariables?: any;
169
+ secretResolver?: (ctx: {
170
+ secrets: Array<{
171
+ key: string;
172
+ value?: string;
173
+ }>;
174
+ url: string;
175
+ }, callback: (error: Error | null, result?: Array<{
176
+ resolvedValue?: string;
177
+ error?: unknown;
178
+ allowedInScript?: boolean;
179
+ }>) => void) => void;
180
+ entrypoint?: {
181
+ execute?: string;
182
+ lookupStrategy?: "idOrName" | "path";
183
+ path?: string[];
184
+ };
185
+ delay?: {
186
+ item?: number;
187
+ iteration?: number;
188
+ };
189
+ fileResolver?: unknown;
190
+ requester?: RequesterOptions;
191
+ script?: {
192
+ serializeLogs?: boolean;
193
+ requestResolver?: (requestId: string, callback: (error: Error | null, collection?: any) => void) => void;
194
+ packageResolver?: (ctx: {
195
+ packages: any;
196
+ }, callback: (error: Error | null, packages?: Record<string, {
197
+ data?: string;
198
+ error?: string;
199
+ }>) => void) => void;
200
+ };
201
+ proxies?: any;
202
+ systemProxy?: (url: string, callback: (error: Error | null, config?: any) => void) => void;
203
+ ignoreProxyEnvironmentVariables?: boolean;
204
+ certificates?: any;
205
+ systemCertificate?: () => void;
206
+ [key: string]: unknown;
207
+ }
208
+ interface RequesterOptions {
209
+ cookieJar?: any;
210
+ disableCookies?: boolean;
211
+ followRedirects?: boolean;
212
+ followOriginalHttpMethod?: boolean;
213
+ maxRedirects?: number;
214
+ maxResponseSize?: number;
215
+ maxHeaderSize?: number;
216
+ protocolVersion?: "http1" | "http2" | "auto";
217
+ useWhatWGUrlParser?: boolean;
218
+ removeRefererHeaderOnRedirect?: boolean;
219
+ strictSSL?: boolean;
220
+ insecureHTTPParser?: boolean;
221
+ timings?: boolean;
222
+ verbose?: boolean;
223
+ implicitCacheControl?: boolean;
224
+ implicitTraceHeader?: boolean;
225
+ systemHeaders?: Record<string, string>;
226
+ extendedRootCA?: string;
227
+ network?: {
228
+ hostLookup?: {
229
+ type: string;
230
+ hostIpMap?: Record<string, string>;
231
+ };
232
+ restrictedAddresses?: Record<string, boolean>;
233
+ };
234
+ agents?: {
235
+ http?: {
236
+ agentClass?: unknown;
237
+ agentOptions?: Record<string, unknown>;
238
+ } | unknown;
239
+ https?: {
240
+ agentClass?: unknown;
241
+ agentOptions?: Record<string, unknown>;
242
+ } | unknown;
243
+ };
244
+ authorizer?: {
245
+ refreshOAuth2Token?: (id: string, callback: (error: Error | null, token?: string) => void) => void;
246
+ };
247
+ maxInvokableNestedRequests?: number;
248
+ sslKeyLogFile?: string;
249
+ [key: string]: unknown;
250
+ }
251
+ /** WebSocket-specific execution options. */
252
+ interface WebSocketOptions {
253
+ /** Absolute ws:// or wss:// URL. Overrides anything derived from the spec. */
254
+ url?: string;
255
+ subprotocols?: string[];
256
+ headers?: Record<string, string>;
257
+ /** Messages sent immediately after the connection opens. */
258
+ send?: Array<string | Record<string, unknown> | Uint8Array>;
259
+ /** Milliseconds to wait between consecutive outbound messages. */
260
+ sendDelayMs?: number;
261
+ /** Stop after this many inbound messages. */
262
+ maxMessages?: number;
263
+ /** Hard cap on total session duration. */
264
+ maxSessionMs?: number;
265
+ /** Close once no message arrives within this window. */
266
+ idleTimeoutMs?: number;
267
+ /** Application-level ping payload sent on an interval. */
268
+ keepAlive?: {
269
+ intervalMs: number;
270
+ payload?: string;
271
+ };
272
+ /** Close code sent when the client terminates the session. */
273
+ closeCode?: number;
274
+ closeReason?: string;
275
+ /** Extra options forwarded verbatim to the `ws` client constructor. */
276
+ clientOptions?: Record<string, unknown>;
277
+ /** Reject self-signed certificates. Defaults to true. */
278
+ rejectUnauthorized?: boolean;
279
+ /** Cap on retained binary payload size, in bytes. */
280
+ maxPayloadBytes?: number;
281
+ }
282
+ interface SendOptions {
283
+ /** The complete OpenAPI 3.2 document. */
284
+ spec: any;
285
+ target: OperationTarget;
286
+ values?: RequestValues;
287
+ /** Overrides `spec.servers[0].url`. */
288
+ serverUrl?: string;
289
+ serverVariables?: Record<string, string>;
290
+ /** Environment variables referenced as {{name}}. */
291
+ variables?: Record<string, string>;
292
+ globals?: Record<string, string>;
293
+ localVariables?: Record<string, string>;
294
+ auth?: AuthConfig;
295
+ scripts?: ScriptConfig;
296
+ /** Full postman-runtime option passthrough. Highest precedence. */
297
+ runner?: RuntimeRunOptions;
298
+ /** WebSocket options, used by the ws adapter. */
299
+ websocket?: WebSocketOptions;
300
+ /** Convenience shortcut, equivalent to runner.timeout.request. */
301
+ timeout?: number;
302
+ /** Maximum number of streaming events to retain. */
303
+ maxEvents?: number;
304
+ /** Maximum streaming duration before sampling stops. */
305
+ maxStreamMs?: number;
306
+ /** Skip the OpenAPI write-back step. Defaults to false. */
307
+ writeBack?: boolean;
308
+ onEvent?: (event: StreamEvent) => void;
309
+ onConsole?: (log: ConsoleLog) => void;
310
+ onAssertion?: (assertion: AssertionResult) => void;
311
+ onResponseStart?: (info: {
312
+ status: number;
313
+ headers: Record<string, string>;
314
+ contentType?: string;
315
+ }) => void;
316
+ /** Fired when a WebSocket connection is established. */
317
+ onOpen?: (info: {
318
+ url: string;
319
+ protocol?: string;
320
+ headers: Record<string, string>;
321
+ }) => void;
322
+ }
323
+ interface SendResult extends ExecResult {
324
+ /** The generated Postman collection (v2.1). Empty for non-HTTP protocols. */
325
+ collection?: any;
326
+ /** The generated Postman environment. */
327
+ environment?: any;
328
+ /** OpenAPI 3.2 Response Object derived from the live call. */
329
+ responseFragment: any;
330
+ /** Status code the fragment was filed under. */
331
+ responseStatusCode: string;
332
+ /** Deep copy of the spec with the response merged in. Undefined when skipped. */
333
+ patchedSpec?: any;
334
+ /** Explains why write-back did not happen. */
335
+ writeBackSkippedReason?: string;
336
+ }
337
+
338
+ interface LocatedOperation {
339
+ path: string;
340
+ /** Lower-cased method name; custom verbs come from `additionalOperations`. */
341
+ method: string;
342
+ /** True when the method came from `additionalOperations`. */
343
+ isCustomMethod: boolean;
344
+ /** Fully dereferenced Operation Object. */
345
+ operation: any;
346
+ pathItem: any;
347
+ /** Path-level and operation-level parameters merged, operation wins. */
348
+ parameters: any[];
349
+ /** Effective servers, honoring operation > pathItem > document precedence. */
350
+ servers: any[];
351
+ security?: any[];
352
+ }
353
+ declare function locateOperation(spec: any, target: OperationTarget): LocatedOperation;
354
+
355
+ interface AdapterContext {
356
+ spec: any;
357
+ options: SendOptions;
358
+ located: LocatedOperation;
359
+ }
360
+ /**
361
+ * Every protocol implements this contract. `plan()` must be pure and
362
+ * synchronous so callers can inspect or export the plan without side effects.
363
+ */
364
+ interface ProtocolAdapter<TPlan = unknown> {
365
+ readonly name: string;
366
+ /** Return 0 when unsupported; higher numbers win the resolution race. */
367
+ supports(ctx: AdapterContext): number;
368
+ plan(ctx: AdapterContext): TPlan;
369
+ execute(plan: TPlan, options: SendOptions): Promise<ExecResult>;
370
+ }
371
+
372
+ export { type AdapterContext as A, type ConsoleLog as C, type ExecResult as E, type Json as J, type LocatedOperation as L, type OperationTarget as O, type ProtocolAdapter as P, type ReplayRecord as R, type ScriptSource as S, type WebSocketOptions as W, type SendOptions as a, type SendResult as b, type AssertionResult as c, type AuthConfig as d, type ProtocolName as e, type RequestValues as f, type RequesterOptions as g, type RuntimeRunOptions as h, type ScriptConfig as i, type ScriptOutcome as j, type ScriptReport as k, type StreamEvent as l, locateOperation as m };
@@ -0,0 +1 @@
1
+ "use strict";var e,t=Object.create,r=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.getPrototypeOf,i=Object.prototype.hasOwnProperty,a=(e,t,s,a)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let c of o(t))i.call(e,c)||c===s||r(e,c,{get:()=>t[c],enumerable:!(a=n(t,c))||a.enumerable});return e},c=(e,n,o)=>(o=null!=e?t(s(e)):{},a(!n&&e&&e.__esModule?o:r(o,"default",{value:e,enumerable:!0}),e)),u={};function l(e,t=0){if(!e||"object"!=typeof e||t>12)return null;if(void 0!==e.example)return e.example;if(void 0!==e.examples){if(Array.isArray(e.examples)&&e.examples.length)return e.examples[0];if("object"==typeof e.examples){const t=Object.values(e.examples)[0];if(void 0!==t)return t&&"object"==typeof t&&"value"in t?t.value:t}}if(void 0!==e.default)return e.default;if(void 0!==e.const)return e.const;if(Array.isArray(e.enum)&&e.enum.length)return e.enum[0];if(Array.isArray(e.allOf)&&e.allOf.length)return e.allOf.reduce((e,r)=>{const n=l(r,t+1);return n&&"object"==typeof n&&!Array.isArray(n)?{...e,...n}:null!=n?n:e},{});for(const r of["oneOf","anyOf"])if(Array.isArray(e[r])&&e[r].length)return l(e[r][0],t+1);switch((Array.isArray(e.type)?e.type.find(e=>"null"!==e)??"null":e.type)??(e.properties?"object":e.items?"array":(e.format,"string"))){case"object":{const r={},n=Array.isArray(e.required)?e.required:[],o=e.properties&&"object"==typeof e.properties?e.properties:{};for(const[e,s]of Object.entries(o))s&&!0===s.readOnly||t>2&&n.length&&!n.includes(e)||(r[e]=l(s,t+1));return!Object.keys(r).length&&e.additionalProperties&&"object"==typeof e.additionalProperties&&(r.key=l(e.additionalProperties,t+1)),r}case"array":{const r=Math.max(1,Math.min(Number(e.minItems)||1,2));return Array.from({length:r},()=>l(e.items,t+1))}case"integer":return p(e,Math.trunc(e.minimum??0));case"number":return p(e,e.minimum??0);case"boolean":return!1;case"null":return null;default:return function(e){switch(e.format){case"date-time":return(new Date).toISOString();case"date":return(new Date).toISOString().slice(0,10);case"time":return(new Date).toISOString().slice(11,19);case"uuid":return"00000000-0000-4000-8000-000000000000";case"email":return"user@example.com";case"hostname":return"example.com";case"ipv4":return"127.0.0.1";case"ipv6":return"::1";case"uri":case"url":case"uri-reference":return"https://example.com";case"byte":case"binary":return"";case"password":return"password";default:{if("string"==typeof e.pattern)return"";const t=Number(e.minLength)||0,r="string";return t>r.length?r.padEnd(t,"x"):r}}}(e)}}function p(e,t){let r=t;return"number"==typeof e.minimum&&r<e.minimum&&(r=e.minimum),"number"==typeof e.maximum&&r>e.maximum&&(r=e.maximum),r}((e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0})})(u,{HttpAdapter:()=>ee,SseParser:()=>U,buildCollection:()=>x,buildEnvironment:()=>y,buildRunOptions:()=>L,createResolver:()=>Y,locateOperation:()=>Z,resolveServerUrl:()=>d,runWithPostman:()=>H}),module.exports=(e=u,a(r({},"__esModule",{value:!0}),e));var f=/(token|secret|password|passwd|apikey|api_key|credential|private)/i;function d(e,t){if(t.serverUrl)return m(t.serverUrl);const r=Array.isArray(e)&&e.length?e[0]:{url:"/"};let n="string"==typeof r?.url&&r.url?r.url:"/";const o=r?.variables&&"object"==typeof r.variables?r.variables:{};for(const[e,r]of Object.entries(o)){const o=t.serverVariables?.[e],s=r?.default??(Array.isArray(r?.enum)&&r.enum.length?r.enum[0]:""),i=void 0!==o?o:s;n=n.split(`{${e}}`).join(String(i??""))}return n=n.replace(/\{[^}]*\}/g,""),m(n)}function m(e){return e.replace(/\/+$/,"")||e}function y(e,t,r={}){const n=[{key:"baseUrl",value:t,type:"default",enabled:!0},...Object.entries(r??{}).filter(([e])=>"baseUrl"!==e).map(([e,t])=>({key:e,value:null==t?"":String(t),type:f.test(e)?"secret":"default",enabled:!0}))];return{id:`protokit-env-${Date.now().toString(36)}`,name:e,values:n,_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"];function b(e,t){const r=Object.entries(t?.header??{}).find(([e])=>"accept"===e.toLowerCase())?.[1];if("string"==typeof r&&r.toLowerCase().includes("text/event-stream"))return!0;const n=e?.responses;if(!n||"object"!=typeof n)return!1;for(const e of Object.values(n)){const t=e?.content;if(t&&"object"==typeof t)for(const[e,r]of Object.entries(t)){const t=e.toLowerCase();if(t.startsWith("text/event-stream"))return!0;if(r&&"object"==typeof r.itemSchema&&h.some(e=>t.startsWith(e)))return!0}}return!1}function g(e){return!!e&&/text\/event-stream/i.test(e)}function v(e){if(!e)return!1;const t=e.toLowerCase();return h.some(e=>t.includes(e))}function j(e){if(!e)return[];return(Array.isArray(e)?e:[e]).filter(e=>!!e&&null!=e.exec)}function w(e,t){return t.map((t,r)=>{return{listen:e,script:{id:t.id??`protokit-${e}-${r}`,type:"text/javascript",exec:(n=t.exec,Array.isArray(n)?n.map(e=>String(e)):String(n).split(/\r?\n/))}};var n}).filter(e=>e.script.exec.some(e=>e.trim().length>0))}function O(e){const t=e?.["x-postman-scripts"];if(!t||"object"!=typeof t)return{pre:[],test:[]};const r=e=>null==e?[]:"string"==typeof e?[{exec:e}]:Array.isArray(e)?e.length?"string"==typeof e[0]?[{exec:e}]:e.filter(e=>e&&null!=e.exec):[]:"object"==typeof e&&null!=e.exec?[e]:[];return{pre:r(t.preRequest??t.prerequest??t.collectionPreRequest),test:r(t.test??t.tests??t.collectionTest)}}var S=new Set(["GET","PUT","POST","DELETE","OPTIONS","HEAD","PATCH","TRACE"]);function A(e,t){const r=e.name,n=e.style??"form",o=e.explode??"form"===n;if(Array.isArray(t)){if(o)return t.map(e=>({key:r,value:k(e)}));const e="spaceDelimited"===n?" ":"pipeDelimited"===n?"|":",";return[{key:r,value:t.map(k).join(e)}]}if(t&&"object"==typeof t){const e=Object.entries(t);return"deepObject"===n?e.map(([e,t])=>({key:`${r}[${e}]`,value:k(t)})):o?e.map(([e,t])=>({key:e,value:k(t)})):[{key:r,value:e.flatMap(([e,t])=>[e,k(t)]).join(",")}]}return[{key:r,value:k(t)}]}function k(e){if(null==e)return"";if("object"==typeof e)try{return JSON.stringify(e)}catch{return String(e)}return String(e)}function x(e,t,r){const n=r.values??{},o=d(e.servers,r),s=function(e,t){if(t?.contentType)return t.contentType;const r=e?.requestBody?.content;if(!r||"object"!=typeof r)return;const n=Object.keys(r);return n.length?n.find(e=>e.includes("json"))??n[0]:void 0}(e.operation,n),i=[];for(const t of e.parameters.filter(e=>"path"===e.in)){const e=n.path?.[t.name],r=void 0!==e?e:l(t.schema??{});i.push({key:t.name,value:k(r)})}const a=e.path.replace(/^\//,"").split("/").filter(e=>e.length>0).map(e=>e.replace(/\{([^}]+)\}/g,(e,t)=>`:${t}`)),c=[],u=new Set;for(const t of e.parameters.filter(e=>"query"===e.in)){u.add(t.name);const e=null!=n.query&&Object.prototype.hasOwnProperty.call(n.query,t.name)?n.query[t.name]:t.required?l(t.schema??{}):void 0;null!=e?c.push(...A(t,e)):t.required||c.push({key:t.name,value:"",disabled:!0})}for(const[e,t]of Object.entries(n.query??{}))u.has(e)||null==t||c.push({key:e,value:k(t)});const p=[],f=new Set,m=(e,t)=>{const r=e.toLowerCase();f.has(r)||(f.add(r),p.push({key:e,value:t}))};for(const[e,t]of Object.entries(n.header??{}))null!=t&&m(e,k(t));for(const t of e.parameters.filter(e=>"header"===e.in)){if(/^(accept|content-type|authorization)$/i.test(t.name))continue;const e=t.required?l(t.schema??{}):void 0;null!=e&&""!==e&&m(t.name,k(e))}s&&m("Content-Type",s);const y=function(e){const t=new Set,r=e?.responses;if(!r||"object"!=typeof r)return;for(const e of Object.values(r))for(const r of Object.keys(e?.content??{}))"*/*"!==r&&t.add(r);if(!t.size)return;const n=Array.from(t);return n.sort((e,t)=>Number(t.toLowerCase().startsWith("text/event-stream"))-Number(e.toLowerCase().startsWith("text/event-stream"))),n.slice(0,8).join(", ")}(e.operation);y&&m("Accept",y);const h=e.parameters.filter(e=>"cookie"===e.in),b=[];for(const e of h){const t=n.cookie?.[e.name],r=void 0!==t?t:e.required?l(e.schema??{}):void 0;null!=r&&b.push(`${e.name}=${encodeURIComponent(k(r))}`)}for(const[e,t]of Object.entries(n.cookie??{}))h.some(t=>t.name===e)||null==t||b.push(`${e}=${encodeURIComponent(k(t))}`);let g;b.length&&m("Cookie",b.join("; "));const v=e.operation.requestBody;if(v&&s){const e=v.content?.[s]?.schema,t=void 0!==n.body?n.body:l(e??{});g=s.includes("json")?{mode:"raw",raw:"string"==typeof t?t:JSON.stringify(t??{},null,2),options:{raw:{language:"json"}}}:s.includes("x-www-form-urlencoded")?{mode:"urlencoded",urlencoded:q(t).map(([e,t])=>({key:e,value:k(t),type:"text"}))}:s.includes("multipart/form-data")?{mode:"formdata",formdata:q(t).map(([e,t])=>t&&"object"==typeof t&&"__file"in t?{key:e,type:"file",src:String(t.__file)}:{key:e,type:"text",value:k(t)})}:s.includes("xml")||s.startsWith("text/")?{mode:"raw",raw:"string"==typeof t?t:k(t)}:{mode:"raw",raw:k(t)}}const x=c.filter(e=>!e.disabled);let E=`{{baseUrl}}/${a.join("/")}`;const T=[x.map(e=>`${encodeURIComponent(e.key)}=${encodeURIComponent(e.value)}`).join("&"),n.querystring?String(n.querystring).replace(/^\?/,""):""].filter(Boolean).join("&");T&&(E+=`?${T}`);const $={raw:E,host:["{{baseUrl}}"],path:a};c.length&&($.query=c),i.length&&($.variable=i);const C=e.method.toUpperCase(),I={method:C,header:p,url:$,description:e.operation.description??e.operation.summary};g&&(I.body=g);const P=function(e,t){const r=!1===t?.fromSpecExtensions?{pre:[],test:[]}:O(e);return[...w("prerequest",[...r.pre,...j(t?.preRequest)]),...w("test",[...r.test,...j(t?.test)])]}(e.operation,r.scripts),_=function(e,t){const r=!1===t?.fromSpecExtensions?{pre:[],test:[]}:O(e);return[...w("prerequest",[...r.pre,...j(t?.collectionPreRequest)]),...w("test",[...r.test,...j(t?.collectionTest)])]}(t,r.scripts),D=function(e){if(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:e.in??"header",type:"string"}]};default:return}}(r.auth),N={info:{_postman_id:`protokit-${Date.now().toString(36)}`,name:t?.info?.title??"OpenAPI Debug Session",description:t?.info?.description,schema:"https://schema.getpostman.com/json/collection/v2.1.0/collection.json"},item:[{name:e.operation.operationId??`${C} ${e.path}`,...P.length?{event:P}:{},request:I,response:[]}],variable:[{key:"baseUrl",value:o}]};return D&&(N.auth=D),_.length&&(N.event=_),{collection:N,baseUrl:o,contentType:s,isCustomMethod:!S.has(C)}}function q(e){return!e||"object"!=typeof e||Array.isArray(e)?[]:Object.entries(e)}var E=c(require("postman-runtime"),1),T=c(require("postman-collection"),1),$=class e extends Error{code;details;constructor(t,r,n){super(t),this.name="ProtoKitError",this.code=r,this.details=n,Object.setPrototypeOf(this,e.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,e)}};function C(e,t,r){return new $(t,e,r)}function I(e){if(e instanceof $)return{message:e.message,code:e.code,name:e.name};if(e instanceof Error)return{message:e.message,code:e.code,name:e.name};if("string"==typeof e)return{message:e};try{return{message:JSON.stringify(e)}}catch{return{message:String(e)}}}function P(e){const t=new WeakSet;return JSON.parse(JSON.stringify(e,(e,r)=>{if(r&&"object"==typeof r){if(t.has(r))return;t.add(r)}return r}))}function _(e,t){if(!t)return e;const r={...e};for(const[e,n]of Object.entries(t)){if(void 0===n)continue;const t=r[e];D(t)&&D(n)?r[e]=_(t,n):r[e]=n}return r}function D(e){if(null===e||"object"!=typeof e||Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function N(e){if(e)try{clearTimeout(e)}catch{}return null}var R=new Set(["[DONE]","DONE"]),U=class{buffer="";decoder=new TextDecoder("utf-8");lastEventId;sequence=0;push(e){if(null==e)return[];if("string"==typeof e)this.buffer+=e;else{const t=e instanceof Uint8Array?e:new Uint8Array(e);this.buffer+=this.decoder.decode(t,{stream:!0})}0===this.sequence&&65279===this.buffer.charCodeAt(0)&&(this.buffer=this.buffer.slice(1));const t=[],r=/\r\n\r\n|\n\n|\r\r/;for(;;){const e=r.exec(this.buffer);if(!e)break;const n=this.buffer.slice(0,e.index);this.buffer=this.buffer.slice(e.index+e[0].length);const o=this.parseBlock(n);o&&t.push(o)}return t}flush(){try{this.buffer+=this.decoder.decode()}catch{}const e=this.buffer;if(this.buffer="",!e.trim())return[];const t=this.parseBlock(e);return t?[t]:[]}reset(){this.buffer="",this.lastEventId=void 0,this.sequence=0}parseBlock(e){const t=e.split(/\r\n|\n|\r/),r=[],n={data:"",receivedAt:Date.now(),direction:"in"};let o=!1;for(const e of t){if(""===e)continue;if(e.startsWith(":"))continue;const t=e.indexOf(":"),s=-1===t?e:e.slice(0,t);let i=-1===t?"":e.slice(t+1);switch(i.startsWith(" ")&&(i=i.slice(1)),s){case"data":r.push(i),o=!0;break;case"event":n.event=i,o=!0;break;case"id":i.includes("\0")||(n.id=i,this.lastEventId=i),o=!0;break;case"retry":{const e=Number(i);Number.isInteger(e)&&e>=0&&(n.retry=e),o=!0;break}}}if(!o)return null;n.data=r.join("\n"),void 0===n.id&&void 0!==this.lastEventId&&(n.id=this.lastEventId);const s=n.data.trim();if(s&&!R.has(s))try{n.parsed=JSON.parse(n.data)}catch{}return this.sequence+=1,n}},M=c(require("postman-collection"),1);function B(e,t=[]){const r=[...t,...Object.entries(e??{}).map(([e,t])=>({key:e,value:null==t?"":String(t)}))],n=new Map;for(const e of r)n.set(e.key,e);return new M.default.VariableScope({values:Array.from(n.values())})}function L(e,t){const r=e.runner?.timeout?.request??e.timeout??3e4,n=_({iterationCount:1,stopOnError:!1,abortOnError:!1,stopOnFailure:!1,abortOnFailure:!1,timeout:{request:r,script:15e3,global:r+(t.streaming?e.maxStreamMs??3e4:0)+15e3},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}},{}),o=_(n,e.runner??{});return o.environment||(o.environment=B(e.variables,[{key:"baseUrl",value:t.baseUrl}])),!o.globals&&e.globals&&(o.globals=B(e.globals)),!o.localVariables&&e.localVariables&&(o.localVariables=B(e.localVariables)),Array.isArray(o.data)&&o.data.length&&void 0===e.runner?.iterationCount&&(o.iterationCount=o.data.length),o}function W(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 J(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)e&&!1!==e.enabled&&null!=e.key&&(n[String(e.key)]=null==e.value?"":String(e.value));return n}catch{return}}function F(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 P(t)}catch{return}}function H(e,t){const r=function(){let e,t,r=!1;return{promise:new Promise((r,n)=>{e=r,t=n}),get settled(){return r},resolve(t){r||(r=!0,e(t))},reject(e){r||(r=!0,t(e))}}}(),n=Date.now();let o,s=e.streamingHint,i=!1,a=!1;const c=new U,u=[],l=[];let p=0;const f={prerequest:[],test:[],assertions:[],console:[],passed:!0,skipped:!1},d=[];let m=null,y=null,h=null,b=null;const j=t.maxEvents??100,w=t.maxStreamMs??3e4,O=t.runner?.timeout?.request??t.timeout??3e4,S=e=>{if(!i){i=!0,a=!0,f.console.push({level:"debug",messages:[`[protokit] stream sampling stopped: ${e}`],at:Date.now()});try{y?.abort?.()}catch{}}},A=(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:J(e?.result?.environment),globals:J(e?.result?.globals),return:e?.result?.return}),k=()=>{if(h=N(h),b=N(b),s)for(const e of c.flush())u.length<j&&(u.push(e),z(()=>t.onEvent?.(e)));if(m)s&&(m.response.events=u,a&&(m.response.truncated=!0));else{const e=Date.now();m={protocol:s?"sse":"http",request:{method:"",url:"",headers:{}},response:{status:i&&u.length?200:0,statusText:i?"Stream sampling stopped":"No response received",headers:{},contentType:s?"text/event-stream":void 0,...s?{events:u}:{},timings:{startedAt:n,endedAt:e,durationMs:e-n,firstByteMs:o?o-n:void 0},sizeBytes:p,...a?{truncated:!0}:{}},...i&&u.length?{}:{error:{message:"Runner finished without a response"}}}}m.scripts=f,r.resolve(m)};let x,q,$;b=setTimeout(()=>{if(!r.settled){f.console.push({level:"error",messages:["[protokit] hard timeout reached, forcing completion"],at:Date.now()});try{y?.abort?.()}catch{}a=!0,k()}},O+w+3e4),"object"==typeof b&&"function"==typeof b.unref&&b.unref();try{x=new T.default.Collection(P(e.collectionJson))}catch(e){return b=N(b),Promise.reject(C("BAD_COLLECTION",`Failed to construct collection: ${I(e).message}`,e))}try{q=L(t,{baseUrl:e.baseUrl,streaming:e.streamingHint})}catch(e){return b=N(b),Promise.reject(C("BAD_RUN_OPTIONS",`Failed to build runtime options: ${I(e).message}`,e))}try{$=new E.default.Runner}catch(e){return b=N(b),Promise.reject(C("RUNTIME_INIT",`Failed to create runner: ${I(e).message}`,e))}return $.run(x,q,(e,O)=>{if(e)return b=N(b),void r.reject(C("RUNTIME_INIT",e.message??"Runner initialization failed",e));y=O,O.start({console(e,r,...n){const o={level:"string"==typeof r?r:"log",messages:n,at:Date.now()};f.console.push(o),z(()=>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||(f.passed=!1),f.assertions.push(r),z(()=>t.onAssertion?.(r))}},prerequest(e,t,r){for(const e of r??[])f.prerequest.push(A(e,"prerequest"))},test(e,t,r){for(const e of r??[])f.test.push(A(e,"test"))},item(e,t,r,n,o){o?.isSkipped&&(f.skipped=!0)},responseStart(e,r,n){o=Date.now();const i=V(n,"content-type");(g(i)||v(i))&&(s=!0),z(()=>t.onResponseStart?.({status:n?.code??0,headers:W(n?.headers),contentType:i})),s&&!h&&(h=setTimeout(()=>S("maxStreamMs reached"),w),"object"==typeof h&&"function"==typeof h.unref&&h.unref())},responseData(e,r){if(i||null==r)return;let n;try{n=Buffer.isBuffer(r)?r:Buffer.from(r)}catch{return}if(p+=n.length,s)for(const e of c.push(n)){if(u.length>=j)return void S("maxEvents reached");if(u.push(e),z(()=>t.onEvent?.(e)),u.length>=j)return void S("maxEvents reached")}else l.push(n)},request(e,t,r,i,c,f){const y=Date.now(),h={method:i?.method??"",url:K(i),headers:W(i?.headers),body:F(i)};if(e)return void(m={protocol:s?"sse":"http",request:h,response:{status:0,statusText:"Request failed",headers:{},timings:{startedAt:n,endedAt:y,durationMs:y-n},sizeBytes:p},error:I(e),replays:d});const b=V(r,"content-type");let j,w;if((g(b)||v(b))&&(s=!0),!s){const e=l.length?Buffer.concat(l):r?.stream?Buffer.from(r.stream):Buffer.alloc(0);j=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"),w=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}}(j,b)}m={protocol:s?"sse":"http",request:h,response:{status:"number"==typeof r?.code?r.code:0,statusText:G(r),headers:W(r?.headers),contentType:b,...s?{events:u}:{body:w,text:j},timings:{startedAt:n,endedAt:y,durationMs:"number"==typeof r?.responseTime?r.responseTime:y-n,firstByteMs:o?o-n:void 0},sizeBytes:p||r?.responseSize||0,...a?{truncated:!0}:{}},cookies:Array.isArray(f)?f.map(e=>({name:String(e?.name??""),value:String(e?.value??""),domain:e?.domain,path:e?.path})):[],replays:d}},io(e,t,r,n,o){"http"===r?.type&&r.source&&"collection"!==r.source&&d.push({url:K(o),method:o?.method??"",status:"number"==typeof n?.code?n.code:0,reason:String(r.source)})},exception(e,t){f.console.push({level:"error",messages:[`[exception] ${I(t).message}`],at:Date.now()})},done(e){if(e&&!m&&!i)return h=N(h),b=N(b),void r.reject(C("RUNTIME_RUN",e.message??"Run failed",e));k()}})}),r.promise}function z(e){try{e()}catch{}}function V(e,t){try{const r=e?.headers?.get?.(t);return null==r?void 0:String(r)}catch{return}}function G(e){try{return String("function"==typeof e?.reason?e.reason()??"":e?.status??"")}catch{return""}}function K(e){try{return"function"==typeof e?.url?.toString?e.url.toString():""}catch{return""}}var X="__protokit_cycle__";function Y(e){const t=new Map;function r(t){if("string"!=typeof t||!t.startsWith("#/"))throw C("EXTERNAL_REF",`Only local $ref pointers are supported, got: ${t}`);let r=e;const n=t.slice(2).split("/");for(const e of n){if(null==r||"object"!=typeof r)throw C("BAD_REF",`Cannot resolve pointer "${t}"`);r=r[decodeURIComponent(e).replace(/~1/g,"/").replace(/~0/g,"~")]}if(void 0===r)throw C("BAD_REF",`Pointer "${t}" resolves to undefined`);return r}function n(e){let t=e;const n=new Set;let o=0;for(;t&&"object"==typeof t&&"string"==typeof t.$ref;){if(n.has(t.$ref)||++o>100)return{type:"object",[X]:!0};n.add(t.$ref),t=r(t.$ref)}return t}function o(e,t=0,r=new Set){if(null==e||"object"!=typeof e)return e;if(t>32)return{type:"object"};const s=n(e);if(null==s||"object"!=typeof s)return s;if(s[X])return{type:"object"};if(r.has(s))return{type:"object"};const i=new Set(r);if(i.add(s),Array.isArray(s))return s.map(e=>o(e,t+1,i));const a={};for(const[e,r]of Object.entries(s))e!==X&&(a[e]=o(r,t+1,i));return a}return{deref:n,deepDeref:function(e){const r=e&&"object"==typeof e?e.$ref:void 0;if("string"==typeof r&&t.has(r))return t.get(r);const n=o(e);return"string"==typeof r&&t.set(r,n),n},byPointer:r}}var Q=["get","put","post","delete","options","head","patch","trace","query"];function Z(e,t){if(!e||"object"!=typeof e)throw C("BAD_SPEC","spec must be an object");if("string"!=typeof e.openapi)throw C("BAD_SPEC","spec.openapi version string is required");if(!t||"object"!=typeof t)throw C("BAD_TARGET","target is required");const r=Y(e),n=e.paths;if(!n||"object"!=typeof n)throw C("BAD_SPEC","spec.paths is missing or invalid");const o=[];for(const[e,t]of Object.entries(n)){let n;try{n=r.deref(t)}catch{continue}if(!n||"object"!=typeof n)continue;for(const t of Q)n[t]&&"object"==typeof n[t]&&o.push({path:e,method:t,rawOperation:n[t],pathItem:n,isCustomMethod:!1});const s=n.additionalOperations;if(s&&"object"==typeof s)for(const[t,r]of Object.entries(s))r&&"object"==typeof r&&o.push({path:e,method:t.toLowerCase(),rawOperation:r,pathItem:n,isCustomMethod:!0})}if(!o.length)throw C("EMPTY_SPEC","The document does not declare any operation");let s;if(t.operationId){if(s=o.find(e=>{try{return r.deref(e.rawOperation)?.operationId===t.operationId}catch{return!1}}),!s)throw C("OP_NOT_FOUND",`operationId "${t.operationId}" was not found`)}else{if(!t.path||!t.method)throw C("BAD_TARGET","Provide either operationId, or both path and method");const e=String(t.method).toLowerCase();if(s=o.find(r=>r.path===t.path&&r.method===e),!s)throw C("OP_NOT_FOUND",`Operation "${String(t.method).toUpperCase()} ${t.path}" was not found`)}const i=r.deepDeref(s.rawOperation)??{},a=r.deref(s.pathItem)??{},c=new Map,u=e=>{if(Array.isArray(e))for(const t of e){let e;try{e=r.deepDeref(t)}catch{continue}e&&"string"==typeof e.name&&"string"==typeof e.in&&c.set(`${e.in}:${e.name}`,e)}};u(a.parameters),u(s.rawOperation.parameters);const l=Array.isArray(i.servers)&&i.servers.length&&i.servers||Array.isArray(a.servers)&&a.servers.length&&a.servers||Array.isArray(e.servers)&&e.servers.length&&e.servers||[{url:"/"}];return{path:s.path,method:s.method,isCustomMethod:s.isCustomMethod,operation:i,pathItem:a,parameters:Array.from(c.values()),servers:l,security:i.security??e.security}}var ee=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=x(e.located,e.spec,e.options);return{...t,environment:y(`${e.spec?.info?.title??"API"} Environment`,t.baseUrl,e.options.variables),streaming:b(e.located.operation,e.options.values)}}execute(e,t){return H({collectionJson:e.collection,baseUrl:e.baseUrl,streamingHint:e.streaming},t)}};
@@ -0,0 +1,86 @@
1
+ import { L as LocatedOperation, a as SendOptions, l as StreamEvent, h as RuntimeRunOptions, E as ExecResult, P as ProtocolAdapter, A as AdapterContext } from '../../protocol-58EyJAsY.cjs';
2
+ export { m as locateOperation } from '../../protocol-58EyJAsY.cjs';
3
+
4
+ interface BuiltCollection {
5
+ collection: Record<string, any>;
6
+ baseUrl: string;
7
+ contentType?: string;
8
+ isCustomMethod: boolean;
9
+ }
10
+ declare function buildCollection(located: LocatedOperation, spec: any, options: SendOptions): BuiltCollection;
11
+
12
+ /**
13
+ * Resolver for local JSON pointers. External references are rejected explicitly
14
+ * rather than silently producing an empty schema.
15
+ */
16
+ declare function createResolver(root: any): {
17
+ deref: <T = any>(node: any) => T;
18
+ deepDeref: (node: any) => any;
19
+ byPointer: (pointer: string) => any;
20
+ };
21
+
22
+ /** Resolve the effective base URL, expanding server variables. */
23
+ declare function resolveServerUrl(servers: any[], options: SendOptions): string;
24
+ declare function buildEnvironment(name: string, baseUrl: string, variables?: Record<string, string>): Record<string, any>;
25
+
26
+ /**
27
+ * Incremental Server-Sent Events parser following the WHATWG event stream rules.
28
+ * postman-runtime usually hands over complete events, but chunk boundaries are
29
+ * not guaranteed, so buffering is still required.
30
+ */
31
+ declare class SseParser {
32
+ private buffer;
33
+ private readonly decoder;
34
+ private lastEventId;
35
+ private sequence;
36
+ /** Feed a chunk and return every complete event it produced. */
37
+ push(chunk: Buffer | Uint8Array | string): StreamEvent[];
38
+ /** Emit whatever remains once the stream has ended. */
39
+ flush(): StreamEvent[];
40
+ reset(): void;
41
+ private parseBlock;
42
+ }
43
+
44
+ interface BuildRunOptionsInput {
45
+ baseUrl: string;
46
+ /** True when the operation is expected to stream, which relaxes the global timeout. */
47
+ streaming: boolean;
48
+ }
49
+ /**
50
+ * Compose the final postman-runtime options object.
51
+ *
52
+ * Precedence, lowest to highest:
53
+ * 1. Library defaults
54
+ * 2. Convenience fields on SendOptions (timeout, variables, globals, ...)
55
+ * 3. `options.runner` — every documented runtime option, passed straight through
56
+ *
57
+ * Scopes are only synthesized when the caller did not supply their own.
58
+ */
59
+ declare function buildRunOptions(options: SendOptions, input: BuildRunOptionsInput): RuntimeRunOptions;
60
+
61
+ interface RunInput {
62
+ collectionJson: any;
63
+ baseUrl: string;
64
+ /** Derived from the spec; the live content-type still has the final say. */
65
+ streamingHint: boolean;
66
+ }
67
+ declare function runWithPostman(input: RunInput, options: SendOptions): Promise<ExecResult>;
68
+
69
+ interface HttpPlan extends BuiltCollection {
70
+ environment: Record<string, any>;
71
+ streaming: boolean;
72
+ }
73
+ /**
74
+ * Default adapter for HTTP and Server-Sent Events.
75
+ * Both share a single postman-runtime execution path so that scripts,
76
+ * variable scopes, cookies and auth helpers behave identically.
77
+ */
78
+ declare class HttpAdapter implements ProtocolAdapter<HttpPlan> {
79
+ readonly name = "http";
80
+ /** Lowest priority: acts as the fallback when no other adapter claims the operation. */
81
+ supports(ctx: AdapterContext): number;
82
+ plan(ctx: AdapterContext): HttpPlan;
83
+ execute(plan: HttpPlan, options: SendOptions): Promise<ExecResult>;
84
+ }
85
+
86
+ export { HttpAdapter, type HttpPlan, SseParser, buildCollection, buildEnvironment, buildRunOptions, createResolver, resolveServerUrl, runWithPostman };
@@ -0,0 +1,86 @@
1
+ import { L as LocatedOperation, a as SendOptions, l as StreamEvent, h as RuntimeRunOptions, E as ExecResult, P as ProtocolAdapter, A as AdapterContext } from '../../protocol-58EyJAsY.js';
2
+ export { m as locateOperation } from '../../protocol-58EyJAsY.js';
3
+
4
+ interface BuiltCollection {
5
+ collection: Record<string, any>;
6
+ baseUrl: string;
7
+ contentType?: string;
8
+ isCustomMethod: boolean;
9
+ }
10
+ declare function buildCollection(located: LocatedOperation, spec: any, options: SendOptions): BuiltCollection;
11
+
12
+ /**
13
+ * Resolver for local JSON pointers. External references are rejected explicitly
14
+ * rather than silently producing an empty schema.
15
+ */
16
+ declare function createResolver(root: any): {
17
+ deref: <T = any>(node: any) => T;
18
+ deepDeref: (node: any) => any;
19
+ byPointer: (pointer: string) => any;
20
+ };
21
+
22
+ /** Resolve the effective base URL, expanding server variables. */
23
+ declare function resolveServerUrl(servers: any[], options: SendOptions): string;
24
+ declare function buildEnvironment(name: string, baseUrl: string, variables?: Record<string, string>): Record<string, any>;
25
+
26
+ /**
27
+ * Incremental Server-Sent Events parser following the WHATWG event stream rules.
28
+ * postman-runtime usually hands over complete events, but chunk boundaries are
29
+ * not guaranteed, so buffering is still required.
30
+ */
31
+ declare class SseParser {
32
+ private buffer;
33
+ private readonly decoder;
34
+ private lastEventId;
35
+ private sequence;
36
+ /** Feed a chunk and return every complete event it produced. */
37
+ push(chunk: Buffer | Uint8Array | string): StreamEvent[];
38
+ /** Emit whatever remains once the stream has ended. */
39
+ flush(): StreamEvent[];
40
+ reset(): void;
41
+ private parseBlock;
42
+ }
43
+
44
+ interface BuildRunOptionsInput {
45
+ baseUrl: string;
46
+ /** True when the operation is expected to stream, which relaxes the global timeout. */
47
+ streaming: boolean;
48
+ }
49
+ /**
50
+ * Compose the final postman-runtime options object.
51
+ *
52
+ * Precedence, lowest to highest:
53
+ * 1. Library defaults
54
+ * 2. Convenience fields on SendOptions (timeout, variables, globals, ...)
55
+ * 3. `options.runner` — every documented runtime option, passed straight through
56
+ *
57
+ * Scopes are only synthesized when the caller did not supply their own.
58
+ */
59
+ declare function buildRunOptions(options: SendOptions, input: BuildRunOptionsInput): RuntimeRunOptions;
60
+
61
+ interface RunInput {
62
+ collectionJson: any;
63
+ baseUrl: string;
64
+ /** Derived from the spec; the live content-type still has the final say. */
65
+ streamingHint: boolean;
66
+ }
67
+ declare function runWithPostman(input: RunInput, options: SendOptions): Promise<ExecResult>;
68
+
69
+ interface HttpPlan extends BuiltCollection {
70
+ environment: Record<string, any>;
71
+ streaming: boolean;
72
+ }
73
+ /**
74
+ * Default adapter for HTTP and Server-Sent Events.
75
+ * Both share a single postman-runtime execution path so that scripts,
76
+ * variable scopes, cookies and auth helpers behave identically.
77
+ */
78
+ declare class HttpAdapter implements ProtocolAdapter<HttpPlan> {
79
+ readonly name = "http";
80
+ /** Lowest priority: acts as the fallback when no other adapter claims the operation. */
81
+ supports(ctx: AdapterContext): number;
82
+ plan(ctx: AdapterContext): HttpPlan;
83
+ execute(plan: HttpPlan, options: SendOptions): Promise<ExecResult>;
84
+ }
85
+
86
+ export { HttpAdapter, type HttpPlan, SseParser, buildCollection, buildEnvironment, buildRunOptions, createResolver, resolveServerUrl, runWithPostman };