@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.
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +124 -0
- package/dist/index.d.ts +124 -0
- package/dist/index.js +1 -0
- package/dist/protocol-58EyJAsY.d.cts +372 -0
- package/dist/protocol-58EyJAsY.d.ts +372 -0
- package/dist/protocols/http/index.cjs +1 -0
- package/dist/protocols/http/index.d.cts +86 -0
- package/dist/protocols/http/index.d.ts +86 -0
- package/dist/protocols/http/index.js +1 -0
- package/dist/protocols/ws/index.cjs +1 -0
- package/dist/protocols/ws/index.d.cts +53 -0
- package/dist/protocols/ws/index.d.ts +53 -0
- package/dist/protocols/ws/index.js +1 -0
- package/package.json +83 -0
- package/readme.md +463 -0
|
@@ -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 };
|